summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShireesh Anjal <anjalshireesh@gmail.com>2011-06-08 06:10:57 -0700
committerShireesh Anjal <anjalshireesh@gmail.com>2011-06-08 06:10:57 -0700
commitd3f71616616e5036f564c7dcc17f8a0231800099 (patch)
treefcb3df17ead669a59e53ec55018ee30ca644d44e
parentc604f66c85de5fcda8ce36be22b34be06ad34704 (diff)
parent7c69863cac6e72e29265d3bca8429a5f6af1d120 (diff)
Merge pull request #62 from Dhandapani/5e433f883b099bf0b8b7438f1e7661becf9a931f
Bug 2838 - Stop Volume popup by default focused on "Yes" button
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java91
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java70
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/StopVolumeAction.java50
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() {