1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Bugs 468857, 468858, 468859 - Various fixes for remote terminal.

Change-Id: I0b05724722a0fe55f45cad5c4edff9398fbb352d
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2015-05-29 18:05:17 -04:00
parent 4ea71eb57e
commit 34bddccabe
10 changed files with 219 additions and 144 deletions

View file

@ -9,19 +9,19 @@ package org.eclipse.tm.terminal.connector.remote;
public interface IRemoteSettings {
public static final String CONNECTION_NAME = "ConnectionName"; //$NON-NLS-1$
public static final String REMOTE_SERVICES = "RemoteServices"; //$NON-NLS-1$
public static final String CONNECTION_TYPE_ID = "ConnectionTypeId"; //$NON-NLS-1$
/**
* Get the host name or IP address of remote system to connect.
* Get the connection type ID for the connection (e.g. local, ssh, etc.)
*
* @return host name or IP address of the remote system.
* @return connection type ID.
*/
String getRemoteServices();
String getConnectionTypeId();
/**
* Get the login name for connecting to the remote system.
* Get the connection name for the target system.
*
* @return remote login name
* @return connection name
*/
String getConnectionName();
}

View file

@ -9,4 +9,5 @@ package org.eclipse.tm.terminal.connector.remote;
public interface IRemoteTerminalConstants {
public static final String PREF_TERMINAL_SHELL_COMMAND = "TERMINAL_SHELL_COMMAND"; //$NON-NLS-1$
public static final String PREF_TERMINAL_TYPE = "TERMINAL_TYPE"; //$NON-NLS-1$
}

View file

