From 74cdc9d92ace5ceb5a5add50b925ec4c4bbe0c09 Mon Sep 17 00:00:00 2001 From: sebthom Date: Wed, 21 Feb 2024 23:34:14 +0100 Subject: [PATCH 1/2] bump tm4e versions for next development iteration --- org.eclipse.tm4e.core.tests/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.core.tests/pom.xml | 2 +- org.eclipse.tm4e.core/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.core/pom.xml | 2 +- org.eclipse.tm4e.feature/feature.xml | 2 +- org.eclipse.tm4e.feature/pom.xml | 2 +- org.eclipse.tm4e.language_pack.feature/feature.xml | 2 +- org.eclipse.tm4e.language_pack.feature/pom.xml | 2 +- org.eclipse.tm4e.language_pack/META-INF/MANIFEST.MF | 8 ++++---- org.eclipse.tm4e.language_pack/pom.xml | 2 +- org.eclipse.tm4e.language_pack/updater/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.languageconfiguration.tests/pom.xml | 2 +- .../META-INF/MANIFEST.MF | 8 ++++---- org.eclipse.tm4e.languageconfiguration/pom.xml | 2 +- org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF | 8 ++++---- org.eclipse.tm4e.markdown/pom.xml | 2 +- org.eclipse.tm4e.registry/META-INF/MANIFEST.MF | 4 ++-- org.eclipse.tm4e.registry/pom.xml | 2 +- org.eclipse.tm4e.repository/pom.xml | 2 +- org.eclipse.tm4e.samples/META-INF/MANIFEST.MF | 6 +++--- org.eclipse.tm4e.samples/pom.xml | 2 +- org.eclipse.tm4e.ui.tests/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.ui.tests/pom.xml | 2 +- org.eclipse.tm4e.ui/META-INF/MANIFEST.MF | 6 +++--- org.eclipse.tm4e.ui/pom.xml | 2 +- pom.xml | 2 +- 27 files changed, 41 insertions(+), 41 deletions(-) diff --git a/org.eclipse.tm4e.core.tests/META-INF/MANIFEST.MF b/org.eclipse.tm4e.core.tests/META-INF/MANIFEST.MF index f3339aa39..7a8d242bc 100644 --- a/org.eclipse.tm4e.core.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.core.tests/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.core.tests;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Require-Bundle: org.apache.batik.css;resolution:=optional, org.apache.batik.util;resolution:=optional, com.google.gson;resolution:=optional, diff --git a/org.eclipse.tm4e.core.tests/pom.xml b/org.eclipse.tm4e.core.tests/pom.xml index 07fcb3d25..30fef2802 100644 --- a/org.eclipse.tm4e.core.tests/pom.xml +++ b/org.eclipse.tm4e.core.tests/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.core.tests diff --git a/org.eclipse.tm4e.core/META-INF/MANIFEST.MF b/org.eclipse.tm4e.core/META-INF/MANIFEST.MF index 121e27194..ce7e7d234 100644 --- a/org.eclipse.tm4e.core/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.core/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.core -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Require-Bundle: com.google.gson;bundle-version="[2.10.1,3.0.0)", org.apache.batik.css;bundle-version="[1.16.0,2.0.0)";resolution:=optional, org.apache.batik.util;bundle-version="[1.16.0,2.0.0)";resolution:=optional, diff --git a/org.eclipse.tm4e.core/pom.xml b/org.eclipse.tm4e.core/pom.xml index bfbd0c935..6870da7de 100644 --- a/org.eclipse.tm4e.core/pom.xml +++ b/org.eclipse.tm4e.core/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.core diff --git a/org.eclipse.tm4e.feature/feature.xml b/org.eclipse.tm4e.feature/feature.xml index 652ab3278..058111887 100644 --- a/org.eclipse.tm4e.feature/feature.xml +++ b/org.eclipse.tm4e.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/org.eclipse.tm4e.feature/pom.xml b/org.eclipse.tm4e.feature/pom.xml index 49eebdd6b..702939228 100644 --- a/org.eclipse.tm4e.feature/pom.xml +++ b/org.eclipse.tm4e.feature/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.feature diff --git a/org.eclipse.tm4e.language_pack.feature/feature.xml b/org.eclipse.tm4e.language_pack.feature/feature.xml index cc9212479..057c5bd72 100644 --- a/org.eclipse.tm4e.language_pack.feature/feature.xml +++ b/org.eclipse.tm4e.language_pack.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/org.eclipse.tm4e.language_pack.feature/pom.xml b/org.eclipse.tm4e.language_pack.feature/pom.xml index 37e68e946..83fb050e3 100644 --- a/org.eclipse.tm4e.language_pack.feature/pom.xml +++ b/org.eclipse.tm4e.language_pack.feature/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.language_pack.feature diff --git a/org.eclipse.tm4e.language_pack/META-INF/MANIFEST.MF b/org.eclipse.tm4e.language_pack/META-INF/MANIFEST.MF index 9022b170c..7da9c3d6d 100644 --- a/org.eclipse.tm4e.language_pack/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.language_pack/META-INF/MANIFEST.MF @@ -4,10 +4,10 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.language_pack;singleton:=true -Bundle-Version: 0.10.2.qualifier -Require-Bundle: org.eclipse.tm4e.ui;bundle-version="0.10.2", - org.eclipse.tm4e.registry;bundle-version="0.10.2", - org.eclipse.tm4e.languageconfiguration;bundle-version="0.10.2", +Bundle-Version: 0.10.3.qualifier +Require-Bundle: org.eclipse.tm4e.ui;bundle-version="0.10.3", + org.eclipse.tm4e.registry;bundle-version="0.10.3", + org.eclipse.tm4e.languageconfiguration;bundle-version="0.10.3", org.eclipse.ui.editors;bundle-version="[3.3.0,4.0.0)", org.eclipse.ui.genericeditor;bundle-version="[1.0.0,2.0.0)", org.eclipse.core.contenttype;bundle-version="[3.2.0,4.0.0)" diff --git a/org.eclipse.tm4e.language_pack/pom.xml b/org.eclipse.tm4e.language_pack/pom.xml index bee22e675..be58af0ef 100644 --- a/org.eclipse.tm4e.language_pack/pom.xml +++ b/org.eclipse.tm4e.language_pack/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.language_pack diff --git a/org.eclipse.tm4e.language_pack/updater/pom.xml b/org.eclipse.tm4e.language_pack/updater/pom.xml index 3a06edd46..ca547b6c7 100644 --- a/org.eclipse.tm4e.language_pack/updater/pom.xml +++ b/org.eclipse.tm4e.language_pack/updater/pom.xml @@ -9,7 +9,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT ../.. diff --git a/org.eclipse.tm4e.languageconfiguration.tests/META-INF/MANIFEST.MF b/org.eclipse.tm4e.languageconfiguration.tests/META-INF/MANIFEST.MF index 3027d28e8..23468db91 100644 --- a/org.eclipse.tm4e.languageconfiguration.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.languageconfiguration.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Tests for TM4E language configuration support Bundle-SymbolicName: org.eclipse.tm4e.languageconfiguration.tests;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Bundle-Vendor: Eclipse TM4E Automatic-Module-Name: org.eclipse.tm4e.languageconfiguration.tests Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/org.eclipse.tm4e.languageconfiguration.tests/pom.xml b/org.eclipse.tm4e.languageconfiguration.tests/pom.xml index 344af114f..7cd7e6eed 100644 --- a/org.eclipse.tm4e.languageconfiguration.tests/pom.xml +++ b/org.eclipse.tm4e.languageconfiguration.tests/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.languageconfiguration.tests diff --git a/org.eclipse.tm4e.languageconfiguration/META-INF/MANIFEST.MF b/org.eclipse.tm4e.languageconfiguration/META-INF/MANIFEST.MF index 7bb450772..5a64725fa 100644 --- a/org.eclipse.tm4e.languageconfiguration/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.languageconfiguration/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.languageconfiguration;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.expressions, org.eclipse.core.filebuffers, @@ -17,9 +17,9 @@ Require-Bundle: org.eclipse.core.expressions, org.eclipse.ui.genericeditor, org.eclipse.ui.ide, org.eclipse.e4.ui.css.swt.theme, - org.eclipse.tm4e.registry;bundle-version="0.10.2", - org.eclipse.tm4e.core;bundle-version="0.10.2", - org.eclipse.tm4e.ui;bundle-version="0.10.2", + org.eclipse.tm4e.registry;bundle-version="0.10.3", + org.eclipse.tm4e.core;bundle-version="0.10.3", + org.eclipse.tm4e.ui;bundle-version="0.10.3", com.google.gson;bundle-version="[2.10.1,3.0.0)" Bundle-Activator: org.eclipse.tm4e.languageconfiguration.LanguageConfigurationPlugin Export-Package: org.eclipse.tm4e.languageconfiguration, diff --git a/org.eclipse.tm4e.languageconfiguration/pom.xml b/org.eclipse.tm4e.languageconfiguration/pom.xml index f8d9af305..9b062f4e5 100644 --- a/org.eclipse.tm4e.languageconfiguration/pom.xml +++ b/org.eclipse.tm4e.languageconfiguration/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.languageconfiguration diff --git a/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF b/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF index 302718478..9c4a43176 100644 --- a/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF @@ -4,11 +4,11 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.markdown;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Require-Bundle: org.eclipse.core.runtime, - org.eclipse.tm4e.core;bundle-version="0.10.2", - org.eclipse.tm4e.registry;bundle-version="0.10.2", - org.eclipse.tm4e.ui;bundle-version="0.10.2" + org.eclipse.tm4e.core;bundle-version="0.10.3", + org.eclipse.tm4e.registry;bundle-version="0.10.3", + org.eclipse.tm4e.ui;bundle-version="0.10.3" Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.tm4e.markdown, org.eclipse.tm4e.markdown.marked diff --git a/org.eclipse.tm4e.markdown/pom.xml b/org.eclipse.tm4e.markdown/pom.xml index 8fcd95592..95781a74a 100644 --- a/org.eclipse.tm4e.markdown/pom.xml +++ b/org.eclipse.tm4e.markdown/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.markdown diff --git a/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF b/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF index 730442fbc..1ffdfa30e 100644 --- a/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF @@ -3,11 +3,11 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.tm4e.registry;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime, org.eclipse.equinox.preferences, - org.eclipse.tm4e.core;bundle-version="0.10.2", + org.eclipse.tm4e.core;bundle-version="0.10.3", com.google.gson;bundle-version="[2.10.1,3.0.0)" Export-Package: org.eclipse.tm4e.registry Bundle-Activator: org.eclipse.tm4e.registry.TMEclipseRegistryPlugin diff --git a/org.eclipse.tm4e.registry/pom.xml b/org.eclipse.tm4e.registry/pom.xml index 66ac95c20..c4595577b 100644 --- a/org.eclipse.tm4e.registry/pom.xml +++ b/org.eclipse.tm4e.registry/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.registry diff --git a/org.eclipse.tm4e.repository/pom.xml b/org.eclipse.tm4e.repository/pom.xml index a79657527..959c85b9a 100644 --- a/org.eclipse.tm4e.repository/pom.xml +++ b/org.eclipse.tm4e.repository/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.repository diff --git a/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF b/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF index 6ecfc2fcf..cc793cce1 100644 --- a/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF @@ -4,14 +4,14 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.samples;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Require-Bundle: org.eclipse.jface.text, org.eclipse.core.runtime, org.eclipse.ui, org.eclipse.ui.editors, org.eclipse.ui.genericeditor;bundle-version="1.0.0";resolution:=optional, - org.eclipse.tm4e.core;bundle-version="0.10.2", - org.eclipse.tm4e.ui;bundle-version="0.10.2" + org.eclipse.tm4e.core;bundle-version="0.10.3", + org.eclipse.tm4e.ui;bundle-version="0.10.3" Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.eclipse.tm4e.samples diff --git a/org.eclipse.tm4e.samples/pom.xml b/org.eclipse.tm4e.samples/pom.xml index 450760791..c39a90244 100644 --- a/org.eclipse.tm4e.samples/pom.xml +++ b/org.eclipse.tm4e.samples/pom.xml @@ -4,7 +4,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.samples diff --git a/org.eclipse.tm4e.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.tm4e.ui.tests/META-INF/MANIFEST.MF index 2b7c153f8..adbb023db 100644 --- a/org.eclipse.tm4e.ui.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.ui.tests/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.ui.tests;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Require-Bundle: org.eclipse.jface.text, org.eclipse.core.filesystem, org.eclipse.core.resources, diff --git a/org.eclipse.tm4e.ui.tests/pom.xml b/org.eclipse.tm4e.ui.tests/pom.xml index bb15e3c54..38e27de3d 100644 --- a/org.eclipse.tm4e.ui.tests/pom.xml +++ b/org.eclipse.tm4e.ui.tests/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.ui.tests diff --git a/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF b/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF index 3146efc93..054579cb3 100644 --- a/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.tm4e.ui;singleton:=true -Bundle-Version: 0.10.2.qualifier +Bundle-Version: 0.10.3.qualifier Require-Bundle: org.eclipse.core.expressions, org.eclipse.core.filesystem, org.eclipse.core.resources, @@ -16,8 +16,8 @@ Require-Bundle: org.eclipse.core.expressions, org.eclipse.ui.trace;resolution:=optional, org.eclipse.ui.workbench.texteditor, org.eclipse.e4.ui.css.swt.theme, - org.eclipse.tm4e.core;bundle-version="0.10.2", - org.eclipse.tm4e.registry;bundle-version="0.10.2", + org.eclipse.tm4e.core;bundle-version="0.10.3", + org.eclipse.tm4e.registry;bundle-version="0.10.3", com.google.gson;bundle-version="[2.10.1,3.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.tm4e.ui, diff --git a/org.eclipse.tm4e.ui/pom.xml b/org.eclipse.tm4e.ui/pom.xml index f82048d38..73dd119fb 100644 --- a/org.eclipse.tm4e.ui/pom.xml +++ b/org.eclipse.tm4e.ui/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT org.eclipse.tm4e.ui diff --git a/pom.xml b/pom.xml index 96739831a..1eafe414b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.eclipse org.eclipse.tm4e - 0.10.2-SNAPSHOT + 0.10.3-SNAPSHOT pom From e99eda0107e9942efcb7c1ba5f28daa51ae427b6 Mon Sep 17 00:00:00 2001 From: sebthom Date: Fri, 1 Mar 2024 21:18:41 +0100 Subject: [PATCH 2/2] fix: Exception using IThemeManager#getDefaultTheme() from non-UI thread This addresses #721 --- .../internal/themes/AbstractThemeManager.java | 4 +-- .../eclipse/tm4e/ui/internal/utils/UI.java | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java index 373ab4bf5..2ccdd38a4 100644 --- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java +++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java @@ -54,7 +54,7 @@ public ITheme[] getThemes() { @Override public ITheme getDefaultTheme() { - return getDefaultTheme(UI.isDarkEclipseTheme()); + return getDefaultTheme(UI.runSync(UI::isDarkEclipseTheme)); } @Override @@ -87,7 +87,7 @@ public ITheme[] getThemes(final boolean dark) { @Override public ITheme getThemeForScope(final String scopeName) { - return getThemeForScope(scopeName, UI.isDarkEclipseTheme()); + return getThemeForScope(scopeName, UI.runSync(UI::isDarkEclipseTheme)); } @Override diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/utils/UI.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/utils/UI.java index 3b4a0cbc2..f0bdfa69b 100644 --- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/utils/UI.java +++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/utils/UI.java @@ -11,12 +11,16 @@ *******************************************************************************/ package org.eclipse.tm4e.ui.internal.utils; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWTException; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Color; @@ -176,6 +180,36 @@ public static boolean isDarkEclipseTheme() { return isDarkColor(shell.getBackground()); } + public static boolean isUIThread() { + return Display.getCurrent() != null; + } + + /** + * Runs the given runnable synchronously on the UI thread + * + * @throws SWTException if the {@link Display} has been disposed + */ + public static T runSync(final Supplier runnable) { + if (isUIThread()) + return runnable.get(); + + final var resultRef = new AtomicReference(); + final var exRef = new AtomicReference<@Nullable RuntimeException>(); + getDisplay().syncExec(() -> { + try { + resultRef.set(runnable.get()); + } catch (final RuntimeException ex) { + exRef.set(ex); + } + }); + + final @Nullable RuntimeException ex = exRef.get(); + if (ex != null) { + throw ex; + } + return resultRef.get(); + } + private UI() { } }