[jbosstools-commits] JBoss Tools SVN: r42488 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Jul 10 11:22:20 EDT 2012
Author: adietish
Date: 2012-07-10 11:22:19 -0400 (Tue, 10 Jul 2012)
New Revision: 42488
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPageModel.java
Log:
[JBIDE-12306] resetting wizard models when user switches openshift user in the application wizard
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -36,6 +36,7 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.fieldassist.AutoCompleteField;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
@@ -161,6 +162,9 @@
ValueBindingBuilder.bind(existingAppNameTextObservable).to(existingAppNameModelObservable).in(dbc);
UIUtils.focusOnSelection(useExistingAppBtn, existingAppNameText);
createExistingAppNameContentAssist();
+ useExistingAppBtnSelection.addValueChangeListener(
+ onUseExistingApplication(
+ newAppConfigurationGroup, existingAppNameText, browseAppsButton));
this.browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
browseAppsButton.setText("Browse...");
@@ -236,11 +240,6 @@
GridDataFactory.fillDefaults()
.grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(newAppConfigurationGroup);
- IObservableValue useExistingApplication = WidgetProperties.selection().observe(useExistingAppBtn);
- useExistingApplication.addValueChangeListener(
- onUseExistingApplication(
- newAppConfigurationGroup, existingAppNameText, browseAppsButton));
-
final Label newAppNameLabel = new Label(newAppConfigurationGroup, SWT.NONE);
newAppNameLabel.setText("Name:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(newAppNameLabel);
@@ -662,24 +661,33 @@
@Override
protected void onPageActivated(final DataBindingContext dbc) {
if (ensureHasDomain()) {
- new Thread() {
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- loadOpenshiftResources(dbc);
- enableApplicationWidgets(pageModel.isUseExistingApplication());
- createExistingAppNameContentAssist();
- // this is needed because of weird issues with UI
- // not reacting to model changes while wizard
- // runnable is run. We force another update
- dbc.updateModels();
- }
- });
- }
- }.start();
+ enableApplicationWidgets(pageModel.isUseExistingApplication());
+ createExistingAppNameContentAssist();
+ // this is needed because of weird issues with UI
+ // not reacting to model changes while wizard
+ // runnable is run. We force another update
+ // dbc.updateModels();
+ this.newAppNameText.setFocus();
}
}
+ @Override
+ protected void onPageWillGetActivated(Direction direction, PageChangingEvent event, DataBindingContext dbc) {
+ if (direction == Direction.FORWARDS) {
+ try {
+ pageModel.reset();
+ // needs to be done before loading resources,
+ // otherwise: dbc.updateModels() will be
+ // called and old data could be restored
+ loadOpenshiftResources(dbc);
+ dbc.updateTargets();
+ setPageComplete(false);
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to reset page fields", e);
+ }
+ }
+ }
+
/**
* Checks that the user has a domain, opens the creation dialog in case he
* hasn't, closes the wizard if the user does not create a domain (required
@@ -709,66 +717,25 @@
return true;
}
- /**
- *
- * @return private boolean ensureHasSshKey() {
- *
- * }
- */
-
protected void loadOpenshiftResources(final DataBindingContext dbc) {
try {
- WizardUtils.runInWizard(new Job("Loading existing applications...") {
+ WizardUtils.runInWizard(new Job("Loading applications, cartridges and gears...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
+ monitor.setTaskName("Loading existing applications...");
pageModel.loadExistingApplications();
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- return Status.OK_STATUS;
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load applications", e);
- }
- }
-
- }, getContainer(), dbc);
-
- WizardUtils.runInWizard(new Job("Loading application cartridges...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
+ monitor.setTaskName("Loading application cartridges...");
pageModel.loadStandaloneCartridges();
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- return Status.OK_STATUS;
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load application cartridges", e);
- }
- }
- }, getContainer(), dbc);
- WizardUtils.runInWizard(new Job("Loading embeddable cartridges...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
+ monitor.setTaskName("Loading embeddable cartridges...");
setViewerInput(pageModel.loadEmbeddedCartridges());
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- return Status.OK_STATUS;
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load embeddable cartridges", e);
- }
- }
- }, getContainer(), dbc);
- WizardUtils.runInWizard(new Job("Loading gear sizes...") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
+ monitor.setTaskName("Loading gear profiles...");
pageModel.loadGearProfiles();
return Status.OK_STATUS;
} catch (NotFoundOpenShiftException e) {
return Status.OK_STATUS;
} catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus("Could not load gear sizes", e);
+ return OpenShiftUIActivator.createErrorStatus("Could not load applications, cartridges and gears", e);
}
}
}, getContainer(), dbc);
@@ -821,14 +788,6 @@
return ValidationStatus.ok();
}
-
- @Override
- public IObservableList getTargets() {
- WritableList targets = new WritableList();
- targets.add(existingAppNameTextObservable);
- return targets;
- }
-
}
class NewApplicationNameValidator extends MultiValidator {
@@ -862,13 +821,6 @@
}
return ValidationStatus.ok();
}
-
- @Override
- public IObservableList getTargets() {
- WritableList targets = new WritableList();
- targets.add(applicationNameObservable);
- return targets;
- }
}
/**
@@ -879,18 +831,18 @@
*/
class NewApplicationTypeValidator extends MultiValidator {
- private final IObservableValue useExistingAppBtnbservable;
+ private final IObservableValue useExistingAppBtnObservable;
private final IObservableValue selectedApplicationTypeObservable;
public NewApplicationTypeValidator(IObservableValue useExistingAppBtnbservable,
IObservableValue selectedApplicationTypeObservable) {
- this.useExistingAppBtnbservable = useExistingAppBtnbservable;
+ this.useExistingAppBtnObservable = useExistingAppBtnbservable;
this.selectedApplicationTypeObservable = selectedApplicationTypeObservable;
}
@Override
protected IStatus validate() {
- final boolean useExistingApp = (Boolean) useExistingAppBtnbservable.getValue();
+ final boolean useExistingApp = (Boolean) useExistingAppBtnObservable.getValue();
final Integer selectedCartridgeIndex = (Integer) selectedApplicationTypeObservable.getValue();
if (useExistingApp) {
return ValidationStatus.ok();
@@ -901,13 +853,6 @@
}
return ValidationStatus.ok();
}
-
- @Override
- public IObservableList getTargets() {
- WritableList targets = new WritableList();
- targets.add(selectedApplicationTypeObservable);
- return targets;
- }
}
@Override
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -325,7 +325,10 @@
public void setExistingApplication(IApplication application) throws OpenShiftException {
if (application != null) {
setExistingApplicationName(application.getName());
- doSetExistingApplication(application);
+ // already called within setExistingApplicationName(String) above
+ // doSetExistingApplication(application);
+ } else {
+ setExistingApplicationName(null);
}
}
@@ -353,10 +356,6 @@
}
}
- public void resetExistingApplication() throws OpenShiftException, SocketTimeoutException {
- setExistingApplication((IApplication) null);
- }
-
public void setApplicationName(String applicationName) {
firePropertyChange(PROPERTY_APPLICATION_NAME
, wizardModel.getApplicationName()
@@ -426,4 +425,12 @@
public IDomain getDomain() throws SocketTimeoutException, OpenShiftException {
return wizardModel.getUser().getDefaultDomain();
}
+
+ public void reset() throws OpenShiftException {
+ setApplicationName(wizardModel.getApplication());
+ setExistingApplication(wizardModel.getApplication());
+ setUseExistingApplication(wizardModel.isUseExistingApplication());
+ setSelectedEmbeddableCartridges(wizardModel.getSelectedEmbeddableCartridges());
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -24,6 +24,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizardPage;
@@ -224,6 +225,14 @@
enableWidgets(pageModel.isNewProject());
}
+ @Override
+ protected void onPageWillGetActivated(Direction direction, PageChangingEvent event, DataBindingContext dbc) {
+ if (direction == Direction.FORWARDS) {
+ pageModel.reset();
+ dbc.updateTargets();
+ }
+ }
+
private void enableWidgets(boolean isNewProject) {
if (isNewProject) {
useDefaultRepoPathButton.setEnabled(true);
@@ -279,14 +288,6 @@
}
return ValidationStatus.ok();
}
-
- @Override
- public IObservableList getTargets() {
- WritableList targets = new WritableList();
- targets.add(repoPathObservable);
- return targets;
- }
-
}
/**
@@ -340,19 +341,15 @@
}
Repository repository = EGitUtils.getRepository(project);
+ if (repository == null) {
+ return false;
+ }
return EGitUtils.hasRemote(remoteName, repository);
} catch (Exception e) {
OpenShiftUIActivator.log(OpenShiftUIActivator.createErrorStatus(e.getMessage(), e));
return false;
}
}
-
- @Override
- public IObservableList getTargets() {
- WritableList targets = new WritableList();
- targets.add(remoteNameObservable);
- return targets;
- }
}
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -174,4 +174,8 @@
return useDefaultRemoteName;
}
+ public void reset() {
+ setRemoteName(wizardModel.getRemoteName());
+ setRepositoryPath(wizardModel.getRepositoryPath());
+ }
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -40,7 +40,10 @@
protected HashMap<String, Object> dataModel = new HashMap<String, Object>();
private static final String KEY_SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges";
-
+ private static final String DEFAULT_APPLICATION = "default_application";
+ private static final String DEFAULT_PROJECT = "default_project";
+ private static final String DEFAULT_USE_EXISTING_APPLICATION = "default_useExistingApplication";
+
public OpenShiftExpressApplicationWizardModel(UserDelegate user) {
this(user, null, null, false);
}
@@ -48,15 +51,10 @@
public OpenShiftExpressApplicationWizardModel(UserDelegate user, IProject project, IApplication application,
boolean useExistingApplication) {
// default value(s)
+ setDefaultProject(project);
+ setDefaultApplication(application);
+ setDefaultUseExistingApplication(useExistingApplication);
setUser(user);
- setProject(project);
- setNewProject(true);
- setApplication(application);
- setUseExistingApplication(useExistingApplication);
- setCreateServerAdapter(true);
- setRepositoryPath(DEFAULT_REPOSITORY_PATH);
- setRemoteName(NEW_PROJECT_REMOTE_NAME_DEFAULT);
- setServerType(ServerCore.findServerType(ExpressServerUtils.OPENSHIFT_SERVER_TYPE));
}
/**
@@ -202,6 +200,15 @@
return (IApplication) getProperty(APPLICATION);
}
+ public void setDefaultApplication(IApplication application) {
+ setProperty(DEFAULT_APPLICATION, application);
+ setApplication(application);
+ }
+
+ public IApplication getDefaultApplication() {
+ return (IApplication) getProperty(DEFAULT_APPLICATION);
+ }
+
@Override
public void setApplication(IApplication application) {
setProperty(APPLICATION, application);
@@ -259,6 +266,16 @@
return (String) setProperty(PROJECT_NAME, projectName);
}
+ public IProject setDefaultProject(IProject project) {
+ setProperty(DEFAULT_PROJECT, project);
+ setProject(project);
+ return project;
+ }
+
+ public IProject getDefaultProject() {
+ return (IProject) getProperty(DEFAULT_PROJECT);
+ }
+
@Override
public IProject setProject(IProject project) {
if (project != null && project.exists()) {
@@ -331,6 +348,20 @@
return (Boolean) getProperty(USE_EXISTING_APPLICATION);
}
+ public boolean setDefaultUseExistingApplication(boolean useExistingApplication) {
+ setProperty(DEFAULT_USE_EXISTING_APPLICATION, useExistingApplication);
+ setUseExistingApplication(useExistingApplication);
+ return useExistingApplication;
+ }
+
+ public boolean getDefaultUseExistingApplication() {
+ Object useExistingApp = getProperty(DEFAULT_USE_EXISTING_APPLICATION);
+ if (useExistingApp != null) {
+ return (Boolean) useExistingApp;
+ }
+ return false;
+ }
+
@Override
public boolean setUseExistingApplication(boolean useExistingApplication) {
Boolean isUseExistingApplication = (Boolean) setProperty(USE_EXISTING_APPLICATION, useExistingApplication);
@@ -433,10 +464,22 @@
@Override
public UserDelegate setUser(UserDelegate user) {
- UserDelegate oldValue = (UserDelegate) getProperty(USER);
- return (UserDelegate) setProperty(USER, user);
+ setProperty(USER, user);
+ resetWizardModel();
+ return user;
}
+ public void resetWizardModel() {
+ setApplication(getDefaultApplication());
+ setUseExistingApplication(getDefaultUseExistingApplication());
+ setSelectedEmbeddableCartridges(new HashSet<IEmbeddableCartridge>());
+ setNewProject(true);
+ setCreateServerAdapter(true);
+ setRepositoryPath(IOpenShiftExpressWizardModel.DEFAULT_REPOSITORY_PATH);
+ setRemoteName(IOpenShiftExpressWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT);
+ setServerType(ServerCore.findServerType(ExpressServerUtils.OPENSHIFT_SERVER_TYPE));
+ }
+
@Override
public void addUserToModel() {
UserDelegate user = getUser();
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -15,8 +15,6 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.list.IObservableList;
-import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.resources.IProject;
@@ -27,6 +25,7 @@
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.fieldassist.AutoCompleteField;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
@@ -301,18 +300,19 @@
}
return status;
}
-
- @Override
- public IObservableList getTargets() {
- WritableList targets = new WritableList();
- targets.add(projectNameObservable);
- return targets;
- }
}
@Override
+ protected void onPageWillGetActivated(Direction direction, PageChangingEvent event, DataBindingContext dbc) {
+ if (direction == Direction.FORWARDS) {
+ pageModel.reset();
+ }
+ }
+
+ @Override
protected void onPageActivated(DataBindingContext dbc) {
setPageTitle();
+ dbc.updateTargets();
}
private void setPageTitle() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPageModel.java 2012-07-10 14:44:38 UTC (rev 42487)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPageModel.java 2012-07-10 15:22:19 UTC (rev 42488)
@@ -85,4 +85,10 @@
public String getApplicationName() {
return wizardModel.getApplicationName();
}
+
+ public void reset() {
+ setNewProject(!wizardModel.isExistingProject());
+ setProjectName(wizardModel.getProjectName());
+ setCreateServerAdapter(wizardModel.isCreateServerAdapter());
+ }
}
More information about the jbosstools-commits
mailing list