Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2017-01-11 17:20:44 +0000
committerChristian W. Damus2017-01-11 17:20:44 +0000
commit47b50b662fa9f3bfe14db3ac4f8743125e42df06 (patch)
treecb7aeeec9ae9f21570c1e7368e8c1011db684b34 /plugins/infra/properties
parent976b7fd26224ab5593d26c75892c851b46363b00 (diff)
downloadorg.eclipse.papyrus-47b50b662fa9f3bfe14db3ac4f8743125e42df06.tar.gz
org.eclipse.papyrus-47b50b662fa9f3bfe14db3ac4f8743125e42df06.tar.xz
org.eclipse.papyrus-47b50b662fa9f3bfe14db3ac4f8743125e42df06.zip
Bug 510254: [Infra] Label provider changes should be propagated in Display thread
Ensure that the various bits of the Properties View are notified of label updates on the UI thread because (a) observables can only interact on the UI thread and (b) the Eclipse Properties View framework doesn't account for title label provider updates triggered on any other thread. https://bugs.eclipse.org/bugs/show_bug.cgi?id=510254 (🍒-picked from branch streams/2.0-maintenance) Change-Id: Ibb47b03b48956e6063abb1929d82ecc098c0b1d8
Diffstat (limited to 'plugins/infra/properties')
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSource.java31
-rw-r--r--plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/PropertiesHeaderLabelProvider.java19
2 files changed, 39 insertions, 11 deletions
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSource.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSource.java
index 0695336bbbf..c27afdf18ac 100644
--- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSource.java
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/modelelement/DataSource.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2010, 2017 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,7 +10,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Add binding implementation
* Christian W. Damus (CEA) - bug 417409
- * Christian W. Damus - bug 455075
+ * Christian W. Damus - bugs 455075, 510254
*
*****************************************************************************/
package org.eclipse.papyrus.infra.properties.ui.modelelement;
@@ -33,6 +33,7 @@ import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.papyrus.infra.properties.contexts.View;
import org.eclipse.papyrus.infra.properties.internal.ui.Activator;
+import org.eclipse.papyrus.infra.tools.util.CoreExecutors;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
@@ -40,6 +41,7 @@ import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.util.INameResolutionHelper;
import org.eclipse.papyrus.infra.widgets.util.IPapyrusConverter;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
/**
* A DataSource is an object encapsulating one or more {@link ModelElement}s.
@@ -251,12 +253,25 @@ public class DataSource implements IChangeListener {
public void labelProviderChanged(LabelProviderChangedEvent event) {
if (!listeners.isEmpty()) {
LabelProviderChangedEvent forward = new LabelProviderChangedEvent(this, event.getElements());
- for (ILabelProviderListener next : listeners) {
- try {
- next.labelProviderChanged(forward);
- } catch (Exception e) {
- Activator.log.error("Uncaught exception in label provider listener.", e); //$NON-NLS-1$
- }
+
+ // Listeners will most likely need to interact with the observables provided through me,
+ // so ensure that events are propagated on the UI thread
+ if (Display.getCurrent() != null) {
+ // Already on the UI thread
+ fireLabelProviderChanged(forward);
+ } else {
+ // Post asynchronously on the UI thread
+ CoreExecutors.getUIExecutorService().execute(() -> fireLabelProviderChanged(forward));
+ }
+ }
+ }
+
+ protected void fireLabelProviderChanged(LabelProviderChangedEvent event) {
+ for (ILabelProviderListener next : listeners) {
+ try {
+ next.labelProviderChanged(event);
+ } catch (Exception e) {
+ Activator.log.error("Uncaught exception in label provider listener.", e); //$NON-NLS-1$
}
}
}
diff --git a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/PropertiesHeaderLabelProvider.java b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/PropertiesHeaderLabelProvider.java
index 7e0911868f8..a8bbc9f3cad 100644
--- a/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/PropertiesHeaderLabelProvider.java
+++ b/plugins/infra/properties/org.eclipse.papyrus.infra.properties.ui/src/org/eclipse/papyrus/infra/properties/ui/providers/PropertiesHeaderLabelProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2017 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,7 +8,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 508629
+ * Christian W. Damus - bugs 508629, 510254
*****************************************************************************/
package org.eclipse.papyrus.infra.properties.ui.providers;
@@ -18,7 +18,9 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.services.labelprovider.service.impl.LabelProviderServiceImpl;
+import org.eclipse.papyrus.infra.tools.util.CoreExecutors;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
/**
* An extensible LabelProvider for the Properties View header. It is based
@@ -57,7 +59,18 @@ public class PropertiesHeaderLabelProvider extends LabelProvider {
}
private void forwardLabelChange(LabelProviderChangedEvent event) {
- fireLabelProviderChanged(new LabelProviderChangedEvent(this, event.getElements()));
+ LabelProviderChangedEvent forward = new LabelProviderChangedEvent(this, event.getElements());
+
+ // The TabbedPropertySheetPage does not account for label-provider events happening
+ // off the UI thread, so we have to synchronize with the UI to protect it
+
+ if (Display.getCurrent() != null) {
+ // Already on the UI thread
+ fireLabelProviderChanged(forward);
+ } else {
+ // Asynchronously on the UI thread, then
+ CoreExecutors.getUIExecutorService().execute(() -> fireLabelProviderChanged(forward));
+ }
}
@Override

Back to the top