Author: adietish
Date: 2011-10-17 14:06:37 -0400 (Mon, 17 Oct 2011)
New Revision: 35734
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
Log:
[JBIDE-9890] fixed selected cartridge not being stored/restored from prefs & correctly
initialized when empty
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-10-17
17:24:28 UTC (rev 35733)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPage.java 2011-10-17
18:06:37 UTC (rev 35734)
@@ -102,19 +102,20 @@
}
return null;
}
- })
- , new UpdateValueStrategy().setAfterGetValidator(
+ }).setAfterGetValidator(
new IValidator() {
@Override
public IStatus validate(Object value) {
- if (!(value instanceof ICartridge)) {
+ if (!(value instanceof String)
+ || ((String) value).length() == 0) {
return ValidationStatus.error("You have to select a type");
} else {
return ValidationStatus.ok();
}
}
- }).setConverter(new Converter(ICartridge.class, String.class) {
+ })
+ , new UpdateValueStrategy().setConverter(new Converter(ICartridge.class,
String.class) {
@Override
public Object convert(Object fromObject) {
@@ -135,7 +136,6 @@
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
-
model.loadCartridges();
} catch (OpenshiftException e) {
return new Status(IStatus.ERROR, OpenshiftUIActivator.PLUGIN_ID, "Could not
load cartridges", e);
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java 2011-10-17
17:24:28 UTC (rev 35733)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewApplicationWizardPageModel.java 2011-10-17
18:06:37 UTC (rev 35734)
@@ -11,7 +11,7 @@
package org.jboss.tools.openshift.express.internal.ui.wizard;
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.List;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
@@ -32,7 +32,7 @@
private IUser user;
private String name;
- private Collection<ICartridge> cartridges = new ArrayList<ICartridge>();
+ private List<ICartridge> cartridges = new ArrayList<ICartridge>();
private ICartridge selectedCartridge;
private StringPreferenceValue selectedCartridgePreference;
@@ -41,16 +41,23 @@
this.selectedCartridgePreference = new StringPreferenceValue(
"org.jboss.tools.openshift.express.internal.ui.wizard.NewApplicationWizard.selectedCartridge",
OpenshiftUIActivator.PLUGIN_ID);
- initSelectedCartridge();
}
- private void initSelectedCartridge() {
+ private ICartridge initSelectedCartridge() {
String selectedCartridgeName = selectedCartridgePreference.get();
+ if (getSelectedCartridge() != null) {
+ selectedCartridgeName = getSelectedCartridge().getName();
+ }
if (selectedCartridgeName == null
|| selectedCartridgeName.length() == 0) {
- selectedCartridge = ICartridge.JBOSSAS_7;
+ selectedCartridgeName = ICartridge.JBOSSAS_7.getName();
}
- this.selectedCartridge = getCartridgeByName(selectedCartridgeName);
+ ICartridge selectedCartridge = getCartridgeByName(selectedCartridgeName);
+ if (selectedCartridge == null
+ && getCartridges().size() > 0) {
+ selectedCartridge = getCartridges().get(0);
+ }
+ return selectedCartridge;
}
public String getName() {
@@ -65,11 +72,12 @@
setCartridges(user.getCartridges());
}
- public void setCartridges(Collection<ICartridge> cartridges) {
+ public void setCartridges(List<ICartridge> cartridges) {
firePropertyChange(PROPERTY_CARTRIDGES, this.cartridges, this.cartridges =
cartridges);
+ setSelectedCartridge(initSelectedCartridge());
}
- public Collection<ICartridge> getCartridges() {
+ public List<ICartridge> getCartridges() {
return cartridges;
}
@@ -78,7 +86,9 @@
}
public void setSelectedCartridge(ICartridge cartridge) {
- selectedCartridgePreference.store(cartridge.getName());
+ if (cartridge != null) {
+ selectedCartridgePreference.store(cartridge.getName());
+ }
firePropertyChange(PROPERTY_SELECTED_CARTRIDGE, selectedCartridge,
this.selectedCartridge = cartridge);
}
@@ -101,7 +111,8 @@
try {
return user.getApplicationByName(name) != null;
} catch (OpenshiftException e) {
- // TODO proper logging
+ OpenshiftUIActivator.log(
+ OpenshiftUIActivator.createErrorStatus("Could not get application by
name", e));
return false;
}
}
Show replies by date