Author: adietish
Date: 2010-10-26 08:08:16 -0400 (Tue, 26 Oct 2010)
New Revision: 26065
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
Log:
[JBIDE-7411] removed static initialization to 'disabled' by dynamic initialization
on behalf of url->type binding validity
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
11:40:07 UTC (rev 26064)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-10-26
12:08:16 UTC (rev 26065)
@@ -273,7 +273,7 @@
Label typeLabel = new Label(container, SWT.NULL);
typeLabel.setText(WizardMessages.getString(CLOUDTYPE_LABEL));
Label computedTypeLabel = new Label(container, SWT.NULL);
- Binding urlBinding = bindCloudType(dbc, urlText, computedTypeLabel);
+ Binding urlTypeBinding = bindCloudType(dbc, urlText, computedTypeLabel);
// username
Label usernameLabel = new Label(container, SWT.NULL);
@@ -299,8 +299,9 @@
// test button
final Button testButton = new Button(container, SWT.NULL);
testButton.setText(WizardMessages.getString(TESTBUTTON_LABEL));
- testButton.setEnabled(false);
- urlBinding.getValidationStatus().addValueChangeListener(enableButtonOnUrlValidityChanges(testButton));
+ boolean isUrlValid = ((IStatus)
urlTypeBinding.getValidationStatus().getValue()).getSeverity() == IStatus.OK;
+ urlTypeBinding.getValidationStatus().addValueChangeListener(
+ enableButtonOnUrlValidityChanges(testButton, isUrlValid));
CredentialsTestAdapter credentialsTestAdapter = new
CredentialsTestAdapter(usernameDecoration,
passwordDecoration);
@@ -403,9 +404,12 @@
*
* @param testButton
* the test button
+ * @param isUrlValid
* @return the i value change listener
*/
- private IValueChangeListener enableButtonOnUrlValidityChanges(final Button testButton)
{
+ private IValueChangeListener enableButtonOnUrlValidityChanges(final Button testButton,
boolean isUrlValid) {
+
+ testButton.setEnabled(isUrlValid);
return new IValueChangeListener() {
@Override
@@ -417,9 +421,11 @@
}
/**
- * Binds the given cloud type label to the given url text widget. Attaches a
- * listener to the url text widget Adds a validity decorator to the url text
- * widget.
+ * Binds the given url text widget to the model type property and uses a
+ * converter to transfer urls to cloud types. Furthermore it binds the given
+ * cloud type label to the result of this conversion. The binding returned
+ * is the binding that connects the url text widget to the cloud type
+ * property in the model.
*
* @param dbc
* the databinding context to use
@@ -436,21 +442,29 @@
updateStrategy.setConverter(urlToCloudTypeConverter);
updateStrategy.setBeforeSetValidator(new CloudTypeValidator());
- Binding binding = dbc.bindValue(
+ // bind url to cloud type in model
+ Binding urlTypeBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(urlText),
BeanProperties.value(CloudConnectionModel.PROPERTY_TYPE).observe(connectionModel),
updateStrategy,
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
- // bind converter to delta cloud label
+ /*
+ * bind converter to delta cloud label.
+ *
+ * Cloud type cannot be fetched from the model since invalid url's don't
+ * get propagated to the model and no type update happens in this case.
+ * We could not show invalid urls in the label if we would get the type
+ * in the model.
+ */
IObservableValue cloudTypeObservable =
urlToCloudTypeConverter.getCloudTypeObservable();
DeltaCloudTypeLabelAdapter cloudTypeAdapter =
new DeltaCloudTypeLabelAdapter((DeltaCloudType) cloudTypeObservable.getValue(),
typeLabel);
cloudTypeObservable.addValueChangeListener(cloudTypeAdapter);
- ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP);
+ ControlDecorationSupport.create(urlTypeBinding, SWT.LEFT | SWT.TOP);
- return binding;
+ return urlTypeBinding;
}
/**
Show replies by date