Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-04-28 13:02:42 +0000
committerUwe Stieber2012-04-28 13:02:42 +0000
commitccf966c976415fc331d963c7392990529ca56aad (patch)
tree3ed1c3744dbb1cf654c5321ebd9679eac23b0b61 /target_explorer/plugins
parent7920e8801b1bcd28e77aa8b5c8de7ebf63c4b01d (diff)
downloadorg.eclipse.tcf-ccf966c976415fc331d963c7392990529ca56aad.tar.gz
org.eclipse.tcf-ccf966c976415fc331d963c7392990529ca56aad.tar.xz
org.eclipse.tcf-ccf966c976415fc331d963c7392990529ca56aad.zip
Target Explorer: Fix DnD of peer nodes between categories
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AlwaysAvailableOfflineCommandHandler.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/categories/CategoryManager.java)32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DropAssistant.java2
4 files changed, 46 insertions, 44 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
index 85378ba8b..a87d5426a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
@@ -41,7 +41,6 @@ Export-Package: org.eclipse.tcf.te.tcf.ui.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.ui.help,
org.eclipse.tcf.te.tcf.ui.internal;x-internal:=true,
org.eclipse.tcf.te.tcf.ui.internal.adapters;x-internal:=true,
- org.eclipse.tcf.te.tcf.ui.internal.categories;x-internal:=true,
org.eclipse.tcf.te.tcf.ui.internal.preferences;x-internal:=true,
org.eclipse.tcf.te.tcf.ui.internal.tabbed;x-internal:=true,
org.eclipse.tcf.te.tcf.ui.navigator,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/categories/CategoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AlwaysAvailableOfflineCommandHandler.java
index 8643eef91..edb5d0ae0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/categories/CategoryManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AlwaysAvailableOfflineCommandHandler.java
@@ -7,12 +7,15 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.ui.internal.categories;
+package org.eclipse.tcf.te.tcf.ui.handler;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -28,30 +31,17 @@ import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
-
/**
- * Category manager implementation.
+ *
*/
-public class CategoryManager {
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstance {
- public static CategoryManager instance = new CategoryManager();
- }
+public class AlwaysAvailableOfflineCommandHandler extends AbstractHandler {
- /**
- * Constructor.
- */
- /* default */ CategoryManager() {
- super();
- }
-
- /**
- * Returns the singleton instance.
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
- public static CategoryManager getInstance() {
- return LazyInstance.instance;
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ return null;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java
index 85dc6f15b..e42137123 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/CommonDnD.java
@@ -13,10 +13,11 @@ import java.util.Iterator;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.ui.internal.categories.CategoryManager;
import org.eclipse.tcf.te.ui.views.Managers;
import org.eclipse.tcf.te.ui.views.ViewsUtil;
import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
@@ -61,16 +62,17 @@ public class CommonDnD {
/**
* Perform the drop operation over dragged selection.
*
+ * @param dropAdapter The common drop adapter.
* @param target The target Object to be moved to.
* @param operations The current DnD operation.
* @param selection The local selection being dropped.
* @return true if the dropping is successful.
*/
- public static boolean dropLocalSelection(Object target, int operations, IStructuredSelection selection) {
+ public static boolean dropLocalSelection(CommonDropAdapter dropAdapter, Object target, int operations, IStructuredSelection selection) {
if (target instanceof ICategory) {
ICategory hovered = (ICategory) target;
- if (IUIConstants.ID_CAT_FAVORITES.equals(hovered.getId())) {
- // Mark the peer nodes as favorite
+ if (IUIConstants.ID_CAT_FAVORITES.equals(hovered.getId())
+ || IUIConstants.ID_CAT_MY_TARGETS.equals(hovered.getId())) {
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
@@ -80,25 +82,33 @@ public class CommonDnD {
// Fire a refresh of the view
ViewsUtil.refresh(IUIConstants.ID_EXPLORER);
}
- else if (IUIConstants.ID_CAT_MY_TARGETS.equals(hovered.getId())) {
- // Create a static copy of the dropped peer node
- Iterator<?> iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object element = iterator.next();
- if (!(element instanceof IPeerModel)) continue;
- CategoryManager.getInstance().addToMyTargets((IPeerModel)element);
- }
- // Fire a refresh of the view
- ViewsUtil.refresh(IUIConstants.ID_EXPLORER);
- }
} else if (target instanceof IRoot) {
- // Remove the peer nodes from the favorites list
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
if (!(element instanceof IPeerModel)) continue;
- Managers.getCategoryManager().remove(IUIConstants.ID_CAT_FAVORITES, ((IPeerModel)element).getPeerId());
+
+ // To determine the parent category, we have to look at the tree path
+ TreePath[] pathes = selection instanceof TreeSelection ? ((TreeSelection)selection).getPathsFor(element) : null;
+ if (pathes != null && pathes.length > 0) {
+ for (TreePath path : pathes) {
+ ICategory category = null;
+ TreePath parentPath = path.getParentPath();
+ while (parentPath != null) {
+ if (parentPath.getLastSegment() instanceof ICategory) {
+ category = (ICategory)parentPath.getLastSegment();
+ break;
+ }
+ parentPath = parentPath.getParentPath();
+ }
+
+ if (category != null) {
+ Managers.getCategoryManager().remove(category.getId(), ((IPeerModel)element).getPeerId());
+ }
+ }
+ }
}
+
// Fire a refresh of the view
ViewsUtil.refresh(IUIConstants.ID_EXPLORER);
}
@@ -135,14 +145,16 @@ public class CommonDnD {
if (!IUIConstants.ID_CAT_NEIGHBORHOOD.equals(hovered.getId())) {
valid = true;
- // If the target is the "Favorites" category, force DROP_LINK operation
- if (IUIConstants.ID_CAT_FAVORITES.equals(hovered.getId())
+ // If the target is the "Favorites" or the "My Targets" category,
+ // force DROP_LINK operation
+ if ((IUIConstants.ID_CAT_FAVORITES.equals(hovered.getId()) || IUIConstants.ID_CAT_MY_TARGETS.equals(hovered.getId()))
&& (operation & DND.DROP_LINK) == 0) {
overrideOperation = DND.DROP_LINK;
}
}
} else if (target instanceof IRoot) {
- // Allow to drag into empty space from favorite nodes only
+ // Allow to drag into empty space either from "Favorites"
+ // or "My Targets" category only
boolean allow = true;
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
@@ -151,7 +163,8 @@ public class CommonDnD {
allow = false;
break;
}
- if (!Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, ((IPeerModel)element).getPeerId())) {
+ if (!Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, ((IPeerModel)element).getPeerId())
+ && !Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_MY_TARGETS, ((IPeerModel)element).getPeerId())) {
allow = false;
break;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DropAssistant.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DropAssistant.java
index 6daff2182..561bd4c87 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DropAssistant.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/dnd/DropAssistant.java
@@ -47,7 +47,7 @@ public class DropAssistant extends CommonDropAdapterAssistant {
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
IStructuredSelection selection = (IStructuredSelection) event.data;
int operations = adapter.getCurrentOperation();
- sucess = CommonDnD.dropLocalSelection(target, operations, selection);
+ sucess = CommonDnD.dropLocalSelection(adapter, target, operations, selection);
}
return sucess ? Status.OK_STATUS : Status.CANCEL_STATUS;
}

Back to the top