Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2015-02-17 09:32:24 +0000
committerUwe Stieber2015-02-17 09:32:24 +0000
commit3e7bc9fefb2d3e8e5abbb593a81c08b827f63e88 (patch)
tree0af0a16b03e08b7dcc3deb33abf01fed349762c0 /terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te
parentf00c0e318e23353e6a15bec9479d85e9856f7db5 (diff)
downloadorg.eclipse.tcf-3e7bc9fefb2d3e8e5abbb593a81c08b827f63e88.tar.gz
org.eclipse.tcf-3e7bc9fefb2d3e8e5abbb593a81c08b827f63e88.tar.xz
org.eclipse.tcf-3e7bc9fefb2d3e8e5abbb593a81c08b827f63e88.zip
Terminals: Move terminals plugins and features into separate directory structure
Diffstat (limited to 'terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te')
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/activator/UIPlugin.java113
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/LaunchTerminalHandler.java90
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/PropertyTester.java60
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/TerminalContextPropertiesProvider.java67
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.java32
-rw-r--r--terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.properties10
6 files changed, 372 insertions, 0 deletions
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/activator/UIPlugin.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/activator/UIPlugin.java
new file mode 100644
index 000000000..614dbaaf8
--- /dev/null
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/activator/UIPlugin.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 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.rse.activator;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.core.terminals.tracing.TraceHandler;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class UIPlugin extends AbstractUIPlugin {
+ // The shared instance
+ private static UIPlugin plugin;
+
+ // The trace handler instance
+ private static volatile TraceHandler traceHandler;
+
+ /**
+ * The constructor
+ */
+ public UIPlugin() {
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static UIPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ */
+ public static String getUniqueIdentifier() {
+ if (getDefault() != null && getDefault().getBundle() != null) {
+ return getDefault().getBundle().getSymbolicName();
+ }
+ return "org.eclipse.tcf.te.ui.terminals.rse"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the bundles trace handler.
+ *
+ * @return The bundles trace handler.
+ */
+ public static TraceHandler getTraceHandler() {
+ if (traceHandler == null) {
+ traceHandler = new TraceHandler(getUniqueIdentifier());
+ }
+ return traceHandler;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
+ */
+ @Override
+ protected void initializeImageRegistry(ImageRegistry registry) {
+ super.initializeImageRegistry(registry);
+ }
+
+ /**
+ * Loads the image registered under the specified key from the image
+ * registry and returns the <code>Image</code> object instance.
+ *
+ * @param key The key the image is registered with.
+ * @return The <code>Image</code> object instance or <code>null</code>.
+ */
+ public static Image getImage(String key) {
+ return getDefault().getImageRegistry().get(key);
+ }
+
+ /**
+ * Loads the image registered under the specified key from the image
+ * registry and returns the <code>ImageDescriptor</code> object instance.
+ *
+ * @param key The key the image is registered with.
+ * @return The <code>ImageDescriptor</code> object instance or <code>null</code>.
+ */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ return getDefault().getImageRegistry().getDescriptor(key);
+ }
+}
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/LaunchTerminalHandler.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/LaunchTerminalHandler.java
new file mode 100644
index 000000000..c70f82993
--- /dev/null
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/LaunchTerminalHandler.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 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.rse.internal;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.rse.core.filters.ISystemFilterReference;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.IRSEModelObject;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.core.terminals.interfaces.constants.ITerminalsConnectorConstants;
+import org.eclipse.tcf.te.ui.terminals.interfaces.ILauncherDelegate;
+import org.eclipse.tcf.te.ui.terminals.internal.dialogs.LaunchTerminalSettingsDialog;
+import org.eclipse.tcf.te.ui.terminals.launcher.LauncherDelegateManager;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Launch terminal handler implementation.
+ */
+@SuppressWarnings("restriction")
+public class LaunchTerminalHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // Get the active shell
+ Shell shell = HandlerUtil.getActiveShell(event);
+ // Get the current selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ // The handler is enabled only if just one element is selected
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof IRSEModelObject || element instanceof IRemoteFile) {
+ // Determine the host
+ IHost host = null;
+
+ if (element instanceof IHost) host = (IHost) element;
+ if (host == null && element instanceof ISubSystem) host = ((ISubSystem) element).getHost();
+ if (host == null && element instanceof ISystemFilterReference) host = ((ISystemFilterReference) element).getSubSystem().getHost();
+ if (host == null && element instanceof IRemoteFile) host = ((IRemoteFile) element).getHost();
+
+ if (host != null) {
+ // Open the launch terminal settings dialog with the SSH panel only
+ LaunchTerminalSettingsDialog dialog = new LaunchTerminalSettingsDialog(shell) {
+ @Override
+ protected boolean isFiltered(ISelection selection, ILauncherDelegate delegate) {
+ Assert.isNotNull(delegate);
+ return !"org.eclipse.tcf.te.ui.terminals.ssh.launcher.ssh".equals(delegate.getId()); //$NON-NLS-1$
+ }
+ };
+ dialog.setSelection(new StructuredSelection(host));
+
+ if (dialog.open() == Window.OK) {
+ // Get the terminal settings from the dialog
+ Map<String, Object> properties = dialog.getSettings();
+ if (properties != null) {
+ String delegateId = (String)properties.get(ITerminalsConnectorConstants.PROP_DELEGATE_ID);
+ Assert.isNotNull(delegateId);
+ ILauncherDelegate delegate = LauncherDelegateManager.getInstance().getLauncherDelegate(delegateId, false);
+ Assert.isNotNull(delegateId);
+ delegate.execute(properties, null);
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/PropertyTester.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/PropertyTester.java
new file mode 100644
index 000000000..5aa6ea079
--- /dev/null
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/PropertyTester.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 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.rse.internal;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.rse.core.filters.ISystemFilterReference;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+
+
+
+/**
+ * Terminals RSE add-on property tester implementation.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+ // Supported system type id's
+ private final static String[] VALID_SYSTEM_TYPES = new String[] {
+ "org.eclipse.rse.systemtype.linux", //$NON-NLS-1$
+ "org.eclipse.rse.systemtype.unix", //$NON-NLS-1$
+ "org.eclipse.rse.systemtype.aix", //$NON-NLS-1$
+ "org.eclipse.rse.systemtype.ssh" //$NON-NLS-1$
+ };
+
+ private final static List<String> VALID_SYSTEM_TYPES_LIST = Arrays.asList(VALID_SYSTEM_TYPES);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ // Determine the host object
+ IHost host = null;
+
+ if (receiver instanceof IHost) host = (IHost) receiver;
+ if (host == null && receiver instanceof ISubSystem) host = ((ISubSystem) receiver).getHost();
+ if (host == null && receiver instanceof ISystemFilterReference) host = ((ISystemFilterReference) receiver).getSubSystem().getHost();
+ if (host == null && receiver instanceof IRemoteFile) host = ((IRemoteFile) receiver).getHost();
+
+ if (host != null) {
+ if ("isVisible".equals(property) && expectedValue instanceof Boolean) { //$NON-NLS-1$
+ String systemTypeID = host.getSystemType().getId();
+ boolean validID = systemTypeID != null ? VALID_SYSTEM_TYPES_LIST.contains(systemTypeID) : false;
+ return ((Boolean)expectedValue).booleanValue() == validID;
+ }
+ }
+
+ return false;
+ }
+
+}
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/TerminalContextPropertiesProvider.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/TerminalContextPropertiesProvider.java
new file mode 100644
index 000000000..706379f6a
--- /dev/null
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/internal/TerminalContextPropertiesProvider.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.terminals.rse.internal;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalContextPropertiesProvider;
+import org.eclipse.tcf.te.core.terminals.interfaces.constants.IContextPropertiesConstants;
+
+/**
+ * Terminal context properties provider implementation.
+ */
+public class TerminalContextPropertiesProvider implements ITerminalContextPropertiesProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.core.terminals.interfaces.ITerminalContextPropertiesProvider#getTargetAddress(java.lang.Object)
+ */
+ @Override
+ public Map<String, String> getTargetAddress(Object context) {
+ if (context instanceof IHost) {
+ IHost host = (IHost) context;
+
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(IContextPropertiesConstants.PROP_ADDRESS, host.getHostName());
+ props.put(IContextPropertiesConstants.PROP_NAME, host.getName());
+
+ return props;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.core.terminals.interfaces.ITerminalContextPropertiesProvider#getProperty(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public Object getProperty(Object context, String key) {
+ if (context instanceof IHost) {
+ IHost host = (IHost) context;
+
+ if (IContextPropertiesConstants.PROP_DEFAULT_USER.equals(key)) {
+ String user = host.getDefaultUserId();
+ if (user != null && !"".equals(user.trim())) { //$NON-NLS-1$
+ return user;
+ }
+ }
+
+ if (IContextPropertiesConstants.PROP_DEFAULT_ENCODING.equals(key)) {
+ String encoding = host.getDefaultEncoding(true);
+ if (encoding != null && !"".equals(encoding)) { //$NON-NLS-1$
+ return encoding;
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.java b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.java
new file mode 100644
index 000000000..7732c2e71
--- /dev/null
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 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.rse.nls;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Externalized strings management.
+ */
+public class Messages extends NLS {
+
+ // The plug-in resource bundle name
+ private static final String BUNDLE_NAME = "org.eclipse.tcf.te.ui.terminals.rse.nls.Messages"; //$NON-NLS-1$
+
+ /**
+ * Static constructor.
+ */
+ static {
+ // Load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ // **** Declare externalized string id's down here *****
+
+}
diff --git a/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.properties b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.properties
new file mode 100644
index 000000000..2e332db1c
--- /dev/null
+++ b/terminals/plugins/org.eclipse.tcf.te.ui.terminals.rse/src/org/eclipse/tcf/te/ui/terminals/rse/nls/Messages.properties
@@ -0,0 +1,10 @@
+###############################################################################
+# Copyright (c) 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
+###############################################################################
+

Back to the top