diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-04-14 20:56:42 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-04-14 23:27:35 +0530 |
| commit | 60679a5b41a789d7c9f785d2c0eedcb726a7b4b1 (patch) | |
| tree | 7eb73ce53f4d086b34b6dfa57fbd52287c6e7fbb /src | |
| parent | 6044ba8846610911dedbce10eecaef4a7d144abd (diff) | |
| parent | d3acbc0eda74dca6bf261be0a914485a08852b33 (diff) | |
Conflicts:
build/package-server.sh
Diffstat (limited to 'src')
6 files changed, 37 insertions, 12 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 a8134c7d..8d6d5002 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 @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Cluster; @@ -394,6 +395,13 @@ public class GlusterDataModelManager { listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTIONS_RESET, null)); } } + + public void setVolumeOption(Volume volume, Entry<String, String> entry) { + volume.setOption(entry.getKey(), (String) entry.getValue()); + for(ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTION_SET, entry)); + } + } public void addVolume(Volume volume) { Cluster cluster = model.getCluster(); diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java index bac86a2e..22b938d2 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java @@ -25,7 +25,8 @@ public class Event { NETWORK_INTERFACE_ADDED, NETWORK_INTERFACE_REMOVED, VOLUME_STATUS_CHANGED, - VOLUME_OPTIONS_RESET + VOLUME_OPTIONS_RESET, + VOLUME_OPTION_SET } private EVENT_TYPE eventType; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java index 5ed83810..5bfe01c8 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java @@ -295,9 +295,9 @@ public class GlusterUtil { } private boolean readOption(Volume volume, String line) { - if (line.matches("^[^:]*:[^:]*$")) { - String[] parts = line.split(":"); - volume.setOption(parts[0].trim(), parts[1].trim()); + if (line.matches("^[^:]*:.*$")) { + int index = line.indexOf(':'); + volume.setOption(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim()); return true; } return false; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionKeyEditingSupport.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionKeyEditingSupport.java index 56f25997..b3f7ca3a 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionKeyEditingSupport.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/details/OptionKeyEditingSupport.java @@ -26,12 +26,12 @@ public class OptionKeyEditingSupport extends EditingSupport { private Volume volume; private List<VolumeOptionInfo> defaults = GlusterDataModelManager.getInstance().getVolumeOptionsDefaults(); private String[] allowedKeys; + private ColumnViewer viewer; public OptionKeyEditingSupport(ColumnViewer viewer, Volume volume) { super(viewer); this.volume = volume; - allowedKeys = getAllowedKeys(); - this.cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys); + this.viewer = viewer; } /** @@ -66,7 +66,6 @@ public class OptionKeyEditingSupport extends EditingSupport { getViewer().refresh(); } - @SuppressWarnings("unchecked") @Override protected Object getValue(Object element) { return cellEditor.getValue(); @@ -74,6 +73,8 @@ public class OptionKeyEditingSupport extends EditingSupport { @Override protected CellEditor getCellEditor(Object element) { + allowedKeys = getAllowedKeys(); + cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys); return cellEditor; } 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 f975f1ff..53ccfaf1 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,6 +3,7 @@ */ package com.gluster.storage.management.gui.views.details; +import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; @@ -34,7 +35,7 @@ public class OptionValueEditingSupport extends EditingSupport { this.volume = volume; this.cellEditor = new TextCellEditor((Composite) viewer.getControl()); } - + @SuppressWarnings("unchecked") @Override protected void setValue(final Object element, final Object value) { @@ -61,7 +62,8 @@ public class OptionValueEditingSupport extends EditingSupport { VolumesClient client = new VolumesClient(GlusterDataModelManager.getInstance().getSecurityToken()); Status status = client.setVolumeOption(volume.getName(), entry.getKey(), (String) value); if (status.isSuccess()) { - volume.setOption(entry.getKey(), (String) value); + entry.setValue((String)value); + GlusterDataModelManager.getInstance().setVolumeOption(volume, entry); } else { MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option", status.getMessage()); 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 5a1a41e9..ad724d25 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 @@ -66,6 +66,7 @@ public class VolumeOptionsPage extends Composite { }; private static final String[] OPTIONS_TABLE_COLUMN_NAMES = new String[] { "Option Key", "Option Value" }; + private Button addButton; public VolumeOptionsPage(final Composite parent, int style, Volume volume) { super(parent, style); @@ -88,18 +89,22 @@ public class VolumeOptionsPage extends Composite { } private void createAddButton() { - Button addButton = toolkit.createButton(this, "&Add", SWT.FLAT); + addButton = toolkit.createButton(this, "&Add", SWT.FLAT); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + // add an empty option to be filled up by user volume.setOption("", ""); tableViewer.refresh(); tableViewer.setSelection(new StructuredSelection(getEntry(""))); + + // disable the add button till user fills up the new option + addButton.setEnabled(false); } - private Entry getEntry(String key) { - for(Entry entry : volume.getOptions().entrySet()) { + private Entry<String, String> getEntry(String key) { + for(Entry<String, String> entry : volume.getOptions().entrySet()) { if(entry.getKey().equals(key)) { return entry; } @@ -137,6 +142,14 @@ public class VolumeOptionsPage extends Composite { tableViewer.refresh(); } } + + if(event.getEventType() == EVENT_TYPE.VOLUME_OPTION_SET) { + Entry<String, String> eventEntry = (Entry<String, String>)event.getEventData(); + if (eventEntry.getKey().equals(volume.getOptions().keySet().toArray()[volume.getOptions().size()-1])) { + // option has been set successfully by the user. re-enable the add button + addButton.setEnabled(true); + } + } } }); |
