Bug 511338 - Perform tooltip update in background thread
The UI thread does not have to be blocked for the retrieval of the
action's tooltip text. Using a CompletableFuture to retrieve the tooltip
text and setting it for the action when done on the UI thread.
Change-Id: I363c7ab642efd078de12cc08fe3cc3226793b4e9
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java
index 99d1435..fa9a4b9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java
@@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.CompletableFuture;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -51,6 +52,7 @@
import org.eclipse.swt.events.MenuAdapter;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
@@ -198,7 +200,10 @@
* </p>
*/
protected void updateTooltip() {
- getAction().setToolTipText(getToolTip());
+ CompletableFuture.supplyAsync(this::getToolTip)
+ .thenAccept(tooltip ->
+ Display.getDefault().asyncExec(() -> getAction().setToolTipText(tooltip))
+ );
}
/**
@@ -421,7 +426,7 @@
/**
* @since 3.12
*/
- protected void runInternal(IAction action, boolean isShift) {
+ protected void runInternal(IAction action, @SuppressWarnings("unused") boolean isShift) {
run(action);
}