diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-03-25 16:59:35 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-03-25 16:59:35 +0530 |
| commit | ecac589948a0ecbe904b0b63433b5b72b40a5a8b (patch) | |
| tree | bca286a58aea85ff50fb6f5eb27c3bddfebdabd8 | |
| parent | 4f208ebaa0d1910e635314f4a7261bc31c98ff8f (diff) | |
Modified action class to display dialog boxes using Display.asyncExec
4 files changed, 69 insertions, 38 deletions
diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java index 07804c3e..266db0af 100644 --- a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java @@ -21,6 +21,7 @@ package com.gluster.storage.management.gui.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Display; import com.gluster.storage.management.core.model.EntityGroup; import com.gluster.storage.management.core.model.Volume; @@ -29,12 +30,18 @@ import com.gluster.storage.management.gui.dialogs.CreateVolumeWizard; public class CreateVolumeAction extends AbstractActionDelegate { @Override public void run(IAction action) { - CreateVolumeWizard wizard = new CreateVolumeWizard(); - - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.create(); - dialog.getShell().setSize(500, 550); - dialog.open(); + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + CreateVolumeWizard wizard = new CreateVolumeWizard(); + + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(500, 550); + dialog.open(); + } + }); } @Override diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java index 66a8b232..cc0fbe94 100644 --- a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StartVolumeAction.java @@ -34,23 +34,31 @@ public class StartVolumeAction extends AbstractActionDelegate { private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); @Override - public void run(IAction action) { - if(volume.getStatus() == VOLUME_STATUS.ONLINE) { + public void run(final IAction action) { + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { return; // Volume already online. Don't do anything. } - + VolumesClient client = new VolumesClient(modelManager.getSecurityToken()); - Status status = client.startVolume(volume.getName()); - if (status.isSuccess()) { - new MessageDialog(Display.getCurrent().getActiveShell(), action.getDescription(), null, "Volume [" - + volume.getName() + "] started successfully!", MessageDialog.INFORMATION, new String[] { "OK" }, 0) - .open(); - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE); - } else { - new MessageDialog(Display.getCurrent().getActiveShell(), action.getDescription(), null, "Volume [" - + volume.getName() + "] could not be started! Error: [" + status + "]", MessageDialog.ERROR, - new String[] { "OK" }, 0).open(); - } + final Status status = client.startVolume(volume.getName()); + final String actionDesc = action.getDescription(); + final Display display = Display.getDefault(); + display.asyncExec(new Runnable() { + + @Override + public void run() { + if (status.isSuccess()) { + new MessageDialog(display.getActiveShell(), actionDesc, null, "Volume [" + + volume.getName() + "] started successfully!", MessageDialog.INFORMATION, + new String[] { "OK" }, 0).open(); + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE); + } else { + new MessageDialog(display.getActiveShell(), actionDesc, null, "Volume [" + + volume.getName() + "] could not be started! Error: [" + status + "]", + MessageDialog.ERROR, new String[] { "OK" }, 0).open(); + } + } + }); } @Override diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java index 5eff2d5d..a89782f9 100644 --- a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java @@ -40,17 +40,26 @@ public class StopVolumeAction extends AbstractActionDelegate { } VolumesClient client = new VolumesClient(modelManager.getSecurityToken()); - Status status = client.stopVolume(volume.getName()); - if (status.isSuccess()) { - new MessageDialog(Display.getCurrent().getActiveShell(), action.getDescription(), null, "Volume [" - + volume.getName() + "] stopped successfully!", MessageDialog.INFORMATION, new String[] { "OK" }, 0) - .open(); - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); - } else { - new MessageDialog(Display.getCurrent().getActiveShell(), action.getDescription(), null, "Volume [" - + volume.getName() + "] could not be stopped! Error: [" + status + "]", MessageDialog.ERROR, - new String[] { "OK" }, 0).open(); - } + final Status status = client.stopVolume(volume.getName()); + final String actionDesc = action.getDescription(); + final Display display = Display.getDefault(); + + display.asyncExec(new Runnable() { + + @Override + public void run() { + if (status.isSuccess()) { + new MessageDialog(Display.getCurrent().getActiveShell(), actionDesc, null, "Volume [" + + volume.getName() + "] stopped successfully!", MessageDialog.INFORMATION, new String[] { "OK" }, 0) + .open(); + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); + } else { + new MessageDialog(Display.getCurrent().getActiveShell(), actionDesc, null, "Volume [" + + volume.getName() + "] could not be stopped! Error: [" + status + "]", MessageDialog.ERROR, + new String[] { "OK" }, 0).open(); + } + } + }); } @Override diff --git a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java index a4e0b715..d919fd84 100644 --- a/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java +++ b/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java @@ -37,6 +37,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; @@ -196,14 +197,20 @@ public class CreateVolumePage1 extends WizardPage { linkCustomize.setText("All Disk(s) (<a>customize</a>)"); linkCustomize.addListener (SWT.Selection, new Listener () { public void handleEvent(Event event) { - SelectDisksDialog dialog = new SelectDisksDialog(getShell(), allDisks, volume.getDisks()); + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + SelectDisksDialog dialog = new SelectDisksDialog(getShell(), allDisks, volume.getDisks()); - dialog.create(); - if(dialog.open() == Window.OK) { - // user has customized disks. get them from the dialog box. - volume.setDisks(dialog.getSelectedDisks()); - linkCustomize.setText("" + volume.getDisks().size() + " Disk(s) (<a>customize</a>)"); - } + dialog.create(); + if(dialog.open() == Window.OK) { + // user has customized disks. get them from the dialog box. + volume.setDisks(dialog.getSelectedDisks()); + linkCustomize.setText("" + volume.getDisks().size() + " Disk(s) (<a>customize</a>)"); + } + } + }); } }); |
