diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-07-09 22:44:44 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-07-09 22:44:44 +0530 |
| commit | 8a33f5d206d6a56212aceca40ae59d812910bfac (patch) | |
| tree | 51ea5a7fc3dd3fff529daf43c2c326d4e23e9ddf /src | |
| parent | 7227b580b23d83b133cdce7becf344ef2c4361cc (diff) | |
| parent | 84a4be4537c2ca13b086752084fc756f774e32b4 (diff) | |
Merge branch 'work'
Diffstat (limited to 'src')
| -rw-r--r-- | src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java index b9d57de7..0f8121e6 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java @@ -18,14 +18,18 @@ *******************************************************************************/ package com.gluster.storage.management.gui.actions; +import org.apache.log4j.Logger; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.UIPlugin; import com.gluster.storage.management.core.model.Entity; @@ -38,20 +42,40 @@ import com.gluster.storage.management.core.model.Entity; @SuppressWarnings("restriction") public abstract class AbstractActionDelegate implements IWorkbenchWindowActionDelegate { protected IWorkbenchWindow window; + protected Logger logger = Logger.getLogger(this.getClass()); // the latest selected entity protected Entity selectedEntity; @Override public void run(final IAction action) { - // Real action code must be executed using Display#asyncExec. Otherwise the system can hang when opening new - // dialog boxes on linux platform - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - performAction(action); - } - }); + // Real action code must be executed using Display#asyncExec. + // Otherwise the system can hang when opening new dialog boxes on linux platform + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { + public void run(final IProgressMonitor monitor) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + monitor.beginTask(action.getDescription(), 1); + performAction(action); + monitor.worked(1); + monitor.done(); + } + }); + } + }); + } catch (final Exception e) { + final String actionDesc = action.getDescription(); + logger.error("Exception while running action [" + actionDesc + "]", e); + + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + showErrorDialog(actionDesc, e.getMessage()); + } + }); + } } abstract protected void performAction(final IAction action); |
