diff options
| author | Dhandapani <dhandapani@gluster.com> | 2011-06-08 15:03:40 +0530 |
|---|---|---|
| committer | Dhandapani <dhandapani@gluster.com> | 2011-06-08 15:03:40 +0530 |
| commit | 118d65438f21d13b6621d11559b4e53e45bab9c5 (patch) | |
| tree | c44d4a90209e0b56f6c11be52ada9c697d2b399c /src | |
| parent | 24136b4fa5f06e8e0f800838fcfcd90fcd7d58b6 (diff) | |
| parent | 7c69863cac6e72e29265d3bca8429a5f6af1d120 (diff) | |
Merge branch 'fixes'
Diffstat (limited to 'src')
3 files changed, 121 insertions, 90 deletions
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java index 41ebbca7..9222c6c7 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java @@ -21,6 +21,7 @@ package com.gluster.storage.management.gui.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Display; import com.gluster.storage.management.client.GlusterDataModelManager; import com.gluster.storage.management.client.VolumesClient; @@ -35,53 +36,61 @@ public class DeleteVolumeAction extends AbstractActionDelegate { private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); @Override - protected void performAction(IAction action) { - final String actionDesc = action.getDescription(); + protected void performAction(final IAction action) { - String warningMessage; - if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { - warningMessage = "Are you sure to delete the Volume[" + volume.getName() + "] ?"; - } else { - warningMessage = "Volume [" + volume.getName() + "] is online, \nAre you sure to continue?"; - } + Display.getDefault().asyncExec(new Runnable() { - Integer deleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel", - "Delete volume and data", "Delete volume, keep data" }, 2).open(); - if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) - return; - } + @Override + public void run() { - VolumesClient client = new VolumesClient(); + final String actionDesc = action.getDescription(); - Status status; - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { // To stop the volume service, if running - status = client.stopVolume(volume.getName()); - if (!status.isSuccess()) { - showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be stopped! Error: [" + status - + "]"); - return; - } - } - - boolean confirmDelete = false; - if (deleteOption == 1) { - confirmDelete = true; - } + String warningMessage; + if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { + warningMessage = "Are you sure to delete the Volume[" + volume.getName() + "] ?"; + } else { + warningMessage = "Volume [" + volume.getName() + "] is online, \nAre you sure to continue?"; + } - status = client.deleteVolume(volume, confirmDelete); - if (status.isSuccess()) { - showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] deleted successfully!"); - modelManager.deleteVolume(volume); - } else { - if (status.isPartSuccess()) { - showWarningDialog(actionDesc, "Volume deleted, but following error(s) occured: " + status); - modelManager.deleteVolume(volume); - } else { - showErrorDialog(actionDesc, - "Volume [" + volume.getName() + "] could not be deleted! Error: [" + status + "]"); + Integer deleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel", + "Delete volume and data", "Delete volume, keep data" }, -1).open(); + if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) + return; + } + + VolumesClient client = new VolumesClient(); + + Status status; + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { // To stop the volume service, if running + status = client.stopVolume(volume.getName()); + if (!status.isSuccess()) { + showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be stopped! Error: [" + + status + "]"); + return; + } + } + + boolean confirmDelete = false; + if (deleteOption == 1) { + confirmDelete = true; + } + + status = client.deleteVolume(volume, confirmDelete); + if (status.isSuccess()) { + showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] deleted successfully!"); + modelManager.deleteVolume(volume); + } else { + if (status.isPartSuccess()) { + showWarningDialog(actionDesc, "Volume deleted, but following error(s) occured: " + status); + modelManager.deleteVolume(volume); + } else { + showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be deleted! Error: [" + + status + "]"); + } + } } - } + }); } @Override diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java index 8c5d8405..ffe2469d 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java @@ -30,39 +30,49 @@ public class RemoveDiskAction extends AbstractActionDelegate { boolean confirmDelete = false; @Override - protected void performAction(IAction action) { - final String actionDesc = action.getDescription(); - List<String> brickList = getBrickList(bricks); - Integer deleteOption = new MessageDialog(getShell(), "Remove Bricks(s)", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME), "Are you sure you want to remove following bricks from volume [" + volume.getName() - + "] ? \n" + StringUtil.ListToString(brickList, ", "), MessageDialog.QUESTION, new String[] { "Cancel", - "Remove bricks, delete data", "Remove bricks, keep data" }, 2).open(); - if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) - return; - } + protected void performAction(final IAction action) { + Display.getDefault().asyncExec(new Runnable() { - if (deleteOption == 1) { - confirmDelete = true; - } - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override public void run() { - VolumesClient client = new VolumesClient(); - Status status = client.removeBricks(volume.getName(), bricks, confirmDelete); - - if (status.isSuccess()) { - - // Remove the bricks from the volume object - for (Brick brick : bricks) { - volume.removeBrick(brick); - } - // Update model with removed bricks in the volume - modelManager.removeBricks(volume, bricks); - - showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] bricks(s) removed successfully!"); - } else { - showErrorDialog(actionDesc, "Volume [" + volume.getName() - + "] bricks(s) could not be removed! Error: [" + status + "]"); + + final String actionDesc = action.getDescription(); + List<String> brickList = getBrickList(bricks); + Integer deleteOption = new MessageDialog(getShell(), "Remove Bricks(s)", GUIHelper.getInstance() + .getImage(IImageKeys.VOLUME), "Are you sure you want to remove following bricks from volume [" + + volume.getName() + "] ? \n" + StringUtil.ListToString(brickList, ", "), + MessageDialog.QUESTION, new String[] { "Cancel", "Remove bricks, delete data", + "Remove bricks, keep data" }, -1).open(); + if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) + return; + } + + if (deleteOption == 1) { + confirmDelete = true; } + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + public void run() { + VolumesClient client = new VolumesClient(); + Status status = client.removeBricks(volume.getName(), bricks, confirmDelete); + + if (status.isSuccess()) { + + // Remove the bricks from the volume object + for (Brick brick : bricks) { + volume.removeBrick(brick); + } + // Update model with removed bricks in the volume + modelManager.removeBricks(volume, bricks); + + showInfoDialog(actionDesc, "Volume [" + volume.getName() + + "] bricks(s) removed successfully!"); + } else { + showErrorDialog(actionDesc, "Volume [" + volume.getName() + + "] bricks(s) could not be removed! Error: [" + status + "]"); + } + } + }); + } }); diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java index 33d12ce3..68623aaf 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java @@ -19,40 +19,52 @@ package com.gluster.storage.management.gui.actions; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Display; import com.gluster.storage.management.client.GlusterDataModelManager; import com.gluster.storage.management.client.VolumesClient; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import com.gluster.storage.management.gui.IImageKeys; +import com.gluster.storage.management.gui.utils.GUIHelper; public class StopVolumeAction extends AbstractActionDelegate { private Volume volume; private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); @Override - protected void performAction(IAction action) { - final String actionDesc = action.getDescription(); - if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { - showWarningDialog(actionDesc, "Volume [" + volume.getName() + "] is already offline!"); - return; // Volume already offline. Don't do anything. - } + protected void performAction(final IAction action) { + Display.getDefault().asyncExec(new Runnable() { - boolean confirmed = showConfirmDialog(actionDesc, - "Are you sure you want to stop the volume [" + volume.getName() + "] ?"); - if (!confirmed) { - return; - } + @Override + public void run() { + final String actionDesc = action.getDescription(); + if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { + showWarningDialog(actionDesc, "Volume [" + volume.getName() + "] is already offline!"); + return; // Volume already offline. Don't do anything. + } - final Status status = stopVolume(); - if (status.isSuccess()) { - showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] stopped successfully!"); - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); - } else { - showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be stopped! Error: [" + status - + "]"); - } + Integer deleteOption = new MessageDialog(getShell(), "Stop Volume", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME), "Are you sure you want to stop the volume [" + volume.getName() + "] ?", + MessageDialog.QUESTION, new String[] { "No", "Yes" }, -1).open(); + + if (deleteOption <= 0) { + return; + } + + final Status status = stopVolume(); + if (status.isSuccess()) { + showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] stopped successfully!"); + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); + } else { + showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be stopped! Error: [" + + status + "]"); + } + } + }); } private Status stopVolume() { |
