diff options
Diffstat (limited to 'terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui')
6 files changed, 600 insertions, 0 deletions
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/activator/UIPlugin.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/activator/UIPlugin.java new file mode 100644 index 000000000..a6ce8753c --- /dev/null +++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/activator/UIPlugin.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2011, 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 + * Max Weninger (Wind River) - [366374] [TERMINALS][TELNET] Add Telnet terminal support + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.telnet.activator; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.te.core.terminals.tracing.TraceHandler; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class UIPlugin extends AbstractUIPlugin { + // The shared instance + private static UIPlugin plugin; + // The trace handler instance + private static volatile TraceHandler traceHandler; + + /** + * The constructor + */ + public UIPlugin() { + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static UIPlugin getDefault() { + return plugin; + } + + /** + * Convenience method which returns the unique identifier of this plugin. + */ + public static String getUniqueIdentifier() { + if (getDefault() != null && getDefault().getBundle() != null) { + return getDefault().getBundle().getSymbolicName(); + } + return "org.eclipse.tcf.te.ui.terminals.telnet"; //$NON-NLS-1$ + } + + /** + * Returns the bundles trace handler. + * + * @return The bundles trace handler. + */ + public static TraceHandler getTraceHandler() { + if (traceHandler == null) { + traceHandler = new TraceHandler(getUniqueIdentifier()); + } + return traceHandler; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) + */ + @Override + protected void initializeImageRegistry(ImageRegistry registry) { + } + + /** + * Loads the image registered under the specified key from the image + * registry and returns the <code>Image</code> object instance. + * + * @param key The key the image is registered with. + * @return The <code>Image</code> object instance or <code>null</code>. + */ + public static Image getImage(String key) { + return getDefault().getImageRegistry().get(key); + } + + /** + * Loads the image registered under the specified key from the image + * registry and returns the <code>ImageDescriptor</code> object instance. + * + * @param key The key the image is registered with. + * @return The <code>ImageDescriptor</code> object instance or <code>null</code>. + */ + public static ImageDescriptor getImageDescriptor(String key) { + return getDefault().getImageRegistry().getDescriptor(key); + } +} diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java new file mode 100644 index 000000000..6a3e934e4 --- /dev/null +++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2011, 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 + * Max Weninger (Wind River) - [366374] [TERMINALS][TELNET] Add Telnet terminal support + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.telnet.controls; + +import java.util.HashMap; +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.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants; +import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanelContainer; +import org.eclipse.tcf.te.ui.terminals.panels.AbstractExtendedConfigurationPanel; +import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage; +import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage; +import org.eclipse.tm.internal.terminal.telnet.NetworkPortMap; +import org.eclipse.tm.internal.terminal.telnet.TelnetConnector; +import org.eclipse.tm.internal.terminal.telnet.TelnetSettings; +import org.eclipse.ui.forms.widgets.FormToolkit; + +/** + * telnet wizard configuration panel implementation. + */ +@SuppressWarnings("restriction") +public class TelnetWizardConfigurationPanel extends AbstractExtendedConfigurationPanel { + + public TelnetSettings telnetSettings; + private ISettingsPage telnetSettingsPage; + + /** + * Constructor. + * + * @param container The configuration panel container or <code>null</code>. + */ + public TelnetWizardConfigurationPanel(IConfigurationPanelContainer container) { + super(container); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel#setupPanel(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) + */ + @Override + public void setupPanel(Composite parent, FormToolkit toolkit) { + Composite panel = new Composite(parent, SWT.NONE); + panel.setLayout(new GridLayout()); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + panel.setLayoutData(data); + + // Create the host selection combo + if (isWithoutSelection()) createHostsUI(panel, true); + + TelnetConnector conn = new TelnetConnector(); + telnetSettings = (TelnetSettings) conn.getTelnetSettings(); + telnetSettings.setHost(getSelectionHost()); + // MWE otherwise we don't get a valid default selection of the combo + telnetSettings.setNetworkPort(NetworkPortMap.PROP_VALUETELNET); + + telnetSettingsPage = conn.makeSettingsPage(); + if (telnetSettingsPage instanceof AbstractSettingsPage) { + ((AbstractSettingsPage)telnetSettingsPage).setHasControlDecoration(true); + } + telnetSettingsPage.createControl(panel); + + // Add the listener to the settings page + telnetSettingsPage.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.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#setupData(java.util.Map) + */ + @Override + public void setupData(Map<String, Object> data) { + if (data == null || telnetSettings == null || telnetSettingsPage == null) return; + + String value = (String)data.get(ITerminalsConnectorConstants.PROP_IP_HOST); + if (value != null) telnetSettings.setHost(value); + + Object v = data.get(ITerminalsConnectorConstants.PROP_IP_PORT); + value = v != null ? v.toString() : null; + if (value != null) telnetSettings.setNetworkPort(value); + + v = data.get(ITerminalsConnectorConstants.PROP_TIMEOUT); + value = v != null ? v.toString() : null; + if (value != null) telnetSettings.setTimeout(value); + + value = (String)data.get(ITerminalsConnectorConstants.PROP_ENCODING); + if (value != null) setEncoding(value); + + telnetSettingsPage.loadSettings(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#extractData(java.util.Map) + */ + @Override + public void extractData(Map<String, Object> data) { + if (data == null) return; + + // set the terminal connector id for ssh + data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.internal.terminal.telnet.TelnetConnector"); //$NON-NLS-1$ + + telnetSettingsPage.saveSettings(); + data.put(ITerminalsConnectorConstants.PROP_IP_HOST,telnetSettings.getHost()); + data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(telnetSettings.getNetworkPort())); + data.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.valueOf(telnetSettings.getTimeout())); + data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding()); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#fillSettingsForHost(java.lang.String) + */ + @Override + protected void fillSettingsForHost(String host){ + if (host != null && host.length() != 0){ + if (hostSettingsMap.containsKey(host)){ + Map<String, String> hostSettings = hostSettingsMap.get(host); + if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST) != null) { + telnetSettings.setHost(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_HOST)); + } + if (hostSettings.get(ITerminalsConnectorConstants.PROP_IP_PORT) != null) { + telnetSettings.setNetworkPort(hostSettings.get(ITerminalsConnectorConstants.PROP_IP_PORT)); + } + if (hostSettings.get(ITerminalsConnectorConstants.PROP_TIMEOUT) != null) { + telnetSettings.setTimeout(hostSettings.get(ITerminalsConnectorConstants.PROP_TIMEOUT)); + } + if (hostSettings.get(ITerminalsConnectorConstants.PROP_ENCODING) != null) { + setEncoding(hostSettings.get(ITerminalsConnectorConstants.PROP_ENCODING)); + } + } else { + telnetSettings.setHost(getSelectionHost()); + // MWE otherwise we don't get a valid default selection of the combo + telnetSettings.setNetworkPort(NetworkPortMap.PROP_VALUETELNET); + } + // set settings in page + telnetSettingsPage.loadSettings(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#saveSettingsForHost(boolean) + */ + @Override + protected void saveSettingsForHost(boolean add){ + String host = getHostFromSettings(); + if(host != null && host.length() != 0) { + if (hostSettingsMap.containsKey(host)) { + Map<String, String> hostSettings=hostSettingsMap.get(host); + hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost()); + hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(telnetSettings.getNetworkPort())); + hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(telnetSettings.getTimeout())); + if (getEncoding() != null) { + hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding()); + } + } else if (add) { + Map<String, String> hostSettings=new HashMap<String, String>(); + hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost()); + hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(telnetSettings.getNetworkPort())); + hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(telnetSettings.getTimeout())); + if (getEncoding() != null) { + hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding()); + } + hostSettingsMap.put(host, hostSettings); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.panels.AbstractWizardConfigurationPanel#isValid() + */ + @Override + public boolean isValid(){ + return isEncodingValid() && telnetSettingsPage.validateSettings(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.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.tcf.te.ui.terminals.panels.AbstractConfigurationPanel#getHostFromSettings() + */ + @Override + protected String getHostFromSettings() { + telnetSettingsPage.saveSettings(); + return telnetSettings.getHost(); + } +} diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java new file mode 100644 index 000000000..6bb351c8f --- /dev/null +++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2011, 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 + * Max Weninger (Wind River) - [366374] [TERMINALS][TELNET] Add Telnet terminal support + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.telnet.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.tcf.te.core.terminals.TerminalServiceFactory; +import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService; +import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService.Done; +import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants; +import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanel; +import org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanelContainer; +import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler; +import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore; +import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate; +import org.eclipse.tcf.te.ui.terminals.telnet.controls.TelnetWizardConfigurationPanel; +import org.eclipse.tcf.te.ui.terminals.telnet.nls.Messages; +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.internal.terminal.telnet.TelnetSettings; + +/** + * Telnet launcher delegate implementation. + */ +@SuppressWarnings("restriction") +public class TelnetLauncherDelegate extends AbstractLauncherDelegate { + // The Telnet terminal connection memento handler + private final IMementoHandler mementoHandler = new TelnetMementoHandler(); + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#needsUserConfiguration() + */ + @Override + public boolean needsUserConfiguration() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#getPanel(org.eclipse.tcf.te.ui.terminals.interfaces.IConfigurationPanelContainer) + */ + @Override + public IConfigurationPanel getPanel(IConfigurationPanelContainer container) { + return new TelnetWizardConfigurationPanel(container); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#execute(java.util.Map, org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService.Done) + */ + @Override + public void execute(Map<String, Object> properties, 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); + } + + // Telnet terminals do have a disconnect button + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON)) { + properties.put(ITerminalsConnectorConstants.PROP_HAS_DISCONNECT_BUTTON, 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 host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST); + + if (host != null) { + DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); + String date = format.format(new Date(System.currentTimeMillis())); + return NLS.bind(Messages.TelnetLauncherDelegate_terminalTitle, new String[]{host, date}); + } + return Messages.TelnetLauncherDelegate_terminalTitle_default; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + if (IMementoHandler.class.equals(adapter)) { + return mementoHandler; + } + return super.getAdapter(adapter); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.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.internal.terminal.telnet.TelnetConnector"; //$NON-NLS-1$ + + // Extract the telnet properties + String host = (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST); + Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT); + String port = value != null ? value.toString() : null; + value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT); + String timeout = value != null ? value.toString() : null; + + int portOffset = 0; + if (properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) instanceof Integer) { + portOffset = ((Integer)properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET)).intValue(); + if (portOffset < 0) portOffset = 0; + } + + // The real port to connect to is port + portOffset + port = Integer.toString(Integer.decode(port).intValue() + portOffset); + + // Construct the terminal settings store + ISettingsStore store = new SettingsStore(); + + // Construct the telnet settings + TelnetSettings telnetSettings = new TelnetSettings(); + telnetSettings.setHost(host); + telnetSettings.setNetworkPort(port); + if (timeout != null) { + telnetSettings.setTimeout(timeout); + } + // And save the settings to the store + telnetSettings.save(store); + + // Construct the terminal connector instance + ITerminalConnector connector = TerminalConnectorExtension.makeTerminalConnector(connectorId); + if (connector != null) { + // Apply default settings + connector.makeSettingsPage(); + // And load the real settings + connector.load(store); + } + + return connector; + } +} diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java new file mode 100644 index 000000000..eaa0c6bde --- /dev/null +++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetMementoHandler.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * 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.tcf.te.ui.terminals.telnet.launcher; + +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants; +import org.eclipse.tcf.te.ui.terminals.interfaces.IMementoHandler; +import org.eclipse.ui.IMemento; + +/** + * Telnet terminal connection memento handler implementation. + */ +public class TelnetMementoHandler implements IMementoHandler { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.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(ITerminalsConnectorConstants.PROP_IP_HOST, (String)properties.get(ITerminalsConnectorConstants.PROP_IP_HOST)); + Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT); + memento.putInteger(ITerminalsConnectorConstants.PROP_IP_PORT, value instanceof Integer ? ((Integer)value).intValue() : -1); + value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT); + memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT, value instanceof Integer ? ((Integer)value).intValue() : -1); + memento.putString(ITerminalsConnectorConstants.PROP_ENCODING, (String)properties.get(ITerminalsConnectorConstants.PROP_ENCODING)); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.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(ITerminalsConnectorConstants.PROP_IP_HOST, memento.getString(ITerminalsConnectorConstants.PROP_IP_HOST)); + properties.put(ITerminalsConnectorConstants.PROP_IP_PORT, memento.getInteger(ITerminalsConnectorConstants.PROP_IP_PORT)); + properties.put(ITerminalsConnectorConstants.PROP_TIMEOUT, memento.getInteger(ITerminalsConnectorConstants.PROP_TIMEOUT)); + properties.put(ITerminalsConnectorConstants.PROP_ENCODING, memento.getString(ITerminalsConnectorConstants.PROP_ENCODING)); + } +} diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/nls/Messages.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/nls/Messages.java new file mode 100644 index 000000000..b1f817b86 --- /dev/null +++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/nls/Messages.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 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 + * Max Weninger (Wind River) - [366374] [TERMINALS][TELNET] Add Telnet terminal support + *******************************************************************************/ +package org.eclipse.tcf.te.ui.terminals.telnet.nls; + +import org.eclipse.osgi.util.NLS; + +/** + * Target Explorer TCF terminals extensions UI plug-in externalized strings management. + */ +public class Messages extends NLS { + + // The plug-in resource bundle name + private static final String BUNDLE_NAME = "org.eclipse.tcf.te.ui.terminals.telnet.nls.Messages"; //$NON-NLS-1$ + + /** + * Static constructor. + */ + static { + // Load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + // **** Declare externalized string id's down here ***** + + public static String TelnetLauncherDelegate_terminalTitle; + public static String TelnetLauncherDelegate_terminalTitle_default; +} diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/nls/Messages.properties b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/nls/Messages.properties new file mode 100644 index 000000000..f00e91243 --- /dev/null +++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/nls/Messages.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2012 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 +############################################################################### + +TelnetLauncherDelegate_terminalTitle=Telnet {0} ({1}) +TelnetLauncherDelegate_terminalTitle_default=Telnet Terminal |