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
parente8832328f3e127882d9fa3c66c0d20e8bdf92989 (diff)
downloadeclipse.platform.team-Y20200120-0020.tar.gz
eclipse.platform.team-Y20200120-0020.tar.xz
eclipse.platform.team-Y20200120-0020.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
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java4
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java3
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java10
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java20
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java7
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java46
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java22
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java4
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java3
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java74
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java4
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java6
-rw-r--r--bundles/org.eclipse.compare/icons/full/elcl16/view_menu.pngbin0 -> 409 bytes
-rw-r--r--bundles/org.eclipse.compare/icons/full/elcl16/view_menu@2x.pngbin0 -> 834 bytes
23 files changed, 184 insertions, 62 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index 0d5ff3fa2..1f5d74475 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare;
@@ -562,7 +563,7 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
}
control.addDisposeListener(ev -> handleDispose());
});
- if (fHelpContextId != null)
+ if (fHelpContextId != null && PlatformUI.isWorkbenchRunning())
PlatformUI.getWorkbench().getHelpSystem().setHelp(fComposite, fHelpContextId);
contentsCreated();
return fComposite;
@@ -1459,7 +1460,7 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit
private boolean saveChanges() {
try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> {
+ Utilities.executeRunnable(monitor -> {
try {
saveChanges(monitor);
} catch (CoreException e) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index 47d7ce017..63ae28658 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -20,6 +20,7 @@
* Robin Stocker (robin@nibor.org) - Bug 398594: [Edit] Enable center arrow buttons when editable and for both sides
* Robin Stocker (robin@nibor.org) - Bug 399960: [Edit] Make merge arrow buttons easier to hit
* John Hendrikx (hjohn@xs4all.nl) - Bug 541401 - [regression] Vertical scrollbar thumb size is wrong in compare view
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.contentmergeviewer;
@@ -2036,7 +2037,9 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
*/
@Override
protected void createControls(Composite composite) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.TEXT_MERGE_VIEW);
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.TEXT_MERGE_VIEW);
+ }
// 1st row
if (fMarginWidth > 0) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
index ede59b1ba..1643acfeb 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
@@ -51,7 +51,9 @@ public class BinaryCompareViewer extends AbstractViewer {
public BinaryCompareViewer(Composite parent, final CompareConfiguration cc) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW);
+ if(PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW);
+ }
fBundle= ResourceBundle.getBundle(BUNDLE_NAME);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java
index 31d5f28d4..5b03a63e2 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContainer.java
@@ -24,7 +24,6 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.services.IServiceLocator;
public class CompareContainer implements ICompareContainer {
@@ -68,7 +67,7 @@ public class CompareContainer implements ICompareContainer {
public void run(boolean fork, boolean cancelable,
IRunnableWithProgress runnable)
throws InvocationTargetException, InterruptedException {
- PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable);
+ Utilities.executeRunnable(runnable, fork, cancelable);
}
@Override
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
index 3026cc907..c0fe6851b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java
@@ -1,8 +1,7 @@
/*******************************************************************************
* Copyright (c) 2009, 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
@@ -10,6 +9,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -47,7 +47,6 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.PlatformUI;
public class CompareContentViewerSwitchingPane extends CompareViewerSwitchingPane {
private static final String OPTIMIZED_INFO_IMAGE_NAME = "obj16/message_info.png"; //$NON-NLS-1$
@@ -122,8 +121,7 @@ public class CompareContentViewerSwitchingPane extends CompareViewerSwitchingPan
toolBar = new ToolBar(composite, SWT.FLAT);
toolBar.setVisible(false); // hide by default
final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
- toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
- /* IWorkbenchGraphicConstants */"IMG_LCL_VIEW_MENU")); //$NON-NLS-1$
+ Utilities.setMenuImage(toolItem);
toolItem.setToolTipText(CompareMessages.CompareContentViewerSwitchingPane_switchButtonTooltip);
toolItem.addSelectionListener(new SelectionAdapter() {
@Override
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java
index ed303baf1..6dc96d2da 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -211,7 +212,7 @@ public class CompareDialog extends TrayDialog implements IPropertyChangeListener
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- if (getHelpContextId() != null)
+ if (PlatformUI.isWorkbenchRunning() && getHelpContextId() != null)
PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, getHelpContextId());
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
index 7da9a8eed..c02f3a56b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
@@ -454,7 +454,11 @@ public class CompareEditor extends EditorPart
}
}
fPageBook.showPage(fControl);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fControl, ICompareContextIds.COMPARE_EDITOR);
+
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(fControl, ICompareContextIds.COMPARE_EDITOR);
+ }
+
if (isActive()) {
setFocus();
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
index 1d54e91c2..870e8385c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
@@ -53,22 +53,20 @@ public class CompareEditorContributor extends EditorActionBarContributor {
public CompareEditorContributor() {
ResourceBundle bundle= CompareUI.getResourceBundle();
- IWorkbenchHelpSystem helpSystem= PlatformUI.getWorkbench().getHelpSystem();
-
fIgnoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(bundle, null);
- helpSystem.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION);
-
fNext= new NavigationAction(bundle, true);
- helpSystem.setHelp(fNext, ICompareContextIds.GLOBAL_NEXT_DIFF_ACTION);
-
fPrevious= new NavigationAction(bundle, false);
- helpSystem.setHelp(fPrevious, ICompareContextIds.GLOBAL_PREVIOUS_DIFF_ACTION);
-
fToolbarNext= new NavigationAction(bundle, true);
- helpSystem.setHelp(fToolbarNext, ICompareContextIds.NEXT_DIFF_ACTION);
-
fToolbarPrevious= new NavigationAction(bundle, false);
- helpSystem.setHelp(fToolbarPrevious, ICompareContextIds.PREVIOUS_DIFF_ACTION);
+
+ if (PlatformUI.isWorkbenchRunning()) {
+ IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+ helpSystem.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION);
+ helpSystem.setHelp(fNext, ICompareContextIds.GLOBAL_NEXT_DIFF_ACTION);
+ helpSystem.setHelp(fPrevious, ICompareContextIds.GLOBAL_PREVIOUS_DIFF_ACTION);
+ helpSystem.setHelp(fToolbarNext, ICompareContextIds.NEXT_DIFF_ACTION);
+ helpSystem.setHelp(fToolbarPrevious, ICompareContextIds.PREVIOUS_DIFF_ACTION);
+ }
}
@Override
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java
index 564726cdb..a25353e7f 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -44,6 +45,10 @@ public class CompareHandlerService {
if (service != null)
return new CompareHandlerService(container, null);
}
+ if (!PlatformUI.isWorkbenchRunning() && shell != null) {
+ Expression e = new ActiveShellExpression(shell);
+ return new CompareHandlerService(container, e);
+ }
if (container.getWorkbenchPart() == null && shell != null) {
// We're in a dialog so we can use an active shell expression
IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class);
@@ -92,7 +97,7 @@ public class CompareHandlerService {
if (service != null)
fHandlerService = service;
}
- if (fHandlerService == null && fContainer.getWorkbenchPart() == null && fExpression != null) {
+ if (PlatformUI.isWorkbenchRunning() && fHandlerService == null && fContainer.getWorkbenchPart() == null && fExpression != null) {
// We're in a dialog so we can use an active shell expression
IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class);
if (service != null) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index 133adb208..caa454ed1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -249,8 +249,9 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
@Override
protected Control createContents(Composite parent) {
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.COMPARE_PREFERENCE_PAGE);
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.COMPARE_PREFERENCE_PAGE);
+ }
fOverlayStore.load();
fOverlayStore.start();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java
index 1593d8577..4f4d79936 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -43,7 +44,6 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.PlatformUI;
public class CompareStructureViewerSwitchingPane extends
CompareViewerSwitchingPane {
@@ -111,8 +111,7 @@ public class CompareStructureViewerSwitchingPane extends
toolBar = new ToolBar(composite, SWT.FLAT);
toolBar.setVisible(false); // hide by default
final ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
- toolItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
- /* IWorkbenchGraphicConstants */"IMG_LCL_VIEW_MENU")); //$NON-NLS-1$
+ Utilities.setMenuImage(toolItem);
toolItem
.setToolTipText(CompareMessages.CompareStructureViewerSwitchingPane_switchButtonTooltip);
toolItem.addSelectionListener(new SelectionAdapter() {
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) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java
index b6612c7b1..5619280a9 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java
@@ -24,6 +24,10 @@ import org.eclipse.compare.IEncodedStreamContentAccessor;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.ResourceNode;
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFileState;
import org.eclipse.core.runtime.CoreException;
@@ -218,6 +222,24 @@ public class EditionAction extends BaseCompareAction {
}
private IDocument getDocument(IFile file) {
+ if (file == null) {
+ return null;
+ }
+
+ // first try FileBuffer API
+ ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
+ ITextFileBuffer buffer = bufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
+ if (buffer != null) {
+ IDocument document = buffer.getDocument();
+ if (document != null) {
+ return document;
+ }
+ }
+
+ // if unsuccessful, try open editors
+ if (!PlatformUI.isWorkbenchRunning()) {
+ return null;
+ }
IWorkbench wb= PlatformUI.getWorkbench();
if (wb == null)
return null;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java
index 50d8da27a..bc0ec4cbe 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewer.java
@@ -44,7 +44,9 @@ public class ImageMergeViewer extends ContentMergeViewer {
public ImageMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
super(styles, ResourceBundle.getBundle(BUNDLE_NAME), mp);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.IMAGE_COMPARE_VIEW);
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.IMAGE_COMPARE_VIEW);
+ }
buildControl(parent);
String title= Utilities.getString(getResourceBundle(), "title"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
index 1728df9f1..f44b6ef84 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
@@ -12,6 +12,7 @@
* IBM Corporation - initial API and implementation
* Max Weninger (max.weninger@windriver.com) - Bug 131895 [Edit] Undo in compare
* Max Weninger (max.weninger@windriver.com) - Bug 72936 [Viewers] Show line numbers in comparision
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -1040,7 +1041,7 @@ public class MergeSourceViewer implements ISelectionChangedListener,
}
private IOperationHistory getHistory() {
- if (PlatformUI.getWorkbench() == null) {
+ if (!PlatformUI.isWorkbenchRunning()) {
return null;
}
return PlatformUI.getWorkbench().getOperationSupport()
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java
index d1e65e45a..4ee2b924b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java
@@ -61,7 +61,7 @@ public abstract class ResizableDialog extends Dialog {
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- if (fContextId != null)
+ if (fContextId != null && PlatformUI.isWorkbenchRunning())
PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, fContextId);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
index 2f2bc3b74..78d22a874 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
@@ -1,8 +1,14 @@
/*******************************************************************************
+<<<<<<< HEAD
* Copyright (c) 2000, 2017 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
+=======
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+>>>>>>> Bug 473847 - Support DialogCompare for pure E4 applications
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
@@ -10,6 +16,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stefan Dirix (sdirix@eclipsesource.com) - Bug 473847: Minimum E4 Compatibility of Compare
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -60,6 +67,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SafeRunner;
@@ -69,6 +77,7 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -77,9 +86,13 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IActionBars;
@@ -88,6 +101,7 @@ import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -911,4 +925,64 @@ public class Utilities {
}
return buffer.toString();
}
+
+ /**
+ * Executes the given runnable. Uses the {@link org.eclipse.ui.progress.IProgressService IProgressService}
+ * if available.
+ *
+ * @param runnable
+ * The {@link IRunnableWithProgress} to execute.
+ * @throws InvocationTargetException
+ * @throws InterruptedException
+ */
+ public static void executeRunnable(IRunnableWithProgress runnable) throws InvocationTargetException,
+ InterruptedException {
+ executeRunnable(runnable, true, true);
+ }
+
+ /**
+ * Executes the given runnable. Uses the {@link org.eclipse.ui.progress.IProgressService IProgressService}
+ * if available.
+ *
+ * @param runnable
+ * The {@link IRunnableWithProgress} to execute.
+ * @param fork indicates whether to run within a separate thread.
+ * @param cancelable indicates whether the operation shall be cancelable
+ * @throws InvocationTargetException
+ * @throws InterruptedException
+ */
+ public static void executeRunnable(IRunnableWithProgress runnable, boolean fork, boolean cancelable) throws InvocationTargetException,
+ InterruptedException {
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable);
+ } else {
+ runnable.run(new NullProgressMonitor());
+ }
+ }
+
+ /**
+ * Sets the menu image for the given {@link Item}. Uses the workbench shared image if available, otherwise
+ * creates a new image and adds a dispose listener.
+ *
+ * @param item
+ * The {@link Item} for which the menu image is to be set.
+ */
+ public static void setMenuImage(final Item item) {
+ final Image image;
+ if (PlatformUI.isWorkbenchRunning()) {
+ image = PlatformUI.getWorkbench().getSharedImages().getImage(
+ /* IWorkbenchGraphicConstants */"IMG_LCL_VIEW_MENU"); //$NON-NLS-1$
+ } else {
+ image = CompareUIPlugin.getImageDescriptor("elcl16/view_menu.png").createImage(); //$NON-NLS-1$
+ item.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Image img = item.getImage();
+ if ((img != null) && (!img.isDisposed())) {
+ img.dispose();
+ }
+ }
+ });
+ }
+ item.setImage(image);
+ }
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
index e7d47260d..1398708a9 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
@@ -48,8 +48,6 @@ import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
/**
* A document merger manages the differences between two documents
@@ -574,11 +572,10 @@ public class DocumentMerger {
}
monitor.done();
};
- IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
RangeDifference[] e= null;
try {
- progressService.run(true, true, runnable);
+ Utilities.executeRunnable(runnable);
e= (RangeDifference[]) result[0];
} catch (InvocationTargetException ex) {
throw new CoreException(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, CompareMessages.DocumentMerger_3, ex.getTargetException()));
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index 1d1cf7442..9d95f6896 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -181,7 +181,10 @@ public class InputPatchPage extends WizardPage {
shell.addShellListener(fActivationListener);
Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE);
+
+ if(PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE);
+ }
}
/**
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
index 2c0e878b1..7bd7b4dce 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
@@ -88,7 +88,9 @@ public class PatchTargetPage extends WizardPage {
updateWidgetEnablements();
Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE);
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICompareContextIds.PATCH_INPUT_WIZARD_PAGE);
+ }
useWorkspaceAsTarget.addListener(SWT.Selection, event -> {
fShowError = true;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
index b3a969ce8..54797a874 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
@@ -58,7 +58,6 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
@@ -651,9 +650,8 @@ public class PreviewPatchPage2 extends WizardPage {
private int guessFuzzFactor(final WorkspacePatcher patcher) {
final int[] result= new int[] { -1 };
try {
- PlatformUI.getWorkbench().getProgressService().run(true, true,
- monitor -> result[0]= patcher.guessFuzzFactor(monitor)
- );
+ org.eclipse.compare.internal.Utilities
+ .executeRunnable(monitor -> result[0] = patcher.guessFuzzFactor(monitor));
} catch (InvocationTargetException | InterruptedException ex) {
// NeedWork
}
diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/view_menu.png b/bundles/org.eclipse.compare/icons/full/elcl16/view_menu.png
new file mode 100644
index 000000000..d8dc2f8fb
--- /dev/null
+++ b/bundles/org.eclipse.compare/icons/full/elcl16/view_menu.png
Binary files differ
diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/view_menu@2x.png b/bundles/org.eclipse.compare/icons/full/elcl16/view_menu@2x.png
new file mode 100644
index 000000000..0774bdfdf
--- /dev/null
+++ b/bundles/org.eclipse.compare/icons/full/elcl16/view_menu@2x.png
Binary files differ

Back to the top