Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Target Management » Programatically creating a connection?
Programatically creating a connection? [message #569767] Thu, 16 August 2007 20:10
Bryan Hunt is currently offline Bryan Hunt
Messages: 346
Registered: July 2009
Senior Member
I need to programatically show a terminal and create a connection
without user input except for maybe a password and even that's a maybe.
I've managed to get an ssh connection to work but I had to modify the
SshSettings.java. Here are my changes:

public void load(ISettingsStore store)
{
fHost = store.get("Host");//$NON-NLS-1$
fUser = store.get("User");//$NON-NLS-1$
fPort = store.get("Port");//$NON-NLS-1$
fPassword = store.get("Password");//$NON-NLS-1$
fTimeout = store.get("Timeout");//$NON-NLS-1$
}


And here is how I'm creating my terminal view:

package test.terminal;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
import org.eclipse.tm.internal.terminal.control.ITerminalViewContro l;
import org.eclipse.tm.internal.terminal.control.TerminalViewControl Factory;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalCo nnectorInfo;
import
org.eclipse.tm.internal.terminal.provisional.api.TerminalCon nectorExtension;
import

org.eclipse.tm.internal.terminal.provisional.api.TerminalSta te;
import org.eclipse.ui.part.ViewPart;

@SuppressWarnings("restriction")
public class TrackerTerminal extends ViewPart implements ITerminalListener
{
public void setState(TerminalState state)
{
if (state == TerminalState.CONNECTED)
{
terminal.pasteString("cd /tmp\n");
}
}

@Override
public void createPartControl(Composite parent)
{
ITerminalConnectorInfo[] connectors =
TerminalConnectorExtension.getTerminalConnectors();
terminal = TerminalViewControlFactory.makeControl(this, parent, connectors);
TerminalSettings settings = new TerminalSettings();
settings.put("Host", "****************");
settings.put("User", "*****");
settings.put("Password", "********");
settings.put("Port", "22");
settings.put("Timeout", "0");

for (ITerminalConnectorInfo element : connectors)
{
if
(element.getId().equals("org.eclipse.tm.internal.terminal.ssh.SshConnector "))
{
element.getConnector().load(settings);
terminal.setConnector(element);
}
}

terminal.connectTerminal();
}

@Override
public

void setFocus()
{
// TODO Auto-generated method stub

}

public void setTerminalTitle(String title)
{
setPartName(title);
}

private ITerminalViewControl terminal;
}

package test.terminal;

import java.util.Properties;

import org.eclipse.tm.internal.terminal.provisional.api.ISettingsSt ore;

@SuppressWarnings("restriction")
public class TerminalSettings implements ISettingsStore
{

public String get(String key)
{
return properties.getProperty(key);
}

public String get(String key, String defaultValue)
{
return properties.getProperty(key, defaultValue);
}

public void put(String key, String value)
{
properties.put(key, value);
}

private final Properties properties = new Properties();
}

As you can see, I'm using the API in a completely non-normal way. Is
there a better way to do this?

Bryan
Previous Topic:RSE 2.0.0 (TM 2.0.1) FTP STOR ignores ASCII/binary preferences saving remote files
Next Topic:Programatically creating a connection?
Goto Forum:
  


Current Time: Tue Sep 16 17:33:02 GMT 2014

Powered by FUDForum. Page generated in 0.14264 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software