Author: elvisisking
Date: 2012-04-19 09:47:13 -0400 (Thu, 19 Apr 2012)
New Revision: 40340
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.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/attributes/RequiredTypes.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/preference/JcrPreferenceConstants.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
Log:
JBIDE-11575 The ModeShape Tools JCR CND Preference Page Should Show Notation Type Preview.
Add more to the CND that is previewed. Corrected some minor formatting problems. Added a
CndImporter that imports the JackRabbit CND Reader *.cnd file.
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-19
13:19:48 UTC (rev 40339)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-19
13:47:13 UTC (rev 40340)
@@ -831,10 +831,11 @@
final StringBuilder builder = new StringBuilder();
{ // name
- builder.append(NAME_NOTATION_PREFIX)
- .append(this.name.toCndNotation(notationType))
- .append(NAME_NOTATION_SUFFIX)
-
.append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER));
+
builder.append(NAME_NOTATION_PREFIX).append(this.name.toCndNotation(notationType)).append(NAME_NOTATION_SUFFIX);
+
+ if (NotationType.LONG == notationType) {
+
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER));
+ }
}
{ // super types
@@ -863,12 +864,17 @@
final String elementDelimiter =
prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENT_DELIMITER);
for (final CndElement element : elements) {
- builder.append(elementStartDelimiter);
+ if (NotationType.LONG == notationType) {
+ builder.append(elementStartDelimiter);
+ }
+
builder.append(element.toCndNotation(notationType));
builder.append(elementDelimiter);
}
-
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENTS_END_DELIMITER));
+ if (NotationType.COMPACT != notationType) {
+
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENTS_END_DELIMITER));
+ }
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java 2012-04-19
13:19:48 UTC (rev 40339)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java 2012-04-19
13:47:13 UTC (rev 40340)
@@ -48,6 +48,16 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getPrefixEndDelimiter(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
+ */
+ @Override
+ protected String getPrefixEndDelimiter( NotationType notationType ) {
+ return Utils.EMPTY_STRING;
+ }
+
+ /**
* @return the collection of required types (never <code>null</code>)
*/
public String[] toArray() {
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-19
13:19:48 UTC (rev 40339)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-19
13:47:13 UTC (rev 40340)
@@ -508,7 +508,9 @@
}
}
-
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NAMESPACE_MAPPING_SECTION_END_DELIMITER));
+ if (NotationType.COMPACT != notationType) {
+
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NAMESPACE_MAPPING_SECTION_END_DELIMITER));
+ }
}
}
@@ -518,11 +520,13 @@
for (final NodeTypeDefinition nodeTypeDefinition :
this.nodeTypeDefinitions) {
if (Utils.build(builder, addDelim, DELIM,
nodeTypeDefinition.toCndNotation(notationType))) {
- addDelim = true;
+ addDelim = (NotationType.COMPACT != notationType);
}
}
-
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER));
+ if (NotationType.COMPACT != notationType) {
+
builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER));
+ }
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java 2012-04-19
13:19:48 UTC (rev 40339)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java 2012-04-19
13:47:13 UTC (rev 40340)
@@ -65,7 +65,7 @@
ELEMENTS_END_DELIMITER,
/**
- * The delimiter before the first CND element.
+ * The delimiter before each node type definition's item definitions
(properties, child nodes).
*/
ELEMENTS_START_DELIMITER,
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java 2012-04-19
13:19:48 UTC (rev 40339)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java 2012-04-19
13:47:13 UTC (rev 40340)
@@ -61,17 +61,23 @@
if (_previewCnd == null) {
_previewCnd = new CompactNodeTypeDefinition();
- final String content = "<ex =
'http://namespace.com/ns'>\n" //$NON-NLS-1$
- + "[ex:NodeType] > ex:ParentType1, ex:ParentType2 abstract
orderable mixin noquery primaryitem ex:property\n" //$NON-NLS-1$
- + "- ex:property (STRING) = 'default1',
'default2' mandatory autocreated protected multiple VERSION\n" //$NON-NLS-1$
+ final String content = "<abc =
'http://namespace.com/abc/1.0'>\n" //$NON-NLS-1$
+ + "<xyz = 'http://namespace.com/xyz/1.0'>\n"
//$NON-NLS-1$
+ + "[abc:NodeType] > abc:ParentType1, abc:ParentType2 abstract
orderable mixin noquery primaryitem abc:propertyABC\n" //$NON-NLS-1$
+ + "- abc:propertyABC (STRING) = 'default1',
'default2' mandatory autocreated protected multiple VERSION\n" //$NON-NLS-1$
+ " queryops '=, <>, <, <=, >, >=,
LIKE' nofulltext noqueryorder < 'constraint1', 'constraint2'"
//$NON-NLS-1$
- + "+ ex:node (ex:reqType1, ex:reqType2) = ex:defaultType
mandatory autocreated protected sns version"; //$NON-NLS-1$
+ + "+ abc:node (abc:reqType1, abc:reqType2) = abc:defaultType
mandatory autocreated protected sns version\n" //$NON-NLS-1$
+ + "[xyz:NodeTypeX]\n" //$NON-NLS-1$
+ + "- xyz:propertyX" //$NON-NLS-1$
+ + "[xyz:NodeTypeY]\n" //$NON-NLS-1$
+ + "- xyz:propertyY (LONG)" //$NON-NLS-1$
+ + "+ xyz:childNodeY"; //$NON-NLS-1$
CndImporter importer = new CndImporter(true);
Collection<Throwable> problems = new ArrayList<Throwable>();
_previewCnd = importer.importFrom(content, problems, "string");
//$NON-NLS-1$
-
+
if (_previewCnd == null) {
for (Throwable e : problems) {
Activator.getSharedInstance().getLog().log(new Status(IStatus.ERROR,
JcrUiConstants.PLUGIN_ID, null, e));
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-19
13:19:48 UTC (rev 40339)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-19
13:47:13 UTC (rev 40340)
@@ -563,6 +563,17 @@
}
@Test
+ public void shouldImportJackRabbitCndReaderTestCnd() throws Exception {
+ this.importer.importFrom(openCndFile("cnd-reader-test-input.cnd"),
this.problems); //$NON-NLS-1$
+
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
+
+ assertEquals(0, this.problems.size());
+ }
+
+ @Test
public void shouldImportJcrBuiltinNodeTypesForJSR170() throws Exception {
this.cnd =
this.importer.importFrom(openCndFile("jcr-builtins-170.cnd"), this.problems);
//$NON-NLS-1$
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/cnd-reader-test-input.cnd 2012-04-19
13:47:13 UTC (rev 40340)
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+<ex = "http://example.org/jackrabbit/example">
+<jcr='http://www.jcp.org/jcr/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+
+// test remapping
+<REP='internal'>
+
+// omit this namespace to test auto-registering
+// <
mix='http://www.jcp.org/jcr/mix/1.0'>
+
+//------------------------------------------------------------------------------
+// E X A M P L E T Y P E S
+//------------------------------------------------------------------------------
+
+[ex:NodeType] > ex:ParentNodeType1, ex:ParentNodeType2
+ orderable mixin
+ - ex:property (long) = '1', '2' primary mandatory autocreated protected
multiple version < '[1,10]'
+ + ex:node (ex:RequiredNodeType1, ex:RequiredNodeType2) = ex:RequiredNodeType1 mandatory
autocreated protected multiple version
+
+[ex:AnotherNodeType] > ex:NodeType
+ - * (string) = 'a residual property' multiple
+ + * (ex:RequiredNodeType1) multiple
+
+[ex:Empty]
+
+[NoPrefix]
+
+[ex:Reference]
+ - ex:ref (reference) mandatory protected < 'ex:ref'
+
+[ex:Name]
+ - ex:name (name) < 'ex:name'
+
+[ex:Path]
+ - ex:path (path) < 'ex:a/ex:b'
+
+[ex:Full] > ex:NodeType
+ orderable mixin abstract primaryitem ex:p1 noquery
+ - ex:p1 (STRING) mandatory protected autocreated multiple
+ - ex:p2 (BINARY) queryops '=, <>, <, <=, >, >=, LIKE'
+ - ex:p3 (LONG) nofulltext noqueryorder
+ - ex:p4 (DOUBLE)
+ - ex:p5 (BOOLEAN)
+ - ex:p6 (NAME)
+ - ex:p8 (PATH)
+ - ex:p9 (REFERENCE)
+ - ex:pa (WEAKREFERENCE)
+ - ex:pb (DECIMAL)
+ - ex:pc (URI)
+ - ex:pd (UNDEFINED)
+ - ex:pf (*)
+ + ex:n1 (ex:NodeType) COPY
+ + ex:n2 (ex:NodeType) VERSION
+ + ex:n3 (ex:NodeType) INITIALIZE
+ + ex:n4 (ex:NodeType) COMPUTE
+ + ex:n5 (ex:NodeType) IGNORE
+ + ex:n6 (ex:NodeType) ABORT
+
+[ex:Full1] > ex:NodeType
+ orderable mixin abstract primaryitem ex:p1 query
+ - ex:p1
+
+//------------------------------------------------------------------------------
+// B A S E T Y P E S
+//------------------------------------------------------------------------------
+
+[nt:base]
+ - jcr:primaryType (name) mandatory autocreated protected compute
+ - jcr:mixinTypes (name) protected multiple compute
+
+[nt:unstructured]
+ orderable
+ - * (undefined) multiple
+ - * (undefined)
+ + * (nt:base) = nt:unstructured multiple version
+
+[mix:referenceable]
+ mixin
+ - jcr:uuid (string) mandatory autocreated protected initialize
+
+[mix:lockable]
+ mixin
+ - jcr:lockOwner (string) protected ignore
+ - jcr:lockIsDeep (boolean) protected ignore
+
+//------------------------------------------------------------------------------
+// V E R S I O N I N G
+//------------------------------------------------------------------------------
+
+[mix:versionable] > mix:referenceable
+ mixin
+ - jcr:versionHistory (reference) mandatory protected
+ < 'nt:versionHistory'
+ - jcr:baseVersion (reference) mandatory protected ignore
+ < 'nt:version'
+ - jcr:isCheckedOut (boolean) = 'true' mandatory autocreated protected ignore
+ - jcr:predecessors (reference) mandatory protected multiple
+ < 'nt:version'
+ - jcr:mergeFailed (reference) protected multiple abort
+
+[nt:versionHistory] > mix:referenceable
+ - jcr:versionableUuid (string) mandatory autocreated protected abort
+ + 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: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 multiple abort
+
+[nt:versionedChild]
+ - jcr:childVersionHistory (reference) mandatory autocreated protected abort
+ < 'nt:versionHistory'
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+[nt:nodeType]
+ - jcr:nodeTypeName (name) mandatory
+ - jcr:supertypes (name) multiple
+ - jcr:isMixin (boolean) mandatory
+ - jcr:hasOrderableChildNodes (boolean) mandatory
+ - jcr:primaryItemName (name)
+ + jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition multiple
version
+ + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition multiple
version
+
+[nt:propertyDefinition]
+ - jcr:name (name)
+ - jcr:autoCreated (boolean) mandatory
+ - jcr:mandatory (boolean) mandatory
+ - jcr:onParentVersion (string) mandatory
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory
+ - jcr:requiredType (string) mandatory
+ < 'STRING', 'BINARY', 'LONG', 'DOUBLE',
'BOOLEAN', 'DATE', 'NAME', 'PATH', 'REFERENCE',
'UNDEFINED'
+ - jcr:valueConstraints (string) multiple
+ - jcr:defaultValues (undefined) multiple
+ - jcr:multiple (boolean) mandatory
+
+[nt:childNodeDefinition]
+ - jcr:name (name)
+ - jcr:autoCreated (boolean) mandatory
+ - jcr:mandatory (boolean) mandatory
+ - jcr:onParentVersion (string) mandatory
+ < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE',
'IGNORE', 'ABORT'
+ - jcr:protected (boolean) mandatory
+ - jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory multiple
+ - jcr:defaultPrimaryType (name)
+ - jcr:sameNameSiblings (boolean) mandatory
+
+//------------------------------------------------------------------------------
+// M I S C
+//------------------------------------------------------------------------------
+
+[nt:hierarchyNode]
+ - jcr:created (date) autocreated protected initialize
+
+[nt:folder] > nt:hierarchyNode
+ + * (nt:hierarchyNode) version
+
+[nt:file] > nt:hierarchyNode
+ + jcr:content (nt:base) primary mandatory
+
+[nt:linkedFile] > nt:hierarchyNode
+ - jcr:content (reference) primary mandatory
+
+[nt:resource] > mix:referenceable
+ - jcr:encoding (string)
+ - jcr:mimeType (string) mandatory
+ - jcr:data (binary) primary mandatory
+ - jcr:lastModified (date) mandatory ignore
+
+[nt:query]
+ - jcr:statement (string)
+ - jcr:language (string)
+
+//------------------------------------------------------------------------------
+// J A C K R A B B I T I N T E R N A L S
+//------------------------------------------------------------------------------
+
+[REP:nodeTypes]
+ + * (nt:nodeType) = nt:nodeType protected abort
+
+[REP:root] > nt:unstructured
+ orderable
+ + jcr:system (REP:system) = REP:system mandatory ignore
+
+[REP:system]
+ orderable
+ + jcr:versionStorage (REP:versionStorage) = REP:versionStorage mandatory protected
abort
+ + jcr:nodeTypes (REP:nodeTypes) = REP:nodeTypes mandatory protected abort
+ + * (nt:base) = nt:unstructured multiple ignore
+
+[REP:versionStorage]
+ + * (nt:versionHistory) = nt:versionHistory protected multiple abort
+ + * (REP:versionStorage) = REP:versionStorage protected multiple abort
\ No newline at end of file