Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-04-18 03:17:04 -0400
committerTobias Schwarz2014-04-18 03:17:04 -0400
commit3808db440066f984fc368d74985e8055a8082507 (patch)
tree30df843e81e0a8865946cf75d728f5eb134cfe0a
parentb1c7ba2bf3ccf99c665051c5ecdac9762e02ae57 (diff)
downloadorg.eclipse.tcf-3808db440066f984fc368d74985e8055a8082507.tar.gz
org.eclipse.tcf-3808db440066f984fc368d74985e8055a8082507.tar.xz
org.eclipse.tcf-3808db440066f984fc368d74985e8055a8082507.zip
Target Explorer: action history work
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryHandler.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ExecuteLastHistoryActionHandler.java68
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties4
6 files changed, 134 insertions, 10 deletions
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 f1b69f03f..53e8efea0 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
@@ -91,5 +91,6 @@ 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
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 31723f387..6a2b3c611 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
@@ -653,6 +653,7 @@
<menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.main.menu.system?after=group.history">
<command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.history"/>
+ <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.historyLast"/>
</menuContribution>
<menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.main.menu.system?after=group.new">
@@ -721,6 +722,12 @@
name="%command.history.label"
description="%command.history.tooltip">
</command>
+ <command
+ id="org.eclipse.tcf.te.tcf.ui.toolbar.command.historyLast"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.tcf.ui.command_HistoryLast"
+ name="%command.historyLast.label">
+ </command>
</extension>
<!-- Command shortcuts -->
@@ -733,6 +740,10 @@
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M2+F11"/>
+ <key commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.historyLast"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+M2+F11"/>
</extension>
<!-- Command image contributions -->
@@ -995,6 +1006,27 @@
</with>
</enabledWhen>
</handler>
+
+ <handler commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.historyLast">
+ <class class="org.eclipse.tcf.te.tcf.ui.handler.ExecuteLastHistoryActionHandler"/>
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <and>
+ <test property="org.eclipse.tcf.te.tcf.ui.hasHistory"/>
+ <adapt type="org.eclipse.tcf.te.core.interfaces.IConnectable">
+ <test forcePluginActivation="true"
+ property="org.eclipse.tcf.te.core.isConnectState"
+ value="connect"/>
+ </adapt>
+ </and>
+ </with>
+ </enabledWhen>
+ </handler>
</extension>
<!-- Tabbed properties view contributions -->
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryHandler.java
index b08d16e60..e98836f25 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryHandler.java
@@ -17,7 +17,7 @@ import org.eclipse.tcf.te.ui.views.handler.OpenEditorHandler;
import org.eclipse.ui.handlers.HandlerUtil;
/**
- * OpenEditorToolbarCommandHandler
+ * ActionHistoryHandler
*/
public class ActionHistoryHandler extends OpenEditorHandler {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java
index cffab2db9..025cdbf6f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java
@@ -9,6 +9,7 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Event;
import org.eclipse.tcf.te.core.interfaces.IConnectable;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
@@ -25,6 +26,8 @@ import org.eclipse.tcf.te.tcf.ui.handler.images.ActionHistoryImageDescriptor;
import org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate;
import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
import org.eclipse.ui.menus.IWorkbenchContribution;
import org.eclipse.ui.services.IServiceLocator;
@@ -80,21 +83,41 @@ public class ActionHistoryToolbarContribution extends CompoundContributionItem i
if (stepGroupId != null && delegates.containsKey(stepGroupId)) {
count++;
final IDefaultContextToolbarDelegate delegate = delegates.get(stepGroupId);
- IAction action = new Action("&" + count + " " + delegate.getLabel(peerNode, entry)) { //$NON-NLS-1$ //$NON-NLS-2$
- @Override
- public void runWithEvent(Event event) {
- delegate.execute(peerNode, entry, false);
- }
- };
+ String label = "&" + count + " " + delegate.getLabel(peerNode, entry); //$NON-NLS-1$ //$NON-NLS-2$
AbstractImageDescriptor descriptor = new ActionHistoryImageDescriptor(
UIPlugin.getDefault().getImageRegistry(),
delegate.getImage(peerNode, entry),
delegate.validate(peerNode, entry));
UIPlugin.getSharedImage(descriptor);
- action.setImageDescriptor(UIPlugin.getImageDescriptor(descriptor.getDecriptorKey()));
+ ImageDescriptor imageDescriptor = UIPlugin.getImageDescriptor(descriptor.getDecriptorKey());
+ if (count == 1) {
+ IContributionItem item = new CommandContributionItem(
+ new CommandContributionItemParameter(
+ serviceLocator,
+ null,
+ "org.eclipse.tcf.te.tcf.ui.toolbar.command.historyLast", //$NON-NLS-1$
+ null,
+ imageDescriptor,
+ null,
+ null,
+ label,
+ null,
+ null,
+ 0, null, false));
+ items.add(item);
+ }
+ else {
+ IAction action = new Action(label) {
+ @Override
+ public void runWithEvent(Event event) {
+ delegate.execute(peerNode, entry, false);
+ }
+ };
+ action.setImageDescriptor(imageDescriptor);
action.setEnabled(enabled);
IContributionItem item = new ActionContributionItem(action);
items.add(item);
+ }
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ExecuteLastHistoryActionHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ExecuteLastHistoryActionHandler.java
new file mode 100644
index 000000000..66ab10031
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ExecuteLastHistoryActionHandler.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.handler;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+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.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IService;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes;
+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.ui.interfaces.IDefaultContextToolbarDelegate;
+import org.eclipse.tcf.te.ui.views.handler.OpenEditorHandler;
+
+/**
+ * ExecuteLastHistoryActionHandler
+ */
+public class ExecuteLastHistoryActionHandler extends OpenEditorHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.handler.OpenEditorHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+
+ IService[] services = ServiceManager.getInstance().getServices(peerNode, IDelegateService.class, false);
+ Map<String, IDefaultContextToolbarDelegate> delegates = new LinkedHashMap<String, IDefaultContextToolbarDelegate>();
+ for (IService service : services) {
+ if (service instanceof IDelegateService) {
+ IDefaultContextToolbarDelegate delegate = ((IDelegateService)service).getDelegate(peerNode, IDefaultContextToolbarDelegate.class);
+ if (delegate != null) {
+ for (String stepGroupId : delegate.getHandledStepGroupIds(peerNode)) {
+ if (!delegates.containsKey(stepGroupId)) {
+ delegates.put(stepGroupId, delegate);
+ }
+ }
+ }
+ }
+ }
+
+ String entry = HistoryManager.getInstance().getFirst(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + peerNode.getPeerId()); //$NON-NLS-1$
+ if (entry != null) {
+ IPropertiesContainer decoded = DataHelper.decodePropertiesContainer(entry);
+ String stepGroupId = decoded.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID);
+ if (stepGroupId != null && delegates.containsKey(stepGroupId)) {
+ IDefaultContextToolbarDelegate delegate = delegates.get(stepGroupId);
+ delegate.execute(peerNode, entry, false);
+ }
+ }
+ return null;
+ }
+}
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 77eb86951..19c615ab4 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
@@ -111,8 +111,8 @@ ActionHistorySelectionDialog_dialogTitle=Action History
ActionHistorySelectionDialog_title=Select an Action for ''{0}''
ActionHistorySelectionDialog_message=Select an action from the history to execute or edit.\n\
The tooltip for an action shows all its properties.
-ActionHistorySelectionDialog_button_edit=Edit
-ActionHistorySelectionDialog_button_execute=Execute
+ActionHistorySelectionDialog_button_edit=&Edit...
+ActionHistorySelectionDialog_button_execute=E&xecute
RedirectHandler_error_title=Error
RedirectHandler_error_redirectFailed=Failed to redirect target communication.

Back to the top