Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-11-20 12:52:57 +0000
committerTobias Schwarz2013-11-20 12:54:42 +0000
commit2e7cb57c2e295a0fb8cf301bb2200c1f567c7683 (patch)
tree68d538d0a4c7afb763be3183e525348fe0bf3153 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler
parent53c28e850f4f08ee928a17b92ee454ae02993aa3 (diff)
downloadorg.eclipse.tcf-2e7cb57c2e295a0fb8cf301bb2200c1f567c7683.tar.gz
org.eclipse.tcf-2e7cb57c2e295a0fb8cf301bb2200c1f567c7683.tar.xz
org.eclipse.tcf-2e7cb57c2e295a0fb8cf301bb2200c1f567c7683.zip
Target Explorer: rework handler activity and enablement
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/DeleteHandler.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
index a2935d75c..2c451a72f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
@@ -11,6 +11,7 @@ package org.eclipse.tcf.te.tcf.ui.handler;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -24,9 +25,11 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tcf.protocol.Protocol;
@@ -99,6 +102,16 @@ public class DeleteHandler extends AbstractHandler {
boolean canDelete = false;
+ if (!(selection instanceof ITreeSelection) && selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Iterator<?> it = ((IStructuredSelection)selection).iterator();
+ List<TreePath> treePathes = new ArrayList<TreePath>();
+ while (it.hasNext()) {
+ Object sel = it.next();
+ treePathes.add(new TreePath(new Object[]{sel}));
+ }
+ selection = new TreeSelection(treePathes.toArray(new TreePath[treePathes.size()]));
+ }
+
// The selection must be a tree selection and must not be empty
if (selection instanceof ITreeSelection && !selection.isEmpty()) {
// Assume the selection to be deletable
@@ -294,7 +307,7 @@ public class DeleteHandler extends AbstractHandler {
* @param selection The selection. Must not be <code>null</code>.
* @param callback The callback. Must not be <code>null</code>.
*/
- public void delete(final ISelection selection, final ICallback callback) {
+ public void delete(ISelection selection, final ICallback callback) {
Assert.isNotNull(selection);
Assert.isNotNull(callback);
@@ -302,6 +315,16 @@ public class DeleteHandler extends AbstractHandler {
// from an asynchronous callback, set this flag to false.
boolean invokeCallback = true;
+ if (!(selection instanceof ITreeSelection) && selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Iterator<?> it = ((IStructuredSelection)selection).iterator();
+ List<TreePath> treePathes = new ArrayList<TreePath>();
+ while (it.hasNext()) {
+ Object sel = it.next();
+ treePathes.add(new TreePath(new Object[]{sel}));
+ }
+ selection = new TreeSelection(treePathes.toArray(new TreePath[treePathes.size()]));
+ }
+
// The selection must be a tree selection and must not be empty
if (selection instanceof ITreeSelection && !selection.isEmpty()) {
// Determine the operations to perform for each of the selected elements

Back to the top