From 65512b3154161a233cee773c6ddda56201ade3ca Mon Sep 17 00:00:00 2001
From: Brian Vosburgh
Date: Wed, 10 Apr 2013 14:41:39 -0400
Subject: clean up some of the common.ui utilities
---
.../org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF | 1 +
.../jpt/common/ui/gen/AbstractJptGenerateJob.java | 14 +-
.../jpt/common/ui/internal/WorkbenchPageTools.java | 2 +-
.../jpt/common/ui/internal/WorkbenchTools.java | 277 ++++++++++-
.../common/ui/internal/WorkbenchWindowTools.java | 2 +-
...AbstractItemStructuredStateProviderManager.java | 4 +-
.../SWTCollectionChangeListenerWrapper.java | 8 +-
.../listeners/SWTListChangeListenerWrapper.java | 8 +-
.../SWTPropertyChangeListenerWrapper.java | 8 +-
.../listeners/SWTStateChangeListenerWrapper.java | 8 +-
.../internal/swt/bind/BooleanStateController.java | 4 +-
.../common/ui/internal/swt/widgets/ComboTools.java | 109 +++++
.../ui/internal/swt/widgets/ControlTools.java | 173 +++++++
.../ui/internal/swt/widgets/DisplayTools.java | 257 ++++++++++
.../common/ui/internal/swt/widgets/TableTools.java | 41 ++
.../common/ui/internal/util/ControlSwitcher.java | 3 +-
.../jpt/common/ui/internal/util/SWTUtil.java | 527 ---------------------
.../internal/utility/AbstractUiCommandContext.java | 4 +-
.../utility/AsynchronousUiCommandContext.java | 6 +-
.../utility/SynchronousUiCommandContext.java | 4 +-
.../ui/internal/widgets/AddRemoveListPane.java | 4 +-
.../common/ui/internal/widgets/AddRemovePane.java | 6 +-
.../ui/internal/widgets/ClassChooserPane.java | 39 +-
.../jpt/common/ui/internal/widgets/ComboPane.java | 4 +-
.../jpt/common/ui/internal/widgets/Dialog.java | 13 -
.../common/ui/internal/widgets/IntegerCombo.java | 4 +-
.../jpt/common/ui/internal/widgets/Pane.java | 37 +-
.../ui/internal/wizards/JavaProjectWizardPage.java | 6 +-
28 files changed, 938 insertions(+), 635 deletions(-)
create mode 100644 common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/ComboTools.java
create mode 100644 common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/ControlTools.java
create mode 100644 common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/DisplayTools.java
create mode 100644 common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/TableTools.java
delete mode 100644 common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
(limited to 'common/plugins/org.eclipse.jpt.common.ui')
diff --git a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
index 6576ee52eb..fae37a260e 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
@@ -11,6 +11,7 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
org.eclipse.draw2d;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.help;bundle-version="[3.6.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.7.0,4.0.0)",
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/gen/AbstractJptGenerateJob.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/gen/AbstractJptGenerateJob.java
index 81c3d97e14..f8f346fe0c 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/gen/AbstractJptGenerateJob.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/gen/AbstractJptGenerateJob.java
@@ -25,13 +25,13 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jpt.common.core.gen.JptGenerator;
import org.eclipse.jpt.common.core.gen.LaunchConfigListener;
import org.eclipse.jpt.common.ui.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.WorkbenchTools;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.DisplayTools;
import org.eclipse.jpt.common.utility.internal.reference.SynchronizedBoolean;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
/**
@@ -110,11 +110,13 @@ public abstract class AbstractJptGenerateJob extends WorkspaceJob {
protected void openEditor(final IFile file) {
if(file != null) {
- SWTUtil.asyncExec(new Runnable() {
+ DisplayTools.asyncExec(new Runnable() {
public void run() {
try {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IDE.openEditor(page, file, true);
+ IWorkbenchPage page = WorkbenchTools.getActivePage();
+ if (page != null) {
+ IDE.openEditor(page, file, true);
+ }
}
catch (PartInitException e) {
AbstractJptGenerateJob.this.logException(e);
@@ -161,7 +163,7 @@ public abstract class AbstractJptGenerateJob extends WorkspaceJob {
}
private void displayError(final String message) {
- SWTUtil.syncExec(new Runnable() {
+ DisplayTools.syncExec(new Runnable() {
public void run() {
MessageDialog.openError(
AbstractJptGenerateJob.this.getShell(),
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchPageTools.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchPageTools.java
index 45be569f70..6b05a5274a 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchPageTools.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchPageTools.java
@@ -16,7 +16,7 @@ import org.eclipse.ui.IWorkbenchPage;
/**
* {@link IWorkbenchPage} utility methods.
*/
-public class WorkbenchPageTools {
+public final class WorkbenchPageTools {
/**
* Close all the views in the specified workbench page with the
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchTools.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchTools.java
index 55ebb29d97..d0a1d4533c 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchTools.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchTools.java
@@ -9,14 +9,254 @@
******************************************************************************/
package org.eclipse.jpt.common.ui.internal;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.help.IContext;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
/**
* {@link IWorkbench} utility methods.
*/
-public class WorkbenchTools {
+public final class WorkbenchTools {
+
+ // ********** workbench UI **********
+
+ /**
+ * Return the Eclipse UI {@link IWorkbench workbench}
+ * {@link Display display}.
+ * Return null
if the workbench is not running.
+ * @see #getWorkbench()
+ * @see IWorkbench#getDisplay()
+ */
+ public static Display getDisplay() {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : wb.getDisplay();
+ }
+
+ /**
+ * Return the currently active workbench window's shell.
+ * Return null
if called from a non-UI thread.
+ * @see #getActiveWindow()
+ * @see #getWorkbench()
+ * @see IWorkbench#getActiveWorkbenchWindow()
+ */
+ public static Shell getActiveShell() {
+ IWorkbenchWindow ww = getActiveWindow();
+ return (ww == null) ? null : ww.getShell();
+ }
+
+ /**
+ * Return the currently active workbench window's shell.
+ * Return null
if called from a non-UI thread.
+ * @see #getActiveWindow()
+ * @see #getWorkbench()
+ * @see IWorkbenchWindow#getActivePage()
+ * @see IWorkbench#getActiveWorkbenchWindow()
+ */
+ public static IWorkbenchPage getActivePage() {
+ IWorkbenchWindow ww = getActiveWindow();
+ return (ww == null) ? null : ww.getActivePage();
+ }
+
+ /**
+ * Return the currently active workbench window's shell.
+ * Return null
if called from a non-UI thread.
+ * @see #getWorkbench()
+ * @see IWorkbench#getActiveWorkbenchWindow()
+ */
+ public static IWorkbenchWindow getActiveWindow() {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : wb.getActiveWorkbenchWindow();
+ }
+
+ /**
+ * Return the Eclipse UI {@link IWorkbench workbench}.
+ * Return null
if the workbench is not running
+ * (i.e. either it has not been started or it has been terminated).
+ *
+ * NB: There is no guarantee the workbench will continue
+ * running after it is returned.
+ * @see PlatformUI#isWorkbenchRunning()
+ */
+ public static IWorkbench getWorkbench() {
+ return PlatformUI.isWorkbenchRunning() ? PlatformUI.getWorkbench() : null;
+ }
+
+
+ // ********** editors **********
+
+ /**
+ * Return the workbench's default editor for the specified file, as
+ * determined by the file's name and content.
+ * @see #getDefaultEditor(String, IContentType)
+ */
+ public static IEditorDescriptor getDefaultEditor(IFile file) {
+ return getDefaultEditor(file.getName(), IDE.getContentType(file));
+ }
+
+ /**
+ * Return the workbench's default editor for the specified file name and
+ * content type.
+ * @see #getWorkbench()
+ * @see IWorkbench#getEditorRegistry()
+ * @see org.eclipse.ui.IEditorRegistry#getDefaultEditor(String, IContentType)
+ */
+ public static IEditorDescriptor getDefaultEditor(String fileName, IContentType contentType) {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : wb.getEditorRegistry().getDefaultEditor(fileName, contentType);
+ }
+
+
+ // ********** shared images **********
+
+ /**
+ * Return the specified image from the Eclipse UI {@link IWorkbench
+ * workbench}'s image registry.
+ * Return null
if the workbench is not running.
+ *
+ * NB: The returned image is managed by the workbench;
+ * clients must not dispose of the returned image.
+ * @see #getWorkbench()
+ * @see IWorkbench#getSharedImages()
+ * @see org.eclipse.ui.ISharedImages
+ */
+ public static Image getSharedImage(String symbolicName) {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : wb.getSharedImages().getImage(symbolicName);
+ }
+
+ /**
+ * Return the specified image descriptor from the Eclipse UI
+ * {@link IWorkbench workbench}'s image registry.
+ * Return null
if the workbench is not running.
+ * @see #getWorkbench()
+ * @see IWorkbench#getSharedImages()
+ * @see org.eclipse.ui.ISharedImages
+ */
+ public static ImageDescriptor getSharedImageDescriptor(String symbolicName) {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : wb.getSharedImages().getImageDescriptor(symbolicName);
+ }
+
+
+ // ********** help **********
+
+ /**
+ * Set the specified help context ID on the specified control.
+ * @see #getWorkbench()
+ * @see IWorkbench#getHelpSystem()
+ * @see org.eclipse.ui.help.IWorkbenchHelpSystem#setHelp(Control, String)
+ */
+ public static void setHelp(Control control, String contextID) {
+ IWorkbench wb = getWorkbench();
+ if (wb != null) {
+ wb.getHelpSystem().setHelp(control, contextID);
+ }
+ }
+
+ /**
+ * Set the specified help context ID on the specified action.
+ * @see #getWorkbench()
+ * @see IWorkbench#getHelpSystem()
+ * @see org.eclipse.ui.help.IWorkbenchHelpSystem#setHelp(IAction, String)
+ */
+ public static void setHelp(IAction action, String contextID) {
+ IWorkbench wb = getWorkbench();
+ if (wb != null) {
+ wb.getHelpSystem().setHelp(action, contextID);
+ }
+ }
+
+ /**
+ * Set the specified help context ID on the specified menu.
+ * @see #getWorkbench()
+ * @see IWorkbench#getHelpSystem()
+ * @see org.eclipse.ui.help.IWorkbenchHelpSystem#setHelp(Menu, String)
+ */
+ public static void setHelp(Menu menu, String contextID) {
+ IWorkbench wb = getWorkbench();
+ if (wb != null) {
+ wb.getHelpSystem().setHelp(menu, contextID);
+ }
+ }
+
+ /**
+ * Set the specified help context ID on the specified control.
+ * @see #getWorkbench()
+ * @see IWorkbench#getHelpSystem()
+ * @see org.eclipse.ui.help.IWorkbenchHelpSystem#setHelp(MenuItem, String)
+ */
+ public static void setHelp(MenuItem item, String contextID) {
+ IWorkbench wb = getWorkbench();
+ if (wb != null) {
+ wb.getHelpSystem().setHelp(item, contextID);
+ }
+ }
+
+ /**
+ * Display the entire help bookshelf.
+ *
+ * NB: Must be called from the UI thread. + *
+ * @see #getWorkbench() + * @see IWorkbench#getHelpSystem() + * @see org.eclipse.ui.help.IWorkbenchHelpSystem#displayHelp() + */ + public static void displayHelp() { + IWorkbench wb = getWorkbench(); + if (wb != null) { + wb.getHelpSystem().displayHelp(); + } + } + + /** + * Display help for the specified context. + *
+ * NB: Must be called from the UI thread. + *
+ * @see #getWorkbench() + * @see IWorkbench#getHelpSystem() + * @see org.eclipse.ui.help.IWorkbenchHelpSystem#displayHelp(IContext) + */ + public static void displayHelp(IContext context) { + IWorkbench wb = getWorkbench(); + if (wb != null) { + wb.getHelpSystem().displayHelp(context); + } + } + + /** + * Display help for the specified context ID. + *
+ * NB: Must be called from the UI thread. + *
+ * @see #getWorkbench()
+ * @see IWorkbench#getHelpSystem()
+ * @see org.eclipse.ui.help.IWorkbenchHelpSystem#displayHelp(String)
+ */
+ public static void displayHelp(String contextID) {
+ IWorkbench wb = getWorkbench();
+ if (wb != null) {
+ wb.getHelpSystem().displayHelp(contextID);
+ }
+ }
+
+
+ // ********** close views **********
/**
* Close all the views in the platform workbench with the specified ID.
@@ -24,7 +264,10 @@ public class WorkbenchTools {
* @see org.eclipse.ui.IWorkbenchPartSite#getId()
*/
public static void closeAllViews(String viewID) {
- closeAllViews(PlatformUI.getWorkbench(), viewID);
+ IWorkbench wb = getWorkbench();
+ if (wb != null) {
+ closeAllViews(wb, viewID);
+ }
}
/**
@@ -38,7 +281,35 @@ public class WorkbenchTools {
}
- // ********** constructor **********
+ // ********** adapters **********
+
+ /**
+ * Adapt the Eclipse UI {@link IWorkbench workbench} to the specified class.
+ * Return
+ * NB: The runnable will not be executed if the workbench
+ * is not running (i.e. the runnable is treated as ephemeral, and not
+ * executing it, probably during workbench shutdown, is not a problem because
+ * it is UI-related and the UI is gone).
+ * @see OpenStrategy#getPostSelectionDelay()
+ * @see #timerExec(int, Runnable)
+ */
+ public static void delayedExec(Runnable runnable) {
+ timerExec(OpenStrategy.getPostSelectionDelay(), runnable);
+ }
+
+ /**
+ * NB: The runnable will not be executed if the workbench
+ * is not running (i.e. the runnable is treated as ephemeral, and not
+ * executing it, probably during workbench shutdown, is not a problem because
+ * it is UI-related and the UI is gone).
+ * @see Display#timerExec(int, Runnable)
+ * @see #asyncExec(Runnable)
+ * @see #syncExec(Runnable)
+ * @see #execute(Runnable)
+ */
+ public static void timerExec(int milliseconds, Runnable runnable) {
+ Display display = getDisplay();
+ if (display != null) {
+ display.timerExec(milliseconds, runnable);
+ }
+ }
+
+ /**
+ * Execute the specified runnable if the current thread is the UI thread;
+ * otherwise asynchrounously dispatch the runnable to the UI thread,
+ * returning immediately. This is useful for event handlers when it is not
+ * obvious whether the events are fired on the UI thread.
+ *
+ * NB: The runnable will not be executed if the workbench
+ * is not running (i.e. the runnable is treated as ephemeral, and not
+ * executing it, probably during workbench shutdown, is not a problem because
+ * it is UI-related and the UI is gone).
+ * @see Display#asyncExec(Runnable)
+ * @see #asyncExec(Runnable)
+ * @see #syncExec(Runnable)
+ * @see #timerExec(int, Runnable)
+ * @see IWorkbench#getDisplay()
+ */
+ public static void execute(Runnable runnable) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ // the current thread is the UI thread
+ runnable.run();
+ } else {
+ display = WorkbenchTools.getDisplay();
+ if (display != null) {
+ display.asyncExec(runnable);
+ }
+ }
+ }
+
+ /**
+ * Execute the specified runnable if the current thread is the specified
+ * viewer's thread;
+ * otherwise asynchrounously dispatch the runnable to the viewer's thread,
+ * returning immediately. This is useful for event handlers when it is not
+ * obviously whether the events are fired on the viewer's thread.
+ * @see #execute(Runnable)
+ * @see Display#asyncExec(Runnable)
+ * @see #asyncExec(Runnable)
+ * @see #syncExec(Runnable)
+ * @see #timerExec(int, Runnable)
+ */
+ public static void execute(Viewer viewer, Runnable runnable) {
+ execute(viewer.getControl(), runnable);
+ }
+
+ /**
+ * Execute the specified runnable if the current thread is the specified
+ * control's thread;
+ * otherwise asynchrounously dispatch the runnable to the control's thread,
+ * returning immediately. This is useful for event handlers when it is not
+ * obviously whether the events are fired on the control's thread.
+ * @see #execute(Runnable)
+ * @see Display#asyncExec(Runnable)
+ * @see #asyncExec(Runnable)
+ * @see #syncExec(Runnable)
+ * @see #timerExec(int, Runnable)
+ */
+ public static void execute(Control control, Runnable runnable) {
+ execute(control.getDisplay(), runnable);
+ }
+
+ /**
+ * Execute the specified runnable if the current thread is the specified
+ * display's thread;
+ * otherwise asynchrounously dispatch the runnable to the display's thread,
+ * returning immediately. This is useful for event handlers when it is not
+ * obviously whether the events are fired on the display's thread.
+ * @see #execute(Runnable)
+ * @see Display#asyncExec(Runnable)
+ * @see #asyncExec(Runnable)
+ * @see #syncExec(Runnable)
+ * @see #timerExec(int, Runnable)
+ */
+ public static void execute(Display display, Runnable runnable) {
+ if (display.getThread() == Thread.currentThread()) {
+ // the current thread is the the UI thread
+ runnable.run();
+ } else {
+ display.asyncExec(runnable);
+ }
+ }
+
+ /**
+ * Return the current shell. Return
- * NB: The runnable will not be executed if the workbench
- * is not running (i.e. the runnable is treated as ephemeral, and not
- * executing it, probably during workbench shutdown, is not a problem because
- * it is UI-related and the UI is gone).
- * @see OpenStrategy#getPostSelectionDelay()
- * @see #timerExec(int, Runnable)
- */
- public static void delayedExec(Runnable runnable) {
- timerExec(OpenStrategy.getPostSelectionDelay(), runnable);
- }
-
- /**
- * NB: The runnable will not be executed if the workbench
- * is not running (i.e. the runnable is treated as ephemeral, and not
- * executing it, probably during workbench shutdown, is not a problem because
- * it is UI-related and the UI is gone).
- * @see Display#timerExec(int, Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #execute(Runnable)
- */
- public static void timerExec(int milliseconds, Runnable runnable) {
- Display display = getDisplay();
- if (display != null) {
- display.timerExec(milliseconds, runnable);
- }
- }
-
- /**
- * Execute the specified runnable if the current thread is the UI thread;
- * otherwise asynchrounously dispatch the runnable to the UI thread,
- * returning immediately. This is useful for event handlers when it is not
- * obvious whether the events are fired on the UI thread.
- *
- * NB: The runnable will not be executed if the workbench
- * is not running (i.e. the runnable is treated as ephemeral, and not
- * executing it, probably during workbench shutdown, is not a problem because
- * it is UI-related and the UI is gone).
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- * @see IWorkbench#getDisplay()
- */
- public static void execute(Runnable runnable) {
- Display display = Display.getCurrent();
- if (display != null) {
- // the current thread is the UI thread
- runnable.run();
- } else {
- display = getWorkbenchDisplay();
- if (display != null) {
- display.asyncExec(runnable);
- }
- }
- }
-
- /**
- * Execute the specified runnable if the current thread is the specified
- * viewer's thread;
- * otherwise asynchrounously dispatch the runnable to the viewer's thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the viewer's thread.
- * @see #execute(Runnable)
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Viewer viewer, Runnable runnable) {
- execute(viewer.getControl(), runnable);
- }
-
- /**
- * Execute the specified runnable if the current thread is the specified
- * control's thread;
- * otherwise asynchrounously dispatch the runnable to the control's thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the control's thread.
- * @see #execute(Runnable)
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Control control, Runnable runnable) {
- execute(control.getDisplay(), runnable);
- }
-
- /**
- * Execute the specified runnable if the current thread is the specified
- * display's thread;
- * otherwise asynchrounously dispatch the runnable to the display's thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the display's thread.
- * @see #execute(Runnable)
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Display display, Runnable runnable) {
- if (display.getThread() == Thread.currentThread()) {
- // the current thread is the the UI thread
- runnable.run();
- } else {
- display.asyncExec(runnable);
- }
- }
-
- /**
- * Return the current shell. Return
- * NB: There is no guarantee the workbench will continue
- * running after it is returned.
- * @see PlatformUI#isWorkbenchRunning()
- */
- public static IWorkbench getWorkbench() {
- return PlatformUI.isWorkbenchRunning() ? PlatformUI.getWorkbench() : null;
- }
-
- /**
- * Center the specified shell within its display.
- *
- * NB: This will not look too good on a dual monitor system.
- */
- public static void center(Shell shell) {
- shell.setBounds(calculateCenteredBounds(shell.getBounds(), shell.getDisplay().getBounds()));
- }
-
- /**
- * Center the specified shell within the specified parent shell.
- */
- public static void center(Shell shell, Shell parentShell) {
- shell.setBounds(calculateCenteredBounds(shell.getBounds(), parentShell.getBounds()));
- }
-
- /**
- * Calculate the bounds (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(Rectangle rectangle1, Rectangle rectangle2) {
- return calculateCenteredBounds(rectangle1.width, rectangle1.height, rectangle2.x, rectangle2.y, rectangle2.width, rectangle2.height);
- }
-
- /**
- * Calculate the bounds (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(Point size1, Point size2) {
- return calculateCenteredBounds(size1.x, size1.y, size2.x, size2.y);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(int width1, int height1, int width2, int height2) {
- return calculateCenteredBounds(width1, height1, 0, 0, width2, height2);
- }
-
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(int width1, int height1, int x2, int y2, int width2, int height2) {
- return new Rectangle(x2 + ((width2 - width1) >> 1), y2 + ((height2 - height1) >> 1), width1, height1);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(Rectangle rectangle1, Rectangle rectangle2) {
- return calculateCenteredPosition(rectangle1.width, rectangle1.height, rectangle2.x, rectangle2.y, rectangle2.width, rectangle2.height);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(Point size1, Point size2) {
- return calculateCenteredPosition(size1.x, size1.y, size2.x, size2.y);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(int width1, int height1, int width2, int height2) {
- return calculateCenteredPosition(width1, height1, 0, 0, width2, height2);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(int width1, int height1, int x2, int y2, int width2, int height2) {
- return new Point(x2 + ((width2 - width1) >> 1), y2 + ((height2 - height1) >> 1));
- }
-
- /**
- * Tweaks the given null
if the workbench is not running
+ * (i.e. either it has not been started or it has been terminated).
+ * @see #getWorkbench()
+ * @see PlatformTools#getAdapter(Object, Class)
+ */
+ public static A getAdapter(Class adapterType) {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : PlatformTools.getAdapter(wb, adapterType);
+ }
+
+ /**
+ * Return the workbench service corresponding to the specified API.
+ * Return null
if the workbench is not running
+ * (i.e. either it has not been started or it has been terminated).
+ * @see #getWorkbench()
+ * @see org.eclipse.ui.services.IServiceLocator#getService(Class)
+ */
+ @SuppressWarnings("unchecked")
+ public static A getService(Class api) {
+ IWorkbench wb = getWorkbench();
+ return (wb == null) ? null : (A) wb.getService(api);
+ }
+
+
+ // ********** disabled constructor **********
/**
* Suppress default constructor, ensuring non-instantiability.
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchWindowTools.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchWindowTools.java
index 35763d2303..eb9917c4e0 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchWindowTools.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/WorkbenchWindowTools.java
@@ -15,7 +15,7 @@ import org.eclipse.ui.IWorkbenchWindow;
/**
* {@link IWorkbenchWindow} utility methods.
*/
-public class WorkbenchWindowTools {
+public final class WorkbenchWindowTools {
/**
* Close all the views in the specified workbench window with the
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java
index 1216a703ac..1b61c007a0 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java
@@ -15,7 +15,7 @@ import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.DisplayTools;
import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemStructuredContentProvider;
@@ -232,7 +232,7 @@ public abstract class AbstractItemStructuredStateProviderManagernull
if there is none.
+ * @exception org.eclipse.swt.SWTException if not called from the UI thread
+ */
+ public static Shell getShell() {
+ Shell shell = getActiveShell();
+ return (shell != null) ? shell : WorkbenchTools.getActiveShell();
+ }
+
+ /**
+ * Return the current "active" shell, which can be the shell from any
+ * window. Return null
if there is no display.
+ * @see Display#getActiveShell()
+ * @exception org.eclipse.swt.SWTException if not called from the UI thread
+ */
+ public static Shell getActiveShell() {
+ // Retrieve the active shell, which can be the shell from any window
+ Display display = getDisplay();
+ return (display == null) ? null : display.getActiveShell();
+ }
+
+ /**
+ * Return the most appropriate {@link Display display}; i.e. return the
+ * {@link Display#getCurrent() display associated with the current thread}
+ * if it is present; otherwise return the
+ * {@link IWorkbench#getDisplay() Eclipse workbench
+ * display} (but, explicitly, not the
+ * {@link Display#getDefault() "default display"} -
+ * see the comment at {@link IWorkbench#getDisplay()}).
+ * Return null
if the workbench is not running.
+ */
+ public static Display getDisplay() {
+ Display display = Display.getCurrent();
+ return (display != null) ? display : WorkbenchTools.getDisplay();
+ }
+
+
+ // ********** UI thread **********
+
+ /**
+ * Determines if the current thread is the UI event thread.
+ *
+ * @return true
if it's the UI event thread, false
+ * otherwise
+ */
+ public static boolean uiThread() {
+ return Display.getCurrent() != null;
+ }
+
+ /**
+ * Determines if the current thread is the UI event thread by using the
+ * thread from which the given viewer's display was instantiated.
+ *
+ * @param viewer The viewer used to determine if the current thread
+ * is the UI event thread
+ * @return true
if the current thread is the UI event thread;
+ * false
otherwise
+ */
+ public static boolean uiThread(Viewer viewer) {
+ return uiThread(viewer.getControl());
+ }
+
+ /**
+ * Determines if the current thread is the UI event thread by using the
+ * thread from which the given widget's display was instantiated.
+ *
+ * @param widget The widget used to determine if the current thread
+ * is the UI event thread
+ * @return true
if the current thread is the UI event thread;
+ * false
otherwise
+ */
+ public static boolean uiThread(Widget widget) {
+ return widget.getDisplay().getThread() == Thread.currentThread();
+ }
+
+
+ // ********** disabled constructor **********
+
+ private DisplayTools() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/TableTools.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/TableTools.java
new file mode 100644
index 0000000000..47487ecf36
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/widgets/TableTools.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.ui.internal.swt.widgets;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.widgets.Table;
+
+/**
+ * {@link Table} utility methods.
+ */
+public final class TableTools {
+
+ public static int calculateHeightHint(Table table, int rowCount) {
+ if (table.getFont().equals(JFaceResources.getDefaultFont())) {
+ table.setFont(JFaceResources.getDialogFont());
+ }
+ int hint = table.getHeaderHeight() + (table.getItemHeight() * rowCount);
+ if (table.getLinesVisible()) {
+ hint += table.getGridLineWidth() * (rowCount - 1);
+ }
+ return hint;
+ }
+
+
+ // ********** disabled constructor **********
+
+ /**
+ * Suppress default constructor, ensuring non-instantiability.
+ */
+ private TableTools() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java
index d442601e7d..932f992a54 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.common.ui.internal.util;
import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.ControlTools;
import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
@@ -146,7 +147,7 @@ public final class ControlSwitcher
this.pageBook.showPage(page);
// Revalidate the parents in order to update the layout
- SWTUtil.reflow(this.pageBook);
+ ControlTools.reflow(this.pageBook);
}
@SuppressWarnings("unchecked")
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
deleted file mode 100644
index f792eeb705..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * A suite of utility methods related to the user interface.
- *
- * @version 2.0
- * @since 1.0
- */
-public class SWTUtil {
-
- /**
- * NB: The runnable will not be executed if the workbench
- * is not running (i.e. the runnable is treated as ephemeral, and not
- * executing it, probably during workbench shutdown, is not a problem because
- * it is UI-related and the UI is gone).
- * @see Display#asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- * @see #execute(Runnable)
- */
- public static void asyncExec(Runnable runnable) {
- Display display = getDisplay();
- if (display != null) {
- display.asyncExec(runnable);
- }
- }
-
- /**
- * NB: The runnable will not be executed if the workbench
- * is not running (i.e. the runnable is treated as ephemeral, and not
- * executing it, probably during workbench shutdown, is not a problem because
- * it is UI-related and the UI is gone).
- * @see Display#syncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #timerExec(int, Runnable)
- * @see #execute(Runnable)
- */
- public static void syncExec(Runnable runnable) {
- Display display = getDisplay();
- if (display != null) {
- display.syncExec(runnable);
- }
- }
-
- /**
- * Use the standard delay.
- * null
if there is none.
- * @exception org.eclipse.swt.SWTException if not called from the UI thread
- */
- public static Shell getShell() {
- Shell shell = getActiveShell();
- return (shell != null) ? shell : getActiveWorkbenchShell();
- }
-
- /**
- * Return the current "active" shell, which can be the shell from any
- * window. Return null
if there is no display.
- * @see Display#getActiveShell()
- * @exception org.eclipse.swt.SWTException if not called from the UI thread
- */
- public static Shell getActiveShell() {
- // Retrieve the active shell, which can be the shell from any window
- Display display = getDisplay();
- return (display == null) ? null : display.getActiveShell();
- }
-
- /**
- * Return the currently active workbench window's shell.
- * Return null
if not called from the UI thread.
- * @see IWorkbench#getActiveWorkbenchWindow()
- */
- public static Shell getActiveWorkbenchShell() {
- IWorkbench wb = getWorkbench();
- if (wb == null) {
- return null;
- }
- IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
- return (ww == null) ? null : ww.getShell();
- }
-
- /**
- * Return the most appropriate {@link Display display}; i.e. return the
- * {@link Display#getCurrent() display associated with the current thread}
- * if it is present; otherwise return the
- * {@link IWorkbench#getDisplay() Eclipse workbench
- * display} (but, explicitly, not the
- * {@link Display#getDefault() "default display"} -
- * see the comment at {@link IWorkbench#getDisplay()}).
- * Return null
if the workbench is not running.
- */
- public static Display getDisplay() {
- Display display = Display.getCurrent();
- return (display != null) ? display : getWorkbenchDisplay();
- }
-
- /**
- * Return the Eclipse UI {@link IWorkbench workbench}
- * {@link Display display}.
- * Return null
if the workbench is not running.
- * @see #getWorkbench()
- */
- public static Display getWorkbenchDisplay() {
- IWorkbench wb = getWorkbench();
- return (wb == null) ? null : wb.getDisplay();
- }
-
- /**
- * Return the Eclipse UI {@link IWorkbench workbench}.
- * Return null
if the workbench is not running
- * (i.e. either it has not been started or it has been terminated).
- * Combo
to remove the default value when the
- * widget receives the focus and to show the default when the widget loses
- * the focus.
- *
- * @param combo The widget having a default value that is always at the
- * beginning of the list
- */
- public static void attachDefaultValueHandler(Combo combo) {
- ComboHandler handler = new ComboHandler();
- combo.addFocusListener(handler);
- combo.addModifyListener(handler);
- }
-
-
- public static int getTableHeightHint(Table table, int rows) {
- if (table.getFont().equals(JFaceResources.getDefaultFont()))
- table.setFont(JFaceResources.getDialogFont());
- int result= table.getItemHeight() * rows + table.getHeaderHeight();
- if (table.getLinesVisible())
- result+= table.getGridLineWidth() * (rows - 1);
- return result;
- }
-
- /**
- * Relays out the parents of the Control
. This was taken from
- * the widget Section
.
- *
- * @param pane The pane to revalidate as well as its parents
- */
- public static void reflow(Composite pane) {
-
- for (Composite composite = pane; composite != null; ) {
- composite.setRedraw(false);
- composite = composite.getParent();
-
- if (composite instanceof ScrolledForm || composite instanceof Shell) {
- break;
- }
- }
-
- for (Composite composite = pane; composite != null; ) {
- composite.layout(true);
- composite = composite.getParent();
-
- if (composite instanceof ScrolledForm) {
- ((ScrolledForm) composite).reflow(true);
- break;
- }
- }
-
- for (Composite composite = pane; composite != null; ) {
- composite.setRedraw(true);
- composite = composite.getParent();
-
- if (composite instanceof ScrolledForm || composite instanceof Shell) {
- break;
- }
- }
- }
-
-
- /**
- * Determines if the current thread is the UI event thread.
- *
- * @return true
if it's the UI event thread, false
- * otherwise
- */
- public static boolean uiThread() {
- return Display.getCurrent() != null;
- }
-
- /**
- * Determines if the current thread is the UI event thread by using the
- * thread from which the given viewer's display was instantiated.
- *
- * @param viewer The viewer used to determine if the current thread
- * is the UI event thread
- * @return true
if the current thread is the UI event thread;
- * false
otherwise
- */
- public static boolean uiThread(Viewer viewer) {
- return uiThread(viewer.getControl());
- }
-
- /**
- * Determines if the current thread is the UI event thread by using the
- * thread from which the given widget's display was instantiated.
- *
- * @param widget The widget used to determine if the current thread
- * is the UI event thread
- * @return true
if the current thread is the UI event thread;
- * false
otherwise
- */
- public static boolean uiThread(Widget widget) {
- return widget.getDisplay().getThread() == Thread.currentThread();
- }
-
-
- /**
- * This handler is responsible for removing the default value when the combo
- * has the focus or when the selected item is the default value and to select
- * it when the combo loses the focus.
- */
- private static class ComboHandler implements ModifyListener,
- FocusListener {
-
- public void focusGained(FocusEvent e) {
- Combo combo = (Combo) e.widget;
-
- if (combo.getSelectionIndex() == 0) {
- // The text selection has to be changed outside of the context of this
- // listener otherwise the combo won't update because it's currently
- // notifying its listeners
- asyncExec(new SelectText(combo));
- }
- }
-
- public void focusLost(FocusEvent e) {
- //do nothing
- }
-
- public void modifyText(ModifyEvent e) {
-
- Combo combo = (Combo) e.widget;
-
- if (combo.isFocusControl() &&
- combo.getSelectionIndex() == 0) {
-
- // The text has to be changed outside of the context of this
- // listener otherwise the combo won't update because it's currently
- // notifying its listeners
- asyncExec(new ModifyText(combo));
- }
- }
-
- private class ModifyText implements Runnable {
- private final Combo combo;
-
- public ModifyText(Combo combo) {
- super();
- this.combo = combo;
- }
-
- public void run() {
- if (this.combo.isDisposed()) {
- return;
- }
- String text = this.combo.getText();
-
- if (text.length() == 0) {
- text = this.combo.getItem(0);
- this.combo.setText(text);
- }
-
- this.combo.setSelection(new Point(0, text.length()));
- }
- }
-
- private class SelectText implements Runnable {
- private final Combo combo;
-
- public SelectText(Combo combo) {
- super();
- this.combo = combo;
- }
-
- public void run() {
- if (this.combo.isDisposed()) {
- return;
- }
- String text = this.combo.getText();
- this.combo.setSelection(new Point(0, text.length()));
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandContext.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandContext.java
index c17a1660d4..1ad032683d 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandContext.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandContext.java
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.common.ui.internal.utility;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.DisplayTools;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.common.utility.command.ExtendedCommandContext;
import org.eclipse.jpt.common.utility.internal.command.CommandRunnable;
@@ -48,7 +48,7 @@ abstract class AbstractUiCommandContext
SynchronizingCommand syncCommand = new SynchronizingCommand(command);
// dispatch the sync command to the UI thread...
- SWTUtil.asyncExec(this.buildRunnable(syncCommand));
+ DisplayTools.asyncExec(this.buildRunnable(syncCommand));
// ...and wait for it to execute
try {
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandContext.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandContext.java
index 8b57470fb6..41a1a9ac8f 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandContext.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandContext.java
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.common.ui.internal.utility;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.DisplayTools;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.common.utility.command.ExtendedCommandContext;
@@ -35,10 +35,10 @@ public final class AsynchronousUiCommandContext
}
public void execute(Command command) {
- SWTUtil.asyncExec(this.buildRunnable(command));
+ DisplayTools.asyncExec(this.buildRunnable(command));
}
public void waitToExecute(Command command) {
- SWTUtil.syncExec(this.buildRunnable(command));
+ DisplayTools.syncExec(this.buildRunnable(command));
}
}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandContext.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandContext.java
index d16d2c00ea..5623c937be 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandContext.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandContext.java
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.common.ui.internal.utility;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.DisplayTools;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.common.utility.command.ExtendedCommandContext;
@@ -35,7 +35,7 @@ public final class SynchronousUiCommandContext
}
public void execute(Command command) {
- SWTUtil.syncExec(this.buildRunnable(command));
+ DisplayTools.syncExec(this.buildRunnable(command));
}
public void waitToExecute(Command command) {
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java
index 2182f293e8..cc958bc86a 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java
@@ -15,7 +15,7 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.swt.widgets.DisplayTools;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.common.utility.model.Model;
import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
@@ -261,7 +261,7 @@ public class AddRemoveListPane