diff options
author | Uwe Stieber | 2015-02-13 08:44:53 +0000 |
---|---|---|
committer | Uwe Stieber | 2015-02-13 08:45:31 +0000 |
commit | b547c27009b3d95c8ecb60913d6b8342de210522 (patch) | |
tree | b991912da8163d69dd451fc04aa48f22b7ef201f | |
parent | 4cc0b421397e32939b944beb9e436279607afbb0 (diff) | |
download | org.eclipse.tcf-b547c27009b3d95c8ecb60913d6b8342de210522.tar.gz org.eclipse.tcf-b547c27009b3d95c8ecb60913d6b8342de210522.tar.xz org.eclipse.tcf-b547c27009b3d95c8ecb60913d6b8342de210522.zip |
Terminal: Merge launcher delegate and connector type. Remove unnecessary connector type extension point.
50 files changed, 552 insertions, 1433 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core.terminals/src/org/eclipse/tcf/te/core/terminals/interfaces/constants/ITerminalsConnectorConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.core.terminals/src/org/eclipse/tcf/te/core/terminals/interfaces/constants/ITerminalsConnectorConstants.java index 938f76cd4..0624d3622 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.core.terminals/src/org/eclipse/tcf/te/core/terminals/interfaces/constants/ITerminalsConnectorConstants.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.core.terminals/src/org/eclipse/tcf/te/core/terminals/interfaces/constants/ITerminalsConnectorConstants.java @@ -82,13 +82,6 @@ public interface ITerminalsConnectorConstants { public static final String PROP_DELEGATE_ID = "delegateId"; //$NON-NLS-1$ /** - * Property: Terminals connector type id. - * <p> - * Property Type: {@link String} - */ - public static final String PROP_CONNECTOR_TYPE_ID = "connector.type.id"; //$NON-NLS-1$ - - /** * Property: Specific terminal connector type id. Allows clients to * override the specifically used terminal connector * implementation for a given type. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java index 0e022f1c8..1be876f92 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java @@ -589,7 +589,7 @@ public class ProcessLauncher extends PlatformObject implements IProcessLauncher if (terminal != null) { // Create the terminal streams settings Map<String, Object> props = new HashMap<String, Object>(); - props.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.streams"); //$NON-NLS-1$ + props.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, "org.eclipse.tcf.te.ui.terminals.telnet.launcher.streams"); //$NON-NLS-1$ props.put(ITerminalsConnectorConstants.PROP_ID, "org.eclipse.tcf.te.ui.terminals.TerminalsView"); //$NON-NLS-1$ // Set the terminal tab title String terminalTitle = getTerminalTitle(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java index f90618117..8211a11f4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.core/src/org/eclipse/tcf/te/tcf/terminals/core/launcher/TerminalsLauncher.java @@ -426,9 +426,6 @@ public class TerminalsLauncher extends PlatformObject implements ITerminalsLaunc if (properties.getProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID) != null) { props.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, properties.getProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID)); } - if (properties.getProperty(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID) != null) { - props.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, properties.getProperty(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID)); - } if (properties.getProperty(ITerminalsConnectorConstants.PROP_ENCODING) != null) { props.put(ITerminalsConnectorConstants.PROP_ENCODING, properties.getProperty(ITerminalsConnectorConstants.PROP_ENCODING)); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.properties index a4c1315fa..4b35ac406 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.properties @@ -11,19 +11,15 @@ pluginName = Target Explorer, TCF Terminals Extensions UI providerName = Eclipse.org - Target Explorer -# ***** Terminal Connectors ***** +# ----- Terminal Connectors ----- TerminalConnector.terminal=TCF Terminals Connector (hidden) -# ***** Terminal Connector Types ***** - -TerminalsConnectorType.label=TCF Terminals Connector Type - -# ***** Terminal Launcher Delegates **** +# ----- Terminal Launcher Delegates ----- launcherDelegate.label=TCF Terminal -# ***** Command Contributions ***** +# ----- Command Contributions ----- command.launch.name=Open Terminal command.launch.label=&Open Terminal diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml index 2cf7615de..d93cba65b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/plugin.xml @@ -11,15 +11,6 @@ class="org.eclipse.tcf.te.tcf.terminals.ui.connector.TerminalsConnector"/> </extension> -<!-- Terminal connector type contributions --> - <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes"> - <connectorType - class="org.eclipse.tcf.te.tcf.terminals.ui.connector.TerminalsConnectorType" - id="org.eclipse.tcf.te.ui.terminals.type.terminals" - label="%TerminalsConnectorType.label"> - </connectorType> - </extension> - <!-- Terminals launcher delegate contributions --> <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> <delegate diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/connector/TerminalsConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/connector/TerminalsConnectorType.java deleted file mode 100644 index a173827a5..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/connector/TerminalsConnectorType.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ -package org.eclipse.tcf.te.tcf.terminals.ui.connector; - -import java.io.InputStream; -import java.io.OutputStream; -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.tcf.terminals.core.interfaces.launcher.ITerminalsLauncher; -import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType; -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; - -/** - * Terminals terminal connector type implementation. - */ -@SuppressWarnings("restriction") -public class TerminalsConnectorType extends AbstractConnectorType { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#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.tcf.te.tcf.terminals.ui.TerminalsConnector"; //$NON-NLS-1$ - - // Extract the streams properties - OutputStream stdin = (OutputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDIN); - InputStream stdout = (InputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT); - InputStream stderr = (InputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDERR); - Object value = properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO); - boolean localEcho = value instanceof Boolean ? ((Boolean)value).booleanValue() : false; - String lineSeparator = (String)properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR); - ITerminalsLauncher launcher = (ITerminalsLauncher)properties.get(ITerminalsConnectorConstants.PROP_DATA); - - // Construct the terminal settings store - ISettingsStore store = new SettingsStore(); - - // Construct the terminals settings - TerminalsSettings terminalsSettings = new TerminalsSettings(); - terminalsSettings.setStdinStream(stdin); - terminalsSettings.setStdoutStream(stdout); - terminalsSettings.setStderrStream(stderr); - terminalsSettings.setLocalEcho(localEcho); - terminalsSettings.setLineSeparator(lineSeparator); - terminalsSettings.setTerminalsLauncher(launcher); - // And save the settings to the store - terminalsSettings.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/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/controls/TerminalsConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/controls/TerminalsConfigurationPanel.java index 57064fcc5..485465a2c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/controls/TerminalsConfigurationPanel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/controls/TerminalsConfigurationPanel.java @@ -65,9 +65,6 @@ public class TerminalsConfigurationPanel extends AbstractExtendedConfigurationPa // set the terminal connector id for terminals (TCF) data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tcf.te.tcf.terminals.ui.TerminalsConnector"); //$NON-NLS-1$ - // set the connector type for terminals (TCF) - data.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.terminals"); //$NON-NLS-1$ - // Extract the encoding data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding()); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java index 858f7ab1e..e909bc548 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.terminals.ui/src/org/eclipse/tcf/te/tcf/terminals/ui/launcher/TerminalsLauncherDelegate.java @@ -9,6 +9,8 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.terminals.ui.launcher; +import java.io.InputStream; +import java.io.OutputStream; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; @@ -26,15 +28,21 @@ import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.terminals.core.interfaces.launcher.ITerminalsLauncher; import org.eclipse.tcf.te.tcf.terminals.core.launcher.TerminalsLauncher; +import org.eclipse.tcf.te.tcf.terminals.ui.connector.TerminalsSettings; import org.eclipse.tcf.te.tcf.terminals.ui.controls.TerminalsConfigurationPanel; 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.tm.internal.terminal.provisional.api.ISettingsStore; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension; /** * Terminals (TCF) launcher delegate implementation. */ +@SuppressWarnings("restriction") public class TerminalsLauncherDelegate extends AbstractLauncherDelegate { // The Terminals (TCF) terminal connection memento handler private final IMementoHandler mementoHandler = new TerminalsMementoHandler(); @@ -106,4 +114,50 @@ public class TerminalsLauncherDelegate extends AbstractLauncherDelegate { } 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.tcf.te.tcf.terminals.ui.TerminalsConnector"; //$NON-NLS-1$ + + // Extract the streams properties + OutputStream stdin = (OutputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDIN); + InputStream stdout = (InputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDOUT); + InputStream stderr = (InputStream)properties.get(ITerminalsConnectorConstants.PROP_STREAMS_STDERR); + Object value = properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO); + boolean localEcho = value instanceof Boolean ? ((Boolean)value).booleanValue() : false; + String lineSeparator = (String)properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR); + ITerminalsLauncher launcher = (ITerminalsLauncher)properties.get(ITerminalsConnectorConstants.PROP_DATA); + + // Construct the terminal settings store + ISettingsStore store = new SettingsStore(); + + // Construct the terminals settings + TerminalsSettings terminalsSettings = new TerminalsSettings(); + terminalsSettings.setStdinStream(stdin); + terminalsSettings.setStdoutStream(stdout); + terminalsSettings.setStderrStream(stderr); + terminalsSettings.setLocalEcho(localEcho); + terminalsSettings.setLineSeparator(lineSeparator); + terminalsSettings.setTerminalsLauncher(launcher); + // And save the settings to the store + terminalsSettings.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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/META-INF/MANIFEST.MF index 8c59ff792..a389bc2fc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/META-INF/MANIFEST.MF @@ -26,5 +26,4 @@ Export-Package: org.eclipse.tcf.te.ui.terminals.local.activator;x-internal:=true org.eclipse.tcf.te.ui.terminals.local.nls;x-internal:=true, org.eclipse.tcf.te.ui.terminals.local.showin, org.eclipse.tcf.te.ui.terminals.local.showin.interfaces, - org.eclipse.tcf.te.ui.terminals.local.showin.preferences, - org.eclipse.tcf.te.ui.terminals.local.types + org.eclipse.tcf.te.ui.terminals.local.showin.preferences diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.properties index c268d2fd4..86ea1e107 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.properties @@ -11,9 +11,6 @@ pluginName = Target Explorer, Terminals Local Connector providerName = Eclipse.org - Target Explorer -# ----- Terminal Connector Types ----- -LocalConnectorType.label=Local Connector Type - # ----- Commands and Menu contributions ----- LocalLauncherDelegate.label=Local Terminal diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml index 3d7e2f3ff..22e2af1c2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/plugin.xml @@ -12,15 +12,6 @@ name="%TerminalConnector.local"/> </extension> -<!-- Terminal connector type contributions --> - <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes"> - <connectorType - class="org.eclipse.tcf.te.ui.terminals.local.types.LocalConnectorType" - id="org.eclipse.tcf.te.ui.terminals.type.local" - label="%LocalConnectorType.label"> - </connectorType> - </extension> - <!-- Terminals launcher delegate contributions --> <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> <delegate diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/controls/LocalWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/controls/LocalWizardConfigurationPanel.java index 8384b530e..83a266f24 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/controls/LocalWizardConfigurationPanel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/controls/LocalWizardConfigurationPanel.java @@ -103,9 +103,6 @@ public class LocalWizardConfigurationPanel extends AbstractExtendedConfiguration // set the terminal connector id for local terminal data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tcf.te.ui.terminals.local.LocalConnector"); //$NON-NLS-1$ - // set the connector type for local terminal - data.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.local"); //$NON-NLS-1$ - // Store the encoding data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java index d3fde5c3d..0314402c3 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherDelegate.java @@ -14,9 +14,13 @@ import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; import java.util.Map; +import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; @@ -28,14 +32,21 @@ import org.eclipse.jface.viewers.IStructuredSelection; 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.ITerminalServiceOutputStreamMonitorListener; +import org.eclipse.tcf.te.core.terminals.interfaces.constants.ILineSeparatorConstants; 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.local.activator.UIPlugin; import org.eclipse.tcf.te.ui.terminals.local.controls.LocalWizardConfigurationPanel; import org.eclipse.tcf.te.ui.terminals.local.showin.interfaces.IPreferenceKeys; +import org.eclipse.tcf.te.ui.terminals.process.ProcessSettings; +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.ui.ISelectionService; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchEncoding; @@ -44,6 +55,7 @@ import org.osgi.framework.Bundle; /** * Serial launcher delegate implementation. */ +@SuppressWarnings("restriction") public class LocalLauncherDelegate extends AbstractLauncherDelegate { private final IMementoHandler mementoHandler = new LocalMementoHandler(); @@ -207,4 +219,156 @@ public class LocalLauncherDelegate extends AbstractLauncherDelegate { } return super.getAdapter(adapter); } + + /** + * Returns the default shell to launch. Looks at the environment + * variable "SHELL" first before assuming some default default values. + * + * @return The default shell to launch. + */ + private final File defaultShell() { + String shell = null; + if (Platform.OS_WIN32.equals(Platform.getOS())) { + if (System.getenv("ComSpec") != null && !"".equals(System.getenv("ComSpec").trim())) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + shell = System.getenv("ComSpec").trim(); //$NON-NLS-1$ + } else { + shell = "cmd.exe"; //$NON-NLS-1$ + } + } + if (shell == null) { + if (System.getenv("SHELL") != null && !"".equals(System.getenv("SHELL").trim())) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + shell = System.getenv("SHELL").trim(); //$NON-NLS-1$ + } else { + shell = "/bin/sh"; //$NON-NLS-1$ + } + } + + return new File(shell); + } + + /* (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.tcf.te.ui.terminals.local.LocalConnector"; //$NON-NLS-1$ + + // Extract the process properties using defaults + String image; + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_PATH) + || properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH) == null) { + File defaultShell = defaultShell(); + image = defaultShell.isAbsolute() ? defaultShell.getAbsolutePath() : defaultShell.getPath(); + } else { + image = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH); + } + + // Determine if a PTY will be used + boolean isUsingPTY = (properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ) == null && PTY.isSupported(PTY.Mode.TERMINAL)) + || properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ) instanceof PTY; + + boolean localEcho = false; + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_LOCAL_ECHO) + || !(properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO) instanceof Boolean)) { + // On Windows, turn on local echo by default if no PTY is used (bug 433645) + if (Platform.OS_WIN32.equals(Platform.getOS())) { + localEcho = !isUsingPTY; + } + } else { + localEcho = ((Boolean)properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO)).booleanValue(); + } + + String lineSeparator = null; + if (!properties.containsKey(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) + || !(properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) instanceof String)) { + // No line separator will be set if a PTY is used + if (!isUsingPTY) { + lineSeparator = Platform.OS_WIN32.equals(Platform.getOS()) ? ILineSeparatorConstants.LINE_SEPARATOR_CRLF : ILineSeparatorConstants.LINE_SEPARATOR_LF; + } + } else { + lineSeparator = (String)properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR); + } + + String arguments = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS); + Process process = (Process)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ); + PTY pty = (PTY)properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ); + ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS); + ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS); + String workingDir = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR); + + String[] envp = null; + if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) && + properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null && + properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]){ + envp = (String[])properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT); + } + + // Set the ECLIPSE_HOME and ECLIPSE_WORKSPACE environment variables + List<String> envpList = new ArrayList<String>(); + if (envp != null) envpList.addAll(Arrays.asList(envp)); + + // ECLIPSE_HOME + String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$ + if (eclipseHomeLocation != null) { + try { + URI uri = URIUtil.fromString(eclipseHomeLocation); + File f = URIUtil.toFile(uri); + envpList.add("ECLIPSE_HOME=" + f.getAbsolutePath()); //$NON-NLS-1$ + } catch (URISyntaxException e) { /* ignored on purpose */ } + } + + // ECLIPSE_WORKSPACE + Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$ + if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) { + if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null + && org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null + && org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) { + envpList.add("ECLIPSE_WORKSPACE=" + org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); //$NON-NLS-1$ + } + } + + // Convert back into a string array + envp = envpList.toArray(new String[envpList.size()]); + + Assert.isTrue(image != null || process != null); + + // Construct the terminal settings store + ISettingsStore store = new SettingsStore(); + + // Construct the process settings + ProcessSettings processSettings = new ProcessSettings(); + processSettings.setImage(image); + processSettings.setArguments(arguments); + processSettings.setProcess(process); + processSettings.setPTY(pty); + processSettings.setLocalEcho(localEcho); + processSettings.setLineSeparator(lineSeparator); + processSettings.setStdOutListeners(stdoutListeners); + processSettings.setStdErrListeners(stderrListeners); + processSettings.setWorkingDir(workingDir); + processSettings.setEnvironment(envp); + + if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) { + Object value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT); + processSettings.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean)value).booleanValue() : false); + } + + // And save the settings to the store + processSettings.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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java index 879461855..bd4d1367c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/launcher/LocalLauncherHandler.java @@ -49,7 +49,6 @@ public class LocalLauncherHandler extends AbstractHandler { if (delegate != null) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, delegate.getId()); - properties.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.local"); //$NON-NLS-1$ properties.put(ITerminalsConnectorConstants.PROP_SELECTION, selection); delegate.execute(properties, null); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/DynamicContributionItems.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/DynamicContributionItems.java index 7aa244eb6..c47050efc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/DynamicContributionItems.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/showin/DynamicContributionItems.java @@ -115,7 +115,6 @@ public class DynamicContributionItems extends CompoundContributionItem implement Map<String, Object> properties = new HashMap<String, Object>(); properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, delegate.getId()); - properties.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.local"); //$NON-NLS-1$ if (selection != null) properties.put(ITerminalsConnectorConstants.PROP_SELECTION, selection); properties.put(ITerminalsConnectorConstants.PROP_PROCESS_PATH, path); if (args != null) properties.put(ITerminalsConnectorConstants.PROP_PROCESS_ARGS, args); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java deleted file mode 100644 index b5350ddf2..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 - 2014 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.local.types; - -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.eclipse.cdt.utils.pty.PTY; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalServiceOutputStreamMonitorListener; -import org.eclipse.tcf.te.core.terminals.interfaces.constants.ILineSeparatorConstants; -import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants; -import org.eclipse.tcf.te.ui.terminals.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.process.ProcessSettings; -import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType; -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.osgi.framework.Bundle; - -/** - * Streams terminal connector type implementation. - */ -@SuppressWarnings("restriction") -public class LocalConnectorType extends AbstractConnectorType { - - /** - * Returns the default shell to launch. Looks at the environment - * variable "SHELL" first before assuming some default default values. - * - * @return The default shell to launch. - */ - private final File defaultShell() { - String shell = null; - if (Platform.OS_WIN32.equals(Platform.getOS())) { - if (System.getenv("ComSpec") != null && !"".equals(System.getenv("ComSpec").trim())) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - shell = System.getenv("ComSpec").trim(); //$NON-NLS-1$ - } else { - shell = "cmd.exe"; //$NON-NLS-1$ - } - } - if (shell == null) { - if (System.getenv("SHELL") != null && !"".equals(System.getenv("SHELL").trim())) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - shell = System.getenv("SHELL").trim(); //$NON-NLS-1$ - } else { - shell = "/bin/sh"; //$NON-NLS-1$ - } - } - - return new File(shell); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#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.tcf.te.ui.terminals.local.LocalConnector"; //$NON-NLS-1$ - - // Extract the process properties using defaults - String image; - if (!properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_PATH) - || properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH) == null) { - File defaultShell = defaultShell(); - image = defaultShell.isAbsolute() ? defaultShell.getAbsolutePath() : defaultShell.getPath(); - } else { - image = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH); - } - - // Determine if a PTY will be used - boolean isUsingPTY = (properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ) == null && PTY.isSupported(PTY.Mode.TERMINAL)) - || properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ) instanceof PTY; - - boolean localEcho = false; - if (!properties.containsKey(ITerminalsConnectorConstants.PROP_LOCAL_ECHO) - || !(properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO) instanceof Boolean)) { - // On Windows, turn on local echo by default if no PTY is used (bug 433645) - if (Platform.OS_WIN32.equals(Platform.getOS())) { - localEcho = !isUsingPTY; - } - } else { - localEcho = ((Boolean)properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO)).booleanValue(); - } - - String lineSeparator = null; - if (!properties.containsKey(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) - || !(properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) instanceof String)) { - // No line separator will be set if a PTY is used - if (!isUsingPTY) { - lineSeparator = Platform.OS_WIN32.equals(Platform.getOS()) ? ILineSeparatorConstants.LINE_SEPARATOR_CRLF : ILineSeparatorConstants.LINE_SEPARATOR_LF; - } - } else { - lineSeparator = (String)properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR); - } - - String arguments = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS); - Process process = (Process)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ); - PTY pty = (PTY)properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ); - ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS); - ITerminalServiceOutputStreamMonitorListener[] stderrListeners = (ITerminalServiceOutputStreamMonitorListener[])properties.get(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS); - String workingDir = (String)properties.get(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR); - - String[] envp = null; - if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) && - properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null && - properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]){ - envp = (String[])properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT); - } - - // Set the ECLIPSE_HOME and ECLIPSE_WORKSPACE environment variables - List<String> envpList = new ArrayList<String>(); - if (envp != null) envpList.addAll(Arrays.asList(envp)); - - // ECLIPSE_HOME - String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$ - if (eclipseHomeLocation != null) { - try { - URI uri = URIUtil.fromString(eclipseHomeLocation); - File f = URIUtil.toFile(uri); - envpList.add("ECLIPSE_HOME=" + f.getAbsolutePath()); //$NON-NLS-1$ - } catch (URISyntaxException e) { /* ignored on purpose */ } - } - - // ECLIPSE_WORKSPACE - Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$ - if (bundle != null && (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.ACTIVE)) { - if (org.eclipse.core.resources.ResourcesPlugin.getWorkspace() != null - && org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot() != null - && org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation() != null) { - envpList.add("ECLIPSE_WORKSPACE=" + org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); //$NON-NLS-1$ - } - } - - // Convert back into a string array - envp = envpList.toArray(new String[envpList.size()]); - - Assert.isTrue(image != null || process != null); - - // Construct the terminal settings store - ISettingsStore store = new SettingsStore(); - - // Construct the process settings - ProcessSettings processSettings = new ProcessSettings(); - processSettings.setImage(image); - processSettings.setArguments(arguments); - processSettings.setProcess(process); - processSettings.setPTY(pty); - processSettings.setLocalEcho(localEcho); - processSettings.setLineSeparator(lineSeparator); - processSettings.setStdOutListeners(stdoutListeners); - processSettings.setStdErrListeners(stderrListeners); - processSettings.setWorkingDir(workingDir); - processSettings.setEnvironment(envp); - - if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) { - Object value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT); - processSettings.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean)value).booleanValue() : false); - } - - // And save the settings to the store - processSettings.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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF index 3472d2c0b..d407d4827 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Vendor: %providerName Import-Package: org.eclipse.cdt.utils.pty;mandatory:=native, org.eclipse.cdt.utils.spawner;mandatory:=native Require-Bundle: org.eclipse.cdt.core;bundle-version="5.6";resolution:=optional, + org.eclipse.core.expressions;bundle-version="3.4.400", org.eclipse.core.resources;bundle-version="3.8.1";resolution:=optional, org.eclipse.core.runtime;bundle-version="3.8.0", org.eclipse.tcf.te.core.terminals;bundle-version="1.3.0", diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.properties index e44179454..76ac078fc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.properties @@ -15,8 +15,8 @@ providerName = Eclipse.org - Target Explorer TerminalConnector.process=Process Connector (hidden) -# ----- Terminal Connector Types ----- +# ----- Terminal Launcher Delegates ----- -ProcessConnectorType.label=Process Connector Type +ProcessLauncherDelegate.label=Streams Terminal # ----- Commands and Menu contributions ----- diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.xml index 55203c7d7..068e51399 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/plugin.xml @@ -1,23 +1,24 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
-<!-- Terminal connector contributions -->
- <extension point="org.eclipse.tm.terminal.terminalConnectors">
- <connector
- class="org.eclipse.tcf.te.ui.terminals.process.ProcessConnector"
- hidden="true"
- id="org.eclipse.tcf.te.ui.terminals.ProcessConnector"
- name="%TerminalConnector.process"/>
- </extension>
-
-<!-- Terminal connector type contributions -->
- <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes">
- <connectorType
- class="org.eclipse.tcf.te.ui.terminals.process.ProcessConnectorType"
- id="org.eclipse.tcf.te.ui.terminals.type.process"
- label="%ProcessConnectorType.label">
- </connectorType>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + +<!-- Terminal connector contributions --> + <extension point="org.eclipse.tm.terminal.terminalConnectors"> + <connector + class="org.eclipse.tcf.te.ui.terminals.process.ProcessConnector" + hidden="true" + id="org.eclipse.tcf.te.ui.terminals.ProcessConnector" + name="%TerminalConnector.process"/> + </extension> + +<!-- Terminals launcher delegate contributions --> + <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> + <delegate + class="org.eclipse.tcf.te.ui.terminals.process.ProcessLauncherDelegate" + hidden="true" + id="org.eclipse.tcf.te.ui.terminals.telnet.launcher.process" + label="%ProcessLauncherDelegate.label"> + </delegate> + </extension> + +</plugin> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessLauncherDelegate.java index 2c982b8c6..fc78d60de 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnectorType.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessLauncherDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 - 2015 Wind River Systems, Inc. and others. All rights reserved. + * 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 @@ -13,22 +13,58 @@ import java.util.Map; import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.core.runtime.Assert; +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.ITerminalServiceOutputStreamMonitorListener; 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.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType; +import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate; 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; /** - * Streams terminal connector type implementation. + * Process launcher delegate implementation. */ @SuppressWarnings("restriction") -public class ProcessConnectorType extends AbstractConnectorType { +public class ProcessLauncherDelegate extends AbstractLauncherDelegate { /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(java.util.Map) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#needsUserConfiguration() + */ + @Override + public boolean needsUserConfiguration() { + return false; + } + + /* (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 null; + } + + /* (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); + + // Get the terminal service + ITerminalService terminal = TerminalServiceFactory.getService(); + // If not available, we cannot fulfill this request + if (terminal != null) { + terminal.openConsole(properties, done); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#createTerminalConnector(java.util.Map) */ @Override public ITerminalConnector createTerminalConnector(Map<String, Object> properties) { @@ -94,4 +130,5 @@ public class ProcessConnectorType extends AbstractConnectorType { return connector; } + } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/META-INF/MANIFEST.MF index 53c8cd0e8..579f425ed 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/META-INF/MANIFEST.MF @@ -21,6 +21,5 @@ Export-Package: org.eclipse.tcf.te.ui.terminals.serial.activator;x-internal:=tru org.eclipse.tcf.te.ui.terminals.serial.controls, org.eclipse.tcf.te.ui.terminals.serial.interfaces, org.eclipse.tcf.te.ui.terminals.serial.launcher, - org.eclipse.tcf.te.ui.terminals.serial.nls;x-internal:=true, - org.eclipse.tcf.te.ui.terminals.serial.types + org.eclipse.tcf.te.ui.terminals.serial.nls;x-internal:=true Import-Package: gnu.io;resolution:=optional diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.properties index 2705043ff..e856544bb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.properties @@ -11,10 +11,6 @@ pluginName = Target Explorer, Serial Terminals Extensions providerName = Eclipse.org - Target Explorer -# ----- Terminal Connector Types ----- - -SerialConnectorType.label=Serial Connector Type - -# ***** Terminal Launcher Delegates **** +# ----- Terminal Launcher Delegates ----- SerialLauncherDelegate.label=Serial Terminal
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.xml index 7a3cc8745..31552a2a7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/plugin.xml @@ -1,14 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> -<!-- Terminal connector type contributions --> - <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes"> - <connectorType - class="org.eclipse.tcf.te.ui.terminals.serial.types.SerialConnectorType" - id="org.eclipse.tcf.te.ui.terminals.type.serial" - label="%SerialConnectorType.label"> - </connectorType> - </extension> <!-- Terminals launcher delegate contributions --> <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/controls/SerialConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/controls/SerialConfigurationPanel.java index 8c2814bd6..d1e4dbe88 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/controls/SerialConfigurationPanel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/controls/SerialConfigurationPanel.java @@ -68,9 +68,6 @@ public class SerialConfigurationPanel extends AbstractExtendedConfigurationPanel // set the terminal connector id for serial data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.internal.terminal.serial.SerialConnector"); //$NON-NLS-1$ - // set the connector type for serial - data.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.serial"); //$NON-NLS-1$ - serialSettingsPage.extractData(data); data.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding()); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java index 2a089e30a..60087396e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/launcher/SerialLauncherDelegate.java @@ -22,13 +22,19 @@ import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnecto 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.serial.controls.SerialConfigurationPanel; import org.eclipse.tcf.te.ui.terminals.serial.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.serial.SerialSettings; /** * Serial launcher delegate implementation. */ +@SuppressWarnings("restriction") public class SerialLauncherDelegate extends AbstractLauncherDelegate { // The serial terminal connection memento handler private final IMementoHandler mementoHandler = new SerialMementoHandler(); @@ -103,4 +109,52 @@ public class SerialLauncherDelegate extends AbstractLauncherDelegate { } 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.serial.SerialConnector"; //$NON-NLS-1$ + + String port = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DEVICE); + String baud = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_BAUD_RATE); + Object value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT); + String timeout = value instanceof Integer ? ((Integer)value).toString() : null; + String databits = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DATA_BITS); + String stopbits = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_STOP_BITS); + String parity = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_PARITY); + String flowcontrol = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_FLOW_CONTROL); + + // Construct the terminal settings store + ISettingsStore store = new SettingsStore(); + + // Construct the serial settings + SerialSettings serialSettings = new SerialSettings(); + serialSettings.setSerialPort(port); + serialSettings.setBaudRate(baud); + serialSettings.setTimeout(timeout); + serialSettings.setDataBits(databits); + serialSettings.setStopBits(stopbits); + serialSettings.setParity(parity); + serialSettings.setFlowControl(flowcontrol); + + // And save the settings to the store + serialSettings.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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/types/SerialConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/types/SerialConnectorType.java deleted file mode 100644 index 7a6999b49..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.serial/src/org/eclipse/tcf/te/ui/terminals/serial/types/SerialConnectorType.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ -package org.eclipse.tcf.te.ui.terminals.serial.types; - -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.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType; -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.serial.SerialSettings; - -/** - * Serial terminal connector type implementation. - */ -@SuppressWarnings("restriction") -public class SerialConnectorType extends AbstractConnectorType { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#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.serial.SerialConnector"; //$NON-NLS-1$ - - String port = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DEVICE); - String baud = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_BAUD_RATE); - Object value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT); - String timeout = value instanceof Integer ? ((Integer)value).toString() : null; - String databits = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_DATA_BITS); - String stopbits = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_STOP_BITS); - String parity = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_PARITY); - String flowcontrol = (String)properties.get(ITerminalsConnectorConstants.PROP_SERIAL_FLOW_CONTROL); - - // Construct the terminal settings store - ISettingsStore store = new SettingsStore(); - - // Construct the serial settings - SerialSettings serialSettings = new SerialSettings(); - serialSettings.setSerialPort(port); - serialSettings.setBaudRate(baud); - serialSettings.setTimeout(timeout); - serialSettings.setDataBits(databits); - serialSettings.setStopBits(stopbits); - serialSettings.setParity(parity); - serialSettings.setFlowControl(flowcontrol); - - // And save the settings to the store - serialSettings.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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF index f3f257a8f..8762d8cf6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/META-INF/MANIFEST.MF @@ -20,5 +20,4 @@ Bundle-Localization: plugin Export-Package: org.eclipse.tcf.te.ui.terminals.ssh.activator;x-internal:=true, org.eclipse.tcf.te.ui.terminals.ssh.controls, org.eclipse.tcf.te.ui.terminals.ssh.launcher, - org.eclipse.tcf.te.ui.terminals.ssh.nls;x-internal:=true, - org.eclipse.tcf.te.ui.terminals.ssh.types + org.eclipse.tcf.te.ui.terminals.ssh.nls;x-internal:=true diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.properties index de36297b9..e7229ff6c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.properties @@ -15,6 +15,6 @@ providerName = Eclipse.org - Target Explorer SshConnectorType.label=SSH Connector Type -# ***** Terminal Launcher Delegates **** +# ----- Terminal Launcher Delegates ----- SshLauncherDelegate.label=SSH Terminal
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml index cc0410f52..ba7ac4af5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml @@ -2,15 +2,6 @@ <?eclipse version="3.4"?> <plugin> -<!-- Terminal connector type contributions --> - <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes"> - <connectorType - class="org.eclipse.tcf.te.ui.terminals.ssh.types.SshConnectorType" - id="org.eclipse.tcf.te.ui.terminals.type.ssh" - label="%SshConnectorType.label"> - </connectorType> - </extension> - <!-- Terminals launcher delegate contributions --> <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> <delegate diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java index 69d7eb2fb..d447ae29c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java @@ -167,9 +167,6 @@ public class SshWizardConfigurationPanel extends AbstractExtendedConfigurationPa // set the terminal connector id for ssh data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.internal.terminal.ssh.SshConnector"); //$NON-NLS-1$ - // set the connector type for ssh - data.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.ssh"); //$NON-NLS-1$ - sshSettingsPage.saveSettings(); data.put(ITerminalsConnectorConstants.PROP_IP_HOST,sshSettings.getHost()); data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(sshSettings.getPort())); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java index 5225fc1b8..47e0a0ef6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/launcher/SshLauncherDelegate.java @@ -23,13 +23,19 @@ import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnecto 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.ssh.controls.SshWizardConfigurationPanel; import org.eclipse.tcf.te.ui.terminals.ssh.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.ssh.SshSettings; /** * SSH launcher delegate implementation. */ +@SuppressWarnings("restriction") public class SshLauncherDelegate extends AbstractLauncherDelegate { // The SSH terminal connection memento handler private final IMementoHandler mementoHandler = new SshMementoHandler(); @@ -111,4 +117,65 @@ public class SshLauncherDelegate extends AbstractLauncherDelegate { } 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.ssh.SshConnector"; //$NON-NLS-1$ + + // Extract the ssh 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; + value = properties.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE); + String keepAlive = value != null ? value.toString() : null; + String password = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_PASSWORD); + String user = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER); + + 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 ssh settings store + ISettingsStore store = new SettingsStore(); + + // Construct the telnet settings + SshSettings sshSettings = new SshSettings(); + sshSettings.setHost(host); + sshSettings.setPort(port); + sshSettings.setTimeout(timeout); + sshSettings.setKeepalive(keepAlive); + sshSettings.setPassword(password); + sshSettings.setUser(user); + + // And save the settings to the store + sshSettings.save(store); + + // MWE TODO make sure this is NOT passed outside as this is plain text + store.put("Password", password); //$NON-NLS-1$ + + // 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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/types/SshConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/types/SshConnectorType.java deleted file mode 100644 index bfd8e7630..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/types/SshConnectorType.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * 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) - [361352] [TERMINALS][SSH] Add SSH terminal support - *******************************************************************************/ -package org.eclipse.tcf.te.ui.terminals.ssh.types; - -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.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType; -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.ssh.SshSettings; - -/** - * Ssh terminal connector type implementation. - */ -@SuppressWarnings("restriction") -public class SshConnectorType extends AbstractConnectorType { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#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.ssh.SshConnector"; //$NON-NLS-1$ - - // Extract the ssh 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; - value = properties.get(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE); - String keepAlive = value != null ? value.toString() : null; - String password = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_PASSWORD); - String user = (String)properties.get(ITerminalsConnectorConstants.PROP_SSH_USER); - - 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; - } - - return host != null && port != null ? createSshConnector(connectorId, new String[] { host, port, timeout, keepAlive, password, user }, portOffset) : null; - } - - /** - * Creates a ssh connector object based on the given ssh server attributes. - * <p> - * The ssh server attributes must contain at least 2 elements: - * <ul> - * <li>attributes[0] --> ssh server host name</li> - * <li>attributes[1] --> ssh port</li> - * <li>attributes[2] --> timeout</li> - * <li>attributes[3] --> keep alive</li> - * <li>attributes[4] --> ssh password</li> - * <li>attributes[5] --> ssh user</li> - * </ul> - * - * @param connectorId The terminal connector id. Must not be <code>null</code>. - * @param attributes The ssh server attributes. Must not be <code>null</code>. - * @param portOffset Offset to add to the port. - * - * @return The terminal connector object instance or <code>null</code>. - */ - protected ITerminalConnector createSshConnector(String connectorId, String[] attributes, int portOffset) { - Assert.isNotNull(connectorId); - Assert.isNotNull(attributes); - Assert.isTrue(attributes.length == 6); - - final String serverName = attributes[0]; - final String serverPort = Integer.toString(Integer.decode(attributes[1]).intValue() + portOffset); - final String timeout = attributes[2]; - final String keepAlive=attributes[3]; - final String password=attributes[4]; - final String user=attributes[5]; - - // Construct the ssh settings store - ISettingsStore store = new SettingsStore(); - - // Construct the telnet settings - SshSettings sshSettings = new SshSettings(); - sshSettings.setHost(serverName); - sshSettings.setPort(serverPort); - sshSettings.setTimeout(timeout); - sshSettings.setKeepalive(keepAlive); - sshSettings.setPassword(password); - sshSettings.setUser(user); - - // And save the settings to the store - sshSettings.save(store); - - // MWE TODO make sure this is NOT passed outside as this is plain text - store.put("Password", password); //$NON-NLS-1$ - - // 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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF index 189cb80d5..94cb5e6f8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/META-INF/MANIFEST.MF @@ -20,5 +20,4 @@ Bundle-Localization: plugin Export-Package: org.eclipse.tcf.te.ui.terminals.telnet.activator;x-internal:=true, org.eclipse.tcf.te.ui.terminals.telnet.controls, org.eclipse.tcf.te.ui.terminals.telnet.launcher, - org.eclipse.tcf.te.ui.terminals.telnet.nls;x-internal:=true, - org.eclipse.tcf.te.ui.terminals.telnet.types + org.eclipse.tcf.te.ui.terminals.telnet.nls;x-internal:=true diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.properties index b04f42eae..6f97ad8a4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.properties @@ -11,10 +11,6 @@ pluginName = Target Explorer, Telnet Terminals Extensions providerName = Eclipse.org - Target Explorer -# ----- Terminal Connector Types ----- +# ----- Terminal Launcher Delegates ----- -TelnetConnectorType.label=Telnet Connector Type - -# ***** Terminal Launcher Delegates **** - -TelnetLauncherDelegate.label=Telnet Terminal
\ No newline at end of file +TelnetLauncherDelegate.label=Telnet Terminal diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml index fbd80e157..68fac1b91 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml @@ -2,15 +2,6 @@ <?eclipse version="3.4"?> <plugin> -<!-- Terminal connector type contributions --> - <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes"> - <connectorType - class="org.eclipse.tcf.te.ui.terminals.telnet.types.TelnetConnectorType" - id="org.eclipse.tcf.te.ui.terminals.type.telnet" - label="%TelnetConnectorType.label"> - </connectorType> - </extension> - <!-- Terminals launcher delegate contributions --> <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> <delegate diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java index 3e7792fdc..842908aa8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java @@ -121,9 +121,6 @@ public class TelnetWizardConfigurationPanel extends AbstractExtendedConfiguratio // set the terminal connector id for ssh data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.internal.terminal.telnet.TelnetConnector"); //$NON-NLS-1$ - // set the connector type for ssh - data.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, "org.eclipse.tcf.te.ui.terminals.type.telnet"); //$NON-NLS-1$ - telnetSettingsPage.saveSettings(); data.put(ITerminalsConnectorConstants.PROP_IP_HOST,telnetSettings.getHost()); data.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.valueOf(telnetSettings.getNetworkPort())); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java index 8bf1aad12..249995924 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/launcher/TelnetLauncherDelegate.java @@ -23,13 +23,19 @@ import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnecto 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(); @@ -110,4 +116,56 @@ public class TelnetLauncherDelegate extends AbstractLauncherDelegate { } 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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/types/TelnetConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/types/TelnetConnectorType.java deleted file mode 100644 index d5e67096f..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/types/TelnetConnectorType.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * 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.types; - -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.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType; -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 terminal connector type implementation. - */ -@SuppressWarnings("restriction") -public class TelnetConnectorType extends AbstractConnectorType { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#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; - } - - return host != null && port != null ? createTelnetConnector(connectorId, new String[] { host, port, timeout }, portOffset) : null; - } - - /** - * Creates a terminal connector object based on the given telnet server attributes. - * <p> - * The telnet server attributes must contain at least 2 elements: - * <ul> - * <li>attributes[0] --> telnet server host name</li> - * <li>attributes[1] --> telnet port</li> - * <li>attributes[2] --> timeout (optional)</li> - * </ul> - * - * @param connectorId The terminal connector id. Must not be <code>null</code>. - * @param attributes The telnet server attributes. Must not be <code>null</code> and must have at least two elements. - * @param portOffset Offset to add to the port. - * - * @return The terminal connector object instance or <code>null</code>. - */ - protected ITerminalConnector createTelnetConnector(String connectorId, String[] attributes, int portOffset) { - Assert.isNotNull(connectorId); - Assert.isNotNull(attributes); - Assert.isTrue(attributes.length >= 2); - - final String serverName = attributes[0]; - final String serverPort = Integer.toString(Integer.decode(attributes[1]).intValue() + portOffset); - final String timeout = attributes.length >= 3 ? attributes[2] : null; - - // Construct the terminal settings store - ISettingsStore store = new SettingsStore(); - - // Construct the telnet settings - TelnetSettings telnetSettings = new TelnetSettings(); - telnetSettings.setHost(serverName); - telnetSettings.setNetworkPort(serverPort); - 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/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF index 6b366fe17..c0845fe21 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/META-INF/MANIFEST.MF @@ -32,5 +32,4 @@ Export-Package: org.eclipse.tcf.te.ui.terminals.actions, org.eclipse.tcf.te.ui.terminals.services, org.eclipse.tcf.te.ui.terminals.streams, org.eclipse.tcf.te.ui.terminals.tabs, - org.eclipse.tcf.te.ui.terminals.types, org.eclipse.tcf.te.ui.terminals.view diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties index dd6cac014..09d2b1ca0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.properties @@ -21,9 +21,9 @@ TerminalsView.context.description=Show modified keyboard shortcuts in context me TerminalConnector.streams=Streams Connector (hidden) -# ----- Terminal Connector Types ----- +# ----- Terminal Launcher Delegates ----- -StreamsConnectorType.label=Streams Connector Type +StreamsLauncherDelegate.label=Streams Terminal # ----- Commands and Menu contributions ----- @@ -42,7 +42,6 @@ menu.showIn.label = Show In # ***** Extension Points ***** -ExtensionPoint.connectorTypes.name=Terminal Connector Types ExtensionPoint.launcherDelegates.name=Terminal Launcher Delegates # ***** Activity contributions ***** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml index 831f95eeb..98f3c59ad 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/plugin.xml @@ -3,7 +3,6 @@ <plugin> <!-- Extension points --> - <extension-point id="connectorTypes" name="%ExtensionPoint.connectorTypes.name" schema="schema/connectorTypes.exsd"/> <extension-point id="launcherDelegates" name="%ExtensionPoint.launcherDelegates.name" schema="schema/launcherDelegates.exsd"/> <!-- View contributions --> @@ -103,13 +102,14 @@ </propertyTester> </extension> -<!-- Terminal connector type contributions --> - <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes"> - <connectorType - class="org.eclipse.tcf.te.ui.terminals.types.StreamsConnectorType" - id="org.eclipse.tcf.te.ui.terminals.type.streams" - label="%StreamsConnectorType.label"> - </connectorType> +<!-- Terminals launcher delegate contributions --> + <extension point="org.eclipse.tcf.te.ui.terminals.launcherDelegates"> + <delegate + class="org.eclipse.tcf.te.ui.terminals.streams.StreamsLauncherDelegate" + hidden="true" + id="org.eclipse.tcf.te.ui.terminals.telnet.launcher.streams" + label="%StreamsLauncherDelegate.label"> + </delegate> </extension> <!-- Menu contributions --> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/connectorTypes.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/connectorTypes.exsd deleted file mode 100644 index 0eb88c533..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/schema/connectorTypes.exsd +++ /dev/null @@ -1,200 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.tcf.te.ui.terminals" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.tcf.te.ui.terminals" id="connectorTypes" name="Terminals Connector Types"/>
- </appinfo>
- <documentation>
- This extension point is used to contribute terminals connector types.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="connectorType" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="connectorType">
- <annotation>
- <documentation>
- Declares a terminal connector type contribution.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="class" minOccurs="0" maxOccurs="1"/>
- <element ref="description" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The unique id of the terminal connector type contribution.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="label" type="string">
- <annotation>
- <documentation>
- The label representing the terminal connector type within the UI.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
- The class that implements <code>org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType</code> or extends <code>org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType</code>.
-<p>
-The terminal connector type implementation class must be specified either by the class attribute or the class child element!
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn="org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType:org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="description" type="string">
- <annotation>
- <documentation>
- A short description of the terminal connector type to be presented in the UI.
- </documentation>
- </annotation>
- </element>
-
- <element name="class">
- <annotation>
- <documentation>
- Used when creating an <code>IExecutableExtension</code> with a named parameter, or more than one.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
- The class that implements <code>org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType</code> or extends <code>org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType</code>.
-<p>
-The terminal connector type implementation class must be specified either by the class attribute or the class child element!
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn="org.eclipse.tcf.te.ui.terminals.types.AbstractConnectorType:org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="parameter">
- <annotation>
- <documentation>
- A parameter for an <code>IExecutableExtension</code>.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- <p>The parameter name.</p>
- </documentation>
- </annotation>
- </attribute>
- <attribute name="value" type="string" use="required">
- <annotation>
- <documentation>
- <p>The parameter value.</p>
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- Target Explorer 1.0.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- This is an example of the extension point usage:
-<p>
-<pre><code>
- <extension point="org.eclipse.tcf.te.ui.terminals.connectorTypes">
- <connectorType
- id="org.eclipse.tcf.te.ui.terminals.connector.telnet"
- class="org.eclipse.tcf.te.ui.terminals.internal.TelnetConnectorType"
- label="Telnet Terminal Connector Type">
- </connectorType>
- </extension>
-</code></pre>
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- The provider of a connector type must implement <samp>org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType</samp>.
- </documentation>
- </annotation>
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- 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.
- </documentation>
- </annotation>
-
-</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConnectorType.java deleted file mode 100644 index 4d0e1d823..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/IConnectorType.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ -package org.eclipse.tcf.te.ui.terminals.interfaces; - -import java.util.Map; - -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; - -/** - * Terminal connector type. - */ -@SuppressWarnings("restriction") -public interface IConnectorType extends IExecutableExtension { - - /** - * Returns the unique id of the terminal connector type. The returned - * id must be never <code>null</code> or an empty string. - * - * @return The unique id. - */ - public String getId(); - - /** - * Creates the terminal connector for this terminal connector type - * based on the given properties. - * - * @param properties The terminal properties. Must not be <code>null</code>. - * @return The terminal connector or <code>null</code>. - */ - public ITerminalConnector createTerminalConnector(Map<String, Object> properties); -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java index 15cb5ef14..67dff921b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/interfaces/ILauncherDelegate.java @@ -15,10 +15,12 @@ import org.eclipse.core.expressions.Expression; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService; +import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; /** * Terminal launcher delegate. */ +@SuppressWarnings("restriction") public interface ILauncherDelegate extends IExecutableExtension, IAdaptable { /** @@ -79,4 +81,13 @@ public interface ILauncherDelegate extends IExecutableExtension, IAdaptable { * @param done The callback or <code>null</code>. */ public void execute(Map<String, Object> properties, ITerminalService.Done done); + + /** + * Creates the terminal connector for this launcher delegate based on + * the given properties. + * + * @param properties The terminal properties. Must not be <code>null</code>. + * @return The terminal connector or <code>null</code>. + */ + public ITerminalConnector createTerminalConnector(Map<String, Object> properties); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java index cd14fea72..6ba77106b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java @@ -304,7 +304,6 @@ public class LaunchTerminalSettingsDialog extends TrayDialog { data.remove(ITerminalsConnectorConstants.PROP_IP_PORT); data.remove(ITerminalsConnectorConstants.PROP_TIMEOUT); data.remove(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID); - data.remove(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID); data.remove(ITerminalsConnectorConstants.PROP_ENCODING); // Switch to the new panel settings.showConfigurationPanel(terminals.getText()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java index eedd25fcb..08398fcf4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/services/TerminalService.java @@ -24,11 +24,11 @@ import org.eclipse.tcf.te.core.terminals.activator.CoreBundleActivator; import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService; import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalTabListener; import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants; -import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType; +import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate; import org.eclipse.tcf.te.ui.terminals.interfaces.IUIConstants; +import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager; import org.eclipse.tcf.te.ui.terminals.manager.ConsoleManager; import org.eclipse.tcf.te.ui.terminals.nls.Messages; -import org.eclipse.tcf.te.ui.terminals.types.ConnectorManager; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.ui.PlatformUI; @@ -242,14 +242,14 @@ public class TerminalService implements ITerminalService { // The terminal connector result object ITerminalConnector connector = null; - // Get the connector type id from the properties - String connectorTypeId = (String)properties.get(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID); - if (connectorTypeId != null) { - // Get the connector type - IConnectorType connectorType = ConnectorManager.getInstance().getConnectorType(connectorTypeId, false); - if (connectorType != null) { - // Create the connector - connector = connectorType.createTerminalConnector(properties); + // Get the launcher delegate id from the properties + String delegateId = (String)properties.get(ITerminalsConnectorConstants.PROP_DELEGATE_ID); + if (delegateId != null) { + // Get the launcher delegate + ILauncherDelegate delegate = LauncherDelegateManager.getInstance().getLauncherDelegate(delegateId, false); + if (delegate != null) { + // Create the terminal connector + connector = delegate.createTerminalConnector(properties); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/StreamsConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsLauncherDelegate.java index 1969adef8..6d492e7ba 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/StreamsConnectorType.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/streams/StreamsLauncherDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * 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 @@ -7,31 +7,67 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.ui.terminals.types; +package org.eclipse.tcf.te.ui.terminals.streams; import java.io.InputStream; import java.io.OutputStream; import java.util.Map; import org.eclipse.core.runtime.Assert; +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.ITerminalServiceOutputStreamMonitorListener; 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.internal.SettingsStore; -import org.eclipse.tcf.te.ui.terminals.streams.StreamsSettings; +import org.eclipse.tcf.te.ui.terminals.launcher.AbstractLauncherDelegate; 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; /** - * Streams terminal connector type implementation. + * Streams launcher delegate implementation. */ @SuppressWarnings("restriction") -public class StreamsConnectorType extends AbstractConnectorType { +public class StreamsLauncherDelegate extends AbstractLauncherDelegate { /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(java.util.Map) + * @see org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate#needsUserConfiguration() */ @Override + public boolean needsUserConfiguration() { + return false; + } + + /* (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 null; + } + + /* (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); + + // Get the terminal service + ITerminalService terminal = TerminalServiceFactory.getService(); + // If not available, we cannot fulfill this request + if (terminal != null) { + terminal.openConsole(properties, done); + } + } + + /* (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); @@ -75,4 +111,5 @@ public class StreamsConnectorType extends AbstractConnectorType { return connector; } + } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/AbstractConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/AbstractConnectorType.java deleted file mode 100644 index c879c6beb..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/AbstractConnectorType.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 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 - *******************************************************************************/ -package org.eclipse.tcf.te.ui.terminals.types; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; -import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType; -import org.eclipse.tcf.te.ui.terminals.nls.Messages; - -/** - * Abstract terminal connector type implementation. - */ -public abstract class AbstractConnectorType extends PlatformObject implements IConnectorType { - // The mandatory id of the extension - private String id = null; - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object) - */ - @Override - public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { - Assert.isNotNull(config); - - // Initialize the id field by reading the <id> extension attribute. - // Throws an exception if the id is empty or null. - id = config.getAttribute("id"); //$NON-NLS-1$ - if (id == null || "".equals(id.trim())) { //$NON-NLS-1$ - throw createMissingMandatoryAttributeException("id", config.getContributor().getName()); //$NON-NLS-1$ - } - } - - /** - * Creates a new {@link CoreException} to be thrown if a mandatory extension attribute - * is missing. - * - * @param attributeName The attribute name. Must not be <code>null</code>. - * @param extensionId The extension id. Must not be <code>null</code>. - * - * @return The {@link CoreException} instance. - */ - protected CoreException createMissingMandatoryAttributeException(String attributeName, String extensionId) { - Assert.isNotNull(attributeName); - Assert.isNotNull(extensionId); - - return new CoreException(new Status(IStatus.ERROR, - UIPlugin.getUniqueIdentifier(), - 0, - NLS.bind(Messages.Extension_error_missingRequiredAttribute, attributeName, extensionId), - null)); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#getId() - */ - @Override - public String getId() { - return id; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof AbstractConnectorType) { - return id.equals(((AbstractConnectorType)obj).id); - } - return super.equals(obj); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return id.hashCode(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/ConnectorManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/ConnectorManager.java deleted file mode 100644 index 23d2b03fe..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/types/ConnectorManager.java +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ -package org.eclipse.tcf.te.ui.terminals.types; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.te.ui.terminals.activator.UIPlugin; -import org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType; -import org.eclipse.tcf.te.ui.terminals.nls.Messages; - -/** - * Terminal connector type extension point manager implementation. - */ -public class ConnectorManager { - // Flag to mark the extension point manager initialized (extensions loaded). - private boolean initialized = false; - - // The map containing all loaded contributions - private final Map<String, Proxy> extensionsMap = new HashMap<String, Proxy>(); - - // The extension point comparator - private ExtensionPointComparator comparator = null; - - /** - * Executable extension proxy implementation. - */ - /* default */ static class Proxy { - // The extension instance. Created on first access - private IConnectorType instance; - // The configuration element - private final IConfigurationElement element; - // The unique id of the extension. - private String id; - - /** - * Constructor. - * - * @param element The configuration element. Must not be <code>null</code>. - * @throws CoreException In case the configuration element attribute <i>id</i> is <code>null</code> or empty. - */ - public Proxy(IConfigurationElement element) throws CoreException { - Assert.isNotNull(element); - this.element = element; - - // Extract the extension attributes - id = element.getAttribute("id"); //$NON-NLS-1$ - if (id == null || id.trim().length() == 0) { - throw new CoreException(new Status(IStatus.ERROR, - UIPlugin.getUniqueIdentifier(), - 0, - NLS.bind(Messages.Extension_error_missingRequiredAttribute, "id", element.getContributor().getName()), //$NON-NLS-1$ - null)); - } - - instance = null; - } - - /** - * Returns the extensions unique id. - * - * @return The unique id. - */ - public String getId() { - return id; - } - - /** - * Returns the configuration element for this extension. - * - * @return The configuration element. - */ - public IConfigurationElement getConfigurationElement() { - return element; - } - - /** - * Returns the terminal connector type class instance. The contributing - * plug-in will be activated if not yet activated anyway. - * - * @return The extension class instance or <code>null</code> if the instantiation fails. - */ - public IConnectorType getInstance() { - if (instance == null) instance = newInstance(); - return instance; - } - - /** - * Returns always a new terminal connector type class instance which is different - * to what {@link #getInstance()} would return. - * - * @return A new extension class instance or <code>null</code> if the instantiation fails. - */ - public IConnectorType newInstance() { - IConfigurationElement element = getConfigurationElement(); - Assert.isNotNull(element); - - // The "class" to load can be specified either as attribute or as child element - if (element.getAttribute("class") != null || element.getChildren("class").length > 0) { //$NON-NLS-1$ //$NON-NLS-2$ - try { - return (IConnectorType)element.createExecutableExtension("class"); //$NON-NLS-1$ - } catch (Exception e) { - // Possible exceptions: CoreException, ClassCastException. - Platform.getLog(UIPlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, - UIPlugin.getUniqueIdentifier(), - NLS.bind(Messages.Extension_error_invalidExtensionPoint, element.getDeclaringExtension().getUniqueIdentifier()), e)); - } - } - return null; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - // Proxies are equal if they have encapsulate an element - // with the same unique id - if (obj instanceof Proxy) { - return getId().equals(((Proxy)obj).getId()); - } - return super.equals(obj); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - // The hash code of a proxy is the one from the id - return getId().hashCode(); - } - } - - /** - * Extension point comparator implementation. - * <p> - * The comparator assure that extension are read in a predictable order. - * <p> - * The order of the extensions is defined as following:<br> - * <ul><li>Extensions contributed by our own plug-ins (<code>org.eclipse.tcf.te.*</code>) - * in ascending alphabetic order and</li> - * <li>Extensions contributed by any other plug-in in ascending alphabetic order.</li> - * <li>Extensions contributed by the same plug-in in ascending alphabetic order by the - * extensions unique id</li> - */ - /* default */ static class ExtensionPointComparator implements Comparator<IExtension> { - private final static String OWN_PLUGINS_PATTERN = "org.eclipse.tcf.te."; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - @Override - public int compare(IExtension o1, IExtension o2) { - // We ignore any comparisation with null and - if (o1 == null || o2 == null) return 0; - // Check if it is the exact same element - if (o1 == o2) return 0; - - // The extensions are compared by the unique id of the contributing plug-in first - String contributor1 = o1.getContributor().getName(); - String contributor2 = o2.getContributor().getName(); - - // Contributions from our own plug-ins comes before 3rdParty plug-ins - if (contributor1.startsWith(OWN_PLUGINS_PATTERN) && !contributor2.startsWith(OWN_PLUGINS_PATTERN)) - return -1; - if (!contributor1.startsWith(OWN_PLUGINS_PATTERN) && contributor2.startsWith(OWN_PLUGINS_PATTERN)) - return 1; - if (contributor1.startsWith(OWN_PLUGINS_PATTERN) && contributor2.startsWith(OWN_PLUGINS_PATTERN)) { - int value = contributor1.compareTo(contributor2); - // Within the same plug-in, the extension are sorted by their unique id (if available) - if (value == 0 && o1.getUniqueIdentifier() != null && o2.getUniqueIdentifier() != null) - return o1.getUniqueIdentifier().compareTo(o2.getUniqueIdentifier()); - // Otherwise, just return the comparisation result from the contributors - return value; - } - - // Contributions from all other plug-ins are sorted alphabetical - int value = contributor1.compareTo(contributor2); - // Within the same plug-in, the extension are sorted by their unique id (if available) - if (value == 0 && o1.getUniqueIdentifier() != null && o2.getUniqueIdentifier() != null) - return o1.getUniqueIdentifier().compareTo(o2.getUniqueIdentifier()); - // Otherwise, just return the comparisation result from the contributors - return value; - } - - } - - /* - * Thread save singleton instance creation. - */ - private static class LazyInstanceHolder { - public static ConnectorManager instance = new ConnectorManager(); - } - - /** - * Returns the singleton instance for the terminal connector type extension point manager. - */ - public static ConnectorManager getInstance() { - return LazyInstanceHolder.instance; - } - - /** - * Constructor. - */ - ConnectorManager() { - super(); - } - - /** - * Returns the list of all contributed terminal connector types. - * - * @param unique If <code>true</code>, the method returns new instances for each - * contributed terminal connector type. - * - * @return The list of contributed terminal connector types, or an empty array. - */ - public IConnectorType[] getConnectorTypes(boolean unique) { - List<IConnectorType> contributions = new ArrayList<IConnectorType>(); - for (Proxy connectorType : getExtensions().values()) { - IConnectorType instance = unique ? connectorType.newInstance() : connectorType.getInstance(); - if (instance != null && !contributions.contains(instance)) { - contributions.add(instance); - } - } - - return contributions.toArray(new IConnectorType[contributions.size()]); - } - - /** - * Returns the terminal connector type identified by its unique id. If no terminal - * connector type with the specified id is registered, <code>null</code> is returned. - * - * @param id The unique id of the terminal connector type or <code>null</code> - * @param unique If <code>true</code>, the method returns new instances of the terminal connector type contribution. - * - * @return The terminal connector type instance or <code>null</code>. - */ - public IConnectorType getConnectorType(String id, boolean unique) { - IConnectorType contribution = null; - if (getExtensions().containsKey(id)) { - Proxy proxy = getExtensions().get(id); - // Get the extension instance - contribution = unique ? proxy.newInstance() : proxy.getInstance(); - } - - return contribution; - } - - /** - * Returns the map of managed extensions. If not loaded before, - * this methods trigger the loading of the extensions to the managed - * extension point. - * - * @return The map of extensions. - */ - protected Map<String, Proxy> getExtensions() { - // Load and store the extensions thread-safe! - synchronized (extensionsMap) { - if (!initialized) { loadExtensions(); initialized = true; } - } - return extensionsMap; - } - - /** - * Returns the extension point comparator instance. If not available, - * {@link #doCreateExtensionPointComparator()} is called to create a new instance. - * - * @return The extension point comparator or <code>null</code> if the instance creation fails. - */ - protected final ExtensionPointComparator getExtensionPointComparator() { - if (comparator == null) { - comparator = new ExtensionPointComparator(); - } - return comparator; - } - - /** - * Returns the extensions of the specified extension point sorted. - * <p> - * For the order of the extensions, see {@link ExtensionPointComparator}. - * - * @param point The extension point. Must not be <code>null</code>. - * @return The extensions in sorted order or an empty array if the extension point has no extensions. - */ - protected IExtension[] getExtensionsSorted(IExtensionPoint point) { - Assert.isNotNull(point); - - List<IExtension> extensions = new ArrayList<IExtension>(Arrays.asList(point.getExtensions())); - if (extensions.size() > 0) { - Collections.sort(extensions, getExtensionPointComparator()); - } - - return extensions.toArray(new IExtension[extensions.size()]); - } - - /** - * Loads the extensions for the managed extension point. - */ - protected void loadExtensions() { - // If already initialized, this method will do nothing. - if (initialized) return; - - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint point = registry.getExtensionPoint("org.eclipse.tcf.te.ui.terminals.connectorTypes"); //$NON-NLS-1$ - if (point != null) { - IExtension[] extensions = getExtensionsSorted(point); - for (IExtension extension : extensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - for (IConfigurationElement element : elements) { - if ("connectorType".equals(element.getName())) { //$NON-NLS-1$ - try { - Proxy candidate = new Proxy(element); - if (candidate.getId() != null) { - // If no extension with this id had been registered before, register now. - if (!extensionsMap.containsKey(candidate.getId())) { - extensionsMap.put(candidate.getId(), candidate); - } - else { - throw new CoreException(new Status(IStatus.ERROR, - UIPlugin.getUniqueIdentifier(), - 0, - NLS.bind(Messages.Extension_error_duplicateExtension, candidate.getId(), element.getContributor().getName()), - null)); - } - } else { - throw new CoreException(new Status(IStatus.ERROR, - UIPlugin.getUniqueIdentifier(), - 0, - NLS.bind(Messages.Extension_error_missingRequiredAttribute, "id", element.getAttribute("label")), //$NON-NLS-1$ //$NON-NLS-2$ - null)); - } - } catch (CoreException e) { - Platform.getLog(UIPlugin.getDefault().getBundle()).log(new Status(IStatus.ERROR, - UIPlugin.getUniqueIdentifier(), - NLS.bind(Messages.Extension_error_invalidExtensionPoint, element.getDeclaringExtension().getUniqueIdentifier()), e)); - } - } - } - } - } - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java index ee1a46d5f..c01fa3696 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals/src/org/eclipse/tcf/te/ui/terminals/view/TerminalsViewMementoHandler.java @@ -96,11 +96,6 @@ public class TerminalsViewMementoHandler { connectionMemento.putString(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, terminalConnectorId); } - String connectorTypeId = (String)properties.get(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID); - if (connectorTypeId != null) { - connectionMemento.putString(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, connectorTypeId); - } - if (properties.get(ITerminalsConnectorConstants.PROP_FORCE_NEW) instanceof Boolean) { connectionMemento.putBoolean(ITerminalsConnectorConstants.PROP_FORCE_NEW, ((Boolean)properties.get(ITerminalsConnectorConstants.PROP_FORCE_NEW)).booleanValue()); } @@ -167,7 +162,6 @@ public class TerminalsViewMementoHandler { // Restore the common attributes properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, connection.getString(ITerminalsConnectorConstants.PROP_DELEGATE_ID)); properties.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, connection.getString(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID)); - properties.put(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID, connection.getString(ITerminalsConnectorConstants.PROP_CONNECTOR_TYPE_ID)); if (connection.getBoolean(ITerminalsConnectorConstants.PROP_FORCE_NEW) != null) { properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, connection.getBoolean(ITerminalsConnectorConstants.PROP_FORCE_NEW)); } |