mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Remote: Contribute remote terminal connector to "Terminals" view
This commit is contained in:
parent
d9130f679c
commit
3b3cc4ae76
12 changed files with 426 additions and 18 deletions
|
@ -12,10 +12,17 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.remote.ui,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.swt,
|
||||
org.eclipse.jface
|
||||
org.eclipse.jface,
|
||||
org.eclipse.tm.terminal.view.core;bundle-version="4.0.0";resolution:=optional,
|
||||
org.eclipse.tm.terminal.view.ui;bundle-version="4.0.0";resolution:=optional,
|
||||
org.eclipse.core.expressions
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Export-Package: org.eclipse.tm.terminal.connector.remote,
|
||||
org.eclipse.tm.terminal.connector.remote.internal;x-internal:=true
|
||||
org.eclipse.tm.terminal.connector.remote.controls,
|
||||
org.eclipse.tm.terminal.connector.remote.internal;x-internal:=true,
|
||||
org.eclipse.tm.terminal.connector.remote.internal.preferences;x-internal:=true,
|
||||
org.eclipse.tm.terminal.connector.remote.launcher,
|
||||
org.eclipse.tm.terminal.connector.remote.nls;x-internal:=true
|
||||
Bundle-Activator: org.eclipse.tm.terminal.connector.remote.internal.Activator
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-LazyStart: true
|
||||
|
|
|
@ -17,6 +17,26 @@
|
|||
id="org.eclipse.tm.terminal.connector.remote.RemoteConnector"
|
||||
class="org.eclipse.tm.terminal.connector.remote.internal.RemoteConnector"/>
|
||||
</extension>
|
||||
|
||||
<!-- Terminal launcher delegate contributions -->
|
||||
<extension point="org.eclipse.tm.terminal.view.ui.launcherDelegates">
|
||||
<delegate
|
||||
class="org.eclipse.tm.terminal.connector.remote.launcher.RemoteLauncherDelegate"
|
||||
id="org.eclipse.tm.terminal.connector.telnet.launcher.remote"
|
||||
label="Remote Terminal">
|
||||
<enablement>
|
||||
<with variable="selection">
|
||||
<count value="1"/>
|
||||
<iterate operator="and" ifEmpty="false">
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.tm.terminal.view.core.hasContextPropertiesProvider"
|
||||
value="true"/>
|
||||
</iterate>
|
||||
</with>
|
||||
</enablement>
|
||||
</delegate>
|
||||
</extension>
|
||||
|
||||
<!-- Preference contributions -->
|
||||
<extension point="org.eclipse.core.runtime.preferences">
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.connector.remote.controls;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.terminal.connector.remote.IRemoteSettings;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.RemoteConnector;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.RemoteSettings;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.RemoteSettingsPage;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
|
||||
import org.eclipse.tm.terminal.view.ui.panels.AbstractExtendedConfigurationPanel;
|
||||
|
||||
/**
|
||||
* Remote wizard configuration panel implementation.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class RemoteWizardConfigurationPanel extends AbstractExtendedConfigurationPanel {
|
||||
|
||||
public RemoteSettings remoteSettings;
|
||||
private ISettingsPage remoteSettingsPage;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param container The configuration panel container or <code>null</code>.
|
||||
*/
|
||||
public RemoteWizardConfigurationPanel(IConfigurationPanelContainer container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
public void setupPanel(Composite parent) {
|
||||
Composite panel = new Composite(parent, SWT.NONE);
|
||||
panel.setLayout(new GridLayout());
|
||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
panel.setLayoutData(data);
|
||||
|
||||
RemoteConnector conn = new RemoteConnector();
|
||||
remoteSettings = (RemoteSettings) conn.getRemoteSettings();
|
||||
|
||||
remoteSettingsPage = new RemoteSettingsPage(remoteSettings);
|
||||
if (remoteSettingsPage instanceof AbstractSettingsPage) {
|
||||
((AbstractSettingsPage)remoteSettingsPage).setHasControlDecoration(true);
|
||||
}
|
||||
remoteSettingsPage.createControl(panel);
|
||||
|
||||
// Add the listener to the settings page
|
||||
remoteSettingsPage.addListener(new ISettingsPage.Listener() {
|
||||
|
||||
@Override
|
||||
public void onSettingsPageChanged(Control control) {
|
||||
if (getContainer() != null) getContainer().validate();
|
||||
}
|
||||
});
|
||||
|
||||
// Create the encoding selection combo
|
||||
createEncodingUI(panel, true);
|
||||
|
||||
setControl(panel);
|
||||
}
|
||||
|
||||
/* (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;
|
||||
|
||||
String value = (String)data.get(IRemoteSettings.REMOTE_SERVICES);
|
||||
if (value != null) remoteSettings.setRemoteServices(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);
|
||||
|
||||
remoteSettingsPage.loadSettings();
|
||||
}
|
||||
|
||||
/* (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;
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected void fillSettingsForHost(String host){
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean)
|
||||
*/
|
||||
@Override
|
||||
protected void saveSettingsForHost(boolean add){
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#isValid()
|
||||
*/
|
||||
@Override
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
|
||||
saveSettingsForHost(true);
|
||||
super.doSaveWidgetValues(settings, idPrefix);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.panels.AbstractConfigurationPanel#getHostFromSettings()
|
||||
*/
|
||||
@Override
|
||||
protected String getHostFromSettings() {
|
||||
remoteSettingsPage.saveSettings();
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.messages.Messages;
|
||||
import org.eclipse.tm.terminal.connector.remote.nls.Messages;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
|||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.tm.terminal.connector.remote.IRemoteTerminalConstants;
|
||||
import org.eclipse.tm.terminal.connector.remote.IRemoteTerminalParser;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.messages.Messages;
|
||||
import org.eclipse.tm.terminal.connector.remote.nls.Messages;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class RemoteConnectionManager extends Job {
|
||||
|
@ -67,20 +67,20 @@ public class RemoteConnectionManager extends Job {
|
|||
|
||||
try {
|
||||
IRemoteServicesManager svcMgr = Activator.getService(IRemoteServicesManager.class);
|
||||
String connTypeId = connector.getSshSettings().getRemoteServices();
|
||||
String connTypeId = connector.getRemoteSettings().getRemoteServices();
|
||||
IRemoteConnectionType connType = svcMgr.getConnectionType(connTypeId);
|
||||
if (connType != null) {
|
||||
remoteConnection = connType.getConnection(connector.getSshSettings().getConnectionName());
|
||||
remoteConnection = connType.getConnection(connector.getRemoteSettings().getConnectionName());
|
||||
}
|
||||
if (remoteConnection == null) {
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.RemoteConnectionManager_0, connector.getSshSettings()
|
||||
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.getSshSettings()
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.RemoteConnectionManager_1, connector.getRemoteSettings()
|
||||
.getConnectionName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,12 +90,11 @@ public class RemoteConnector extends TerminalConnectorImpl {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the SSH Settings.
|
||||
* Return the Remote Settings.
|
||||
*
|
||||
* @return the settings for a concrete connection.
|
||||
* @since org.eclipse.tm.terminal.ssh 2.0 renamed from getTelnetSettings()
|
||||
*/
|
||||
public IRemoteSettings getSshSettings() {
|
||||
public IRemoteSettings getRemoteSettings() {
|
||||
return fSettings;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ package org.eclipse.tm.terminal.connector.remote.internal;
|
|||
|
||||
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -25,13 +27,19 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
|||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
|
||||
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
|
||||
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
|
||||
if (fRemoteConnectionWidget.getConnection() != null) {
|
||||
if (fRemoteConnectionWidget.getConnection().getConnectionType() != null) {
|
||||
fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
|
||||
}
|
||||
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSettings() {
|
||||
if (fTerminalSettings != null) {
|
||||
if (fTerminalSettings != null && fRemoteConnectionWidget != null && !fRemoteConnectionWidget.isDisposed()) {
|
||||
fRemoteConnectionWidget.setConnection(fTerminalSettings.getRemoteServices(), fTerminalSettings.getConnectionName());
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +53,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
|||
|
||||
@Override
|
||||
public boolean validateSettings() {
|
||||
if (fRemoteConnectionWidget.getConnection() == null) {
|
||||
if (fRemoteConnectionWidget == null || fRemoteConnectionWidget.isDisposed() || fRemoteConnectionWidget.getConnection() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -61,6 +69,12 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
|||
composite.setLayoutData(gridData);
|
||||
|
||||
fRemoteConnectionWidget = new RemoteConnectionWidget(composite, SWT.NONE, null, 0);
|
||||
fRemoteConnectionWidget.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
fireListeners(fRemoteConnectionWidget);
|
||||
}
|
||||
});
|
||||
loadSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.eclipse.jface.preference.StringFieldEditor;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tm.terminal.connector.remote.IRemoteTerminalConstants;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.Activator;
|
||||
import org.eclipse.tm.terminal.connector.remote.internal.messages.Messages;
|
||||
import org.eclipse.tm.terminal.connector.remote.nls.Messages;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.connector.remote.launcher;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
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.RemoteSettings;
|
||||
import org.eclipse.tm.terminal.connector.remote.nls.Messages;
|
||||
import org.eclipse.tm.terminal.view.core.TerminalServiceFactory;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.ITerminalService;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanel;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IConfigurationPanelContainer;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler;
|
||||
import org.eclipse.tm.terminal.view.ui.internal.SettingsStore;
|
||||
import org.eclipse.tm.terminal.view.ui.launcher.AbstractLauncherDelegate;
|
||||
|
||||
/**
|
||||
* Remote launcher delegate implementation.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class RemoteLauncherDelegate extends AbstractLauncherDelegate {
|
||||
// The Remote terminal connection memento handler
|
||||
private final IMementoHandler mementoHandler = new RemoteMementoHandler();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#needsUserConfiguration()
|
||||
*/
|
||||
@Override
|
||||
public boolean needsUserConfiguration() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
@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
|
||||
if (terminal != null) {
|
||||
terminal.openConsole(properties, done);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the terminal title string.
|
||||
* <p>
|
||||
* The default implementation constructs a title like "SSH @ host (Start time) ".
|
||||
*
|
||||
* @return The terminal title string or <code>null</code>.
|
||||
*/
|
||||
private String getTerminalTitle(Map<String, Object> properties) {
|
||||
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 Messages.RemoteLauncherDelegate_terminalTitle_default;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (IMementoHandler.class.equals(adapter)) {
|
||||
return mementoHandler;
|
||||
}
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public ITerminalConnector createTerminalConnector(Map<String, Object> 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$
|
||||
|
||||
// Extract the remote properties
|
||||
String services = (String)properties.get(IRemoteSettings.REMOTE_SERVICES);
|
||||
String connection = (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);
|
||||
// And save the settings to the store
|
||||
remoteSettings.save(store);
|
||||
|
||||
// Construct the terminal connector instance
|
||||
ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId);
|
||||
if (connector != null) {
|
||||
// Apply default settings
|
||||
connector.setDefaultSettings();
|
||||
// And load the real settings
|
||||
connector.load(store);
|
||||
}
|
||||
|
||||
return connector;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012, 2015 Wind River Systems, Inc. and others. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.connector.remote.launcher;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.tm.terminal.connector.remote.IRemoteSettings;
|
||||
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
|
||||
import org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler;
|
||||
import org.eclipse.ui.IMemento;
|
||||
|
||||
/**
|
||||
* Telnet terminal connection memento handler implementation.
|
||||
*/
|
||||
public class RemoteMementoHandler implements IMementoHandler {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler#saveState(org.eclipse.ui.IMemento, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void saveState(IMemento memento, Map<String, Object> properties) {
|
||||
Assert.isNotNull(memento);
|
||||
Assert.isNotNull(properties);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.tm.terminal.view.ui.interfaces.IMementoHandler#restoreState(org.eclipse.ui.IMemento, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void restoreState(IMemento memento, Map<String, Object> properties) {
|
||||
Assert.isNotNull(memento);
|
||||
Assert.isNotNull(properties);
|
||||
|
||||
// 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(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING));
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.tm.terminal.connector.remote.internal.messages;
|
||||
package org.eclipse.tm.terminal.connector.remote.nls;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.tm.internal.terminal.remote.messages.messages"; //$NON-NLS-1$
|
||||
private static final String BUNDLE_NAME = "org.eclipse.tm.terminal.connector.remote.nls.Messages"; //$NON-NLS-1$
|
||||
|
||||
public static String RemoteConnectionManager_0;
|
||||
|
||||
|
@ -19,6 +19,10 @@ public class Messages extends NLS {
|
|||
public static String RemoteTerminalPreferencePage_0;
|
||||
|
||||
public static String TERMINAL_EXCEPTION;
|
||||
|
||||
public static String RemoteLauncherDelegate_terminalTitle;
|
||||
public static String RemoteLauncherDelegate_terminalTitle_default;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
|
@ -11,3 +11,6 @@ RemoteConnectionManager_0=Unable to create connection: {0}
|
|||
RemoteConnectionManager_1=Unable to to open connection: {0}
|
||||
RemoteTerminalPreferencePage_0=Initial Shell Command
|
||||
TERMINAL_EXCEPTION=Remote Terminal Exception
|
||||
|
||||
RemoteLauncherDelegate_terminalTitle={0} ({1})
|
||||
RemoteLauncherDelegate_terminalTitle_default=Remote Terminal
|
Loading…
Add table
Reference in a new issue