diff options
author | Selvasundaram <selvam@gluster.com> | 2011-11-24 15:27:33 +0530 |
---|---|---|
committer | Selvasundaram <selvam@gluster.com> | 2011-11-25 18:49:53 +0530 |
commit | 6a7ca2f7733d15f57d278275f55d65c5de0c561e (patch) | |
tree | 5851a7015a6de2314298dc85c890ef4df8a1c421 /src/com.gluster.storage.management.console/src | |
parent | 8ceca6ee92099b5f356bcc57198e70225647e65a (diff) |
Mount point parameter enclosed in quotes
Diffstat (limited to 'src/com.gluster.storage.management.console/src')
-rw-r--r-- | src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java (renamed from src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitializeDiskTypeSelection.java) | 70 | ||||
-rw-r--r-- | src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java | 26 |
2 files changed, 41 insertions, 55 deletions
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitializeDiskTypeSelection.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java index b484d6d2..870de286 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitializeDiskTypeSelection.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java @@ -46,24 +46,23 @@ import org.eclipse.ui.forms.widgets.Hyperlink; import com.gluster.storage.management.console.utils.GUIHelper; -public class InitializeDiskTypeSelection extends Dialog { +public class InitDiskDialog extends Dialog { private Combo formatTypeCombo = null; private final GUIHelper guiHelper = GUIHelper.getInstance(); private Composite initializeDiskTypeComposite; private Composite composite; private String fsType; - private String mountPointText; - private Text mountPoint; + private String mountPoint; + private Text mountPointText; private String deviceName; - private List<String> possibleFsType; - private String defaultMountPoint = "/export/"; + private List<String> fsTypes; + private static final String DEFAULT_MOUNT_POINT = "/export/"; - public InitializeDiskTypeSelection(Shell parentShell, String formatingDeviceName, List<String> possibleFsType) { + public InitDiskDialog(Shell parentShell, String deviceName, List<String> fsTypes) { super(parentShell); - this.possibleFsType = possibleFsType; - this.deviceName = formatingDeviceName; - // TODO Auto-generated constructor stub + this.fsTypes = fsTypes; + this.deviceName = deviceName; } @Override @@ -127,24 +126,23 @@ public class InitializeDiskTypeSelection extends Dialog { private void createFormatTypeCombo(Composite composite) { formatTypeCombo = new Combo(composite, SWT.READ_ONLY); - formatTypeCombo.setItems(possibleFsType.toArray(new String[0])); + formatTypeCombo.setItems(fsTypes.toArray(new String[0])); formatTypeCombo.select(0); new Label(composite, SWT.NONE); } private void createMountPointText(Composite container) { - mountPoint = new Text(container, SWT.BORDER); + mountPointText = new Text(container, SWT.BORDER); GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - txtNameData.horizontalSpan = 1; txtNameData.widthHint = 400; - mountPoint.setTextLimit(100); - mountPoint.setLayoutData(txtNameData); - mountPoint.setText(defaultMountPoint + deviceName); - mountPoint.setEnabled(false); - mountPoint.addModifyListener(new ModifyListener() { + mountPointText.setTextLimit(100); + mountPointText.setLayoutData(txtNameData); + mountPointText.setText(DEFAULT_MOUNT_POINT + deviceName); + mountPointText.setEnabled(false); + mountPointText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { - validateMountPoint(mountPoint.getText().trim()); + validateMountPoint(); } }); } @@ -156,26 +154,11 @@ public class InitializeDiskTypeSelection extends Dialog { changeLink.setForeground(new Color(Display.getDefault(), 0, 0, 255)); changeLink.addHyperlinkListener(new HyperlinkAdapter() { - - // private void finishEdit() { - // changeLink.setText("change"); - // mountPoint.setEnabled(false); - // } - - private void startEdit() { - // changeLink.setText("update"); - changeLink.setVisible(false); - mountPoint.setEnabled(true); - } - @Override public void linkActivated(HyperlinkEvent e) { - if (mountPoint.isEnabled()) { - // we were already in edit mode. - // finishEdit(); - } else { - // Get in to edit mode - startEdit(); + if (!mountPointText.isEnabled()) { + changeLink.setVisible(false); + mountPointText.setEnabled(true); } } }); @@ -184,11 +167,11 @@ public class InitializeDiskTypeSelection extends Dialog { @Override protected void okPressed() { fsType = formatTypeCombo.getText().trim(); - mountPointText = mountPoint.getText().trim(); + mountPoint = mountPointText.getText().trim(); if (validateForm()) { super.okPressed(); } else { - MessageDialog.openError(getShell(), "Error: Validation error!", "Empty or Invalid mountpoint."); + MessageDialog.openError(getShell(), "Initialize Disk - Error", "Please enter a valid mount point"); } } @@ -197,15 +180,16 @@ public class InitializeDiskTypeSelection extends Dialog { super.cancelPressed(); } - private boolean validateMountPoint(String deviceMountPoint) { - if (deviceMountPoint.isEmpty()) { + private boolean validateMountPoint() { + String mountPoint = mountPointText.getText().trim(); + if (mountPoint.isEmpty()) { return false; } - return deviceMountPoint.matches("^/.+"); + return mountPoint.matches("^/.+"); } private boolean validateForm() { - return (!formatTypeCombo.getText().trim().isEmpty() && validateMountPoint( mountPoint.getText().trim())); + return (!formatTypeCombo.getText().trim().isEmpty() && validateMountPoint()); } /** @@ -223,6 +207,6 @@ public class InitializeDiskTypeSelection extends Dialog { } public String getMountPoint() { - return mountPointText; + return mountPoint; } } diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java index b131ccc2..43a7e61a 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java @@ -45,7 +45,8 @@ import com.gluster.storage.management.client.TasksClient; import com.gluster.storage.management.console.Application; import com.gluster.storage.management.console.GlusterDataModelManager; import com.gluster.storage.management.console.IEntityListener; -import com.gluster.storage.management.console.dialogs.InitializeDiskTypeSelection; +import com.gluster.storage.management.console.dialogs.InitDiskDialog; +import com.gluster.storage.management.console.utils.GlusterLogger; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.ClusterListener; import com.gluster.storage.management.core.model.DefaultClusterListener; @@ -61,6 +62,7 @@ import com.gluster.storage.management.core.model.TaskInfo; public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk> implements IEntityListener { protected List<Disk> disks; + protected static final GlusterLogger logger = GlusterLogger.getInstance(); /** * @return Index of the "status" column in the table. Return -1 if status column is not displayed @@ -71,7 +73,7 @@ public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk super(site, parent, style, false, true, disks); this.disks = disks; - // creates hyperlinks for "unitialized" disks + // creates hyperlinks for "uninitialized" disks setupStatusCellEditor(); // Listen for disk status change events Application.getApplication().addEntityListener(this); @@ -252,25 +254,25 @@ public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk TaskInfo existingTaskInfo = modelManager.getTaskByReference(reference); if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { - MessageDialog.openInformation(getShell(), "Error: Initialize disk", "Initializing disk [" + reference + MessageDialog.openInformation(getShell(), "Initialize disk - Error", "Initializing disk [" + reference + "] is already in progress! Try later."); return; } // To collect the available fsType GlusterServersClient serversClient = new GlusterServersClient(); - List<String> possibleFsType = new ArrayList<String>(); + List<String> fsTypes = new ArrayList<String>(); try { - possibleFsType = serversClient.getFSType(device.getServerName()); - } catch (GlusterRuntimeException eFsType) { - MessageDialog.openError(getShell(), "Error: File System Type", eFsType.getMessage()); + fsTypes = serversClient.getFSTypes(device.getServerName()); + } catch (GlusterRuntimeException e1) { + MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); return; } - InitializeDiskTypeSelection formatDialog = new InitializeDiskTypeSelection(getShell(), device.getName(), possibleFsType); + InitDiskDialog formatDialog = new InitDiskDialog(getShell(), device.getName(), fsTypes); int userAction = formatDialog.open(); if (userAction == Window.CANCEL) { - formatDialog.cancelPressed(); + // formatDialog.cancelPressed(); return; } @@ -296,12 +298,12 @@ public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk // GlusterDataModelManager.getInstance().updateDeviceStatus(device.getServerName(), device.getName(), // DEVICE_STATUS.INITIALIZED); } else { - MessageDialog.openError(getShell(), "Error: Initialize disk", taskInfo.getStatus().getMessage()); + MessageDialog.openError(getShell(), "Initialize disk - Error", taskInfo.getStatus().getMessage()); } guiHelper.showTaskView(); } catch (Exception e1) { - e1.printStackTrace(); - MessageDialog.openError(getShell(), "Error: Initialize disk", e1.getMessage()); + logger.error("Exception while initialize disk", e1); + MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); } } } |