Author: elvisisking
Date: 2012-03-16 16:46:09 -0400 (Fri, 16 Mar 2012)
New Revision: 39593
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.png
Removed:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.gif
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Added more validation
rules. Implemented a namespace dialog and qualified name dialog to handle editing and
creating namespace mappings and qualified names.
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -81,6 +81,12 @@
public static String duplicatePropertyDefinitionName;
/**
+ * A message indicating duplicate qualified names exist. Two parameters, the type of
qualified name and the duplicate qualified
+ * name, are required.
+ */
+ public static String duplicateQualifiedName;
+
+ /**
* A message indicating duplicate query operators of a property definition exist. The
parameters of property definition name and
* the duplicate query operator are required.
*/
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -11,7 +11,7 @@
import java.net.URI;
import java.sql.Date;
import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.Messages;
@@ -124,7 +124,7 @@
* @param childNodeDefinition the child node definition being validated (cannot be
<code>null</code>)
* @return the status (never <code>null</code>)
*/
- public static ValidationStatus validateChildNodeDefinition( final ChildNodeDefinition
childNodeDefinition ) {
+ public static MultiValidationStatus validateChildNodeDefinition( final
ChildNodeDefinition childNodeDefinition ) {
Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
/**
@@ -158,7 +158,7 @@
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyRequiredTypes,
childNodeName)));
}
} else {
- final List<String> names = new
ArrayList<String>(requiredTypeNames.length);
+ final Collection<String> names = new
ArrayList<String>(requiredTypeNames.length);
for (final String requiredTypeName : requiredTypeNames) {
// ERROR - Invalid required type name
@@ -218,7 +218,7 @@
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateChildNodeDefinitions( final String
nodeTypeName,
- final
List<ChildNodeDefinition> childNodeDefinitions ) {
+ final
Collection<ChildNodeDefinition> childNodeDefinitions ) {
Utils.verifyIsNotEmpty(nodeTypeName, "nodeTypeName"); //$NON-NLS-1$
/**
@@ -233,7 +233,7 @@
}
final MultiValidationStatus status = new MultiValidationStatus();
- final List<String> childNodeNames = new
ArrayList<String>(childNodeDefinitions.size());
+ final Collection<String> childNodeNames = new
ArrayList<String>(childNodeDefinitions.size());
for (final ChildNodeDefinition childNodeDefn : childNodeDefinitions) {
validateChildNodeDefinition(childNodeDefn, status);
@@ -262,7 +262,7 @@
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateChildNodeDefinitions( final String nodeTypeName,
- final
List<ChildNodeDefinition> childNodeDefinitions,
+ final
Collection<ChildNodeDefinition> childNodeDefinitions,
final MultiValidationStatus status )
{
final MultiValidationStatus newStatus =
validateChildNodeDefinitions(nodeTypeName, childNodeDefinitions);
@@ -275,7 +275,7 @@
* @param cnd the CND being validated (cannot be <code>null</code>)
* @return the status (never <code>null</code>)
*/
- public static ValidationStatus validateCnd( final CompactNodeTypeDefinition cnd ) {
+ public static MultiValidationStatus validateCnd( final CompactNodeTypeDefinition cnd
) {
Utils.verifyIsNotNull(cnd, "cnd"); //$NON-NLS-1$
/**
@@ -289,7 +289,7 @@
boolean noNodeTypeDefinitions = false;
{ // namespace mappings
- final List<NamespaceMapping> namespaceMappings =
cnd.getNamespaceMappings();
+ final Collection<NamespaceMapping> namespaceMappings =
cnd.getNamespaceMappings();
if (Utils.isEmpty(namespaceMappings)) {
noNamespaceMappings = true;
@@ -299,7 +299,7 @@
}
{ // node type definitions
- final List<NodeTypeDefinition> nodeTypeDefinitions =
cnd.getNodeTypeDefinitions();
+ final Collection<NodeTypeDefinition> nodeTypeDefinitions =
cnd.getNodeTypeDefinitions();
if (Utils.isEmpty(nodeTypeDefinitions)) {
noNodeTypeDefinitions = true;
@@ -384,7 +384,7 @@
* @param namespaceMapping the namespace mapping being validated (cannot be
<code>null</code>)
* @return the status (never <code>null</code>)
*/
- public static ValidationStatus validateNamespaceMapping( final NamespaceMapping
namespaceMapping ) {
+ public static MultiValidationStatus validateNamespaceMapping( final NamespaceMapping
namespaceMapping ) {
Utils.verifyIsNotNull(namespaceMapping, "namespaceMapping");
//$NON-NLS-1$
/**
@@ -400,17 +400,80 @@
validateLocalName(namespaceMapping.getPrefix(), Messages.namespacePrefix,
status);
// ERROR - Empty or invalid URI
- validateLocalName(namespaceMapping.getUri(), Messages.namespaceUri, status);
+ ValidationStatus uriStatus = validateUri(namespaceMapping.getUri(),
Messages.namespaceUri);
+ if (!uriStatus.isOk()) {
+ status.add(uriStatus);
+ }
+
return status;
}
/**
* @param namespaceMapping the namespace mapping being validated (cannot be
<code>null</code>)
+ * @param existingNamespaces the existing namespaces whose prefixes and URIs will be
checked against (can be <code>null</code>
+ * or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateNamespaceMapping( final NamespaceMapping
namespaceMapping,
+ final
Collection<NamespaceMapping> existingNamespaces ) {
+ final MultiValidationStatus status = validateNamespaceMapping(namespaceMapping);
+
+ // check for duplicate prefix or URI
+ if (!Utils.isEmpty(existingNamespaces)) {
+ boolean checkPrefix = true;
+ boolean checkUri = true;
+
+ for (final NamespaceMapping namespace : existingNamespaces) {
+ if (checkPrefix && Utils.equivalent(namespaceMapping.getPrefix(),
namespace.getPrefix())) {
+ checkPrefix = false;
+ String prefix = namespaceMapping.getPrefix();
+
+ if (prefix == null) {
+ prefix = Utils.EMPTY_STRING;
+ }
+
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNamespacePrefix,
prefix)));
+ }
+
+ if (checkUri && Utils.equivalent(namespaceMapping.getUri(),
namespace.getUri())) {
+ checkUri = false;
+ String uri = namespaceMapping.getUri();
+
+ if (uri == null) {
+ uri = Utils.EMPTY_STRING;
+ }
+
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNamespaceUri,
uri)));
+ }
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * @param namespaceMapping the namespace mapping being validated (cannot be
<code>null</code>)
+ * @param existingNamespaces the existing namespaces whose prefixes and URIs will be
checked against (can be <code>null</code>
+ * or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateNamespaceMapping( final NamespaceMapping
namespaceMapping,
+ final Collection<NamespaceMapping>
existingNamespaces,
final MultiValidationStatus status ) {
+ final ValidationStatus newStatus = validateNamespaceMapping(namespaceMapping,
existingNamespaces);
+
+ if (!newStatus.isOk()) {
+ status.add(newStatus);
+ }
+ }
+
+ /**
+ * @param namespaceMapping the namespace mapping being validated (cannot be
<code>null</code>)
+ * @param status the status to add the new status to (never
<code>null</code>)
+ */
+ public static void validateNamespaceMapping( final NamespaceMapping
namespaceMapping,
+ final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateNamespaceMapping(namespaceMapping);
if (!newStatus.isOk()) {
@@ -422,7 +485,7 @@
* @param namespaceMappings the collection of namespace mappings being validated (can
be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
- public static MultiValidationStatus validateNamespaceMappings( final
List<NamespaceMapping> namespaceMappings ) {
+ public static MultiValidationStatus validateNamespaceMappings( final
Collection<NamespaceMapping> namespaceMappings ) {
/**
* <pre>
* ERROR - Duplicate namespace mapping prefix
@@ -436,8 +499,8 @@
}
final MultiValidationStatus status = new MultiValidationStatus();
- final List<String> prefixes = new
ArrayList<String>(namespaceMappings.size());
- final List<String> uris = new
ArrayList<String>(namespaceMappings.size());
+ final Collection<String> prefixes = new
ArrayList<String>(namespaceMappings.size());
+ final Collection<String> uris = new
ArrayList<String>(namespaceMappings.size());
for (final NamespaceMapping namespaceMapping : namespaceMappings) {
validateNamespaceMapping(namespaceMapping, status);
@@ -474,7 +537,7 @@
* @param namespaceMappings the collection of namespace mappings being validated (can
be <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
- public static void validateNamespaceMappings( final List<NamespaceMapping>
namespaceMappings,
+ public static void validateNamespaceMappings( final
Collection<NamespaceMapping> namespaceMappings,
final MultiValidationStatus status ) {
final ValidationStatus newStatus = validateNamespaceMappings(namespaceMappings);
@@ -487,7 +550,7 @@
* @param nodeTypeDefinition the node type definition being validated (cannot be
<code>null</code>)
* @return the status (never <code>null</code>)
*/
- public static ValidationStatus validateNodeTypeDefinition( final NodeTypeDefinition
nodeTypeDefinition ) {
+ public static MultiValidationStatus validateNodeTypeDefinition( final
NodeTypeDefinition nodeTypeDefinition ) {
Utils.verifyIsNotNull(nodeTypeDefinition, "nodeTypeDefinition");
//$NON-NLS-1$
/**
@@ -546,7 +609,7 @@
boolean noChildNodeDefinitions = false;
{ // property definitions
- final List<PropertyDefinition> propertyDefinitions =
nodeTypeDefinition.getPropertyDefinitions();
+ final Collection<PropertyDefinition> propertyDefinitions =
nodeTypeDefinition.getPropertyDefinitions();
if (Utils.isEmpty(propertyDefinitions)) {
noPropertyDefinitions = true;
@@ -556,7 +619,7 @@
}
{ // child node definitions
- final List<ChildNodeDefinition> childNodeDefinitions =
nodeTypeDefinition.getChildNodeDefinitions();
+ final Collection<ChildNodeDefinition> childNodeDefinitions =
nodeTypeDefinition.getChildNodeDefinitions();
if (Utils.isEmpty(childNodeDefinitions)) {
noChildNodeDefinitions = true;
@@ -590,7 +653,7 @@
* @param nodeTypeDefinitions the collection of namespace mappings to validate (can
be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
- public static MultiValidationStatus validateNodeTypeDefinitions( final
List<NodeTypeDefinition> nodeTypeDefinitions ) {
+ public static MultiValidationStatus validateNodeTypeDefinitions( final
Collection<NodeTypeDefinition> nodeTypeDefinitions ) {
/**
* <pre>
* ERROR - Duplicate node type definition names
@@ -603,7 +666,7 @@
}
final MultiValidationStatus status = new MultiValidationStatus();
- final List<String> names = new
ArrayList<String>(nodeTypeDefinitions.size());
+ final Collection<String> names = new
ArrayList<String>(nodeTypeDefinitions.size());
for (final NodeTypeDefinition nodeTypeDefinition : nodeTypeDefinitions) {
validateNodeTypeDefinition(nodeTypeDefinition, status);
@@ -628,7 +691,7 @@
* @param nodeTypeDefinitions the collection of namespace mappings to validate (can
be <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
- public static void validateNodeTypeDefinitions( final List<NodeTypeDefinition>
nodeTypeDefinitions,
+ public static void validateNodeTypeDefinitions( final
Collection<NodeTypeDefinition> nodeTypeDefinitions,
final MultiValidationStatus status )
{
final ValidationStatus newStatus =
validateNodeTypeDefinitions(nodeTypeDefinitions);
@@ -641,7 +704,7 @@
* @param propertyDefinition the property definition being validated (never
<code>null</code>)
* @return the status (never <code>null</code>)
*/
- public static ValidationStatus validatePropertyDefinition( final PropertyDefinition
propertyDefinition ) {
+ public static MultiValidationStatus validatePropertyDefinition( final
PropertyDefinition propertyDefinition ) {
Utils.verifyIsNotNull(propertyDefinition, "propertyDefinition");
//$NON-NLS-1$
/**
@@ -679,7 +742,7 @@
}
{ // default values
- final List<String> defaultValues =
propertyDefinition.getDefaultValuesAsStrings();
+ final Collection<String> defaultValues =
propertyDefinition.getDefaultValuesAsStrings();
if (Utils.isEmpty(defaultValues)) {
if
(propertyDefinition.getState(PropertyDefinition.PropertyName.DEFAULT_VALUES) == Value.IS)
{
@@ -693,7 +756,7 @@
propertyDefinitionName)));
}
- final List<String> values = new
ArrayList<String>(defaultValues.size());
+ final Collection<String> values = new
ArrayList<String>(defaultValues.size());
for (final String defaultValue : defaultValues) {
// ERROR - Default value is not valid for the property definition
type
@@ -726,7 +789,7 @@
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValueConstraints,
propertyDefinitionName)));
}
} else {
- final List<String> constraints = new
ArrayList<String>(valueConstraints.length);
+ final Collection<String> constraints = new
ArrayList<String>(valueConstraints.length);
for (final String constraint : valueConstraints) {
// ERROR - Invalid value constraint
@@ -759,7 +822,7 @@
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyQueryOperators,
propertyDefinitionName)));
}
} else {
- final List<String> operators = new
ArrayList<String>(queryOperators.length);
+ final Collection<String> operators = new
ArrayList<String>(queryOperators.length);
for (final String operator : queryOperators) {
// ERROR - Invalid query operator
@@ -807,7 +870,7 @@
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validatePropertyDefinitions( final String
nodeTypeName,
- final
List<PropertyDefinition> propertyDefinitions ) {
+ final
Collection<PropertyDefinition> propertyDefinitions ) {
Utils.verifyIsNotEmpty(nodeTypeName, "nodeTypeName"); //$NON-NLS-1$
/**
@@ -822,7 +885,7 @@
}
final MultiValidationStatus status = new MultiValidationStatus();
- final List<String> propNames = new
ArrayList<String>(propertyDefinitions.size());
+ final Collection<String> propNames = new
ArrayList<String>(propertyDefinitions.size());
for (final PropertyDefinition propertyDefn : propertyDefinitions) {
validatePropertyDefinition(propertyDefn, status);
@@ -851,7 +914,7 @@
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validatePropertyDefinitions( final String nodeTypeName,
- final List<PropertyDefinition>
propertyDefinitions,
+ final
Collection<PropertyDefinition> propertyDefinitions,
final MultiValidationStatus status )
{
final MultiValidationStatus newStatus = validatePropertyDefinitions(nodeTypeName,
propertyDefinitions);
@@ -887,7 +950,7 @@
final String unqualifiedName = qname.getUnqualifiedName();
if (Utils.isEmpty(unqualifiedName)) {
-
status.add(ValidationStatus.createErrorMessage(Messages.emptyUnqualifiedName));
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyUnqualifiedName,
propertyName)));
} else {
final ValidationStatus nameStatus = validateLocalName(unqualifiedName,
propertyName);
@@ -905,13 +968,16 @@
* @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
* @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
* or empty)
+ * @param existingQNames a list of existing qualified names used to make sure the
name being validated is not a duplicate (can
+ * be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateQualifiedName( final QualifiedName
qname,
final String
propertyName,
- final List<String>
validNamespacePrefixes ) {
+ final
Collection<String> validNamespacePrefixes,
+ final
Collection<QualifiedName> existingQNames ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateQualifiedName(qname, propertyName, validNamespacePrefixes, status);
+ validateQualifiedName(qname, propertyName, validNamespacePrefixes,
existingQNames, status);
return status;
}
@@ -920,14 +986,18 @@
* @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
* @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
* or empty)
+ * @param existingQNames a list of existing qualified names used to make sure the
name being validated is not a duplicate (can
+ * be <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateQualifiedName( final QualifiedName qname,
final String propertyName,
- final List<String>
validNamespacePrefixes,
+ final Collection<String>
validNamespacePrefixes,
+ final Collection<QualifiedName>
existingQNames,
final MultiValidationStatus status ) {
validateQualifiedName(qname, propertyName, status);
+ // make sure qualifier is valid
if (!Utils.isEmpty(validNamespacePrefixes)) {
final String qualifier = qname.getQualifier();
@@ -937,6 +1007,13 @@
status.add(newStatus);
}
}
+
+ // make sure qname is not a duplicate
+ if (!Utils.isEmpty(existingQNames) && existingQNames.contains(qname)) {
+ final ValidationStatus newStatus =
ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateQualifiedName,
+
propertyName, qname));
+ status.add(newStatus);
+ }
}
/**
@@ -1017,7 +1094,7 @@
}
final MultiValidationStatus status = new MultiValidationStatus();
- final List<String> names = new
ArrayList<String>(superTypeNames.length);
+ final Collection<String> names = new
ArrayList<String>(superTypeNames.length);
for (final String superTypeName : superTypeNames) {
// ERROR - Invalid super type name
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -226,6 +226,21 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(this.prefix);
+ builder.append(NOTATION_DELIMITER);
+ builder.append(this.uri);
+
+ return builder.toString();
+ }
+
+ /**
* The property names whose <code>toString()</code> is used in {@link
PropertyChangeEvent}s.
*/
public enum PropertyName {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -143,7 +143,7 @@
public boolean addSuperType( final String superTypeBeingAdded ) {
Utils.verifyIsNotEmpty(superTypeBeingAdded, "superTypeBeingAdded");
//$NON-NLS-1$
- if (this.superTypes.add(superTypeBeingAdded)) {
+ if (this.superTypes.add(QualifiedName.parse(superTypeBeingAdded))) {
notifyChangeListeners(PropertyName.SUPERTYPES, null, superTypeBeingAdded);
return true; // added
}
@@ -244,7 +244,7 @@
* @return <code>true</code> if there was at least one super type before
clearing
*/
public boolean clearSuperTypes() {
- final List<String> types = new
ArrayList<String>(this.superTypes.getSupportedItems());
+ final List<QualifiedName> types = new
ArrayList<QualifiedName>(this.superTypes.getSupportedItems());
if (this.superTypes.clear()) {
notifyChangeListeners(PropertyName.SUPERTYPES, types, null);
@@ -459,6 +459,13 @@
}
/**
+ * @return the qualified names of the supertypes (never <code>null</code>
but can be empty)
+ */
+ public List<QualifiedName> getSupertypes() {
+ return this.superTypes.getSupportedItems();
+ }
+
+ /**
* {@inheritDoc}
*
* @see javax.jcr.nodetype.NodeTypeDefinition#hasOrderableChildNodes()
@@ -595,7 +602,7 @@
* @return <code>true</code> if successfully removed
*/
public boolean removeSuperType( final String superTypeBeingRemoved ) {
- if (this.superTypes.remove(superTypeBeingRemoved)) {
+ if (this.superTypes.remove(QualifiedName.parse(superTypeBeingRemoved))) {
notifyChangeListeners(PropertyName.SUPERTYPES, superTypeBeingRemoved, null);
return true; // removed
}
@@ -621,12 +628,12 @@
*/
@Override
public void setDeclaredSuperTypeNames( final String[] newSuperTypes ) {
- final List<String> oldValue = this.superTypes.getSupportedItems();
+ final List<QualifiedName> oldValue = this.superTypes.getSupportedItems();
boolean changed = this.superTypes.clear();
if (!Utils.isEmpty(newSuperTypes)) {
for (final String superType : newSuperTypes) {
- if (this.superTypes.add(superType)) {
+ if (this.superTypes.add(QualifiedName.parse(superType))) {
changed = true;
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -10,11 +10,12 @@
import java.util.List;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedName;
/**
*
*/
-public final class SuperTypes extends ListAttributeState<String> {
+public final class SuperTypes extends ListAttributeState<QualifiedName> {
/**
* The CND list suffix.
@@ -35,7 +36,7 @@
* @return the collection of super types (never <code>null</code>)
*/
public String[] toArray() {
- final List<String> superTypes = getSupportedItems();
+ final List<QualifiedName> superTypes = getSupportedItems();
if (Utils.isEmpty(superTypes)) {
return Utils.EMPTY_STRING_ARRAY;
@@ -44,8 +45,8 @@
final String[] result = new String[superTypes.size()];
int i = 0;
- for (final String superType : superTypes) {
- result[i++] = superType;
+ for (final QualifiedName superType : superTypes) {
+ result[i++] = superType.get();
}
return result;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-16
20:46:09 UTC (rev 39593)
@@ -30,6 +30,8 @@
duplicateNodeTypeDefinitionName = There are multiple node type definitions with the name
of "{0}."
# 0 = property definition name, 1 = node type definition name
duplicatePropertyDefinitionName = There are multiple property definitions with a name of
"{1}" in node type definition "{0}."
+# 0 = type of qualified name, 1 = duplicate qualified name
+duplicateQualifiedName = There are duplicate {0}s of "{1}."
# 0 = property definition name, 1 = query operator
duplicateQueryOperator = There are multiple query operators of "{1}" in
property definition "{0}."
# 0 = child node definition name, 1 = duplicate required type name
@@ -50,7 +52,7 @@
# 0 = node type definition name
emptySuperTypes = The node type definition "{0}" must have at least one super
type.
# 0 = name or type of qualified name
-emptyUnqualifiedName = The "{0}" qualified name has an empty unqualified name.
+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
# 0 = property definition name
@@ -81,7 +83,7 @@
# 0 = CND line number, 1 = CND column number
multipleKeywordNotValidInJcr2CndFormat = The 'MULTIPLE' attribute at line {0},
column {1} is no longer valid in the JCR 2.0 CND format. Use 'SNS' instead.
# 0 = type of qualified name, 1 = qualifier
-nameQualifierNotFound = The "{0}" qualified name has a qualifier of
"{1}" that does not match any namespace prefixes in the CND.
+nameQualifierNotFound = The "{0}" has a qualifier of "{1}" that does
not match any namespace prefixes in the CND.
namespacePrefix = namespace prefix
namespaceUri = namespace URI
# 0 = node type definition name
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -79,7 +79,6 @@
private ScrolledForm scrolledForm;
private final CndEditorPage formsPage;
-// private final CndEditorPage sourcePage;
/**
* Constructs a CND editor.
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -16,6 +16,7 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -31,6 +32,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
@@ -71,6 +73,7 @@
import org.jboss.tools.modeshape.jcr.ui.JcrUiUtils;
import org.jboss.tools.modeshape.ui.Activator;
import org.jboss.tools.modeshape.ui.UiConstants;
+import org.jboss.tools.modeshape.ui.UiMessages;
import org.jboss.tools.modeshape.ui.UiUtils;
import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
import org.jboss.tools.modeshape.ui.forms.FormUtils;
@@ -85,35 +88,26 @@
private IAction addChildNode;
private IAction addNamespace;
private IAction addNodeType;
-
private IAction addProperty;
private IAction addSuperType;
- // node type attributes
private Button btnAbstract;
-
private Button btnMixin;
private Button btnOrderable;
private Button btnQueryable;
-
- // node type details
private CCombo cbxNamePrefix;
private Section childNodeSection;
private final ErrorMessage childNodesError;
-
private TableViewer childNodeViewer;
private IAction deleteChildNode;
private IAction deleteNamespace;
-
private IAction deleteNodeType;
private IAction deleteProperty;
private IAction deleteSuperType;
private Section detailsSection;
private IAction editChildNode;
-
private IAction editNamespace;
private IAction editNodeType;
private IAction editProperty;
-
private IAction editSuperType;
private final ErrorMessage namespacesError;
private TableViewer namespaceViewer;
@@ -121,14 +115,11 @@
private String nodeTypeNameFilterPattern;
private final ErrorMessage nodeTypeNamePrefixError;
private final ErrorMessage nodeTypesError;
-
private TableViewer nodeTypeViewer;
-
private final ErrorMessage propertiesError;
private Section propertiesSection;
private TableViewer propertyViewer;
private final ErrorMessage superTypesError;
-
private TableViewer superTypesViewer;
private Text txtName;
@@ -181,6 +172,7 @@
}
};
this.addChildNode.setEnabled(false);
+ this.addChildNode.setText(CndMessages.addChildNodeMenuText);
this.addChildNode.setToolTipText(CndMessages.addChildNodeToolTip);
this.addChildNode.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
@@ -197,6 +189,7 @@
}
};
this.deleteChildNode.setEnabled(false);
+ this.deleteChildNode.setText(CndMessages.deleteChildNodeMenuText);
this.deleteChildNode.setToolTipText(CndMessages.deleteChildNodeToolTip);
this.deleteChildNode.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
@@ -213,6 +206,7 @@
}
};
this.editChildNode.setEnabled(false);
+ this.editChildNode.setText(CndMessages.editChildNodeMenuText);
this.editChildNode.setToolTipText(CndMessages.editChildNodeToolTip);
this.editChildNode.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
}
@@ -242,6 +236,13 @@
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+ // table context menu
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(this.addChildNode);
+ menuManager.add(this.editChildNode);
+ menuManager.add(this.deleteChildNode);
+ table.setMenu(menuManager.createContextMenu(table));
+
createChildNodeViewer(table);
this.childNodesError.setControl(table);
}
@@ -534,7 +535,7 @@
this.btnQueryable.setToolTipText(CndMessages.queryableAttributeToolTip);
// fill with data from CND
- refreshNameControls(true); // fill control with data from CND
+ refreshNameControls();
refreshAttributeControls();
}
}
@@ -556,6 +557,14 @@
this.superTypesError.setControl(table);
createSuperTypesActions();
+
+ // table context menu
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(this.addSuperType);
+ menuManager.add(this.editSuperType);
+ menuManager.add(this.deleteSuperType);
+ table.setMenu(menuManager.createContextMenu(table));
+
createSuperTypesViewer(table);
// add toolbar buttons (add, edit, delete)
@@ -588,6 +597,7 @@
handleAddNamespace();
}
};
+ this.addNamespace.setText(CndMessages.addNamespaceMenuText);
this.addNamespace.setToolTipText(CndMessages.addNamespaceToolTip);
this.addNamespace.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
@@ -604,6 +614,7 @@
}
};
this.deleteNamespace.setEnabled(false);
+ this.deleteNamespace.setText(CndMessages.deleteNamespaceMenuText);
this.deleteNamespace.setToolTipText(CndMessages.deleteNamespaceToolTip);
this.deleteNamespace.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
@@ -620,6 +631,7 @@
}
};
this.editNamespace.setEnabled(false);
+ this.editNamespace.setText(CndMessages.editNamespaceMenuText);
this.editNamespace.setToolTipText(CndMessages.editNamespaceToolTip);
this.editNamespace.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
}
@@ -650,6 +662,13 @@
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+ // table context menu
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(this.addNamespace);
+ menuManager.add(this.editNamespace);
+ menuManager.add(this.deleteNamespace);
+ table.setMenu(menuManager.createContextMenu(table));
+
createNamespaceViewer(table);
this.namespacesError.setControl(table);
}
@@ -787,6 +806,7 @@
handleAddNodeType();
}
};
+ this.addNodeType.setText(CndMessages.addNodeTypeMenuText);
this.addNodeType.setToolTipText(CndMessages.addNodeTypeToolTip);
this.addNodeType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
@@ -803,6 +823,7 @@
}
};
this.deleteNodeType.setEnabled(false);
+ this.deleteNodeType.setText(CndMessages.deleteNodeTypeMenuText);
this.deleteNodeType.setToolTipText(CndMessages.deleteNodeTypeToolTip);
this.deleteNodeType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
@@ -819,6 +840,7 @@
}
};
this.editNodeType.setEnabled(false);
+ this.editNodeType.setText(CndMessages.editNodeTypeMenuText);
this.editNodeType.setToolTipText(CndMessages.editNodeTypeToolTip);
this.editNodeType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
}
@@ -881,6 +903,13 @@
final Table table = FormUtils.createTable(toolkit, viewerContainer);
table.setLinesVisible(false);
+ // table context menu
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(this.addNodeType);
+ menuManager.add(this.editNodeType);
+ menuManager.add(this.deleteNodeType);
+ table.setMenu(menuManager.createContextMenu(table));
+
createNodeTypeViewer(table);
this.nodeTypesError.setControl(table);
}
@@ -1056,6 +1085,7 @@
}
};
this.addProperty.setEnabled(false);
+ this.addProperty.setText(CndMessages.addPropertyMenuText);
this.addProperty.setToolTipText(CndMessages.addPropertyToolTip);
this.addProperty.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
@@ -1072,6 +1102,7 @@
}
};
this.deleteProperty.setEnabled(false);
+ this.deleteProperty.setText(CndMessages.deletePropertyMenuText);
this.deleteProperty.setToolTipText(CndMessages.deletePropertyToolTip);
this.deleteProperty.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
@@ -1088,6 +1119,7 @@
}
};
this.editProperty.setEnabled(false);
+ this.editProperty.setText(CndMessages.editPropertyMenuText);
this.editProperty.setToolTipText(CndMessages.editPropertyToolTip);
this.editProperty.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
}
@@ -1118,6 +1150,13 @@
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+ // table context menu
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(this.addProperty);
+ menuManager.add(this.editProperty);
+ menuManager.add(this.deleteProperty);
+ table.setMenu(menuManager.createContextMenu(table));
+
createPropertyViewer(table);
this.propertiesError.setControl(table);
}
@@ -1296,6 +1335,7 @@
}
};
this.addSuperType.setEnabled(false);
+ this.addSuperType.setText(CndMessages.addSuperTypeMenuText);
this.addSuperType.setToolTipText(CndMessages.addSuperTypeToolTip);
this.addSuperType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
@@ -1312,6 +1352,7 @@
}
};
this.deleteSuperType.setEnabled(false);
+ this.deleteSuperType.setText(CndMessages.deleteSuperTypeMenuText);
this.deleteSuperType.setToolTipText(CndMessages.deleteSuperTypeToolTip);
this.deleteSuperType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
@@ -1328,6 +1369,7 @@
}
};
this.editSuperType.setEnabled(false);
+ this.editSuperType.setText(CndMessages.editSuperTypeMenuText);
this.editSuperType.setToolTipText(CndMessages.editSuperTypeToolTip);
this.editSuperType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
}
@@ -1404,6 +1446,27 @@
});
}
+ private Image getCndEditorImage() {
+ return org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
+
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
+ }
+
+ private List<String> getNamespacePrefixes() {
+ final List<NamespaceMapping> namespaces = getCnd().getNamespaceMappings();
+
+ if (namespaces.isEmpty()) {
+ return null;
+ }
+
+ final List<String> prefixes = new
ArrayList<String>(namespaces.size());
+
+ for (final NamespaceMapping namespace : namespaces) {
+ prefixes.add(namespace.getPrefix());
+ }
+
+ return prefixes;
+ }
+
/**
* @return the name filter pattern (can be <code>null</code>)
*/
@@ -1496,8 +1559,20 @@
}
void handleAddNamespace() {
- // TODO handleAddNamespace
- MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ final NamespaceMappingDialog dialog = new NamespaceMappingDialog(getShell(),
getCnd().getNamespaceMappings());
+ dialog.create();
+ dialog.getShell().pack();
+
+ if (dialog.open() == Window.OK) {
+ final NamespaceMapping namespaceMapping = dialog.getNamespaceMapping();
+
+ if (getCnd().addNamespaceMapping(namespaceMapping)) {
+ this.namespaceViewer.refresh();
+ } else {
+ MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
getCndEditorImage(),
+
NLS.bind(CndMessages.errorAddingNamespaceMapping, namespaceMapping));
+ }
+ }
}
void handleAddNodeType() {
@@ -1511,8 +1586,27 @@
}
void handleAddSuperType() {
- // TODO handleAddSuperType
- MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ assert (getSelectedNodeType() != null) : "add supertype button is enabled
when there is no selected node type"; //$NON-NLS-1$
+
+ final QualifiedNameDialog dialog = new QualifiedNameDialog(getShell(),
+
CndMessages.newSuperTypeDialogTitle,
+
Messages.superTypeName,
+
getNamespacePrefixes());
+ dialog.setExistingQNames(getSelectedNodeType().getSupertypes());
+ dialog.create();
+ dialog.getShell().pack();
+
+ if (dialog.open() == Window.OK) {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final QualifiedName newQName = dialog.getQualifiedName();
+
+ if (nodeTypeDefinition.addSuperType(newQName.get())) {
+ this.superTypesViewer.refresh();
+ } else {
+ MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
getCndEditorImage(),
+ NLS.bind(CndMessages.errorAddingSupertype,
newQName));
+ }
+ }
}
void handleChildNodeSelected() {
@@ -1543,7 +1637,7 @@
public void handleCndReloaded() {
// make sure GUI has been constructed before refreshing
if (this.propertyViewer != null) {
- refreshNameControls(true);
+ refreshNameControls();
refreshAttributeControls();
refreshSuperTypes();
refreshPropertyViewer();
@@ -1556,8 +1650,6 @@
assert (getSelectedChildNode() != null) : "Delete child node button is
enabled and there is no child node selected"; //$NON-NLS-1$
final ChildNodeDefinition childNodeDefinition = getSelectedChildNode();
- final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
-
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
String name = childNodeDefinition.getName();
if (Utils.isEmpty(name)) {
@@ -1565,7 +1657,7 @@
}
// show confirmation dialog
- if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteChildNodeDialogTitle, image,
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteChildNodeDialogTitle, getCndEditorImage(),
NLS.bind(CndMessages.deleteChildNodeDialogMessage, name))) {
getSelectedNodeType().removeChildNodeDefinition(childNodeDefinition);
}
@@ -1575,8 +1667,6 @@
assert (getSelectedNamespace() != null) : "Delete namespace button is
enabled and there is no namespace selected"; //$NON-NLS-1$
final NamespaceMapping namespaceMapping = getSelectedNamespace();
- final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
-
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
String prefix = namespaceMapping.getPrefix();
if (Utils.isEmpty(prefix)) {
@@ -1584,7 +1674,7 @@
}
// show confirmation dialog
- if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteNamespaceDialogTitle, image,
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteNamespaceDialogTitle, getCndEditorImage(),
NLS.bind(CndMessages.deleteNamespaceDialogMessage, prefix))) {
getCnd().removeNamespaceMapping(namespaceMapping);
}
@@ -1594,8 +1684,6 @@
assert (getSelectedNodeType() != null) : "Delete node type button is enabled
and there is no node type selected"; //$NON-NLS-1$
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
-
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
String name = nodeTypeDefinition.getName();
if (Utils.isEmpty(name)) {
@@ -1603,7 +1691,7 @@
}
// show confirmation dialog
- if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteNodeTypeDialogTitle, image,
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteNodeTypeDialogTitle, getCndEditorImage(),
NLS.bind(CndMessages.deleteNodeTypeDialogMessage, name))) {
getCnd().removeNodeTypeDefinition(nodeTypeDefinition);
}
@@ -1614,8 +1702,6 @@
assert (getSelectedProperty() != null) : "Delete property button is enabled
and there is no property selected"; //$NON-NLS-1$
final PropertyDefinition propertyDefinition = getSelectedProperty();
- final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
-
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
String name = propertyDefinition.getName();
if (Utils.isEmpty(name)) {
@@ -1623,7 +1709,7 @@
}
// show confirmation dialog
- if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deletePropertyDialogTitle, image,
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deletePropertyDialogTitle, getCndEditorImage(),
NLS.bind(CndMessages.deletePropertyDialogMessage, name))) {
getSelectedNodeType().removePropertyDefinition(propertyDefinition);
}
@@ -1634,43 +1720,109 @@
assert (getSelectedSuperType() != null) : "Delete super type button is
enabled and there is no super type selected"; //$NON-NLS-1$
String superTypeName = getSelectedSuperType();
- final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
-
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
if (Utils.isEmpty(superTypeName)) {
superTypeName = Messages.missingName;
}
// show confirmation dialog
- if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteSuperTypeDialogTitle, image,
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteSuperTypeDialogTitle, getCndEditorImage(),
NLS.bind(CndMessages.deleteSuperTypeDialogMessage, superTypeName))) {
getSelectedNodeType().removeSuperType(superTypeName);
}
}
void handleEditChildNode() {
+ assert (getSelectedChildNode() != null) : "Edit child node handler has been
called when there is no child node selected"; //$NON-NLS-1$
// TODO handleEditChildNode
MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
}
void handleEditNamespace() {
- // TODO handleEditNamespace
- MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ assert (getSelectedNamespace() != null) : "Edit namespace handler has been
called when there is no namespace selected"; //$NON-NLS-1$
+ final NamespaceMapping selectedNamespace = getSelectedNamespace();
+
+ // TODO if prefix is changed should qualified names with old prefix be
automatically updated?
+ final NamespaceMappingDialog dialog = new NamespaceMappingDialog(getShell(),
+
getCnd().getNamespaceMappings(),
+
selectedNamespace);
+ dialog.create();
+ dialog.getShell().pack();
+
+ if (dialog.open() == Window.OK) {
+ final NamespaceMapping modifiedNamespaceMapping =
dialog.getNamespaceMapping();
+ boolean removed = false;
+ boolean added = false;
+
+ // remove existing and add in new
+ if (getCnd().removeNamespaceMapping(selectedNamespace)) {
+ removed = true;
+
+ if (getCnd().addNamespaceMapping(modifiedNamespaceMapping)) {
+ added = true;
+ this.namespaceViewer.refresh();
+ }
+ }
+
+ if (!removed || !added) {
+ MessageFormDialog.openError(getShell(),
+ UiMessages.errorDialogTitle,
+ getCndEditorImage(),
+
NLS.bind(CndMessages.errorEditingNamespaceMapping, new Object[] {
+ modifiedNamespaceMapping, removed,
added }));
+ }
+ }
}
void handleEditNodeType() {
+ assert (getSelectedNodeType() != null) : "Edit node type handler has been
called when there is no node type selected"; //$NON-NLS-1$
// TODO handleEditNodeType
MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
}
void handleEditProperty() {
+ assert (getSelectedProperty() != null) : "Edit property handler has been
called when there is no property selected"; //$NON-NLS-1$
// TODO handleEditProperty
MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
}
void handleEditSuperType() {
- // TODO handleEditSuperType
- MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ assert (getSelectedSuperType() != null) : "Edit super type handler has been
called when there is no super type selected"; //$NON-NLS-1$
+ final String selectedSupertype = getSelectedSuperType();
+
+ final QualifiedNameDialog dialog = new QualifiedNameDialog(getShell(),
+
CndMessages.editSuperTypeDialogTitle,
+
Messages.superTypeName,
+
getNamespacePrefixes(),
+
QualifiedName.parse(selectedSupertype));
+ dialog.setExistingQNames(getSelectedNodeType().getSupertypes());
+ dialog.create();
+ dialog.getShell().pack();
+
+ if (dialog.open() == Window.OK) {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final QualifiedName modifiedSuperType = dialog.getQualifiedName();
+ boolean removed = false;
+ boolean added = false;
+
+ // remove existing and add in new
+ if (nodeTypeDefinition.removeSuperType(selectedSupertype)) {
+ removed = true;
+
+ if (nodeTypeDefinition.addSuperType(modifiedSuperType.get())) {
+ added = true;
+ this.superTypesViewer.refresh();
+ }
+ }
+
+ if (!removed || !added) {
+ MessageFormDialog.openError(getShell(),
+ UiMessages.errorDialogTitle,
+ getCndEditorImage(),
+ NLS.bind(CndMessages.errorEditingSupertype,
new Object[] { modifiedSuperType, removed,
+ added }));
+ }
+ }
}
void handleMixinChanged( final boolean newValue ) {
@@ -1762,7 +1914,7 @@
}
// populate details section
- refreshNameControls(false);
+ refreshNameControls();
refreshAttributeControls();
refreshSuperTypes();
refreshPropertyViewer();
@@ -1801,7 +1953,7 @@
} else if
(NodeTypeDefinition.PropertyName.PRIMARY_ITEM.toString().equals(propName)) {
// TODO primary item has not been code for in this class yet
} else if
(NodeTypeDefinition.PropertyName.PROPERTY_DEFINITIONS.toString().equals(propName)) {
-
+
} else if (NodeTypeDefinition.PropertyName.QUERYABLE.toString().equals(propName))
{
} else if
(NodeTypeDefinition.PropertyName.SUPERTYPES.toString().equals(propName)) {
@@ -1834,14 +1986,8 @@
void handleSuperTypeSelected() {
// update button enablements
- boolean enable = (getSelectedNodeType() != null);
+ final boolean enable = (getSelectedSuperType() != null);
- if (this.addSuperType.isEnabled() != enable) {
- this.addSuperType.setEnabled(enable);
- }
-
- enable = (getSelectedSuperType() != null);
-
if (this.editSuperType.isEnabled() != enable) {
this.editSuperType.setEnabled(enable);
}
@@ -1914,7 +2060,7 @@
}
}
- private void refreshNameControls( final boolean loadNamespaces ) {
+ private void refreshNameControls() {
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
if ((nodeTypeDefinition == null) || Utils.isEmpty(nodeTypeDefinition.getName()))
{
@@ -1922,22 +2068,20 @@
this.txtName.setText(Utils.EMPTY_STRING);
} else {
// load qualifiers with namespace prefixes
- if (loadNamespaces) {
- final List<NamespaceMapping> namespaceMappings =
getCnd().getNamespaceMappings();
- final List<String> prefixes = new
ArrayList<String>(namespaceMappings.size() + 1); // add one for empty qualifier
- prefixes.add(CndMessages.noNameQualifierChoice);
+ final List<NamespaceMapping> namespaceMappings =
getCnd().getNamespaceMappings();
+ final List<String> prefixes = new
ArrayList<String>(namespaceMappings.size() + 1); // add one for empty qualifier
+ prefixes.add(CndMessages.noNameQualifierChoice);
- for (final NamespaceMapping namespaceMapping : namespaceMappings) {
- prefixes.add(namespaceMapping.getPrefix());
- }
+ for (final NamespaceMapping namespaceMapping : namespaceMappings) {
+ prefixes.add(namespaceMapping.getPrefix());
+ }
- // set qualifier choices if they have changed
- final String[] currentItems = this.cbxNamePrefix.getItems();
+ // set qualifier choices if they have changed
+ final String[] currentItems = this.cbxNamePrefix.getItems();
- // only reload qualifiers if different
- if ((prefixes.size() != currentItems.length) ||
!prefixes.containsAll(Arrays.asList(currentItems))) {
- this.cbxNamePrefix.setItems(prefixes.toArray(new
String[prefixes.size()]));
- }
+ // only reload qualifiers if different
+ if ((prefixes.size() != currentItems.length) ||
!prefixes.containsAll(Arrays.asList(currentItems))) {
+ this.cbxNamePrefix.setItems(prefixes.toArray(new
String[prefixes.size()]));
}
// load name
@@ -2014,13 +2158,20 @@
return;
}
- boolean enable = !getCndEditor().isReadOnly();
+ final boolean cndWritable = !getCndEditor().isReadOnly();
+ final boolean enableWithNodeTypeSelected = (cndWritable &&
(getSelectedNodeType() != null));
{ // namespaces section
- if (this.addNamespace.isEnabled() != enable) {
- this.addNamespace.setEnabled(enable);
+ if (this.addNamespace.isEnabled() != cndWritable) {
+ this.addNamespace.setEnabled(cndWritable);
}
+ if (this.namespaceViewer.getTable().isEnabled() != cndWritable) {
+ this.namespaceViewer.getTable().setEnabled(cndWritable);
+ }
+
+ final boolean enable = (cndWritable && (getSelectedNamespace() !=
null));
+
if (this.editNamespace.isEnabled() != enable) {
this.editNamespace.setEnabled(enable);
}
@@ -2028,67 +2179,81 @@
if (this.deleteNamespace.isEnabled() != enable) {
this.deleteNamespace.setEnabled(enable);
}
-
- if (this.namespaceViewer.getTable().isEnabled() != enable) {
- this.namespaceViewer.getTable().setEnabled(enable);
- }
}
- { // nodetypes section
- if (this.addNodeType.isEnabled() != enable) {
- this.addNodeType.setEnabled(enable);
+ { // node types section
+ if (this.addNodeType.isEnabled() != cndWritable) {
+ this.addNodeType.setEnabled(cndWritable);
}
- if (this.editNodeType.isEnabled() != enable) {
- this.editNodeType.setEnabled(enable);
+ if (this.nodeTypeViewer.getTable().isEnabled() != cndWritable) {
+ this.nodeTypeViewer.getTable().setEnabled(cndWritable);
}
- if (this.deleteNodeType.isEnabled() != enable) {
- this.deleteNodeType.setEnabled(enable);
+ if (this.editNodeType.isEnabled() != enableWithNodeTypeSelected) {
+ this.editNodeType.setEnabled(enableWithNodeTypeSelected);
}
- if (this.nodeTypeViewer.getTable().isEnabled() != enable) {
- this.nodeTypeViewer.getTable().setEnabled(enable);
+ if (this.deleteNodeType.isEnabled() != enableWithNodeTypeSelected) {
+ this.deleteNodeType.setEnabled(enableWithNodeTypeSelected);
}
}
- enable = (enable && (getSelectedNodeType() != null));
-
{ // details section
- if (this.cbxNamePrefix.isEnabled() != enable) {
- this.cbxNamePrefix.setEnabled(enable);
+ if (this.cbxNamePrefix.isEnabled() != enableWithNodeTypeSelected) {
+ this.cbxNamePrefix.setEnabled(enableWithNodeTypeSelected);
}
- if (this.txtName.isEnabled() != enable) {
- this.txtName.setEnabled(enable);
+ if (this.txtName.isEnabled() != enableWithNodeTypeSelected) {
+ this.txtName.setEnabled(enableWithNodeTypeSelected);
}
- if (this.btnAbstract.isEnabled() != enable) {
- this.btnAbstract.setEnabled(enable);
+ if (this.btnAbstract.isEnabled() != enableWithNodeTypeSelected) {
+ this.btnAbstract.setEnabled(enableWithNodeTypeSelected);
}
- if (this.btnMixin.isEnabled() != enable) {
- this.btnMixin.setEnabled(enable);
+ if (this.btnMixin.isEnabled() != enableWithNodeTypeSelected) {
+ this.btnMixin.setEnabled(enableWithNodeTypeSelected);
}
- if (this.btnOrderable.isEnabled() != enable) {
- this.btnOrderable.setEnabled(enable);
+ if (this.btnOrderable.isEnabled() != enableWithNodeTypeSelected) {
+ this.btnOrderable.setEnabled(enableWithNodeTypeSelected);
}
- if (this.btnQueryable.isEnabled() != enable) {
- this.btnQueryable.setEnabled(enable);
+ if (this.btnQueryable.isEnabled() != enableWithNodeTypeSelected) {
+ this.btnQueryable.setEnabled(enableWithNodeTypeSelected);
}
- if (this.superTypesViewer.getTable().isEnabled() != enable) {
- this.superTypesViewer.getTable().setEnabled(enable);
+ if (this.addSuperType.isEnabled() != enableWithNodeTypeSelected) {
+ this.addSuperType.setEnabled(enableWithNodeTypeSelected);
}
+
+ if (this.superTypesViewer.getTable().isEnabled() !=
enableWithNodeTypeSelected) {
+ this.superTypesViewer.getTable().setEnabled(enableWithNodeTypeSelected);
+ }
+
+ final boolean enable = (enableWithNodeTypeSelected &&
(getSelectedSuperType() != null));
+
+ if (this.editSuperType.isEnabled() != enable) {
+ this.editSuperType.setEnabled(enable);
+ }
+
+ if (this.deleteSuperType.isEnabled() != enable) {
+ this.deleteSuperType.setEnabled(enable);
+ }
}
{ // properties section
- if (this.addProperty.isEnabled() != enable) {
- this.addProperty.setEnabled(enable);
+ if (this.addProperty.isEnabled() != enableWithNodeTypeSelected) {
+ this.addProperty.setEnabled(enableWithNodeTypeSelected);
}
+ if (this.propertyViewer.getTable().isEnabled() != enableWithNodeTypeSelected)
{
+ this.propertyViewer.getTable().setEnabled(enableWithNodeTypeSelected);
+ }
+
+ final boolean enable = (enableWithNodeTypeSelected &&
(getSelectedProperty() != null));
+
if (this.editProperty.isEnabled() != enable) {
this.editProperty.setEnabled(enable);
}
@@ -2096,17 +2261,19 @@
if (this.deleteProperty.isEnabled() != enable) {
this.deleteProperty.setEnabled(enable);
}
-
- if (this.propertyViewer.getTable().isEnabled() != enable) {
- this.propertyViewer.getTable().setEnabled(enable);
- }
}
{ // child nodes section
- if (this.addChildNode.isEnabled() != enable) {
- this.addChildNode.setEnabled(enable);
+ if (this.addChildNode.isEnabled() != enableWithNodeTypeSelected) {
+ this.addChildNode.setEnabled(enableWithNodeTypeSelected);
}
+ if (this.childNodeViewer.getTable().isEnabled() !=
enableWithNodeTypeSelected) {
+ this.childNodeViewer.getTable().setEnabled(enableWithNodeTypeSelected);
+ }
+
+ final boolean enable = (enableWithNodeTypeSelected &&
(getSelectedChildNode() != null));
+
if (this.editChildNode.isEnabled() != enable) {
this.editChildNode.setEnabled(enable);
}
@@ -2114,10 +2281,6 @@
if (this.deleteChildNode.isEnabled() != enable) {
this.deleteChildNode.setEnabled(enable);
}
-
- if (this.childNodeViewer.getTable().isEnabled() != enable) {
- this.childNodeViewer.getTable().setEnabled(enable);
- }
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -26,26 +26,62 @@
public static String abstractAttributeToolTip;
/**
+ * A dialog message indicating the namespace mapping has been changed and asks the
user to OK the dialog.
+ */
+ public static String acceptNamespaceDialogMsg;
+
+ /**
+ * A dialog message indicating the qualified name has been changed and asks the user
to OK the dialog. One parameter, the type
+ * of qualified name, is required.
+ */
+ public static String acceptQualifiedNameDialogMsg;
+
+ /**
+ * The context menu item text for the add child node definition action.
+ */
+ public static String addChildNodeMenuText;
+
+ /**
* The tool tip message of the add child node definition action.
*/
public static String addChildNodeToolTip;
/**
+ * The context menu item text for the add namespace mapping action.
+ */
+ public static String addNamespaceMenuText;
+
+ /**
* The tool tip message of the add namespace mapping action.
*/
public static String addNamespaceToolTip;
/**
+ * The context menu item text for the add node type definition action.
+ */
+ public static String addNodeTypeMenuText;
+
+ /**
* The tool tip message of the add node type definition action.
*/
public static String addNodeTypeToolTip;
/**
+ * The context menu item text for the add property action.
+ */
+ public static String addPropertyMenuText;
+
+ /**
* The tool tip message of the add property definition action.
*/
public static String addPropertyToolTip;
/**
+ * The context menu item text for the add supertype action.
+ */
+ public static String addSuperTypeMenuText;
+
+ /**
* The tool tip message of the add property definition action.
*/
public static String addSuperTypeToolTip;
@@ -212,6 +248,11 @@
public static String deleteChildNodeDialogTitle;
/**
+ * The context menu item text for the delete child node definition action.
+ */
+ public static String deleteChildNodeMenuText;
+
+ /**
* The tool tip message of the delete child node definition action.
*/
public static String deleteChildNodeToolTip;
@@ -227,6 +268,11 @@
public static String deleteNamespaceDialogTitle;
/**
+ * The context menu item text for the delete namespace mapping action.
+ */
+ public static String deleteNamespaceMenuText;
+
+ /**
* The tool tip message of the delete namespace mapping action.
*/
public static String deleteNamespaceToolTip;
@@ -243,6 +289,11 @@
public static String deleteNodeTypeDialogTitle;
/**
+ * The context menu item text for the delete node type definition action.
+ */
+ public static String deleteNodeTypeMenuText;
+
+ /**
* The tool tip message of the delete node type definition action.
*/
public static String deleteNodeTypeToolTip;
@@ -259,6 +310,11 @@
public static String deletePropertyDialogTitle;
/**
+ * The context menu item text for the delete property action.
+ */
+ public static String deletePropertyMenuText;
+
+ /**
* The tool tip message of the delete property definition action.
*/
public static String deletePropertyToolTip;
@@ -274,36 +330,100 @@
public static String deleteSuperTypeDialogTitle;
/**
+ * The context menu item text for the delete supertype action.
+ */
+ public static String deleteSuperTypeMenuText;
+
+ /**
* The tool tip message of the delete super type action.
*/
public static String deleteSuperTypeToolTip;
/**
+ * The context menu item text for the edit child node definition action.
+ */
+ public static String editChildNodeMenuText;
+
+ /**
* The tool tip message of the edit child node definition action.
*/
public static String editChildNodeToolTip;
/**
+ * The namespace editor dialog message area title when editing an existing namespace
mapping.
+ */
+ public static String editNamespaceDialogTitle;
+
+ /**
+ * The context menu item text for the edit namespace mapping action.
+ */
+ public static String editNamespaceMenuText;
+
+ /**
* The tool tip message of the edit namespace mapping action.
*/
public static String editNamespaceToolTip;
/**
+ * The context menu item text for the edit node type definition action.
+ */
+ public static String editNodeTypeMenuText;
+
+ /**
* The tool tip message of the edit node type definition action.
*/
public static String editNodeTypeToolTip;
/**
+ * The context menu item text for the edit property action.
+ */
+ public static String editPropertyMenuText;
+
+ /**
* The tool tip message of the edit property definition action.
*/
public static String editPropertyToolTip;
/**
+ * The qualified name editor dialog message area title when editing an existing
supertype.
+ */
+ public static String editSuperTypeDialogTitle;
+
+ /**
+ * The context menu item text for the edit supertype action.
+ */
+ public static String editSuperTypeMenuText;
+
+ /**
* The tool tip message of the edit super type action.
*/
public static String editSuperTypeToolTip;
/**
+ * An error message indicating the updated namespace mapping did not get saved to the
CND. Three parameters, the namespace
+ * mapping, a flag indicating if the remove succeeded, and a flag indicating if the
add succeeded, are required.
+ */
+ public static String errorEditingNamespaceMapping;
+
+ /**
+ * An error message indicating the updated supertype did not get saved to the CND.
Three parameters, the supertype, a flag
+ * indicating if the remove succeeded, and a flag indicating if the add succeeded,
are required.
+ */
+ public static String errorEditingSupertype;
+
+ /**
+ * An error message indicating the new supertype was not added to the node type
definition. One parameter, the supertype, is
+ * required.
+ */
+ public static String errorAddingSupertype;
+
+ /**
+ * An error message indicating the new namespace mapping was not added to the CND.
One parameter, the namespace mapping, is
+ * required.
+ */
+ public static String errorAddingNamespaceMapping;
+
+ /**
* The error message when the CND editor could not be opened.
*/
public static String errorOpeningCndEditor;
@@ -329,6 +449,16 @@
public static String nameHeaderText;
/**
+ * The message displayed in the namespace mapping dialog when first displayed.
+ */
+ public static String namespaceDialogMsg;
+
+ /**
+ * The title of the namespace mapping dialog.
+ */
+ public static String namespaceDialogTitle;
+
+ /**
* A label for a generic name control.
*/
public static String nameLabel;
@@ -344,6 +474,11 @@
public static String namespacePrefixHeaderText;
/**
+ * A label for a namespace prefix control.
+ */
+ public static String namespacePrefixLabel;
+
+ /**
* The tool tip for a namespace prefix.
*/
public static String namespacePrefixToolTip;
@@ -364,6 +499,16 @@
public static String nodeTypeNamePatternMessage;
/**
+ * The namespace editor dialog message area title when creating a new namespace
mapping.
+ */
+ public static String newNamespaceDialogTitle;
+
+ /**
+ * The qualified name editor dialog message area title when creating a new
supertype.
+ */
+ public static String newSuperTypeDialogTitle;
+
+ /**
* The column header text for the node type definition name.
*/
public static String nodeTypeNameHeaderText;
@@ -414,6 +559,22 @@
public static String propertyValueConstraintsToolTip;
/**
+ * The message displayed in the qualified name dialog when first displayed. One
parameter, the type of qualified name, is
+ * required.
+ */
+ public static String qualifiedNameDialogMsg;
+
+ /**
+ * The title of the qualified name dialog.
+ */
+ public static String qualifiedNameDialogTitle;
+
+ /**
+ * A label for a qualifier control of a qualified name.
+ */
+ public static String qualifierLabel;
+
+ /**
* The queryable attribute name suitable for a radio or check button.
*/
public static String queryableAttribute;
@@ -439,6 +600,16 @@
public static String typeHeaderText;
/**
+ * A tooltip message for the control where the name of the qualified name is being
edited.
+ */
+ public static String unqualifiedNameToolTip;
+
+ /**
+ * A tooltip message for a control containing all the valid qualifed name qualifiers
in a CND.
+ */
+ public static String validQualifiersToolTip;
+
+ /**
* The column header text for the value constraints of a property definition.
*/
public static String valueConstraintsHeaderText;
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -0,0 +1,267 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.jcr.ui.cnd;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.jboss.tools.modeshape.jcr.MultiValidationStatus;
+import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.NamespaceMapping;
+import org.jboss.tools.modeshape.jcr.ui.Activator;
+import org.jboss.tools.modeshape.jcr.ui.UiConstants;
+import org.jboss.tools.modeshape.ui.forms.FormUtils.Styles;
+
+/**
+ * The <code>NamespaceMappingDialog</code> is used to create or edit a
namespace mapping.
+ */
+class NamespaceMappingDialog extends FormDialog {
+
+ private Button btnOk;
+
+ /**
+ * An optional list of existing namespace mappings. When this is non-empty, it is
checked to make sure the prefix and URI being
+ * edited is not a duplicate.
+ */
+ private final List<NamespaceMapping> existingNamespaces;
+
+ /**
+ * The namespace mapping being edited or <code>null</code> when creating
a namespace mapping.
+ */
+ private NamespaceMapping namespaceBeingEdited;
+
+ private String prefix;
+
+ private ScrolledForm scrolledForm;
+
+ private String uri;
+
+ /**
+ * Used to construct a new namespace mapping.
+ *
+ * @param parentShell the parent shell (may be <code>null</code>)
+ * @param existingNamespaces the existing namespace mappings (can be
<code>null</code> or empty)
+ */
+ public NamespaceMappingDialog( final Shell parentShell,
+ final Collection<NamespaceMapping>
existingNamespaces ) {
+ super(parentShell);
+
+ this.existingNamespaces = ((existingNamespaces == null) ? new
ArrayList<NamespaceMapping>()
+ : new
ArrayList<NamespaceMapping>(existingNamespaces));
+ }
+
+ /**
+ * Used to edit an existing namespace mapping.
+ *
+ * @param parentShell the parent shell (may be <code>null</code>)
+ * @param existingNamespaces the existing namespace mappings (can be
<code>null</code> or empty)
+ * @param namespaceBeingEdited the namespace mapping being edited (cannot be
<code>null</code>)
+ */
+ public NamespaceMappingDialog( final Shell parentShell,
+ final Collection<NamespaceMapping>
existingNamespaces,
+ final NamespaceMapping namespaceBeingEdited ) {
+ this(parentShell, existingNamespaces);
+ Utils.verifyIsNotNull(namespaceBeingEdited, "namespaceBeingEdited");
//$NON-NLS-1$
+
+ this.namespaceBeingEdited = namespaceBeingEdited;
+ this.prefix = this.namespaceBeingEdited.getPrefix();
+ this.uri = this.namespaceBeingEdited.getUri();
+
+ // remove the namespace mapping being edited so validating doesn't show it as
a duplicate
+ this.existingNamespaces.remove(this.namespaceBeingEdited);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell( Shell newShell ) {
+ super.configureShell(newShell);
+ newShell.setText(CndMessages.namespaceDialogTitle);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int,
java.lang.String, boolean)
+ */
+ @Override
+ protected Button createButton( final Composite parent,
+ final int id,
+ final String label,
+ final boolean defaultButton ) {
+ final Button btn = super.createButton(parent, id, label, defaultButton);
+
+ if (id == IDialogConstants.OK_ID) {
+ // disable OK button initially
+ this.btnOk = btn;
+ btn.setEnabled(false);
+ }
+
+ return btn;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent( final IManagedForm managedForm ) {
+ this.scrolledForm = managedForm.getForm();
+ this.scrolledForm.setText(isEditMode() ? CndMessages.editNamespaceDialogTitle :
CndMessages.newNamespaceDialogTitle);
+
this.scrolledForm.setImage(Activator.getSharedInstance().getImage(UiConstants.Images.CND_EDITOR));
+ this.scrolledForm.setMessage(CndMessages.namespaceDialogMsg,
IMessageProvider.NONE);
+
+ final FormToolkit toolkit = managedForm.getToolkit();
+ toolkit.decorateFormHeading(this.scrolledForm.getForm());
+
+ final Composite body = this.scrolledForm.getBody();
+ body.setLayout(new GridLayout(2, false));
+
+ { // prefix
+ final Label lblPrefix = toolkit.createLabel(body,
CndMessages.namespacePrefixLabel, SWT.NONE);
+ lblPrefix.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+ final Text txtPrefix = toolkit.createText(body, null, Styles.TEXT_STYLE);
+ txtPrefix.setToolTipText(CndMessages.namespacePrefixToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
+ txtPrefix.setLayoutData(gd);
+
+ if (isEditMode()) {
+ txtPrefix.setText(this.namespaceBeingEdited.getPrefix());
+ }
+
+ txtPrefix.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handlePrefixChanged(((Text)e.widget).getText());
+ }
+ });
+
+ txtPrefix.setFocus();
+ }
+
+ { // URI
+ final Label lblUri = toolkit.createLabel(body, CndMessages.nameLabel,
SWT.NONE);
+ lblUri.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+ final Text txtUri = toolkit.createText(body, null, Styles.TEXT_STYLE);
+ txtUri.setToolTipText(CndMessages.namespaceUriToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
+ txtUri.setLayoutData(gd);
+
+ if (isEditMode()) {
+ txtUri.setText(this.namespaceBeingEdited.getUri());
+ }
+
+ txtUri.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleUriChanged(((Text)e.widget).getText());
+ }
+ });
+ }
+ }
+
+ /**
+ * <strong>Should only be called after the OK button has been
pressed.</strong>
+ *
+ * @return a namespace mapping representing the dialog changes (never
<code>null</code>)
+ */
+ public NamespaceMapping getNamespaceMapping() {
+ return new NamespaceMapping(this.prefix, this.uri);
+ }
+
+ void handlePrefixChanged( final String newPrefix ) {
+ this.prefix = newPrefix;
+ updateState();
+ }
+
+ void handleUriChanged( final String newUri ) {
+ this.uri = newUri;
+ updateState();
+ }
+
+ private boolean isEditMode() {
+ return (this.namespaceBeingEdited != null);
+ }
+
+ private void updateState() {
+ // validate qname
+ final NamespaceMapping currentNamespace = getNamespaceMapping();
+ final MultiValidationStatus status =
CndValidator.validateNamespaceMapping(currentNamespace, this.existingNamespaces);
+ boolean enable = !status.isError();
+
+ // a bug in Eclipse doesn't reset the font color going from an error to NONE
so first set to INFORMATION to get the
+ // font color to change
+ this.scrolledForm.setMessage(Utils.EMPTY_STRING, IMessageProvider.INFORMATION);
+
+ if (!enable) {
+ this.scrolledForm.setMessage(status.getMessage(), IMessageProvider.ERROR);
+ } else if ((isEditMode() &&
currentNamespace.equals(this.namespaceBeingEdited))
+ || (!isEditMode() && Utils.isEmpty(this.prefix) &&
Utils.isEmpty(this.uri))) {
+ enable = false;
+ this.scrolledForm.setMessage(CndMessages.namespaceDialogMsg,
IMessageProvider.NONE);
+ } else {
+ int severity = IMessageProvider.NONE; // OK severity
+ String message = status.getMessage();
+
+ if (status.isWarning()) {
+ severity = IMessageProvider.WARNING;
+ } else if (status.isInfo()) {
+ severity = IMessageProvider.INFORMATION;
+ } else {
+ message = CndMessages.acceptNamespaceDialogMsg;
+ }
+
+ this.scrolledForm.setMessage(message, severity);
+ }
+
+ // set enabled state of OK button
+ if (this.btnOk.getEnabled() != enable) {
+ this.btnOk.setEnabled(enable);
+ }
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameDialog.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameDialog.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -0,0 +1,321 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+package org.jboss.tools.modeshape.jcr.ui.cnd;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.jboss.tools.modeshape.jcr.MultiValidationStatus;
+import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedName;
+import org.jboss.tools.modeshape.jcr.ui.Activator;
+import org.jboss.tools.modeshape.jcr.ui.UiConstants;
+import org.jboss.tools.modeshape.ui.forms.FormUtils.Styles;
+
+/**
+ * The <code>QualifiedNameDialog</code> is used to create or edit a qualified
name.
+ */
+class QualifiedNameDialog extends FormDialog {
+
+ private Button btnOk;
+
+ /**
+ * An optional list of existing qualified names. When this is non-empty, it is
checked to make sure the qualified name being
+ * edited is not a duplicate.
+ */
+ private List<QualifiedName> existingQNames;
+
+ /**
+ * The qualified name being edited or <code>null</code> when creating a
qualified name.
+ */
+ private QualifiedName qnameBeingEdited;
+
+ private final String qualifiedNameType;
+
+ private String qualifier;
+
+ private ScrolledForm scrolledForm;
+
+ private final String title;
+
+ private String unqualifiedName;
+
+ /**
+ * A collection of known qualifiers/namespace prefixes to the CND (never
<code>null</code>).
+ */
+ private final List<String> validQualifiers;
+
+ /**
+ * Used to construct a new qualified name.
+ *
+ * @param parentShell the parent shell (may be <code>null</code>)
+ * @param title a short message area title for use when creating a new qualified name
(cannot be <code>null</code> or empty)
+ * @param qualifiedNameType a word describing what the qualified name represents
(cannot be <code>null</code> or empty)
+ * @param existingQualifiers the existing qualifies (can be
<code>null</code> or empty)
+ */
+ public QualifiedNameDialog( final Shell parentShell,
+ final String title,
+ final String qualifiedNameType,
+ final Collection<String> existingQualifiers ) {
+ super(parentShell);
+ Utils.verifyIsNotNull(qualifiedNameType, "qualifiedNameType");
//$NON-NLS-1$
+
+ this.title = title;
+ this.qualifiedNameType = qualifiedNameType;
+ this.validQualifiers = ((existingQualifiers == null) ? new
ArrayList<String>(1) : new ArrayList<String>(existingQualifiers));
+ this.validQualifiers.add(0, CndMessages.noNameQualifierChoice); // include empty
qualifier at index 0
+ }
+
+ /**
+ * Used to edit an existing qualified name.
+ *
+ * @param parentShell the parent shell (may be <code>null</code>)
+ * @param title a short message area title for use when creating a new qualified name
(cannot be <code>null</code> or empty)
+ * @param qualifiedNameType a word describing what the qualified name represents
(cannot be <code>null</code> or empty)
+ * @param existingQualifiers the existing qualifiers (can be
<code>null</code> or empty)
+ * @param qnameBeingEdited the qualified name being edited (cannot be
<code>null</code>)
+ */
+ public QualifiedNameDialog( final Shell parentShell,
+ final String title,
+ final String qualifiedNameType,
+ final Collection<String> existingQualifiers,
+ final QualifiedName qnameBeingEdited ) {
+ this(parentShell, title, qualifiedNameType, existingQualifiers);
+ Utils.verifyIsNotNull(qnameBeingEdited, "qnameBeingEdited");
//$NON-NLS-1$
+
+ this.qnameBeingEdited = qnameBeingEdited;
+ this.qualifier = this.qnameBeingEdited.getQualifier();
+ this.unqualifiedName = this.qnameBeingEdited.getUnqualifiedName();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell( Shell newShell ) {
+ super.configureShell(newShell);
+ newShell.setText(CndMessages.qualifiedNameDialogTitle);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int,
java.lang.String, boolean)
+ */
+ @Override
+ protected Button createButton( final Composite parent,
+ final int id,
+ final String label,
+ final boolean defaultButton ) {
+ final Button btn = super.createButton(parent, id, label, defaultButton);
+
+ if (id == IDialogConstants.OK_ID) {
+ // disable OK button initially
+ this.btnOk = btn;
+ btn.setEnabled(false);
+ }
+
+ return btn;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent( final IManagedForm managedForm ) {
+ this.scrolledForm = managedForm.getForm();
+ this.scrolledForm.setText(this.title);
+
this.scrolledForm.setImage(Activator.getSharedInstance().getImage(UiConstants.Images.CND_EDITOR));
+ this.scrolledForm.setMessage(NLS.bind(CndMessages.qualifiedNameDialogMsg,
this.qualifiedNameType), IMessageProvider.NONE);
+
+ final FormToolkit toolkit = managedForm.getToolkit();
+ toolkit.decorateFormHeading(this.scrolledForm.getForm());
+
+ final Composite body = this.scrolledForm.getBody();
+ body.setLayout(new GridLayout(2, false));
+
+ { // qualifier
+ final Label lblQualifier = toolkit.createLabel(body,
CndMessages.qualifierLabel, SWT.NONE);
+ lblQualifier.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
false));
+
+ final CCombo cbxQualifiers = new CCombo(body, Styles.COMBO_STYLE);
+ toolkit.adapt(cbxQualifiers, true, false);
+ cbxQualifiers.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
+ cbxQualifiers.setToolTipText(CndMessages.validQualifiersToolTip);
+
+ // populate qualifiers
+ for (final String validQualifier : this.validQualifiers) {
+ cbxQualifiers.add(validQualifier);
+ }
+
+ // select the current qualifier
+ if (isEditMode()) {
+ final String currentQualifier = this.qnameBeingEdited.getQualifier();
+
+ if (Utils.isEmpty(currentQualifier)) {
+ cbxQualifiers.select(0);
+ } else {
+ final int index = cbxQualifiers.indexOf(currentQualifier);
+
+ if (index == -1) {
+ // not a valid qualifier but add and select
+ cbxQualifiers.add(currentQualifier);
+ cbxQualifiers.select(cbxQualifiers.getItemCount() - 1);
+ } else {
+ cbxQualifiers.select(index);
+ }
+ }
+ } else {
+ cbxQualifiers.select(0);
+ }
+
+ cbxQualifiers.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ final String newQualifier = ((CCombo)e.widget).getText();
+ handleQualifierChanged(newQualifier);
+ }
+ });
+ }
+
+ { // unqualified name
+ final Label lblName = toolkit.createLabel(body, CndMessages.nameLabel,
SWT.NONE);
+ lblName.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+ final Text txtName = toolkit.createText(body, null, Styles.TEXT_STYLE);
+ txtName.setToolTipText(CndMessages.unqualifiedNameToolTip);
+
+ final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
+ txtName.setLayoutData(gd);
+
+ if (isEditMode()) {
+ txtName.setText(this.qnameBeingEdited.getUnqualifiedName());
+ }
+
+ txtName.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleNameChanged(((Text)e.widget).getText());
+ }
+ });
+
+ txtName.setFocus();
+ }
+ }
+
+ /**
+ * <strong>Should only be called after the OK button has been
pressed.</strong>
+ *
+ * @return the new or edited qualified name (never <code>null</code>)
+ */
+ public QualifiedName getQualifiedName() {
+ return new QualifiedName(this.qualifier, this.unqualifiedName);
+ }
+
+ void handleNameChanged( final String newName ) {
+ this.unqualifiedName = newName;
+ updateState();
+ }
+
+ void handleQualifierChanged( final String newQualifier ) {
+ this.qualifier = newQualifier;
+ updateState();
+ }
+
+ private boolean isEditMode() {
+ return (this.qnameBeingEdited != null);
+ }
+
+ /**
+ * @param existingQNames used to check against for duplicate qualified names (can be
<code>null</code> or empty)
+ */
+ void setExistingQNames( final List<QualifiedName> existingQNames ) {
+ if (!Utils.isEmpty(this.existingQNames) && isEditMode()) {
+ this.existingQNames = new ArrayList<QualifiedName>(existingQNames);
+ this.existingQNames.remove(this.qnameBeingEdited); // so that validating
won't show it as a duplicate
+ }
+ }
+
+ private void updateState() {
+ // validate qname
+ final QualifiedName currentQName = new QualifiedName(this.qualifier,
this.unqualifiedName);
+ final MultiValidationStatus status =
CndValidator.validateQualifiedName(currentQName, this.qualifiedNameType,
+
this.validQualifiers, this.existingQNames);
+ boolean enable = !status.isError();
+
+ // a bug in Eclipse doesn't reset the font color going from an error to NONE
so first set to INFORMATION to get the
+ // font color to change
+ this.scrolledForm.setMessage(Utils.EMPTY_STRING, IMessageProvider.INFORMATION);
+
+ if (!enable) {
+ this.scrolledForm.setMessage(status.getMessage(), IMessageProvider.ERROR);
+ } else if ((isEditMode() && currentQName.equals(this.qnameBeingEdited))
+ || (!isEditMode() && Utils.isEmpty(this.qualifier) &&
Utils.isEmpty(this.unqualifiedName))) {
+ enable = false;
+ this.scrolledForm.setMessage(NLS.bind(CndMessages.qualifiedNameDialogMsg,
this.qualifiedNameType),
+ IMessageProvider.NONE);
+ } else {
+ int severity = IMessageProvider.NONE; // OK severity
+ String message = status.getMessage();
+
+ if (status.isWarning()) {
+ severity = IMessageProvider.WARNING;
+ } else if (status.isInfo()) {
+ severity = IMessageProvider.INFORMATION;
+ } else {
+ message = NLS.bind(CndMessages.acceptQualifiedNameDialogMsg,
this.qualifiedNameType);
+ }
+
+ this.scrolledForm.setMessage(message, severity);
+ }
+
+ // set enabled state of OK button
+ if (this.btnOk.getEnabled() != enable) {
+ this.btnOk.setEnabled(enable);
+ }
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-16
20:46:09 UTC (rev 39593)
@@ -6,13 +6,19 @@
abstractAttribute = Abstract
abstractAttributeToolTip = Indicates if the node type definition cannot be instantiated
+acceptNamespaceDialogMsg = Select OK to accept the changes to the namespace mapping.
+acceptQualifiedNameDialogMsg = Select OK to accept the changes to the "{0}"
qualified name.
+addChildNodeMenuText = Add Child Node
addChildNodeToolTip = Add a child node definition
+addNamespaceMenuText = Add Namespace
addNamespaceToolTip = Add a namespace mapping
+addNodeTypeMenuText = Add Node Type
addNodeTypeToolTip = Add a node type definition
+addPropertyMenuText = Add Property
addPropertyToolTip = Add a property definition
-addSuperTypeToolTip = Add a super type
+addSuperTypeMenuText = Add Supertype
+addSuperTypeToolTip = Add a supertype
attributesHeaderText = Attributes
-propertyAttributesToolTip = The attributes of a property definition (autocreated,
mandatory, multiple, nofulltext, noqueryorder, abstract, opv, queryops)
childNodeAttributesToolTip = The attributes of a child node definition (autocreated,
mandatory, abstract, opv, sns)
childNodeDefaultTypeToolTip = The default type of a child node definition
childNodeNameToolTip = The name of a child node definition
@@ -48,39 +54,60 @@
# 0 = child node definition name
deleteChildNodeDialogMessage = Are you sure you want to delete the "{0}" child
node definition?
deleteChildNodeDialogTitle = Delete Child Node
+deleteChildNodeMenuText = Delete Child Node
deleteChildNodeToolTip = Delete the selected child node definition
# 0 = namespace mapping prefix
deleteNamespaceDialogMessage = Are you sure you want to delete the namespace mapping with
prefix "{0}"?
deleteNamespaceDialogTitle = Delete Namespace
+deleteNamespaceMenuText = Delete Namespace
deleteNamespaceToolTip = Delete the selected namespace mapping
# 0 = node type definition name
deleteNodeTypeDialogMessage = Are you sure you want to delete the "{0}" node
type definition?
deleteNodeTypeDialogTitle = Delete Node Type
+deleteNodeTypeMenuText = Delete Node Type
deleteNodeTypeToolTip = Delete the selected node type definition
# 0 = property definition name
deletePropertyDialogMessage = Are you sure you want to delete the "{0}"
property definition?
deletePropertyDialogTitle = Delete Property
+deletePropertyMenuText = Delete Property
deletePropertyToolTip = Delete the selected property definition
# 0 = supertype name
-deleteSuperTypeDialogMessage = Are you sure you want to delete the "{0}" super
type?
-deleteSuperTypeDialogTitle = Delete Super Type
-deleteSuperTypeToolTip = Delete the selected super type
+deleteSuperTypeDialogMessage = Are you sure you want to delete the "{0}"
supertype?
+deleteSuperTypeDialogTitle = Delete Supertype
+deleteSuperTypeMenuText = Delete Supertype
+deleteSuperTypeToolTip = Delete the selected supertype
+editChildNodeMenuText = Edit Child Node
editChildNodeToolTip = Edit the selected child node definition
+editNamespaceDialogTitle = Edit Namespace
+editNamespaceMenuText = Edit Namespace
editNamespaceToolTip = Edit the selected namespace mapping
+editNodeTypeMenuText = Edit Node Type
editNodeTypeToolTip = Edit the selected node type definition
+editPropertyMenuText = Edit Property
editPropertyToolTip = Edit the selected property definition
-editSuperTypeToolTip = Edit the selected super type
+editSuperTypeDialogTitle = Edit Supertype
+editSuperTypeMenuText = Edit Supertype
+editSuperTypeToolTip = Edit the selected supertype
+errorAddingNamespaceMapping = There was an unexpected error adding namespace mapping
"{0}" to the CND.
+errorAddingSupertype = There was an unexpected error adding supertype "{0}" to
the CND.
+errorEditingNamespaceMapping = There was an unexpected error updating namespace mapping
"{0}" to the CND.\nThe remove command result: {1}. The add command result: {2}.
+errorEditingSupertype = There was an unexpected error updating supertype "{0}"
to the CND.\nThe remove command result: {1}. The add command result: {2}.
errorOpeningCndEditor = There was a problem creating the CND editor.
missingValue = <missing>
mixinAttribute = Mixin
mixinAttributeToolTip = Indicates if the node type definition is a mixin and not a
primary node type
nameLabel = Name:
nameHeaderText = Name
+namespaceDialogMsg = Enter a unique prefix and a unique URI.\nSelect OK when finished
editing.
+namespaceDialogTitle = Namespace Editor
namespaceLabel = Namespace:
namespacePrefixHeaderText = Prefix
-namespacePrefixToolTip = The prefix of the namespace mapping
+namespacePrefixLabel = Prefix:
+namespacePrefixToolTip = The prefix of the namespace mapping. Must be unique within a
CND.
namespaceUriHeaderText = URI
-namespaceUriToolTip = The URI of the namespace mapping
+namespaceUriToolTip = The URI of the namespace mapping. Must be unique with a CND.
+newNamespaceDialogTitle = Create Namespace
+newSuperTypeDialogTitle = Create Supertype
nodeTypeNamePatternMessage = enter name pattern
nodeTypeNameHeaderText = Node Type Name
nodeTypeNameToolTip = The name of the node type definition
@@ -92,11 +119,16 @@
propertyNameToolTip = The name or identifier of the property definition
propertyTypeToolTip = The data type of the property definition
propertyValueConstraintsToolTip = The value constraints of a property definition
+qualifiedNameDialogMsg = Select a qualifier and edit the name value of the {0}.\nSelect
OK when finished editing.
+qualifiedNameDialogTitle = Qualified Name Editor
+qualifierLabel = Qualifier:
queryableAttribute = Queryable
queryableAttributeToolTip = Indicates if the node type can be queried
supertypesLabel = Supertypes:
requiredTypesHeaderText = Required Types
typeHeaderText = Type
+unqualifiedNameToolTip = The name part of the qualified name (cannot be empty)
+validQualifiersToolTip = The qualifiers known to this CND
valueConstraintsHeaderText = Value Constraints
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.gif
===================================================================
(Binary files differ)
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.png
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -40,6 +40,6 @@
/**
* The relative path from the plugin folder to the icon used for creating new
objects.
*/
- String NEW_16X = ICONS_FOLDER + "new-16x.gif"; //$NON-NLS-1$
+ String NEW_16X = ICONS_FOLDER + "new-16x.png"; //$NON-NLS-1$
}
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -82,9 +82,8 @@
@Test
public void emptyQualifiedNameQualifierShouldBeValid() {
-
assertTrue(CndValidator.validateQualifiedName(Constants.NAME_WITH_EMPTY_QUALIFIER,
"propertyName", //$NON-NLS-1$
-
Constants.Helper.getDefaultQualifiers()).isOk());
+
Constants.Helper.getDefaultQualifiers(), null).isOk());
}
@Test
@@ -95,7 +94,7 @@
@Test
public void invalidQualifiedNameQualifierShouldBeAnError() {
final QualifiedName qname = new QualifiedName(Constants.QUALIFIER1 +
"Changed", Constants.UNQUALIFIED_NAME1); //$NON-NLS-1$
- assertTrue(CndValidator.validateQualifiedName(qname, "propertyName",
Constants.Helper.getDefaultQualifiers()).isError()); //$NON-NLS-1$
+ assertTrue(CndValidator.validateQualifiedName(qname, "propertyName",
Constants.Helper.getDefaultQualifiers(), null).isError()); //$NON-NLS-1$
}
@Test
@@ -242,6 +241,26 @@
}
@Test
+ public void shouldNotAllDuplicateNamespacePrefixes() {
+ // create a namespace mapping with a prefix that already exists and a URI that
doesn't exist in the default namespaces
+ final NamespaceMapping namespaceMapping = new
NamespaceMapping(Constants.NAMESPACE_PREFIX1, "xyz"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateNamespaceMapping(namespaceMapping,
Constants.Helper.getDefaultNamespaces()).isError());
+ }
+
+ @Test
+ public void shouldNotAllDuplicateNamespaceUris() {
+ // create a namespace mapping with a URI that already exists and a prefix that
doesn't exist in the default namespaces
+ final NamespaceMapping namespaceMapping = new NamespaceMapping("xyz",
Constants.NAMESPACE_URI1); //$NON-NLS-1$
+ assertTrue(CndValidator.validateNamespaceMapping(namespaceMapping,
Constants.Helper.getDefaultNamespaces()).isError());
+ }
+
+ @Test
+ public void shouldNotAllDuplicateQualifiedNames() {
+ assertTrue(CndValidator.validateQualifiedName(Constants.QUALIFIED_NAME1,
+ "propertyName",
Constants.Helper.getDefaultQualifiers(),
Constants.Helper.getDefaultQualifiedNames()).isError()); //$NON-NLS-1$
+ }
+
+ @Test
public void shouldValidateAllQueryOperators() {
for (final QueryOperator operator : QueryOperator.values()) {
assertTrue(CndValidator.validateQueryOperator(operator.toString(),
"propName").isOk()); //$NON-NLS-1$
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -8,7 +8,7 @@
package org.jboss.tools.modeshape.jcr.cnd;
import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
@@ -37,6 +37,18 @@
*/
public interface Constants {
+ String NAMESPACE_PREFIX1 = "NAMESPACE_PREFIX1"; //$NON-NLS-1$
+ String NAMESPACE_PREFIX2 = "NAMESPACE_PREFIX2"; //$NON-NLS-1$
+ String NAMESPACE_PREFIX3 = "NAMESPACE_PREFIX3"; //$NON-NLS-1$
+
+ String NAMESPACE_URI1 = "NAMESPACE_URI1"; //$NON-NLS-1$
+ String NAMESPACE_URI2 = "NAMESPACE_URI2"; //$NON-NLS-1$
+ String NAMESPACE_URI3 = "NAMESPACE_URI3"; //$NON-NLS-1$
+
+ NamespaceMapping NAMESPACE1 = new NamespaceMapping(NAMESPACE_PREFIX1,
NAMESPACE_URI1);
+ NamespaceMapping NAMESPACE2 = new NamespaceMapping(NAMESPACE_PREFIX2,
NAMESPACE_URI2);
+ NamespaceMapping NAMESPACE3 = new NamespaceMapping(NAMESPACE_PREFIX3,
NAMESPACE_URI3);
+
String QUALIFIER1 = "QUALIFIER1"; //$NON-NLS-1$
String QUALIFIER2 = "QUALIFIER2"; //$NON-NLS-1$
String QUALIFIER3 = "QUALIFIER3"; //$NON-NLS-1$
@@ -187,20 +199,22 @@
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
String REQUIRED_TYPES_VARIANT = RequiredTypes.NOTATION_PREFIX + VARIANT +
RequiredTypes.NOTATION_SUFFIX;
- String REQUIRED_TYPES_ONE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
QUALIFIED_NAME1.get() + RequiredTypes.NOTATION_SUFFIX;
- String REQUIRED_TYPES_THREE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
QUALIFIED_NAME1.get()
- +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME2.get()
- +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME3.get()
+ String REQUIRED_TYPES_ONE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX + QUALIFIED_NAME1
+ RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_THREE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX +
QUALIFIED_NAME1
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME2
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME3
+ RequiredTypes.NOTATION_SUFFIX;
String SUPER_TYPES_VARIANT = SuperTypes.NOTATION_PREFIX
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ VARIANT;
String SUPER_TYPES_ONE_ITEM_FORM = SuperTypes.NOTATION_PREFIX
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
- + ONE_ITEM_SINGLE_QUOTED_FORM;
+ + QUALIFIED_NAME1;
String SUPER_TYPES_THREE_ITEM_FORM = SuperTypes.NOTATION_PREFIX
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
- + THREE_ITEM_SINGLE_QUOTED_FORM;
+ + QUALIFIED_NAME1
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME2
+ +
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ QUALIFIED_NAME3;
String VALUE_CONSTRAINTS_VARIANT = ValueConstraints.NOTATION_PREFIX
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ VARIANT;
@@ -224,12 +238,29 @@
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
class Helper {
- public static List<String> getDefaultQualifiers() {
- List<String> qualifiers = new ArrayList<String>();
+ public static Collection<NamespaceMapping> getDefaultNamespaces() {
+ Collection<NamespaceMapping> namespaces = new
ArrayList<NamespaceMapping>();
+ namespaces.add(NAMESPACE1);
+ namespaces.add(NAMESPACE2);
+ namespaces.add(NAMESPACE3);
+ return namespaces;
+ }
+
+ public static Collection<QualifiedName> getDefaultQualifiedNames() {
+ Collection<QualifiedName> qualifiedNames = new
ArrayList<QualifiedName>();
+ qualifiedNames.add(QUALIFIED_NAME1);
+ qualifiedNames.add(QUALIFIED_NAME2);
+ qualifiedNames.add(QUALIFIED_NAME3);
+ return qualifiedNames;
+ }
+
+ public static Collection<String> getDefaultQualifiers() {
+ Collection<String> qualifiers = new ArrayList<String>();
qualifiers.add(QUALIFIER1);
qualifiers.add(QUALIFIER2);
qualifiers.add(QUALIFIER3);
return qualifiers;
}
+
}
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -290,7 +290,7 @@
public void shouldReceiveEventAfterClearingSuperTypes() {
final String SUPER_TYPE = "superType"; //$NON-NLS-1$
assertTrue(this.nodeTypeDefinition.addSuperType(SUPER_TYPE));
- Collection<String> oldValue = Collections.singletonList(SUPER_TYPE);
+ Collection<QualifiedName> oldValue =
this.nodeTypeDefinition.getSupertypes();
Listener l = new Listener();
assertTrue(this.nodeTypeDefinition.addListener(l));
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java 2012-03-16
20:34:09 UTC (rev 39592)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java 2012-03-16
20:46:09 UTC (rev 39593)
@@ -15,6 +15,7 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
import org.jboss.tools.modeshape.jcr.cnd.Constants;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedName;
import org.junit.Before;
import org.junit.Test;
@@ -25,14 +26,14 @@
private SuperTypes attribute;
- private void add( String item ) {
- if (!this.attribute.add(item)) {
+ private void add( QualifiedName qname ) {
+ if (!this.attribute.add(qname)) {
fail();
}
}
- private void remove( String item ) {
- if (!this.attribute.remove(item)) {
+ private void remove( QualifiedName qname ) {
+ if (!this.attribute.remove(qname)) {
fail();
}
}
@@ -52,11 +53,11 @@
@Test
public void verifyAddedItem() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
assertEquals(1, this.attribute.getSupportedItems().size());
- assertTrue(this.attribute.getSupportedItems().contains(ITEM_ONE));
+ assertTrue(this.attribute.getSupportedItems().contains(QUALIFIED_NAME1));
}
@Test
@@ -72,9 +73,9 @@
@Test
public void verifyMultipleElementsCndNotation() {
// setup
- add(ITEM_ONE);
- add(ITEM_TWO);
- add(ITEM_THREE);
+ add(QUALIFIED_NAME1);
+ add(QUALIFIED_NAME2);
+ add(QUALIFIED_NAME3);
// tests
assertEquals(SUPER_TYPES_THREE_ITEM_FORM,
this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
@@ -85,7 +86,7 @@
@Test
public void verifyOneElementCndNotation() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
assertEquals(SUPER_TYPES_ONE_ITEM_FORM,
this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
@@ -96,21 +97,21 @@
@Test
public void verifyRemoveItem() {
// setup
- add(ITEM_ONE);
- add(ITEM_TWO);
- remove(ITEM_ONE);
+ add(QUALIFIED_NAME1);
+ add(QUALIFIED_NAME2);
+ remove(QUALIFIED_NAME1);
// tests
- assertFalse(this.attribute.getSupportedItems().contains(ITEM_ONE));
+ assertFalse(this.attribute.getSupportedItems().contains(QUALIFIED_NAME1));
}
@Test
public void verifySameElementIsNotAdded() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
- if (this.attribute.add(ITEM_ONE)) {
+ if (this.attribute.add(QUALIFIED_NAME1)) {
fail();
}
@@ -120,7 +121,7 @@
@Test
public void verifyStateShouldBeIsAfterAdd() {
// setup
- add(ITEM_ONE);
+ add(QUALIFIED_NAME1);
// tests
assertEquals(AttributeState.Value.IS, this.attribute.get());
@@ -129,8 +130,8 @@
@Test
public void verifyStateShouldBeIsNotWhenEmpty() {
// setup
- add(ITEM_ONE);
- remove(ITEM_ONE);
+ add(QUALIFIED_NAME1);
+ remove(QUALIFIED_NAME1);
// tests
assertEquals(0, this.attribute.getSupportedItems().size());