Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-05-14 09:32:51 +0000
committerTobias Schwarz2014-05-14 09:32:51 +0000
commitc0283368508c615997f8b080ac9a3c63fb6ddfe9 (patch)
treed29549e2aa6da2573c7857950a49b8c01d7269bb /target_explorer
parent66884ea8b29dd827e4488cdaef02cf1119c3bc6a (diff)
downloadorg.eclipse.tcf-c0283368508c615997f8b080ac9a3c63fb6ddfe9.tar.gz
org.eclipse.tcf-c0283368508c615997f8b080ac9a3c63fb6ddfe9.tar.xz
org.eclipse.tcf-c0283368508c615997f8b080ac9a3c63fb6ddfe9.zip
Target Exlorer: add attach action to toolbar action menu
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IContextDataProperties.java23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/META-INF/MANIFEST.MF9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.xml81
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java39
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessesDataProperties.java23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepGroupIds.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepperServiceOperations.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/steps/IProcessesStepAttributes.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/GsonProcessContextItemPersistenceDelegate.java77
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/services/StepperOperationService.java92
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextStep.java110
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextsIterator.java82
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java139
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/attach.gifbin0 -> 962 bytes
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/detach.gifbin0 -> 956 bytes
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml65
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/activator/UIPlugin.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextHandler.java100
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextToolbarHandler.java42
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/ImageConsts.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java199
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java503
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/DelegateService.java42
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java173
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IPreferenceKeys.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PreferencesInitializer.java40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/IDataExchangeDialog.java26
41 files changed, 2077 insertions, 28 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
index effbba95e..79e8173a4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java
@@ -362,7 +362,7 @@ public class Stepper implements IStepper {
if (!data.getBooleanProperty(IStepAttributes.PROP_SKIP_LAST_RUN_HISTORY)) {
// this is the history used for the list of history actions and the history dialog
- HistoryManager.getInstance().add(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + context.getId(), historyData, 10); //$NON-NLS-1$
+ HistoryManager.getInstance().add(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + context.getId(), historyData, 50); //$NON-NLS-1$
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IContextDataProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IContextDataProperties.java
new file mode 100644
index 000000000..cd8c076a3
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IContextDataProperties.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 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.tcf.core.interfaces;
+
+/**
+ * Keys for context data.
+ */
+public interface IContextDataProperties {
+
+ /**
+ * Data key holding the list of selected contexts.
+ */
+ public static final String PROPERTY_CONTEXT_LIST = "contextList"; //$NON-NLS-1$
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java
index a7c9b3629..86fb76f58 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java
@@ -37,6 +37,9 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
*/
public class StartDebuggerStep extends AbstractPeerNodeStep {
+ public static final String PARAM_ATTACH_ALL = "autoAttachAll"; //$NON-NLS-1$
+ public static final String PARAM_FORCE_START_DEBUGGER = "forceStart"; //$NON-NLS-1$
+
/**
* Interface to be implemented by start debugger step delegates.
*/
@@ -72,10 +75,12 @@ public class StartDebuggerStep extends AbstractPeerNodeStep {
public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId);
Assert.isNotNull(node);
- String value = getParameters().get("autoAttachAll"); //$NON-NLS-1$
+ String value = getParameters().get(PARAM_ATTACH_ALL);
final boolean autoAttachAll = value != null ? Boolean.parseBoolean(value) : false;
+ value = getParameters().get(PARAM_FORCE_START_DEBUGGER);
+ final boolean forceStart = value != null ? Boolean.parseBoolean(value) : false;
- if (StepperAttributeUtil.getBooleanProperty(IStepAttributes.ATTR_START_DEBUGGER, fullQualifiedId, data)) {
+ if (forceStart || StepperAttributeUtil.getBooleanProperty(IStepAttributes.ATTR_START_DEBUGGER, fullQualifiedId, data)) {
Protocol.invokeLater(new Runnable() {
@Override
public void run() {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/META-INF/MANIFEST.MF
index facd16b9f..3f0f7f5ca 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/META-INF/MANIFEST.MF
@@ -16,13 +16,15 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400",
org.eclipse.tcf.te.tcf.core;bundle-version="1.3.0",
org.eclipse.tcf.te.tcf.core.model;bundle-version="1.3.0",
org.eclipse.tcf.te.tcf.locator;bundle-version="1.3.0",
- org.eclipse.tcf.te.runtime.stepper;bundle-version="1.3.0"
+ org.eclipse.tcf.te.runtime.stepper;bundle-version="1.3.0",
+ org.eclipse.tcf.te.runtime.persistence;bundle-version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.tcf.te.tcf.processes.core.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.core.interfaces,
org.eclipse.tcf.te.tcf.processes.core.interfaces.launcher,
+ org.eclipse.tcf.te.tcf.processes.core.interfaces.services,
org.eclipse.tcf.te.tcf.processes.core.interfaces.steps,
org.eclipse.tcf.te.tcf.processes.core.interfaces.tracing;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.core.launcher,
@@ -38,4 +40,7 @@ Export-Package: org.eclipse.tcf.te.tcf.processes.core.activator;x-internal:=true
org.eclipse.tcf.te.tcf.processes.core.model.runtime.services,
org.eclipse.tcf.te.tcf.processes.core.model.steps,
org.eclipse.tcf.te.tcf.processes.core.nls;x-internal:=true,
- org.eclipse.tcf.te.tcf.processes.core.steps
+ org.eclipse.tcf.te.tcf.processes.core.persistence,
+ org.eclipse.tcf.te.tcf.processes.core.services,
+ org.eclipse.tcf.te.tcf.processes.core.steps,
+ org.eclipse.tcf.te.tcf.processes.core.util
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.properties
index 850642c5f..8ac133de4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.properties
@@ -11,6 +11,7 @@
pluginName = Target Explorer, TCF Processes Extensions Core
providerName = Eclipse.org - Target Explorer
+AttachContextStep.name = Attach Context
LaunchProcessStep.name = Launch Process
ResumeProcessStep.name=Resume Process
InitializeModelStep.name=Initialize Processes Runtime Model
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.xml
index 11fade104..71e75caf0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/plugin.xml
@@ -14,6 +14,20 @@
<!-- Service contributions -->
<extension point="org.eclipse.tcf.te.runtime.services.services">
<service
+ class="org.eclipse.tcf.te.tcf.processes.core.services.StepperOperationService"
+ id="org.eclipse.tcf.te.tcf.processes.core.services.stepper">
+ <serviceType
+ bundleId="org.eclipse.tcf.te.runtime.stepper"
+ class="org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService">
+ </serviceType>
+ <enablement>
+ <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
+ <test property="org.eclipse.tcf.te.tcf.locator.hasOfflineService" value="Processes"/>
+ </adapt>
+ </enablement>
+ </service>
+
+ <service
class="org.eclipse.tcf.te.tcf.core.model.services.PropertiesAccessService"
id="org.eclipse.tcf.te.tcf.processes.services.tcf.propertiesAccess">
<serviceType
@@ -28,6 +42,47 @@
</service>
</extension>
+<!-- Persistence delegate contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.persistence.delegates">
+ <delegate
+ id="org.eclipse.tcf.te.tcf.processes.core.persistence.gson.processContextItem"
+ class="org.eclipse.tcf.te.tcf.processes.core.persistence.GsonProcessContextItemPersistenceDelegate">
+ </delegate>
+ </extension>
+
+<!-- Persistence delegate bindings contributions -->
+ <extension
+ point="org.eclipse.tcf.te.runtime.persistence.bindings">
+ <binding
+ delegateId="org.eclipse.tcf.te.tcf.processes.core.persistence.gson.processContextItem"
+ id="org.eclipse.tcf.te.tcf.processes.core.persistence.binding.gson.map">
+ <enablement>
+ <with variable="container">
+ <or>
+ <instanceof value="java.lang.String"/>
+ <and>
+ <instanceof value="java.lang.Class"/>
+ <with variable="containerClass">
+ <equals value="java.lang.String"/>
+ </with>
+ </and>
+ </or>
+ </with>
+ <with variable="context">
+ <or>
+ <instanceof value="org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem"/>
+ <and>
+ <instanceof value="java.lang.Class"/>
+ <with variable="contextClass">
+ <equals value="org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem"/>
+ </with>
+ </and>
+ </or>
+ </with>
+ </enablement>
+ </binding>
+ </extension>
+
<!-- Eclipse core expressions property tester -->
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
@@ -62,6 +117,10 @@
id="org.eclipse.tcf.te.tcf.processes.core.disposeModelStep"
label="%DisposeModelStep.name">
</step>
+ <step
+ id="org.eclipse.tcf.te.tcf.processes.core.attachContextStep"
+ class="org.eclipse.tcf.te.tcf.processes.core.steps.AttachContextStep"
+ label="%AttachContextStep.name"/>
</extension>
<!-- Step group contributions -->
@@ -97,5 +156,27 @@
insertAfter="org.eclipse.tcf.te.tcf.core.shutDownStep"/>
</references>
</stepGroup>
+
+ <stepGroup
+ id="org.eclipse.tcf.te.tcf.processes.core.attachStepGroup"
+ label="%AttachStepGroup.name">
+ <references>
+ <reference id="org.eclipse.tcf.te.tcf.core.openChannelStep"/>
+ <reference id="org.eclipse.tcf.te.tcf.processes.core.internal.attachStepGroup"/>
+ <reference id="org.eclipse.tcf.te.tcf.locator.startDebuggerStep">
+ <parameter name="forceStart" value="true"/>
+ </reference>
+ <reference id="org.eclipse.tcf.te.tcf.core.closeChannelStep"/>
+ </references>
+ </stepGroup>
+
+ <stepGroup
+ id="org.eclipse.tcf.te.tcf.processes.core.internal.attachStepGroup"
+ label="%AttachStepGroup.name"
+ iterator="org.eclipse.tcf.te.tcf.processes.core.steps.AttachContextsIterator">
+ <references>
+ <reference id="org.eclipse.tcf.te.tcf.processes.core.attachContextStep"/>
+ </references>
+ </stepGroup>
</extension>
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java
new file mode 100644
index 000000000..a6768fb22
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessContextItem.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 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.tcf.processes.core.interfaces;
+
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+
+/**
+ * IProcessContextItem
+ */
+public interface IProcessContextItem extends IPropertiesContainer {
+
+ public static final String PROPERTY_ID = "id"; //$NON-NLS-1$
+ public static final String PROPERTY_PID = "pid"; //$NON-NLS-1$
+ public static final String PROPERTY_NAME = "name"; //$NON-NLS-1$
+ public static final String PROPERTY_PATH = "path"; //$NON-NLS-1$
+
+ /**
+ * Return the context id.
+ */
+ public String getId();
+
+ /**
+ * Return the context name.
+ */
+ public String getName();
+
+ /**
+ * Return the context path.
+ */
+ public String[] getPath();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessesDataProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessesDataProperties.java
new file mode 100644
index 000000000..80f34f3d1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/IProcessesDataProperties.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.interfaces;
+
+/**
+ * Keys for process data.
+ */
+public interface IProcessesDataProperties {
+
+ /**
+ * Data key holding a list of process context data.
+ */
+ public static final String PROPERTY_CONTEXT_LIST = "processContextList"; //$NON-NLS-1$
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepGroupIds.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepGroupIds.java
new file mode 100644
index 000000000..a343592d9
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepGroupIds.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.interfaces.services;
+
+/**
+ * IStepGroupIds
+ */
+public interface IStepGroupIds {
+
+ public static final String ATTACH = "org.eclipse.tcf.te.tcf.processes.core.attachStepGroup"; //$NON-NLS-1$
+ public static final String DETACH = "org.eclipse.tcf.te.tcf.processes.core.detachStepGroup"; //$NON-NLS-1$
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepperServiceOperations.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepperServiceOperations.java
new file mode 100644
index 000000000..258e0dbb1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/services/IStepperServiceOperations.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.interfaces.services;
+
+/**
+ * IStepperServiceOperations
+ */
+public interface IStepperServiceOperations {
+
+ public static final String ATTACH = "attach"; //$NON-NLS-1$
+ public static final String DETACH = "detach"; //$NON-NLS-1$
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/steps/IProcessesStepAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/steps/IProcessesStepAttributes.java
index 893ffa912..e5c7a8de9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/steps/IProcessesStepAttributes.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/interfaces/steps/IProcessesStepAttributes.java
@@ -69,4 +69,9 @@ public interface IProcessesStepAttributes {
* Launch configuration attribute (internal use): The process context object.
*/
public static final String ATTR_PROCESS_CONTEXT = ATTR_PREFIX + ".process_context"; //$NON-NLS-1$
+
+ /**
+ * Launch configuration attribute (internal use): The process context node object.
+ */
+ public static final String ATTR_PROCESS_CONTEXT_NODE = ATTR_PREFIX + ".process_context_node"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/GsonProcessContextItemPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/GsonProcessContextItemPersistenceDelegate.java
new file mode 100644
index 000000000..81a1e023c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/GsonProcessContextItemPersistenceDelegate.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.persistence;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.tcf.te.runtime.persistence.delegates.GsonMapPersistenceDelegate;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+
+/**
+ * Process context item to string delegate implementation.
+ */
+public class GsonProcessContextItemPersistenceDelegate extends GsonMapPersistenceDelegate {
+
+ /**
+ * Constructor.
+ */
+ public GsonProcessContextItemPersistenceDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(java.lang.Object)
+ */
+ @Override
+ public Class<?> getPersistedClass(Object context) {
+ return IProcessContextItem.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#toMap(java.lang.Object)
+ */
+ @Override
+ protected Map<String, Object> toMap(final Object context) throws IOException {
+ IProcessContextItem item = getProcessContextItem(context);
+ if (item != null) {
+ return super.toMap(item.getProperties());
+ }
+
+ return new HashMap<String, Object>();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#fromMap(java.util.Map, java.lang.Object)
+ */
+ @Override
+ protected Object fromMap(Map<String, Object> map, Object context) throws IOException {
+ IProcessContextItem item = new ProcessContextItem();
+ item.setProperties(map);
+ return item;
+ }
+
+ /**
+ * Get a process context item from the given context.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @return The process context item or <code>null</code>.
+ */
+ protected IProcessContextItem getProcessContextItem(Object context) {
+ IProcessContextItem item = null;
+
+ if (context instanceof IProcessContextItem) {
+ item = (IProcessContextItem)context;
+ }
+
+ return item;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java
new file mode 100644
index 000000000..ce83190eb
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/persistence/ProcessContextItem.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.persistence;
+
+import java.util.List;
+
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+
+/**
+ * ProcessContextItem
+ */
+public class ProcessContextItem extends PropertiesContainer implements IProcessContextItem {
+
+ /**
+ * Constructor.
+ */
+ public ProcessContextItem() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem#getId()
+ */
+ @Override
+ public String getId() {
+ return getStringProperty(PROPERTY_ID);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem#getName()
+ */
+ @Override
+ public String getName() {
+ return getStringProperty(PROPERTY_NAME);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem#getPath()
+ */
+ @Override
+ public String[] getPath() {
+ Object path = getProperty(PROPERTY_PATH);
+ if (path instanceof String[]) {
+ return (String[])path;
+ }
+ if (path instanceof List<?>) {
+ return ((List<?>)path).toArray(new String[((List<?>)path).size()]);
+ }
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/services/StepperOperationService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/services/StepperOperationService.java
new file mode 100644
index 000000000..0218c5cc1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/services/StepperOperationService.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.services;
+
+import org.eclipse.tcf.te.runtime.stepper.services.AbstractStepperOperationService;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.services.IStepGroupIds;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.services.IStepperServiceOperations;
+
+/**
+ * Processes stepper operation service implementation.
+ */
+public class StepperOperationService extends AbstractStepperOperationService {
+ /**
+ * Constructor.
+ */
+ public StepperOperationService() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.services.StepperOperationService#isHandledOperation(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isHandledOperation(Object context, String operation) {
+ return IStepperServiceOperations.ATTACH.equals(operation) ||
+ IStepperServiceOperations.DETACH.equals(operation);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.services.StepperOperationService#addToActionHistory(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean addToActionHistory(Object context, String operation) {
+ return IStepperServiceOperations.ATTACH.equals(operation) ||
+ IStepperServiceOperations.DETACH.equals(operation);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.services.StepperOperationService#getStepGroupId(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public String getStepGroupId(Object context, String operation) {
+ if (IStepperServiceOperations.ATTACH.equals(operation)) {
+ return IStepGroupIds.ATTACH;
+ }
+ if (IStepperServiceOperations.DETACH.equals(operation)) {
+ return IStepGroupIds.DETACH;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.services.StepperOperationService#getStepGroupName(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public String getStepGroupName(Object context, String operation) {
+ if (IStepperServiceOperations.ATTACH.equals(operation)) {
+ return "Attach"; //$NON-NLS-1$
+ }
+ if (IStepperServiceOperations.DETACH.equals(operation)) {
+ return "Detach"; //$NON-NLS-1$
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService#isEnabled(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isEnabled(Object context, String operation) {
+ return IStepperServiceOperations.ATTACH.equals(operation) ||
+ IStepperServiceOperations.DETACH.equals(operation);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.services.StepperOperationService#isCancelable(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isCancelable(Object context, String operation) {
+ return IStepperServiceOperations.ATTACH.equals(operation) ||
+ IStepperServiceOperations.DETACH.equals(operation);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextStep.java
new file mode 100644
index 000000000..78452b76f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextStep.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.steps;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IProcesses;
+import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes;
+import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel;
+import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService;
+import org.eclipse.tcf.te.tcf.locator.steps.AbstractPeerNodeStep;
+import org.eclipse.tcf.te.tcf.processes.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.steps.IProcessesStepAttributes;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+
+/**
+ * Attach context step implementation.
+ */
+public class AttachContextStep extends AbstractPeerNodeStep {
+
+ /**
+ * Constructor.
+ */
+ public AttachContextStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ if (channel == null || channel.getState() != IChannel.STATE_OPEN) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing or closed channel")); //$NON-NLS-1$
+ }
+
+ IProcesses.ProcessContext processContext = (IProcesses.ProcessContext)StepperAttributeUtil.getProperty(IProcessesStepAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId, data);
+ if (processContext == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing process context")); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
+ if (Protocol.isDispatchThread()) {
+ internalExecute(context, data, fullQualifiedId, monitor, callback);
+ }
+ else {
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ internalExecute(context, data, fullQualifiedId, monitor, callback);
+ }
+ });
+ }
+ }
+
+ protected void internalExecute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
+ final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ final IProcesses.ProcessContext processContext = (IProcesses.ProcessContext)StepperAttributeUtil.getProperty(IProcessesStepAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId, data);
+ final IProcessContextNode processContextNode = (IProcessContextNode)StepperAttributeUtil.getProperty(IProcessesStepAttributes.ATTR_PROCESS_CONTEXT_NODE, fullQualifiedId, data);
+ final IProcesses processes = channel.getRemoteService(IProcesses.class);
+
+ if (processes != null) {
+ processContext.attach(new IProcesses.DoneCommand() {
+ @Override
+ public void doneCommand(IToken token, Exception error) {
+ if (processContextNode != null) {
+ IModel model = processContextNode.getParent(IModel.class);
+ Assert.isNotNull(model);
+ model.getService(IModelRefreshService.class).refresh(processContextNode, new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
+ });
+ }
+ else {
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
+ }
+ });
+ }
+ else {
+ callback.done(this, new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing processes service")); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextsIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextsIterator.java
new file mode 100644
index 000000000..ebdf9abc3
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/steps/AttachContextsIterator.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.steps;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.iterators.AbstractPeerNodeStepGroupIterator;
+import org.eclipse.tcf.te.tcf.processes.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessesDataProperties;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.steps.IProcessesStepAttributes;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+import org.eclipse.tcf.te.tcf.processes.core.util.ProcessDataHelper;
+
+/**
+ * Step group iterator for attach contexts.
+ */
+public class AttachContextsIterator extends AbstractPeerNodeStepGroupIterator {
+
+ final List<IProcessContextNode> items = new ArrayList<IProcessContextNode>();
+
+ /**
+ * Constructor.
+ */
+ public AttachContextsIterator() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupIterator#initialize(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void initialize(IStepContext context, final IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ super.initialize(context, data, fullQualifiedId, monitor);
+ final IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId);
+
+ for (IProcessContextItem item : ProcessDataHelper.decodeProcessContextItems(data.getStringProperty(IProcessesDataProperties.PROPERTY_CONTEXT_LIST))) {
+ for (IProcessContextNode node : ProcessDataHelper.getProcessContextNodes(peerNode, item)) {
+ items.add(node);
+ }
+ }
+ setIterations(items.size());
+
+ if (items.isEmpty()) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Cannot find contexts to attach.")); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void internalNext(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ final IProcessContextNode item = items.get(getIteration());
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ StepperAttributeUtil.setProperty(IProcessesStepAttributes.ATTR_PROCESS_CONTEXT_NODE, fullQualifiedId, data, item);
+ StepperAttributeUtil.setProperty(IProcessesStepAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId, data, item.getProcessContext());
+ }
+ });
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java
new file mode 100644
index 000000000..cb66803c1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/util/ProcessDataHelper.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * 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.tcf.processes.core.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModelLookupService;
+import org.eclipse.tcf.te.tcf.processes.core.persistence.ProcessContextItem;
+
+/**
+ * Process data helper for en/decoding.
+ */
+public class ProcessDataHelper {
+
+ public static final String encodeProcessContextItems(IProcessContextItem[] items) {
+ try {
+ if (items != null && items.length > 0) {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IProcessContextItem.class, String.class);
+ return (String)delegate.writeList(items, String.class);
+ }
+ }
+ catch (Exception e) {
+ }
+ return null;
+ }
+
+ public static final IProcessContextItem[] decodeProcessContextItems(String encoded) {
+ if (encoded != null && encoded.trim().length() > 0) {
+ try {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IProcessContextItem.class, String.class);
+ Object[] input = delegate.readList(IProcessContextItem.class, encoded);
+ List<IProcessContextItem> items = new ArrayList<IProcessContextItem>();
+ for (Object object : input) {
+ if (object instanceof IProcessContextItem) {
+ items.add((IProcessContextItem)object);
+ }
+ }
+ return items.toArray(new IProcessContextItem[items.size()]);
+ }
+ catch (Exception e) {
+ }
+ }
+ return new IProcessContextItem[0];
+ }
+
+ public static final IProcessContextItem getProcessContextItem(final IProcessContextNode node) {
+ final AtomicReference<IProcessContextItem> ctxItem = new AtomicReference<IProcessContextItem>();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if (node.getProcessContext().getProperties().containsKey("CanAttach")) { //$NON-NLS-1$
+ Boolean value = (Boolean)node.getProcessContext().getProperties().get("CanAttach"); //$NON-NLS-1$
+ if (value != null && value.booleanValue()) {
+ IProcessContextItem item = new ProcessContextItem();
+ item.setProperty(IProcessContextItem.PROPERTY_ID, node.getProcessContext().getID());
+ item.setProperty(IProcessContextItem.PROPERTY_PID, node.getSysMonitorContext().getPID());
+ item.setProperty(IProcessContextItem.PROPERTY_NAME, node.getProcessContext().getName());
+ item.setProperty(IProcessContextItem.PROPERTY_PATH, getProcessContextNodePath(node));
+ ctxItem.set(item);
+ }
+ }
+ }
+ });
+ return ctxItem.get();
+ }
+
+ protected static final String[] getProcessContextNodePath(IProcessContextNode node) {
+ List<String> path = new ArrayList<String>();
+ while (node.getParent() instanceof IProcessContextNode) {
+ node = (IProcessContextNode)node.getParent();
+ path.add(0, node.getProcessContext().getName());
+ }
+ return path.toArray(new String[path.size()]);
+ }
+
+ public static final IProcessContextNode[] getProcessContextNodes(final IPeerNode peerNode, final IProcessContextItem item) {
+ final List<IProcessContextNode> nodes = new ArrayList<IProcessContextNode>();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ IRuntimeModelLookupService lkup = ModelManager.getRuntimeModel(peerNode).getService(IRuntimeModelLookupService.class);
+ IModelNode[] modelNodes = null;
+ if (item.getId() != null) {
+ modelNodes = lkup.lkupModelNodesById(item.getId());
+ }
+ if (modelNodes == null || modelNodes.length == 0) {
+ modelNodes = lkup.lkupModelNodesByName(item.getName());
+ }
+ if (modelNodes != null) {
+ for (IModelNode node : modelNodes) {
+ if (node instanceof IProcessContextNode && isValid((IProcessContextNode)node, item)) {
+ nodes.add((IProcessContextNode)node);
+ }
+ }
+ }
+ }
+ });
+ return nodes.toArray(new IProcessContextNode[nodes.size()]);
+ }
+
+ protected static final boolean isValid(IProcessContextNode node, IProcessContextItem item) {
+ if (item.getName() != null && node.getProcessContext().getName().equals(item.getName())) {
+ if (item.getPath() != null) {
+ String[] itemPath = item.getPath();
+ String[] nodePath = getProcessContextNodePath(node);
+ if (itemPath.length == nodePath.length) {
+ for (int i=0; i<itemPath.length; i++) {
+ if (!itemPath[i].equals(nodePath[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF
index adb7539b6..77a2044c3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF
@@ -25,7 +25,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.tcf.te.ui.forms;bundle-version="1.3.0",
org.eclipse.tcf.te.ui.swt;bundle-version="1.3.0",
org.eclipse.tcf.te.ui.views;bundle-version="1.3.0",
- org.eclipse.tcf.te.ui.controls;bundle-version="1.3.0"
+ org.eclipse.tcf.te.ui.controls;bundle-version="1.3.0",
+ org.eclipse.tcf.te.runtime.persistence;bundle-version="1.3.0",
+ org.eclipse.tcf.te.runtime.stepper;bundle-version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
@@ -39,6 +41,7 @@ Export-Package: org.eclipse.tcf.te.tcf.processes.ui.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.interfaces,
org.eclipse.tcf.te.tcf.processes.ui.internal;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.adapters;x-internal:=true,
+ org.eclipse.tcf.te.tcf.processes.ui.internal.delegates,
org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.preferences;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.properties;x-internal:=true,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/attach.gif b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/attach.gif
new file mode 100644
index 000000000..59c0c793d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/attach.gif
Binary files differ
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/detach.gif b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/detach.gif
new file mode 100644
index 000000000..7cb6dd37e
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/icons/obj16/detach.gif
Binary files differ
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties
index 9a27e097c..78bce32e1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties
@@ -72,6 +72,9 @@ command.terminate.label = Terminate
command.terminate.tooltip = Terminate the selected process
command.terminate.name = Terminate
+command.attach.label = Attach...
+command.attach.tooltip = Select contexts to attach to.
+
command.filter.label=Filter...
command.reset.label = Reset Filter
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
index f0894f2f0..1479ac155 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
@@ -47,6 +47,15 @@
</or>
</enablement>
</service>
+
+ <service
+ class="org.eclipse.tcf.te.tcf.processes.ui.services.DelegateService"
+ id="org.eclipse.tcf.te.tcf.processes.ui.services.Delegate">
+ <serviceType class="org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService"/>
+ <enablement>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </enablement>
+ </service>
</extension>
<!-- Eclipse core expressions property tester -->
@@ -435,6 +444,17 @@
</visibleWhen>
</command>
</menuContribution>
+
+ <!-- Main toolbar contributions -->
+ <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.DefaultContextActionsToolbarContribution?after=group.launch.rundebug">
+ <command commandId="org.eclipse.tcf.te.tcf.processes.ui.command.attach"/>
+ </menuContribution>
+
+ <!-- System menu contributions -->
+ <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.main.menu.system?after=group.launch.rundebug">
+ <command commandId="org.eclipse.tcf.te.tcf.processes.ui.command.attach"/>
+ </menuContribution>
+
</extension>
<!-- Command contributions -->
@@ -453,10 +473,23 @@
</command>
<command
categoryId="org.eclipse.tcf.te.ui.commands.category"
- helpContextId="org.eclipse.tcf.te.launch.command_erminate"
+ helpContextId="org.eclipse.tcf.te.launch.command_Terminate"
id="org.eclipse.tcf.te.launch.command.terminate"
name="%command.terminate.name">
</command>
+ <command
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.tcf.processes.ui.command_Attach"
+ id="org.eclipse.tcf.te.tcf.processes.ui.command.attach"
+ description="%command.attach.tooltip"
+ name="%command.attach.label">
+ </command>
+ </extension>
+
+<!-- Command image contributions -->
+ <extension point="org.eclipse.ui.commandImages">
+ <image commandId="org.eclipse.tcf.te.tcf.processes.ui.command.attach"
+ icon="icons/obj16/attach.gif"/>
</extension>
<!-- Handler contributions -->
@@ -471,9 +504,10 @@
commandId="org.eclipse.tcf.te.tcf.processes.ui.command.refreshInterval">
</handler>
- <handler
- class="org.eclipse.tcf.te.tcf.processes.ui.handler.AttachHandler"
- commandId="org.eclipse.tcf.te.launch.command.attach">
+ <handler commandId="org.eclipse.tcf.te.launch.command.attach">
+ <class class="org.eclipse.tcf.te.tcf.processes.ui.handler.AttachContextHandler">
+ <parameter name="operation" value="attach"/>
+ </class>
<activeWhen>
<and>
<with variable="activePartId">
@@ -512,6 +546,29 @@
</enabledWhen>
</handler>
+ <handler commandId="org.eclipse.tcf.te.tcf.processes.ui.command.attach">
+ <class class="org.eclipse.tcf.te.tcf.processes.ui.handler.AttachContextToolbarHandler">
+ <parameter name="operation" value="attach"/>
+ </class>
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
+ <test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="RunControl"/>
+ <test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="Processes"/>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.tcf.te.runtime.services.hasService"
+ value="org.eclipse.tcf.te.runtime.services.interfaces.IDebugService"/>
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
+
<handler
class="org.eclipse.tcf.te.tcf.processes.ui.handler.DetachHandler"
commandId="org.eclipse.tcf.te.launch.command.detach">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/activator/UIPlugin.java
index 761a17282..78949f47b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/activator/UIPlugin.java
@@ -82,6 +82,10 @@ public class UIPlugin extends AbstractUIPlugin {
registry.put(ImageConsts.OBJ_Process_Root, ImageDescriptor.createFromURL(url));
url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "process_polling.png"); //$NON-NLS-1$
registry.put(ImageConsts.PM_POLLING, ImageDescriptor.createFromURL(url));
+ url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "attach.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.ATTACH, ImageDescriptor.createFromURL(url));
+ url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "detach.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.DETACH, ImageDescriptor.createFromURL(url));
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextHandler.java
new file mode 100644
index 000000000..ca3149829
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextHandler.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.tcf.processes.ui.handler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessesDataProperties;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+import org.eclipse.tcf.te.tcf.processes.core.util.ProcessDataHelper;
+import org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs.AttachContextSelectionDialog;
+import org.eclipse.tcf.te.tcf.ui.handler.AbstractContextStepperCommandHandler;
+import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Stepper command handler vor attach.
+ */
+public class AttachContextHandler extends AbstractContextStepperCommandHandler {
+
+ public static final String RUNTIME_SERVICE_PROCESSES = "Processes"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractCommandHandler#getDialogSettingsSectionName()
+ */
+ @Override
+ protected String getDialogSettingsSectionName() {
+ return AttachContextHandler.class.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see com.windriver.te.tcf.ui.handler.AbstractContextStepperCommandHandler#getServices()
+ */
+ @Override
+ protected String[] getServices() {
+ return new String[]{RUNTIME_SERVICE_PROCESSES};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.handler.AbstractContextStepperCommandHandler#getDialog(org.eclipse.core.commands.ExecutionEvent, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ protected IDataExchangeDialog getDialog(ExecutionEvent event, IPropertiesContainer data) {
+ if (!data.containsKey(IProcessesDataProperties.PROPERTY_CONTEXT_LIST)) {
+ return new AttachContextSelectionDialog(HandlerUtil.getActiveShell(event), null);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.handler.AbstractContextStepperCommandHandler#getSelections(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ protected List<IStructuredSelection> getSelections(ExecutionEvent event) {
+ List<IStructuredSelection> selections = new ArrayList<IStructuredSelection>();
+ ISelection sel = HandlerUtil.getCurrentSelection(event);
+ if (sel instanceof IStructuredSelection) {
+ selections.add((IStructuredSelection)sel);
+ }
+
+ return selections;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.handler.AbstractContextStepperCommandHandler#addSelection(org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ protected void addSelection(IStructuredSelection selection, IPropertiesContainer data) {
+ final List<IProcessContextItem> items = new ArrayList<IProcessContextItem>();
+ if (selection != null) {
+ Iterator<Object> it = selection.iterator();
+ while (it.hasNext()) {
+ final Object element = it.next();
+ if (element instanceof IProcessContextNode) {
+ IProcessContextItem item = ProcessDataHelper.getProcessContextItem((IProcessContextNode)element);
+ if (item != null) {
+ items.add(item);
+ }
+ }
+ }
+ }
+
+ if (!items.isEmpty()) {
+ data.setProperty(IProcessesDataProperties.PROPERTY_CONTEXT_LIST, ProcessDataHelper.encodeProcessContextItems(items.toArray(new IProcessContextItem[items.size()])));
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextToolbarHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextToolbarHandler.java
new file mode 100644
index 000000000..a1bb8c118
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/AttachContextToolbarHandler.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.tcf.processes.ui.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+import org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs.AttachContextSelectionDialog;
+import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Stepper command toolbar handler vor attach.
+ */
+public class AttachContextToolbarHandler extends AttachContextHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractCommandHandler#getSelection(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ protected IStructuredSelection getSelection(ExecutionEvent event) {
+ return new StructuredSelection(ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.handler.AbstractContextStepperCommandHandler#getDialog(org.eclipse.core.commands.ExecutionEvent, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ protected IDataExchangeDialog getDialog(ExecutionEvent event, IPropertiesContainer data) {
+ return new AttachContextSelectionDialog(HandlerUtil.getActiveShell(event), null);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/ImageConsts.java
index db77b27cf..3cfed8a6d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/ImageConsts.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/ImageConsts.java
@@ -28,10 +28,13 @@ public interface ImageConsts {
// ***** The image constants *****
public static final String OBJ_Process = "OBJ_Process"; //$NON-NLS-1$
-
+
public static final String OBJ_Process_Root = "OBJ_Process_Root"; //$NON-NLS-1$
-
+
public static final String OBJ_Thread = "OBJ_Thread"; //$NON-NLS-1$
public static final String PM_POLLING = "OBJ_Process_Polling"; //$NON-NLS-1$
+
+ public static final String ATTACH = "OBJ_Attach"; //$NON-NLS-1$
+ public static final String DETACH = "OBJ_Detach"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
new file mode 100644
index 000000000..10df25f6c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * 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.tcf.processes.ui.internal.delegates;
+
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.persistence.utils.DataHelper;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService;
+import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper;
+import org.eclipse.tcf.te.tcf.core.interfaces.IContextDataProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.utils.PeerDataHelper;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessesDataProperties;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.services.IStepGroupIds;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.services.IStepperServiceOperations;
+import org.eclipse.tcf.te.tcf.processes.core.util.ProcessDataHelper;
+import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;
+import org.eclipse.tcf.te.tcf.processes.ui.internal.ImageConsts;
+import org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs.AttachContextSelectionDialog;
+import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate;
+import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
+
+public class DefaultContextToolbarDelegate extends AbstractDefaultContextToolbarDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate#getHandledStepGroupIds(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
+ */
+ @Override
+ public String[] getHandledStepGroupIds(IPeerNode peerNode) {
+ return new String[]{IStepGroupIds.ATTACH, IStepGroupIds.DETACH};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate#getLabel(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String)
+ */
+ @Override
+ public String getLabel(IPeerNode peerNode, String entry) {
+ IPropertiesContainer data = DataHelper.decodePropertiesContainer(entry);
+ String stepGroupId = getStepGroupId(entry);
+ if (IStepGroupIds.ATTACH.equals(stepGroupId)) {
+ IProcessContextItem[] items = ProcessDataHelper.decodeProcessContextItems(data.getStringProperty(IProcessesDataProperties.PROPERTY_CONTEXT_LIST));
+ String contexts = null;
+ int count = 0;
+ for (IProcessContextItem item : items) {
+ if (contexts == null) {
+ contexts = ""; //$NON-NLS-1$
+ }
+ else {
+ contexts += ","; //$NON-NLS-1$
+ }
+ if (count >= 2) {
+ contexts += ".."; //$NON-NLS-1$
+ break;
+ }
+ contexts += item.getName();
+ }
+ return NLS.bind(Messages.DefaultContextToolbarDelegate_attachContext_label, contexts);
+ }
+ return super.getLabel(peerNode, entry);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate#getDescription(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String)
+ */
+ @Override
+ public String getDescription(IPeerNode peerNode, String entry) {
+ IPropertiesContainer data = DataHelper.decodePropertiesContainer(entry);
+ String stepGroupId = getStepGroupId(entry);
+ if (IStepGroupIds.ATTACH.equals(stepGroupId)) {
+ IProcessContextItem[] items = ProcessDataHelper.decodeProcessContextItems(data.getStringProperty(IProcessesDataProperties.PROPERTY_CONTEXT_LIST));
+ String contexts = null;
+ for (IProcessContextItem item : items) {
+ if (contexts == null) {
+ contexts = "\t"; //$NON-NLS-1$
+ }
+ else {
+ contexts += "\n\t"; //$NON-NLS-1$
+ }
+ String[] path = item.getPath();
+ if (path != null && path.length > 0) {
+ for (String segment : path) {
+ contexts += segment + "/"; //$NON-NLS-1$
+ }
+ }
+ contexts += item.getName();
+ IUIService service = peerNode != null ? ServiceManager.getInstance().getService(peerNode, IUIService.class) : null;
+ IProcessMonitorUIDelegate delegate = service != null ? service.getDelegate(peerNode, IProcessMonitorUIDelegate.class) : null;
+ long id = item.getLongProperty(IProcessContextItem.PROPERTY_PID);
+
+ if (id > 0) {
+ contexts += " (" + (delegate != null ? delegate.getText(peerNode, "PID", new Long(id).toString()) : id+"") + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ }
+ return NLS.bind(Messages.DefaultContextToolbarDelegate_attachContext_description, contexts);
+ }
+ return super.getDescription(peerNode, entry);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate#getImage(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String)
+ */
+ @Override
+ public Image getImage(IPeerNode peerNode, String entry) {
+ String stepGroupId = getStepGroupId(entry);
+ if (IStepGroupIds.ATTACH.equals(stepGroupId)) {
+ return UIPlugin.getImage(ImageConsts.ATTACH);
+ }
+ if (IStepGroupIds.DETACH.equals(stepGroupId)) {
+ return UIPlugin.getImage(ImageConsts.DETACH);
+ }
+ return super.getImage(peerNode, entry);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate#execute(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String, boolean)
+ */
+ @Override
+ public boolean execute(IPeerNode peerNode, String entry, boolean showDialog) {
+ String operation = null;
+ String stepGroupId = getStepGroupId(entry);
+ if (IStepGroupIds.ATTACH.equals(stepGroupId)) {
+ operation = IStepperServiceOperations.ATTACH;
+ }
+ if (IStepGroupIds.DETACH.equals(stepGroupId)) {
+ operation = IStepperServiceOperations.DETACH;
+ }
+ IPropertiesContainer data = DataHelper.decodePropertiesContainer(entry);
+ IStepperOperationService stepperOperationService = StepperHelper.getService(peerNode, operation);
+ if (stepperOperationService != null) {
+ if (!showDialog) {
+ showDialog |= !stepperOperationService.validateStepData(peerNode, operation, data);
+ }
+ }
+ else {
+ return false;
+ }
+
+ if (showDialog) {
+ IDataExchangeDialog dialog = null;
+ if (IStepGroupIds.ATTACH.equals(stepGroupId)) {
+ dialog = new AttachContextSelectionDialog(Display.getDefault().getActiveShell(), null);
+ }
+ if (dialog != null) {
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, PeerDataHelper.encodeContextList(new IPeerNode[]{peerNode}));
+ dialog.setupData(data);
+ if (dialog.open() == Window.OK) {
+ data = new PropertiesContainer();
+ dialog.extractData(data);
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, null);
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ StepperHelper.scheduleStepperJob(peerNode, operation, stepperOperationService, data, null, null);
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.delegates.AbstractDefaultContextToolbarDelegate#validate(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String)
+ */
+ @Override
+ public boolean validate(IPeerNode peerNode, String entry) {
+ String operation = null;
+ String stepGroupId = getStepGroupId(entry);
+ if (IStepGroupIds.ATTACH.equals(stepGroupId)) {
+ operation = IStepperServiceOperations.ATTACH;
+ }
+ if (IStepGroupIds.DETACH.equals(stepGroupId)) {
+ operation = IStepperServiceOperations.DETACH;
+ }
+ if (operation != null) {
+ IPropertiesContainer data = DataHelper.decodePropertiesContainer(entry);
+ IStepperOperationService stepperOperationService = StepperHelper.getService(peerNode, operation);
+ if (stepperOperationService != null) {
+ return stepperOperationService.validateStepData(peerNode, operation, data);
+ }
+ }
+ return super.validate(peerNode, entry);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
new file mode 100644
index 000000000..decb43b40
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
@@ -0,0 +1,503 @@
+/*******************************************************************************
+ * 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.tcf.processes.ui.internal.dialogs;
+
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.tcf.core.interfaces.IContextDataProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.utils.PeerDataHelper;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
+import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessesDataProperties;
+import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModelLookupService;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModelRefreshService;
+import org.eclipse.tcf.te.tcf.processes.core.util.ProcessDataHelper;
+import org.eclipse.tcf.te.tcf.processes.ui.editor.tree.ContentProvider;
+import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
+import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
+import org.eclipse.tcf.te.ui.trees.TreeViewerSorterCaseInsensitive;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Dialog for selecting contexts to attach to.
+ */
+public class AttachContextSelectionDialog extends CustomTitleAreaDialog implements IEventListener, IDataExchangeDialog {
+ protected TreeViewer viewer;
+
+ private boolean initDone = false;
+
+ IPeerNode peerNode;
+ IPropertiesContainer data = null;
+
+ Text filter;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#isResizable()
+ */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+ */
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ return getDialogSettings();
+ }
+
+ /**
+ * Constructor
+ */
+ public AttachContextSelectionDialog(Shell parent, String contextHelpId) {
+ super(parent, contextHelpId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createDialogAreaContent(Composite parent) {
+ super.createDialogAreaContent(parent);
+
+ // Set dialog title and default message
+ setDialogTitle(Messages.AttachContextSelectionDialog_dialogTitle);
+ setTitle(Messages.AttachContextSelectionDialog_title);
+ setDefaultMessage(Messages.AttachContextSelectionDialog_message, IMessageProvider.INFORMATION);
+
+ // Create the inner panel
+ Composite panel = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout(1, false);
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label filterLabel = new Label(panel, SWT.NONE);
+ filterLabel.setText(Messages.AttachContextSelectionDialog_filter_label);
+
+ filter = new Text(panel, SWT.BORDER);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ filter.setLayoutData(gd);
+ filter.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ viewer.refresh();
+ viewer.expandAll();
+ }
+ });
+
+ Label contextLabel = new Label(panel, SWT.NONE);
+ contextLabel.setText(Messages.AttachContextSelectionDialog_contexts_label);
+
+ viewer = new TreeViewer(panel, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ Tree fModuleTree = viewer.getTree();
+ gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
+ gd.minimumHeight = 300;
+ gd.minimumWidth = 300;
+ gd.widthHint = 300;
+ gd.heightHint = 300;
+ fModuleTree.setLayoutData(gd);
+
+ viewer.setContentProvider(new ContentProvider());
+ DelegatingLabelProvider labelProvider = new DelegatingLabelProvider() {
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider#decorateText(java.lang.String, java.lang.Object)
+ */
+ @Override
+ public String decorateText(String text, final Object element) {
+ final AtomicBoolean isAttached = new AtomicBoolean();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ isAttached.set(isAttached(element));
+ }
+ });
+ if (isAttached.get()) {
+ return NLS.bind(Messages.AttachContextSelectionDialog_allReadyAttached_decoration, text);
+ }
+ return text;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider#getForeground(java.lang.Object)
+ */
+ @Override
+ public Color getForeground(final Object element) {
+ final AtomicBoolean canAttach = new AtomicBoolean();
+ final AtomicBoolean isAttached = new AtomicBoolean();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ canAttach.set(canAttach(element));
+ isAttached.set(isAttached(element));
+ }
+ });
+ if (!canAttach.get() || isAttached.get()) {
+ return PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
+ }
+ return null;
+ }
+ };
+ viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider) );
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ validate();
+ }
+ });
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ if (event.getSelection() instanceof IStructuredSelection &&
+ ((IStructuredSelection)event.getSelection()).size() > 0) {
+ final Object selected = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ final AtomicBoolean valid = new AtomicBoolean();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ valid.set(isValid(selected)); }
+ });
+ if (valid.get()) {
+ okPressed();
+ }
+ }
+ }
+ });
+
+ viewer.setSorter(new TreeViewerSorterCaseInsensitive());
+ viewer.addFilter(new ViewerFilter() {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, final Object element) {
+ if (element instanceof IProcessContextNode) {
+ final IProcessContextNode node = (IProcessContextNode)element;
+ String filterStr = filter.getText().trim();
+ filterStr = filterStr.replaceAll("\\*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$
+ filterStr = filterStr.replaceAll("\\?", "."); //$NON-NLS-1$ //$NON-NLS-2$
+ filterStr += ".*"; //$NON-NLS-1$
+ if (!matchesFilter(filterStr, node)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean matchesFilter(final String filterStr, final IProcessContextNode node) {
+ boolean childMatches = false;
+ if (node.hasChildren()) {
+ for (IModelNode child : node.getChildren()) {
+ if (child instanceof IProcessContextNode) {
+ if (matchesFilter(filterStr, (IProcessContextNode)child)) {
+ childMatches = true;
+ break;
+ }
+ }
+ else {
+ childMatches = true;
+ break;
+ }
+ }
+ }
+ final AtomicBoolean filterMatches = new AtomicBoolean();
+ final AtomicBoolean canAttach = new AtomicBoolean();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ filterMatches.set(node.getName().toLowerCase().matches(filterStr.toLowerCase()));
+ canAttach.set(canAttach(node));
+ }
+ });
+ return (filterMatches.get() || childMatches) && canAttach.get();
+ }
+ });
+
+ EventManager.getInstance().addEventListener(this, ChangeEvent.class);
+
+ restoreWidgetValues();
+ setupData(data);
+ applyDialogFont(panel);
+
+ initDone = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+ validate();
+ return control;
+ }
+
+ protected void validate() {
+ if (!initDone) {
+ return;
+ }
+
+ final AtomicBoolean valid = new AtomicBoolean(false);
+ final ISelection selection = viewer.getSelection();
+
+ if (selection instanceof IStructuredSelection &&
+ ((IStructuredSelection)selection).size() > 0) {
+ valid.set(true);
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ Iterator<?> it = ((IStructuredSelection)selection).iterator();
+ while (valid.get() && it.hasNext()) {
+ Object sel = it.next();
+ valid.set(isValid(sel));
+ }
+ }
+ });
+ }
+
+ if (valid.get()) {
+ setErrorMessage(null);
+ }
+
+ getButton(IDialogConstants.OK_ID).setEnabled(valid.get());
+ }
+
+ protected boolean canAttach(Object selection) {
+ if (selection instanceof IProcessContextNode) {
+ IProcessContextNode node = (IProcessContextNode)selection;
+ if (node.getProcessContext().getProperties().containsKey("CanAttach")) { //$NON-NLS-1$
+ Boolean value = (Boolean)node.getProcessContext().getProperties().get("CanAttach"); //$NON-NLS-1$
+ return value != null && value.booleanValue();
+ }
+ }
+ return false;
+ }
+
+ protected boolean isAttached(Object selection) {
+ if (selection instanceof IProcessContextNode) {
+ IProcessContextNode node = (IProcessContextNode)selection;
+ return node.getProcessContext().isAttached();
+ }
+ return false;
+ }
+
+ protected boolean isValid(Object selection) {
+ return canAttach(selection) && !isAttached(selection);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.windriver.ide.target.ui.dialogs.UnifiedDialog#saveWidgetValues()
+ */
+ @Override
+ public void saveWidgetValues() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#restoreWidgetValues()
+ */
+ @Override
+ protected void restoreWidgetValues() {
+ super.restoreWidgetValues();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#dispose()
+ */
+ @Override
+ protected void dispose() {
+ super.dispose();
+ viewer = null;
+
+ EventManager.getInstance().removeEventListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (event instanceof ChangeEvent) {
+ final ChangeEvent e = (ChangeEvent)event;
+ if (IContainerModelNode.NOTIFY_CHANGED.equals(e.getEventId()) &&
+ (e.getSource() instanceof IRuntimeModel || e.getSource() instanceof IProcessContextNode)) {
+ IPeerNode node = (IPeerNode)Platform.getAdapterManager().getAdapter(e.getSource(), IPeerNode.class);
+ if (node == peerNode) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.refresh(e.getSource(), true);
+ }
+ });
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode#setupData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void setupData(IPropertiesContainer data) {
+ this.data = new PropertiesContainer();
+ this.data.setProperties(data.getProperties());
+
+ IPeerNode[] contexts = PeerDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
+ IPeerNode newPeerNode = contexts != null && contexts.length > 0 ? contexts[0] : null;
+
+ if (peerNode == null || peerNode != newPeerNode) {
+ peerNode = newPeerNode;
+ if (viewer != null) {
+ viewer.setInput(peerNode);
+ viewer.expandAll();
+ viewer.refresh(true);
+ }
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ IRuntimeModelRefreshService refresh = ModelManager.getRuntimeModel(peerNode).getService(IRuntimeModelRefreshService.class);
+ refresh.refresh(new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ if (viewer != null) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ internalSetupData();
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ }
+ else {
+ internalSetupData();
+ }
+ }
+
+ protected void internalSetupData() {
+ if (viewer != null) {
+ viewer.setInput(peerNode);
+ viewer.expandAll();
+ viewer.refresh(true);
+ final List<IProcessContextNode> ctxNodes = new ArrayList<IProcessContextNode>();
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ for (IProcessContextItem item : ProcessDataHelper.decodeProcessContextItems(AttachContextSelectionDialog.this.data.getStringProperty(IProcessesDataProperties.PROPERTY_CONTEXT_LIST))) {
+ IRuntimeModelLookupService lkup = ModelManager.getRuntimeModel(peerNode).getService(IRuntimeModelLookupService.class);
+ IModelNode[] nodes = null;
+ if (item.getId() != null) {
+ nodes = lkup.lkupModelNodesById(item.getId());
+ }
+ if (nodes == null || nodes.length == 0) {
+ nodes = lkup.lkupModelNodesByName(item.getName());
+ }
+
+ if (nodes != null) {
+ for (IModelNode node : nodes) {
+ if (node instanceof IProcessContextNode) {
+ ctxNodes.add((IProcessContextNode)node);
+ }
+ }
+ }
+ }
+ }
+ });
+ viewer.setSelection(new StructuredSelection(ctxNodes));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void extractData(IPropertiesContainer data) {
+ Assert.isNotNull(data);
+ data.setProperties(this.data.getProperties());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Extract the properties
+ if (data == null) {
+ data = new PropertiesContainer();
+ }
+ if (viewer != null) {
+ ISelection sel = viewer.getSelection();
+ final List<IProcessContextItem> items = new ArrayList<IProcessContextItem>();
+ if (sel instanceof IStructuredSelection) {
+ final Iterator<?> it = ((IStructuredSelection)sel).iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj instanceof IProcessContextNode) {
+ IProcessContextItem item = ProcessDataHelper.getProcessContextItem((IProcessContextNode)obj);
+ if (item != null) {
+ items.add(item);
+ }
+ }
+ }
+ }
+ data.setProperty(IProcessesDataProperties.PROPERTY_CONTEXT_LIST, ProcessDataHelper.encodeProcessContextItems(items.toArray(new IProcessContextItem[items.size()])));
+ }
+
+ super.okPressed();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
index f47b5f224..f56129d0f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
@@ -196,4 +196,14 @@ public class Messages extends NLS {
public static String ProcessUserSearchable_Myself;
public static String ProcessUserSearchable_SpecifyUser;
public static String ProcessUserSearchable_WhoStarted;
+
+ public static String AttachContextSelectionDialog_dialogTitle;
+ public static String AttachContextSelectionDialog_title;
+ public static String AttachContextSelectionDialog_message;
+ public static String AttachContextSelectionDialog_filter_label;
+ public static String AttachContextSelectionDialog_contexts_label;
+ public static String AttachContextSelectionDialog_allReadyAttached_decoration;
+
+ public static String DefaultContextToolbarDelegate_attachContext_label;
+ public static String DefaultContextToolbarDelegate_attachContext_description;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
index c31da06d1..87cdb5087 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
@@ -149,3 +149,13 @@ ProcessUserSearchable_DontRemember=Don't remember
ProcessUserSearchable_Myself=I myself
ProcessUserSearchable_SpecifyUser=Specify a user:
ProcessUserSearchable_WhoStarted=Who started the process?
+
+AttachContextSelectionDialog_dialogTitle=Attach
+AttachContextSelectionDialog_title=Select contexts to attach
+AttachContextSelectionDialog_message=The list shows are all attachable contexts, grayed out ones are already attached.
+AttachContextSelectionDialog_filter_label=Enter context name or pattern (*, ?):
+AttachContextSelectionDialog_contexts_label=Contexts to Attach:
+AttachContextSelectionDialog_allReadyAttached_decoration={0} (already attached)
+
+DefaultContextToolbarDelegate_attachContext_label=Attach ''{0}''
+DefaultContextToolbarDelegate_attachContext_description=Attach\n{0}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/DelegateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/DelegateService.java
new file mode 100644
index 000000000..3ad3c0446
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/DelegateService.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.tcf.processes.ui.services;
+
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.processes.ui.internal.delegates.DefaultContextToolbarDelegate;
+import org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate;
+
+/**
+ * Delegate service implementation.
+ */
+public class DelegateService extends AbstractService implements IDelegateService {
+
+ final private IDefaultContextToolbarDelegate toolbarDelegate = new DefaultContextToolbarDelegate();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService#getDelegate(java.lang.Object, java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <V> V getDelegate(Object context, Class<? extends V> clazz) {
+
+ if (context instanceof IPeerNode) {
+ if (IDefaultContextToolbarDelegate.class.isAssignableFrom(clazz)) {
+ return (V) toolbarDelegate;
+ }
+ return null;
+ }
+
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java
index a96375ed1..01e3c40f6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java
@@ -1,13 +1,12 @@
-/**
- * UIService.java
- * Created on Nov 15, 2012
- *
- * Copyright (c) 2012, 2013 Wind River Systems, Inc.
+/*******************************************************************************
+ * 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
*
- * The right to copy, distribute, modify, or otherwise make use
- * of this software may be licensed only pursuant to the terms
- * of an applicable Wind River license agreement.
- */
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
package org.eclipse.tcf.te.tcf.processes.ui.services;
import org.eclipse.tcf.te.runtime.services.AbstractService;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
index d607d40e4..b1c9c9284 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
@@ -90,7 +90,7 @@ command.launch.label=Launch Terminal...
command.launch.mnemonic=L
command.launch.tooltip=Opens a terminal on the selected target.
-command.history.label=Action History...
-command.historyLast.label=Exectute Last History Action
+command.history.label=Recent Actions...
+command.historyLast.label=Execute Last Action
toolbar.label=System Management
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index 56a85a568..25dbd6bd5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -26,6 +26,14 @@
</factory>
</extension>
+<!-- Preference contributions -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.tcf.te.tcf.ui.internal.PreferencesInitializer">
+ </initializer>
+ </extension>
+
+
<!-- Source provider contributions -->
<extension point="org.eclipse.ui.services">
<sourceProvider provider="org.eclipse.tcf.te.tcf.ui.internal.SourceProvider">
@@ -620,7 +628,7 @@
id="org.eclipse.tcf.te.tcf.ui.ActionHistoryToolbarContribution"/>
<command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.history"/>
</menuContribution>
- <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.DefaultContextActionsToolbarContribution?after=group.launch.rundebug">
+ <!--menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.DefaultContextActionsToolbarContribution?after=group.launch.rundebug">
<command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.debug">
<visibleWhen checkEnabled="false">
<with variable="defaultContextSelection">
@@ -628,7 +636,7 @@
</with>
</visibleWhen>
</command>
- </menuContribution>
+ </menuContribution-->
<!-- System menu contribution -->
<menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.main.menu.system?after=group.connect">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java
index aee128504..7eb5c56d2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java
@@ -39,6 +39,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService
import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.ui.handler.images.ActionHistoryImageDescriptor;
import org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate;
+import org.eclipse.tcf.te.tcf.ui.interfaces.IPreferenceKeys;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
@@ -48,6 +49,8 @@ import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
*/
public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog {
+ private int maxEntries = -1;
+
protected static class Entry {
IPeerNode peerNode;
IDefaultContextToolbarDelegate delegate;
@@ -140,6 +143,13 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog {
SWTControlUtil.setEnabled(editButton, entry != null);
}
+ protected int getMaxEntries() {
+ if (maxEntries <= 0) {
+ maxEntries = UIPlugin.getScopedPreferences().getInt(IPreferenceKeys.PREF_MAX_RECENT_ACTION_ENTRIES);
+ }
+ return maxEntries;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#getInput()
*/
@@ -165,7 +175,11 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog {
List<Entry> actions = new ArrayList<Entry>();
String[] entries = HistoryManager.getInstance().getHistory(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + peerNode.getPeerId()); //$NON-NLS-1$
if (entries != null && entries.length > 0) {
+ int count = 0;
for (final String entry : entries) {
+ if (count >= getMaxEntries()) {
+ break;
+ }
IPropertiesContainer decoded = DataHelper.decodePropertiesContainer(entry);
String stepGroupId = decoded.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID);
if (stepGroupId != null && delegates.containsKey(stepGroupId)) {
@@ -174,6 +188,7 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog {
action.delegate = delegates.get(stepGroupId);
action.data = entry;
actions.add(action);
+ count++;
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
new file mode 100644
index 000000000..257d0a660
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 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.tcf.ui.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager;
+import org.eclipse.tcf.te.runtime.persistence.utils.DataHelper;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IService;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService;
+import org.eclipse.tcf.te.tcf.core.interfaces.IContextDataProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+import org.eclipse.tcf.te.tcf.locator.services.selection.RuntimeServiceContextFilter;
+import org.eclipse.tcf.te.tcf.locator.utils.PeerDataHelper;
+import org.eclipse.tcf.te.ui.handler.AbstractStepperCommandHandler;
+import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Abstract stepper command handler for load/unload.
+ */
+public abstract class AbstractContextStepperCommandHandler extends AbstractStepperCommandHandler {
+
+ protected void calculateSelectionData(ExecutionEvent event, IPropertiesContainer data) {
+
+ setContextList(event, data);
+
+ List<IStructuredSelection> selections = getSelections(event);
+
+ for (IStructuredSelection selection : selections) {
+ if (selection != null) {
+ addSelection(selection, data);
+ }
+ }
+ }
+
+ protected abstract String[] getServices();
+
+ protected abstract void addSelection(IStructuredSelection selection, IPropertiesContainer data);
+
+ protected boolean doShowDisconnectedContexts() {
+ return false;
+ }
+
+ protected IPropertiesContainer getDataFromHistory(ExecutionEvent event) {
+ IPeerNode context = getContext(event);
+ if (context != null) {
+ IService[] stepperOpServices = ServiceManager.getInstance().getServices(context, IStepperOperationService.class, false);
+ for (IService stepperOpService : stepperOpServices) {
+ if (stepperOpService instanceof IStepperOperationService && ((IStepperOperationService)stepperOpService).isHandledOperation(context, operation)) {
+ String groupId = ((IStepperOperationService)stepperOpService).getStepGroupId(context, operation);
+ if (groupId != null) {
+ String history = HistoryManager.getInstance().getFirst(groupId + "@" + context.getPeerId()); //$NON-NLS-1$
+ if (history != null) {
+ return DataHelper.decodePropertiesContainer(history);
+ }
+ }
+ }
+ }
+ }
+
+ return new PropertiesContainer();
+ }
+
+ protected IPeerNode getContext(ExecutionEvent event) {
+ IDefaultContextService selService = ServiceManager.getInstance().getService(IDefaultContextService.class);
+ if (selService != null) {
+ IPeerNode[] peerModels = selService.getCandidates(getSelection(event),
+ new RuntimeServiceContextFilter(getServices(), doShowDisconnectedContexts()));
+ if (peerModels.length > 0) {
+ return peerModels[0];
+ }
+ }
+ return null;
+ }
+
+ protected void setContextList(ExecutionEvent event, IPropertiesContainer data) {
+ IPeerNode context = getContext(event);
+ if (context != null) {
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, PeerDataHelper.encodeContextList(new IPeerNode[]{context}));
+ }
+ }
+
+ protected String getContextName(IPropertiesContainer data) {
+ String encoded = data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST);
+ IPeerNode[] contexts = PeerDataHelper.decodeContextList(encoded);
+ if (contexts != null && contexts.length > 0) {
+ return contexts[0].getName();
+ }
+ return null;
+ }
+
+ protected abstract IDataExchangeDialog getDialog(ExecutionEvent event, IPropertiesContainer data);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractStepperCommandHandler#getData(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ protected final IPropertiesContainer getData(ExecutionEvent event) {
+
+ IPropertiesContainer data = getDataFromHistory(event);
+ calculateSelectionData(event, data);
+
+ IDataExchangeDialog dialog = getDialog(event, data);
+
+ if (dialog != null) {
+ dialog.setupData(data);
+ if (dialog.open() == Window.OK) {
+ String contextList = data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST);
+ data = new PropertiesContainer();
+ dialog.extractData(data);
+ if (!data.containsKey(IContextDataProperties.PROPERTY_CONTEXT_LIST)) {
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, contextList);
+ }
+ return data;
+ }
+ return null;
+ }
+
+ return data;
+ }
+
+
+ protected List<IStructuredSelection> getSelections(ExecutionEvent event) {
+ List<IStructuredSelection> selections = new ArrayList<IStructuredSelection>();
+ String partId = HandlerUtil.getActivePartId(event);
+ selections.add(getSelection(event));
+ if (!PART_ID_PROJECT_VIEW.equals(partId)) {
+ selections.add(getPartSelection(PART_ID_PROJECT_VIEW));
+ }
+ if (!IUIConstants.ID_EXPLORER.equals(partId)) {
+ selections.add(getEditorInputSelection());
+ selections.add(getPartSelection(IUIConstants.ID_EXPLORER));
+ }
+
+ return selections;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractStepperCommandHandler#getContext(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ protected Object getContext(IPropertiesContainer data) {
+ IPeerNode[] contexts = PeerDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
+ return contexts.length == 1 ? contexts[0] : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractStepperCommandHandler#cleanupData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ protected IPropertiesContainer cleanupData(IPropertiesContainer data) {
+ data = super.cleanupData(data);
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, null);
+ return data;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IPreferenceKeys.java
new file mode 100644
index 000000000..e7f352075
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IPreferenceKeys.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.tcf.ui.interfaces;
+
+/**
+ * Preference key identifiers.
+ */
+public interface IPreferenceKeys {
+ /**
+ * Common prefix for all ui preference keys
+ */
+ public final String PREFIX = "te.tcf.ui."; //$NON-NLS-1$
+
+ /**
+ * The maximum number of recent actions shown in the recent action dialog.
+ * Defaults to 20.
+ */
+ public final String PREF_MAX_RECENT_ACTION_ENTRIES = PREFIX + "maxRecentActions"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PreferencesInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PreferencesInitializer.java
new file mode 100644
index 000000000..c57ed2b39
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PreferencesInitializer.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.tcf.ui.internal;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.tcf.ui.interfaces.IPreferenceKeys;
+
+/**
+ * Preference initializer.
+ */
+public class PreferencesInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Constructor.
+ */
+ public PreferencesInitializer() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ // Get the bundles scoped preferences store
+ ScopedEclipsePreferences prefs = UIPlugin.getScopedPreferences();
+ if (prefs != null) {
+ prefs.putDefaultInt(IPreferenceKeys.PREF_MAX_RECENT_ACTION_ENTRIES, 20);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
index d15f53c26..bc2d051db 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
@@ -110,9 +110,9 @@ PeerNodeSelectionDialog_dialogTitle=Select
PeerNodeSelectionDialog_title=Select Connection
PeerNodeSelectionDialog_message=Select the connection for the operation to perform.
-ActionHistorySelectionDialog_dialogTitle=Action History
+ActionHistorySelectionDialog_dialogTitle=Recent Actions
ActionHistorySelectionDialog_title=Select an Action for ''{0}''
-ActionHistorySelectionDialog_message=Select an action from the history to execute or edit.\n\
+ActionHistorySelectionDialog_message=Select an action from the list to execute or edit.\n\
The tooltip for an action shows all its properties.
ActionHistorySelectionDialog_button_edit=&Edit...
ActionHistorySelectionDialog_button_execute=E&xecute
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
index af6d95c8f..ccc85c46c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
@@ -27,6 +27,7 @@ import org.eclipse.tcf.te.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
+import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
import org.eclipse.tcf.te.ui.interfaces.data.IUpdatable;
import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
@@ -39,7 +40,7 @@ import org.eclipse.ui.forms.widgets.ScrolledForm;
/**
* Section dialog implementation.
*/
-public abstract class AbstractSectionDialog extends CustomTitleAreaDialog implements IValidatingContainer, IDataExchangeNode {
+public abstract class AbstractSectionDialog extends CustomTitleAreaDialog implements IValidatingContainer, IDataExchangeDialog {
// References to the sections
private AbstractSection[] sections = null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/IDataExchangeDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/IDataExchangeDialog.java
new file mode 100644
index 000000000..fea66298c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/IDataExchangeDialog.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.interfaces;
+
+import org.eclipse.jface.window.Window;
+import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
+
+/**
+ * IDataExchangeDialog
+ */
+public interface IDataExchangeDialog extends IDataExchangeNode {
+
+ /**
+ * Open the dialog.
+ * @return @see {@link Window}
+ */
+ public int open();
+}

Back to the top