Author: xcoulon
Date: 2012-02-23 15:24:02 -0500 (Thu, 23 Feb 2012)
New Revision: 39074
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPageModel.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
Log:
Fixed - JBIDE-10966
domain and appnames must only be lowercase
https://issues.jboss.org/browse/JBIDE-10966
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java 2012-02-23
20:23:52 UTC (rev 39073)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java 2012-02-23
20:24:02 UTC (rev 39074)
@@ -53,7 +53,8 @@
public static boolean isAlphaNumeric(String value) {
for (int i = 0; i < value.length(); ++i) {
- if (!Character.isLetterOrDigit(value.charAt(i))) {
+ final char c = value.charAt(i);
+ if (!Character.isLowerCase(c) && !Character.isDigit(c)) {
return false;
}
}
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-23
20:23:52 UTC (rev 39073)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-23
20:24:02 UTC (rev 39074)
@@ -348,14 +348,6 @@
}, newAppConfigurationGroup);
}
- private void resetExistingApplication() {
- try {
- pageModel.resetExistingApplication();
- } catch (OpenShiftException e) {
- OpenShiftUIActivator.log(e);
- }
- }
-
private void fillCartridgesCombo(DataBindingContext dbc, Combo cartridgesCombo) {
dbc.bindList(WidgetProperties.items().observe(cartridgesCombo),
BeanProperties.list(ApplicationConfigurationWizardPageModel.PROPERTY_CARTRIDGES).observe(pageModel),
@@ -796,7 +788,7 @@
}
if (!StringUtils.isAlphaNumeric(applicationName)) {
return ValidationStatus.error(
- "The name may only contain letters and numbers.");
+ "The name may only contain lower-case letters and digits.");
}
if (pageModel.isExistingApplication(applicationName)) {
return ValidationStatus.error(
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java 2012-02-23
20:23:52 UTC (rev 39073)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPage.java 2012-02-23
20:24:02 UTC (rev 39074)
@@ -11,7 +11,16 @@
package org.jboss.tools.openshift.express.internal.ui.wizard;
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.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
+import org.eclipse.jface.databinding.swt.ISWTObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizard;
@@ -19,19 +28,20 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.common.ui.databinding.DataBindingUtils;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
+import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
+import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
/**
* @author André Dietisheim
*/
public class EditDomainWizardPage extends AbstractOpenShiftWizardPage {
- private EditDomainWizardPageModel model;
+ private final EditDomainWizardPageModel pageModel;
- public EditDomainWizardPage(EditDomainWizardPageModel model, IWizard wizard) {
+ public EditDomainWizardPage(final EditDomainWizardPageModel pageModel, final IWizard
wizard) {
super("OpenShift Domain Edition", "Rename your domain",
"Domain Name Edition", wizard);
- this.model = model;
+ this.pageModel = pageModel;
}
protected void doCreateControls(Composite container, DataBindingContext dbc) {
@@ -48,13 +58,51 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(namespaceLabel);
Text namespaceText = new Text(domainGroup, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(namespaceText);
- DataBindingUtils.bindMandatoryTextField(namespaceText, "Domain",
EditDomainWizardPageModel.PROPERTY_NAMESPACE,
- model, dbc);
- }
+ ISWTObservableValue namespaceTextObservable = WidgetProperties.text(SWT.Modify)
+ .observe(namespaceText);
+ final NamespaceValidator namespaceValidator = new
NamespaceValidator(namespaceTextObservable);
+ dbc.addValidationStatusProvider(namespaceValidator);
+ ControlDecorationSupport.create(namespaceValidator, SWT.LEFT | SWT.TOP, null,
+ new CustomControlDecorationUpdater());
+ final IObservableValue namespaceModelObservable = BeanProperties.value(
+ EditDomainWizardPageModel.PROPERTY_NAMESPACE).observe(pageModel);
+ ValueBindingBuilder.bind(namespaceTextObservable).to(namespaceModelObservable).in(dbc);
+ }
+
@Override
protected void setupWizardPageSupport(DataBindingContext dbc) {
ParametrizableWizardPageSupport.create(IStatus.ERROR, this, dbc);
}
+
+ class NamespaceValidator extends MultiValidator {
+ private final ISWTObservableValue domainNameObservable;
+
+ public NamespaceValidator(ISWTObservableValue domainNameObservable) {
+ this.domainNameObservable = domainNameObservable;
+ }
+
+ @Override
+ protected IStatus validate() {
+ final String domainName = (String) domainNameObservable.getValue();
+ if (domainName.isEmpty()) {
+ return ValidationStatus.cancel(
+ "Select an alphanumerical name and a type for the domain to edit.");
+ }
+ if (!StringUtils.isAlphaNumeric(domainName)) {
+ return ValidationStatus.error(
+ "The name may only contain lower-case letters and digits.");
+ }
+ return ValidationStatus.ok();
+ }
+
+ @Override
+ public IObservableList getTargets() {
+ WritableList targets = new WritableList();
+ targets.add(domainNameObservable);
+ return targets;
+ }
+ }
+
}
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPageModel.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPageModel.java 2012-02-23
20:23:52 UTC (rev 39073)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EditDomainWizardPageModel.java 2012-02-23
20:24:02 UTC (rev 39074)
@@ -13,7 +13,6 @@
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
-import com.openshift.express.client.IDomain;
import com.openshift.express.client.IUser;
import com.openshift.express.client.OpenShiftException;
@@ -24,14 +23,17 @@
public class EditDomainWizardPageModel extends ObservableUIPojo {
public static final String PROPERTY_NAMESPACE = "namespace";
- public static final String PROPERTY_DOMAIN = "domain";
private String namespace;
- private IDomain domain;
+ private final IUser user;
+
public EditDomainWizardPageModel(IUser user) {
+ this.user = user;
try {
- setDomain(user.getDomain());
+ if (user.getDomain() != null) {
+ setNamespace(user.getDomain().getNamespace());
+ }
} catch (OpenShiftException e) {
Logger.error("Fail to retrieve OpenShift domain", e);
}
@@ -42,25 +44,15 @@
}
public void setNamespace(String namespace) {
- firePropertyChange(PROPERTY_NAMESPACE, this.namespace, this.namespace = namespace);
+ firePropertyChange(PROPERTY_NAMESPACE, this.namespace,
+ this.namespace = namespace);
}
- public boolean hasDomain() {
- return domain != null;
- }
-
- public IDomain getDomain() {
- return domain;
- }
-
- public void setDomain(IDomain domain) {
- firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
- if (domain != null) {
- setNamespace(domain.getNamespace());
+ public void renameDomain() throws OpenShiftException {
+ if (user.getDomain() != null) {
+ user.getDomain().setNamespace(namespace);
+ } else {
+ Logger.warn("Attempting to rename missing user domain...");
}
}
-
- public void renameDomain() throws OpenShiftException {
- domain.setNamespace(namespace);
- }
}
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-02-23
20:23:52 UTC (rev 39073)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-02-23
20:24:02 UTC (rev 39074)
@@ -17,11 +17,16 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
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.IValidator;
+import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
+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.ErrorDialog;
@@ -43,9 +48,9 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.common.ui.databinding.DataBindingUtils;
import org.jboss.tools.common.ui.databinding.MandatoryStringValidator;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
+import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
@@ -61,11 +66,11 @@
private static final String FILTEREXPRESSION_PUBLIC_SSH_KEY = "*.pub";
private static final String FILTERNAME_PUBLIC_SSH_KEY = "Public ssh key file
(*.pub)";
- private NewDomainWizardPageModel model;
+ private NewDomainWizardPageModel pageModel;
- public NewDomainWizardPage(NewDomainWizardPageModel model, IWizard wizard) {
+ public NewDomainWizardPage(NewDomainWizardPageModel pageModel, IWizard wizard) {
super("Domain Creation", "Create a new domain", "New
Domain", wizard);
- this.model = model;
+ this.pageModel = pageModel;
}
protected void doCreateControls(Composite container, DataBindingContext dbc) {
@@ -78,9 +83,20 @@
Text namespaceText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults()
.span(3, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(namespaceText);
- DataBindingUtils.bindMandatoryTextField(
+ ISWTObservableValue namespaceTextObservable = WidgetProperties.text(SWT.Modify)
+ .observe(namespaceText);
+ final NamespaceValidator namespaceValidator = new
NamespaceValidator(namespaceTextObservable);
+ dbc.addValidationStatusProvider(namespaceValidator);
+ ControlDecorationSupport.create(namespaceValidator, SWT.LEFT | SWT.TOP, null,
+ new CustomControlDecorationUpdater());
+ final IObservableValue namespaceModelObservable = BeanProperties.value(
+ EditDomainWizardPageModel.PROPERTY_NAMESPACE).observe(pageModel);
+ ValueBindingBuilder.bind(namespaceTextObservable).to(namespaceModelObservable).in(dbc);
+
+ /*DataBindingUtils.bindMandatoryTextField(
namespaceText, "Domain name", NewDomainWizardPageModel.PROPERTY_NAMESPACE,
model, dbc);
-
+ */
+
Label sshKeyLabel = new Label(container, SWT.NONE);
sshKeyLabel.setText("SSH Public Key");
GridDataFactory.fillDefaults()
@@ -90,13 +106,13 @@
.align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sshKeyText);
Binding sshKeyTextBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(sshKeyText),
- BeanProperties.value(NewDomainWizardPageModel.PROPERTY_SSHKEY).observe(model),
+ BeanProperties.value(NewDomainWizardPageModel.PROPERTY_SSHKEY).observe(pageModel),
new UpdateValueStrategy().setAfterGetValidator(new MandatoryStringValidator(
"You have to select a ssh public key")),
new UpdateValueStrategy().setAfterGetValidator(new SSHKeyValidator()));
ControlDecorationSupport.create(sshKeyTextBinding, SWT.TOP | SWT.LEFT);
try {
- model.initSshKey();
+ pageModel.initSshKey();
} catch (OpenShiftException ex) {
IStatus status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
"Could check your ssh keys", ex);
@@ -134,10 +150,10 @@
public void widgetSelected(SelectionEvent e) {
try {
- if (model.libraPublicKeyExists()) {
+ if (pageModel.libraPublicKeyExists()) {
MessageDialog.openInformation(getShell(),
"Libra Key already present",
- "You already have a key at \"" + model.getLibraPublicKey() +
"\". Please move it or use it.");
+ "You already have a key at \"" + pageModel.getLibraPublicKey() +
"\". Please move it or use it.");
return;
}
@@ -145,7 +161,7 @@
if (Dialog.OK == dialog.open()) {
try {
String passPhrase = dialog.getValue();
- model.createLibraKeyPair(passPhrase);
+ pageModel.createLibraKeyPair(passPhrase);
} catch (FileNotFoundException ex) {
IStatus status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
"Could not read the ssh key folder", ex);
@@ -183,7 +199,7 @@
dialog.setFilterExtensions(new String[] { FILTEREXPRESSION_PUBLIC_SSH_KEY });
String sshKeyPath = dialog.open();
if (sshKeyPath != null) {
- model.setSshKey(sshKeyPath);
+ pageModel.setSshKey(sshKeyPath);
}
}
};
@@ -245,5 +261,35 @@
return false;
}
}
+
+ private class NamespaceValidator extends MultiValidator {
+ private final ISWTObservableValue domainNameObservable;
+
+ public NamespaceValidator(ISWTObservableValue domainNameObservable) {
+ this.domainNameObservable = domainNameObservable;
+ }
+
+ @Override
+ protected IStatus validate() {
+ final String domainName = (String) domainNameObservable.getValue();
+ if (domainName.isEmpty()) {
+ return ValidationStatus.cancel(
+ "Select an alphanumerical name and a type for the domain to edit.");
+ }
+ if (!StringUtils.isAlphaNumeric(domainName)) {
+ return ValidationStatus.error(
+ "The name may only contain lower-case letters and digits.");
+ }
+ return ValidationStatus.ok();
+ }
+
+ @Override
+ public IObservableList getTargets() {
+ WritableList targets = new WritableList();
+ targets.add(domainNameObservable);
+ return targets;
+ }
+ }
+
}
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2012-02-23
20:23:52 UTC (rev 39073)
+++
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPageModel.java 2012-02-23
20:24:02 UTC (rev 39074)
@@ -37,7 +37,6 @@
public static final String PROPERTY_NAMESPACE = "namespace";
public static final String PROPERTY_SSHKEY = "sshKey";
- public static final String PROPERTY_DOMAIN = "domain";
private String namespace;
private IDomain domain;
@@ -88,7 +87,6 @@
public void createDomain() throws OpenShiftException, IOException {
IDomain domain = user.createDomain(namespace, loadSshKey());
- setDomain(domain);
}
public String getSshKey() {
@@ -156,10 +154,4 @@
return domain;
}
- public void setDomain(IDomain domain) {
- firePropertyChange(PROPERTY_DOMAIN, this.domain, this.domain = domain);
- if (domain != null) {
- setNamespace(domain.getNamespace());
- }
- }
}