Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-03-17 07:35:04 +0000
committerUwe Stieber2014-03-17 09:35:16 +0000
commit74876812e4ad8d1d4732737dc822fc0e82ecd486 (patch)
tree8e439cd4fea9553c5fd3cf9790d97032360817fc /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler
parent2e7bcc06b8fcd54154b250e2be05cebc8e5d9546 (diff)
downloadorg.eclipse.tcf-74876812e4ad8d1d4732737dc822fc0e82ecd486.tar.gz
org.eclipse.tcf-74876812e4ad8d1d4732737dc822fc0e82ecd486.tar.xz
org.eclipse.tcf-74876812e4ad8d1d4732737dc822fc0e82ecd486.zip
Target Explorer: Continue work for simplification of discovered peer connect
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectPeerCommandHandler.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectPeerCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectPeerCommandHandler.java
index 2adfb34c5..074fb4256 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectPeerCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectPeerCommandHandler.java
@@ -12,17 +12,50 @@ package org.eclipse.tcf.te.tcf.ui.handler;
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.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.events.TriggerCommandEvent;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.internal.navigator.wizards.CommonWizardDescriptor;
+import org.eclipse.ui.internal.navigator.wizards.CommonWizardDescriptorManager;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.WizardActionGroup;
/**
* Connect peer command handler implementation.
*/
+@SuppressWarnings("restriction")
public class ConnectPeerCommandHandler extends AbstractHandler {
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
- @Override
+ @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ // Get the selection from the event
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ // The selection contains only one element as multi element selections are not supported by this handler
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ // The element must be of type IPeer
+ if (element instanceof IPeer) {
+ // Get the list of enabled new wizards
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ if (part instanceof CommonNavigator) {
+ CommonWizardDescriptor[] wizards = CommonWizardDescriptorManager.getInstance().getEnabledCommonWizardDescriptors(element, WizardActionGroup.TYPE_NEW, ((CommonNavigator)part).getNavigatorContentService());
+ // If there are more than one wizard, the user must select which wizard
+ // to use to create the connection -> open the new connection wizard
+ if (wizards.length > 1) {
+ TriggerCommandEvent e = new TriggerCommandEvent(element, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ EventManager.getInstance().fireEvent(e);
+ }
+ }
+ }
+ }
+
return null;
}

Back to the top