Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-05-31 11:11:08 +0000
committerUwe Stieber2013-05-31 11:11:08 +0000
commitc0a5d7ac4101f3f89e256435f7abb840d54e3250 (patch)
treebe66bc571aafcdef2e568ac86d39a57671ab96eb /target_explorer
parentbf69d325b81a012764a659b1166e4f8413db8dd5 (diff)
downloadorg.eclipse.tcf-c0a5d7ac4101f3f89e256435f7abb840d54e3250.tar.gz
org.eclipse.tcf-c0a5d7ac4101f3f89e256435f7abb840d54e3250.tar.xz
org.eclipse.tcf-c0a5d7ac4101f3f89e256435f7abb840d54e3250.zip
Target Explorer: Allow the stepper input element to be adapted
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/CancelStepperCommandHandler.java193
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java219
3 files changed, 224 insertions, 198 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
index 380c654f6..baa4d8cb9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
@@ -291,6 +291,11 @@
<test forcePluginActivation="true"
property="org.eclipse.tcf.te.runtime.stepper.isRunning"
value="connect"/>
+ <not>
+ <test forcePluginActivation="true"
+ property="org.eclipse.tcf.te.runtime.stepper.isEnabled"
+ value="disconnect"/>
+ </not>
</adapt>
</iterate>
</with>
@@ -306,11 +311,6 @@
<test forcePluginActivation="true"
property="org.eclipse.tcf.te.runtime.stepper.isRunning"
value="connect"/>
- <not>
- <test forcePluginActivation="true"
- property="org.eclipse.tcf.te.runtime.stepper.isEnabled"
- value="disconnect"/>
- </not>
</adapt>
</iterate>
</with>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/CancelStepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/CancelStepperCommandHandler.java
index fa07350e6..01a2642a5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/CancelStepperCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/CancelStepperCommandHandler.java
@@ -1,90 +1,103 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.handler;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.jface.viewers.ISelection;
-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.runtime.services.interfaces.IPropertiesAccessService;
-import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.part.EditorPart;
-
-/**
- * Cancel stepper command handler implementation.
- */
-public class CancelStepperCommandHandler extends AbstractHandler implements IExecutableExtension {
-
- private String operation = null;
-
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- Assert.isNotNull(operation);
-
- // Get the active part
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- // Get the current selection
- ISelection selection = HandlerUtil.getCurrentSelection(event);
-
- // If the handler is invoked from an editor part, ignore the selection and
- // construct an artificial selection from the active editor input.
- if (part instanceof EditorPart) {
- IEditorInput input = ((EditorPart)part).getEditorInput();
- Object element = input != null ? input.getAdapter(Object.class) : null;
- if (element != null) {
- selection = new StructuredSelection(element);
- }
- }
-
- // If the selection is not empty, iterate over the selection and execute
- // the operation for each peer model node in the selection.
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
- while (iterator.hasNext()) {
- final Object element = iterator.next();
- IPropertiesAccessService service = ServiceManager.getInstance().getService(element, IPropertiesAccessService.class);
- StepperJob job = service != null ? (StepperJob)service.getProperty(element, StepperJob.class.getName() + "." + operation) : null; //$NON-NLS-1$
- if (service == null && element instanceof IPropertiesContainer)
- job = (StepperJob)((IPropertiesContainer)element).getProperty(StepperJob.class.getName() + "." + operation); //$NON-NLS-1$
- if (job != null)
- job.cancel();
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- if (data instanceof Map && ((Map<?,?>)data).get("operation") instanceof String) { //$NON-NLS-1$
- this.operation = ((Map<?,?>)data).get("operation").toString(); //$NON-NLS-1$
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.handler;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.ISelection;
+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.runtime.services.interfaces.IPropertiesAccessService;
+import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.part.EditorPart;
+
+/**
+ * Cancel stepper command handler implementation.
+ */
+public class CancelStepperCommandHandler extends AbstractHandler implements IExecutableExtension {
+
+ private String operation = null;
+ private String adaptTo = null;
+
+ /* (non-Javadoc)
+ * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Assert.isNotNull(operation);
+
+ // Get the active part
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // Get the current selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ // If the handler is invoked from an editor part, ignore the selection and
+ // construct an artificial selection from the active editor input.
+ if (part instanceof EditorPart) {
+ IEditorInput input = ((EditorPart)part).getEditorInput();
+ Object element = input != null ? input.getAdapter(Object.class) : null;
+ if (element != null) {
+ selection = new StructuredSelection(element);
+ }
+ }
+
+ // If the selection is not empty, iterate over the selection and execute
+ // the operation for each peer model node in the selection.
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ Object adapted = element;
+ if (adaptTo != null) {
+ Object adapter = Platform.getAdapterManager().getAdapter(element, adaptTo);
+ if (adapter != null) adapted = adapter;
+ }
+ IPropertiesAccessService service = ServiceManager.getInstance().getService(adapted, IPropertiesAccessService.class);
+ StepperJob job = service != null ? (StepperJob)service.getProperty(adapted, StepperJob.class.getName() + "." + operation) : null; //$NON-NLS-1$
+ if (service == null && adapted instanceof IPropertiesContainer)
+ job = (StepperJob)((IPropertiesContainer)adapted).getProperty(StepperJob.class.getName() + "." + operation); //$NON-NLS-1$
+ if (job != null)
+ job.cancel();
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ if (data instanceof Map) {
+ Map<?,?> dataMap = (Map<?,?>)data;
+ if (dataMap.get("operation") instanceof String) { //$NON-NLS-1$
+ this.operation = dataMap.get("operation").toString(); //$NON-NLS-1$
+ }
+ if (dataMap.get("adaptTo") instanceof String) { //$NON-NLS-1$
+ this.adaptTo = dataMap.get("adaptTo").toString(); //$NON-NLS-1$
+ }
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java
index 3a1de5382..688912c2f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java
@@ -1,103 +1,116 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.handler;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.jface.viewers.ISelection;
-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.properties.PropertiesContainer;
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
-import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.part.EditorPart;
-
-/**
- * Stepper command handler implementation.
- */
-public class StepperCommandHandler extends AbstractHandler implements IExecutableExtension {
-
- private String operation = null;
-
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- Assert.isNotNull(operation);
-
- // Get the active part
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- // Get the current selection
- ISelection selection = HandlerUtil.getCurrentSelection(event);
-
- // If the handler is invoked from an editor part, ignore the selection and
- // construct an artificial selection from the active editor input.
- if (part instanceof EditorPart) {
- IEditorInput input = ((EditorPart)part).getEditorInput();
- Object element = input != null ? input.getAdapter(Object.class) : null;
- if (element != null) {
- selection = new StructuredSelection(element);
- }
- }
-
- // If the selection is not empty, iterate over the selection and execute
- // the operation for each peer model node in the selection.
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
- while (iterator.hasNext()) {
- final Object element = iterator.next();
- IStepperService service = ServiceManager.getInstance().getService(element, IStepperService.class);
- if (service != null) {
- String stepGroupId = service.getStepGroupId(element, operation);
- IStepContext stepContext = service.getStepContext(element, operation);
- String name = service.getStepGroupName(element, operation);
-
- if (stepGroupId != null && stepContext != null) {
- IPropertiesContainer data = new PropertiesContainer();
- StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$
- stepContext,
- data,
- stepGroupId,
- operation,
- service.isCancelable(element, operation));
- job.schedule();
- }
- }
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- if (data instanceof Map && ((Map<?,?>)data).get("operation") instanceof String) { //$NON-NLS-1$
- this.operation = ((Map<?,?>)data).get("operation").toString(); //$NON-NLS-1$
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.handler;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.ISelection;
+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.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
+import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.part.EditorPart;
+
+/**
+ * Stepper command handler implementation.
+ */
+public class StepperCommandHandler extends AbstractHandler implements IExecutableExtension {
+
+ private String operation = null;
+ private String adaptTo = null;
+
+ /* (non-Javadoc)
+ * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Assert.isNotNull(operation);
+
+ // Get the active part
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // Get the current selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ // If the handler is invoked from an editor part, ignore the selection and
+ // construct an artificial selection from the active editor input.
+ if (part instanceof EditorPart) {
+ IEditorInput input = ((EditorPart)part).getEditorInput();
+ Object element = input != null ? input.getAdapter(Object.class) : null;
+ if (element != null) {
+ selection = new StructuredSelection(element);
+ }
+ }
+
+ // If the selection is not empty, iterate over the selection and execute
+ // the operation for each peer model node in the selection.
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ Object adapted = element;
+ if (adaptTo != null) {
+ Object adapter = Platform.getAdapterManager().getAdapter(element, adaptTo);
+ if (adapter != null) adapted = adapter;
+ }
+ IStepperService service = ServiceManager.getInstance().getService(adapted, IStepperService.class);
+ if (service != null) {
+ String stepGroupId = service.getStepGroupId(adapted, operation);
+ IStepContext stepContext = service.getStepContext(adapted, operation);
+ String name = service.getStepGroupName(adapted, operation);
+
+ if (stepGroupId != null && stepContext != null) {
+ IPropertiesContainer data = new PropertiesContainer();
+ StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$
+ stepContext,
+ data,
+ stepGroupId,
+ operation,
+ service.isCancelable(adapted, operation));
+ job.schedule();
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ if (data instanceof Map) {
+ Map<?,?> dataMap = (Map<?,?>)data;
+ if (dataMap.get("operation") instanceof String) { //$NON-NLS-1$
+ this.operation = dataMap.get("operation").toString(); //$NON-NLS-1$
+ }
+ if (dataMap.get("adaptTo") instanceof String) { //$NON-NLS-1$
+ this.adaptTo = dataMap.get("adaptTo").toString(); //$NON-NLS-1$
+ }
+ }
+ }
+}

Back to the top