Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2016-04-25 07:49:34 +0000
committerAnton Leherbauer2016-04-28 12:24:38 +0000
commit62e98b84ce9278dc51ba2df5011e708b165a2842 (patch)
treed4eb4e40ee389598108a8862d5d46c14452f1cbb /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui
parent22f45e9b4fbc831ad5e277fde8f6064f58f13ed3 (diff)
downloadorg.eclipse.tcf-62e98b84ce9278dc51ba2df5011e708b165a2842.tar.gz
org.eclipse.tcf-62e98b84ce9278dc51ba2df5011e708b165a2842.tar.xz
org.eclipse.tcf-62e98b84ce9278dc51ba2df5011e708b165a2842.zip
Target Explorer: Reduce flicker on connect and disconnect
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/SourceProvider.java48
2 files changed, 55 insertions, 30 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java
index 48834bfbd..8bfe4edfc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextSelectorToolbarContribution.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014-2015 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -121,6 +121,8 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
/* default */ Boolean signatureValid;
+ protected volatile boolean updatePending;
+
/**
* Constructor.
*/
@@ -553,30 +555,35 @@ implements IWorkbenchContribution, IEventListener, IPeerModelListener, IProperty
IPeerNodeProperties.PROPERTY_IS_VALID.equals(changeEvent.getEventId()) ||
IPeerNodeProperties.PROPERTY_WARNINGS.equals(changeEvent.getEventId()) ||
"properties".equals(changeEvent.getEventId())))) { //$NON-NLS-1$
- if (menuMgr != null) menuMgr.markDirty();
- ExecutorsUtil.executeInUI(new Runnable() {
- @Override
- public void run() {
- update();
- }
- });
+ scheduleUpdate();
}
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean)
- */
- @Override
- public void modelChanged(IPeerModel model, IPeerNode peerNode, boolean added) {
- if (menuMgr != null) menuMgr.markDirty();
+ private void scheduleUpdate() {
+ if (updatePending) return;
+ updatePending = true;
ExecutorsUtil.executeInUI(new Runnable() {
+ private boolean scheduled;
@Override
public void run() {
+ if (!scheduled) {
+ Display.getCurrent().timerExec(200, this);
+ scheduled = true;
+ return;
+ }
+ updatePending = false;
update();
}
});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean)
+ */
+ @Override
+ public void modelChanged(IPeerModel model, IPeerNode peerNode, boolean added) {
+ scheduleUpdate();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/SourceProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/SourceProvider.java
index 46e11250d..5a9cd9f7e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/SourceProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/SourceProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -37,20 +37,24 @@ public class SourceProvider extends AbstractSourceProvider implements IEventList
*/
public static final String defaultContextSelectionName = "defaultContextSelection"; //$NON-NLS-1$
+ // see org.eclipse.ui.internal.services.EvaluationService
+ private static final String RE_EVAL = "org.eclipse.ui.internal.services.EvaluationService.evaluate"; //$NON-NLS-1$
+
// The internal list of provided source names
private final static String[] PROVIDED_SOURCE_NAMES = {defaultContextSelectionName};
// The reference to the expression evaluation service
private IEvaluationService service = null;
- private IPeerNode defaultContext = null;
+ private IPeerNode defaultContext;
+ private IPeerNode prevContext;
+ private volatile boolean changePending;
/**
* Constructor.
*/
public SourceProvider() {
super();
- EventManager.getInstance().addEventListener(this, ChangeEvent.class);
}
/* (non-Javadoc)
@@ -61,6 +65,7 @@ public class SourceProvider extends AbstractSourceProvider implements IEventList
super.initialize(locator);
defaultContext = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ EventManager.getInstance().addEventListener(this, ChangeEvent.class);
// Register the source provider with the expression evaluation service
if (locator.hasService(IEvaluationService.class)) {
@@ -109,19 +114,32 @@ public class SourceProvider extends AbstractSourceProvider implements IEventList
ChangeEvent changeEvent = (ChangeEvent)event;
if (changeEvent.getSource() instanceof IDefaultContextService || changeEvent.getSource() == defaultContext) {
defaultContext = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (changePending || !PlatformUI.isWorkbenchRunning() || PlatformUI.getWorkbench().isClosing())
+ return;
+ changePending = true;
// Fire the source changed notification within the UI thread
- if (Display.getCurrent() != null) {
- fireSourceChanged(ISources.WORKBENCH, defaultContextSelectionName, defaultContext != null ? defaultContext : IEvaluationContext.UNDEFINED_VARIABLE);
- } else if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getDisplay() != null && !PlatformUI.getWorkbench().getDisplay().isDisposed()) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @SuppressWarnings("synthetic-access")
- @Override
- public void run() {
- fireSourceChanged(ISources.WORKBENCH, defaultContextSelectionName, IEvaluationContext.UNDEFINED_VARIABLE);
- fireSourceChanged(ISources.WORKBENCH, defaultContextSelectionName, defaultContext != null ? defaultContext : IEvaluationContext.UNDEFINED_VARIABLE);
- }
- });
- }
+ final Display display = PlatformUI.getWorkbench().getDisplay();
+ display.asyncExec(new Runnable() {
+ private boolean scheduled;
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void run() {
+ if (service == null) return;
+ if (!scheduled) {
+ scheduled = true;
+ display.timerExec(100, this);
+ return;
+ }
+ IPeerNode newContext = defaultContext;
+ changePending = false;
+ if (newContext == prevContext) {
+ // force re-evaluation of enablement expressions
+ service.getCurrentState().addVariable(RE_EVAL, new Object());
+ } else
+ fireSourceChanged(ISources.WORKBENCH, defaultContextSelectionName, newContext != null ? newContext : IEvaluationContext.UNDEFINED_VARIABLE);
+ prevContext = newContext;
+ }
+ });
}
}
}

Back to the top