Author: rob.stryker(a)jboss.com
Date: 2011-10-19 10:39:41 -0400 (Wed, 19 Oct 2011)
New Revision: 35807
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
Log:
JBIDE-9947 - runtime validation
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-19
14:39:38 UTC (rev 35806)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AdapterWizardPage.java 2011-10-19
14:39:41 UTC (rev 35807)
@@ -102,7 +102,7 @@
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(projectGroup);
- Group serverAdapterGroup = createAdapterGroup(parent);
+ Group serverAdapterGroup = createAdapterGroup(parent, dbc);
GridDataFactory.fillDefaults()
.align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(serverAdapterGroup);
}
@@ -266,7 +266,7 @@
};
}
- private Group createAdapterGroup(Composite parent) {
+ private Group createAdapterGroup(Composite parent, DataBindingContext dbc) {
Group serverAdapterGroup = new Group(parent, SWT.BORDER);
serverAdapterGroup.setText("JBoss Server adapter");
FillLayout fillLayout = new FillLayout();
@@ -274,6 +274,25 @@
fillLayout.marginWidth = 6;
serverAdapterGroup.setLayout(fillLayout);
fillServerAdapterGroup(serverAdapterGroup);
+ IObservableValue runtimeSelection =
WidgetProperties.singleSelectionIndex().observe(suitableRuntimes);
+ dbc.bindValue(
+ WidgetProperties.singleSelectionIndex().observe(suitableRuntimes)
+ , WidgetProperties.singleSelectionIndex().observe(suitableRuntimes)
+ , new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)
+ , new UpdateValueStrategy().setAfterGetValidator(new IValidator() {
+ public IStatus validate(Object value) {
+ if( !serverAdapterCheckbox.getSelection())
+ return Status.OK_STATUS;
+ if( new Integer(-1).equals(value)) {
+ if( suitableRuntimes.getItems() == null || suitableRuntimes.getItems().length ==
0) {
+ return ValidationStatus.error("Please add a new valid runtime.");
+ }
+ return ValidationStatus.error("Please select a runtime");
+ }
+ return Status.OK_STATUS;
+ }
+ }));
+ runtimeSelection.setValue(null);
return serverAdapterGroup;
}