diff options
author | Stefan Dirix | 2015-07-30 09:01:36 +0000 |
---|---|---|
committer | Mickael Istria | 2020-01-17 22:37:03 +0000 |
commit | 91927cb3b3916b6ea17b8ba234ae55a03d94b839 (patch) | |
tree | 558636781ee6f1dca40e9c279a987d3d29069023 /bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java | |
parent | e8832328f3e127882d9fa3c66c0d20e8bdf92989 (diff) | |
download | eclipse.platform.team-91927cb3b3916b6ea17b8ba234ae55a03d94b839.tar.gz eclipse.platform.team-91927cb3b3916b6ea17b8ba234ae55a03d94b839.tar.xz eclipse.platform.team-91927cb3b3916b6ea17b8ba234ae55a03d94b839.zip |
Bug 473847 - Support DialogCompare for pure E4 applicationsY20200126-2245Y20200121-0055Y20200120-2315Y20200120-0020I20200126-1800I20200126-0250I20200125-1805I20200124-1800I20200123-1800I20200123-0525I20200123-0430I20200122-1805I20200121-2225I20200121-1805I20200120-1800I20200120-0715I20200120-0530I20200120-0445I20200120-0355I20200120-0115I20200119-2330I20200119-1800I20200118-1800I20200117-1800
Removes runtime dependencies to the workbench which allows pure E4
applications to execute comparisons within dialogs without exceptions.
Bug: 473847
Signed-off-by: Stefan Dirix <sdirix@eclipsesource.com>
Change-Id: I51851b0cab6dace0bc44bc9b6d30dfad32eeff39
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java')
-rw-r--r-- | bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java index 693ca3d1e..384504d9d 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java @@ -12,6 +12,7 @@ * IBM Corporation - initial API and implementation * Carsten Pfeiffer <carsten.pfeiffer@gebit.de> - CompareUIPlugin.getCommonType() returns null if left or right side is not available - https://bugs.eclipse.org/311843 * Stefan Xenos <sxenos@gmail.com> (Google) - bug 448968 - Add diagnostic logging + * Stefan Dirix <sdirix@eclipsesource.com> - bug 473847: Minimum E4 Compatibility of Compare *******************************************************************************/ package org.eclipse.compare.internal; @@ -475,17 +476,23 @@ public final class CompareUIPlugin extends AbstractUIPlugin { } /** - * Returns the SWT Shell of the active workbench window or <code>null</code> if + * If the workbench is running returns the SWT Shell of the active workbench window or <code>null</code> if * no workbench window is active. * - * @return the SWT Shell of the active workbench window, or <code>null</code> if - * no workbench window is active + * If the workbench is not running, returns the shell of the default display. + * + * @return If the workbench is running, returns the SWT Shell of the active workbench window, or <code>null</code> if + * no workbench window is active. Otherwise returns the shell of the default display. */ public static Shell getShell() { - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getShell(); + if(PlatformUI.isWorkbenchRunning()){ + IWorkbenchWindow window = getActiveWorkbenchWindow(); + if (window == null) + return null; + return window.getShell(); + } + + return Display.getDefault().getActiveShell(); } /** @@ -606,10 +613,12 @@ public final class CompareUIPlugin extends AbstractUIPlugin { public boolean compareResultOK(CompareEditorInput input, IRunnableContext context) { final Shell shell= getShell(); try { - // run operation in separate thread and make it cancelable - if (context == null) - context = PlatformUI.getWorkbench().getProgressService(); - context.run(true, true, input); + // run operation in context if possible + if (context != null) { + context.run(true, true, input); + } else { + Utilities.executeRunnable(input); + } String message= input.getMessage(); if (message != null) { @@ -1377,13 +1386,16 @@ public final class CompareUIPlugin extends AbstractUIPlugin { } private void internalOpenDialog(final CompareEditorInput input) { - Runnable runnable = () -> { - CompareDialog dialog = new CompareDialog(PlatformUI - .getWorkbench().getModalDialogShellProvider() - .getShell(), input); + syncExec(() -> { + Shell shell; + if (PlatformUI.isWorkbenchRunning()) { + shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); + } else { + shell = Display.getDefault().getActiveShell(); + } + CompareDialog dialog = new CompareDialog(shell, input); dialog.open(); - }; - syncExec(runnable); + }); } private void syncExec(Runnable runnable) { |