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.
+ *
+ * The default implementation constructs a title like "SSH @ host (Start time) ".
+ *
+ * @return The terminal title string or null
.
+ */
+ private String getTerminalTitle(Map 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 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;
+ }
+}
diff --git a/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/launcher/RemoteMementoHandler.java b/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/launcher/RemoteMementoHandler.java
new file mode 100644
index 00000000000..92db0a543d1
--- /dev/null
+++ b/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/launcher/RemoteMementoHandler.java
@@ -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 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 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));
+ }
+}
diff --git a/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/internal/messages/Messages.java b/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/nls/Messages.java
similarity index 74%
rename from plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/internal/messages/Messages.java
rename to plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/nls/Messages.java
index cbd28f45ea6..b544abe7400 100644
--- a/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/internal/messages/Messages.java
+++ b/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/nls/Messages.java
@@ -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);
diff --git a/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/internal/messages/messages.properties b/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/nls/Messages.properties
similarity index 87%
rename from plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/internal/messages/messages.properties
rename to plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/nls/Messages.properties
index 0690775e652..427a2ef1018 100644
--- a/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/internal/messages/messages.properties
+++ b/plugins/org.eclipse.tm.terminal.connnector.remote/src/org/eclipse/tm/terminal/connector/remote/nls/Messages.properties
@@ -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