@ -33,19 +33,22 @@ import org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel
@SuppressWarnings("restriction")
public class RemoteWizardConfigurationPanel extends AbstractExtendedConfigurationPanel {
public RemoteSettings remoteSettings;
private RemoteSettings remoteSettings;
private ISettingsPage remoteSettingsPage;
/**
* Constructor.
*
* @param container The configuration panel container or <code>null</code>.
* @param container
* The configuration panel container or <code>null</code>.
*/
public RemoteWizardConfigurationPanel(IConfigurationPanelContainer container) {
super(container);
}
super(container);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
*/
@Override
@ -60,7 +63,7 @@ public class RemoteWizardConfigurationPanel extends AbstractExtendedConfiguratio
remoteSettingsPage = new RemoteSettingsPage(remoteSettings);
if (remoteSettingsPage instanceof AbstractSettingsPage) {
((AbstractSettingsPage)remoteSettingsPage).setHasControlDecoration(true);
((AbstractSettingsPage) remoteSettingsPage).setHasControlDecoration(true);
}
remoteSettingsPage.createControl(panel);
@ -69,7 +72,9 @@ public class RemoteWizardConfigurationPanel extends AbstractExtendedConfiguratio
@Override
public void onSettingsPageChanged(Control control) {
if (getContainer() != null) getContainer().validate();
if (getContainer() != null) {
getContainer().validate();
}
}
});
@ -79,79 +84,107 @@ public class RemoteWizardConfigurationPanel extends AbstractExtendedConfiguratio
setControl(panel);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#setupData(java.util.Map)
*/
@Override
public void setupData(Map<String, Object> data) {
if (data == null || remoteSettings == null || remoteSettingsPage == null) return;
if (data == null || remoteSettings == null || remoteSettingsPage == null) {
return;
}
String value = (String)data.get(IRemoteSettings.REMOTE_SERVICES);
if (value != null) remoteSettings.setRemoteServices(value);
String value = (String) data.get(IRemoteSettings.CONNECTION_TYPE_ID);
if (value != null) {
remoteSettings.setConnectionTypeId(value);
}
value = (String)data.get(IRemoteSettings.CONNECTION_NAME);
if (value != null) remoteSettings.setConnectionName(value);
value = (String) data.get(IRemoteSettings.CONNECTION_NAME);
if (value != null) {
remoteSettings.setConnectionName(value);
}
value = (String)data.get(ITerminalsConnectorConstants.PROP_ENCODING);
if (value != null) setEncoding(value);
value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
if (value != null) {
setEncoding(value);
}
remoteSettingsPage.loadSettings();
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#extractData(java.util.Map)
*/
@Override
public void extractData(Map<String, Object> data) {
if (data == null) return;
if (data == null) {
return;
}
// set the terminal connector id for remote
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.remote.RemoteConnector"); //$NON-NLS-1$
// set the terminal connector id for remote
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID,
"org.eclipse.tm.terminal.connector.remote.RemoteConnector"); //$NON-NLS-1$
remoteSettingsPage.saveSettings();
data.put(IRemoteSettings.REMOTE_SERVICES, remoteSettings.getRemoteServices());
data.put(IRemoteSettings.CONNECTION_NAME, remoteSettings.getConnectionName());
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
}
remoteSettingsPage.saveSettings();
/* (non-Javadoc)
data.put(IRemoteSettings.CONNECTION_TYPE_ID, remoteSettings.getConnectionTypeId());
data.put(IRemoteSettings.CONNECTION_NAME, remoteSettings.getConnectionName());
if (getEncoding() != null) {
data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
*/
@Override
protected void fillSettingsForHost(String host){
protected void fillSettingsForHost(String host) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
*/
@Override
protected void saveSettingsForHost(boolean add){
protected void saveSettingsForHost(boolean add) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
*/
@Override
public boolean isValid(){
public boolean isValid() {
return isEncodingValid() && remoteSettingsPage.validateSettings();
}
/* (non-Javadoc)
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.IDialogSettings, java.lang.String)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#doSaveWidgetValues(org.eclipse.jface.dialogs.
* IDialogSettings, java.lang.String)
*/
@Override
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
saveSettingsForHost(true);
super.doSaveWidgetValues(settings, idPrefix);
}
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
saveSettingsForHost(true);
super.doSaveWidgetValues(settings, idPrefix);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
*/
@Override
protected String getHostFromSettings() {
protected String getHostFromSettings() {
remoteSettingsPage.saveSettings();
return null;
}
return null;
}
}

View file

@ -28,6 +28,7 @@ import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.IRemoteProcessBuilder;
import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.IRemoteProcessTerminalService;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
@ -40,12 +41,14 @@ import org.eclipse.tm.terminal.connector.remote.nls.Messages;
public class RemoteConnectionManager extends Job {
private final static String PARSERS_EXTENSION_POINT = "parsers"; //$NON-NLS-1$
private final static String PARSER_ELEMENT = "parser"; //$NON-NLS-1$
private static int fgNo;
private final ITerminalControl control;
private final RemoteConnector connector;
private IRemoteTerminalParser parser;
private IRemoteProcess remoteProcess;
protected RemoteConnectionManager(RemoteConnector conn, ITerminalControl control) {
super("Remote Terminal-" + fgNo++); //$NON-NLS-1$
@ -62,31 +65,32 @@ public class RemoteConnectionManager extends Job {
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
IRemoteProcess remoteProcess = null;
IRemoteConnection remoteConnection = null;
try {
IRemoteServicesManager svcMgr = Activator.getService(IRemoteServicesManager.class);
String connTypeId = connector.getRemoteSettings().getRemoteServices();
String connTypeId = connector.getRemoteSettings().getConnectionTypeId();
IRemoteConnectionType connType = svcMgr.getConnectionType(connTypeId);
if (connType != null) {
remoteConnection = connType.getConnection(connector.getRemoteSettings().getConnectionName());
}
if (remoteConnection == null) {
throw new RemoteConnectionException(NLS.bind(Messages.RemoteConnectionManager_0, connector.getRemoteSettings()
.getConnectionName()));
throw new RemoteConnectionException(
NLS.bind(Messages.RemoteConnectionManager_0, connector.getRemoteSettings().getConnectionName()));
}
if (!remoteConnection.isOpen()) {
remoteConnection.open(monitor);
if (!remoteConnection.isOpen()) {
throw new RemoteConnectionException(NLS.bind(Messages.RemoteConnectionManager_1, connector.getRemoteSettings()
.getConnectionName()));
throw new RemoteConnectionException(
NLS.bind(Messages.RemoteConnectionManager_1, connector.getRemoteSettings().getConnectionName()));
}
}
if (parser != null) {
remoteProcess = parser.initialize(remoteConnection);
synchronized (this) {
remoteProcess = parser.initialize(remoteConnection);
}
} else {
/*
* Check the terminal shell command preference. If the preference is empty and we support a command shell,
@ -97,18 +101,23 @@ public class RemoteConnectionManager extends Job {
if (!("".equals(terminalShellCommand)) //$NON-NLS-1$
&& remoteConnection.hasService(IRemoteCommandShellService.class)) {
IRemoteCommandShellService cmdShellSvc = remoteConnection.getService(IRemoteCommandShellService.class);
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
synchronized (this) {
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
}
} else {
if ("".equals(terminalShellCommand)) { //$NON-NLS-1$
terminalShellCommand = "/bin/bash -l"; //$NON-NLS-1$
}
IRemoteProcessService procSvc = remoteConnection.getService(IRemoteProcessService.class);
IRemoteProcessBuilder processBuilder = procSvc.getProcessBuilder(new ArgumentParser(terminalShellCommand)
.getTokenList());
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
IRemoteProcessBuilder processBuilder = procSvc
.getProcessBuilder(new ArgumentParser(terminalShellCommand).getTokenList());
synchronized (this) {
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
}
}
}
control.setVT100LineWrapping(true);
connector.setInputStream(remoteProcess.getInputStream());
control.setState(TerminalState.CONNECTED);
control.setTerminalTitle(remoteConnection.getName());
@ -123,20 +132,27 @@ public class RemoteConnectionManager extends Job {
} finally {
// make sure the terminal is disconnected when the thread ends
connector.disconnect();
synchronized (this) {
if (remoteProcess != null && !remoteProcess.isCompleted()) {
remoteProcess.destroy();
}
}
}
return Status.OK_STATUS;
}
@Override
protected void canceling() {
super.canceling();
synchronized (this) {
if (remoteProcess != null && !remoteProcess.isCompleted()) {
remoteProcess.destroy();
}
}
}
public void setTerminalSize(int cols, int rows, int width, int height) {
// Enable for org.eclipse.remote v1.2
// if (remoteProcess instanceof IRemoteTerminal) {
// ((IRemoteTerminal) remoteProcess).setTerminalSize(cols, rows, width, height);
// }
if (remoteProcess != null) {
IRemoteProcessTerminalService termSvc = remoteProcess.getService(IRemoteProcessTerminalService.class);
if (termSvc != null) {
termSvc.setTerminalSize(cols, rows, width, height);
}
}
}
/**
@ -147,11 +163,8 @@ public class RemoteConnectionManager extends Job {
*/
private void readData(InputStream in) throws IOException {
byte[] buf = new byte[32 * 1024];
while (getState() == Job.RUNNING) {
int n = in.read(buf, 0, buf.length);
if (n <= 0) {
break;
}
int n;
while ((n = in.read(buf, 0, buf.length)) > 0) {
if (parser == null || parser.parse(buf)) {
control.getRemoteToTerminalOutputStream().write(buf, 0, n);
}

View file

@ -56,22 +56,6 @@ public class RemoteConnector extends TerminalConnectorImpl {
*/
@Override
public synchronized void doDisconnect() {
if (getInputStream() != null) {
try {
getInputStream().close();
} catch (Exception exception) {
Activator.log(exception);
}
}
if (getTerminalToRemoteStream() != null) {
try {
getTerminalToRemoteStream().close();
} catch (Exception exception) {
Activator.log(exception);
}
}
fConnection.cancel();
}
@ -117,7 +101,7 @@ public class RemoteConnector extends TerminalConnectorImpl {
public void setDefaultSettings() {
fSettings.load(new NullSettingsStore());
}
@Override
public void save(ISettingsStore store) {
fSettings.save(store);

View file

@ -12,22 +12,24 @@ import org.eclipse.tm.terminal.connector.remote.IRemoteSettings;
@SuppressWarnings("restriction")
public class RemoteSettings implements IRemoteSettings {
protected String fRemoteServices;
protected String fConnectionName;
protected String connectionTypeId;
protected String connectionName;
public RemoteSettings() {
}
@Override
public String getConnectionName() {
return fConnectionName;
return connectionName;
}
public String getRemoteServices() {
return fRemoteServices;
@Override
public String getConnectionTypeId() {
return connectionTypeId;
}
public String getSummary() {
return "Remote:" + getRemoteServices() + '_' + getConnectionName(); //$NON-NLS-1$
return "Remote:" + getConnectionTypeId() + '_' + getConnectionName(); //$NON-NLS-1$
}
@Override
@ -39,23 +41,23 @@ public class RemoteSettings implements IRemoteSettings {
* Load information into the RemoteSettings object.
*/
public void load(ISettingsStore store) {
fRemoteServices = store.get(REMOTE_SERVICES, ""); //$NON-NLS-1$
fConnectionName = store.get(CONNECTION_NAME, ""); //$NON-NLS-1$
connectionTypeId = store.get(CONNECTION_TYPE_ID, ""); //$NON-NLS-1$
connectionName = store.get(CONNECTION_NAME, ""); //$NON-NLS-1$
}
/**
* Extract information from the RemoteSettings object.
*/
public void save(ISettingsStore store) {
store.put(REMOTE_SERVICES, fRemoteServices);
store.put(CONNECTION_NAME, fConnectionName);
store.put(CONNECTION_TYPE_ID, connectionTypeId);
store.put(CONNECTION_NAME, connectionName);
}
public void setConnectionName(String name) {
fConnectionName = name;
connectionName = name;
}
public void setRemoteServices(String remoteServices) {
fRemoteServices = remoteServices;
public void setConnectionTypeId(String id) {
connectionTypeId = id;
}
}

View file

@ -30,7 +30,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
if (fRemoteConnectionWidget.getConnection() != null) {
if (fRemoteConnectionWidget.getConnection().getConnectionType() != null) {
fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
fTerminalSettings.setConnectionTypeId(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
}
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
}
@ -40,7 +40,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
@Override
public void loadSettings() {
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
fRemoteConnectionWidget.setConnection(fTerminalSettings.getRemoteServices(), fTerminalSettings.getConnectionName());
fRemoteConnectionWidget.setConnection(fTerminalSettings.getConnectionTypeId(), fTerminalSettings.getConnectionName());
}
}
@ -53,7 +53,8 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
@Override
public boolean validateSettings() {
if (fRemoteConnectionWidget == null || fRemoteConnectionWidget.isDisposed() || fRemoteConnectionWidget.getConnection() == null) {
if (fRemoteConnectionWidget == null || fRemoteConnectionWidget.isDisposed()
|| fRemoteConnectionWidget.getConnection() == null) {
return false;
}
return true;

View file

@ -20,8 +20,10 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class RemoteTerminalPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@Override
protected void createFieldEditors() {
Composite parent = getFieldEditorParent();
addField(new StringFieldEditor(IRemoteTerminalConstants.PREF_TERMINAL_TYPE, "Terminal Type", parent));
addField(new StringFieldEditor(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND,
Messages.RemoteTerminalPreferencePage_0, parent));
}
@ -31,6 +33,7 @@ public class RemoteTerminalPreferencePage extends FieldEditorPreferencePage impl
return new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.getUniqueIdentifier());
}
@Override
public void init(IWorkbench workbench) {
// Nothing
}

View file

@ -15,11 +15,15 @@ import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.osgi.util.NLS;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
import org.eclipse.tm.terminal.connector.remote.IRemoteSettings;
import org.eclipse.tm.terminal.connector.remote.controls.RemoteWizardConfigurationPanel;
import org.eclipse.tm.terminal.connector.remote.internal.Activator;
import org.eclipse.tm.terminal.connector.remote.internal.RemoteSettings;
import org.eclipse.tm.terminal.connector.remote.nls.Messages;
import org.eclipse.tm.terminal.view.core.TerminalServiceFactory;
@ -39,7 +43,9 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
// The Remote terminal connection memento handler
private final IMementoHandler mementoHandler = new RemoteMementoHandler();
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#needsUserConfiguration()
*/
@Override
@ -47,33 +53,27 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.terminal.view.ui.interfaces.
* IConfigurationPanelContainer)
*/
@Override
public IConfigurationPanel getPanel(IConfigurationPanelContainer container) {
return new RemoteWizardConfigurationPanel(container);
}
/* (non-Javadoc)
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#execute(java.util.Map, org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#execute(java.util.Map,
* org.eclipse.tm.terminal.view.core.interfaces.ITerminalService.Done)
*/
@Override
public void execute(Map<String, Object> properties, ITerminalService.Done done) {
Assert.isNotNull(properties);
// Set the terminal tab title
String terminalTitle = getTerminalTitle(properties);
if (terminalTitle != null) {
properties.put(ITerminalsConnectorConstants.PROP_TITLE, terminalTitle);
}
// For Telnet terminals, force a new terminal tab each time it is launched,
// if not set otherwise from outside
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW)) {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
}
// Get the terminal service
ITerminalService terminal = TerminalServiceFactory.getService();
// If not available, we cannot fulfill this request
@ -90,50 +90,56 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
* @return The terminal title string or <code>null</code>.
*/
private String getTerminalTitle(Map<String, Object> properties) {
String connection = (String)properties.get(IRemoteSettings.CONNECTION_NAME);
String connection = (String) properties.get(IRemoteSettings.CONNECTION_NAME);
if (connection != null) {
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
String date = format.format(new Date(System.currentTimeMillis()));
return NLS.bind(Messages.RemoteLauncherDelegate_terminalTitle, new String[]{connection, date});
return NLS.bind(Messages.RemoteLauncherDelegate_terminalTitle, new String[] { connection, date });
}
return Messages.RemoteLauncherDelegate_terminalTitle_default;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/
@SuppressWarnings("rawtypes")
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object getAdapter(Class adapter) {
if (IMementoHandler.class.equals(adapter)) {
return mementoHandler;
}
return super.getAdapter(adapter);
return super.getAdapter(adapter);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
*/
@Override
@Override
public ITerminalConnector createTerminalConnector(Map<String, Object> properties) {
Assert.isNotNull(properties);
Assert.isNotNull(properties);
// Check for the terminal connector id
String connectorId = (String)properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
if (connectorId == null) connectorId = "org.eclipse.tm.terminal.connector.remote.RemoteConnector"; //$NON-NLS-1$
// Check for the terminal connector id
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
if (connectorId == null) {
connectorId = "org.eclipse.tm.terminal.connector.remote.RemoteConnector"; //$NON-NLS-1$
}
// Extract the remote properties
String services = (String)properties.get(IRemoteSettings.REMOTE_SERVICES);
String connection = (String)properties.get(IRemoteSettings.CONNECTION_NAME);
String connTypeId = (String) properties.get(IRemoteSettings.CONNECTION_TYPE_ID);
String connName = (String) properties.get(IRemoteSettings.CONNECTION_NAME);
// Construct the terminal settings store
ISettingsStore store = new SettingsStore();
// Construct the remote settings
RemoteSettings remoteSettings = new RemoteSettings();
remoteSettings.setRemoteServices(services);
remoteSettings.setConnectionName(connection);
remoteSettings.setConnectionTypeId(connTypeId);
remoteSettings.setConnectionName(connName);
// And save the settings to the store
remoteSettings.save(store);
@ -146,6 +152,33 @@ public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
connector.load(store);
}
// Set the terminal tab title
String terminalTitle = getTerminalTitle(properties);
if (terminalTitle != null) {
properties.put(ITerminalsConnectorConstants.PROP_TITLE, terminalTitle);
}
// For Telnet terminals, force a new terminal tab each time it is launched,
// if not set otherwise from outside
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_FORCE_NEW)) {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
}
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_ENCODING)) {
IRemoteServicesManager svcMgr = Activator.getService(IRemoteServicesManager.class);
IRemoteConnectionType connType = svcMgr.getConnectionType(connTypeId);
if (connType != null) {
IRemoteConnection remoteConnection = connType.getConnection(connName);
if (remoteConnection != null && remoteConnection.isOpen()) {
properties.put(ITerminalsConnectorConstants.PROP_ENCODING,
remoteConnection.getProperty(IRemoteConnection.LOCALE_CHARMAP_PROPERTY));
}
}
}
properties.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, "/tmp"); //$NON-NLS-1$
return connector;
}
}

View file

@ -22,7 +22,9 @@ import org.eclipse.ui.IMemento;
*/
public class RemoteMementoHandler implements IMementoHandler {
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler#saveState(org.eclipse.ui.IMemento, java.util.Map)
*/
@Override
@ -32,12 +34,15 @@ public class RemoteMementoHandler implements IMementoHandler {
// Do not write the terminal title to the memento -> needs to
// be recreated at the time of restoration.
memento.putString(IRemoteSettings.CONNECTION_NAME, (String)properties.get(IRemoteSettings.CONNECTION_NAME));
memento.putString(IRemoteSettings.REMOTE_SERVICES, (String)properties.get(IRemoteSettings.REMOTE_SERVICES));
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING, (String)properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
memento.putString(IRemoteSettings.CONNECTION_NAME, (String) properties.get(IRemoteSettings.CONNECTION_NAME));
memento.putString(IRemoteSettings.CONNECTION_TYPE_ID, (String) properties.get(IRemoteSettings.CONNECTION_TYPE_ID));
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING,
(String) properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler#restoreState(org.eclipse.ui.IMemento, java.util.Map)
*/
@Override
@ -47,7 +52,7 @@ public class RemoteMementoHandler implements IMementoHandler {
// Restore the terminal properties from the memento
properties.put(IRemoteSettings.CONNECTION_NAME, memento.getString(IRemoteSettings.CONNECTION_NAME));
properties.put(IRemoteSettings.REMOTE_SERVICES, memento.getString(IRemoteSettings.REMOTE_SERVICES));
properties.put(IRemoteSettings.CONNECTION_TYPE_ID, memento.getString(IRemoteSettings.CONNECTION_TYPE_ID));
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
}
}