Author: xcoulon
Date: 2012-05-10 16:53:59 -0400 (Thu, 10 May 2012)
New Revision: 40928
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/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/IOpenShiftExpressWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
Log:
Fixed - JBIDE-11298
Git clone destination folder is not validated
Fixed - JBIDE-11141
Set the "location" field to the existing project location in the import 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-05-10
20:24:25 UTC (rev 40927)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-05-10
20:53:59 UTC (rev 40928)
@@ -291,13 +291,7 @@
dbc.addValidationStatusProvider(newApplicationNameValidator);
ControlDecorationSupport.create(
newApplicationNameValidator, SWT.LEFT | SWT.TOP, null, new
CustomControlDecorationUpdater());
- final NewApplicationTypeValidator newApplicationTypeValidator =
- new NewApplicationTypeValidator(useExistingAppBtnSelection,
selectedCartridgeComboObservable);
- dbc.addValidationStatusProvider(newApplicationTypeValidator);
- ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT | SWT.TOP, null,
- new CustomControlDecorationUpdater());
-
- // gear size
+ // gear profile
final Label gearProfileLabel = new Label(newAppConfigurationGroup, SWT.NONE);
gearProfileLabel.setText("Gear profile:");
GridDataFactory.fillDefaults()
@@ -306,11 +300,11 @@
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false).applyTo(gearProfilesCombo);
fillGearProfilesCombo(dbc, gearProfilesCombo);
- final ISWTObservableValue gearSizeComboObservable =
+ final ISWTObservableValue selectedGearProfileComboObservable =
WidgetProperties.selection().observe(gearProfilesCombo);
final IObservableValue selectedGearProfileModelObservable = BeanProperties.value(
ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_GEAR_PROFILE).observe(pageModel);
- ValueBindingBuilder.bind(gearSizeComboObservable)
+ ValueBindingBuilder.bind(selectedGearProfileComboObservable)
.converting(new StringToGearProfileConverter())
.to(selectedGearProfileModelObservable)
.converting(new GearProfileToStringConverter())
@@ -327,6 +321,12 @@
.to(enableScalingModelObservable).converting(new
ApplicationScaleToBooleanConverter())
.in(dbc);
+ final NewApplicationTypeValidator newApplicationTypeValidator =
+ new NewApplicationTypeValidator(useExistingAppBtnSelection,
selectedCartridgeComboObservable);
+ dbc.addValidationStatusProvider(newApplicationTypeValidator);
+ ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT | SWT.TOP, null,
+ new CustomControlDecorationUpdater());
+
// embeddable cartridges
this.newAppEmbeddableCartridgesGroup = new Group(newAppConfigurationGroup, SWT.NONE);
newAppEmbeddableCartridgesGroup.setText("Embeddable Cartridges");
@@ -849,25 +849,30 @@
}
}
+ /**
+ * Validates that the new application type is selected
+ * @author Xavier Coulon
+ *
+ */
class NewApplicationTypeValidator extends MultiValidator {
private final IObservableValue useExistingAppBtnbservable;
- private final IObservableValue selectedCartridgeObservable;
+ private final IObservableValue selectedApplicationTypeObservable;
public NewApplicationTypeValidator(IObservableValue useExistingAppBtnbservable,
- IObservableValue selectedCartridgeObservable) {
+ IObservableValue selectedApplicationTypeObservable) {
this.useExistingAppBtnbservable = useExistingAppBtnbservable;
- this.selectedCartridgeObservable = selectedCartridgeObservable;
+ this.selectedApplicationTypeObservable = selectedApplicationTypeObservable;
}
@Override
protected IStatus validate() {
final boolean useExistingApp = (Boolean) useExistingAppBtnbservable.getValue();
- final String cartridge = (String) selectedCartridgeObservable.getValue();
+ final String applicationType = (String) selectedApplicationTypeObservable.getValue();
if (useExistingApp) {
return ValidationStatus.ok();
}
- if (StringUtils.isEmpty(cartridge)) {
+ if (StringUtils.isEmpty(applicationType)) {
return ValidationStatus.cancel(getDescription());
}
return ValidationStatus.ok();
@@ -876,7 +881,7 @@
@Override
public IObservableList getTargets() {
WritableList targets = new WritableList();
- targets.add(selectedCartridgeObservable);
+ targets.add(selectedApplicationTypeObservable);
return targets;
}
}
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-05-10
20:24:25 UTC (rev 40927)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-05-10
20:53:59 UTC (rev 40928)
@@ -122,12 +122,11 @@
// 'Use default location' option.
UIUtils.focusOnSelection(useDefaultRepoPathButton, repoPathText);
- dbc.addValidationStatusProvider(
- new RepoPathValidationStatusProvider(
- isDefaultRepoObservable
- , repoPathObservable
- ,
BeanProperties.value(GitCloningSettingsWizardPageModel.PROPERTY_APPLICATION_NAME).observe(
- pageModel)));
+ final IObservableValue applicationNameModelObservable = BeanProperties.value(
+ GitCloningSettingsWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel);
+
+ dbc.addValidationStatusProvider(new
RepoPathValidationStatusProvider(repoPathObservable,
+ applicationNameModelObservable));
// Remote Name Management
useDefaultRemoteNameButton = new Button(cloneGroup, SWT.CHECK);
@@ -240,47 +239,32 @@
*/
class RepoPathValidationStatusProvider extends MultiValidator {
- private final IObservableValue isDefaultRepoPathObservable;
private final IObservableValue repoPathObservable;
- private IObservableValue applicationNameObservable;
+ private final IObservableValue applicationNameModelObservable;
- public RepoPathValidationStatusProvider(IObservableValue isDefaultRepoPathObservable,
- IObservableValue repoPathObservable, IObservableValue applicationNameObservable) {
- this.isDefaultRepoPathObservable = isDefaultRepoPathObservable;
+ public RepoPathValidationStatusProvider(IObservableValue repoPathObservable,
+ IObservableValue applicationNameModelObservable) {
this.repoPathObservable = repoPathObservable;
- this.applicationNameObservable = applicationNameObservable;
+ this.applicationNameModelObservable = applicationNameModelObservable;
}
+ // Validator is also be called when application name is set..
@Override
protected IStatus validate() {
- Boolean isDefaultRepoPath = (Boolean) isDefaultRepoPathObservable.getValue();
- String repoPath = (String) repoPathObservable.getValue();
- String applicationName = (String) applicationNameObservable.getValue();
-
- // skip the validation if the user wants to create a new project.
- // The
- // name and state of the existing project do
- // not matter...
- if (applicationName == null
- || applicationName.length() == 0) {
- return OpenShiftUIActivator
- .createCancelStatus("You have to choose an application name / existing
application");
+ final String repoPath = (String) repoPathObservable.getValue();
+ final String applicationName = (String) applicationNameModelObservable.getValue();
+
+ final IPath repoResourcePath = new Path(repoPath);
+ if (repoResourcePath.isEmpty()
+ || !repoResourcePath.isAbsolute()
+ || !repoResourcePath.toFile().canWrite()) {
+ return OpenShiftUIActivator.createErrorStatus("The location '" +
repoResourcePath.toOSString() + "' does not exist or is not writeable.");
}
-
- if (isDefaultRepoPath == null
- || !isDefaultRepoPath) {
- final IPath repoResourcePath = new Path(repoPath);
- if (repoResourcePath.isEmpty()
- || !repoResourcePath.isAbsolute()
- || !repoResourcePath.toFile().canWrite()) {
- return OpenShiftUIActivator.createErrorStatus("The path does not exist or is
not writeable.");
- }
- final IPath applicationPath = repoResourcePath.append(new Path(applicationName));
- if (applicationPath.toFile().exists()) {
- return OpenShiftUIActivator.createErrorStatus(
- NLS.bind("The location \"{0}\" already contains a folder named
\"{1}\"",
- repoResourcePath.toOSString(), applicationName));
- }
+ final IPath applicationPath = applicationName != null ? repoResourcePath.append(new
Path(applicationName)) : null;
+ if (applicationPath != null && applicationPath.toFile().exists()) {
+ return OpenShiftUIActivator.createErrorStatus(
+ NLS.bind("The location \"{0}\" already contains a folder named
\"{1}\"",
+ repoResourcePath.toOSString(), applicationName));
}
return ValidationStatus.ok();
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-05-10
20:24:25 UTC (rev 40927)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-05-10
20:53:59 UTC (rev 40928)
@@ -44,33 +44,63 @@
public GitCloningSettingsWizardPageModel(IOpenShiftExpressWizardModel wizardModel) {
this.wizardModel = wizardModel;
wizardModel.addPropertyChangeListener(IOpenShiftExpressWizardModel.APPLICATION_NAME,
onWizardApplicationNameChanged());
+ wizardModel.addPropertyChangeListener(IOpenShiftExpressWizardModel.PROJECT_NAME,
onWizardProjectNameChanged());
+ wizardModel.addPropertyChangeListener(IOpenShiftExpressWizardModel.NEW_PROJECT,
onWizardProjectNameChanged());
setRepositoryPath(getDefaultRepositoryPath());
}
+
+ /**
+ * Listener to propagate the application name changes from the underlying WizardModel
into this WizardPageModel, so that properties can be affected here, too.
+ * @return
+ */
private PropertyChangeListener onWizardApplicationNameChanged() {
return new PropertyChangeListener() {
-
@Override
public void propertyChange(PropertyChangeEvent evt) {
firePropertyChange(PROPERTY_APPLICATION_NAME, evt.getOldValue(), evt.getNewValue());
+ if(wizardModel.isNewProject() && isUseDefaultRepoPath()) {
+ setRepositoryPath(IOpenShiftExpressWizardModel.DEFAULT_REPOSITORY_PATH);
+ }
}
};
}
+ /**
+ * Listener to propagate the project name changes from the underlying WizardModel into
this WizardPageModel, so that properties can be affected here, too.
+ * @return
+ */
+ private PropertyChangeListener onWizardProjectNameChanged() {
+ return new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if(!wizardModel.isNewProject() && isUseDefaultRepoPath()) {
+ final IProject project = wizardModel.getProject();
+ if(project != null && project.exists()) {
+ setRepositoryPath(project.getLocation().toOSString());
+ } else {
+ setRepositoryPath("");
+ }
+ }
+ }
+ };
+ }
+
public boolean isNewProject() {
return wizardModel.isNewProject();
}
- public void setApplicationName(String name) {
+
+ /*public void setApplicationName(String name) {
firePropertyChange(PROPERTY_APPLICATION_NAME
, wizardModel.getApplicationName()
, wizardModel.setApplicationName(name));
- }
+ }*/
public String getApplicationName() {
return wizardModel.getApplicationName();
}
-
+
public boolean isJBossAS7Application() {
IApplication application = wizardModel.getApplication();
if (application == null) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java 2012-05-10
20:24:25 UTC (rev 40927)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftExpressWizardModel.java 2012-05-10
20:53:59 UTC (rev 40928)
@@ -204,4 +204,6 @@
ApplicationScale setApplicationScale(final ApplicationScale scale);
+ IProject getProject();
+
}
\ No newline at end of file
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-05-10
20:24:25 UTC (rev 40927)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-05-10
20:53:59 UTC (rev 40928)
@@ -297,7 +297,12 @@
return EGitUtils.isSharedWithGit(getProject());
}
- private IProject getProject() {
+ @Override
+ public IProject getProject() {
+ String projectName = getProjectName();
+ if(projectName == null || projectName.isEmpty()) {
+ return null;
+ }
return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
}