Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-12-09 15:39:00 +0000
committerChristian W. Damus2014-12-09 15:40:14 +0000
commite3770e9dd15b6b8394690ad02409883df743727b (patch)
treebcdad3466e4615ebd80582d3ab88d77b2e90093f /plugins/uml
parentabdfb27fa3de4e95746516c87b374f563c45ebeb (diff)
downloadorg.eclipse.papyrus-e3770e9dd15b6b8394690ad02409883df743727b.tar.gz
org.eclipse.papyrus-e3770e9dd15b6b8394690ad02409883df743727b.tar.xz
org.eclipse.papyrus-e3770e9dd15b6b8394690ad02409883df743727b.zip
454578: [Palette Service] SWT thread problem when repairing profile application
https://bugs.eclipse.org/bugs/show_bug.cgi?id=454578 Ensure that palette service updates are processed on the UI thread. Also fix failure to present the palette customization UI when there is any unresolved reference in a profile application.
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java
index d2284573c8a..91d58f5832f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/service/PaletteProfileApplicationListener.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
+ * Copyright (c) 2009, 2014 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,6 +8,7 @@
*
* Contributors:
* Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 454578
*
*****************************************************************************/
@@ -19,6 +20,7 @@ import org.eclipse.papyrus.commands.Activator;
import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.uml2.uml.ProfileApplication;
@@ -50,7 +52,22 @@ public class PaletteProfileApplicationListener implements IPapyrusListener {
if (editor == null) {
return;
}
- PapyrusPaletteService.getInstance().providerChanged(new ProviderChangeEvent(PapyrusPaletteService.getInstance()));
+
+ Display display = editor.getSite().getWorkbenchWindow().getShell().getDisplay();
+ if ((display != null) && (display != Display.getCurrent())) {
+ // Update the palette service on the UI thread because it may need to add/remove palette content,
+ // which implies changing SWT controls
+ display.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ updatePaletteService();
+ }
+ });
+ } else {
+ // Just do it synchronously
+ updatePaletteService();
+ }
} catch (ServiceException ex) {
// Nothing to do. The ServiceRegistry is not available or there is no active editor. Don't update the palette
} catch (Exception ex) {
@@ -60,4 +77,8 @@ public class PaletteProfileApplicationListener implements IPapyrusListener {
}
}
}
+
+ protected void updatePaletteService() {
+ PapyrusPaletteService.getInstance().providerChanged(new ProviderChangeEvent(PapyrusPaletteService.getInstance()));
+ }
}

Back to the top