Author: adietish
Date: 2012-03-21 10:53:37 -0400 (Wed, 21 Mar 2012)
New Revision: 39709
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
Log:
[JBIDE-11240] making sure selecting application by name and by instance behaves the same
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-03-21
14:48:53 UTC (rev 39708)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-03-21
14:53:37 UTC (rev 39709)
@@ -20,6 +20,7 @@
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.ICartridge;
@@ -48,7 +49,7 @@
// start with a null value as a marker of non-initialized state (used during
// first pass validation)
- private List<IApplication> existingApplications = null;
+ private List<IApplication> existingApplications = new
ArrayList<IApplication>();
private List<ICartridge> cartridges = new ArrayList<ICartridge>();
private List<IEmbeddableCartridge> embeddableCartridges = new
ArrayList<IEmbeddableCartridge>();
private String existingApplicationName;
@@ -111,21 +112,24 @@
return existingApplicationName;
}
+ /**
+ * Sets the existing application in this model by name. If there's an
+ * existing application with the given name, all properties related to an
+ * existing application are also set.
+ *
+ * @param applicationName
+ * @throws OpenShiftException
+ *
+ * @see #doSetExistingApplication(IApplication)
+ */
public void setExistingApplicationName(String applicationName) throws OpenShiftException
{
firePropertyChange(PROPERTY_EXISTING_APPLICATION_NAME
- , existingApplicationName
- , this.existingApplicationName = applicationName);
- if (applicationName != null) {
- for (IApplication application : getApplications()) {
- if (application.getName().equals(applicationName)) {
- setApplicationName(application.getName());
- setSelectedCartridge(application.getCartridge());
- setSelectedEmbeddableCartridges(new HashSet<IEmbeddableCartridge>(
- application.getEmbeddedCartridges()));
- }
- }
+ , this.existingApplicationName, this.existingApplicationName = applicationName);
+
+ if (!StringUtils.isEmpty(applicationName)
+ && isExistingApplication(applicationName)) {
+ doSetExistingApplication(getExistingApplication(applicationName));
}
-
}
public void loadExistingApplications() throws OpenShiftException {
@@ -146,15 +150,19 @@
return existingApplicationsLoaded;
}
- public boolean isExistingApplication(String applicationName) {
+ public IApplication getExistingApplication(String applicationName) {
for (IApplication application : getExistingApplications()) {
if (application.getName().equalsIgnoreCase(applicationName)) {
- return true;
+ return application;
}
}
- return false;
+ return null;
}
+ public boolean isExistingApplication(String applicationName) {
+ return getExistingApplication(applicationName) != null;
+ }
+
/**
* @param existingApplications
* the existingApplications to set
@@ -215,9 +223,40 @@
return cartridges;
}
+ /**
+ * Sets the properties in this model that are related to an existing
+ * application. The name of the existing application is set!.
+ *
+ * @param application
+ * @throws OpenShiftException
+ *
+ * @see #setExistingApplicationName(String)
+ * @see #setApplicationName(IApplication)
+ * @see #setSelectedCartridge(IApplication)
+ * @see #setSelectedEmbeddableCartridges(Set)
+ * @see #wizardModel#setApplication
+ */
public void setExistingApplication(IApplication application) throws OpenShiftException
{
- if(application != null) {
+ if (application != null) {
setExistingApplicationName(application.getName());
+ doSetExistingApplication(application);
+ }
+ }
+
+ /**
+ * Sets the properties in this model that are related to an existing
+ * application. It does not set the name of the existing application!.
+ *
+ * @param application
+ * @throws OpenShiftException
+ *
+ * @see #setApplicationName(IApplication)
+ * @see #setSelectedCartridge(IApplication)
+ * @see #setSelectedEmbeddableCartridges(Set)
+ * @see #wizardModel#setApplication
+ */
+ protected void doSetExistingApplication(IApplication application) throws
OpenShiftException {
+ if (application != null) {
setApplicationName(application.getName());
setSelectedCartridge(application.getCartridge());
setSelectedEmbeddableCartridges(new
HashSet<IEmbeddableCartridge>(application.getEmbeddedCartridges()));
@@ -225,6 +264,7 @@
}
}
+
public void resetExistingApplication() throws OpenShiftException {
setExistingApplication(null);
}
Show replies by date