Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-02-19 08:34:37 -0500
committerTobias Schwarz2014-02-19 08:34:37 -0500
commit59a4ec704506ff244dc5638e6817192fb78cc4e9 (patch)
tree3bf1386ff5f0e1f35bb2f001b3f006bd0eaf2edf
parent98b87aa3b027800057a99b57d71f3fdbc01010b3 (diff)
downloadorg.eclipse.tcf-59a4ec704506ff244dc5638e6817192fb78cc4e9.tar.gz
org.eclipse.tcf-59a4ec704506ff244dc5638e6817192fb78cc4e9.tar.xz
org.eclipse.tcf-59a4ec704506ff244dc5638e6817192fb78cc4e9.zip
Target Explorer: add default context selector to system menu
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties3
-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/SelectDefaultContextHandler.java83
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties3
6 files changed, 140 insertions, 0 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 fcda5985c..23724a981 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
@@ -62,6 +62,9 @@ preference.page.name = Logging
menu.system.label=System
menu.system.mnemonic=y
+command.select.label=Select Default Connection...
+command.select.toolbar.tooltip=Select a default connection
+
command.new.label=New Connection...
command.new.toolbar.tooltip=Create a new connection
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 3e5f6f798..3b468de5f 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
@@ -47,6 +47,13 @@
class="org.eclipse.tcf.te.tcf.ui.internal.PropertyTester"
id="org.eclipse.tcf.te.tcf.ui.propertyTester"
namespace="org.eclipse.tcf.te.tcf.ui"
+ properties="canChangeDefaultContext"
+ type="java.lang.Object">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.tcf.te.tcf.ui.internal.PropertyTester"
+ id="org.eclipse.tcf.te.tcf.ui.propertyTester"
+ namespace="org.eclipse.tcf.te.tcf.ui"
properties="canDelete"
type="org.eclipse.jface.viewers.ISelection">
</propertyTester>
@@ -622,6 +629,8 @@
</menuContribution>
<menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.main.menu.system?after=group.new">
+ <separator name="group.connections" visible="true"/>
+ <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.select"/>
<command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.new"/>
</menuContribution>
@@ -630,6 +639,13 @@
<!-- Command contributions -->
<extension point="org.eclipse.ui.commands">
<command
+ id="org.eclipse.tcf.te.tcf.ui.toolbar.command.select"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.tcf.ui.command_Select"
+ name="%command.select.label"
+ description="%command.select.toolbar.tooltip">
+ </command>
+ <command
id="org.eclipse.tcf.te.tcf.ui.toolbar.command.new"
categoryId="org.eclipse.tcf.te.ui.commands.category"
helpContextId="org.eclipse.tcf.te.tcf.ui.command_New"
@@ -673,6 +689,14 @@
</command>
</extension>
+<!-- Command shortcuts -->
+ <extension point="org.eclipse.ui.bindings">
+ <key commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.select"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+M2+C"/>
+ </extension>
+
<!-- Command image contributions -->
<extension point="org.eclipse.ui.commandImages">
<image
@@ -804,6 +828,14 @@
</handler>
<handler
+ commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.select"
+ class="org.eclipse.tcf.te.tcf.ui.handler.SelectDefaultContextHandler">
+ <enabledWhen>
+ <test property="org.eclipse.tcf.te.tcf.ui.canChangeDefaultContext"/>
+ </enabledWhen>
+ </handler>
+
+ <handler
commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.open"
class="org.eclipse.tcf.te.tcf.ui.handler.OpenEditorToolbarCommandHandler">
<activeWhen>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/SelectDefaultContextHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/SelectDefaultContextHandler.java
new file mode 100644
index 000000000..4f5c3543a
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/SelectDefaultContextHandler.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+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.dialogs.PeerNodeSelectionDialog;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * AbstractHandler
+ */
+public class SelectDefaultContextHandler extends AbstractHandler {
+
+ /**
+ * Constructor.
+ */
+ public SelectDefaultContextHandler() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ PeerNodeSelectionDialog dialog = new PeerNodeSelectionDialog(HandlerUtil.getActiveShell(event)) {
+ @Override
+ protected String getTitle() {
+ return Messages.SelectDefaultContextHandler_dialog_title;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.dialogs.PeerNodeSelectionDialog#getDefaultMessage()
+ */
+ @Override
+ protected String getDefaultMessage() {
+ return Messages.SelectDefaultContextHandler_dialog_message;
+ }
+ @Override
+ protected Object[] getInput() {
+ IPeerNode defaultPeer = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ Object[] peerNodes = super.getInput();
+ List<Object> input = new ArrayList<Object>();
+ for (Object object : peerNodes) {
+ if (!object.equals(defaultPeer)) {
+ input.add(object);
+ }
+ }
+
+ return input.toArray();
+ }
+ };
+
+ if (dialog.open() == Window.OK) {
+ ISelection selection = dialog.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).getFirstElement() instanceof IPeerNode) {
+ ServiceManager.getInstance().getService(IDefaultContextService.class).setDefaultContext((IPeerNode)((IStructuredSelection)selection).getFirstElement());
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
index 27194bb8b..02f1d5ee1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
@@ -9,10 +9,16 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.ui.internal;
+import java.util.Arrays;
+import java.util.List;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
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.model.ModelManager;
import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
import org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler;
import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
@@ -50,6 +56,16 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
return ((Boolean)expectedValue).booleanValue() == valid;
}
+ if ("canChangeDefaultContext".equals(property)) { //$NON-NLS-1$
+ IPeerNode defaultPeer = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ List<IPeerNode> peerNodes = Arrays.asList(ModelManager.getPeerModel().getPeerNodes());
+ if (defaultPeer != null && peerNodes.contains(defaultPeer)) {
+ return peerNodes.size() > 1;
+ }
+ return peerNodes.size() > 0;
+ }
+
+
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
index 811ec0618..d9e7dab2d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
@@ -130,6 +130,9 @@ public class Messages extends NLS {
public static String PeerAttributesTablePart_edit_title;
public static String PeerAttributesTablePart_edit_message;
+ public static String SelectDefaultContextHandler_dialog_title;
+ public static String SelectDefaultContextHandler_dialog_message;
+
public static String DeleteHandler_error_title;
public static String DeleteHandler_error_deleteFailed;
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 b05fccd2c..ef0a50794 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
@@ -89,6 +89,9 @@ PeerAttributesTablePart_edit_dialogTitle=Edit
PeerAttributesTablePart_edit_title=Edit Attribute
PeerAttributesTablePart_edit_message=Edit the selected target attribute.
+SelectDefaultContextHandler_dialog_title=Select Default Connection
+SelectDefaultContextHandler_dialog_message=Select the Connection that should be used as the default.
+
DeleteHandler_error_title=Error
DeleteHandler_error_deleteFailed=Failed to delete connection.\n\n{0}
DeleteHandlerDelegate_DialogTitle=Confirm Delete

Back to the top