Author: adietish
Date: 2010-12-22 12:53:58 -0500 (Wed, 22 Dec 2010)
New Revision: 27678
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/NewInstancePage.java
Log:
[JBIDE-7983] do not report an error if no hardware profiles are available and no profile
is selected therefore.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-22 17:35:28
UTC (rev 27677)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-22 17:53:58
UTC (rev 27678)
@@ -1,5 +1,8 @@
2010-12-22 adietisheim <adietisheim@adietisheim-thinkpad>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
+ (bindProfileCombo):
+ [JBIDE-7983] do not report an error if no hardware profiles are available and no profile
is selected therefore.
* src/org/jboss/tools/deltacloud/ui/views/cloud/ImageItem.java:
* src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudObjectLabelUtils.java
(getLabel):
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
(ImageLabel2DeltaCloudImageConverter.convert):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-22
17:35:28 UTC (rev 27677)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-22
17:53:58 UTC (rev 27678)
@@ -259,8 +259,8 @@
@Override
public IStatus validate(Object value) {
- if (value == null
- || (value instanceof Integer && ((Integer) value) < 0)) {
+ if (areRealmsAvailable() &&
+ !isValidComboIndex(value)) {
// TODO: internationalize strings
return ValidationStatus.error("You must select a realm.");
}
@@ -303,7 +303,7 @@
@Override
public void handleChange(ChangeEvent event) {
- realmCombo.setEnabled(model.getFilteredProfiles().size() > 0);
+ realmCombo.setEnabled(areRealmsAvailable());
}
}, realmsObservable, container);
@@ -320,8 +320,8 @@
@Override
public IStatus validate(Object value) {
- if (value == null
- || (value instanceof Integer && ((Integer) value) < 0)) {
+ if (areProfilesAvailable() &&
+ !isValidComboIndex(value)) {
// TODO: internationalize strings
return ValidationStatus.error("You must select a hardware profile.");
}
@@ -355,7 +355,6 @@
}
}
));
-
// bind combo enablement
IObservableList filteredProfilesObservable =
BeanProperties.list(NewInstanceModel.PROPERTY_FILTERED_PROFILES).observe(model);
@@ -364,11 +363,24 @@
@Override
public void handleChange(ChangeEvent event) {
- profileCombo.setEnabled(model.getFilteredProfiles().size() > 0);
+ profileCombo.setEnabled(areProfilesAvailable());
}
}, filteredProfilesObservable, container);
}
+ private boolean isValidComboIndex(Object index) {
+ return index != null
+ && (index instanceof Integer && ((Integer) index) >= 0);
+ }
+
+ private boolean areProfilesAvailable() {
+ return model.getFilteredProfiles().size() > 0;
+ }
+
+ private boolean areRealmsAvailable() {
+ return model.getRealms().size() > 0;
+ }
+
private void bindProfilePages(Combo hardwareCombo, final Map<String, ProfilePage>
profilePages,
DataBindingContext dbc) {
// bind all profiles
@@ -468,7 +480,6 @@
return image;
}
-
private DeltaCloudImage getImage(String id) {
try {
return cloud.getImage(id);