summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-04-16 00:42:50 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-04-16 00:42:50 +0530
commita907385e3ff254ae7a8c316ae7bf4ce1a5fcb491 (patch)
tree54dad1997d1c8c06416e4e7879701fb22e111745
parentfc4b5612808484af3ec1d4d09e36a3146c491787 (diff)
Story#15 - Volume options view - integration with status line and volume summary view.
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java16
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java10
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/login/LoginDialog.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java9
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java31
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionValueEditingSupport.java16
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java27
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java2
9 files changed, 95 insertions, 20 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
index 018ab75f..c47830b2 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
@@ -397,15 +397,23 @@ public class GlusterDataModelManager {
public List<VolumeOptionInfo> getVolumeOptionsDefaults() {
return volumeOptionsDefaults;
}
-
- public String getVolumeOptionDefaultValue(String optionKey) {
+
+ public VolumeOptionInfo getVolumeOptionInfo(String optionKey) {
for(VolumeOptionInfo info : volumeOptionsDefaults) {
if(info.getName().equals(optionKey)) {
- return info.getDefaultValue();
+ return info;
}
}
throw new GlusterRuntimeException("Invalid option key [" + optionKey
- + "] passed to GlusterDataModelManager#getVolumeOptionDefaultValue");
+ + "] passed to GlusterDataModelManager#getVolumeOptionInfo");
+ }
+
+ public String getVolumeOptionDefaultValue(String optionKey) {
+ return getVolumeOptionInfo(optionKey).getDefaultValue();
+ }
+
+ public String getVolumeOptionDesc(String optionKey) {
+ return getVolumeOptionInfo(optionKey).getDescription();
}
public void setAccessControlList(Volume volume, String accessControlList) {
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java
index 50dbd314..47f2cfd9 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/Application.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
@@ -43,6 +44,7 @@ public class Application implements IApplication {
public static final String PLUGIN_ID = "com.gluster.storage.management.gui";
private static Application instance;
private List<IEntityListener> entityListeners = Collections.synchronizedList(new ArrayList<IEntityListener>());
+ private IStatusLineManager statusLineManager;
public Application() {
instance = this;
@@ -52,6 +54,14 @@ public class Application implements IApplication {
return instance;
}
+ public IStatusLineManager getStatusLineManager() {
+ return statusLineManager;
+ }
+
+ public void setStatusLineManager(IStatusLineManager statusLineManager) {
+ this.statusLineManager = statusLineManager;
+ }
+
private boolean login() {
LoginDialog loginDialog = new LoginDialog(new Shell(Display.getDefault()));
return (loginDialog.open() == Window.OK);
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java
index 722821f7..05d7443f 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchWindowAdvisor.java
@@ -56,5 +56,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
public void postWindowCreate() {
super.postWindowCreate();
guiHelper.centerShellInScreen(getWindowConfigurer().getWindow().getShell());
+ Application.getApplication().setStatusLineManager(
+ getWindowConfigurer().getActionBarConfigurer().getStatusLineManager());
}
}
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 b955f0e3..c6ffa8d5 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
@@ -41,8 +41,6 @@ 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;
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java
index 9f5fdfb7..d153a27c 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java
@@ -67,6 +67,7 @@ import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.progress.IProgressConstants;
import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
+import com.gluster.storage.management.gui.Application;
import com.gluster.storage.management.gui.IImageKeys;
import com.gluster.storage.management.gui.views.NavigationView;
@@ -370,4 +371,12 @@ public class GUIHelper {
throw new GlusterRuntimeException("Could not open the progress view!", e);
}
}
+
+ public void setStatusMessage(String message) {
+ Application.getApplication().getStatusLineManager().setMessage(message);
+ }
+
+ public void clearStatusMessage() {
+ Application.getApplication().getStatusLineManager().setMessage(null);
+ }
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
index 274a1942..497e939e 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
@@ -26,7 +26,6 @@ import org.eclipse.ui.part.ViewPart;
import com.gluster.storage.management.client.GlusterDataModelManager;
import com.gluster.storage.management.client.VolumesClient;
-import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.model.Alert;
import com.gluster.storage.management.core.model.DefaultClusterListener;
import com.gluster.storage.management.core.model.Event;
@@ -53,6 +52,7 @@ public class VolumeSummaryView extends ViewPart {
private Hyperlink changeLink;
private Text accessControlText;
private ControlDecoration errDecoration;
+ private Composite parent;
@Override
public void createPartControl(Composite parent) {
@@ -60,15 +60,26 @@ public class VolumeSummaryView extends ViewPart {
volume = (Volume) guiHelper.getSelectedEntity(getSite(), Volume.class);
}
- createSections(parent);
+ this.parent = parent;
+ createSections();
// Refresh the navigation tree whenever there is a change to the data model
volumeChangedListener = new DefaultClusterListener() {
+ @SuppressWarnings("unchecked")
@Override
public void volumeChanged(Volume volume, Event event) {
if (event.getEventType() == EVENT_TYPE.VOLUME_STATUS_CHANGED) {
updateVolumeStatusLabel();
new GlusterToolbarManager(getSite().getWorkbenchWindow()).updateToolbar(volume);
+ } else if (event.getEventType() == EVENT_TYPE.VOLUME_OPTION_SET) {
+ Entry<String, String> option = (Entry<String, String>)event.getEventData();
+ if (option.getKey().equals(Volume.OPTION_AUTH_ALLOW)) {
+ // access control option value has changed. update the text field with new value.
+ populateAccessControlText();
+ }
+ } else if (event.getEventType() == EVENT_TYPE.VOLUME_OPTIONS_RESET) {
+ // all volume options reset. populate access control text with default value.
+ populateAccessControlText();
}
}
};
@@ -86,7 +97,7 @@ public class VolumeSummaryView extends ViewPart {
GlusterDataModelManager.getInstance().removeClusterListener(volumeChangedListener);
}
- private void createSections(Composite parent) {
+ private void createSections() {
form = guiHelper.setupForm(parent, toolkit, "Volume Properties [" + volume.getName() + "]");
createVolumePropertiesSection();
@@ -170,13 +181,14 @@ public class VolumeSummaryView extends ViewPart {
changeLink = toolkit.createHyperlink(section, "change", SWT.NONE);
changeLink.addHyperlinkListener(new HyperlinkAdapter() {
- @SuppressWarnings("static-access")
private void finishEdit() {
saveAccessControlList();
}
private void startEdit() {
accessControlText.setEnabled(true);
+ accessControlText.setFocus();
+ accessControlText.selectAll();
changeLink.setText("update");
}
@@ -194,20 +206,23 @@ public class VolumeSummaryView extends ViewPart {
}
private void saveAccessControlList() {
- String newACL = accessControlText.getText();
+ final String newACL = accessControlText.getText();
+
+ guiHelper.setStatusMessage("Setting access control list to [" + newACL + "]...");
+ parent.update();
if (!newACL.equals(volume.getAccessControlList()) && ValidationUtil.isValidAccessControl(newACL)) {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
@Override
public void run() {
Status status = (new VolumesClient(GlusterDataModelManager.getInstance().getSecurityToken()))
- .setVolumeOption(volume.getName(), Volume.OPTION_AUTH_ALLOW, accessControlText.getText());
+ .setVolumeOption(volume.getName(), Volume.OPTION_AUTH_ALLOW, newACL);
if (status.isSuccess()) {
accessControlText.setEnabled(false);
changeLink.setText("change");
- GlusterDataModelManager.getInstance().setAccessControlList(volume, accessControlText.getText());
+ GlusterDataModelManager.getInstance().setAccessControlList(volume, newACL);
} else {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control",
status.getMessage());
@@ -218,6 +233,8 @@ public class VolumeSummaryView extends ViewPart {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control",
"Invalid IP / Host name ");
}
+ guiHelper.clearStatusMessage();
+ parent.update();
}
private void addKeyListerForAccessControl() {
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionValueEditingSupport.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionValueEditingSupport.java
index 53ccfaf1..5749c703 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionValueEditingSupport.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionValueEditingSupport.java
@@ -3,7 +3,6 @@
*/
package com.gluster.storage.management.gui.views.details;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
@@ -21,6 +20,7 @@ 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.VolumeOptionInfo;
+import com.gluster.storage.management.gui.utils.GUIHelper;
/**
* Editing support for the "value" column in volume options table viewer.
@@ -29,6 +29,7 @@ public class OptionValueEditingSupport extends EditingSupport {
private CellEditor cellEditor;
private Volume volume;
private List<VolumeOptionInfo> defaults = GlusterDataModelManager.getInstance().getVolumeOptionsDefaults();
+ private GUIHelper guiHelper = GUIHelper.getInstance();
public OptionValueEditingSupport(ColumnViewer viewer, Volume volume) {
super(viewer);
@@ -40,16 +41,22 @@ public class OptionValueEditingSupport extends EditingSupport {
@Override
protected void setValue(final Object element, final Object value) {
final Entry<String, String> entry = (Entry<String, String>) element;
+ final String optionKey = entry.getKey();
+ final String optionValue = (String)value;
+ final String oldValue = entry.getValue();
+ guiHelper.setStatusMessage("Setting option [" + optionKey + " = " + optionValue + "]...");
+ getViewer().getControl().update();
+
// It is not allowed to change value to empty string
- if(((String)value).isEmpty()) {
+ if(optionValue.isEmpty()) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option",
"Option value can't be empty! Please enter a valid value.");
cellEditor.setFocus();
return;
}
- if (entry.getValue().equals(value)) {
+ if (oldValue.equals(optionValue)) {
// value is same as that present in the model. return without doing anything.
return;
}
@@ -71,6 +78,9 @@ public class OptionValueEditingSupport extends EditingSupport {
getViewer().update(entry, null);
}
});
+
+ guiHelper.clearStatusMessage();
+ getViewer().getControl().update();
}
/**
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java
index d300c3b6..b30ce379 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/VolumeOptionsPage.java
@@ -24,6 +24,7 @@ import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -47,10 +48,12 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import com.gluster.storage.management.client.GlusterDataModelManager;
+import com.gluster.storage.management.core.constants.CoreConstants;
import com.gluster.storage.management.core.model.DefaultClusterListener;
import com.gluster.storage.management.core.model.Event;
import com.gluster.storage.management.core.model.Event.EVENT_TYPE;
import com.gluster.storage.management.core.model.Volume;
+import com.gluster.storage.management.core.model.VolumeOptionInfo;
import com.gluster.storage.management.gui.VolumeOptionsTableLabelProvider;
import com.gluster.storage.management.gui.utils.GUIHelper;
@@ -73,19 +76,18 @@ public class VolumeOptionsPage extends Composite {
super(parent, style);
this.volume = volume;
+
toolkit.adapt(this);
toolkit.paintBordersFor(this);
setupPageLayout();
- Text filterText = guiHelper.createFilterText(toolkit, this);
- setupDiskTableViewer(filterText);
+ setupDiskTableViewer(guiHelper.createFilterText(toolkit, this));
createAddButton();
tableViewer.setInput(volume.getOptions().entrySet());
parent.layout(); // Important - this actually paints the table
-
registerListeners(parent);
}
@@ -144,6 +146,7 @@ public class VolumeOptionsPage extends Composite {
});
clusterListener = new DefaultClusterListener() {
+ @SuppressWarnings("unchecked")
@Override
public void volumeChanged(Volume volume, Event event) {
super.volumeChanged(volume, event);
@@ -159,6 +162,14 @@ public class VolumeOptionsPage extends Composite {
// option has been set successfully by the user. re-enable the add button
addButton.setEnabled(true);
}
+
+ if(tableViewer.getTable().getItemCount() < volume.getOptions().size()) {
+ // new volume set from outside this page. refresh the viewer.
+ tableViewer.refresh();
+ } else {
+ // existing volume option value changed. update that element.
+ tableViewer.update(eventEntry, null);
+ }
}
}
};
@@ -219,6 +230,15 @@ public class VolumeOptionsPage extends Composite {
public String getText(Object element) {
return ((Entry<String, String>) element).getKey();
}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getToolTipText(Object element) {
+ VolumeOptionInfo optionInfo = GlusterDataModelManager.getInstance().getVolumeOptionInfo(
+ ((Entry<String, String>) element).getKey());
+ return optionInfo.getDescription() + CoreConstants.NEWLINE + "Default value: "
+ + optionInfo.getDefaultValue();
+ }
});
// Editing support required when adding new key
@@ -245,6 +265,7 @@ public class VolumeOptionsPage extends Composite {
private void setupDiskTableViewer(final Text filterText) {
Composite tableViewerComposite = createTableViewerComposite();
createDiskTableViewer(tableViewerComposite);
+ ColumnViewerToolTipSupport.enableFor(tableViewer);
// Create a case insensitive filter for the table viewer using the filter text field
guiHelper.createFilter(tableViewer, filterText, false);
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java
index 7f78829e..6913e211 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/tabcreators/VolumeTabCreator.java
@@ -255,7 +255,7 @@ public class VolumeTabCreator implements TabCreator {
private void createVolumeOptionsTab(Volume volume, TabFolder tabFolder, FormToolkit toolkit) {
Composite volumeTab = guiHelper.createTab(tabFolder, "Options", IImageKeys.VOLUME);
- VolumeOptionsPage page = new VolumeOptionsPage(volumeTab, SWT.NONE, volume);
+ //VolumeOptionsPage page = new VolumeOptionsPage(volumeTab, SWT.NONE, volume);
volumeTab.layout(); // IMP: lays out the form properly
}