[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tm-dev] Opening a connection in TerminalView programatically

I've raised a bug here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=392092

So we can continue discussion there and don't need to use the mailing list 
going forward.

Thanks for all your help,

Kris

----- Original Message -----
> Hi Kris,
> 
> OK. I see.
> 
> > If you think it would be worthwhile to add some api like this (and
> > maybe later also some more methods to programatically manage the
> > connection history as well), then this is something I might be
> > interested in creating a patch for.
> 
> Note that for Kepler, we plan to split the bundle into a view
> offering and a widget offering, for those projects who require the
> widget only. I think that would be a good chance too to add some
> basic API to the ITerminalViewConnectionManager and ITerminalView
> interface to allow opening a connection programmatically. So yes, it
> is for sure worthwhile to add some API to the view to enable your
> usage of it without the need to go through reflection. If you are
> willing to provide some patches, you are absolutly welcome to do so
> :).
> 
> Best regards, Uwe :)
> 
> 
> 
> > -----Original Message-----
> > From: tm-dev-bounces@xxxxxxxxxxx
> > [mailto:tm-dev-bounces@xxxxxxxxxxx] On Behalf Of Kris De
> > Volder
> > Sent: Montag, 15. Oktober 2012 20:06
> > To: TM project developer discussions
> > Subject: Re: [tm-dev] Opening a connection in TerminalView
> > programatically
> > 
> > Hi Uwe,
> > 
> > Thanks for the info. If I understand correctly, this instantiates
> > only a 'control' not a 'view'.
> > This is perhaps what we'll have to do eventually. And if we decide
> > to go that route, your info will be
> > very helpful.
> > 
> > However, I was hoping to just be able to plugin to the existing
> > terminal view.
> > I.e. I mean the class
> > 'org.eclipse.tm.internal.terminal.view.TerminalView'. This is a
> > complete UI to
> > manage terminal connections, not just a widget that still needs to
> > be placed inside of a view. It pretty
> > much does what we want.
> > 
> > So I think it would be nice if the 'TerminalView' provided some
> > simple public API to open connections
> > and manage them programatically (i.e so you can programmatically do
> > more or less the same stuff a
> > user can do via its UI).
> > I hope that you agree this is desirable, even if you probably don't
> > want to be the one to have to
> > implement it :-)
> > 
> > I couldn't really figure out how to do what I wanted with the
> > available API (on the TerminalView class)
> > but I came up with this hacky (yuck! :-) piece of code that works:
> > 
> > 	private static Object call(Class<?> cls, String name, Class<?>[]
> > 	types, Object obj, Object... args)
> > {
> > 		try {
> > 			Method m = cls.getDeclaredMethod(name, types);
> > 			m.setAccessible(true);
> > 			return m.invoke(obj, args);
> > 		} catch (Exception e) {
> > 			throw new Error(e);
> > 		}
> > 	}
> > 
> > 	/**
> > 	 * Programatically open a new terminal for a given terminal
> > 	 connector (i.e. instead of
> > 	 * popping up a settings dialog to fill in connection details, the
> > 	 connector
> > 	 * should already have all its details pre-configured by the
> > 	 caller.
> > 	 */
> > 	public static void newTerminal(TerminalView tv, ITerminalConnector
> > 	c) {
> > 		//tv.setupControls();
> > 		call(TerminalView.class, "setupControls", new Class[0], tv);
> > 		tv.setCommandInputField(true);
> > 		if(c!=null) {
> > 			//tv.setConnector(c);
> > 			call(TerminalView.class, "setConnector", new Class<?>[]
> > {ITerminalConnector.class}, tv, c);
> > 			tv.onTerminalConnect();
> > 		}
> > 	}
> > 
> > Originally, I had this 'newTerminal' method added as an instance
> > method in the TerminalView class.
> > But I decided to move it into our own code base for now and use
> > reflection hackery. But I could
> > imagine contributing a method like that as a small patch instead.
> > 
> > With this method in place, it is possible for me to create a
> > pre-configured 'ITerminalConnector'
> > instance and ask the terminal view to open a terminal with that
> > 'UI-less' connector.
> > 
> > If you think it would be worthwhile to add some api like this (and
> > maybe later also some more
> > methods to programatically manage the connection history as well),
> > then this is something I might be
> > interested in creating a patch for.
> > 
> > Kris
> > 
> > ----- Original Message -----
> > 
> > > Hi Kris,
> > 
> > > In short, the method to create a is the following
> > 
> > > ITerminalViewControl terminal = TerminalViewControlFactory.
> > > makeControl (terminalListener, parent, new ITerminalConnector[] {
> > > connector }, true );
> > 
> > > terminal.setConnector(connector);
> > > terminal.connectTerminal();
> > 
> > > You are right that all this is living in internal packages, but
> > > as a
> > > matter of fact, it is the terminal API. Creating a public API is
> > > tracked in bugzilla
> > > https://bugs.eclipse.org/bugs/show_bug.cgi?id=259271 , but I
> > > doubt
> > > that this will ever happen, at least not without creating a âTM
> > > Terminal 4.0â.
> > 
> > > If you need a closer look to the usage of the above methods, it
> > > is
> > > from o.e.tcf.te.ui.terminals.tabs.TabFolderManager. The Target
> > > Explorer is providing a tabbed terminal view on top of the TM
> > > terminal
> > > widget. And the Target Explorers âRemote Applicationâ
> > > launch configuration type is using the Terminal for presenting
> > > the
> > > remote I/O of the application. So you might be able to get some
> > > ideas
> > > from there.
> > 
> > > And any kind of contribution will be always welcome.
> > 
> > > Best regards, Uwe J
> > 
> > > From: tm-dev-bounces@xxxxxxxxxxx
> > > [mailto:tm-dev-bounces@xxxxxxxxxxx]
> > > On Behalf Of Kris De Volder
> > > Sent: Freitag, 12. Oktober 2012 21:28
> > > To: tm-dev@xxxxxxxxxxx
> > > Subject: [tm-dev] Opening a connection in TerminalView
> > > programatically
> > 
> > > Hi all, I'm trying to reuse the TerminalView in our Grails
> > > tooling
> > > (see https://github.com/SpringSource/grails-ide ).
> > > We want to use this to launch and connect to an external grails
> > > process and display the output of this process (uses ANSI to make
> > > some
> > > colored text etc).
> > 
> > > I was pretty quickly able to create a new GrailsTerminalConnector
> > > with
> > > its own 'settings page' to allow a user to connect to the grails
> > > process.
> > > So I was pretty pleased with how nice and easy this was.
> > 
> > > Unfortunately, this is not precisely what we want. What we want
> > > is a
> > > 'UI-less' connection that is programmatically instantiated by our
> > > tools whenever they execute a grails command. I'm really stuck.
> > > Looking around the code reading comments etc. it seems like there
> > > is
> > > clearly the intention for this to be possible. E.g
> > > - the 'hidden' attribute on the extension point
> > > - some comments on the
> > > 'org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector.makeSettingsPage()'
> > > method talk about 'UI-less' connectors.
> > 
> > > However, as far as I've been able to figure out the methods of
> > > terminal view for opening connection programmatically are simple
> > > not
> > > available or private.
> > 
> > > Maybe I'm missing something and/or not looking in the right
> > > place?
> > 
> > > If it is possible, I would appreciate a pointer on how to work
> > > with
> > > 'UI-less' TerminalConnector instances. (E.g. a pointer to some
> > > code
> > > doing this in one of the projects would help a lot).
> > 
> > > If this is in fact not (yet) possible, I would be interested in
> > > making
> > > it possible by preparing a patch (but before jumping into that,
> > > I'd
> > > figure I'd at least ask here and get some input).
> > 
> > > Thanks for your time,
> > 
> > > Kris De Volder
> > > _______________________________________________
> > > tm-dev mailing list
> > > tm-dev@xxxxxxxxxxx
> > > http://dev.eclipse.org/mailman/listinfo/tm-dev
> > _______________________________________________
> > tm-dev mailing list
> > tm-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/tm-dev
> _______________________________________________
> tm-dev mailing list
> tm-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/tm-dev
>