summaryrefslogtreecommitdiffstats
path: root/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-11-25 20:13:35 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-11-25 20:13:35 +0530
commit1142b0e41de39010de7845cf70d71dbb001fc1dc (patch)
tree3513487f65c1a7df47996bd2852393aceaac1b8a /src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java
parent92c52d8edf285945d31e446503fc742fde9dcc49 (diff)
Renamed projects / packages com.gluster.* to org.gluster.*
Diffstat (limited to 'src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java')
-rw-r--r--src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java
new file mode 100644
index 00000000..da40f1d9
--- /dev/null
+++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java
@@ -0,0 +1,96 @@
+/**
+ * AddDiskWizard.java
+ *
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+package org.gluster.storage.management.console.dialogs;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.Wizard;
+import org.gluster.storage.management.client.VolumesClient;
+import org.gluster.storage.management.console.GlusterDataModelManager;
+import org.gluster.storage.management.core.model.Brick;
+import org.gluster.storage.management.core.model.Volume;
+import org.gluster.storage.management.core.utils.StringUtil;
+
+
+/**
+ *
+ */
+public class AddBrickWizard extends Wizard {
+ private AddBrickPage page;
+ private Volume volume;
+
+ public AddBrickWizard(Volume volume) {
+ setWindowTitle("Gluster Management Console - Add Brick");
+ setHelpAvailable(false); // TODO: Introduce wizard help
+ this.volume = volume;
+ }
+
+ public void addPages() {
+ page = new AddBrickPage(volume);
+ addPage(page);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ Set<Brick> bricks = page.getChosenBricks(volume.getName());
+ VolumesClient volumeClient = new VolumesClient();
+ try {
+ Set<String> brickList = getBrickList(bricks);
+
+ volumeClient.addBricks(volume.getName(), brickList);
+
+ // Update model with new bricks in the volume
+ GlusterDataModelManager.getInstance().addBricks(volume, bricks);
+
+ MessageDialog.openInformation(getShell(), "Add brick(s) to Volume", "Volume [" + volume.getName()
+ + "] is expanded with bricks [" + StringUtil.collectionToString(brickList, ", ") + "]");
+ return true;
+ } catch (Exception e) {
+ MessageDialog.openError(getShell(), "Add brick(s) to Volume", e.getMessage());
+ return false;
+ }
+ }
+
+ private Set<String> getBrickList(Set<Brick> bricks) {
+ Set<String> brickList = new HashSet<String>();
+ for(Brick brick : bricks) {
+ brickList.add(brick.getServerName() + ":" + brick.getBrickDirectory());
+ }
+ return brickList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
+ @Override
+ public boolean canFinish() {
+ return super.canFinish() && page.isPageComplete();
+ }
+}