diff options
| author | Selvam <selvam@gluster.com> | 2011-04-06 18:05:28 +0530 |
|---|---|---|
| committer | Selvam <selvam@gluster.com> | 2011-04-06 18:05:28 +0530 |
| commit | 46a13fe293c0fca60d9c8b7e4eaffd3eaac1e12f (patch) | |
| tree | cb605ead9b50c3b94e33591d8ca6165435a38dd6 /src/com.gluster.storage.management.gui | |
| parent | 8607a637093bda070f78289c34c529a990967ff4 (diff) | |
| parent | 4c69fc2e2a653d39216505ba583c428fb659d377 (diff) | |
Merge branch 'alerts-review'
Diffstat (limited to 'src/com.gluster.storage.management.gui')
3 files changed, 82 insertions, 36 deletions
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java index fd5972c5..513901bb 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/IImageKeys.java @@ -42,10 +42,16 @@ public interface IImageKeys { public static final String WORK_IN_PROGRESS = "icons/progress-bar.png"; public static final String CHECKBOX_UNCHECKED = "icons/ui-check-box-uncheck.png"; public static final String CHECKBOX_CHECKED = "icons/ui-check-box.png"; + public static final String DISK = "icons/disk.png"; + public static final String DISKS = "icons/disks.png"; public static final String DISK_UNINITIALIZED = "icons/disk-uninitialized.png"; public static final String SEARCH = "icons/search.png"; public static final String ARROW_UP = "icons/arrow-up.png"; public static final String ARROW_DOWN = "icons/arrow-down.png"; + public static final String VOLUME_REBALANCE = "icons/volume-rebalance.png"; + public static final String DISK_MIGRATE = "icons/disk-migrate.png"; + public static final String LOW_DISK_SPACE = "icons/disk.png"; + public static final String DISK_OFFLINE = "icons/status-offline.png"; public static final String OVERLAY_OFFLINE = "icons/status-offline-small.png"; public static final String OVERLAY_ONLINE = "icons/status-online-small.png"; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java index 45b13a19..cc9c0385 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java @@ -42,6 +42,7 @@ import org.eclipse.swt.widgets.Text; import com.gluster.storage.management.client.GlusterDataModelManager; import com.gluster.storage.management.client.UsersClient; import com.gluster.storage.management.client.constants.ClientConstants; +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.ConnectionDetails; import com.gluster.storage.management.gui.IImageKeys; import com.gluster.storage.management.gui.utils.GUIHelper; @@ -51,7 +52,7 @@ import com.gluster.storage.management.gui.validators.StringRequiredValidator; * Login dialog, which prompts for the user's account info, and has Login and Cancel buttons. */ public class LoginDialog extends Dialog { - + public static final int RETURN_CODE_ERROR = 2; private Text userIdText = null; private Text passwordText = null; private Button okButton; @@ -191,8 +192,16 @@ public class LoginDialog extends Dialog { UsersClient usersClient = new UsersClient(); if (usersClient.authenticate(user, password)) { - GlusterDataModelManager.getInstance().initializeModel(usersClient.getSecurityToken()); - super.okPressed(); + try { + GlusterDataModelManager.getInstance().initializeModel( + usersClient.getSecurityToken()); + super.okPressed(); + } catch (GlusterRuntimeException e) { + setReturnCode(RETURN_CODE_ERROR); + MessageDialog.openError(getShell(), "Initialization Error", e.getMessage()); + close(); + } + } else { MessageDialog.openError(getShell(), "Authentication Failed", "Invalid User ID or password"); } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java index 5950bd38..ac2c19b0 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java @@ -23,6 +23,7 @@ package com.gluster.storage.management.gui.views; import java.util.List; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -33,11 +34,11 @@ import org.eclipse.ui.part.ViewPart; import com.gluster.storage.management.core.model.Alert; import com.gluster.storage.management.core.model.EntityGroup; import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.GlusterDataModel; import com.gluster.storage.management.client.GlusterDataModelManager; import com.gluster.storage.management.core.model.RunningTask; 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; import com.gluster.storage.management.gui.views.details.tabcreators.PieChartViewerComposite; @@ -50,22 +51,27 @@ public class VolumesSummaryView extends ViewPart { private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); private ScrolledForm form; private EntityGroup<Volume> volumes; - + private static final String ALERTS = "Alerts"; private static final String RUNNING_TASKS = "Running Tasks"; private static final String VOLUMES_SUMMARY = "Volumes - Summary"; private static final String AVAILABILITY = "Availability"; - + /* * (non-Javadoc) * - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + * @see + * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets + * .Composite) */ + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void createPartControl(Composite parent) { if (volumes == null) { - Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Volume.class) { + Object selectedObj = guiHelper.getSelectedEntity(getSite(), + EntityGroup.class); + if (selectedObj != null + && ((EntityGroup) selectedObj).getEntityType() == Volume.class) { volumes = (EntityGroup<Volume>) selectedObj; } } @@ -83,50 +89,74 @@ public class VolumesSummaryView extends ViewPart { } private void createAlertsSection() { - Composite section = guiHelper.createSection(form, toolkit, ALERTS, null, 1, false); - // toolkit.createLabel(section, "Any alerts related to volumes\nwill be displayed here."); + Composite section = guiHelper.createSection(form, toolkit, ALERTS, + null, 1, false); + List<Alert> alerts = GlusterDataModelManager.getInstance().getModel() + .getCluster().getAlerts(); - Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster(); - List<Alert> alerts = cluster.getAlerts(); for (Alert alert : alerts) { - if (alert.getType() == Alert.ALERT_TYPES.DISK_USAGE_ALERT || - alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_DISKS_ALERT) { - toolkit.createLabel(section, alert.getMessage()); - } + addAlertLabel(section, alert); + } + } + + private void addAlertLabel(Composite section, Alert alert) { + if (alert.getType() == Alert.ALERT_TYPES.DISK_USAGE_ALERT + || alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_DISKS_ALERT) { + CLabel lblAlert = new CLabel(section, SWT.NONE); + lblAlert.setText(alert.getMessage()); + lblAlert.setImage((alert.getType() == Alert.ALERT_TYPES.DISK_USAGE_ALERT) ? guiHelper + .getImage(IImageKeys.LOW_DISK_SPACE) : guiHelper + .getImage(IImageKeys.DISK_OFFLINE)); + lblAlert.redraw(); } } private void createRunningTasksSection() { - Composite section = guiHelper.createSection(form, toolkit, RUNNING_TASKS, null, 1, false); + Composite section = guiHelper.createSection(form, toolkit, + RUNNING_TASKS, null, 1, false); - List<RunningTask> runningTasks = GlusterDataModelManager.getInstance().getModel().getCluster().getRunningTasks(); + List<RunningTask> runningTasks = GlusterDataModelManager.getInstance() + .getModel().getCluster().getRunningTasks(); for (RunningTask task : runningTasks) { - if (task.getType() == RunningTask.TASK_TYPES.MIGRATE_DISK - || task.getType() == RunningTask.TASK_TYPES.VOLUME_REBALANCE) { - if (task.getStatus().isPercentageSupported()) { - // TODO Progress bar - } - toolkit.createLabel(section, task.getTaskInfo()); + addRunningTaskLabel(section, task); + } + } + + private void addRunningTaskLabel(Composite section, RunningTask task) { + // Task related to Volumes context + if (task.getType() == RunningTask.TASK_TYPES.DISK_MIGRATE + || task.getType() == RunningTask.TASK_TYPES.VOLUME_REBALANCE) { + if (task.getStatus().isPercentageSupported()) { + // TODO Progress bar } + CLabel lblAlert = new CLabel(section, SWT.NONE); + lblAlert.setText(task.getTaskInfo()); + lblAlert.setImage((task.getType() == RunningTask.TASK_TYPES.DISK_MIGRATE) ? guiHelper + .getImage(IImageKeys.DISK_MIGRATE) : guiHelper + .getImage(IImageKeys.VOLUME_REBALANCE)); + lblAlert.redraw(); } } private void createSummarySection() { - Composite section = guiHelper.createSection(form, toolkit, AVAILABILITY, null, 2, false); - - // Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster(); + Composite section = guiHelper.createSection(form, toolkit, + AVAILABILITY, null, 2, false); - GlusterDataModel model = GlusterDataModelManager.getInstance().getModel(); - Cluster cluster = (Cluster) model.getChildren().get(0); +// Cluster cluster = GlusterDataModelManager.getInstance().getModel() +// .getCluster(); - Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.ONLINE)), - Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.OFFLINE)) }; + Double[] values = new Double[] { + Double.valueOf(getVolumeCountByStatus(volumes, + VOLUME_STATUS.ONLINE)), + Double.valueOf(getVolumeCountByStatus(volumes, + VOLUME_STATUS.OFFLINE)) }; createStatusChart(toolkit, section, values); } @SuppressWarnings("unchecked") - private int getVolumeCountByStatus(EntityGroup<Volume> volumes, VOLUME_STATUS status) { + private int getVolumeCountByStatus(EntityGroup<Volume> volumes, + VOLUME_STATUS status) { int count = 0; for (Volume volume : (List<Volume>) volumes.getEntities()) { if (volume.getStatus() == status) { @@ -136,10 +166,11 @@ public class VolumesSummaryView extends ViewPart { return count; } - private void createStatusChart(FormToolkit toolkit, Composite section, Double[] values) { + private void createStatusChart(FormToolkit toolkit, Composite section, + Double[] values) { String[] categories = new String[] { "Online", "Offline" }; - PieChartViewerComposite chartViewerComposite = new PieChartViewerComposite(section, SWT.NONE, categories, - values); + PieChartViewerComposite chartViewerComposite = new PieChartViewerComposite( + section, SWT.NONE, categories, values); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); data.widthHint = 250; |
