Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java')
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java
new file mode 100644
index 000000000..112d34fff
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.tm.te.tcf.terminals.ui.launcher;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tm.tcf.protocol.IPeer;
+import org.eclipse.tm.tcf.protocol.Protocol;
+import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tm.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tm.te.tcf.terminals.core.interfaces.launcher.ITerminalsLauncher;
+import org.eclipse.tm.te.tcf.terminals.core.launcher.TerminalsLauncher;
+import org.eclipse.tm.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tm.te.ui.controls.interfaces.IWizardConfigurationPanel;
+import org.eclipse.tm.te.ui.terminals.launcher.AbstractLauncherDelegate;
+
+/**
+ * Terminals launcher delegate implementation.
+ */
+public class LauncherDelegate extends AbstractLauncherDelegate {
+ private IWizardConfigurationPanel configPanel = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.terminals.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.te.ui.controls.BaseDialogPageControl)
+ */
+ @Override
+ public IWizardConfigurationPanel getPanel(BaseDialogPageControl parentControl) {
+ if (configPanel == null || configPanel.getControl() == null || configPanel.getControl().isDisposed()) {
+ configPanel = new SettingsPanel(parentControl);
+ }
+ return configPanel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.terminals.interfaces.ILauncherDelegate#execute(org.eclipse.tm.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tm.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(IPropertiesContainer properties, ICallback callback) {
+ Assert.isNotNull(properties);
+
+ // Get the selection from the properties
+ ISelection selection = (ISelection)properties.getProperty("selection"); //$NON-NLS-1$
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ if (element instanceof IPeerModel) {
+ final IPeerModel peerModel = (IPeerModel)element;
+ final AtomicReference<IPeer> peer = new AtomicReference<IPeer>();
+ if (Protocol.isDispatchThread()) {
+ peer.set(peerModel.getPeer());
+ } else {
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ peer.set(peerModel.getPeer());
+ }
+ });
+ }
+
+ if (peer.get() != null) {
+ ITerminalsLauncher launcher = new TerminalsLauncher();
+ launcher.launch(peer.get(), properties, callback);
+ }
+ }
+
+ }
+ }
+}

Back to the top