Bug 514277 - Performance of closing parts/windows (with many visibleWhen/enabledWhen) is very slow
Change-Id: Ic6a5a73d294edaf5f7e14c0957c23eb07de8ccfb
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/AbstractContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/AbstractContributionItem.java
index f4aa230..4f7cd7b 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/AbstractContributionItem.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/AbstractContributionItem.java
@@ -542,23 +542,8 @@
return null;
}
- private Runnable scheduledUpdate;
protected void updateItemEnablement() {
- if (scheduledUpdate == null) {
- Display current = Display.getCurrent();
- scheduledUpdate = () -> {
- try {
- performUpdateItemEnablement();
- } finally {
- scheduledUpdate = null;
- }
- };
- current.asyncExec(scheduledUpdate);
- }
- }
-
- private void performUpdateItemEnablement() {
if (!(modelItem.getWidget() instanceof ToolItem))
return;
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarContributionRecord.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarContributionRecord.java
index 75a95d7..c041756 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarContributionRecord.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/ToolBarContributionRecord.java
@@ -15,11 +15,9 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.eclipse.core.expressions.ExpressionInfo;
import org.eclipse.e4.core.commands.ExpressionContext;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
@@ -34,7 +32,6 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.swt.widgets.Display;
public class ToolBarContributionRecord {
public static final String FACTORY = "ToolBarContributionFactory"; //$NON-NLS-1$
@@ -49,8 +46,6 @@
private IEclipseContext infoContext;
private Runnable factoryDispose;
- private Map<IEclipseContext, Runnable> scheduledUpdate = new HashMap<>();
-
public ToolBarContributionRecord(MToolBar model,
MToolBarContribution contribution, ToolBarManagerRenderer renderer) {
this.toolbarModel = model;
@@ -63,26 +58,6 @@
}
public void updateVisibility(IEclipseContext context) {
- scheduledUpdate.computeIfAbsent(context, c -> {
- Display current = Display.getCurrent();
- Runnable r = () -> {
- try {
- performUpdateVisibility(context);
- } finally {
- synchronized (scheduledUpdate) {
- scheduledUpdate.remove(context);
- }
- }
- };
- current.asyncExec(r);
- return r;
- });
- }
-
- /**
- * @param context
- */
- private void performUpdateVisibility(IEclipseContext context) {
ExpressionContext exprContext = new ExpressionContext(context);
updateIsVisible(exprContext);
HashSet<ToolBarContributionRecord> recentlyUpdated = new HashSet<>();