Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-09-29 11:14:17 -0400
committerUwe Stieber2012-09-29 11:14:17 -0400
commitc2b03466197a866a08e2a304ff6852d373adada9 (patch)
tree51b9b18d0d32f4f791b268d7fedf89d19fd9e7fc
parent5e14bf1ddcd4bc6e933d27baddb004fa1545f950 (diff)
downloadorg.eclipse.tcf-c2b03466197a866a08e2a304ff6852d373adada9.tar.gz
org.eclipse.tcf-c2b03466197a866a08e2a304ff6852d373adada9.tar.xz
org.eclipse.tcf-c2b03466197a866a08e2a304ff6852d373adada9.zip
Target Explorer: Fix category initialization must happen in UI thread to be able to create the category image
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java
index 75b920351..4b4856fb3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java
@@ -9,11 +9,15 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.views.internal.categories;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
+import org.eclipse.ui.PlatformUI;
/**
* The element factory for a category.
*/
@@ -23,9 +27,23 @@ public class CategoryFactory implements IElementFactory {
* @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
*/
@Override
- public IAdaptable createElement(IMemento memento) {
- String id = memento.getString("id"); //$NON-NLS-1$
- ICategory category = CategoriesExtensionPointManager.getInstance().getCategory(id, false);
- return category instanceof IAdaptable ? (IAdaptable)category : null;
+ public IAdaptable createElement(final IMemento memento) {
+ final AtomicReference<ICategory> category = new AtomicReference<ICategory>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ String id = memento.getString("id"); //$NON-NLS-1$
+ category.set(CategoriesExtensionPointManager.getInstance().getCategory(id, false));
+ }
+ };
+
+ if (Display.findDisplay(Thread.currentThread()) == null) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
+ } else {
+ runnable.run();
+ }
+
+ return category.get() instanceof IAdaptable ? (IAdaptable)category.get() : null;
}
}

Back to the top