diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-04-19 18:31:14 +0530 |
|---|---|---|
| committer | Selvam <selvam@gluster.com> | 2011-04-25 17:25:31 +0530 |
| commit | 99014bdfd97d4fc25fc0866c47019769721d7093 (patch) | |
| tree | ed436c092876b996035d48dd82a294a485b69676 | |
| parent | 1bc94b1768a96bdf9118d64e21f413e4614347fd (diff) | |
Bug 2824 - Mounting information is not shown in Volume properties section - fix
3 files changed, 71 insertions, 17 deletions
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 6ff61934..1c9577ac 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 @@ -10,6 +10,8 @@ import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; @@ -53,7 +55,8 @@ public class VolumeSummaryView extends ViewPart { private Text accessControlText; private ControlDecoration errDecoration; private Composite parent; - + private static final String COURIER_FONT = "Courier"; + @Override public void createPartControl(Composite parent) { if (volume == null) { @@ -72,7 +75,7 @@ public class VolumeSummaryView extends ViewPart { 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(); + 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(); @@ -126,9 +129,51 @@ public class VolumeSummaryView extends ViewPart { lblAlert.redraw(); } + private Label setLabelStyle(Label label, String fontName, int size, int style) { + Font font = new Font(Display.getCurrent(), new FontData(fontName, size, style)); + label.setFont(font); + return label; + } + private void createVolumeMountingInfoSection() { - Composite section = guiHelper.createSection(form, toolkit, "Mounting Information", null, 3, false); - toolkit.createLabel(section, "Information about mounting the\nvolume will be printed here"); + String glusterFs = "Gluster:"; + String nfs = "NFS:"; + String glusterFsSyntax = "mount -t glusterfs <SERVER-NAME>:/<VOLUME-NAME> <MOUNT-POINT>"; + String nfsSyntax = "mount -t nfs <SERVER-NAME>:/nfs/<VOLUME-NAME> <MOUNT-POINT>"; + String info = "<SERVER-NAME> - Any server name in the storage cloud"; + String volumeName = volume.getName().trim(); + String serverName = volume.getDisks().get(0).split(":")[0].trim(); // disk if the form of: "server:disk" + + Composite section = guiHelper.createSection(form, toolkit, "Mounting Information", null, 2, false); + + Label lbl = toolkit.createLabel(section, "Syntax"); + final int defaultFontSize = lbl.getFont().getFontData()[0].getHeight(); + final String defaultFontName = lbl.getFont().getFontData()[0].name; + + setLabelStyle(lbl, defaultFontName, defaultFontSize, SWT.BOLD); + toolkit.createLabel(section, ""); + + setLabelStyle(toolkit.createLabel(section, glusterFs), defaultFontName, defaultFontSize, SWT.NORMAL); + setLabelStyle(toolkit.createLabel(section, glusterFsSyntax, SWT.NONE), COURIER_FONT, 10, SWT.NONE); + + // TODO: Check required if nfs is optional + setLabelStyle(toolkit.createLabel(section, nfs), defaultFontName, defaultFontSize, SWT.NORMAL); + setLabelStyle(toolkit.createLabel(section, nfsSyntax, SWT.NONE), COURIER_FONT, 10, SWT.NONE); + + toolkit.createLabel(section, ""); + setLabelStyle(toolkit.createLabel(section, info), defaultFontName, (defaultFontSize - 1), SWT.NONE); + + setLabelStyle(toolkit.createLabel(section, "Example"), defaultFontName, defaultFontSize, SWT.BOLD); + toolkit.createLabel(section, ""); + + setLabelStyle(toolkit.createLabel(section, glusterFs), defaultFontName, defaultFontSize, SWT.NORMAL); + setLabelStyle(toolkit.createLabel(section, "#mount -t glusterfs " + serverName + ":/" + volumeName + " /mnt"), + COURIER_FONT, 10, SWT.NONE); + + // TODO: Check required if nfs is optional + setLabelStyle(toolkit.createLabel(section, nfs), defaultFontName, defaultFontSize, SWT.NORMAL); + setLabelStyle(toolkit.createLabel(section, "#mount -t nfs " + serverName + ":/" + volumeName + " /mnt"), + COURIER_FONT, 10, SWT.NONE); } /** @@ -162,24 +207,23 @@ public class VolumeSummaryView extends ViewPart { layoutData.widthHint = 300; return layoutData; } - private void createAccessControlField(Composite section) { toolkit.createLabel(section, "Access Control: ", SWT.NONE); accessControlText = toolkit.createText(section, volume.getAccessControlList()); - + populateAccessControlText(); addKeyListerForAccessControl(); accessControlText.setLayoutData(createDefaultLayoutData()); accessControlText.setEnabled(false); createChangeLinkForAccessControl(section); - + // error decoration used while validating the access control text errDecoration = guiHelper.createErrorDecoration(accessControlText); errDecoration.hide(); createAccessControlInfoLabel(section); // info text } - + private void createAccessControlInfoLabel(Composite section) { toolkit.createLabel(section, "", SWT.NONE); Label accessControlInfoLabel = toolkit.createLabel(section, "(Comma separated list of IP addresses/hostnames)"); @@ -218,10 +262,10 @@ public class VolumeSummaryView extends ViewPart { private void saveAccessControlList() { final String newACL = accessControlText.getText(); - + guiHelper.setStatusMessage("Setting access control list to [" + newACL + "]..."); parent.update(); - + if (newACL.equals(volume.getAccessControlList())) { accessControlText.setEnabled(false); changeLink.setText("change"); @@ -265,7 +309,7 @@ public class VolumeSummaryView extends ViewPart { saveAccessControlList(); break; } - + validateAccessControlList(); } }); @@ -273,7 +317,7 @@ public class VolumeSummaryView extends ViewPart { private void populateAccessControlText() { String accessControlList = volume.getAccessControlList(); - if(accessControlList == null) { + if (accessControlList == null) { // if not set, show default value accessControlList = GlusterDataModelManager.getInstance().getVolumeOptionDefaultValue( Volume.OPTION_AUTH_ALLOW); @@ -395,14 +439,14 @@ public class VolumeSummaryView extends ViewPart { private void validateAccessControlList() { errDecoration.hide(); - + if (accessControlText.getText().length() == 0) { errDecoration.setDescriptionText("Access control list cannot be empty!"); errDecoration.show(); return; } - - if(!ValidationUtil.isValidAccessControl(accessControlText.getText())) { + + if (!ValidationUtil.isValidAccessControl(accessControlText.getText())) { errDecoration .setDescriptionText("Access control list must be a comma separated list of IP addresses/Host names. Please enter a valid value!"); errDecoration.show(); 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 936cf450..9e0a18ca 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 @@ -13,6 +13,7 @@ import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnViewer; import org.eclipse.jface.viewers.ComboBoxCellEditor; import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import com.gluster.storage.management.client.GlusterDataModelManager; @@ -77,13 +78,18 @@ public class OptionKeyEditingSupport extends EditingSupport { return cellEditor.getValue(); } + if(entryBeingAdded.getKey().isEmpty()) { + // editing just about to start. set first element as default. + return 0; + } + return getIndexOfEntry(entryBeingAdded); } @Override protected CellEditor getCellEditor(Object element) { allowedKeys = getAllowedKeys(); - cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys); + cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys, SWT.READ_ONLY); return cellEditor; } 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 7ab5b9b8..5139014e 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 @@ -36,6 +36,8 @@ import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -71,6 +73,7 @@ public class VolumeOptionsPage extends Composite { private static final String[] OPTIONS_TABLE_COLUMN_NAMES = new String[] { "Option Key", "Option Value" }; private Button addButton; + private TableViewerColumn keyColumn; public VolumeOptionsPage(final Composite parent, int style, Volume volume) { super(parent, style); @@ -101,6 +104,7 @@ public class VolumeOptionsPage extends Composite { tableViewer.refresh(); tableViewer.setSelection(new StructuredSelection(getEntry(""))); + keyColumn.getViewer().editElement(getEntry(""), 0); // edit newly created entry // disable the add button till user fills up the new option addButton.setEnabled(false); @@ -216,7 +220,7 @@ public class VolumeOptionsPage extends Composite { } private TableColumn createKeyColumn() { - TableViewerColumn keyColumn = new TableViewerColumn(tableViewer, SWT.NONE); + keyColumn = new TableViewerColumn(tableViewer, SWT.NONE); keyColumn.getColumn().setText(OPTIONS_TABLE_COLUMN_NAMES[OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal()]); keyColumn.setLabelProvider(new ColumnLabelProvider() { @SuppressWarnings("unchecked") |
