Author: elvisisking
Date: 2012-04-03 16:50:15 -0400 (Tue, 03 Apr 2012)
New Revision: 40016
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemOwnerProvider.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.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/PropertyDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.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/PropertyDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.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/NodeTypeDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. For inherited item
definitions, now showing their declaring node type in the tables. Required changes to the
business objects so that they knew who their owner/parent is.
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -25,9 +25,9 @@
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
- *
+ * The <code>ChildNodeDefinition</code> class represents node type child node
definition.
*/
-public class ChildNodeDefinition implements ItemDefinition, Comparable,
NodeDefinitionTemplate {
+public class ChildNodeDefinition implements ItemDefinition, NodeDefinitionTemplate {
/**
* The prefix used in CND notation before the property definition.
@@ -36,10 +36,12 @@
/**
* @param childNodeBeingCopied the child node definition being copied (cannot be
<code>null</code>)
+ * @param ownerProvider the owner provider that owns this child node (cannot be
<code>null</code>)
* @return the copy (never <code>null</code>)
*/
- public static ChildNodeDefinition copy( final ChildNodeDefinition
childNodeBeingCopied ) {
- final ChildNodeDefinition copy = new ChildNodeDefinition();
+ public static ChildNodeDefinition copy( final ChildNodeDefinition
childNodeBeingCopied,
+ final ItemOwnerProvider ownerProvider ) {
+ final ChildNodeDefinition copy = new ChildNodeDefinition(ownerProvider);
// name
copy.setName(childNodeBeingCopied.getName());
@@ -86,14 +88,24 @@
private final QualifiedName name;
/**
+ * An owner provider for this property (never <code>null</code>).
+ */
+ private final ItemOwnerProvider ownerProvider;
+
+ /**
* The node required types (never <code>null</code>).
*/
private final RequiredTypes requiredTypes;
/**
* Constructs an instance set to all defaults.
+ *
+ * @param ownerProvider the item owner provider that owns this child node (cannot be
<code>null</code>)
*/
- public ChildNodeDefinition() {
+ public ChildNodeDefinition( final ItemOwnerProvider ownerProvider ) {
+ Utils.verifyIsNotNull(ownerProvider, "ownerProvider"); //$NON-NLS-1$
+
+ this.ownerProvider = ownerProvider;
this.attributes = new NodeAttributes();
this.name = new QualifiedName();
this.defaultType = new DefaultType();
@@ -263,6 +275,10 @@
return false;
}
+ if (!Utils.equals(getDeclaringNodeTypeDefinitionName(),
that.getDeclaringNodeTypeDefinitionName())) {
+ return false;
+ }
+
return this.requiredTypes.equals(that.requiredTypes);
}
@@ -294,6 +310,16 @@
/**
* {@inheritDoc}
*
+ * @see
org.jboss.tools.modeshape.jcr.ItemDefinition#getDeclaringNodeTypeDefinitionName()
+ */
+ @Override
+ public QualifiedName getDeclaringNodeTypeDefinitionName() {
+ return this.ownerProvider.getOwnerQualifiedName();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryType()
* @throws UnsupportedOperationException if method is called
*/
@@ -464,7 +490,8 @@
*/
@Override
public int hashCode() {
- return Utils.hashCode(this.attributes, this.name, this.defaultType,
this.requiredTypes);
+ return Utils.hashCode(this.attributes, this.name, this.defaultType,
this.requiredTypes,
+ getDeclaringNodeTypeDefinitionName());
}
/**
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -12,7 +12,7 @@
/**
* An interface for property definitions and child node definitions.
*/
-public interface ItemDefinition extends CndElement {
+public interface ItemDefinition extends CndElement, Comparable {
/**
* Defines a residual set of child items.
@@ -20,6 +20,11 @@
String RESIDUAL_NAME = "*"; //$NON-NLS-1$
/**
+ * @return the name of the node type definition where this item definition is defined
(never <code>null</code>)
+ */
+ QualifiedName getDeclaringNodeTypeDefinitionName();
+
+ /**
* @return the qualified name (never <code>null</code>)
*/
QualifiedName getQualifiedName();
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemOwnerProvider.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemOwnerProvider.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemOwnerProvider.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -0,0 +1,19 @@
+/*
+ * 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;
+
+/**
+ * Provides information about an item's owner.
+ */
+public interface ItemOwnerProvider {
+
+ /**
+ * @return the qualified name of the owner (never <code>null</code>)
+ */
+ QualifiedName getOwnerQualifiedName();
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemOwnerProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -31,7 +31,7 @@
/**
* Represents a CND node type definition.
*/
-public class NodeTypeDefinition implements CndElement, Comparable, NodeTypeTemplate {
+public class NodeTypeDefinition implements CndElement, Comparable, ItemOwnerProvider,
NodeTypeTemplate {
/**
* Then node type name prefix used in the CND notation.
@@ -65,12 +65,12 @@
// child nodes
for (final ChildNodeDefinition childNode :
nodeTypeToCopy.getChildNodeDefinitions()) {
- copy.addChildNodeDefinition(ChildNodeDefinition.copy(childNode));
+ copy.addChildNodeDefinition(ChildNodeDefinition.copy(childNode, copy));
}
// properties
for (final PropertyDefinition property : nodeTypeToCopy.getPropertyDefinitions())
{
- copy.addPropertyDefinition(PropertyDefinition.copy(property));
+ copy.addPropertyDefinition(PropertyDefinition.copy(property, copy));
}
// supertypes
@@ -317,7 +317,7 @@
}
/**
- * @return the child node definitions (never <code>null</code>)
+ * @return the declared child node definitions (never <code>null</code>)
*/
public List<ChildNodeDefinition> getChildNodeDefinitions() {
if (this.cndElements == null) {
@@ -416,6 +416,16 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.ItemOwnerProvider#getOwnerQualifiedName()
+ */
+ @Override
+ public QualifiedName getOwnerQualifiedName() {
+ return getQualifiedName();
+ }
+
+ /**
* @return the qualified primary item name (never <code>null</code>)
*/
public QualifiedName getPrimaryItem() {
@@ -440,7 +450,7 @@
}
/**
- * @return the property definitions (never <code>null</code>)
+ * @return the declared property definitions (never <code>null</code>)
*/
public List<PropertyDefinition> getPropertyDefinitions() {
if (this.cndElements == null) {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -32,7 +32,7 @@
/**
* The <code>PropertyDefinition</code> class represents node type property
definition.
*/
-public class PropertyDefinition implements ItemDefinition, Comparable,
PropertyDefinitionTemplate {
+public class PropertyDefinition implements ItemDefinition, PropertyDefinitionTemplate {
/**
* The prefix used in CND notation before the property definition.
@@ -46,10 +46,12 @@
/**
* @param propertyBeingCopied the property definition being copied (cannot be
<code>null</code>)
+ * @param ownerProvider the item owner provider that owns this property (cannot be
<code>null</code>)
* @return the copy (never <code>null</code>)
*/
- public static final PropertyDefinition copy( final PropertyDefinition
propertyBeingCopied ) {
- final PropertyDefinition copy = new PropertyDefinition();
+ public static final PropertyDefinition copy( final PropertyDefinition
propertyBeingCopied,
+ final ItemOwnerProvider ownerProvider )
{
+ final PropertyDefinition copy = new PropertyDefinition(ownerProvider);
// name
copy.setName(propertyBeingCopied.getName());
@@ -106,6 +108,11 @@
private final QualifiedName name;
/**
+ * An owner provider for this property (never <code>null</code>).
+ */
+ private final ItemOwnerProvider ownerProvider;
+
+ /**
* The property type (never <code>null</code>).
*/
private PropertyType type;
@@ -117,8 +124,13 @@
/**
* Constructs an instance with a default type of {@link PropertyType#STRING}.
+ *
+ * @param ownerProvider the item owner provider that owns this property (cannot be
<code>null</code>)
*/
- public PropertyDefinition() {
+ public PropertyDefinition( final ItemOwnerProvider ownerProvider ) {
+ Utils.verifyIsNotNull(ownerProvider, "ownerProvider"); //$NON-NLS-1$
+
+ this.ownerProvider = ownerProvider;
this.type = PropertyType.DEFAULT_VALUE;
this.name = new QualifiedName();
this.attributes = new PropertyAttributes();
@@ -325,8 +337,6 @@
}
final PropertyDefinition that = (PropertyDefinition)obj;
- // this.defaultValues = new DefaultValues();
- // this.valueConstraints = new ValueConstraints();
if (!this.attributes.equals(that.attributes)) {
return false;
@@ -344,6 +354,10 @@
return false;
}
+ if (!Utils.equals(getDeclaringNodeTypeDefinitionName(),
that.getDeclaringNodeTypeDefinitionName())) {
+ return false;
+ }
+
return this.valueConstraints.equals(that.valueConstraints);
}
@@ -385,6 +399,16 @@
/**
* {@inheritDoc}
*
+ * @see
org.jboss.tools.modeshape.jcr.ItemDefinition#getDeclaringNodeTypeDefinitionName()
+ */
+ @Override
+ public QualifiedName getDeclaringNodeTypeDefinitionName() {
+ return this.ownerProvider.getOwnerQualifiedName();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see javax.jcr.nodetype.PropertyDefinition#getDefaultValues()
*/
@Override
@@ -542,7 +566,8 @@
*/
@Override
public int hashCode() {
- return Utils.hashCode(this.attributes, this.name, this.defaultValues, this.type,
this.valueConstraints);
+ return Utils.hashCode(this.attributes, this.name, this.defaultValues, this.type,
this.valueConstraints,
+ getDeclaringNodeTypeDefinitionName());
}
/**
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -172,7 +172,7 @@
assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
tokens.consume(ChildNodeDefinition.NOTATION_PREFIX);
- final ChildNodeDefinition childNodeDefn = new ChildNodeDefinition();
+ final ChildNodeDefinition childNodeDefn = new ChildNodeDefinition(nodeTypeDefn);
// name
final String name = parseName(tokens);
@@ -610,7 +610,7 @@
assert (nodeTypeDefn != null) : "nodeTypeDefn is null"; //$NON-NLS-1$
tokens.consume(PropertyDefinition.NOTATION_PREFIX);
- final PropertyDefinition propDefn = new PropertyDefinition();
+ final PropertyDefinition propDefn = new PropertyDefinition(nodeTypeDefn);
// name
final String name = parseName(tokens);
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -56,6 +56,7 @@
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition.PropertyName;
+import org.jboss.tools.modeshape.jcr.ItemOwnerProvider;
import org.jboss.tools.modeshape.jcr.Messages;
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
@@ -108,13 +109,17 @@
* Used to create a new child node definition.
*
* @param parentShell the parent shell (can be <code>null</code>)
+ * @param ownerProvider an item owner provider for the new child node (cannot be
<code>null</code>)
* @param existingChildNodeNames the existing child node names (can be
<code>null</code> or empty)
* @param existingNamespacePrefixes the existing CND namespace prefixes (can be
<code>null</code> or empty)
*/
public ChildNodeDialog( final Shell parentShell,
+ final ItemOwnerProvider ownerProvider,
final Collection<QualifiedName>
existingChildNodeNames,
final Collection<String> existingNamespacePrefixes ) {
super(parentShell);
+ Utils.verifyIsNotNull(ownerProvider, "ownerProvider"); //$NON-NLS-1$
+
this.existingChildNodeNames = ((existingChildNodeNames == null) ?
Collections.<QualifiedName> emptyList()
: new
ArrayList<QualifiedName>(existingChildNodeNames));
this.existingNamespacePrefixes = ((existingNamespacePrefixes == null) ?
Collections.<String> emptyList()
@@ -122,28 +127,30 @@
this.nameError = new ErrorMessage();
this.defaultTypeError = new ErrorMessage();
this.requiredTypesError = new ErrorMessage();
- this.childNodeBeingEdited = new ChildNodeDefinition();
+ this.childNodeBeingEdited = new ChildNodeDefinition(ownerProvider);
}
/**
* Used to edit a child node definition.
*
* @param parentShell the parent shell (can be <code>null</code>)
+ * @param ownerProvider an item owner provider for the new child node (cannot be
<code>null</code>)
* @param existingChildNodeNames the existing child node names (can be
<code>null</code> or empty)
* @param existingNamespacePrefixes the existing CND namespace prefixes (can be
<code>null</code> or empty)
* @param childNodeBeingEdited the child node definition being edited (cannot be
<code>null</code>)
*/
public ChildNodeDialog( final Shell parentShell,
+ final ItemOwnerProvider ownerProvider,
final Collection<QualifiedName>
existingChildNodeNames,
final Collection<String> existingNamespacePrefixes,
final ChildNodeDefinition childNodeBeingEdited ) {
- this(parentShell, existingChildNodeNames, existingNamespacePrefixes);
+ this(parentShell, ownerProvider, existingChildNodeNames,
existingNamespacePrefixes);
Utils.verifyIsNotNull(childNodeBeingEdited, "childNodeBeingEdited");
//$NON-NLS-1$
this.originalChildNode = childNodeBeingEdited;
// create copy of child node being edited
- this.childNodeBeingEdited = ChildNodeDefinition.copy(this.originalChildNode);
+ this.childNodeBeingEdited = ChildNodeDefinition.copy(this.originalChildNode,
ownerProvider);
// remove name from existing names so that validation won't show it as a
duplicate
if (!Utils.isEmpty(this.childNodeBeingEdited.getName())) {
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
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -293,13 +293,14 @@
* @see
org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
*/
@Override
- public Color getBackground( Object element ) {
+ public Color getBackground( final Object element ) {
final ChildNodeDefinition childNodeDefinition =
(ChildNodeDefinition)element;
if (shouldShowInheritedChildNodes()) {
- NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if
(!nodeTypeDefinition.hasDeclaredChildNodeDefinition(childNodeDefinition.getName())) {
+ if (Utils.equivalent(nodeTypeDefinition.getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
+
.get())) {
return
getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
}
}
@@ -313,13 +314,14 @@
* @see
org.eclipse.jface.viewers.ColumnLabelProvider#getFont(java.lang.Object)
*/
@Override
- public Font getFont( Object element ) {
+ public Font getFont( final Object element ) {
final ChildNodeDefinition childNodeDefinition =
(ChildNodeDefinition)element;
if (shouldShowInheritedChildNodes()) {
- NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if
(!nodeTypeDefinition.hasDeclaredChildNodeDefinition(childNodeDefinition.getName())) {
+ if (Utils.equivalent(nodeTypeDefinition.getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
+
.get())) {
return
JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
}
}
@@ -342,6 +344,15 @@
final NotationType notationType = NotationType.LONG;
+ if (this.columnIndex == ChildNodeColumnIndexes.DECLARING_NODE_TYPE) {
+ if (Utils.equivalent(getSelectedNodeType().getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
+
.get())) {
+ return
childNodeDefinition.getDeclaringNodeTypeDefinitionName().get();
+ }
+
+ return Utils.EMPTY_STRING;
+ }
+
if (this.columnIndex == ChildNodeColumnIndexes.DEFAULT_TYPE) {
return childNodeDefinition.getDefaultType().getDefaultType().get();
}
@@ -387,7 +398,7 @@
try {
return
getCnd().getChildNodeDefinitions(nodeTypeDefinition.getName(),
shouldShowInheritedChildNodes())
.toArray();
- } catch (Exception e) {
+ } catch (final Exception e) {
Activator.getSharedInstance()
.getLog()
.log(new Status(IStatus.ERROR,
@@ -417,7 +428,7 @@
// open edit child node on double click
final IAction editAction = this.editChildNode;
-
+
this.childNodeViewer.addDoubleClickListener(new IDoubleClickListener() {
/**
@@ -471,6 +482,12 @@
CndMessages.attributesHeaderText,
CndMessages.childNodeAttributesToolTip, false, true);
}
+ { // create declaring node type column
+ final TableViewerColumn nodeTypeColumn = new
TableViewerColumn(this.childNodeViewer, SWT.LEFT);
+ UiUtils.configureColumn(nodeTypeColumn, new
ChildNodeLabelProvider(ChildNodeColumnIndexes.DECLARING_NODE_TYPE),
+ CndMessages.declaringNodeTypeHeaderText,
CndMessages.declaringNodeTypeToolTip, false, true);
+ }
+
// this will sort by child node name
this.childNodeViewer.setSorter(new ViewerSorter() {
@@ -1286,13 +1303,14 @@
* @see
org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
*/
@Override
- public Color getBackground( Object element ) {
+ public Color getBackground( final Object element ) {
final PropertyDefinition propertyDefinition =
(PropertyDefinition)element;
if (shouldShowInheritedProperties()) {
- NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if
(!nodeTypeDefinition.hasDeclaredPropertyDefinition(propertyDefinition.getName())) {
+ if (!Utils.equivalent(nodeTypeDefinition.getName(),
propertyDefinition.getDeclaringNodeTypeDefinitionName()
+
.get())) {
return
getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
}
}
@@ -1306,13 +1324,14 @@
* @see
org.eclipse.jface.viewers.ColumnLabelProvider#getFont(java.lang.Object)
*/
@Override
- public Font getFont( Object element ) {
+ public Font getFont( final Object element ) {
final PropertyDefinition propertyDefinition =
(PropertyDefinition)element;
if (shouldShowInheritedProperties()) {
- NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if
(!nodeTypeDefinition.hasDeclaredPropertyDefinition(propertyDefinition.getName())) {
+ if (!Utils.equivalent(nodeTypeDefinition.getName(),
propertyDefinition.getDeclaringNodeTypeDefinitionName()
+
.get())) {
return
JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
}
}
@@ -1343,6 +1362,15 @@
return propertyDefinition.getAttributesCndNotation(notationType);
}
+ if (this.columnIndex == PropertyColumnIndexes.DECLARING_NODE_TYPE) {
+ if (!Utils.equivalent(getSelectedNodeType().getName(),
propertyDefinition.getDeclaringNodeTypeDefinitionName()
+
.get())) {
+ return
propertyDefinition.getDeclaringNodeTypeDefinitionName().get();
+ }
+
+ return Utils.EMPTY_STRING;
+ }
+
if (this.columnIndex == PropertyColumnIndexes.DEFAULT_VALUES) {
final List<String> defaultValues =
propertyDefinition.getDefaultValuesAsStrings();
@@ -1390,7 +1418,7 @@
try {
return
getCnd().getPropertyDefinitions(nodeTypeDefinition.getName(),
shouldShowInheritedProperties())
.toArray();
- } catch (Exception e) {
+ } catch (final Exception e) {
Activator.getSharedInstance()
.getLog()
.log(new Status(IStatus.ERROR,
@@ -1481,6 +1509,12 @@
true);
}
+ { // create declaring node type column
+ final TableViewerColumn nodeTypeColumn = new
TableViewerColumn(this.propertyViewer, SWT.LEFT);
+ UiUtils.configureColumn(nodeTypeColumn, new
PropertyLabelProvider(PropertyColumnIndexes.DECLARING_NODE_TYPE),
+ CndMessages.declaringNodeTypeHeaderText,
CndMessages.declaringNodeTypeToolTip, false, true);
+ }
+
// this will sort by property name
this.propertyViewer.setSorter(new ViewerSorter() {
@@ -1768,7 +1802,10 @@
void handleAddChildNode() {
assert (getSelectedNodeType() != null) : "add child node handler called but
there is no selected node type"; //$NON-NLS-1$
- final ChildNodeDialog dialog = new ChildNodeDialog(getShell(),
getChildNodeNames(), getCnd().getNamespacePrefixes());
+ final ChildNodeDialog dialog = new ChildNodeDialog(getShell(),
+ getSelectedNodeType(),
+ getChildNodeNames(),
+
getCnd().getNamespacePrefixes());
dialog.create();
dialog.getShell().pack();
@@ -1854,6 +1891,7 @@
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
final PropertyDialog dialog = new PropertyDialog(getShell(),
+ getSelectedNodeType(),
getPropertyNames(),
getCnd().getNamespacePrefixes(),
nodeTypeDefinition.isQueryable());
@@ -2062,6 +2100,7 @@
final ChildNodeDefinition childNodeBeingEdited = getSelectedChildNode();
final ChildNodeDialog dialog = new ChildNodeDialog(getShell(),
+ getSelectedNodeType(),
getChildNodeNames(),
getCnd().getNamespacePrefixes(),
childNodeBeingEdited);
@@ -2138,6 +2177,7 @@
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
final PropertyDefinition propertyBeingEdited = getSelectedProperty();
final PropertyDialog dialog = new PropertyDialog(getShell(),
+ getSelectedNodeType(),
getPropertyNames(),
getCnd().getNamespacePrefixes(),
nodeTypeDefinition.isQueryable(),
@@ -2848,6 +2888,7 @@
interface ChildNodeColumnIndexes {
int ATTRIBUTES = 3;
+ int DECLARING_NODE_TYPE = 4;
int DEFAULT_TYPE = 2;
int NAME = 0;
int REQUIRED_TYPES = 1;
@@ -2872,6 +2913,7 @@
interface PropertyColumnIndexes {
int ATTRIBUTES = 3;
int CONSTRAINTS = 4;
+ int DECLARING_NODE_TYPE = 5;
int DEFAULT_VALUES = 2;
int NAME = 0;
int TYPE = 1;
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
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -320,6 +320,16 @@
public static String cndMessageDialogTitle;
/**
+ * The column header text of the declaring node type of an item definition.
+ */
+ public static String declaringNodeTypeHeaderText;
+
+ /**
+ * The tool tip message of the declaring node type of an item definition.
+ */
+ public static String declaringNodeTypeToolTip;
+
+ /**
* The column header text of the default type of a child node definition.
*/
public static String defaultTypeHeaderText;
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
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -52,6 +52,7 @@
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.jboss.tools.modeshape.jcr.ItemOwnerProvider;
import org.jboss.tools.modeshape.jcr.Messages;
import org.jboss.tools.modeshape.jcr.PropertyDefinition;
import org.jboss.tools.modeshape.jcr.PropertyDefinition.PropertyName;
@@ -107,11 +108,13 @@
* Used to create a new property definition.
*
* @param parentShell the parent shell (can be <code>null</code>)
+ * @param ownerProvider an item owner provider for the new property (cannot 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 ItemOwnerProvider ownerProvider,
final Collection<QualifiedName> existingPropertyNames,
final Collection<String> existingNamespacePrefixes,
final boolean nodeTypeQueryable ) {
@@ -124,30 +127,32 @@
this.defaultValuesError = new ErrorMessage();
this.nameError = new ErrorMessage();
this.valueConstraintsError = new ErrorMessage();
- this.propertyBeingEdited = new PropertyDefinition();
+ this.propertyBeingEdited = new PropertyDefinition(ownerProvider);
}
/**
* Used to edit a property definition.
*
* @param parentShell the parent shell (can be <code>null</code>)
+ * @param ownerProvider an item owner provider for the new property (cannot 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 edited is
queryable
* @param propertyDefinitionBeingEdited the property definition being edited (cannot
be <code>null</code>)
*/
public PropertyDialog( final Shell parentShell,
+ final ItemOwnerProvider ownerProvider,
final Collection<QualifiedName> existingPropertyNames,
final Collection<String> existingNamespacePrefixes,
final boolean nodeTypeQueryable,
final PropertyDefinition propertyDefinitionBeingEdited ) {
- this(parentShell, existingPropertyNames, existingNamespacePrefixes,
nodeTypeQueryable);
+ this(parentShell, ownerProvider, existingPropertyNames,
existingNamespacePrefixes, nodeTypeQueryable);
Utils.verifyIsNotNull(propertyDefinitionBeingEdited,
"propertyDefinitionBeingEdited"); //$NON-NLS-1$
this.originalProperty = propertyDefinitionBeingEdited;
// create copy of property being edited
- this.propertyBeingEdited = PropertyDefinition.copy(this.originalProperty);
+ this.propertyBeingEdited = PropertyDefinition.copy(this.originalProperty,
ownerProvider);
// remove name from existing names so that validation won't show it as a
duplicate
if (!Utils.isEmpty(this.propertyBeingEdited.getName())) {
@@ -633,7 +638,7 @@
*/
@Override
public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
+ final Button btn = (Button)e.widget;
handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
}
});
@@ -658,7 +663,7 @@
*/
@Override
public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
+ final Button btn = (Button)e.widget;
handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
}
});
@@ -683,7 +688,7 @@
*/
@Override
public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
+ final Button btn = (Button)e.widget;
handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
}
});
@@ -708,7 +713,7 @@
*/
@Override
public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
+ final Button btn = (Button)e.widget;
handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
}
});
@@ -734,7 +739,7 @@
*/
@Override
public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
+ final Button btn = (Button)e.widget;
handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
}
});
@@ -759,7 +764,7 @@
*/
@Override
public void widgetSelected( final SelectionEvent e ) {
- Button btn = (Button)e.widget;
+ final Button btn = (Button)e.widget;
handleQueryOperatorChanged(btn.getText(),
btn.getSelection());
}
});
@@ -888,19 +893,6 @@
validateType();
}
- /**
- * @param text
- * @param selection
- */
- protected void handleQueryOperatorChanged( String text,
- boolean selection ) {
- if (selection) {
- this.propertyBeingEdited.addQueryOperator(QueryOperator.find(text));
- } else {
- this.propertyBeingEdited.removeQueryOperator(QueryOperator.find(text));
- }
- }
-
void createValueConstraintsActions() {
this.addValueConstraint = new Action(Utils.EMPTY_STRING) {
@@ -1429,6 +1421,19 @@
this.propertyBeingEdited.setProtected(newProtected);
}
+ /**
+ * @param text
+ * @param selection
+ */
+ protected void handleQueryOperatorChanged( final String text,
+ final boolean selection ) {
+ if (selection) {
+ this.propertyBeingEdited.addQueryOperator(QueryOperator.find(text));
+ } else {
+ this.propertyBeingEdited.removeQueryOperator(QueryOperator.find(text));
+ }
+ }
+
void handleTypeChanged( final String newType ) {
this.propertyBeingEdited.setType(PropertyType.valueOf(newType));
}
@@ -1481,7 +1486,7 @@
}
private void validateDefaultValues() {
- updateMessage(CndValidator.validateDefaultValues(this.propertyBeingEdited,
existingNamespacePrefixes),
+ updateMessage(CndValidator.validateDefaultValues(this.propertyBeingEdited,
this.existingNamespacePrefixes),
this.defaultValuesError);
}
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
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-03
20:50:15 UTC (rev 40016)
@@ -68,6 +68,8 @@
cndMessageDialogMessageAreaMessage = The {0} CND has {1} error(s), {2} warnings, and {3}
information messages.
cndMessageDialogMessageAreaTitle = Message Summary
cndMessageDialogTitle = CND Validation Messages
+declaringNodeTypeHeaderText = Declaring Node Type
+declaringNodeTypeToolTip = The node type definition that defines the property or child
node
defaultTypeHeaderText = Default Type
defaultValueDialogCreateMsg = Create Default Value
defaultValueDialogEditMsg = Edit Default Value
@@ -223,8 +225,8 @@
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
+showInheritedChildNodesToolTip = Show the child node definitions inherited by the
selected node type or just those explictly declared
+showInheritedPropertiesToolTip = Show the property definitions inherited by the selected
node type or just those explictly declared
supertypesLabel = Supertypes:
supertypesToolTip = The supertypes (node types and mixins) whose property definitions and
child node definitions are inherited
typeHeaderText = Type
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -15,6 +15,8 @@
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition.PropertyName;
import org.jboss.tools.modeshape.jcr.Listener;
+import org.jboss.tools.modeshape.jcr.NodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.attributes.OnParentVersion;
@@ -26,63 +28,68 @@
*/
public class ChildNodeDefinitionTest {
+ private static final QualifiedName OWNER_NAME = Constants.QUALIFIED_NAME1;
+
+ private NodeTypeDefinition owner;
private ChildNodeDefinition childNodeDefinition;
@Before
public void beforeEach() {
- this.childNodeDefinition = new ChildNodeDefinition();
+ this.owner = new NodeTypeDefinition();
+ this.owner.setName(OWNER_NAME.get());
+ this.childNodeDefinition = new ChildNodeDefinition(owner);
}
@Test
public void copiesShouldBeEqualAndHaveSameHashCode() {
- ChildNodeDefinition thatChildNodeDefinition =
ChildNodeDefinition.copy(this.childNodeDefinition);
+ ChildNodeDefinition thatChildNodeDefinition =
ChildNodeDefinition.copy(this.childNodeDefinition, this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.DEFAULT_TYPE);
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setAutoCreated(!this.childNodeDefinition.isAutoCreated());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setMandatory(!this.childNodeDefinition.isMandatory());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setProtected(!this.childNodeDefinition.isProtected());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setSameNameSiblings(!this.childNodeDefinition.allowsSameNameSiblings());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setOnParentVersion(OnParentVersion.ABORT.asJcrValue());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
this.childNodeDefinition.setRequiredPrimaryTypeNames(Constants.Helper.getDefaultQualifiedNamesAsStringArray());
- thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
+ thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition,
this.owner);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
}
@Test
public void differentInstancesWithSameValuesShouldBeEqual() {
- final ChildNodeDefinition that = new ChildNodeDefinition();
+ final ChildNodeDefinition that = new ChildNodeDefinition(this.owner);
assertEquals(this.childNodeDefinition, that);
this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
@@ -120,7 +127,7 @@
@Test
public void differentInstancesWithSameValuesShouldHaveSameHashCode() {
- assertEquals(this.childNodeDefinition.hashCode(), new
ChildNodeDefinition().hashCode());
+ assertEquals(this.childNodeDefinition.hashCode(), new
ChildNodeDefinition(this.owner).hashCode());
}
@Test
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
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -35,16 +35,16 @@
@Before
public void beforeEach() {
- this.childNodeDefinition = new ChildNodeDefinition();
- this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
-
this.cnd = new CompactNodeTypeDefinition();
this.namespaceMapping = new NamespaceMapping();
this.nodeTypeDefinition = new NodeTypeDefinition();
this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.propertyDefinition = new PropertyDefinition();
+ this.childNodeDefinition = new ChildNodeDefinition(this.nodeTypeDefinition);
+ this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
+ this.propertyDefinition = new PropertyDefinition(this.nodeTypeDefinition);
this.propertyDefinition.setName(Constants.QUALIFIED_NAME1.get());
}
@@ -177,7 +177,7 @@
final String NAME = "name"; //$NON-NLS-1$
this.childNodeDefinition.setName(NAME);
- final ChildNodeDefinition child2 = new ChildNodeDefinition();
+ final ChildNodeDefinition child2 = new
ChildNodeDefinition(this.nodeTypeDefinition);
child2.setName(NAME);
this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
@@ -192,7 +192,7 @@
final String NAME = "name"; //$NON-NLS-1$
this.propertyDefinition.setName(NAME);
- final PropertyDefinition prop2 = new PropertyDefinition();
+ final PropertyDefinition prop2 = new
PropertyDefinition(this.nodeTypeDefinition);
prop2.setName(NAME);
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
@@ -316,7 +316,7 @@
public void shouldAllowMultipleChildNodeDefinitionsWithResidualNames() {
this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- final ChildNodeDefinition childNode2 = new ChildNodeDefinition();
+ final ChildNodeDefinition childNode2 = new
ChildNodeDefinition(this.nodeTypeDefinition);
childNode2.setName(ItemDefinition.RESIDUAL_NAME);
this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
this.nodeTypeDefinition.addChildNodeDefinition(childNode2);
@@ -328,7 +328,7 @@
public void shouldAllowMultiplePropertyDefinitionsWithResidualNames() {
this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
this.propertyDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- final PropertyDefinition propDefn2 = new PropertyDefinition();
+ final PropertyDefinition propDefn2 = new
PropertyDefinition(this.nodeTypeDefinition);
propDefn2.setName(ItemDefinition.RESIDUAL_NAME);
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
this.nodeTypeDefinition.addPropertyDefinition(propDefn2);
@@ -346,7 +346,7 @@
public void shouldNotAllowChildNodeDefinitionsWithSameName() {
this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
this.childNodeDefinition.setName("name"); //$NON-NLS-1$
- final ChildNodeDefinition childNode2 = new ChildNodeDefinition();
+ final ChildNodeDefinition childNode2 = new
ChildNodeDefinition(this.nodeTypeDefinition);
childNode2.setName(this.childNodeDefinition.getName());
this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
this.nodeTypeDefinition.addChildNodeDefinition(childNode2);
@@ -378,7 +378,7 @@
public void shouldNotAllowPropertyDefinitionsWithSameName() {
this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
this.propertyDefinition.setName("name"); //$NON-NLS-1$
- final PropertyDefinition propDefn2 = new PropertyDefinition();
+ final PropertyDefinition propDefn2 = new
PropertyDefinition(this.nodeTypeDefinition);
propDefn2.setName(this.propertyDefinition.getName());
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
this.nodeTypeDefinition.addPropertyDefinition(propDefn2);
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinitionTest.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -33,9 +33,9 @@
@Before
public void beforeEach() {
- this.childNodeDefinition = new ChildNodeDefinition();
this.nodeTypeDefinition = new NodeTypeDefinition();
- this.propertyDefinition = new PropertyDefinition();
+ this.childNodeDefinition = new ChildNodeDefinition(this.nodeTypeDefinition);
+ this.propertyDefinition = new PropertyDefinition(this.nodeTypeDefinition);
}
@Test
@@ -79,12 +79,12 @@
assertEquals(this.nodeTypeDefinition, thatNodeTypeDefinition);
assertEquals(this.nodeTypeDefinition.hashCode(),
thatNodeTypeDefinition.hashCode());
- this.nodeTypeDefinition.addChildNodeDefinition(new ChildNodeDefinition());
+ this.nodeTypeDefinition.addChildNodeDefinition(new
ChildNodeDefinition(this.nodeTypeDefinition));
thatNodeTypeDefinition = NodeTypeDefinition.copy(this.nodeTypeDefinition);
assertEquals(this.nodeTypeDefinition, thatNodeTypeDefinition);
assertEquals(this.nodeTypeDefinition.hashCode(),
thatNodeTypeDefinition.hashCode());
- this.nodeTypeDefinition.addPropertyDefinition(new PropertyDefinition());
+ this.nodeTypeDefinition.addPropertyDefinition(new
PropertyDefinition(this.nodeTypeDefinition));
thatNodeTypeDefinition = NodeTypeDefinition.copy(this.nodeTypeDefinition);
assertEquals(this.nodeTypeDefinition, thatNodeTypeDefinition);
assertEquals(this.nodeTypeDefinition.hashCode(),
thatNodeTypeDefinition.hashCode());
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-04-03
20:08:42 UTC (rev 40015)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-04-03
20:50:15 UTC (rev 40016)
@@ -16,8 +16,10 @@
import java.util.Collections;
import org.jboss.tools.modeshape.jcr.Listener;
+import org.jboss.tools.modeshape.jcr.NodeTypeDefinition;
import org.jboss.tools.modeshape.jcr.PropertyDefinition;
import org.jboss.tools.modeshape.jcr.PropertyDefinition.PropertyName;
+import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.attributes.OnParentVersion;
@@ -32,83 +34,88 @@
*/
public class PropertyDefinitionTest {
+ private static final QualifiedName OWNER_NAME = Constants.QUALIFIED_NAME1;
+
+ private NodeTypeDefinition owner;
private PropertyDefinition propDefn;
@Before
public void beforeEach() {
- this.propDefn = new PropertyDefinition();
+ this.owner = new NodeTypeDefinition();
+ this.owner.setName(OWNER_NAME.get());
+ this.propDefn = new PropertyDefinition(this.owner);
}
@Test
public void copiesShouldBeEqualAndHaveSameHashCode() {
- PropertyDefinition thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ PropertyDefinition thatPropDefn = PropertyDefinition.copy(this.propDefn,
this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setAvailableQueryOperators(Constants.Helper.getDefaultQueryOperators());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setAutoCreated(!this.propDefn.isAutoCreated());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setDefaultValues(Constants.Helper.getDefaultStringValues());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setFullTextSearchable(!this.propDefn.isFullTextSearchable());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setMandatory(!this.propDefn.isMandatory());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setMultiple(!this.propDefn.isMultiple());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setName(Constants.QUALIFIED_NAME1.get());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setOnParentVersion(OnParentVersion.COMPUTE.asJcrValue());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setProtected(!this.propDefn.isProtected());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setQueryOrderable(!this.propDefn.isQueryOrderable());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setRequiredType(PropertyType.BINARY.asJcrValue());
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
this.propDefn.setValueConstraints(Constants.DEFAULT_VALUE_CONSTRAINTS);
- thatPropDefn = PropertyDefinition.copy(this.propDefn);
+ thatPropDefn = PropertyDefinition.copy(this.propDefn, this.owner);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
}
@Test
public void differentInstancesWithSameValuesShouldBeEqual() {
- final PropertyDefinition thatPropDefn = new PropertyDefinition();
+ final PropertyDefinition thatPropDefn = new PropertyDefinition(this.owner);
assertEquals(this.propDefn, thatPropDefn);
this.propDefn.setAvailableQueryOperators(Constants.Helper.getDefaultQueryOperators());
@@ -162,7 +169,7 @@
@Test
public void differentInstancesWithSameValuesShouldHaveSameHashCode() {
- assertEquals(this.propDefn.hashCode(), new PropertyDefinition().hashCode());
+ assertEquals(this.propDefn.hashCode(), new
PropertyDefinition(this.owner).hashCode());
}
@Test