Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-04-26 23:39:48 -0400
committerWilliam Chen2012-04-26 23:39:48 -0400
commit410992c7f7b771c8cd54d2ed71f1d65ba7b89acb (patch)
tree8468c69c2b4f5e750f8abde345ba0817e408573b /target_explorer/plugins
parentb8568f52d50263d38cc3fb5fc9ed6b3315f2c472 (diff)
downloadorg.eclipse.tcf-410992c7f7b771c8cd54d2ed71f1d65ba7b89acb.tar.gz
org.eclipse.tcf-410992c7f7b771c8cd54d2ed71f1d65ba7b89acb.tar.xz
org.eclipse.tcf-410992c7f7b771c8cd54d2ed71f1d65ba7b89acb.zip
Target Explorer: Add DnD of files whose cache files exist to an external
program.
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java27
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragAdapterAssistant.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragSourceListener.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java13
5 files changed, 38 insertions, 14 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
index 529ef072f..6346cb378 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
@@ -1766,6 +1766,9 @@
</operations>
<transferTypes>
<transferType name ="LocalSelectionTransfer" />
+ <transferType
+ name="FileTransfer">
+ </transferType>
</transferTypes>
</dragSupport>
<dropSupport
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java
index 6c48ce7cf..3b959f9e7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.graphics.Image;
@@ -36,6 +37,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCopy;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpMove;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRefresh;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpUpload;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel;
import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
@@ -378,4 +380,29 @@ public class CommonDnD implements IConfirmCallback {
});
return results[0];
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
+ */
+ public boolean setDragData(DragSourceEvent anEvent) {
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(anEvent.dataType)) {
+ anEvent.data = LocalSelectionTransfer.getTransfer().getSelection();
+ return true;
+ }
+ else if (FileTransfer.getInstance().isSupportedType(anEvent.dataType)) {
+ IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
+ List<FSTreeNode> nodes = selection.toList();
+ List<String> paths = new ArrayList<String>();
+ for(FSTreeNode node : nodes) {
+ File file = CacheManager.getCacheFile(node);
+ if(file.exists()) {
+ paths.add(file.getAbsolutePath());
+ }
+ }
+ if (!paths.isEmpty()) anEvent.data = paths.toArray(new String[paths.size()]);
+ return !paths.isEmpty();
+ }
+ return false;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragAdapterAssistant.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragAdapterAssistant.java
index d066d77bc..64d935454 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragAdapterAssistant.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragAdapterAssistant.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.dnd;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
@@ -45,7 +46,7 @@ public class FSDragAdapterAssistant extends CommonDragAdapterAssistant {
*/
@Override
public Transfer[] getSupportedTransferTypes() {
- return new Transfer[] {};
+ return new Transfer[] {FileTransfer.getInstance()};
}
/*
@@ -54,6 +55,6 @@ public class FSDragAdapterAssistant extends CommonDragAdapterAssistant {
*/
@Override
public boolean setDragData(DragSourceEvent anEvent, IStructuredSelection aSelection) {
- return false;
+ return dnd.setDragData(anEvent);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragSourceListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragSourceListener.java
index 95de0e244..1dc4d7e9e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragSourceListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDragSourceListener.java
@@ -51,9 +51,7 @@ public class FSDragSourceListener implements DragSourceListener {
*/
@Override
public void dragSetData(DragSourceEvent event) {
- if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
- event.data = LocalSelectionTransfer.getTransfer().getSelection();
- }
+ event.doit = dnd.setDragData(event);
}
/*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java
index cc6505905..2f6786021 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java
@@ -44,16 +44,11 @@ public class FSDropTargetListener extends ViewerDropAdapter {
*/
@Override
public void dragEnter(DropTargetEvent event) {
- super.dragEnter(event);
- // Force the operation of file transfer from external application to DROP_COPY
- for (int i = 0; i < event.dataTypes.length; i++) {
- if (FileTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
- event.currentDataType = event.dataTypes[i];
- event.detail = DND.DROP_COPY;
- super.dragEnter(event);
- break;
- }
+ if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ // Force the operation of file transfer from external application to DROP_COPY
+ event.detail = DND.DROP_COPY;
}
+ super.dragEnter(event);
}
/*

Back to the top