Author: adietish
Date: 2010-10-26 06:11:24 -0400 (Tue, 26 Oct 2010)
New Revision: 26057
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
Log:
[JBIDE-7402] corrected CloudNameValidator to ignore the name of the connection that's
being edited
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-26 10:10:28
UTC (rev 26056)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-10-26 10:11:24
UTC (rev 26057)
@@ -6,6 +6,8 @@
[JBIDE-7402] added MalformedURLException handling.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
(bindCloudType):
[JBIDE-7402] bound type label to converter state.
+ (CloudNameValidator): [JBIDE-7402] corrected CloudNameValidator to ignore the name of
the connection that's being edited
+ (bindName): [JBIDE-7402] corrected CloudNameValidator to ignore the name of the
connection that's being edited
* src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionModel.java
(getDeltaCloudType): [JBIDE-7402] added setup of type at instantiation time
(CloudConnectionModel): [JBIDE-7402] radded setup of type at instantiation time
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-26
10:10:28 UTC (rev 26056)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-26
10:11:24 UTC (rev 26057)
@@ -62,7 +62,7 @@
public class CloudConnectionPage extends WizardPage {
private static final int CLOUDTYPE_CHECK_DELAY = 500;
-
+
private static final String DESCRIPTION = "NewCloudConnection.desc";
//$NON-NLS-1$
private static final String TITLE = "NewCloudConnection.title"; //$NON-NLS-1$
private static final String URL_LABEL = "Url.label"; //$NON-NLS-1$
@@ -137,7 +137,7 @@
}
/**
- * A class that listens to a user click on a button that allows it to test
+ * A Listener that listens to user clicks on a button that allows it to test
* credentials.
*
* @see CloudConnection#performTest()
@@ -186,6 +186,35 @@
}
}
+ /**
+ * A validator that marks cloud names as invalid if the name the user
+ * entered is already used by another connection. It does not invalidate the
+ * name the connection had before editing.
+ *
+ * @see IValidator
+ * @see CloudConnectionModel#getInitialName()
+ * @see DeltaCloudManager#findCloud(String)
+ *
+ */
+ private class CloudNameValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ String connectionName = (String) value;
+ /*
+ * keeping the same name when editing must be valid
+ */
+ if (!connectionName.equals(connectionModel.getInitialName())
+ /* all new names must be unique */
+ && DeltaCloudManager.getDefault().findCloud(connectionName) != null) {
+ return ValidationStatus
+ .error(WizardMessages.getString(NAME_ALREADY_IN_USE));
+ } else {
+ return ValidationStatus.ok();
+ }
+ }
+ }
+
public CloudConnectionPage(String pageName, CloudConnection cloudConnection) {
super(pageName);
setDescription(WizardMessages.getString(DESCRIPTION));
@@ -415,8 +444,8 @@
// bind converter to delta cloud label
IObservableValue cloudTypeObservable =
urlToCloudTypeConverter.getCloudTypeObservable();
- DeltaCloudTypeLabelAdapter cloudTypeAdapter = new DeltaCloudTypeLabelAdapter(
- (DeltaCloudType) cloudTypeObservable.getValue(), typeLabel);
+ DeltaCloudTypeLabelAdapter cloudTypeAdapter =
+ new DeltaCloudTypeLabelAdapter((DeltaCloudType) cloudTypeObservable.getValue(),
typeLabel);
cloudTypeObservable.addValueChangeListener(cloudTypeAdapter);
ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP);
@@ -441,24 +470,7 @@
new UpdateValueStrategy().setBeforeSetValidator(
new CompositeValidator(
new MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_A_NAME)),
- new IValidator() {
-
- @Override
- public IStatus validate(Object value) {
- /*
- * keeping the same name when editing
- * must be valid
- */
- if (!nameText.getText().equals(connectionModel.getInitialName())
- /* all new names must be unique */
- && DeltaCloudManager.getDefault().findCloud(nameText.getText()) !=
null) {
- return ValidationStatus
- .error(WizardMessages.getString(NAME_ALREADY_IN_USE));
- } else {
- return ValidationStatus.ok();
- }
- }
- })),
+ new CloudNameValidator())),
null);
ControlDecorationSupport.create(nameTextBinding, SWT.LEFT | SWT.TOP);
}