Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-02-27 03:51:58 -0500
committerWilliam Chen2012-02-27 03:51:58 -0500
commit3b6ec8bc5e108e746f2c96ecb475634897ce838b (patch)
tree6c27bcd4cf3e4a63afaac588fbcb1c9468fc5497
parent873578be96dd9bdf53bb53df4aafb0a6921b4b7c (diff)
downloadorg.eclipse.tcf-3b6ec8bc5e108e746f2c96ecb475634897ce838b.tar.gz
org.eclipse.tcf-3b6ec8bc5e108e746f2c96ecb475634897ce838b.tar.xz
org.eclipse.tcf-3b6ec8bc5e108e746f2c96ecb475634897ce838b.zip
Target Explorer: Clear and dispose the system clipboard in UI threads.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSClipboard.java41
1 files changed, 37 insertions, 4 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSClipboard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSClipboard.java
index ee5db53a3..196b3c254 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSClipboard.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem/src/org/eclipse/tcf/te/tcf/filesystem/internal/operations/FSClipboard.java
@@ -12,7 +12,9 @@ package org.eclipse.tcf.te.tcf.filesystem.internal.operations;
import java.util.List;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.tcf.te.tcf.filesystem.model.FSTreeNode;
import org.eclipse.tcf.te.ui.utils.PropertyChangeProvider;
import org.eclipse.ui.PlatformUI;
@@ -75,7 +77,7 @@ public class FSClipboard extends PropertyChangeProvider {
public void cutFiles(List<FSTreeNode> files) {
operation = CUT;
this.files = files;
- clipboard.clearContents();
+ clearSystemClipboard();
PropertyChangeEvent event = new PropertyChangeEvent(this, "cut", null, null); //$NON-NLS-1$
firePropertyChange(event);
}
@@ -88,7 +90,7 @@ public class FSClipboard extends PropertyChangeProvider {
public void copyFiles(List<FSTreeNode> files) {
operation = COPY;
this.files = files;
- clipboard.clearContents();
+ clearSystemClipboard();
PropertyChangeEvent event = new PropertyChangeEvent(this, "copy", null, null); //$NON-NLS-1$
firePropertyChange(event);
}
@@ -99,16 +101,47 @@ public class FSClipboard extends PropertyChangeProvider {
public void clear() {
operation = NONE;
this.files = null;
- clipboard.clearContents();
+ clearSystemClipboard();
PropertyChangeEvent event = new PropertyChangeEvent(this, "clear", null, null); //$NON-NLS-1$
firePropertyChange(event);
}
/**
+ * Make sure the system clip board is cleared in a UI thread.
+ */
+ void clearSystemClipboard() {
+ if (Display.getCurrent() != null) {
+ clipboard.clearContents();
+ }
+ else {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
+ @Override
+ public void run() {
+ clearSystemClipboard();
+ }});
+ }
+ }
+
+ /**
* Dispose the clipboard.
*/
public void dispose() {
- if (!clipboard.isDisposed()) clipboard.dispose();
+ if(Display.getCurrent() != null) {
+ if (!clipboard.isDisposed()) {
+ try {
+ clipboard.dispose();
+ }
+ catch (SWTException e) {
+ }
+ }
+ }
+ else {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
+ @Override
+ public void run() {
+ dispose();
+ }});
+ }
}
/**

Back to the top