Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2004-02-29 05:23:58 +0000
committerAlain Magloire2004-02-29 05:23:58 +0000
commite1140e486b06263b813a6aa39aef4e7bc40d1993 (patch)
treecef34de1ca008620dab70c0046da00a82d78b870
parent17436b16d022f8c1ca3aae3bb1f629d10a9aec2e (diff)
downloadorg.eclipse.cdt-e1140e486b06263b813a6aa39aef4e7bc40d1993.tar.gz
org.eclipse.cdt-e1140e486b06263b813a6aa39aef4e7bc40d1993.tar.xz
org.eclipse.cdt-e1140e486b06263b813a6aa39aef4e7bc40d1993.zip
PR 51757 help fixing. Run the PasteAction
update selection in a UI thread.
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java60
2 files changed, 44 insertions, 22 deletions
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 6c21c9d3a5e..eb4b1bf2657 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,5 +1,11 @@
2004-02-28 Alain Magloire
+ PR 51757
+
+ * src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
+
+2004-02-28 Alain Magloire
+
Provide an implementation of CView.selectReveal().
The problem was that ITranslationUnit != IWorkingCopy
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
index 2224060a3d9..68f148557ca 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
@@ -164,19 +165,23 @@ public class PasteAction extends SelectionListenerAction {
if (!super.updateSelection(selection))
return false;
- // clipboard must have resources or files
- ResourceTransfer resTransfer = ResourceTransfer.getInstance();
- IResource[] resourceData = (IResource[]) clipboard.getContents(resTransfer);
- FileTransfer fileTransfer = FileTransfer.getInstance();
- String[] fileData = (String[]) clipboard.getContents(fileTransfer);
- if (resourceData == null && fileData == null)
- return false;
-
- // can paste open projects regardless of selection
- boolean isProjectRes = resourceData != null && resourceData.length > 0 && resourceData[0].getType() == IResource.PROJECT;
+ final IResource[][] clipboardData = new IResource[1][];
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // clipboard must have resources or files
+ ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+ clipboardData[0] = (IResource[])clipboard.getContents(resTransfer);
+ }
+ });
+ IResource[] resourceData = clipboardData[0];
+ boolean isProjectRes = resourceData != null
+ && resourceData.length > 0
+ && resourceData[0].getType() == IResource.PROJECT;
+
if (isProjectRes) {
for (int i = 0; i < resourceData.length; i++) {
// make sure all resource data are open projects
+ // can paste open projects regardless of selection
if (resourceData[i].getType() != IResource.PROJECT || ((IProject) resourceData[i]).isOpen() == false)
return false;
}
@@ -187,18 +192,16 @@ public class PasteAction extends SelectionListenerAction {
// or multiple file selection with the same parent
if (getSelectedNonResources().size() > 0)
return false;
- List selectedResources = getSelectedResources();
- IResource targetResource = getTarget();
// targetResource is null if no valid target is selected or
// selection is empty
+ IResource targetResource = getTarget();
if (targetResource == null)
return false;
- // linked resources can only be pasted into projects
- if (isLinked(resourceData) && targetResource.getType() != IResource.PROJECT)
- return false;
-
+ // can paste files and folders to a single selection (file, folder,
+ // open project) or multiple file selection with the same parent
+ List selectedResources = getSelectedResources();
if (selectedResources.size() > 1) {
// if more than one resource is selected the selection has
// to be all files with the same parent
@@ -211,14 +214,27 @@ public class PasteAction extends SelectionListenerAction {
}
}
- if (targetResource.getType() == IResource.FOLDER && resourceData != null) {
- // don't try to copy folder to self
- for (int i = 0; i < resourceData.length; i++) {
- if (targetResource.equals(resourceData[i]))
- return false;
+ if (resourceData != null) {
+ // linked resources can only be pasted into projects
+ if (isLinked(resourceData) && targetResource.getType() != IResource.PROJECT)
+ return false;
+
+ if (targetResource.getType() == IResource.FOLDER) {
+ // don't try to copy folder to self
+ for (int i = 0; i < resourceData.length; i++) {
+ if (targetResource.equals(resourceData[i]))
+ return false;
+ }
}
+ return true;
}
- return true;
+ TransferData[] transfers = clipboard.getAvailableTypes();
+ FileTransfer fileTransfer = FileTransfer.getInstance();
+ for (int i = 0; i < transfers.length; i++) {
+ if (fileTransfer.isSupportedType(transfers[i]))
+ return true;
+ }
+ return false;
}
}

Back to the top