Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Dirix2015-07-30 09:01:36 +0000
committerMickael Istria2020-01-17 22:37:03 +0000
commit91927cb3b3916b6ea17b8ba234ae55a03d94b839 (patch)
tree558636781ee6f1dca40e9c279a987d3d29069023 /bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
parente8832328f3e127882d9fa3c66c0d20e8bdf92989 (diff)
downloadeclipse.platform.team-91927cb3b3916b6ea17b8ba234ae55a03d94b839.tar.gz
eclipse.platform.team-91927cb3b3916b6ea17b8ba234ae55a03d94b839.tar.xz
eclipse.platform.team-91927cb3b3916b6ea17b8ba234ae55a03d94b839.zip
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.java46
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) {

Back to the top