Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Torregrosa Paez2016-06-02 09:58:21 -0400
committerPablo Torregrosa Paez2016-06-02 09:58:21 -0400
commitbceb8f3c36c3de772a215a6dfa0432dab45b3a6f (patch)
treea48490495d80cf05c9e1728a79c1d17ed4b1cabc /target_explorer
parentde7b4d6b1f0ed0eea32f60d1162c080fdceada24 (diff)
downloadorg.eclipse.tcf-bceb8f3c36c3de772a215a6dfa0432dab45b3a6f.tar.gz
org.eclipse.tcf-bceb8f3c36c3de772a215a6dfa0432dab45b3a6f.tar.xz
org.eclipse.tcf-bceb8f3c36c3de772a215a6dfa0432dab45b3a6f.zip
Target Explorer: Fixed recurrent call to SWT Clipboard from FSClipboard
Change-Id: Ia4eeb4a6ad4efa3360cb3184cb3e3221b6022db6 Signed-off-by: Pablo Torregrosa Paez <pablo.torregrosa@windriver.com>
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/FsClipboard.java44
1 files changed, 42 insertions, 2 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/FsClipboard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/FsClipboard.java
index e7145bdcb..360359ec7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/FsClipboard.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/operations/FsClipboard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2016 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -49,13 +49,43 @@ public class FsClipboard extends PropertyChangeProvider {
}
}
+ private static class FsClipboardCache {
+ private boolean cacheValid;
+ private boolean clipboardEmpty;
+
+ public FsClipboardCache() {
+ super();
+ cacheValid = false;
+ clipboardEmpty = true;
+ }
+
+ public boolean isCacheValid() {
+ return cacheValid;
+ }
+
+ public void invalidateCache() {
+ cacheValid = false;
+ }
+
+ public boolean isClipboardEmpty() {
+ return clipboardEmpty;
+ }
+
+ public void setClipboardEmpty(boolean empty) {
+ clipboardEmpty = empty;
+ cacheValid = true;
+ }
+ }
+
/* default */ final Clipboard clipboard;
+ /* default */ final FsClipboardCache clipboardCache;
/**
* Create a clip board instance.
*/
public FsClipboard() {
clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
+ clipboardCache = new FsClipboardCache();
}
public boolean isCutOp() {
@@ -93,6 +123,11 @@ public class FsClipboard extends PropertyChangeProvider {
}
public boolean isEmpty() {
+ // Check cache before consulting SWT clipboard
+ if (clipboardCache.isCacheValid()) {
+ return clipboardCache.isClipboardEmpty();
+ }
+
final AtomicReference<Object> object = new AtomicReference<Object>();
Runnable runnable = new Runnable() {
@@ -106,7 +141,9 @@ public class FsClipboard extends PropertyChangeProvider {
FsClipboardContent content = (FsClipboardContent) object.get();
- return content == null || content.files.isEmpty();
+ boolean empty = content == null || content.files.isEmpty();
+ clipboardCache.setClipboardEmpty(empty);
+ return empty;
}
/**
@@ -142,6 +179,7 @@ public class FsClipboard extends PropertyChangeProvider {
Runnable runnable = new Runnable() {
@Override
public void run() {
+ clipboardCache.invalidateCache();
clipboard.setContents(new Object[] { content }, new Transfer[] { transfer });
PropertyChangeEvent event = new PropertyChangeEvent(this, "cut", null, null); //$NON-NLS-1$
@@ -167,6 +205,7 @@ public class FsClipboard extends PropertyChangeProvider {
Runnable runnable = new Runnable() {
@Override
public void run() {
+ clipboardCache.invalidateCache();
clipboard.setContents(new Object[] { content }, new Transfer[] { transfer });
PropertyChangeEvent event = new PropertyChangeEvent(this, "copy", null, null); //$NON-NLS-1$
@@ -184,6 +223,7 @@ public class FsClipboard extends PropertyChangeProvider {
Runnable runnable = new Runnable() {
@Override
public void run() {
+ clipboardCache.invalidateCache();
clipboard.clearContents();
PropertyChangeEvent event = new PropertyChangeEvent(this, "clear", null, null); //$NON-NLS-1$

Back to the top