diff options
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml | 48 | ||||
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java | 25 |
2 files changed, 39 insertions, 34 deletions
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 0cf70def5..80a7f866f 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 @@ -523,16 +523,11 @@ commandId="org.eclipse.ui.edit.delete" class="org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler"> <activeWhen> - <and> - <with variable="activePartId"> - <equals value="org.eclipse.tcf.te.ui.views.View"/> - </with> - <with variable="selection"> - <iterate operator="and" ifEmpty="false"> - <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> - </iterate> - </with> - </and> + <with variable="selection"> + <iterate operator="and" ifEmpty="false"> + <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> + </iterate> + </with> </activeWhen> <enabledWhen> <with variable="selection"> @@ -545,16 +540,11 @@ commandId="org.eclipse.ui.edit.rename" class="org.eclipse.tcf.te.tcf.ui.handler.RenameHandler"> <activeWhen> - <and> - <with variable="activePartId"> - <equals value="org.eclipse.tcf.te.ui.views.View"/> - </with> - <with variable="selection"> - <iterate operator="and" ifEmpty="false"> - <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> - </iterate> - </with> - </and> + <with variable="selection"> + <iterate operator="and" ifEmpty="false"> + <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> + </iterate> + </with> </activeWhen> <enabledWhen> <with variable="selection"> @@ -588,19 +578,11 @@ commandId="org.eclipse.tcf.te.ui.command.refresh" class="org.eclipse.tcf.te.tcf.ui.handler.RefreshHandler"> <activeWhen> - <and> - <with variable="activePartId"> - <or> - <equals value="org.eclipse.tcf.te.ui.views.View"/> - <equals value="org.eclipse.tcf.te.ui.views.Editor"/> - </or> - </with> - <with variable="selection"> - <iterate operator="and" ifEmpty="false"> - <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> - </iterate> - </with> - </and> + <with variable="selection"> + <iterate operator="and" ifEmpty="false"> + <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> + </iterate> + </with> </activeWhen> <enabledWhen> <with variable="selection"> 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 |