Author: elvisisking
Date: 2012-04-03 13:25:43 -0400 (Tue, 03 Apr 2012)
New Revision: 40012
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/show-inherited-16x.gif
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/cnd/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/cnd/jsr_283_builtins.cnd
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/cnd/
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/cnd/jsr_283_builtins.cnd
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java
Removed:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java
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/NamespaceMappingDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.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/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.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/NamespaceMapping.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.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/CompactNodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/build.properties
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.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/CompactNodeTypeDefinitionTest.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/test/AllTests.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Added an option to
show/hide inherited property definitions and child node definitions. QualifiedNameEditor
now sorts the qualifiers. URIs of built-in namespaces are autopopulated in the
NamespaceMappingEditor. Query operators now cannot be edited if their owning node type is
not queryable. Fixed an issue where the editor was staying writable when the file was
changed to readonly from outside Eclipse. Property definitions of type NAME are now
validated correctly.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF 2012-04-03
14:26:17 UTC (rev 40011)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF 2012-04-03
17:25:43 UTC (rev 40012)
@@ -8,7 +8,8 @@
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Import-Package: org.eclipse.osgi.util
-Require-Bundle: org.jboss.tools.modeshape.client
+Require-Bundle: org.jboss.tools.modeshape.client,
+ org.eclipse.core.runtime
Export-Package: org.jboss.tools.modeshape.jcr,
org.jboss.tools.modeshape.jcr.attributes,
org.jboss.tools.modeshape.jcr.cnd
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties 2012-04-03
14:26:17 UTC (rev 40011)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties 2012-04-03
17:25:43 UTC (rev 40012)
@@ -11,7 +11,8 @@
#
bin.includes = META-INF/,\
.,\
- OSGI-INF/
+ OSGI-INF/,\
+ cnd/jsr_283_builtins.cnd
jars.compile.order = .
source.. = src/
output.. = bin/
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/cnd/jsr_283_builtins.cnd
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/cnd/jsr_283_builtins.cnd
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/cnd/jsr_283_builtins.cnd 2012-04-03
17:25:43 UTC (rev 40012)
@@ -0,0 +1,183 @@
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+// ------------------------------------------------------------------------
+// Pre-defined Node Types
+// ------------------------------------------------------------------------
+
+[nt:base] abstract
+ - jcr:primaryType (name) mandatory autocreated
+ protected compute
+ - jcr:mixinTypes (name) protected multiple compute
+
+[nt:unstructured]
+ orderable
+ - * (undefined) multiple
+ - * (undefined)
+ + * (nt:base) = nt:unstructured sns version
+
+[mix:created] mixin
+ - jcr:created (date) protected
+ - jcr:createdBy (string) protected
+
+[nt:hierarchyNode] > mix:created abstract
+
+[nt:file] > nt:hierarchyNode
+ + jcr:content (nt:base) primary mandatory
+
+[nt:linkedFile] > nt:hierarchyNode
+ - jcr:content (reference) primary mandatory
+
+[nt:folder] > nt:hierarchyNode
+ + * (nt:hierarchyNode) version
+
+[mix:referenceable] mixin
+ - jcr:uuid (string) mandatory autocreated protected initialize
+
+[mix:mimeType] mixin
+ - jcr:mimeType (string)
+ - jcr:encoding (string)
+
+[mix:lastModified] mixin
+ - jcr:lastModified (date)
+ - jcr:lastModifiedBy (string)
+
+[nt:resource] > mix:mimeType, mix:lastModified
+ - jcr:data (binary) primary mandatory
+
+[nt:nodeType]
+ - jcr:nodeTypeName (name) mandatory protected copy
+ - jcr:supertypes (name) multiple protected copy
+ - jcr:isAbstract (boolean) mandatory protected copy
+ - jcr:isMixin (boolean) mandatory protected copy
+ - jcr:isQueryable (boolean) mandatory protected copy
+ - jcr:hasOrderableChildNodes (boolean) mandatory protected copy
+ - jcr:primaryItemName (name) protected copy
+ + jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition sns protected
copy
+ + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition sns
protected copy
+
+[nt:propertyDefinition]
+ - jcr:name (name) protected
+ - jcr:autoCreated (boolean) mandatory protected
+ - jcr:mandatory (boolean) mandatory protected
+ - jcr:isFullTextSearchable (boolean) mandatory protected
+ - jcr:isQueryOrderable (boolean) mandatory protected
+ - jcr:onParentVersion (string) mandatory protected
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
+ 'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory protected
+ - jcr:requiredType (string) mandatory protected
+ < 'STRING', 'URI', 'BINARY', 'LONG',
'DOUBLE', 'DECIMAL', 'BOOLEAN',
+ 'DATE', 'NAME', 'PATH', 'REFERENCE',
'WEAKREFERENCE', 'UNDEFINED'
+ - jcr:valueConstraints (string) multiple protected
+ - jcr:availableQueryOperators (name) mandatory multiple protected
+ - jcr:defaultValues (undefined) multiple protected
+ - jcr:multiple (boolean) mandatory protected
+
+[nt:childNodeDefinition]
+ - jcr:name (name) protected
+ - jcr:autoCreated (boolean) mandatory protected
+ - jcr:mandatory (boolean) mandatory protected
+ - jcr:onParentVersion (string) mandatory protected
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
+ 'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory protected
+ - jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory protected multiple
+ - jcr:defaultPrimaryType (name) protected
+ - jcr:sameNameSiblings (boolean) mandatory protected
+
+[nt:versionHistory] > mix:referenceable
+ - jcr:versionableUuid (string) mandatory autocreated protected abort
+ - jcr:copiedFrom (weakreference) protected abort < 'nt:version'
+ + jcr:rootVersion (nt:version) = nt:version mandatory autocreated protected abort
+ + jcr:versionLabels (nt:versionLabels) = nt:versionLabels mandatory autocreated
protected abort
+ + * (nt:version) = nt:version protected abort
+
+
+[nt:versionLabels]
+ - * (reference) protected abort < 'nt:version'
+
+[nt:version] > mix:referenceable
+ - jcr:created (date) mandatory autocreated protected abort
+ - jcr:predecessors (reference) protected multiple abort < 'nt:version'
+ - jcr:successors (reference) protected multiple abort < 'nt:version'
+ - jcr:activity (reference) protected abort < 'nt:activity'
+ + jcr:frozenNode (nt:frozenNode) protected abort
+
+[nt:frozenNode] > mix:referenceable
+ orderable
+ - jcr:frozenPrimaryType (name) mandatory autocreated protected abort
+ - jcr:frozenMixinTypes (name) protected multiple abort
+ - jcr:frozenUuid (string) mandatory autocreated protected abort
+ - * (undefined) protected abort
+ - * (undefined) protected multiple abort
+ + * (nt:base) protected sns abort
+
+[nt:versionedChild]
+ - jcr:childVersionHistory (reference) mandatory autocreated protected abort <
'nt:versionHistory'
+
+[nt:query]
+ - jcr:statement (string)
+ - jcr:language (string)
+
+[nt:activity] > mix:referenceable
+ - jcr:activityTitle (string) mandatory autocreated protected
+
+
+[mix:simpleVersionable] mixin
+ - jcr:isCheckedOut (boolean) = 'true' mandatory autocreated protected ignore
+
+[mix:versionable] > mix:simpleVersionable, mix:referenceable mixin
+ - jcr:versionHistory (reference) mandatory protected ignore <
'nt:versionHistory'
+ - jcr:baseVersion (reference) mandatory protected ignore < 'nt:version'
+ - jcr:predecessors (reference) mandatory protected multiple ignore <
'nt:version'
+ - jcr:mergeFailed (reference) protected multiple abort
+ - jcr:activity (reference) protected < 'nt:version'
+ - jcr:configuration (reference) protected ignore < 'nt:configuration'
+
+[nt:configuration] > mix:versionable
+ - jcr:root (reference) mandatory autocreated protected
+
+[nt:address]
+ - jcr:protocol (string)
+ - jcr:host (string)
+ - jcr:port (string)
+ - jcr:repository (string)
+ - jcr:workspace (string)
+ - jcr:path (path)
+ - jcr:id (weakreference)
+
+[nt:naturalText]
+ - jcr:text (string)
+ - jcr:messageId (string)
+
+
+// ------------------------------------------------------------------------
+// Pre-defined Mixins
+// ------------------------------------------------------------------------
+
+[mix:etag] mixin
+ - jcr:etag (string) protected autocreated
+
+[mix:lockable] mixin
+ - jcr:lockOwner (string) protected ignore
+ - jcr:lockIsDeep (boolean) protected ignore
+
+[mix:lifecycle] mixin
+ - jcr:lifecyclePolicy (reference) protected initialize
+ - jcr:currentLifecycleState (string) protected initialize
+
+[mix:managedRetention] > mix:referenceable mixin
+ - jcr:hold (string) protected multiple
+ - jcr:isDeep (boolean) protected multiple
+ - jcr:retentionPolicy (reference) protected
+
+[mix:shareable] > mix:referenceable mixin
+
+[mix:title] mixin
+ - jcr:title (string)
+ - jcr:description (string)
+
+[mix:language] mixin
+ - jcr:language (string)
\ No newline at end of file
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -193,6 +193,12 @@
public static String invalidGetStateRequest;
/**
+ * A message indicating a default value of a property definition with a NAME type has
an invalid qualifier. Two parameters, the
+ * property definition name and the default value, are required.
+ */
+ public static String invalidQualifierForDefaultValue;
+
+ /**
* A message indicating an invalid property valid was found. The parameters of
invalid property value, property type, and
* property definition name are required.
*/
@@ -210,6 +216,18 @@
public static String invalidUri;
/**
+ * An error message indicating that the JSR built-ins CND could not be found in the
workspace. One parameter, the path of the
+ * CND file, is required.
+ */
+ public static String jsrBuiltInsCndFileNotFound;
+
+ /**
+ * An error message indicating that the JSR built-ins CND could not be found in the
filesystem. One parameter, the path of the
+ * CND file, is required.
+ */
+ public static String jsrBuiltInsCndFileNotFoundInFilesystem;
+
+ /**
* A message indicating a name equal to parent or self was found. One parameter, a
string identifying the name, is required.
*/
public static String localNameEqualToSelfOrParent;
@@ -263,7 +281,7 @@
* A message used for the node type definition name property.
*/
public static String nodeTypeDefinitionName;
-
+
/**
* A message indicating a <code>null</code> was found. One parameter, a
string identifying the object, is required.
*/
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -251,37 +251,6 @@
}
/**
- * The built-in namespace mappings.
- */
- public interface BuiltIns {
-
- /**
- * Reserved for items defined within built-in node types.
- */
- NamespaceMapping JCR = new NamespaceMapping("jcr",
"http://www.jcp.org/jcr/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Reserved for the names of built-in mixin node types.
- */
- NamespaceMapping MIX = new NamespaceMapping("mix",
"http://www.jcp.org/jcr/mix/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Reserved for the names of built-in primary node types.
- */
- NamespaceMapping NT = new NamespaceMapping("nt",
"http://www.jcp.org/jcr/nt/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Reserved for reasons of compatibility with XML.
- */
- NamespaceMapping XML = new NamespaceMapping("xml",
"http://www.w3.org/XML/1998/namespace"); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * A collection of all built-in namespace mappings.
- */
- NamespaceMapping[] ALL_BUILT_INS = new NamespaceMapping[] { JCR, NT, MIX, XML };
- }
-
- /**
* 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/NodeTypeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -89,14 +89,9 @@
private final NodeTypeAttributes attributes;
/**
- * The collection of CND elements (can be <code>null</code>).
+ * The collection of property definitions and child node definitions (can be
<code>null</code>).
*/
private List<CndElement> cndElements;
- //
- // /**
- // * The collection of child node definitions (can be
<code>null</code>).
- // */
- // private List<ChildNodeDefinition> childNodesDefinitions;
/**
* The collection of property change listeners (never
<code>null</code>).
@@ -107,11 +102,6 @@
* The node type name (never <code>null</code> but can have a
<code>null</code> or empty value).
*/
private final QualifiedName name;
- //
- // /**
- // * The collection of property definitions (can be <code>null</code>).
- // */
- // private List<PropertyDefinition> propertyDefinitions;
/**
* The super types (never <code>null</code>).
@@ -531,6 +521,42 @@
}
/**
+ * Inherited child node definitions are not checked.
+ *
+ * @param name the child node definition name being searched for (cannot be
<code>null</code> or empty)
+ * @return <code>true</code> if a child node definition with the
specified name was found
+ */
+ public boolean hasDeclaredChildNodeDefinition( final String name ) {
+ Utils.verifyIsNotEmpty(name, "name"); //$NON-NLS-1$
+
+ for (final ChildNodeDefinition childNode : getChildNodeDefinitions()) {
+ if (name.equals(childNode.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Inherited property definitions are not checked.
+ *
+ * @param name the property definition name being searched for (cannot be
<code>null</code> or empty)
+ * @return <code>true</code> if a property definition with the specified
name was found
+ */
+ public boolean hasDeclaredPropertyDefinition( final String name ) {
+ Utils.verifyIsNotEmpty(name, "name"); //$NON-NLS-1$
+
+ for (final PropertyDefinition prop : getPropertyDefinitions()) {
+ if (name.equals(prop.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
@@ -538,10 +564,8 @@
@Override
public int hashCode() {
final int result1 = Utils.hashCode(this.name, this.attributes, this.superTypes);
- final int result2 = Utils.hashCode(getChildNodeDefinitions().toArray());
- final int result3 = Utils.hashCode(getPropertyDefinitions().toArray());
-
- return Utils.hashCode(result1, result2, result3);
+ final int result2 = Utils.hashCode(getElements().toArray());
+ return Utils.hashCode(result1, result2);
}
/**
@@ -822,11 +846,12 @@
}
{ // elements
- final String elementStartDelimiter =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENTS_START_DELIMITER);
- final String elementDelimiter =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENT_DELIMITER);
final List<CndElement> elements = getElements();
if (!Utils.isEmpty(elements)) {
+ final String elementStartDelimiter =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENTS_START_DELIMITER);
+ final String elementDelimiter =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENT_DELIMITER);
+
for (final CndElement element : elements) {
builder.append(elementStartDelimiter);
builder.append(element.toCndNotation(notationType));
@@ -900,5 +925,4 @@
return (getClass().getName() + '.' + super.toString());
}
}
-
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -20,6 +20,10 @@
public final class Utils {
/**
+ * The plug-in bundle's symbolic name.
+ */
+ public static final String PLUGIN_ID = Utils.class.getPackage().getName();
+ /**
* And empty object array.
*/
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -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;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.modeshape.jcr.cnd.CndImporter;
+import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
+import org.osgi.framework.Bundle;
+
+/**
+ * A registry containing {@link NamespaceMapping namespace mappings} and {@link
NodeTypeDefinition node type definitions}. At
+ * construction the registry holds the built-in JSR namespaces and node types.
+ */
+public class WorkspaceRegistry {
+
+ private static WorkspaceRegistry _registry;
+
+ private static String BUILT_INS_CND_FILE_NAME = "cnd/jsr_283_builtins.cnd";
//$NON-NLS-1$
+
+ /**
+ * @return the shared instance of the workspace registry (never
<code>null</code>)
+ * @throws Exception if there is a problem loading the registry
+ */
+ public static WorkspaceRegistry get() throws Exception {
+ if (_registry == null) {
+ _registry = new WorkspaceRegistry();
+ }
+
+ return _registry;
+ }
+
+ private final Collection<NamespaceMapping> namespaces;
+
+ private final Collection<NodeTypeDefinition> nodeTypes;
+
+ /**
+ * Don't allow construction outside of this class.
+ */
+ private WorkspaceRegistry() throws Exception {
+ final CndImporter importer = new CndImporter();
+ final List<Throwable> errors = new ArrayList<Throwable>();
+ File builtInsCndFile = null;
+
+ if (Platform.isRunning()) {
+ Bundle bundle = Platform.getBundle(Utils.PLUGIN_ID);
+ URL url = bundle.getEntry(BUILT_INS_CND_FILE_NAME);
+
+ if (url == null) {
+ throw new Exception(NLS.bind(Messages.jsrBuiltInsCndFileNotFound,
BUILT_INS_CND_FILE_NAME));
+ }
+
+ builtInsCndFile = new
File(org.eclipse.core.runtime.FileLocator.toFileURL(url).getFile());
+
+ if (!builtInsCndFile.exists()) {
+ throw new
Exception(NLS.bind(Messages.jsrBuiltInsCndFileNotFoundInFilesystem,
BUILT_INS_CND_FILE_NAME));
+ }
+ } else {
+ // when running unit tests
+ builtInsCndFile = new File(BUILT_INS_CND_FILE_NAME);
+ }
+
+ final CompactNodeTypeDefinition jsrBuiltIns =
importer.importFrom(builtInsCndFile, errors);
+
+ // check for parse errors
+ if (!errors.isEmpty()) {
+ final Throwable t = errors.iterator().next();
+
+ if (t.getCause() == null) {
+ throw new RuntimeException(t);
+ }
+
+ throw new Exception(t.getCause());
+ }
+
+ this.namespaces = new ArrayList<NamespaceMapping>();
+ this.nodeTypes = new ArrayList<NodeTypeDefinition>();
+
+ // register namespace mappings
+ for (final NamespaceMapping namespace : jsrBuiltIns.getNamespaceMappings()) {
+ assert !CndValidator.validateNamespaceMapping(namespace).isError() :
"Invalid namespace " + namespace; //$NON-NLS-1$
+ this.namespaces.add(namespace);
+ }
+
+ // register node type definitions
+ for (final NodeTypeDefinition nodeType : jsrBuiltIns.getNodeTypeDefinitions()) {
+ assert !CndValidator.validateNodeTypeDefinition(nodeType, getPrefixes(),
null, true).isError() : "Invalid node type definition " //$NON-NLS-1$
+ + nodeType.getName();
+ this.nodeTypes.add(nodeType);
+ }
+ }
+
+ /**
+ * @param nodeTypeDefinitionName the name of the node type definition whose child
nodes are being requested (cannot be
+ * <code>null</code> or empty)
+ * @param includeInherited indicates if inherited child nodes should be included
+ * @return the child nodes (never <code>null</code>)
+ */
+ public Collection<ChildNodeDefinition> getChildNodeDefinitions( final String
nodeTypeDefinitionName,
+ final boolean
includeInherited ) {
+ final NodeTypeDefinition nodeType =
getNodeTypeDefinition(nodeTypeDefinitionName);
+
+ if (nodeType == null) {
+ return Collections.emptyList();
+ }
+
+ final Collection<ChildNodeDefinition> childNodes = new
ArrayList<ChildNodeDefinition>(nodeType.getChildNodeDefinitions());
+
+ if (includeInherited) {
+ for (final QualifiedName superType : nodeType.getSupertypes()) {
+ final NodeTypeDefinition superTypeNodeType =
getNodeTypeDefinition(superType.get());
+
+ if (superTypeNodeType != null) {
+
childNodes.addAll(getChildNodeDefinitions(superTypeNodeType.getName(), true));
+ }
+ }
+ }
+
+ return childNodes;
+ }
+
+ /**
+ * @param prefix the prefix whose namespace mapping is being requested (cannot be
<code>null</code> or empty)
+ * @return thre requested namespace mapping or <code>null</code> if not
found
+ */
+ public NamespaceMapping getNamespaceMapping( final String prefix ) {
+ Utils.verifyIsNotEmpty(prefix, "prefix"); //$NON-NLS-1$
+
+ for (final NamespaceMapping namespace : getNamespaceMappings()) {
+ if (namespace.getPrefix().equals(prefix)) {
+ return namespace;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return an unmodifiable collection of namespace mappings (never
<code>null</code>)
+ */
+ public Collection<NamespaceMapping> getNamespaceMappings() {
+ return Collections.unmodifiableCollection(this.namespaces);
+ }
+
+ /**
+ * @param name the name of the node type definition being requested (cannot be
<code>null</code> or empty)
+ * @return the node type definition or <code>null</code> if not found
+ */
+ public NodeTypeDefinition getNodeTypeDefinition( final String name ) {
+ Utils.verifyIsNotEmpty(name, "name"); //$NON-NLS-1$
+
+ for (final NodeTypeDefinition nodeType : getNodeTypeDefinitions()) {
+ if (nodeType.getName().equals(name)) {
+ return nodeType;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return an unmodifiable collection of all primary and mixin node type definitions
(never <code>null</code>)
+ */
+ public Collection<NodeTypeDefinition> getNodeTypeDefinitions() {
+ return Collections.unmodifiableCollection(this.nodeTypes);
+ }
+
+ /**
+ * @param uri the URI whose prefix is being requested (cannot be
<code>null</code> or empty)
+ * @return the prefix or <code>null</code> if a namespace mapping was not
found
+ */
+ public String getPrefix( final String uri ) {
+ Utils.verifyIsNotEmpty(uri, "uri"); //$NON-NLS-1$
+
+ for (final NamespaceMapping namespace : this.namespaces) {
+ if (namespace.getUri().equals(uri)) {
+ return namespace.getPrefix();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return the registered prefixes (never <code>null</code>)
+ */
+ public Collection<String> getPrefixes() {
+ final Collection<String> prefixes = new
ArrayList<String>(this.namespaces.size());
+
+ for (final NamespaceMapping namespace : this.namespaces) {
+ prefixes.add(namespace.getPrefix());
+ }
+
+ return prefixes;
+ }
+
+ /**
+ * @param nodeTypeDefinitionName the name of the node type definition whose
properties are being requested (cannot be
+ * <code>null</code> or empty)
+ * @param includeInherited indicates if inherited properties should be included
+ * @return the properties (never <code>null</code>)
+ */
+ public Collection<PropertyDefinition> getPropertyDefinitions( final String
nodeTypeDefinitionName,
+ final boolean
includeInherited ) {
+ final NodeTypeDefinition nodeType =
getNodeTypeDefinition(nodeTypeDefinitionName);
+
+ if (nodeType == null) {
+ return Collections.emptyList();
+ }
+
+ final Collection<PropertyDefinition> properties = new
ArrayList<PropertyDefinition>(nodeType.getPropertyDefinitions());
+
+ if (includeInherited) {
+ for (final QualifiedName superType : nodeType.getSupertypes()) {
+ final NodeTypeDefinition superTypeNodeType =
getNodeTypeDefinition(superType.get());
+
+ if (superTypeNodeType != null) {
+ properties.addAll(getPropertyDefinitions(superTypeNodeType.getName(),
true));
+ }
+ }
+ }
+
+ return properties;
+ }
+
+ /**
+ * @param prefix the prefix whose URI is being requested (cannot be
<code>null</code> or empty)
+ * @return the URI or <code>null</code> if the namespace mapping does not
exist
+ */
+ public String getUri( final String prefix ) {
+ Utils.verifyIsNotEmpty(prefix, "prefix"); //$NON-NLS-1$
+
+ for (final NamespaceMapping namespace : this.namespaces) {
+ if (namespace.getPrefix().equals(prefix)) {
+ return namespace.getUri();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return the registered prefixes (never <code>null</code>)
+ */
+ public Collection<String> getUris() {
+ final Collection<String> uris = new
ArrayList<String>(this.namespaces.size());
+
+ for (final NamespaceMapping namespace : this.namespaces) {
+ uris.add(namespace.getUri());
+ }
+
+ return uris;
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -97,7 +97,7 @@
PropertyType.LONG));
}
} else if (PropertyType.NAME == propertyType) {
- return validateLocalName(value, propertyName);
+ return validateQualifiedName(QualifiedName.parse(value), propertyName,
null, null);
} else if (PropertyType.PATH == propertyType) {
return validatePath(value, propertyName);
} else if (PropertyType.REFERENCE == propertyType) {
@@ -359,19 +359,23 @@
/**
* @param propertyDefinition the property definition whose default values are being
validated (cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
- public static MultiValidationStatus validateDefaultValues( final PropertyDefinition
propertyDefinition ) {
+ public static MultiValidationStatus validateDefaultValues( final PropertyDefinition
propertyDefinition,
+ final
Collection<String> validNamespacePrefixes ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateDefaultValues(propertyDefinition, status);
+ validateDefaultValues(propertyDefinition, validNamespacePrefixes, status);
return status;
}
/**
* @param propertyDefinition the property definition whose default values are being
validated (cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param status the status to add the new status to (cannot be
<code>null</code>)
*/
public static void validateDefaultValues( final PropertyDefinition
propertyDefinition,
+ final Collection<String>
validNamespacePrefixes,
final MultiValidationStatus status ) {
Utils.verifyIsNotNull(propertyDefinition, "propertyDefinition");
//$NON-NLS-1$
Utils.verifyIsNotNull(status, "status"); //$NON-NLS-1$
@@ -402,6 +406,27 @@
// ERROR - Default value is not valid for the property definition type
isValid(defaultValue, propertyDefinition.getType(),
Messages.defaultValue, status);
+ // make sure if NAME type the qualifier is valid
+ if (!Utils.isEmpty(validNamespacePrefixes) &&
propertyDefinition.getType() == PropertyType.NAME) {
+ QualifiedName qname = QualifiedName.parse(defaultValue);
+ String qualifier = qname.getQualifier();
+ boolean valid = false;
+
+ if (!Utils.isEmpty(qualifier)) {
+ for (String validQualifier : validNamespacePrefixes) {
+ if (validQualifier.equals(qualifier)) {
+ valid = true;
+ break;
+ }
+ }
+ }
+
+ if (!valid) {
+
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidQualifierForDefaultValue,
+
propertyName, defaultValue)));
+ }
+ }
+
if (!Utils.isEmpty(defaultValue)) {
// ERROR - Duplicate default value
if (values.contains(defaultValue)) {
@@ -1068,7 +1093,7 @@
}
{ // default values
- validateDefaultValues(propertyDefinition, status);
+ validateDefaultValues(propertyDefinition, validNamespacePrefixes, status);
}
{ // value constraints
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -15,9 +15,13 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
import org.jboss.tools.modeshape.jcr.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.NodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.PropertyDefinition;
+import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
@@ -208,6 +212,43 @@
return true;
}
+ /**
+ * The node type definition must exist in this CND for it to return child nodes.
+ *
+ * @param nodeTypeDefinitionName the name of the node type definition whose child
nodes are being requested (cannot be
+ * <code>null</code> or empty)
+ * @param includeInherited indicates if inherited child nodes should be included
+ * @return the child nodes (never <code>null</code>)
+ * @throws Exception if there is a problem obtaining the inherited child node
definitions
+ */
+ public Collection<ChildNodeDefinition> getChildNodeDefinitions( final String
nodeTypeDefinitionName,
+ final boolean
includeInherited ) throws Exception {
+ final NodeTypeDefinition nodeType =
getNodeTypeDefinition(nodeTypeDefinitionName);
+
+ // if not found in CND return empty collection
+ if (nodeType == null) {
+ return Collections.emptyList();
+ }
+
+ // first add declared child nodes
+ final Collection<ChildNodeDefinition> childNodes = new
ArrayList<ChildNodeDefinition>(nodeType.getChildNodeDefinitions());
+
+ // now add inherited child nodes
+ if (includeInherited) {
+ for (final QualifiedName superType : nodeType.getSupertypes()) {
+ final NodeTypeDefinition superTypeNodeType =
getNodeTypeDefinition(superType.get());
+
+ if (superTypeNodeType == null) {
+
childNodes.addAll(WorkspaceRegistry.get().getChildNodeDefinitions(nodeTypeDefinitionName,
true));
+ } else {
+
childNodes.addAll(getChildNodeDefinitions(superTypeNodeType.getName(), true));
+ }
+ }
+ }
+
+ return childNodes;
+ }
+
private String getEndNamespaceMappingSectionDelimiter() {
return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NAMESPACE_MAPPING_SECTION_END_DELIMITER);
}
@@ -250,6 +291,22 @@
return prefixes;
}
+ /**
+ * @param name the name of the node type definition being requested (cannot be
<code>null</code> or empty)
+ * @return the node type definition or <code>null</code> if not found
+ */
+ public NodeTypeDefinition getNodeTypeDefinition( final String name ) {
+ Utils.verifyIsNotEmpty(name, "name"); //$NON-NLS-1$
+
+ for (final NodeTypeDefinition ntd : getNodeTypeDefinitions()) {
+ if (name.equals(ntd.getName())) {
+ return ntd;
+ }
+ }
+
+ return null;
+ }
+
private String getNodeTypeDefinitionDelimiter() {
return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_DELIMITER);
}
@@ -266,6 +323,43 @@
}
/**
+ * The node type definition must exist in this CND for it to return properties.
+ *
+ * @param nodeTypeDefinitionName the name of the node type definition whose
properties are being requested (cannot be
+ * <code>null</code> or empty)
+ * @param includeInherited indicates if inherited properties should be included
+ * @return the properties (never <code>null</code>)
+ * @throws Exception if there is a problem obtaining inherited property definitions
+ */
+ public Collection<PropertyDefinition> getPropertyDefinitions( final String
nodeTypeDefinitionName,
+ final boolean
includeInherited ) throws Exception {
+ final NodeTypeDefinition nodeType =
getNodeTypeDefinition(nodeTypeDefinitionName);
+
+ // if not found in CND return empty collection
+ if (nodeType == null) {
+ return Collections.emptyList();
+ }
+
+ // first add declared properties
+ final Collection<PropertyDefinition> properties = new
ArrayList<PropertyDefinition>(nodeType.getPropertyDefinitions());
+
+ // now add inherited properties
+ if (includeInherited) {
+ for (final QualifiedName superType : nodeType.getSupertypes()) {
+ final NodeTypeDefinition superTypeNodeType =
getNodeTypeDefinition(superType.get());
+
+ if (superTypeNodeType == null) {
+
properties.addAll(WorkspaceRegistry.get().getPropertyDefinitions(nodeTypeDefinitionName,
true));
+ } else {
+ properties.addAll(getPropertyDefinitions(superTypeNodeType.getName(),
true));
+ }
+ }
+ }
+
+ return properties;
+ }
+
+ /**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-04-03
17:25:43 UTC (rev 40012)
@@ -67,12 +67,18 @@
invalidFindUsingJcrValueRequest = The "findUsingJcrValue" method cannot be used
for a value of "{0}."
# 0 = property definition name
invalidGetStateRequest = The "getState" method cannot be used for property
"{0}."
+# 0 = property definition name, 1 = default value with the invalid qualifier
+invalidQualifierForDefaultValue = Property definition "{0}" has a default value
of "{1}" that does not have a valid qualifier.
# 0 = invalid query operator
invalidQueryOperator = Expected a valid query operator ('=', '<>',
'<', '<=', '>', '>=', or 'LIKE'), but
was "{0}" for property definition "{1}."
# 0 = property value, 1 = property type, 2 = property definition name
invalidPropertyValueForType = The value "{0}" is not valid for a
"{1}" property type in property "{2}."
# 0 = URI value
invalidUri = "{0}" is not a valid URI.
+# 0 = path to CND file
+jsrBuiltInsCndFileNotFound = The JSR built-ins CND file "{0}" could not be
found in workspace.
+# 0 = path to CND file
+jsrBuiltInsCndFileNotFoundInFilesystem = The JSR built-ins CND file "{0}" could
not be found in the filesystem.
# 0 = a name
localNameEqualToSelfOrParent = The "{0}" cannot be equal to self (dot) or
parent (dot dot).
# 0 = property or attribute name
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/show-inherited-16x.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/show-inherited-16x.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -69,5 +69,10 @@
* The relative path from the plugin folder to the icon used for the CND editor.
*/
String CND_EDITOR = ICONS_FOLDER + "cnd-editor-16x.png"; //$NON-NLS-1$
+
+ /**
+ * The relative path from the plugin folder to the icon used to show inherited
properties and child nodes.
+ */
+ String SHOW_INHERITED = ICONS_FOLDER + "show-inherited-16x.gif";
//$NON-NLS-1$
}
}
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -536,6 +536,8 @@
hookRefreshListener();
}
+
+ refreshReadOnlyState();
}
/**
@@ -670,7 +672,6 @@
public void setFocus() {
super.setFocus();
refreshCnd();
- refreshReadOnlyState();
}
/**
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -17,6 +17,8 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
@@ -45,7 +47,9 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -79,6 +83,8 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.ui.Activator;
+import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
import org.jboss.tools.modeshape.jcr.ui.JcrUiUtils;
import org.jboss.tools.modeshape.ui.UiMessages;
import org.jboss.tools.modeshape.ui.UiUtils;
@@ -93,7 +99,6 @@
class CndFormsEditorPage extends CndEditorPage implements PropertyChangeListener {
private IAction addChildNode;
-
private IAction addNamespace;
private IAction addNodeType;
private IAction addProperty;
@@ -124,6 +129,8 @@
private Section propertiesSection;
private TableViewer propertyViewer;
private NodeTypeDefinition selectedNodeType; // needed for property changes (can be
null)
+ private IAction showInheritedChildNodes;
+ private IAction showInheritedProperties;
private TableViewer superTypesViewer;
private Text txtFilter;
@@ -204,6 +211,22 @@
this.editChildNode.setEnabled(false);
this.editChildNode.setToolTipText(CndMessages.editChildNodeToolTip);
this.editChildNode.setImageDescriptor(JcrUiUtils.getEditImageDescriptor());
+
+ this.showInheritedChildNodes = new Action(Utils.EMPTY_STRING, SWT.TOGGLE) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleShowInheritedChildNodesChanged();
+ }
+ };
+
this.showInheritedChildNodes.setToolTipText(CndMessages.showInheritedChildNodesToolTip);
+ this.showInheritedChildNodes.setImageDescriptor(Activator.getSharedInstance()
+
.getImageDescriptor(JcrUiConstants.Images.SHOW_INHERITED));
}
private void createChildNodeSection( final IManagedForm managedForm,
@@ -238,7 +261,8 @@
toolkit.paintBordersFor(container);
// create toolbar
- FormUtils.createToolBar(container, toolkit, new IAction[] { this.addChildNode,
this.editChildNode, this.deleteChildNode });
+ FormUtils.createToolBar(container, toolkit, new IAction[] { this.addChildNode,
this.editChildNode, this.deleteChildNode,
+ this.showInheritedChildNodes });
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
@@ -266,6 +290,46 @@
/**
* {@inheritDoc}
*
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
+ */
+ @Override
+ public Color getBackground( Object element ) {
+ final ChildNodeDefinition childNodeDefinition =
(ChildNodeDefinition)element;
+
+ if (shouldShowInheritedChildNodes()) {
+ NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if
(!nodeTypeDefinition.hasDeclaredChildNodeDefinition(childNodeDefinition.getName())) {
+ return
getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+ }
+ }
+
+ return super.getBackground(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getFont(java.lang.Object)
+ */
+ @Override
+ public Font getFont( Object element ) {
+ final ChildNodeDefinition childNodeDefinition =
(ChildNodeDefinition)element;
+
+ if (shouldShowInheritedChildNodes()) {
+ NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if
(!nodeTypeDefinition.hasDeclaredChildNodeDefinition(childNodeDefinition.getName())) {
+ return
JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
+ }
+ }
+
+ return super.getFont(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see
org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
*/
@Override
@@ -319,11 +383,22 @@
public Object[] getElements( final Object inputElement ) {
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if (nodeTypeDefinition == null) {
- return Utils.EMPTY_OBJECT_ARRAY;
+ if (nodeTypeDefinition != null) {
+ try {
+ return
getCnd().getChildNodeDefinitions(nodeTypeDefinition.getName(),
shouldShowInheritedChildNodes())
+ .toArray();
+ } catch (Exception e) {
+ Activator.getSharedInstance()
+ .getLog()
+ .log(new Status(IStatus.ERROR,
+ JcrUiConstants.PLUGIN_ID,
+
NLS.bind(CndMessages.errorObtainingInheritedItemDefinitions,
+ nodeTypeDefinition.getName()),
+ e));
+ }
}
- return nodeTypeDefinition.getChildNodeDefinitions().toArray();
+ return Utils.EMPTY_OBJECT_ARRAY;
}
/**
@@ -341,6 +416,8 @@
});
// open edit child node on double click
+ final IAction editAction = this.editChildNode;
+
this.childNodeViewer.addDoubleClickListener(new IDoubleClickListener() {
/**
@@ -350,7 +427,9 @@
*/
@Override
public void doubleClick( final DoubleClickEvent event ) {
- handleEditChildNode();
+ if (editAction.isEnabled()) {
+ handleEditChildNode();
+ }
}
});
@@ -777,6 +856,8 @@
});
// open edit namespace on double click
+ final IAction editAction = this.editNamespace;
+
this.namespaceViewer.addDoubleClickListener(new IDoubleClickListener() {
/**
@@ -786,7 +867,9 @@
*/
@Override
public void doubleClick( final DoubleClickEvent event ) {
- handleEditNamespace();
+ if (editAction.isEnabled()) {
+ handleEditNamespace();
+ }
}
});
@@ -1121,6 +1204,22 @@
this.editProperty.setEnabled(false);
this.editProperty.setToolTipText(CndMessages.editPropertyToolTip);
this.editProperty.setImageDescriptor(JcrUiUtils.getEditImageDescriptor());
+
+ this.showInheritedProperties = new Action(Utils.EMPTY_STRING, SWT.TOGGLE) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleShowInheritedPropertiesChanged();
+ }
+ };
+
this.showInheritedProperties.setToolTipText(CndMessages.showInheritedPropertiesToolTip);
+ this.showInheritedProperties.setImageDescriptor(Activator.getSharedInstance()
+
.getImageDescriptor(JcrUiConstants.Images.SHOW_INHERITED));
}
private void createPropertySection( final IManagedForm managedForm,
@@ -1155,7 +1254,8 @@
toolkit.paintBordersFor(container);
// create toolbar
- FormUtils.createToolBar(container, toolkit, new IAction[] { this.addProperty,
this.editProperty, this.deleteProperty });
+ FormUtils.createToolBar(container, toolkit, new IAction[] { this.addProperty,
this.editProperty, this.deleteProperty,
+ this.showInheritedProperties });
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
@@ -1183,6 +1283,46 @@
/**
* {@inheritDoc}
*
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
+ */
+ @Override
+ public Color getBackground( Object element ) {
+ final PropertyDefinition propertyDefinition =
(PropertyDefinition)element;
+
+ if (shouldShowInheritedProperties()) {
+ NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if
(!nodeTypeDefinition.hasDeclaredPropertyDefinition(propertyDefinition.getName())) {
+ return
getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+ }
+ }
+
+ return super.getBackground(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getFont(java.lang.Object)
+ */
+ @Override
+ public Font getFont( Object element ) {
+ final PropertyDefinition propertyDefinition =
(PropertyDefinition)element;
+
+ if (shouldShowInheritedProperties()) {
+ NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if
(!nodeTypeDefinition.hasDeclaredPropertyDefinition(propertyDefinition.getName())) {
+ return
JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
+ }
+ }
+
+ return super.getFont(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see
org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
*/
@Override
@@ -1246,11 +1386,22 @@
public Object[] getElements( final Object inputElement ) {
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if (nodeTypeDefinition == null) {
- return Utils.EMPTY_OBJECT_ARRAY;
+ if (nodeTypeDefinition != null) {
+ try {
+ return
getCnd().getPropertyDefinitions(nodeTypeDefinition.getName(),
shouldShowInheritedProperties())
+ .toArray();
+ } catch (Exception e) {
+ Activator.getSharedInstance()
+ .getLog()
+ .log(new Status(IStatus.ERROR,
+ JcrUiConstants.PLUGIN_ID,
+
NLS.bind(CndMessages.errorObtainingInheritedItemDefinitions,
+ nodeTypeDefinition.getName()),
+ e));
+ }
}
- return nodeTypeDefinition.getPropertyDefinitions().toArray();
+ return Utils.EMPTY_OBJECT_ARRAY;
}
/**
@@ -1268,6 +1419,8 @@
});
// open edit property on double click
+ final IAction editAction = this.editProperty;
+
this.propertyViewer.addDoubleClickListener(new IDoubleClickListener() {
/**
@@ -1277,7 +1430,9 @@
*/
@Override
public void doubleClick( final DoubleClickEvent event ) {
- handleEditProperty();
+ if (editAction.isEnabled()) {
+ handleEditProperty();
+ }
}
});
@@ -1437,6 +1592,8 @@
}
});
+ final IAction editAction = this.editSuperType;
+
this.superTypesViewer.addDoubleClickListener(new IDoubleClickListener() {
/**
@@ -1446,7 +1603,9 @@
*/
@Override
public void doubleClick( final DoubleClickEvent event ) {
- handleEditSuperType();
+ if (editAction.isEnabled()) {
+ handleEditSuperType();
+ }
}
});
@@ -1693,7 +1852,11 @@
void handleAddProperty() {
assert (getSelectedNodeType() != null) : "add property handler called but
there is no selected node type"; //$NON-NLS-1$
- final PropertyDialog dialog = new PropertyDialog(getShell(), getPropertyNames(),
getCnd().getNamespacePrefixes());
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final PropertyDialog dialog = new PropertyDialog(getShell(),
+ getPropertyNames(),
+
getCnd().getNamespacePrefixes(),
+
nodeTypeDefinition.isQueryable());
dialog.create();
dialog.getShell().pack();
@@ -1701,7 +1864,7 @@
final PropertyDefinition newPropertyDefinition =
dialog.getPropertyDefinition();
// add and select new property definition
- if (getSelectedNodeType().addPropertyDefinition(newPropertyDefinition)) {
+ if (nodeTypeDefinition.addPropertyDefinition(newPropertyDefinition)) {
this.propertyViewer.setSelection(new
StructuredSelection(newPropertyDefinition), true);
UiUtils.pack(this.propertyViewer);
@@ -1757,6 +1920,11 @@
enable = (getSelectedChildNode() != null);
+ // disable if selected child node is inherited
+ if (enable && shouldShowInheritedChildNodes()) {
+ enable =
getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
+ }
+
if (this.editChildNode.isEnabled() != enable) {
this.editChildNode.setEnabled(enable);
}
@@ -1967,16 +2135,17 @@
assert (getSelectedNodeType() != null) : "Edit property handler called but
there is no selected node type"; //$NON-NLS-1$
assert (getSelectedProperty() != null) : "Edit property handler has been
called when there is no property selected"; //$NON-NLS-1$
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
final PropertyDefinition propertyBeingEdited = getSelectedProperty();
final PropertyDialog dialog = new PropertyDialog(getShell(),
getPropertyNames(),
getCnd().getNamespacePrefixes(),
+
nodeTypeDefinition.isQueryable(),
propertyBeingEdited);
dialog.create();
dialog.getShell().pack();
if (dialog.open() == Window.OK) {
- final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
final PropertyDefinition newPropertyDefinition =
dialog.getPropertyDefinition();
boolean removed = false;
boolean added = false;
@@ -2086,8 +2255,8 @@
// update section descriptions
if (this.selectedNodeType == null) {
this.detailsSection.setDescription(CndMessages.cndEditorDetailsSectionDescription);
-
this.propertiesSection.setDescription(CndMessages.cndEditorChildNodeSectionDescription);
-
this.childNodeSection.setDescription(CndMessages.cndEditorPropertySectionDescription);
+
this.propertiesSection.setDescription(CndMessages.cndEditorPropertySectionDescription);
+
this.childNodeSection.setDescription(CndMessages.cndEditorChildNodeSectionDescription);
} else {
String name = this.selectedNodeType.getName();
@@ -2097,8 +2266,8 @@
this.nameEditor.setNameBeingEdited(this.selectedNodeType.getQualifiedName());
this.detailsSection.setDescription(NLS.bind(CndMessages.cndEditorChildNodeSectionDescriptionWithNodeTypeName,
name));
-
this.propertiesSection.setDescription(NLS.bind(CndMessages.cndEditorChildNodeSectionDescriptionWithNodeTypeName,
name));
-
this.childNodeSection.setDescription(NLS.bind(CndMessages.cndEditorPropertySectionDescriptionWithNodeTypeName,
name));
+
this.propertiesSection.setDescription(NLS.bind(CndMessages.cndEditorPropertySectionDescriptionWithNodeTypeName,
name));
+
this.childNodeSection.setDescription(NLS.bind(CndMessages.cndEditorChildNodeSectionDescriptionWithNodeTypeName,
name));
}
// populate details section
@@ -2183,6 +2352,11 @@
enable = (getSelectedProperty() != null);
+ // disable if selected property is inherited
+ if (enable && shouldShowInheritedProperties()) {
+ enable =
getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
+ }
+
if (this.editProperty.isEnabled() != enable) {
this.editProperty.setEnabled(enable);
}
@@ -2196,6 +2370,14 @@
getSelectedNodeType().setQueryable(newValue);
}
+ void handleShowInheritedChildNodesChanged() {
+ refreshChildNodeViewer();
+ }
+
+ void handleShowInheritedPropertiesChanged() {
+ refreshPropertyViewer();
+ }
+
void handleSuperTypeSelected() {
// update button enablements
final boolean enable = (getSelectedSuperType() != null);
@@ -2461,6 +2643,14 @@
updateEnabledState();
}
+ boolean shouldShowInheritedChildNodes() {
+ return this.showInheritedChildNodes.isChecked();
+ }
+
+ boolean shouldShowInheritedProperties() {
+ return this.showInheritedProperties.isChecked();
+ }
+
/**
* {@inheritDoc}
*
@@ -2570,8 +2760,13 @@
this.propertyViewer.getTable().setEnabled(enableWithNodeTypeSelected);
}
- final boolean enable = (enableWithNodeTypeSelected &&
(getSelectedProperty() != null));
+ boolean enable = (enableWithNodeTypeSelected &&
(getSelectedProperty() != null));
+ // disable if selected property is inherited
+ if (enable && shouldShowInheritedProperties()) {
+ enable =
getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
+ }
+
if (this.editProperty.isEnabled() != enable) {
this.editProperty.setEnabled(enable);
}
@@ -2590,8 +2785,13 @@
this.childNodeViewer.getTable().setEnabled(enableWithNodeTypeSelected);
}
- final boolean enable = (enableWithNodeTypeSelected &&
(getSelectedChildNode() != null));
+ boolean enable = (enableWithNodeTypeSelected &&
(getSelectedChildNode() != null));
+ // disable if selected child node is inherited
+ if (enable && shouldShowInheritedChildNodes()) {
+ enable =
getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
+ }
+
if (this.editChildNode.isEnabled() != enable) {
this.editChildNode.setEnabled(enable);
}
@@ -2629,13 +2829,13 @@
private void validateNamespaces() {
final MultiValidationStatus status =
CndValidator.validateNamespaceMappings(getCnd().getNamespaceMappings());
- updateMessage(status, this.namespaceSection);
+ updateMessage(status, this.namespaceSection.getDescriptionControl());
}
private void validateNodeTypes() {
final MultiValidationStatus status =
CndValidator.validateNodeTypeDefinitions(getCnd().getNodeTypeDefinitions(),
getCnd().getNamespacePrefixes(), true);
- updateMessage(status, this.nodeTypeSection);
+ updateMessage(status, this.nodeTypeSection.getDescriptionControl());
}
private void validateProperties() {
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -623,6 +623,11 @@
public static String editValueConstraintToolTip;
/**
+ * A tool tip message for the "equals" query operator.
+ */
+ public static String equalsOperatorToolTip;
+
+ /**
* An error message indicating the new child node definition was not added to the
node type definition. One parameter, the child
* definition name, is required.
*/
@@ -755,11 +760,37 @@
public static String errorEditingValueConstraint;
/**
+ * The error message when there was a problem obtaining the node type
definition's inherited properties and child nodes. One
+ * parameter, the node type definition name, is required.
+ */
+ public static String errorObtainingInheritedItemDefinitions;
+
+ /**
* The error message when the CND editor could not be opened.
*/
public static String errorOpeningCndEditor;
/**
+ * A tool tip message for the "greater than or equals to" query operator.
+ */
+ public static String greaterThanEqualsOperatorToolTip;
+
+ /**
+ * A tool tip message for the "greater than" query operator.
+ */
+ public static String greaterThanOperatorToolTip;
+
+ /**
+ * A tool tip message for the "less than or equals to" query operator.
+ */
+ public static String lessThanEqualsOperatorToolTip;
+
+ /**
+ * A tool tip message for the "less than" query operator.
+ */
+ public static String lessThanOperatorToolTip;
+
+ /**
* A name for the mandatory attribute suitable for a radio or check button.
*/
public static String mandatoryAttribute;
@@ -915,6 +946,11 @@
public static String noQueryOrderAttributeToolTip;
/**
+ * A tool tip message for the "not equals" query operator.
+ */
+ public static String notEqualsOperatorToolTip;
+
+ /**
* A label for an on parent version attribute control.
*/
public static String onParentVersionLabel;
@@ -1051,6 +1087,16 @@
public static String sameNamedSiblingsAttributeToolTip;
/**
+ * A tool tip message for the show inherited child node action.
+ */
+ public static String showInheritedChildNodesToolTip;
+
+ /**
+ * A tool tip message for the show inherited properties action.
+ */
+ public static String showInheritedPropertiesToolTip;
+
+ /**
* A label for a supertypes control.
*/
public static String supertypesLabel;
@@ -1076,6 +1122,11 @@
public static String unqualifiedNameToolTip;
/**
+ * A label for a URI control.
+ */
+ public static String uriLabel;
+
+ /**
* A tooltip message for a control containing all the valid qualifed name qualifiers
in a CND.
*/
public static String validQualifiersToolTip;
Modified:
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 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -16,6 +16,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -30,6 +31,7 @@
import org.jboss.tools.modeshape.jcr.MultiValidationStatus;
import org.jboss.tools.modeshape.jcr.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
@@ -55,8 +57,12 @@
private String prefix;
+ private String saveUri = Utils.EMPTY_STRING;
+
private ScrolledForm scrolledForm;
+ private Text txtUri;
+
private String uri;
/**
@@ -176,21 +182,21 @@
}
{ // URI
- final Label lblUri = toolkit.createLabel(body, CndMessages.nameLabel,
SWT.NONE);
+ final Label lblUri = toolkit.createLabel(body, CndMessages.uriLabel,
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);
+ this.txtUri = toolkit.createText(body, null, Styles.TEXT_STYLE);
+ this.txtUri.setToolTipText(CndMessages.namespaceUriToolTip);
final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.verticalIndent += ((GridLayout)body.getLayout()).verticalSpacing;
- txtUri.setLayoutData(gd);
+ this.txtUri.setLayoutData(gd);
if (isEditMode()) {
- txtUri.setText(this.namespaceBeingEdited.getUri());
+ this.txtUri.setText(this.namespaceBeingEdited.getUri());
}
- txtUri.addModifyListener(new ModifyListener() {
+ this.txtUri.addModifyListener(new ModifyListener() {
/**
* {@inheritDoc}
@@ -216,6 +222,20 @@
void handlePrefixChanged( final String newPrefix ) {
this.prefix = newPrefix;
+
+ try {
+ if (!Utils.isEmpty(this.prefix)) {
+ if (!Utils.isEmpty(this.saveUri) &&
WorkspaceRegistry.get().getUri(this.prefix) == null) {
+ this.txtUri.setText(this.saveUri);
+ this.saveUri = Utils.EMPTY_STRING;
+ } else {
+ this.saveUri = this.txtUri.getText();
+ this.txtUri.setText(WorkspaceRegistry.get().getUri(this.prefix));
+ }
+ }
+ } catch (final Exception e) {
+ }
+
updateState();
}
@@ -240,6 +260,11 @@
if (!enable) {
this.scrolledForm.setMessage(status.getMessage(), IMessageProvider.ERROR);
+ Point preferredSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ if (preferredSize.x > getShell().getSize().x) {
+ getShell().pack();
+ }
} else if ((isEditMode() &&
currentNamespace.equals(this.namespaceBeingEdited))
|| (!isEditMode() && Utils.isEmpty(this.prefix) &&
Utils.isEmpty(this.uri))) {
enable = false;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -96,6 +96,7 @@
private final Collection<QualifiedName> existingPropertyNames;
private QualifiedNameEditor nameEditor;
private final ErrorMessage nameError;
+ private final boolean nodeTypeQueryable; // query ops are not used if node type is
not queryable
private PropertyDefinition originalProperty;
private PropertyDefinition propertyBeingEdited;
private ScrolledForm scrolledForm;
@@ -108,15 +109,18 @@
* @param parentShell the parent shell (can be <code>null</code>)
* @param existingPropertyNames the existing property names (can be
<code>null</code> or empty)
* @param existingNamespacePrefixes the existing CND namespace prefixes (can be
<code>null</code> or empty)
+ * @param nodeTypeQueryable indicates if node type of the property being created is
queryable
*/
public PropertyDialog( final Shell parentShell,
final Collection<QualifiedName> existingPropertyNames,
- final Collection<String> existingNamespacePrefixes ) {
+ final Collection<String> existingNamespacePrefixes,
+ final boolean nodeTypeQueryable ) {
super(parentShell);
this.existingPropertyNames = ((existingPropertyNames == null) ?
Collections.<QualifiedName> emptyList()
: new
ArrayList<QualifiedName>(existingPropertyNames));
this.existingNamespacePrefixes = ((existingNamespacePrefixes == null) ?
Collections.<String> emptyList()
: new
ArrayList<String>(existingNamespacePrefixes));
+ this.nodeTypeQueryable = nodeTypeQueryable;
this.defaultValuesError = new ErrorMessage();
this.nameError = new ErrorMessage();
this.valueConstraintsError = new ErrorMessage();
@@ -129,13 +133,15 @@
* @param parentShell the parent shell (can be <code>null</code>)
* @param existingPropertyNames the existing property names (can be
<code>null</code> or empty)
* @param existingNamespacePrefixes the existing CND namespace prefixes (can be
<code>null</code> or empty)
- * @param propertyDefinitionBeingEdited the proeprty definition being edited (cannot
be <code>null</code>)
+ * @param nodeTypeQueryable indicates if node type of the property being edited is
queryable
+ * @param propertyDefinitionBeingEdited the property definition being edited (cannot
be <code>null</code>)
*/
public PropertyDialog( final Shell parentShell,
final Collection<QualifiedName> existingPropertyNames,
final Collection<String> existingNamespacePrefixes,
+ final boolean nodeTypeQueryable,
final PropertyDefinition propertyDefinitionBeingEdited ) {
- this(parentShell, existingPropertyNames, existingNamespacePrefixes);
+ this(parentShell, existingPropertyNames, existingNamespacePrefixes,
nodeTypeQueryable);
Utils.verifyIsNotNull(propertyDefinitionBeingEdited,
"propertyDefinitionBeingEdited"); //$NON-NLS-1$
this.originalProperty = propertyDefinitionBeingEdited;
@@ -599,163 +605,166 @@
});
}
- { // queryOps
- final Collection<String> supportedQueryOps =
Arrays.asList(this.propertyBeingEdited.getAvailableQueryOperators());
- final Composite queryOpsContainer =
toolkit.createComposite(attributesContainer);
- queryOpsContainer.setLayout(new GridLayout(7, false));
- ((GridLayout)queryOpsContainer.getLayout()).marginHeight = 0;
- ((GridLayout)queryOpsContainer.getLayout()).marginWidth = 0;
- queryOpsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
- toolkit.paintBordersFor(queryOpsContainer);
- toolkit.createLabel(queryOpsContainer, CndMessages.queryOperatorsLabel);
+ if (this.nodeTypeQueryable) {
+ { // queryOps
+ final Collection<String> supportedQueryOps =
Arrays.asList(this.propertyBeingEdited.getAvailableQueryOperators());
+ final Composite queryOpsContainer =
toolkit.createComposite(attributesContainer);
+ queryOpsContainer.setLayout(new GridLayout(7, false));
+ ((GridLayout)queryOpsContainer.getLayout()).marginHeight = 0;
+ ((GridLayout)queryOpsContainer.getLayout()).marginWidth = 0;
+ queryOpsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, true));
+ toolkit.paintBordersFor(queryOpsContainer);
+ toolkit.createLabel(queryOpsContainer,
CndMessages.queryOperatorsLabel);
- { // equals query operator
- final Button btnEquals = toolkit.createButton(queryOpsContainer,
QueryOperator.EQUALS.toString(), SWT.CHECK);
- btnEquals.setBackground(attributesContainer.getBackground());
+ { // equals query operator
+ final Button btnEquals = toolkit.createButton(queryOpsContainer,
QueryOperator.EQUALS.toString(), SWT.CHECK);
+ btnEquals.setBackground(attributesContainer.getBackground());
- if (supportedQueryOps.contains(btnEquals.getText())) {
- btnEquals.setSelection(true);
+ if (supportedQueryOps.contains(btnEquals.getText())) {
+ btnEquals.setSelection(true);
+ }
+
+ btnEquals.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ Button btn = (Button)e.widget;
+ handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ }
+ });
+ btnEquals.setToolTipText(CndMessages.equalsOperatorToolTip);
}
- btnEquals.addSelectionListener(new SelectionAdapter() {
+ { // not equals query operator
+ final Button btnNotEquals =
toolkit.createButton(queryOpsContainer, QueryOperator.NOT_EQUALS.toString(),
+ SWT.CHECK);
+ btnNotEquals.setBackground(attributesContainer.getBackground());
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
- handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ if (supportedQueryOps.contains(btnNotEquals.getText())) {
+ btnNotEquals.setSelection(true);
}
- });
- // btnEquals.setToolTipText(CndMessages.multipleAttributeToolTip);
- }
- { // not equals query operator
- final Button btnNotEquals = toolkit.createButton(queryOpsContainer,
QueryOperator.NOT_EQUALS.toString(),
- SWT.CHECK);
- btnNotEquals.setBackground(attributesContainer.getBackground());
+ btnNotEquals.addSelectionListener(new SelectionAdapter() {
- if (supportedQueryOps.contains(btnNotEquals.getText())) {
- btnNotEquals.setSelection(true);
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ Button btn = (Button)e.widget;
+ handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ }
+ });
+
btnNotEquals.setToolTipText(CndMessages.notEqualsOperatorToolTip);
}
- btnNotEquals.addSelectionListener(new SelectionAdapter() {
+ { // greater than query operator
+ final Button btnGreaterThan =
toolkit.createButton(queryOpsContainer,
+
QueryOperator.GREATER_THAN.toString(), SWT.CHECK);
+
btnGreaterThan.setBackground(attributesContainer.getBackground());
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
- handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ if (supportedQueryOps.contains(btnGreaterThan.getText())) {
+ btnGreaterThan.setSelection(true);
}
- });
- //
btnNotEquals.setToolTipText(CndMessages.multipleAttributeToolTip);
- }
- { // greater than query operator
- final Button btnGreaterThan = toolkit.createButton(queryOpsContainer,
QueryOperator.GREATER_THAN.toString(),
- SWT.CHECK);
- btnGreaterThan.setBackground(attributesContainer.getBackground());
+ btnGreaterThan.addSelectionListener(new SelectionAdapter() {
- if (supportedQueryOps.contains(btnGreaterThan.getText())) {
- btnGreaterThan.setSelection(true);
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ Button btn = (Button)e.widget;
+ handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ }
+ });
+
btnGreaterThan.setToolTipText(CndMessages.greaterThanOperatorToolTip);
}
- btnGreaterThan.addSelectionListener(new SelectionAdapter() {
+ { // less than query operator
+ final Button btnLessThan =
toolkit.createButton(queryOpsContainer, QueryOperator.LESS_THAN.toString(),
+ SWT.CHECK);
+ btnLessThan.setBackground(attributesContainer.getBackground());
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
- handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ if (supportedQueryOps.contains(btnLessThan.getText())) {
+ btnLessThan.setSelection(true);
}
- });
- // btnGreater.setToolTipText(CndMessages.multipleAttributeToolTip);
- }
- { // less than query operator
- final Button btnLessThan = toolkit.createButton(queryOpsContainer,
QueryOperator.LESS_THAN.toString(),
- SWT.CHECK);
- btnLessThan.setBackground(attributesContainer.getBackground());
+ btnLessThan.addSelectionListener(new SelectionAdapter() {
- if (supportedQueryOps.contains(btnLessThan.getText())) {
- btnLessThan.setSelection(true);
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ Button btn = (Button)e.widget;
+ handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ }
+ });
+ btnLessThan.setToolTipText(CndMessages.lessThanOperatorToolTip);
}
- btnLessThan.addSelectionListener(new SelectionAdapter() {
+ { // greater than or equal query operator
+ final Button btnGreaterThanEquals =
toolkit.createButton(queryOpsContainer,
+
QueryOperator.GREATER_THAN_EQUALS.toString(),
+
SWT.CHECK);
+
btnGreaterThanEquals.setBackground(attributesContainer.getBackground());
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
- handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ if (supportedQueryOps.contains(btnGreaterThanEquals.getText()))
{
+ btnGreaterThanEquals.setSelection(true);
}
- });
- // btnLess.setToolTipText(CndMessages.multipleAttributeToolTip);
- }
- { // greater than or equal query operator
- final Button btnGreaterThanEqual =
toolkit.createButton(queryOpsContainer,
-
QueryOperator.GREATER_THAN_EQUALS.toString(), SWT.CHECK);
-
btnGreaterThanEqual.setBackground(attributesContainer.getBackground());
+ btnGreaterThanEquals.addSelectionListener(new SelectionAdapter()
{
- if (supportedQueryOps.contains(btnGreaterThanEqual.getText())) {
- btnGreaterThanEqual.setSelection(true);
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ Button btn = (Button)e.widget;
+ handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ }
+ });
+
btnGreaterThanEquals.setToolTipText(CndMessages.greaterThanEqualsOperatorToolTip);
}
- btnGreaterThanEqual.addSelectionListener(new SelectionAdapter() {
+ { // less than or equals query operator
+ final Button btnLessThanEquals =
toolkit.createButton(queryOpsContainer,
+
QueryOperator.LESS_THAN_EQUALS.toString(), SWT.CHECK);
+
btnLessThanEquals.setBackground(attributesContainer.getBackground());
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
- handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ if (supportedQueryOps.contains(btnLessThanEquals.getText())) {
+ btnLessThanEquals.setSelection(true);
}
- });
- //
btnGreaterEqual.setToolTipText(CndMessages.multipleAttributeToolTip);
- }
- { // less than or equals query operator
- final Button btnLessThanEqual =
toolkit.createButton(queryOpsContainer,
-
QueryOperator.LESS_THAN_EQUALS.toString(), SWT.CHECK);
- btnLessThanEqual.setBackground(attributesContainer.getBackground());
+ btnLessThanEquals.addSelectionListener(new SelectionAdapter() {
- if (supportedQueryOps.contains(btnLessThanEqual.getText())) {
- btnLessThanEqual.setSelection(true);
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ Button btn = (Button)e.widget;
+ handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
+ }
+ });
+
btnLessThanEquals.setToolTipText(CndMessages.lessThanEqualsOperatorToolTip);
}
-
- btnLessThanEqual.addSelectionListener(new SelectionAdapter() {
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
- handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
- }
- });
- //
btnLessThanEqual.setToolTipText(CndMessages.multipleAttributeToolTip);
}
}
}
@@ -1472,7 +1481,8 @@
}
private void validateDefaultValues() {
- updateMessage(CndValidator.validateDefaultValues(this.propertyBeingEdited),
this.defaultValuesError);
+ updateMessage(CndValidator.validateDefaultValues(this.propertyBeingEdited,
existingNamespacePrefixes),
+ this.defaultValuesError);
}
private void validateName() {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -242,7 +242,11 @@
*/
void setValidQualifiers( final Collection<String> validQualifiers ) {
this.validQualifiers = ((validQualifiers == null) ? new
ArrayList<String>(1) : new ArrayList<String>(validQualifiers));
- this.validQualifiers.add(0, CndMessages.noNameQualifierChoice); // include empty
qualifier at index 0
+
+ if (!this.validQualifiers.contains(CndMessages.noNameQualifierChoice)) {
+ this.validQualifiers.add(0, CndMessages.noNameQualifierChoice); // include
empty qualifier at index 0
+ }
+
updateUi();
}
@@ -252,7 +256,9 @@
// only reload qualifiers if different
if ((this.validQualifiers.size() != currentItems.length) ||
!this.validQualifiers.containsAll(Arrays.asList(currentItems))) {
- this.cbxQualifiers.setItems(this.validQualifiers.toArray(new
String[this.validQualifiers.size()]));
+ String[] newQualifiers = this.validQualifiers.toArray(new
String[this.validQualifiers.size()]);
+ Arrays.sort(newQualifiers);
+ this.cbxQualifiers.setItems(newQualifiers);
}
// select the current qualifier and set the name
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-03
17:25:43 UTC (rev 40012)
@@ -135,6 +135,7 @@
editSuperTypeMenuText = Edit Supertype
editValueConstraintMenuText = Edit Value Constraint
editValueConstraintToolTip = Edit the selected value constraint of the property
definition
+equalsOperatorToolTip = Indicates if the property supports the "equals" query
operation
errorAddingChildNode = There was an unexpected error adding child node "{0}" to
the node type definition.
errorAddingDefaultValue = There was an unexpected error adding default value
"{0}" to the property definition.
errorAddingNamespaceMapping = There was an unexpected error adding namespace mapping
"{0}" to the CND.
@@ -157,7 +158,12 @@
errorEditingRequiredType = There was an unexpected error updating required type
"{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}.
errorEditingValueConstraint = There was an unexpected error updating value constraint
"{0}" to the property definition.\nThe remove command result: {1}. The add
command result: {2}.
+errorObtainingInheritedItemDefinitions = There was a problem obtaining the inherited
properties and child node for node type definition "{0}."
errorOpeningCndEditor = There were errors parsing the CND so the CND editor could not be
created. Fix errors and retry.
+greaterThanEqualsOperatorToolTip = Indicates if the property supports the "greater
than or equal to" query operation
+greaterThanOperatorToolTip = Indicates if the property supports the "greater
than" query operation
+lessThanEqualsOperatorToolTip = Indicates if the property supports the "less than or
equal to" query operation
+lessThanOperatorToolTip = Indicates if the property supports the "less than"
query operation
mandatoryAttribute = Mandatory
mandatoryAttributeToolTip = Indicates if the child node/property must exist
missingValue = <missing>
@@ -189,6 +195,7 @@
noPrimaryItemChoice = <not assigned>
noQueryOrderAttribute = Not Query Orderable
noQueryOrderAttributeToolTip = Indicates if query results of this property cannot be
ordered
+notEqualsOperatorToolTip = Indicates if the property supports the "not equals"
query operation
onParentVersionLabel = On Parent Version:
onParentVersionToolTip = Indicates what happens to the child node/property when the
parent is created
orderableAttribute = Orderable
@@ -216,11 +223,14 @@
requiredTypesLabel = Required Types:
sameNamedSiblingsAttribute = Same Named Siblings
sameNamedSiblingsAttributeToolTip = Indicates if the node type can be queried
+showInheritedChildNodesToolTip = Show the child node definitions inherited by the
selected node type definition
+showInheritedPropertiesToolTip = Show the property definitions inherited by the selected
node type definition
supertypesLabel = Supertypes:
supertypesToolTip = The supertypes (node types and mixins) whose property definitions and
child node definitions are inherited
typeHeaderText = Type
typeLabel = Type:
unqualifiedNameToolTip = The name part of the qualified name (cannot be empty)
+uriLabel = URI:
validQualifiersToolTip = The qualifiers known to this CND
valueConstraintDialogCreateMsg = Create Value Constraint
valueConstraintDialogEditMsg = Edit Value Constraint
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/build.properties
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/build.properties 2012-04-03
14:26:17 UTC (rev 40011)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/build.properties 2012-04-03
17:25:43 UTC (rev 40012)
@@ -13,5 +13,6 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- OSGI-INF/
+ OSGI-INF/,\
+ cnd/
src.includes = testdata/
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/cnd/jsr_283_builtins.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/cnd/jsr_283_builtins.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/cnd/jsr_283_builtins.cnd 2012-04-03
17:25:43 UTC (rev 40012)
@@ -0,0 +1,183 @@
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+// ------------------------------------------------------------------------
+// Pre-defined Node Types
+// ------------------------------------------------------------------------
+
+[nt:base] abstract
+ - jcr:primaryType (name) mandatory autocreated
+ protected compute
+ - jcr:mixinTypes (name) protected multiple compute
+
+[nt:unstructured]
+ orderable
+ - * (undefined) multiple
+ - * (undefined)
+ + * (nt:base) = nt:unstructured sns version
+
+[mix:created] mixin
+ - jcr:created (date) protected
+ - jcr:createdBy (string) protected
+
+[nt:hierarchyNode] > mix:created abstract
+
+[nt:file] > nt:hierarchyNode
+ + jcr:content (nt:base) primary mandatory
+
+[nt:linkedFile] > nt:hierarchyNode
+ - jcr:content (reference) primary mandatory
+
+[nt:folder] > nt:hierarchyNode
+ + * (nt:hierarchyNode) version
+
+[mix:referenceable] mixin
+ - jcr:uuid (string) mandatory autocreated protected initialize
+
+[mix:mimeType] mixin
+ - jcr:mimeType (string)
+ - jcr:encoding (string)
+
+[mix:lastModified] mixin
+ - jcr:lastModified (date)
+ - jcr:lastModifiedBy (string)
+
+[nt:resource] > mix:mimeType, mix:lastModified
+ - jcr:data (binary) primary mandatory
+
+[nt:nodeType]
+ - jcr:nodeTypeName (name) mandatory protected copy
+ - jcr:supertypes (name) multiple protected copy
+ - jcr:isAbstract (boolean) mandatory protected copy
+ - jcr:isMixin (boolean) mandatory protected copy
+ - jcr:isQueryable (boolean) mandatory protected copy
+ - jcr:hasOrderableChildNodes (boolean) mandatory protected copy
+ - jcr:primaryItemName (name) protected copy
+ + jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition sns protected
copy
+ + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition sns
protected copy
+
+[nt:propertyDefinition]
+ - jcr:name (name) protected
+ - jcr:autoCreated (boolean) mandatory protected
+ - jcr:mandatory (boolean) mandatory protected
+ - jcr:isFullTextSearchable (boolean) mandatory protected
+ - jcr:isQueryOrderable (boolean) mandatory protected
+ - jcr:onParentVersion (string) mandatory protected
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
+ 'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory protected
+ - jcr:requiredType (string) mandatory protected
+ < 'STRING', 'URI', 'BINARY', 'LONG',
'DOUBLE', 'DECIMAL', 'BOOLEAN',
+ 'DATE', 'NAME', 'PATH', 'REFERENCE',
'WEAKREFERENCE', 'UNDEFINED'
+ - jcr:valueConstraints (string) multiple protected
+ - jcr:availableQueryOperators (name) mandatory multiple protected
+ - jcr:defaultValues (undefined) multiple protected
+ - jcr:multiple (boolean) mandatory protected
+
+[nt:childNodeDefinition]
+ - jcr:name (name) protected
+ - jcr:autoCreated (boolean) mandatory protected
+ - jcr:mandatory (boolean) mandatory protected
+ - jcr:onParentVersion (string) mandatory protected
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
+ 'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory protected
+ - jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory protected multiple
+ - jcr:defaultPrimaryType (name) protected
+ - jcr:sameNameSiblings (boolean) mandatory protected
+
+[nt:versionHistory] > mix:referenceable
+ - jcr:versionableUuid (string) mandatory autocreated protected abort
+ - jcr:copiedFrom (weakreference) protected abort < 'nt:version'
+ + jcr:rootVersion (nt:version) = nt:version mandatory autocreated protected abort
+ + jcr:versionLabels (nt:versionLabels) = nt:versionLabels mandatory autocreated
protected abort
+ + * (nt:version) = nt:version protected abort
+
+
+[nt:versionLabels]
+ - * (reference) protected abort < 'nt:version'
+
+[nt:version] > mix:referenceable
+ - jcr:created (date) mandatory autocreated protected abort
+ - jcr:predecessors (reference) protected multiple abort < 'nt:version'
+ - jcr:successors (reference) protected multiple abort < 'nt:version'
+ - jcr:activity (reference) protected abort < 'nt:activity'
+ + jcr:frozenNode (nt:frozenNode) protected abort
+
+[nt:frozenNode] > mix:referenceable
+ orderable
+ - jcr:frozenPrimaryType (name) mandatory autocreated protected abort
+ - jcr:frozenMixinTypes (name) protected multiple abort
+ - jcr:frozenUuid (string) mandatory autocreated protected abort
+ - * (undefined) protected abort
+ - * (undefined) protected multiple abort
+ + * (nt:base) protected sns abort
+
+[nt:versionedChild]
+ - jcr:childVersionHistory (reference) mandatory autocreated protected abort <
'nt:versionHistory'
+
+[nt:query]
+ - jcr:statement (string)
+ - jcr:language (string)
+
+[nt:activity] > mix:referenceable
+ - jcr:activityTitle (string) mandatory autocreated protected
+
+
+[mix:simpleVersionable] mixin
+ - jcr:isCheckedOut (boolean) = 'true' mandatory autocreated protected ignore
+
+[mix:versionable] > mix:simpleVersionable, mix:referenceable mixin
+ - jcr:versionHistory (reference) mandatory protected ignore <
'nt:versionHistory'
+ - jcr:baseVersion (reference) mandatory protected ignore < 'nt:version'
+ - jcr:predecessors (reference) mandatory protected multiple ignore <
'nt:version'
+ - jcr:mergeFailed (reference) protected multiple abort
+ - jcr:activity (reference) protected < 'nt:version'
+ - jcr:configuration (reference) protected ignore < 'nt:configuration'
+
+[nt:configuration] > mix:versionable
+ - jcr:root (reference) mandatory autocreated protected
+
+[nt:address]
+ - jcr:protocol (string)
+ - jcr:host (string)
+ - jcr:port (string)
+ - jcr:repository (string)
+ - jcr:workspace (string)
+ - jcr:path (path)
+ - jcr:id (weakreference)
+
+[nt:naturalText]
+ - jcr:text (string)
+ - jcr:messageId (string)
+
+
+// ------------------------------------------------------------------------
+// Pre-defined Mixins
+// ------------------------------------------------------------------------
+
+[mix:etag] mixin
+ - jcr:etag (string) protected autocreated
+
+[mix:lockable] mixin
+ - jcr:lockOwner (string) protected ignore
+ - jcr:lockIsDeep (boolean) protected ignore
+
+[mix:lifecycle] mixin
+ - jcr:lifecyclePolicy (reference) protected initialize
+ - jcr:currentLifecycleState (string) protected initialize
+
+[mix:managedRetention] > mix:referenceable mixin
+ - jcr:hold (string) protected multiple
+ - jcr:isDeep (boolean) protected multiple
+ - jcr:retentionPolicy (reference) protected
+
+[mix:shareable] > mix:referenceable mixin
+
+[mix:title] mixin
+ - jcr:title (string)
+ - jcr:description (string)
+
+[mix:language] mixin
+ - jcr:language (string)
\ No newline at end of file
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -838,6 +838,22 @@
}
@Test
+ public void shouldParseNamespacesAndNodeTypesInAnyOrder() {
+ final String content = "[foo] > supertype1, supertype2\n"
//$NON-NLS-1$
+ + "<ns1 = 'http://namespace1.com/ns1'>\n"
//$NON-NLS-1$
+ + "<ns2 = 'http://namespace2.com/ns2'>\n"
//$NON-NLS-1$
+ + "[bar] > supertype1, supertype2\n" //$NON-NLS-1$
+ + "<ns3 = 'http://namespace3.com/ns3'>";
//$NON-NLS-1$
+ this.cnd = this.importer.parse(content);
+
+ final List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
+ assertEquals(3, namespaces.size());
+
+ final List<NodeTypeDefinition> nodeTypes =
this.cnd.getNodeTypeDefinitions();
+ assertEquals(2, nodeTypes.size());
+ }
+
+ @Test
public void shouldParseNamespaceDeclarationWithQuotedUriAndUnquotedPrefix() {
final String content = "<ns =
'http://namespace.com/ns'>"; //$NON-NLS-1$
this.cnd = this.importer.parse(content);
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -98,6 +98,14 @@
}
@Test
+ public void defaultValueWithInvalidQualifierShouldBeAnError() {
+ assertTrue(this.propertyDefinition.setType(PropertyType.NAME));
+ assertTrue(this.propertyDefinition.addDefaultValue("bogus:value"));
//$NON-NLS-1$
+ assertTrue(CndValidator.validateDefaultValues(this.propertyDefinition,
Constants.Helper.getDefaultNamespacePrefixes())
+ .isError());
+ }
+
+ @Test
public void emptyNamespaceMappingPrefixShouldBeAnError() {
assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinitionTest.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinitionTest.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -12,13 +12,9 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.util.Collection;
-import java.util.Collections;
-
import org.jboss.tools.modeshape.jcr.Listener;
import org.jboss.tools.modeshape.jcr.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.NodeTypeDefinition;
-import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition.PropertyName;
import org.junit.Before;
import org.junit.Test;
@@ -56,18 +52,6 @@
assertEquals(this.nodeTypeDefinition,
this.cnd.getNodeTypeDefinitions().iterator().next());
}
- @Test
- public void shouldClearNamespaceMappings() {
- assertTrue(this.cnd.addNamespaceMapping(this.namespaceMapping));
- assertTrue(this.cnd.clearNamespaceMappings());
- }
-
- @Test
- public void shouldClearNodeTypeDefinitions() {
- assertTrue(this.cnd.addNodeTypeDefinition(this.nodeTypeDefinition));
- assertTrue(this.cnd.clearNodeTypeDefinitions());
- }
-
@Test(expected = IllegalArgumentException.class)
public void shouldNotAllowNullNamespaceToBeAdded() {
this.cnd.addNamespaceMapping(null);
@@ -79,16 +63,6 @@
}
@Test
- public void shouldNotClearNamespaceMappingsWhenEmpty() {
- assertFalse(this.cnd.clearNamespaceMappings());
- }
-
- @Test
- public void shouldNotClearNodeTypeDefinitionsWhenEmpty() {
- assertFalse(this.cnd.clearNodeTypeDefinitions());
- }
-
- @Test
public void shouldNotReceiveEventAfterUnregistering() {
final Listener l = new Listener();
assertTrue(this.cnd.addListener(l));
@@ -135,36 +109,6 @@
}
@Test
- public void shouldReceiveEventAfterClearingNamespaceMappings() {
- assertTrue(this.cnd.addNamespaceMapping(this.namespaceMapping));
- final Collection<NamespaceMapping> oldValue =
Collections.singletonList(this.namespaceMapping);
-
- final Listener l = new Listener();
- assertTrue(this.cnd.addListener(l));
-
- assertTrue(this.cnd.clearNamespaceMappings());
- assertEquals(1, l.getCount());
- assertEquals(PropertyName.NAMESPACE_MAPPINGS.toString(), l.getPropertyName());
- assertNull(l.getNewValue());
- assertTrue(Utils.equivalent(oldValue,
(Collection<NamespaceMapping>)l.getOldValue()));
- }
-
- @Test
- public void shouldReceiveEventAfterClearingNodeTypeDefinitions() {
- assertTrue(this.cnd.addNodeTypeDefinition(this.nodeTypeDefinition));
- final Collection<NodeTypeDefinition> oldValue =
Collections.singletonList(this.nodeTypeDefinition);
-
- final Listener l = new Listener();
- assertTrue(this.cnd.addListener(l));
-
- assertTrue(this.cnd.clearNodeTypeDefinitions());
- assertEquals(1, l.getCount());
- assertEquals(PropertyName.NODE_TYPE_DEFINITIONS.toString(),
l.getPropertyName());
- assertNull(l.getNewValue());
- assertTrue(Utils.equivalent(oldValue,
(Collection<NodeTypeDefinition>)l.getOldValue()));
- }
-
- @Test
public void shouldReceiveEventAfterRemoveNamespaceMapping() {
assertTrue(this.cnd.addNamespaceMapping(this.namespaceMapping));
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-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -16,6 +16,7 @@
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.attributes.Abstract;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState;
+import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.attributes.Autocreated;
import org.jboss.tools.modeshape.jcr.attributes.DefaultType;
import org.jboss.tools.modeshape.jcr.attributes.DefaultValues;
@@ -29,12 +30,11 @@
import org.jboss.tools.modeshape.jcr.attributes.PropertyValue;
import org.jboss.tools.modeshape.jcr.attributes.Protected;
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators;
+import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.attributes.RequiredTypes;
import org.jboss.tools.modeshape.jcr.attributes.SameNameSiblings;
import org.jboss.tools.modeshape.jcr.attributes.SuperTypes;
import org.jboss.tools.modeshape.jcr.attributes.ValueConstraints;
-import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
-import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
@@ -310,4 +310,35 @@
new PropertyValue(PropertyType.STRING, ITEM_TWO), new
PropertyValue(PropertyType.STRING, ITEM_THREE) };
}
}
+
+ /**
+ * The built-in namespace mappings.
+ */
+ public interface BuiltInNamespaces {
+
+ /**
+ * Reserved for items defined within built-in node types.
+ */
+ NamespaceMapping JCR = new NamespaceMapping("jcr",
"http://www.jcp.org/jcr/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * Reserved for the names of built-in mixin node types.
+ */
+ NamespaceMapping MIX = new NamespaceMapping("mix",
"http://www.jcp.org/jcr/mix/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * Reserved for the names of built-in primary node types.
+ */
+ NamespaceMapping NT = new NamespaceMapping("nt",
"http://www.jcp.org/jcr/nt/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * Reserved for reasons of compatibility with XML.
+ */
+ NamespaceMapping XML = new NamespaceMapping("xml",
"http://www.w3.org/XML/1998/namespace"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * A collection of all built-in namespace mappings.
+ */
+ NamespaceMapping[] ALL_BUILT_INS = new NamespaceMapping[] { JCR, NT, MIX, XML };
+ }
}
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -0,0 +1,122 @@
+/*
+ * 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.cnd;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.tools.modeshape.jcr.PropertyDefinition;
+import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class WorkspaceRegistryTest {
+
+ private WorkspaceRegistry registry;
+
+ @Before
+ public void beforeEach() throws Exception {
+ this.registry = WorkspaceRegistry.get();
+ }
+
+ @Test
+ public void jcrNamespaceShouldBeRegistered() {
+
assertNotNull(this.registry.getNamespaceMapping(Constants.BuiltInNamespaces.JCR.getPrefix()));
+ assertEquals(Constants.BuiltInNamespaces.JCR.getPrefix(),
this.registry.getPrefix(Constants.BuiltInNamespaces.JCR.getUri()));
+ assertEquals(Constants.BuiltInNamespaces.JCR.getUri(),
this.registry.getUri(Constants.BuiltInNamespaces.JCR.getPrefix()));
+ }
+
+ @Test
+ public void mixNamespaceShouldBeRegistered() {
+
assertNotNull(this.registry.getNamespaceMapping(Constants.BuiltInNamespaces.MIX.getPrefix()));
+ assertEquals(Constants.BuiltInNamespaces.MIX.getPrefix(),
this.registry.getPrefix(Constants.BuiltInNamespaces.MIX.getUri()));
+ assertEquals(Constants.BuiltInNamespaces.MIX.getUri(),
this.registry.getUri(Constants.BuiltInNamespaces.MIX.getPrefix()));
+ }
+
+ @Test
+ public void ntNamespaceShouldBeRegistered() {
+
assertNotNull(this.registry.getNamespaceMapping(Constants.BuiltInNamespaces.NT.getPrefix()));
+ assertEquals(Constants.BuiltInNamespaces.NT.getPrefix(),
this.registry.getPrefix(Constants.BuiltInNamespaces.NT.getUri()));
+ assertEquals(Constants.BuiltInNamespaces.NT.getUri(),
this.registry.getUri(Constants.BuiltInNamespaces.NT.getPrefix()));
+ }
+
+ @Test
+ public void shouldGetInheriteProperties() {
+ final Collection<PropertyDefinition> properties =
this.registry.getPropertyDefinitions("nt:resource", true); //$NON-NLS-1$
+ assertEquals(5, properties.size());
+
+ final Collection<String> names = new ArrayList<String>(5);
+ names.add("jcr:mimeType"); //$NON-NLS-1$
+ names.add("jcr:encoding"); //$NON-NLS-1$
+ names.add("jcr:lastModified"); //$NON-NLS-1$
+ names.add("jcr:lastModifiedBy"); //$NON-NLS-1$
+ names.add("jcr:data"); //$NON-NLS-1$
+
+ for (final PropertyDefinition propDefn : properties) {
+ if (names.contains(propDefn.getName())) {
+ names.remove(propDefn.getName());
+ } else {
+ fail();
+ }
+ }
+
+ assertTrue(names.isEmpty());
+ }
+
+ @Test
+ public void shouldHaveRegisteredNodeTypes() throws Exception {
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:base"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:unstructured"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:created"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:hierarchyNode"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:file"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:linkedFile"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:folder"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("mix:referenceable"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:mimeType"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:lastModified"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:resource"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:nodeType"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("nt:propertyDefinition"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("nt:childNodeDefinition"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("nt:versionHistory"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:versionLabels"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:version"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:frozenNode"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("nt:versionedChild"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:query"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:activity"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("mix:simpleVersionable"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:versionable"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:configuration"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:address"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("nt:naturalText"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:etag"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:lockable"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:lifecycle"));
//$NON-NLS-1$
+
assertNotNull(this.registry.getNodeTypeDefinition("mix:managedRetention"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:shareable"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:title"));
//$NON-NLS-1$
+ assertNotNull(this.registry.getNodeTypeDefinition("mix:language"));
//$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldNotGetInheriteProperties() {
+ final Collection<PropertyDefinition> properties =
this.registry.getPropertyDefinitions("nt:resource", false); //$NON-NLS-1$
+ assertEquals(1, properties.size());
+ assertEquals("jcr:data", properties.iterator().next().getName());
//$NON-NLS-1$
+ }
+}
Property changes on:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/test/AllTests.java 2012-04-03
17:25:43 UTC (rev 40012)
@@ -14,8 +14,10 @@
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinitionTest;
import org.jboss.tools.modeshape.jcr.cnd.LocalNameTest;
import org.jboss.tools.modeshape.jcr.cnd.NamespaceMappingTest;
+import org.jboss.tools.modeshape.jcr.cnd.NodeTypeDefinitionTest;
import org.jboss.tools.modeshape.jcr.cnd.PropertyDefinitionTest;
import org.jboss.tools.modeshape.jcr.cnd.QualifiedNameTest;
+import org.jboss.tools.modeshape.jcr.cnd.WorkspaceRegistryTest;
import org.jboss.tools.modeshape.jcr.cnd.attributes.AbstractTest;
import org.jboss.tools.modeshape.jcr.cnd.attributes.AutocreatedTest;
import org.jboss.tools.modeshape.jcr.cnd.attributes.DefaultTypeTest;
@@ -45,13 +47,40 @@
*
*/
@RunWith(Suite.class)
-(a)Suite.SuiteClasses({ ChildNodeDefinitionTest.class, CndImporterTest.class,
CndTokenizerTest.class, CndValidatorTest.class,
- CompactNodeTypeDefinitionTest.class, LocalNameTest.class,
NamespaceMappingTest.class, PropertyDefinitionTest.class,
- QualifiedNameTest.class, AbstractTest.class, AutocreatedTest.class,
DefaultTypeTest.class, DefaultValuesTest.class,
- MandatoryTest.class, MixinTest.class, MultipleTest.class,
NodeAttributesTest.class, NodeTypeAttributesTest.class,
- NoFullTextTest.class, NoQueryOrderTest.class, OnParentValueTest.class,
OrderableTest.class, PrimaryItemTest.class,
- PropertyAttributesTest.class, ProtectedTest.class, QueryableTest.class,
QueryOperatorsTest.class, RequiredTypesTest.class,
- SameNameSiblingsTest.class, SuperTypesTest.class, ValueConstraintsTest.class })
+(a)Suite.SuiteClasses({
+ ChildNodeDefinitionTest.class,
+ CndImporterTest.class,
+ CndTokenizerTest.class,
+ CndValidatorTest.class,
+ CompactNodeTypeDefinitionTest.class,
+ LocalNameTest.class,
+ NamespaceMappingTest.class,
+ NodeTypeDefinitionTest.class,
+ PropertyDefinitionTest.class,
+ QualifiedNameTest.class,
+ WorkspaceRegistryTest.class,
+ AbstractTest.class,
+ AutocreatedTest.class,
+ DefaultTypeTest.class,
+ DefaultValuesTest.class,
+ MandatoryTest.class,
+ MixinTest.class,
+ MultipleTest.class,
+ NodeAttributesTest.class,
+ NodeTypeAttributesTest.class,
+ NoFullTextTest.class,
+ NoQueryOrderTest.class,
+ OnParentValueTest.class,
+ OrderableTest.class,
+ PrimaryItemTest.class,
+ PropertyAttributesTest.class,
+ ProtectedTest.class,
+ QueryableTest.class,
+ QueryOperatorsTest.class,
+ RequiredTypesTest.class,
+ SameNameSiblingsTest.class,
+ SuperTypesTest.class,
+ ValueConstraintsTest.class })
public class AllTests {
// nothing to do
}
Deleted:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd 2012-04-03
14:26:17 UTC (rev 40011)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/jsr_283_builtins.cnd 2012-04-03
17:25:43 UTC (rev 40012)
@@ -1,183 +0,0 @@
-<jcr='http://www.jcp.org/jcr/1.0'>
-<nt='http://www.jcp.org/jcr/nt/1.0'>
-<mix='http://www.jcp.org/jcr/mix/1.0'>
-
-// ------------------------------------------------------------------------
-// Pre-defined Node Types
-// ------------------------------------------------------------------------
-
-[nt:base] abstract
- - jcr:primaryType (name) mandatory autocreated
- protected compute
- - jcr:mixinTypes (name) protected multiple compute
-
-[nt:unstructured]
- orderable
- - * (undefined) multiple
- - * (undefined)
- + * (nt:base) = nt:unstructured sns version
-
-[mix:created] mixin
- - jcr:created (date) protected
- - jcr:createdBy (string) protected
-
-[nt:hierarchyNode] > mix:created abstract
-
-[nt:file] > nt:hierarchyNode
- + jcr:content (nt:base) primary mandatory
-
-[nt:linkedFile] > nt:hierarchyNode
- - jcr:content (reference) primary mandatory
-
-[nt:folder] > nt:hierarchyNode
- + * (nt:hierarchyNode) version
-
-[mix:referenceable] mixin
- - jcr:uuid (string) mandatory autocreated protected initialize
-
-[mix:mimeType] mixin
- - jcr:mimeType (string)
- - jcr:encoding (string)
-
-[mix:lastModified] mixin
- - jcr:lastModified (date)
- - jcr:lastModifiedBy (string)
-
-[nt:resource] > mix:mimeType, mix:lastModified
- - jcr:data (binary) primary mandatory
-
-[nt:nodeType]
- - jcr:nodeTypeName (name) mandatory protected copy
- - jcr:supertypes (name) multiple protected copy
- - jcr:isAbstract (boolean) mandatory protected copy
- - jcr:isMixin (boolean) mandatory protected copy
- - jcr:isQueryable (boolean) mandatory protected copy
- - jcr:hasOrderableChildNodes (boolean) mandatory protected copy
- - jcr:primaryItemName (name) protected copy
- + jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition sns protected
copy
- + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition sns
protected copy
-
-[nt:propertyDefinition]
- - jcr:name (name) protected
- - jcr:autoCreated (boolean) mandatory protected
- - jcr:mandatory (boolean) mandatory protected
- - jcr:isFullTextSearchable (boolean) mandatory protected
- - jcr:isQueryOrderable (boolean) mandatory protected
- - jcr:onParentVersion (string) mandatory protected
- < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
- 'IGNORE', 'ABORT'
- - jcr:protected (boolean) mandatory protected
- - jcr:requiredType (string) mandatory protected
- < 'STRING', 'URI', 'BINARY', 'LONG',
'DOUBLE', 'DECIMAL', 'BOOLEAN',
- 'DATE', 'NAME', 'PATH', 'REFERENCE',
'WEAKREFERENCE', 'UNDEFINED'
- - jcr:valueConstraints (string) multiple protected
- - jcr:availableQueryOperators (name) mandatory multiple protected
- - jcr:defaultValues (undefined) multiple protected
- - jcr:multiple (boolean) mandatory protected
-
-[nt:childNodeDefinition]
- - jcr:name (name) protected
- - jcr:autoCreated (boolean) mandatory protected
- - jcr:mandatory (boolean) mandatory protected
- - jcr:onParentVersion (string) mandatory protected
- < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
- 'IGNORE', 'ABORT'
- - jcr:protected (boolean) mandatory protected
- - jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory protected multiple
- - jcr:defaultPrimaryType (name) protected
- - jcr:sameNameSiblings (boolean) mandatory protected
-
-[nt:versionHistory] > mix:referenceable
- - jcr:versionableUuid (string) mandatory autocreated protected abort
- - jcr:copiedFrom (weakreference) protected abort < 'nt:version'
- + jcr:rootVersion (nt:version) = nt:version mandatory autocreated protected abort
- + jcr:versionLabels (nt:versionLabels) = nt:versionLabels mandatory autocreated
protected abort
- + * (nt:version) = nt:version protected abort
-
-
-[nt:versionLabels]
- - * (reference) protected abort < 'nt:version'
-
-[nt:version] > mix:referenceable
- - jcr:created (date) mandatory autocreated protected abort
- - jcr:predecessors (reference) protected multiple abort < 'nt:version'
- - jcr:successors (reference) protected multiple abort < 'nt:version'
- - jcr:activity (reference) protected abort < 'nt:activity'
- + jcr:frozenNode (nt:frozenNode) protected abort
-
-[nt:frozenNode] > mix:referenceable
- orderable
- - jcr:frozenPrimaryType (name) mandatory autocreated protected abort
- - jcr:frozenMixinTypes (name) protected multiple abort
- - jcr:frozenUuid (string) mandatory autocreated protected abort
- - * (undefined) protected abort
- - * (undefined) protected multiple abort
- + * (nt:base) protected sns abort
-
-[nt:versionedChild]
- - jcr:childVersionHistory (reference) mandatory autocreated protected abort <
'nt:versionHistory'
-
-[nt:query]
- - jcr:statement (string)
- - jcr:language (string)
-
-[nt:activity] > mix:referenceable
- - jcr:activityTitle (string) mandatory autocreated protected
-
-
-[mix:simpleVersionable] mixin
- - jcr:isCheckedOut (boolean) = 'true' mandatory autocreated protected ignore
-
-[mix:versionable] > mix:simpleVersionable, mix:referenceable mixin
- - jcr:versionHistory (reference) mandatory protected ignore <
'nt:versionHistory'
- - jcr:baseVersion (reference) mandatory protected ignore < 'nt:version'
- - jcr:predecessors (reference) mandatory protected multiple ignore <
'nt:version'
- - jcr:mergeFailed (reference) protected multiple abort
- - jcr:activity (reference) protected < 'nt:version'
- - jcr:configuration (reference) protected ignore < 'nt:configuration'
-
-[nt:configuration] > mix:versionable
- - jcr:root (reference) mandatory autocreated protected
-
-[nt:address]
- - jcr:protocol (string)
- - jcr:host (string)
- - jcr:port (string)
- - jcr:repository (string)
- - jcr:workspace (string)
- - jcr:path (path)
- - jcr:id (weakreference)
-
-[nt:naturalText]
- - jcr:text (string)
- - jcr:messageId (string)
-
-
-// ------------------------------------------------------------------------
-// Pre-defined Mixins
-// ------------------------------------------------------------------------
-
-[mix:etag] mixin
- - jcr:etag (string) protected autocreated
-
-[mix:lockable] mixin
- - jcr:lockOwner (string) protected ignore
- - jcr:lockIsDeep (boolean) protected ignore
-
-[mix:lifecycle] mixin
- - jcr:lifecyclePolicy (reference) protected initialize
- - jcr:currentLifecycleState (string) protected initialize
-
-[mix:managedRetention] > mix:referenceable mixin
- - jcr:hold (string) protected multiple
- - jcr:isDeep (boolean) protected multiple
- - jcr:retentionPolicy (reference) protected
-
-[mix:shareable] > mix:referenceable mixin
-
-[mix:title] mixin
- - jcr:title (string)
- - jcr:description (string)
-
-[mix:language] mixin
- - jcr:language (string)