Author: elvisisking
Date: 2012-05-31 12:47:55 -0400 (Thu, 31 May 2012)
New Revision: 41584
Modified:
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
branches/jbosstools-3.3.x/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
Log:
JBIDE-12056 Exception Adding/Editing Property Definition's Value Constraint In CND
Editor. Problem was that a value constraint was being added to an unmodifiable list. Fixed
that as well as an issue when the value constraint was empty. Fixed same issues with
adding/editing default values.
Modified:
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
===================================================================
---
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-05-31
16:08:12 UTC (rev 41583)
+++
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-05-31
16:47:55 UTC (rev 41584)
@@ -163,6 +163,11 @@
public static String emptyValue;
/**
+ * A message indicating a property definition's value constraint is empty.
+ */
+ public static String emptyValueConstraint;
+
+ /**
* A message indicating a property definition is missing value constraints. One
parameter, the property definition name, is
* required.
*/
Modified:
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
---
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-05-31
16:08:12 UTC (rev 41583)
+++
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-05-31
16:47:55 UTC (rev 41584)
@@ -1629,7 +1629,11 @@
* @return the status (never <code>null</code>)
*/
public static ValidationStatus validateValueConstraint( final String constraint ) {
- Utils.verifyIsNotEmpty(constraint, "constraint"); //$NON-NLS-1$
+ try {
+ Utils.verifyIsNotEmpty(constraint, "constraint"); //$NON-NLS-1$
+ } catch (IllegalArgumentException e) {
+ return
ValidationStatus.createErrorMessage(StatusCodes.EMPTY_VALUE_CONSTRAINT,
Messages.emptyValueConstraint);
+ }
// TODO implement validateValueConstraint to make sure constraint is property
syntax
return ValidationStatus.OK_STATUS;
@@ -1789,6 +1793,7 @@
int EMPTY_VALUE_CONSTRAINTS = 285;
int DUPLICATE_VALUE_CONSTRAINT = 290;
int VALUE_CONSTRAINTS_EXIST_BUT_MARKED_AS_VARIANT = 295;
+ int EMPTY_VALUE_CONSTRAINT = 300;
}
}
Modified:
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
===================================================================
---
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-05-31
16:08:12 UTC (rev 41583)
+++
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-05-31
16:47:55 UTC (rev 41584)
@@ -57,6 +57,7 @@
emptyUnqualifiedName = The {0} has an empty unqualified name.
# 0 = property or attribute name of a node type definition, property definition, or child
node definition
emptyValue = A "{0}" value cannot be empty
+emptyValueConstraint = The value constraint cannot be empty.
# 0 = property definition name
emptyValueConstraints = The property definition "{0}" must have at least one
value constraint.
# 0 = property value, 1 = property type, 2 = property name
Modified:
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
===================================================================
---
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-05-31
16:08:12 UTC (rev 41583)
+++
branches/jbosstools-3.3.x/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-05-31
16:47:55 UTC (rev 41584)
@@ -57,6 +57,7 @@
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.jboss.tools.modeshape.jcr.ItemOwnerProvider;
import org.jboss.tools.modeshape.jcr.Messages;
+import org.jboss.tools.modeshape.jcr.MultiValidationStatus;
import org.jboss.tools.modeshape.jcr.PropertyDefinition;
import org.jboss.tools.modeshape.jcr.PropertyDefinition.PropertyName;
import org.jboss.tools.modeshape.jcr.QualifiedName;
@@ -1134,8 +1135,12 @@
// check for duplicate
currentDefaultValues.add(newValue);
- return CndValidator.validateDefaultValues(propDefn.getName(),
propDefn.getType(), currentDefaultValues,
-
accessExistingNamespacePrefixes());
+ MultiValidationStatus validationStatus =
CndValidator.validateDefaultValues(propDefn.getName(),
+
propDefn.getType(),
+
currentDefaultValues,
+
accessExistingNamespacePrefixes());
+ currentDefaultValues.remove(newValue);
+ return validationStatus;
}
};
@@ -1158,7 +1163,7 @@
void handleAddValueConstraint() {
final PropertyDefinition propDefn = getPropertyDefinition();
- final Collection<String> currentConstraints =
Arrays.asList(propDefn.getValueConstraints());
+ final Collection<String> currentConstraints = new
ArrayList<String>(Arrays.asList(propDefn.getValueConstraints()));
final StringValueEditorDialog dialog = new StringValueEditorDialog(getShell()) {
/**
@@ -1191,7 +1196,10 @@
// check for duplicate
currentConstraints.add(newValue);
- return CndValidator.validateValueConstraints(propDefn.getName(),
currentConstraints);
+ MultiValidationStatus validationStatus =
CndValidator.validateValueConstraints(propDefn.getName(),
+
currentConstraints);
+ currentConstraints.remove(newValue);
+ return validationStatus;
}
};
@@ -1301,8 +1309,12 @@
// check for duplicate
currentDefaultValues.add(newValue);
- return CndValidator.validateDefaultValues(propDefn.getName(),
propDefn.getType(), currentDefaultValues,
-
accessExistingNamespacePrefixes());
+ MultiValidationStatus validationStatus =
CndValidator.validateDefaultValues(propDefn.getName(),
+
propDefn.getType(),
+
currentDefaultValues,
+
accessExistingNamespacePrefixes());
+ currentDefaultValues.remove(newValue);
+ return validationStatus;
}
};
@@ -1378,7 +1390,10 @@
// check for duplicate
currentConstraints.add(newValue);
- return CndValidator.validateValueConstraints(propDefn.getName(),
currentConstraints);
+ MultiValidationStatus validationStatus =
CndValidator.validateValueConstraints(propDefn.getName(),
+
currentConstraints);
+ currentConstraints.remove(newValue);
+ return validationStatus;
}
};
Modified:
branches/jbosstools-3.3.x/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
===================================================================
---
branches/jbosstools-3.3.x/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-05-31
16:08:12 UTC (rev 41583)
+++
branches/jbosstools-3.3.x/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-05-31
16:47:55 UTC (rev 41584)
@@ -205,6 +205,16 @@
}
@Test
+ public void emptyValueConstraintShouldBeAnError() {
+ // setup
+ final ValidationStatus status =
CndValidator.validateValueConstraint(Utils.EMPTY_STRING);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(),
status.containsCode(StatusCodes.EMPTY_VALUE_CONSTRAINT)); //$NON-NLS-1$
+ }
+
+ @Test
public void invalidQualifiedNameQualifierShouldBeAnError() {
// setup
final QualifiedName qname = new QualifiedName(Constants.QUALIFIER1 +
"Changed", Constants.UNQUALIFIED_NAME1); //$NON-NLS-1$
@@ -410,6 +420,16 @@
}
@Test
+ public void nullValueConstraintShouldBeAnError() {
+ // setup
+ final ValidationStatus status = CndValidator.validateValueConstraint(null);
+
+ // tests
+ assertTrue(status.isError());
+ assertTrue("Code is " + status.getCode(),
status.containsCode(StatusCodes.EMPTY_VALUE_CONSTRAINT)); //$NON-NLS-1$
+ }
+
+ @Test
public void primaryItemNameWithNonMatchingQualifierShouldBeAnError() {
// setup
nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());