Author: elvisisking
Date: 2012-03-30 14:35:02 -0400 (Fri, 30 Mar 2012)
New Revision: 39948
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageLabelProvider.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageSummaryDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageViewerSorter.java
Removed:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/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/PropertyDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties
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/attributes/PropertyAttributesTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperatorsTest.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Work on query operators
and a validation message dialog that is displayed when the editor header error message
hyperlink is activated.
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-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -63,11 +63,8 @@
copy.attributes.getProtected().set(propertyBeingCopied.attributes.getProtected().get());
copy.attributes.setOnParentVersion(propertyBeingCopied.attributes.getOnParentVersion());
copy.attributes.getQueryOps().set(propertyBeingCopied.attributes.getQueryOps().get());
+
copy.setAvailableQueryOperators(propertyBeingCopied.getAvailableQueryOperators());
- for (final QueryOperator operator :
propertyBeingCopied.attributes.getQueryOps().getSupportedItems()) {
- copy.attributes.getQueryOps().add(operator);
- }
-
// default values
copy.defaultValues.set(propertyBeingCopied.defaultValues.get());
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -18,7 +18,7 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
/**
- * The primary item attribute used by property definitions.
+ * The query operators attribute used by property definitions. Initially a property
supports all operators.
*/
public final class QueryOperators extends ListAttributeState<QueryOperator> {
@@ -28,6 +28,15 @@
public static final String[] NOTATION = new String[] { "queryops",
"qop", "qop" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
+ * Constructs a query operators attribute that supports all operators.
+ */
+ public QueryOperators() {
+ for (final QueryOperator operator : QueryOperator.values()) {
+ add(operator);
+ }
+ }
+
+ /**
* @param operator the operator notation (cannot be <code>null</code> or
empty)
* @return <code>true</code> if added
* @throws IllegalArgumentException if an invalid operator notation
@@ -72,7 +81,27 @@
return super.hashCode();
}
+
+ /**
+ * @param operator the operator notation of the operator being removed (cannot be
<code>null</code> or empty)
+ * @return <code>true</code> if removed
+ * @throws IllegalArgumentException if an invalid operator notation
+ */
+ public boolean remove( final String operator ) {
+ Utils.verifyIsNotEmpty(operator, "operator"); //$NON-NLS-1$
+ return remove(QueryOperator.find(operator));
+ }
+ private boolean supportsAll() {
+ for (QueryOperator operator : QueryOperator.values()) {
+ if (!supports(operator)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/**
* @return a list of supported operator notations (never
<code>null</code> but can be empty)
*/
@@ -94,6 +123,20 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
+ */
+ @Override
+ public String toCndNotation( NotationType notationType ) {
+ if (supportsAll()) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return super.toCndNotation(notationType);
+ }
+
+ /**
* The valid query operators.
*/
public enum QueryOperator implements CndElement {
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Abstract.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The abstract attribute used by node type definitions.
- */
-public class Abstract extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "abstract",
"abs", "a" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/AttributeState.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,191 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * An attribute will have either a supported, unsupported, or variant state.
- */
-public abstract class AttributeState implements CndElement {
-
- /**
- * The character used in CND notation to indicate the attribute is a variant.
- */
- public static final char VARIANT_CHAR = '?';
-
- /**
- * The CND variant character as a string.
- *
- * @see #VARIANT_CHAR
- */
- public static final String VARIANT_STRING = Character.toString(VARIANT_CHAR);
-
- private Value state;
-
- /**
- * Constructs a not supported attribute state.
- *
- * @see Value#IS_NOT
- */
- public AttributeState() {
- this.state = Value.IS_NOT;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( final Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- final AttributeState that = (AttributeState)obj;
- return (this.state == that.state);
- }
-
- /**
- * @return the attribute state (never <code>null</code>)
- */
- public Value get() {
- return this.state;
- }
-
- /**
- * @return the attribute's compact CND notation (can be
<code>null</code> or empty)
- */
- protected abstract String getCompactCndNotation();
-
- /**
- * @return the attribute's compressed CND notation (can be
<code>null</code> or empty)
- */
- protected abstract String getCompressedCndNotation();
-
- /**
- * @return the attribute's long CND notation (can be
<code>null</code> or empty)
- */
- protected abstract String getLongCndNotation();
-
- /**
- * @return <code>true</code> if the CND notation is not empty
- */
- protected boolean hasCndNotation() {
- return !isNot();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return this.state.hashCode();
- }
-
- /**
- * @return <code>true</code> if attribute state is {@link Value#IS}.
- */
- public boolean is() {
- return (this.state == Value.IS);
- }
-
- /**
- * @return <code>true</code> if attribute state is {@link Value#IS_NOT}.
- */
- public boolean isNot() {
- return (this.state == Value.IS_NOT);
- }
-
- /**
- * @return <code>true</code> if attribute state is {@link
Value#VARIANT}.
- */
- public boolean isVariant() {
- return (this.state == Value.VARIANT);
- }
-
- /**
- * @param newState the proposed new state (cannot be <code>null</code>)
- * @return <code>true</code> if state was changed
- */
- public boolean set( final Value newState ) {
- Utils.verifyIsNotNull(newState, "newState"); //$NON-NLS-1$
-
- if (this.state != newState) {
- this.state = newState;
- return true;
- }
-
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- if (hasCndNotation()) {
- String notation = Utils.EMPTY_STRING;
-
- if (NotationType.LONG == notationType) {
- notation = getLongCndNotation();
- } else if (NotationType.COMPRESSED == notationType) {
- notation = getCompressedCndNotation();
- } else if (NotationType.COMPACT == notationType) {
- notation = getCompactCndNotation();
- }
-
- if (isVariant()) {
- return toVariantCndNotation(notation);
- }
-
- return notation;
- }
-
- return Utils.EMPTY_STRING;
- }
-
- /**
- * @param cndNotation the CND notation without the variant indicator (can be
<code>null</code> or empty)
- * @return the variant CND notation (never <code>null</code> or empty)
- */
- protected String toVariantCndNotation( final String cndNotation ) {
- if (Utils.isEmpty(cndNotation)) {
- return String.valueOf(AttributeState.VARIANT_CHAR);
- }
-
- return cndNotation + AttributeState.VARIANT_CHAR;
- }
-
- /**
- * The attribute state possible values.
- */
- public enum Value {
-
- /**
- * Indicates the attribute is supported.
- */
- IS,
-
- /**
- * Indicates the attribute is not supported.
- */
- IS_NOT,
-
- /**
- * Indicates the attribute is a variant.
- */
- VARIANT
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Autocreated.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,53 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The autocreated attribute used by property definitions and child node definitions.
When set, the property is automatically
- * created when the parent node is created. It mandates that a default value is set.
- */
-public class Autocreated extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "autocreated",
"aut", "a" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultType.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,162 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.QualifiedName;
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-
-/**
- * The child node definition's default type property.
- */
-public class DefaultType extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String NOTATION = "="; //$NON-NLS-1$
-
- private final QualifiedName defaultType = new QualifiedName();
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#get()
- */
- @Override
- public Value get() {
- final Value state = super.get();
-
- if (state == Value.VARIANT) {
- return Value.VARIANT;
- }
-
- if (Utils.isEmpty(this.defaultType.get())) {
- return Value.IS_NOT;
- }
-
- return Value.IS;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return getLongCndNotation();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return getLongCndNotation();
- }
-
- /**
- * @return the default type's qualified name (never
<code>null</code>)
- */
- public QualifiedName getDefaultType() {
- return this.defaultType;
- }
-
- /**
- * @return the default type name (can be <code>null</code> or empty)
- */
- public String getDefaultTypeName() {
- String defaultTypeName = this.defaultType.get();
-
- // per API return null if it doesn't exist
- if (Utils.isEmpty(defaultTypeName)) {
- return null;
- }
-
- return defaultTypeName;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- if (isVariant()) {
- return getPrefix();
- }
-
- String defaultType = getDefaultTypeName();
-
- if (Utils.isEmpty(defaultType)) {
- return Utils.EMPTY_STRING;
- }
-
- return getPrefix() + defaultType;
- }
-
- private String getPrefix() {
- String delim =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER);
-
- if (Utils.isEmpty(delim)) {
- return NOTATION;
- }
-
- return (NOTATION + delim);
- }
-
- /**
- * {@inheritDoc} <strong>Can only be used to change to a variant state. Use
{@link DefaultType#setDefaultType(String)} to set to
- * other states</strong>
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
- */
- @Override
- public boolean set( final Value newState ) {
- if (newState == Value.VARIANT) {
- if (super.set(Value.VARIANT)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @param newDefaultType the proposed new value for the default type (can be
<code>null</code> or empty)
- * @return <code>true</code> if changed
- */
- public boolean setDefaultType( final String newDefaultType ) {
- if (this.defaultType.set(newDefaultType)) {
- if (Utils.isEmpty(newDefaultType) && !isVariant()) {
- super.set(Value.IS_NOT);
- } else {
- super.set(Value.IS);
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toVariantCndNotation(java.lang.String)
- */
- @Override
- protected String toVariantCndNotation( final String cndNotation ) {
- return cndNotation + AttributeState.VARIANT_CHAR;
- }
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValues.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,65 +0,0 @@
-/*
- * 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.attributes;
-
-import java.util.Collection;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-
-/**
- *
- */
-public final class DefaultValues extends ListAttributeState<String> {
-
- /**
- * The CND list prefix.
- */
- public static final String NOTATION_PREFIX = "="; //$NON-NLS-1$
-
- /**
- * @return the JCR value for each default value (never
<code>null</code>)
- */
- public javax.jcr.Value[] asJcrValues() {
- final Collection<String> defaultValues = getSupportedItems();
-
- if (Utils.isEmpty(defaultValues)) {
- return new javax.jcr.Value[0];
- }
-
- final javax.jcr.Value[] jcrValues = new javax.jcr.Value[defaultValues.size()];
- int i = 0;
-
- for (final String defaultValue : defaultValues) {
- jcrValues[i++] = new PropertyValue(PropertyType.STRING.asJcrValue(),
defaultValue);
- }
-
- return jcrValues;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- protected String getCndNotationPrefix( final NotationType notationType ) {
- return NOTATION_PREFIX;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getQuoteCharacter()
- */
- @Override
- protected String getQuoteCharacter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ListAttributeState.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,338 +0,0 @@
-/*
- * 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.attributes;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-
-/**
- * @param <E> the class of the list items
- */
-public abstract class ListAttributeState<E extends Comparable> extends
AttributeState {
-
- /**
- * A list of supported items (can be <code>null</code>).
- */
- private List<E> supported;
-
- /**
- * @param item the item being added (cannot be <code>null</code>)
- * @return <code>true</code> if successfully added
- */
- public boolean add( final E item ) {
- Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
-
- if (this.supported == null) {
- this.supported = new ArrayList<E>();
- }
-
- boolean added = false;
-
- if (!this.supported.contains(item)) {
- added = this.supported.add(item);
- }
-
- if (added && !is()) {
- super.set(Value.IS);
- }
-
- return added;
- }
-
- /**
- * @return <code>true</code> if at least one item was cleared
- */
- public boolean clear() {
- boolean cleared = false;
-
- if (this.supported != null) {
- cleared = !this.supported.isEmpty();
- this.supported = null;
- }
-
- if (!isNot()) {
- super.set(Value.IS_NOT);
- }
-
- return cleared;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( final Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- final ListAttributeState that = (ListAttributeState)obj;
- final List<E> thatSupportedItems = that.getSupportedItems();
- final List<E> thisSupportedItems = getSupportedItems();
-
- if (Utils.isEmpty(thisSupportedItems)) {
- return Utils.isEmpty(thatSupportedItems);
- }
-
- if (Utils.isEmpty(thatSupportedItems)) {
- return false;
- }
-
- if (thisSupportedItems.size() != thatSupportedItems.size()) {
- return false;
- }
-
- return thisSupportedItems.containsAll(thatSupportedItems);
- }
-
- /**
- * @param item the item being checked to see if it is already supported (cannot be
<code>null</code>)
- * @return <code>true</code> if already exists
- */
- public boolean exists( E item ) {
- Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
- return getSupportedItems().contains(item);
- }
-
- /**
- * @param notationType the notation type whose CND notation prefix is being requested
(cannot be <code>null</code>)
- * @return the CND notation prefix (can be <code>null</code> or empty)
- */
- protected abstract String getCndNotationPrefix( NotationType notationType );
-
- /**
- * @param notationType the notation type whose CND notation suffix is being requested
(cannot be <code>null</code>)
- * @return the CND notation suffix (can be <code>null</code> or empty)
- */
- protected String getCndNotationSuffix( final NotationType notationType ) {
- return Utils.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return the quote character (empty, single, or double) surrounding each item of
the list (cannot be <code>null</code>)
- */
- protected String getItemQuoteCharacter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- }
-
- /**
- * @return the delimiter used after the list prefix (never
<code>null</code> but can be empty)
- */
- protected String getListPrefixEndDelimiter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return the quote character (empty, single, double) surrounding the elements of
the list (cannot be <code>null</code>)
- */
- protected String getQuoteCharacter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
- }
-
- /**
- * @return the collection of supported items (never <code>null</code>)
- */
- public List<E> getSupportedItems() {
- if (this.supported == null) {
- return Collections.emptyList();
- }
-
- return Collections.unmodifiableList(this.supported);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#hasCndNotation()
- */
- @Override
- protected boolean hasCndNotation() {
- return !isNot();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return Utils.hashCode(getSupportedItems());
- }
-
- /**
- * @param item the item being removed (cannot be <code>null</code>)
- * @return <code>true</code> if successfully removed
- */
- public boolean remove( final E item ) {
- Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
-
- if (this.supported == null) {
- return false;
- }
-
- final boolean removed = this.supported.remove(item);
-
- if (this.supported.isEmpty()) {
- this.supported = null;
-
- if (is()) {
- super.set(Value.IS_NOT);
- }
- }
-
- return removed;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
- */
- @Override
- public final boolean set( final Value newState ) {
- if (Value.VARIANT == newState) {
- clear();
- return super.set(Value.VARIANT);
- }
-
- return false; // other states set by adding and removing supported items
- }
-
- /**
- * @param notationType the CND notation type to use (cannot be
<code>null</code>)
- * @return the CND notation (never <code>null</code> but can be empty)
- */
- protected String supportedItemsCndNotation( final NotationType notationType ) {
- final List<E> items = new ArrayList<E>(getSupportedItems());
- Collections.sort(items);
-
- if (items.isEmpty()) {
- return Utils.EMPTY_STRING;
- }
-
- final String itemQuote = getItemQuoteCharacter();
- final boolean useQuote = !Utils.isEmpty(itemQuote);
- final StringBuilder builder = new StringBuilder();
-
- for (final Iterator<E> itr = items.iterator(); itr.hasNext();) {
- final E item = itr.next();
-
- if (useQuote) {
- builder.append(itemQuote);
- }
-
- if (item instanceof CndElement) {
- builder.append(((CndElement)item).toCndNotation(notationType));
- } else {
- builder.append(item.toString());
- }
-
- if (useQuote) {
- builder.append(itemQuote);
- }
-
- if (itr.hasNext()) {
-
builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER));
- }
- }
-
- return builder.toString();
- }
-
- /**
- * @param item the item being checked (cannot be <code>null</code>)
- * @return <code>true</code> if item is contained in list
- */
- public boolean supports( final E item ) {
- Utils.verifyIsNotNull(item, "item"); //$NON-NLS-1$
- return getSupportedItems().contains(item);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- if (hasCndNotation()) {
- final StringBuilder builder = new StringBuilder();
-
- if (!Utils.isEmpty(getCndNotationPrefix(notationType))) {
- builder.append(getCndNotationPrefix(notationType));
- }
-
- final String delim = getListPrefixEndDelimiter();
-
- if (!Utils.isEmpty(delim)) {
- builder.append(delim);
- }
-
- if (isVariant()) {
- builder.append(AttributeState.VARIANT_CHAR);
- } else {
- // add the delimited list
- builder.append(getQuoteCharacter());
- builder.append(supportedItemsCndNotation(notationType));
- builder.append(getQuoteCharacter());
- }
-
- if (!Utils.isEmpty(getCndNotationSuffix(notationType))) {
- builder.append(getCndNotationSuffix(notationType));
- }
-
- return builder.toString();
- }
-
- return Utils.EMPTY_STRING;
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mandatory.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,53 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The mandatory attribute used by property definitions and child node definitions. When
set, the property is mandatory, meaning it
- * must be present in order to save the node.
- */
-public class Mandatory extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "mandatory",
"man", "m" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Mixin.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The mixin attribute used by node type definitions.
- */
-public class Mixin extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "mixin",
"mix", "m" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Multiple.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The multiple attribute used by property definitions. When set, the property is
multi-valued, accepting a list of values.
- */
-public class Multiple extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "multiple",
"mul", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoFullText.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The no full text search attribute used by the property definitions.
- */
-public class NoFullText extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "nofulltext",
"nof", "nof" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NoQueryOrder.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The no query order attribute used by property definitions.
- */
-public class NoQueryOrder extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "noqueryorder",
"nqord", "nqord" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeAttributes.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,189 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-import org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value;
-
-/**
- * The child node definition attribute collection.
- */
-public class NodeAttributes implements CndElement {
-
- private final Autocreated autocreated;
-
- private final Mandatory mandatory;
-
- private final Protected notDeletable;
-
- private OnParentVersion opv;
-
- private final SameNameSiblings sns;
-
- /**
- * Constructs node attributes all set to default values.
- */
- public NodeAttributes() {
- this.autocreated = new Autocreated();
- this.mandatory = new Mandatory();
- this.notDeletable = new Protected();
- this.opv = OnParentVersion.DEFAULT_VALUE;
- this.sns = new SameNameSiblings();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( final Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- final NodeAttributes that = (NodeAttributes)obj;
-
- return (this.autocreated.equals(that.autocreated) &&
this.mandatory.equals(that.mandatory)
- && this.notDeletable.equals(that.notDeletable) &&
(this.opv == that.opv) && this.sns.equals(that.sns));
- }
-
- /**
- * @return the autocreated attribute (never <code>null</code>)
- */
- public Autocreated getAutocreated() {
- return this.autocreated;
- }
-
- private String getFormatDelimiter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER);
- }
-
- /**
- * @return the mandatory attribute (never <code>null</code>)
- */
- public Mandatory getMandatory() {
- return this.mandatory;
- }
-
- /**
- * @return the on parent version attribute (never <code>null</code>)
- */
- public OnParentVersion getOnParentVersion() {
- return this.opv;
- }
-
- /**
- * @return the protected attribute (never <code>null</code>)
- */
- public Protected getProtected() {
- return this.notDeletable;
- }
-
- /**
- * @return the same named siblings attribute (never <code>null</code>)
- */
- public SameNameSiblings getSameNameSiblings() {
- return this.sns;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return Utils.hashCode(this.autocreated, this.mandatory, this.notDeletable,
this.opv, this.sns);
- }
-
- /**
- * @param newState the new value to set the autocreated attribute state to (cannot be
<code>null</code>)
- * @return <code>true</code> if the state changed
- */
- public boolean setAutocreated( final Value newState ) {
- return this.autocreated.set(newState);
- }
-
- /**
- * @param newState the new value to set the mandatory attribute state to (cannot be
<code>null</code>)
- * @return <code>true</code> if state changed
- */
- public boolean setMandatory( final Value newState ) {
- return this.mandatory.set(newState);
- }
-
- /**
- * @param newOpv the new value to set the on parent version attribute to (cannot be
<code>null</code>)
- * @return <code>true</code> if changed
- */
- public boolean setOnParentVersion( final OnParentVersion newOpv ) {
- Utils.verifyIsNotNull(newOpv, "newOpv"); //$NON-NLS-1$
-
- if (this.opv != newOpv) {
- this.opv = newOpv;
- return true;
- }
-
- return false;
- }
-
- /**
- * @param newState the new value to set the protected attribute state to (cannot be
<code>null</code>)
- * @return <code>true</code> if state changed
- */
- public boolean setProtected( final Value newState ) {
- return this.notDeletable.set(newState);
- }
-
- /**
- * @param newState the new value to set the same named siblings attribute state to
(cannot be <code>null</code>)
- * @return <code>true</code> if state changed
- */
- public boolean setSameNameSibling( final Value newState ) {
- return this.sns.set(newState);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- final String DELIM = getFormatDelimiter();
- final StringBuilder builder = new StringBuilder();
-
- boolean addDelim = Utils.build(builder, false, DELIM,
this.autocreated.toCndNotation(notationType));
-
- if (Utils.build(builder, addDelim, DELIM,
this.mandatory.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.notDeletable.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM, this.opv.toCndNotation(notationType)))
{
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM, this.sns.toCndNotation(notationType)))
{
- addDelim = true;
- }
-
- return builder.toString().trim();
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,223 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-
-/**
- * Property attributes of a node type definitions.
- */
-public class NodeTypeAttributes implements CndElement {
-
- private Mixin mixin;
-
- private Abstract notConcrete;
-
- private Orderable orderable;
-
- private PrimaryItem primaryItem;
-
- private Queryable queryable;
-
- /**
- * Constructs a node type definition's attribute collection all set to there
default values.
- */
- public NodeTypeAttributes() {
- this.orderable = new Orderable();
- this.mixin = new Mixin();
- this.notConcrete = new Abstract();
- this.primaryItem = new PrimaryItem();
- this.queryable = new Queryable();
- }
-
- /**
- * @param initialOrderable the initial orderable value (can be
<code>null</code>)
- * @param initialMixin the initial mixin value (can be
<code>null</code>)
- * @param initialAbstract the initial abstract value (can be
<code>null</code>)
- * @param initialQueryable the initial queryable value (can be
<code>null</code>)
- * @param initialPrimaryItem the initial primary item value (can be
<code>null</code>)
- */
- public NodeTypeAttributes( final Orderable initialOrderable,
- final Mixin initialMixin,
- final Abstract initialAbstract,
- final Queryable initialQueryable,
- final PrimaryItem initialPrimaryItem ) {
- this();
-
- if (!this.orderable.equals(initialOrderable)) {
- this.orderable = initialOrderable;
- }
-
- if (!this.mixin.equals(initialMixin)) {
- this.mixin = initialMixin;
- }
-
- if (!this.notConcrete.equals(initialOrderable)) {
- this.notConcrete = initialAbstract;
- }
-
- if (!this.queryable.equals(initialQueryable)) {
- this.queryable = initialQueryable;
- }
-
- if (!this.primaryItem.equals(initialPrimaryItem)) {
- this.primaryItem = initialPrimaryItem;
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( final Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- final NodeTypeAttributes that = (NodeTypeAttributes)obj;
-
- return (this.mixin.equals(that.mixin) &&
this.notConcrete.equals(that.notConcrete) &&
this.orderable.equals(that.orderable)
- && this.queryable.equals(that.queryable) &&
this.primaryItem.equals(that.primaryItem));
- }
-
- /**
- * @return the abstract attribute (never <code>null</code>)
- */
- public Abstract getAbstract() {
- return this.notConcrete;
- }
-
- /**
- * @return the mixin attribute (never <code>null</code>)
- */
- public Mixin getMixin() {
- return this.mixin;
- }
-
- /**
- * @return the orderable attribute (never <code>null</code>)
- */
- public Orderable getOrderable() {
- return this.orderable;
- }
-
- /**
- * @return the primary item attribute (never <code>null</code>)
- */
- public PrimaryItem getPrimaryItem() {
- return this.primaryItem;
- }
-
- /**
- * @return the queryable attribute (never <code>null</code>)
- */
- public Queryable getQueryable() {
- return this.queryable;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return Utils.hashCode(this.mixin, this.notConcrete, this.orderable,
this.queryable, this.primaryItem);
- }
-
- /**
- * @param newState the proposed new state of the abstract attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setAbstract( final AttributeState.Value newState ) {
- return this.notConcrete.set(newState);
- }
-
- /**
- * @param newState the proposed new state of the mixin attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setMixin( final AttributeState.Value newState ) {
- return this.mixin.set(newState);
- }
-
- /**
- * @param newState the proposed new state of the orderable attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setOrderable( final AttributeState.Value newState ) {
- return this.orderable.set(newState);
- }
-
- /**
- * <strong>Can only be used to set to variant state.</strong>
- *
- * @param newState the proposed new state of the primary item attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setPrimaryItem( final AttributeState.Value newState ) {
- return this.primaryItem.set(newState);
- }
-
- /**
- * @param newPrimaryItem the proposed new value for the primary item (can be
<code>null</code> or empty)
- * @return <code>true</code> if primary item was changed
- */
- public boolean setPrimaryItem( final String newPrimaryItem ) {
- return this.primaryItem.setPrimaryItem(newPrimaryItem);
- }
-
- /**
- * @param newState the proposed new state of the queryable attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setQueryable( final AttributeState.Value newState ) {
- return this.queryable.set(newState);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- final String DELIM =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
- final StringBuilder builder = new StringBuilder();
-
- boolean addDelim = Utils.build(builder, false, DELIM,
this.orderable.toCndNotation(notationType));
-
- if (Utils.build(builder, addDelim, DELIM,
this.mixin.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.notConcrete.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.queryable.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.primaryItem.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- return builder.toString().trim();
- }
-
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/OnParentVersion.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,151 +0,0 @@
-/*
- * 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.attributes;
-
-import javax.jcr.version.OnParentVersionAction;
-
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.modeshape.jcr.Messages;
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The primary item attribute used by child node definitions and property definitions.
- */
-public enum OnParentVersion implements CndElement {
-
- /**
- * Upon check-in, a VersionException will be thrown as the creation of a version is
prohibited.
- */
- ABORT(OnParentVersionAction.ABORT),
-
- /**
- * Upon check-in, the new version will contain this property. However, when the node
is restored from a previous node, the value
- * of this property is NOT being restored.
- */
- COMPUTE(OnParentVersionAction.COMPUTE),
-
- /**
- * Upon check-in, the value of the property will be copied to the new version.
- */
- COPY(OnParentVersionAction.COPY),
-
- /**
- * Upon check-in, the version entry will not contain this property, i.e. it is not
versioned.
- */
- IGNORE(OnParentVersionAction.IGNORE),
-
- /**
- * Upon check-in, a new property with the same name will be created and
re-initialized with any default values specified or as
- * empty. Essentially, the property is re-set when a new version of the node is
created.
- */
- INITIALIZE(OnParentVersionAction.INITIALIZE),
-
- /**
- * Indicates that OPV is a variant. Cannot be used with {@link #find(String)}.
- */
- VARIANT(-1),
-
- /**
- * Upon check-in, the value of the property will be copied to the new version.
- */
- VERSION(OnParentVersionAction.VERSION);
-
- /**
- * The default value. Value is {@value} .
- */
- public static OnParentVersion DEFAULT_VALUE = COPY;
-
- /**
- * @param notation the CND representation of the OPV (cannot be
<code>null</code> or empty)
- * @return the OPV (never <code>null</code>)
- * @throws IllegalArgumentException if the <code>jcrValue</code> is not
valid
- */
- public static OnParentVersion find( final String notation ) {
- for (final OnParentVersion opv : OnParentVersion.values()) {
- if (opv.toCndNotation(NotationType.LONG).equalsIgnoreCase(notation)
- ||
opv.toCndNotation(NotationType.COMPRESSED).equalsIgnoreCase(notation)
- ||
opv.toCndNotation(NotationType.COMPACT).equalsIgnoreCase(notation)) {
- return opv;
- }
- }
-
- throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest,
notation));
- }
-
- /**
- * @param jcrValue the integer representation
- * @return the OPV (never <code>null</code>)
- * @throws IllegalArgumentException if the <code>jcrValue</code> is not
valid
- */
- public static OnParentVersion findUsingJcrValue( final int jcrValue ) {
- for (final OnParentVersion opv : OnParentVersion.values()) {
- if (opv.asJcrValue() == jcrValue) {
- return opv;
- }
- }
-
- throw new
IllegalArgumentException(NLS.bind(Messages.invalidFindUsingJcrValueRequest, jcrValue));
- }
-
- /**
- * @return a collection of all valid CND notation values (never
<code>null</code> or empty)
- */
- public static String[] toArray() {
- final OnParentVersion[] allOpv = OnParentVersion.values();
- final String[] notations = new String[allOpv.length];
- int i = 0;
-
- for (final OnParentVersion opv : allOpv) {
- notations[i++] = opv.toCndNotation(NotationType.LONG);
- }
-
- return notations;
- }
-
- private final int jcrValue;
-
- private OnParentVersion( final int jcrValue ) {
- this.jcrValue = jcrValue;
- }
-
- /**
- * @return the JCR integer representation
- */
- public int asJcrValue() {
- return this.jcrValue;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- if ((this == DEFAULT_VALUE) && (NotationType.LONG != notationType)) {
- return Utils.EMPTY_STRING;
- }
-
- if (this == VARIANT) {
- return "OPV?"; //$NON-NLS-1$
- }
-
- return super.toString();
- }
- //
- // /**
- // * {@inheritDoc}
- // *
- // * @see java.lang.Enum#toString()
- // */
- // @Override
- // public String toString() {
- // return OnParentVersionAction.nameFromValue(asJcrValue());
- // }
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Orderable.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The orderable attribute used by node type definitions.
- */
-public class Orderable extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "orderable",
"ord", "o" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,171 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.QualifiedName;
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The primary item attribute used by node type definitions. This primary item may be a
child node or a property.
- */
-public class PrimaryItem extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "primaryitem",
"!", "!" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- private final QualifiedName primaryItem = new QualifiedName();
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#equals(java.lang.Object)
- */
- @Override
- public boolean equals( Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- PrimaryItem that = (PrimaryItem)obj;
- return (super.equals(obj) &&
getPrimaryItem().equals(that.getPrimaryItem()));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#get()
- */
- @Override
- public Value get() {
- final Value state = super.get();
-
- if (state == Value.VARIANT) {
- return Value.VARIANT;
- }
-
- if (Utils.isEmpty(this.primaryItem.get())) {
- return Value.IS_NOT;
- }
-
- return Value.IS;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
- /**
- * @return the primary item (never <code>null</code>)
- */
- public QualifiedName getPrimaryItem() {
- return this.primaryItem;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#hashCode()
- */
- @Override
- public int hashCode() {
- return Utils.hashCode(super.hashCode(), this.primaryItem);
- }
-
- /**
- * {@inheritDoc} Only can be used to set to variant state.
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
- */
- @Override
- public boolean set( final Value newState ) {
- if (newState == Value.VARIANT) {
- if (super.set(Value.VARIANT)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @param newPrimaryItem the proposed new primary item (can be
<code>null</code> or empty)
- * @return <code>true</code> if the primary item was changed
- */
- public boolean setPrimaryItem( final String newPrimaryItem ) {
- if (this.primaryItem.set(newPrimaryItem)) {
- if (Utils.isEmpty(this.primaryItem.get()) && !isVariant()) {
- super.set(Value.IS_NOT);
- } else {
- super.set(Value.IS);
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- String notation = super.toCndNotation(notationType);
-
- if (!isVariant() && is()) {
- notation += ' ' + this.primaryItem.toCndNotation(notationType);
- }
-
- return notation;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#toVariantCndNotation(java.lang.String)
- */
- @Override
- protected String toVariantCndNotation( final String cndNotation ) {
- return cndNotation + ' ' + AttributeState.VARIANT_CHAR;
- }
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributes.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,300 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-
-/**
- * Property attributes of a property definitions.
- */
-public class PropertyAttributes implements CndElement {
-
- private Autocreated autocreated;
-
- private Mandatory mandatory;
-
- private Multiple multiple;
-
- private NoFullText noFullText;
-
- private NoQueryOrder noQueryOrder;
-
- private Protected notDeletable; // protected
-
- private OnParentVersion opv;
-
- private QueryOperators queryOps;
-
- /**
- * Constructs a property definition's attribute collecdtion all set to there
default values.
- */
- public PropertyAttributes() {
- this.autocreated = new Autocreated();
- this.mandatory = new Mandatory();
- this.multiple = new Multiple();
- this.notDeletable = new Protected();
- this.opv = OnParentVersion.DEFAULT_VALUE;
- this.noFullText = new NoFullText();
- this.noQueryOrder = new NoQueryOrder();
- this.queryOps = new QueryOperators();
- }
-
- /**
- * @param initialAutocreated the initial autocreated value (can be
<code>null</code>)
- * @param initialMandatory the initial mandatory value (can be
<code>null</code>)
- * @param initialMultiple the initial multiple values value (can be
<code>null</code>)
- * @param initialProtected the initial protected value (can be
<code>null</code>)
- * @param initialOpv the initial on-parent-value value (can be
<code>null</code>)
- * @param initialNoFullText the initial no full text search support value (can be
<code>null</code>)
- * @param initialNoQueryOrder the initial no query order support value (can be
<code>null</code>)
- * @param initialQueryOps the initial query operator support value (can be
<code>null</code>)
- */
- public PropertyAttributes( Autocreated initialAutocreated,
- Mandatory initialMandatory,
- Multiple initialMultiple,
- Protected initialProtected,
- OnParentVersion initialOpv,
- NoFullText initialNoFullText,
- NoQueryOrder initialNoQueryOrder,
- QueryOperators initialQueryOps ) {
- this();
-
- if (!this.autocreated.equals(initialAutocreated)) {
- this.autocreated = initialAutocreated;
- }
-
- if (!this.mandatory.equals(initialMandatory)) {
- this.mandatory = initialMandatory;
- }
-
- if (!this.multiple.equals(initialMultiple)) {
- this.multiple = initialMultiple;
- }
-
- if (!this.notDeletable.equals(initialProtected)) {
- this.notDeletable = initialProtected;
- }
-
- if (initialOpv != this.opv) {
- this.opv = initialOpv;
- }
-
- if (!this.noFullText.equals(initialNoFullText)) {
- this.noFullText = initialNoFullText;
- }
-
- if (!this.noQueryOrder.equals(initialNoQueryOrder)) {
- this.noQueryOrder = initialNoQueryOrder;
- }
-
- if (!this.queryOps.equals(initialQueryOps)) {
- this.queryOps = initialQueryOps;
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- PropertyAttributes that = (PropertyAttributes)obj;
-
- return (this.autocreated.equals(that.autocreated) &&
this.mandatory.equals(that.mandatory)
- && this.multiple.equals(that.multiple) &&
this.noFullText.equals(that.noFullText)
- && this.noQueryOrder.equals(that.noQueryOrder) &&
this.notDeletable.equals(that.notDeletable)
- && (this.opv == that.opv) &&
this.queryOps.equals(that.queryOps));
- }
-
- /**
- * @return the autocreated attribute (never <code>null</code>)
- */
- public Autocreated getAutocreated() {
- return this.autocreated;
- }
-
- private String getFormatDelimiter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
- }
-
- /**
- * @return the mandatory attribute (never <code>null</code>)
- */
- public Mandatory getMandatory() {
- return this.mandatory;
- }
-
- /**
- * @return the multiple attribute (never <code>null</code>)
- */
- public Multiple getMultiple() {
- return this.multiple;
- }
-
- /**
- * @return the no full text search attribute (never <code>null</code>)
- */
- public NoFullText getNoFullText() {
- return this.noFullText;
- }
-
- /**
- * @return the no query order attribute (never <code>null</code>)
- */
- public NoQueryOrder getNoQueryOrder() {
- return this.noQueryOrder;
- }
-
- /**
- * @return the on parent version attribute (never <code>null</code>)
- */
- public OnParentVersion getOnParentVersion() {
- return this.opv;
- }
-
- /**
- * @return the protected attribute (never <code>null</code>)
- */
- public Protected getProtected() {
- return this.notDeletable;
- }
-
- /**
- * @return the query operators attribute (never <code>null</code>)
- */
- public QueryOperators getQueryOps() {
- return this.queryOps;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return Utils.hashCode(0, this.autocreated, this.mandatory, this.multiple,
this.noFullText, this.noQueryOrder,
- this.notDeletable, this.opv, this.queryOps);
- }
-
- /**
- * @param newState the proposed new state of the autocreated attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setAutocreated( AttributeState.Value newState ) {
- return this.autocreated.set(newState);
- }
-
- /**
- * @param newState the proposed new state of the mandatory attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setMandatory( AttributeState.Value newState ) {
- return this.mandatory.set(newState);
- }
-
- /**
- * @param newState the proposed new state of the multiple attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setMultiple( AttributeState.Value newState ) {
- return this.multiple.set(newState);
- }
-
- /**
- * @param newState the proposed new state of the no full text search attribute
(cannot be <code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setNoFullText( AttributeState.Value newState ) {
- return this.noFullText.set(newState);
- }
-
- /**
- * @param newState the proposed new state of the no query order attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setNoQueryOrder( AttributeState.Value newState ) {
- return this.noQueryOrder.set(newState);
- }
-
- /**
- * @param newOpv the proposed new value of the on parent version attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the value was changed
- */
- public boolean setOnParentVersion( OnParentVersion newOpv ) {
- if (this.opv != newOpv) {
- this.opv = newOpv;
- return true;
- }
-
- return false;
- }
-
- /**
- * @param newState the proposed new state of the protected attribute (cannot be
<code>null</code>)
- * @return <code>true</code> if the state was changed
- */
- public boolean setProtected( AttributeState.Value newState ) {
- return this.notDeletable.set(newState);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( NotationType notationType ) {
- final String DELIM = getFormatDelimiter();
- StringBuilder builder = new StringBuilder();
-
- boolean addDelim = Utils.build(builder, false, DELIM,
this.autocreated.toCndNotation(notationType));
-
- if (Utils.build(builder, addDelim, DELIM,
this.mandatory.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.notDeletable.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.multiple.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM, this.opv.toCndNotation(notationType)))
{
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.noFullText.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.noQueryOrder.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- if (Utils.build(builder, addDelim, DELIM,
this.queryOps.toCndNotation(notationType))) {
- addDelim = true;
- }
-
- return builder.toString().trim();
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyType.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,206 +0,0 @@
-/*
- * 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.attributes;
-
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.modeshape.jcr.Messages;
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The type property of a property definition.
- */
-public enum PropertyType implements CndElement {
-
- /**
- * The property value is a UTF-8 encoded string.
- */
- BINARY(javax.jcr.PropertyType.BINARY),
-
- /**
- * The property value is any string that can be converted via {@link
Boolean#valueOf(String)}, such as �true�, �false�, �0�,
- * �1�.
- */
- BOOLEAN(javax.jcr.PropertyType.BOOLEAN),
-
- /**
- * The property value is a valid date in ISO 8601:2000-compliant format:
sYYYY-MM-DDThh:mm:ss.sssTZD.
- */
- DATE(javax.jcr.PropertyType.DATE),
-
- /**
- * The property value is a decimal number.
- */
- DECIMAL(javax.jcr.PropertyType.DECIMAL),
-
- /**
- * The property value is a double number.
- */
- DOUBLE(javax.jcr.PropertyType.DOUBLE),
-
- /**
- * The property value is a long number.
- */
- LONG(javax.jcr.PropertyType.LONG),
-
- /**
- * The property value is a valid JCR local name, fully qualified with namespace
prefix.
- */
- NAME(javax.jcr.PropertyType.NAME),
-
- /**
- * The property value is a valid JCR path whose namespace prefixes are all registered
correctly. The path does not have to point
- * to an existing node.
- */
- PATH(javax.jcr.PropertyType.PATH),
-
- /**
- * The property value is a valid JCR identifier.
- */
- REFERENCE(javax.jcr.PropertyType.REFERENCE),
-
- /**
- * The property value is a string.
- */
- STRING(javax.jcr.PropertyType.STRING),
-
- /**
- * The property value is any string. The value is automatically converted to the
appropriate type of the property when created.
- */
- UNDEFINED(javax.jcr.PropertyType.UNDEFINED),
-
- /**
- * The property value is a URI string.
- */
- URI(javax.jcr.PropertyType.URI),
-
- /**
- * The property value is a UTF-8 encoded string.
- */
- VARIANT(-1),
-
- /**
- * The property value is a JCR identifier.
- */
- WEAKREFERENCE(javax.jcr.PropertyType.WEAKREFERENCE);
-
- /**
- * The default property type. Defaults to {@value PropertyType#STRING}.
- */
- public static final PropertyType DEFAULT_VALUE = PropertyType.STRING;
-
- /**
- * The value prefixing the CND notation of the type.
- */
- public static final String NOTATION_PREFIX = "("; //$NON-NLS-1$
-
- /**
- * The value suffixing the CND notation of the type.
- */
- public static final String NOTATION_SUFFIX = ")"; //$NON-NLS-1$
-
- /**
- * The shortened value for the {@link #UNDEFINED} type.
- */
- public static final String UNDEFINED_ADDITIONAL_NOTATION = "*";
//$NON-NLS-1$
-
- /**
- * @param cndNotation the CND notation of the property type being requested (cannot
be <code>null</code> or empty)
- * @return the property type (never <code>null</code>)
- */
- public static PropertyType find( final String cndNotation ) {
- Utils.verifyIsNotEmpty(cndNotation, "cndNotation"); //$NON-NLS-1$
-
- if (UNDEFINED_ADDITIONAL_NOTATION.equals(cndNotation)) {
- return UNDEFINED;
- }
-
- for (final PropertyType type : PropertyType.values()) {
- if (PropertyType.VARIANT == type) {
- continue;
- }
-
- if (type.toString().equalsIgnoreCase(cndNotation)) {
- return type;
- }
- }
-
- throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest,
cndNotation));
- }
-
- /**
- * @param propertyType the {@link javax.jcr.PropertyType} of the type being
requested
- * @return the property type (never <code>null</code>
- * @throws IllegalArgumentException if an invalid input value
- */
- public static PropertyType findUsingJcrValue( final int propertyType ) {
- for (final PropertyType type : PropertyType.values()) {
- if (type.asJcrValue() == propertyType) {
- return type;
- }
- }
-
- throw new
IllegalArgumentException(NLS.bind(Messages.invalidFindUsingJcrValueRequest,
propertyType));
- }
-
- /**
- * @return a collection of all the valid CND notations (never
<code>null</code> or empty)
- */
- public static String[] validValues() {
- final PropertyType[] allTypes = PropertyType.values();
- // add one for additional undefined notation added later but subtract one for
variant
- final String[] result = new String[allTypes.length];
- int i = 0;
-
- for (final PropertyType type : allTypes) {
- if (type != VARIANT) {
- result[i++] = type.toString();
- }
- }
-
- result[i] = UNDEFINED_ADDITIONAL_NOTATION;
- return result;
- }
-
- private final int jcrValue;
-
- private PropertyType( final int propertyType ) {
- this.jcrValue = propertyType;
- }
-
- /**
- * If variant, will return <code>-1</code> which is not a valid {@link
javax.jcr.PropertyType}.
- *
- * @return the {@link javax.jcr.PropertyType} of the type
- */
- public int asJcrValue() {
- return this.jcrValue;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( final NotationType notationType ) {
- final StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
-
- if (this == VARIANT) {
- builder.append(AttributeState.VARIANT_CHAR);
- } else {
- if ((this == UNDEFINED) && (NotationType.LONG != notationType)) {
- builder.append(UNDEFINED_ADDITIONAL_NOTATION);
- } else {
- builder.append(toString());
- }
- }
-
- return builder.append(NOTATION_SUFFIX).toString();
- }
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyValue.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,295 +0,0 @@
-/*
- * 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.attributes;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.jcr.Binary;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.modeshape.web.jcr.rest.client.RestClientI18n;
-
-/**
- *
- */
-public class PropertyValue implements Value {
-
- private final int type;
- private String value;
-
- /**
- * @param jcrType the {@link PropertyType} used to create the value
- */
- public PropertyValue( final int jcrType ) {
- this.type = jcrType;
- }
-
- /**
- * @param jcrType the {@link PropertyType} used to create the value
- * @param initialValue the initial property value (can be
<code>null</code> or empty)
- */
- public PropertyValue( final int jcrType,
- final String initialValue ) {
- this(jcrType);
- this.value = initialValue;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals( final Object obj ) {
- if ((obj == null) || !getClass().equals(obj.getClass())) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- final PropertyValue that = (PropertyValue)obj;
- return (Utils.equals(this.type, that.type) && Utils.equals(this.value,
that.value));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getBinary()
- */
- @Override
- public Binary getBinary() {
- final byte[] bytes = this.value.getBytes();
- return new Binary() {
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Binary#dispose()
- */
- @Override
- public void dispose() {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Binary#getSize()
- */
- @Override
- public long getSize() {
- return bytes.length;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Binary#getStream()
- */
- @Override
- public InputStream getStream() {
- return new ByteArrayInputStream(bytes);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Binary#read(byte[], long)
- */
- @Override
- public int read( final byte[] b,
- final long position ) throws IOException {
- if (getSize() <= position) {
- return -1;
- }
-
- InputStream stream = null;
- IOException error = null;
-
- try {
- stream = getStream();
- // Read/skip the next 'position' bytes ...
- long skip = position;
-
- while (skip > 0) {
- final long skipped = stream.skip(skip);
-
- if (skipped <= 0) {
- return -1;
- }
-
- skip -= skipped;
- }
-
- return stream.read(b);
- } catch (final IOException e) {
- error = e;
- throw e;
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (final RuntimeException t) {
- // Only throw if we've not already thrown an exception
...
- if (error == null) {
- throw t;
- }
- } catch (final IOException t) {
- // Only throw if we've not already thrown an exception
...
- if (error == null) {
- throw t;
- }
- }
- }
- }
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getBoolean()
- */
- @Override
- public boolean getBoolean() throws ValueFormatException {
- if (!Utils.isEmpty(this.value)) {
- if (this.value.equals(Boolean.TRUE.toString())) {
- return true;
- }
-
- if (this.value.equals(Boolean.FALSE.toString())) {
- return false;
- }
- }
-
- throw new ValueFormatException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getDate()
- */
- @Override
- public Calendar getDate() throws ValueFormatException {
- try {
- // TODO how do you determine the format here
- final SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd
hh:mm:ss"); //$NON-NLS-1$
- final Calendar cal = Calendar.getInstance();
- final Date d1 = df.parse(this.value);
- cal.setTime(d1);
- return cal;
- } catch (final Exception e) {
- final String from = PropertyType.nameFromValue(getType());
- final String to = PropertyType.nameFromValue(PropertyType.LONG);
- throw new
ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), e);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getDecimal()
- */
- @Override
- public BigDecimal getDecimal() throws ValueFormatException {
- try {
- return new BigDecimal(this.value);
- } catch (final NumberFormatException t) {
- final String from = PropertyType.nameFromValue(getType());
- final String to = PropertyType.nameFromValue(PropertyType.DECIMAL);
- throw new
ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), t);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getDouble()
- */
- @Override
- public double getDouble() throws ValueFormatException {
- try {
- return Double.parseDouble(this.value);
- } catch (final NumberFormatException t) {
- final String from = PropertyType.nameFromValue(getType());
- final String to = PropertyType.nameFromValue(PropertyType.DOUBLE);
- throw new
ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), t);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getLong()
- */
- @Override
- public long getLong() throws ValueFormatException {
- try {
- return Long.parseLong(this.value);
- } catch (final NumberFormatException t) {
- final String from = PropertyType.nameFromValue(getType());
- final String to = PropertyType.nameFromValue(PropertyType.LONG);
- throw new
ValueFormatException(RestClientI18n.unableToConvertValue.text(this.value, from, to), t);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getStream()
- */
- @SuppressWarnings("deprecation")
- @Deprecated
- @Override
- public InputStream getStream() throws RepositoryException {
- return getBinary().getStream();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getString()
- */
- @Override
- public String getString() {
- return this.value;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Value#getType()
- */
- @Override
- public int getType() {
- return ((this.type == PropertyType.UNDEFINED) ? PropertyType.STRING :
this.type);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return Utils.hashCode(this.type, this.value);
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Protected.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,53 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The protected attribute used by property definitions and child node definitions.
Protected properties cannot be removed from
- * their parent node unless the parent node is deleted.
- */
-public class Protected extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "protected",
"pro", "p" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperators.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,202 +0,0 @@
-/*
- * 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.attributes;
-
-import java.util.List;
-
-import javax.jcr.query.qom.QueryObjectModelConstants;
-
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.modeshape.jcr.Messages;
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.attributes.QueryOperators.QueryOperator;
-
-/**
- * The primary item attribute used by property definitions.
- */
-public final class QueryOperators extends ListAttributeState<QueryOperator> {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "queryops",
"qop", "qop" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * The valid query operators.
- */
- public enum QueryOperator implements CndElement {
-
- /**
- * The equals sign.
- */
- EQUALS("=", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO),
//$NON-NLS-1$
-
- /**
- * The greater than sign.
- */
- GREATER_THAN(">", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO),
//$NON-NLS-1$
-
- /**
- * The greater than or equal to sign.
- */
- GREATER_THAN_EQUALS(">=",
QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
-
- /**
- * The less than sign.
- */
- LESS_THAN("<", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO),
//$NON-NLS-1$
-
- /**
- * The less than or equal to sign.
- */
- LESS_THAN_EQUALS("<=",
QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO), //$NON-NLS-1$
-
- /**
- * The LIKE sign.
- */
- LIKE("LIKE", QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO),
//$NON-NLS-1$
-
- /**
- * The not equals sign.
- */
- NOT_EQUALS("<>",
QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO); //$NON-NLS-1$
-
- /**
- * @param notation the operator's CND notation (cannot be
<code>null</code> or empty)
- * @return the query operator (never <code>null</code>)
- * @throws IllegalArgumentException if an invalid CND notation
- */
- public static QueryOperator find( String notation ) {
- for (QueryOperator operator : QueryOperator.values()) {
- if (operator.notation.equals(notation)) {
- return operator;
- }
- }
-
- throw new IllegalArgumentException(NLS.bind(Messages.invalidFindRequest,
notation));
- }
-
- /**
- * @param jcrValue the {@link QueryObjectModelConstants} value of the query
operator (cannot be <code>null</code> or empty)
- * @return the query operator (never <code>null</code>)
- * @throws IllegalArgumentException if an invalid JCR value
- */
- public static QueryOperator findUsingJcrValue( String jcrValue ) {
- for (QueryOperator operator : QueryOperator.values()) {
- if (operator.asJcrValue().equals(jcrValue)) {
- return operator;
- }
- }
-
- throw new
IllegalArgumentException(NLS.bind(Messages.invalidFindUsingJcrValueRequest, jcrValue));
- }
-
- private final String notation;
- private final String jcrValue;
-
- private QueryOperator( String notation,
- String jcrValue ) {
- this.notation = notation;
- this.jcrValue = jcrValue;
- }
-
- /**
- * @return the {@link QueryObjectModelConstants} value (never
<code>null</code> or empty)
- */
- public String asJcrValue() {
- return this.jcrValue;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- public String toCndNotation( NotationType notationType ) {
- return toString();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return this.notation;
- }
- }
-
- /**
- * @param operator the operator notation (cannot be <code>null</code> or
empty)
- * @return <code>true</code> if added
- * @throws IllegalArgumentException if an invalid operator notation
- */
- public boolean add( String operator ) {
- Utils.verifyIsNotEmpty(operator, "operator"); //$NON-NLS-1$
- return add(QueryOperator.find(operator));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- int result = 0;
-
- for (QueryOperator operator : QueryOperator.values()) {
- if (supports(operator)) {
- result = Utils.hashCode(result, operator);
- }
- }
-
- return super.hashCode();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- protected String getCndNotationPrefix( NotationType notationType ) {
- if (NotationType.LONG == notationType) {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
- if (NotationType.COMPRESSED == notationType) {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * @return a list of supported operator notations (never
<code>null</code> but can be empty)
- */
- public String[] toArray() {
- List<QueryOperator> operators = getSupportedItems();
-
- if (Utils.isEmpty(operators)) {
- return Utils.EMPTY_STRING_ARRAY;
- }
-
- String[] result = new String[operators.size()];
- int i = 0;
-
- for (QueryOperator operator : operators) {
- result[i++] = operator.toString();
- }
-
- return result;
- }
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/Queryable.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,99 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The queryable attribute used by child node definitions.
- */
-public class Queryable extends AttributeState {
-
- /**
- * The CND notation for each notation type for when queryable.
- */
- public static final String[] QUERY_NOTATION = new String[] { "query",
"q", "q" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * The CND notation for each notation type for when not queryable..
- */
- public static final String[] NO_QUERY_NOTATION = new String[] { "noquery",
"nq", "nq" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * Constructs a queryable attribute set to be a variant (the default).
- */
- public Queryable() {
- set(Value.VARIANT);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- if (is()) {
- return QUERY_NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- if (isNot()) {
- return NO_QUERY_NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- return Utils.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- if (is()) {
- return QUERY_NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- if (isNot()) {
- return NO_QUERY_NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- return Utils.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- if (is()) {
- return QUERY_NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
- if (isNot()) {
- return NO_QUERY_NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
- return Utils.EMPTY_STRING;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#hasCndNotation()
- */
- @Override
- protected boolean hasCndNotation() {
- return !isVariant();
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypes.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,80 +0,0 @@
-/*
- * 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.attributes;
-
-import java.util.List;
-
-import org.jboss.tools.modeshape.jcr.QualifiedName;
-import org.jboss.tools.modeshape.jcr.Utils;
-
-/**
- * The required types of a child node definition.
- */
-public final class RequiredTypes extends ListAttributeState<QualifiedName> {
-
- /**
- * The CND list prefix.
- */
- public static final String NOTATION_PREFIX = "("; //$NON-NLS-1$;
-
- /**
- * The CND list suffix.
- */
- public static final String NOTATION_SUFFIX = ")"; //$NON-NLS-1$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- protected String getCndNotationPrefix( final NotationType notationType ) {
- return NOTATION_PREFIX;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationSuffix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- protected String getCndNotationSuffix( final NotationType notationType ) {
- return NOTATION_SUFFIX;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getListPrefixEndDelimiter()
- */
- @Override
- protected String getListPrefixEndDelimiter() {
- return Utils.EMPTY_STRING;
- }
-
- /**
- * @return the collection of required types (never <code>null</code>)
- */
- public String[] toArray() {
- final List<QualifiedName> typeNames = getSupportedItems();
-
- if (Utils.isEmpty(typeNames)) {
- return Utils.EMPTY_STRING_ARRAY;
- }
-
- final String[] result = new String[typeNames.size()];
- int i = 0;
-
- for (final QualifiedName typeName : typeNames) {
- result[i++] = typeName.get();
- }
-
- return result;
- }
-
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SameNameSiblings.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,52 +0,0 @@
-/*
- * 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.attributes;
-
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
-/**
- * The same named siblings attribute used by child node definitions.
- */
-public class SameNameSiblings extends AttributeState {
-
- /**
- * The CND notation for each notation type.
- */
- public static final String[] NOTATION = new String[] { "sns",
"*", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompactCndNotation()
- */
- @Override
- protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getCompressedCndNotation()
- */
- @Override
- protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#getLongCndNotation()
- */
- @Override
- protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
- }
-
-}
\ No newline at end of file
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypes.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,55 +0,0 @@
-/*
- * 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.attributes;
-
-import java.util.List;
-
-import org.jboss.tools.modeshape.jcr.QualifiedName;
-import org.jboss.tools.modeshape.jcr.Utils;
-
-/**
- *
- */
-public final class SuperTypes extends ListAttributeState<QualifiedName> {
-
- /**
- * The CND list suffix.
- */
- public static final String NOTATION_PREFIX = ">"; //$NON-NLS-1$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- protected String getCndNotationPrefix( final NotationType notationType ) {
- return NOTATION_PREFIX;
- }
-
- /**
- * @return the collection of super types (never <code>null</code>)
- */
- public String[] toArray() {
- final List<QualifiedName> superTypes = getSupportedItems();
-
- if (Utils.isEmpty(superTypes)) {
- return Utils.EMPTY_STRING_ARRAY;
- }
-
- final String[] result = new String[superTypes.size()];
- int i = 0;
-
- for (final QualifiedName superType : superTypes) {
- result[i++] = superType.get();
- }
-
- return result;
- }
-
-}
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraints.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1,66 +0,0 @@
-/*
- * 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.attributes;
-
-import java.util.List;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
-
-/**
- * The value constraints of a property definition.
- */
-public final class ValueConstraints extends ListAttributeState<String> {
-
- /**
- * The CND list suffix.
- */
- public static final String NOTATION_PREFIX = "<"; //$NON-NLS-1$
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getCndNotationPrefix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
- */
- @Override
- protected String getCndNotationPrefix( final NotationType notationType ) {
- return NOTATION_PREFIX;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.ListAttributeState#getItemQuoteCharacter()
- */
- @Override
- protected String getItemQuoteCharacter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER);
- }
-
- /**
- * @return the collection of value constraints (never <code>null</code>)
- */
- public String[] toArray() {
- final List<String> constraints = getSupportedItems();
-
- if (Utils.isEmpty(constraints)) {
- return Utils.EMPTY_STRING_ARRAY;
- }
-
- final String[] result = new String[constraints.size()];
- int i = 0;
-
- for (final String constraint : constraints) {
- result[i++] = constraint;
- }
-
- return result;
- }
-
-}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -30,6 +30,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.window.Window;
@@ -47,9 +48,13 @@
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.editors.text.FileDocumentProvider;
import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessage;
import org.eclipse.ui.forms.IMessageManager;
import org.eclipse.ui.forms.editor.SharedHeaderFormEditor;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.FileEditorInput;
@@ -61,6 +66,7 @@
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants.Images;
import org.jboss.tools.modeshape.ui.UiMessages;
import org.jboss.tools.modeshape.ui.forms.MessageFormDialog;
+import org.jboss.tools.modeshape.ui.forms.MessageSummaryDialog;
/**
*
@@ -233,6 +239,19 @@
final Form form = this.scrolledForm.getForm();
getToolkit().decorateFormHeading(form);
+ form.addMessageHyperlinkListener(new HyperlinkAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.events.HyperlinkAdapter#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ @Override
+ public void linkActivated( final HyperlinkEvent e ) {
+ handleDisplayMessageDialog((IMessage[])e.data);
+ }
+ });
+
//
// createActions();
// contributeToToolBar(form.getToolBarManager());
@@ -346,6 +365,48 @@
return getEditorSite().getShell();
}
+ void handleDisplayMessageDialog( final IMessage[] data ) {
+ // configure message and message type
+ int numErrors = 0;
+ int numWarnings = 0;
+ int numInfos = 0;
+ int messageType = IMessageProvider.ERROR;
+
+ for (final IMessage message : data) {
+ if (message.getMessageType() == IMessageProvider.ERROR) {
+ ++numErrors;
+ } else if (message.getMessageType() == IMessageProvider.WARNING) {
+ ++numWarnings;
+ } else if (message.getMessageType() == IMessageProvider.INFORMATION) {
+ ++numInfos;
+ }
+ }
+
+ if (numErrors == 0) {
+ if (numWarnings != 0) {
+ messageType = IMessageProvider.WARNING;
+ } else if (numInfos != 0) {
+ messageType = IMessageProvider.INFORMATION;
+ } else {
+ messageType = IMessageProvider.NONE;
+ }
+ }
+
+ final String message = NLS.bind(CndMessages.cndMessageDialogMessageAreaMessage,
new Object[] { getFile().getName(),
+ numErrors, numWarnings, numInfos });
+
+ // show dialog
+ final FormDialog dialog = new MessageSummaryDialog(getShell(),
+
CndMessages.cndMessageDialogTitle,
+
CndMessages.cndMessageDialogMessageAreaTitle,
+ message,
+ messageType,
+ data);
+ dialog.create();
+ dialog.getShell().pack();
+ dialog.open();
+ }
+
/**
* Registers an editor activation listener.
*/
@@ -353,16 +414,6 @@
getContainer().addListener(SWT.Activate, this.refreshListener);
}
- //
- // /**
- // * Handler for page change listener.
- // */
- // void handlePageChanged() {
- // final FormPage page = (FormPage)getSelectedPage();
- // this.scrolledForm.setText(page.getTitle());
- // page.setFocus();
- // }
-
/**
* {@inheritDoc}
*
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -1912,6 +1912,8 @@
if (nodeTypeDefinition.addChildNodeDefinition(newChildNodeDefinition)) {
added = true;
}
+
+ UiUtils.pack(this.childNodeViewer);
}
if (!removed || !added) {
@@ -1947,6 +1949,8 @@
if (getCnd().addNamespaceMapping(modifiedNamespaceMapping)) {
added = true;
}
+
+ UiUtils.pack(this.namespaceViewer);
}
if (!removed || !added) {
@@ -1983,6 +1987,8 @@
if (nodeTypeDefinition.addPropertyDefinition(newPropertyDefinition)) {
added = true;
}
+
+ UiUtils.pack(this.propertyViewer);
}
if (!removed || !added) {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -304,6 +304,22 @@
public static String cndEditorTitle;
/**
+ * The message area message of the CND validation message dialog. Four parameters,
the name of the CND, the number of errors,
+ * the number of warnings, and the number of info messages, are required.
+ */
+ public static String cndMessageDialogMessageAreaMessage;
+
+ /**
+ * The message area title of the CND validation message dialog.
+ */
+ public static String cndMessageDialogMessageAreaTitle;
+
+ /**
+ * The title of the CND validation message dialog.
+ */
+ public static String cndMessageDialogTitle;
+
+ /**
* The column header text of the default type of a child node definition.
*/
public static String defaultTypeHeaderText;
@@ -1010,6 +1026,11 @@
public static String queryableAttributeToolTip;
/**
+ * A label for a query operators control.
+ */
+ public static String queryOperatorsLabel;
+
+ /**
* The column header text for the required types of a child node definition.
*/
public static String requiredTypesHeaderText;
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-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -60,6 +60,7 @@
import org.jboss.tools.modeshape.jcr.ValidationStatus;
import org.jboss.tools.modeshape.jcr.attributes.OnParentVersion;
import org.jboss.tools.modeshape.jcr.attributes.PropertyType;
+import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
@@ -550,14 +551,17 @@
{ // opv
final Composite opvContainer =
toolkit.createComposite(attributesContainer);
opvContainer.setLayout(new GridLayout(2, false));
- opvContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
true));
+ ((GridLayout)opvContainer.getLayout()).marginHeight = 0;
+ ((GridLayout)opvContainer.getLayout()).marginWidth = 0;
+ opvContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
false));
+ ((GridData)opvContainer.getLayoutData()).horizontalSpan = 2;
toolkit.paintBordersFor(opvContainer);
final Label lblOpv = toolkit.createLabel(opvContainer,
CndMessages.onParentVersionLabel, SWT.NONE);
lblOpv.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
final CCombo cbxOpvs = new CCombo(opvContainer, Styles.COMBO_STYLE);
- cbxOpvs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ cbxOpvs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
((GridData)cbxOpvs.getLayoutData()).heightHint = cbxOpvs.getItemHeight()
+ 4;
cbxOpvs.setToolTipText(CndMessages.onParentVersionToolTip);
toolkit.adapt(cbxOpvs, true, false);
@@ -596,7 +600,163 @@
}
{ // queryOps
- // TODO implement queryOps controls
+ 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());
+
+ 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.multipleAttributeToolTip);
+ }
+
+ { // not equals query operator
+ final Button btnNotEquals = toolkit.createButton(queryOpsContainer,
QueryOperator.NOT_EQUALS.toString(),
+ SWT.CHECK);
+ btnNotEquals.setBackground(attributesContainer.getBackground());
+
+ if (supportedQueryOps.contains(btnNotEquals.getText())) {
+ btnNotEquals.setSelection(true);
+ }
+
+ btnNotEquals.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());
+ }
+ });
+ //
btnNotEquals.setToolTipText(CndMessages.multipleAttributeToolTip);
+ }
+
+ { // greater than query operator
+ final Button btnGreaterThan = toolkit.createButton(queryOpsContainer,
QueryOperator.GREATER_THAN.toString(),
+ SWT.CHECK);
+ btnGreaterThan.setBackground(attributesContainer.getBackground());
+
+ if (supportedQueryOps.contains(btnGreaterThan.getText())) {
+ btnGreaterThan.setSelection(true);
+ }
+
+ btnGreaterThan.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());
+ }
+ });
+ // btnGreater.setToolTipText(CndMessages.multipleAttributeToolTip);
+ }
+
+ { // less than query operator
+ final Button btnLessThan = toolkit.createButton(queryOpsContainer,
QueryOperator.LESS_THAN.toString(),
+ SWT.CHECK);
+ btnLessThan.setBackground(attributesContainer.getBackground());
+
+ if (supportedQueryOps.contains(btnLessThan.getText())) {
+ btnLessThan.setSelection(true);
+ }
+
+ btnLessThan.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());
+ }
+ });
+ // 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());
+
+ if (supportedQueryOps.contains(btnGreaterThanEqual.getText())) {
+ btnGreaterThanEqual.setSelection(true);
+ }
+
+ btnGreaterThanEqual.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());
+ }
+ });
+ //
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());
+
+ if (supportedQueryOps.contains(btnLessThanEqual.getText())) {
+ btnLessThanEqual.setSelection(true);
+ }
+
+ 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);
+ }
}
}
@@ -719,6 +879,19 @@
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) {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-30
18:35:02 UTC (rev 39948)
@@ -64,6 +64,10 @@
cndEditorSaveError = Error saving the model extension definition editor.
cndEditorSourcePageTitle = Source
cndEditorTitle = JCR Compact Node Definition
+# 0 = name of CND, 1 = number of errors, 2 = number of warnings, 3 = number of info
+cndMessageDialogMessageAreaMessage = The {0} CND has {1} error(s), {2} warnings, and {3}
information messages.
+cndMessageDialogMessageAreaTitle = Message Summary
+cndMessageDialogTitle = CND Validation Messages
defaultTypeHeaderText = Default Type
defaultValueDialogCreateMsg = Create Default Value
defaultValueDialogEditMsg = Edit Default Value
@@ -207,6 +211,7 @@
qualifierLabel = Namespace:
queryableAttribute = Queryable
queryableAttributeToolTip = Indicates if the child node definition supports siblings of
the same name
+queryOperatorsLabel = Supported Query Operators:
requiredTypesHeaderText = Required Types
requiredTypesLabel = Required Types:
sameNamedSiblingsAttribute = Same Named Siblings
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -25,6 +25,11 @@
public static String infoDialogTitle;
/**
+ * The table column header title for a message.
+ */
+ public static String messageColumnHeader;
+
+ /**
* The title of a generic question message dialog.
*/
public static String questionDialogTitle;
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageLabelProvider.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageLabelProvider.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageLabelProvider.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -0,0 +1,74 @@
+/*
+ * 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.ui.forms;
+
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.forms.IMessage;
+import org.jboss.tools.modeshape.ui.Activator;
+import org.jboss.tools.modeshape.ui.UiUtils;
+
+/**
+ * A label provider for {@link IMessage}s.
+ */
+public class MessageLabelProvider extends ColumnLabelProvider {
+
+ private final boolean messageTypeFlag;
+
+ /**
+ * @param messageTypeFlag a flag indicating if the {@link TableViewerColumn} is
message type column or the the message column.
+ */
+ public MessageLabelProvider( final boolean messageTypeFlag ) {
+ this.messageTypeFlag = messageTypeFlag;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage( final Object element ) {
+ if (this.messageTypeFlag) {
+ final ISharedImages sharedImages =
Activator.getSharedInstance().getWorkbench().getSharedImages();
+ final int messageType = ((IMessage)element).getMessageType();
+
+ if (messageType == IMessageProvider.ERROR) {
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ }
+
+ if (messageType == IMessageProvider.WARNING) {
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ }
+
+ if (messageType == IMessageProvider.INFORMATION) {
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( final Object element ) {
+ if (this.messageTypeFlag) {
+ return UiUtils.EMPTY_STRING;
+ }
+
+ final IMessage message = (IMessage)element;
+ return message.getMessage();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageLabelProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageSummaryDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageSummaryDialog.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageSummaryDialog.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -0,0 +1,180 @@
+/*
+ * 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.ui.forms;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.jboss.tools.modeshape.ui.UiMessages;
+import org.jboss.tools.modeshape.ui.UiUtils;
+
+/**
+ * A dialog that displays messages in a table.
+ */
+public class MessageSummaryDialog extends FormDialog {
+
+ private final String dialogTitle;
+ private final String messageAreaMessage;
+ private final String messageAreaTitle;
+ private final int messageType;
+ private final IMessage[] messages;
+
+ /**
+ * @param parent the parent (can be <code>null</code>)
+ * @param dialogTitle the dialog window title (cannot be
<code>null</code> or empty)
+ * @param messageAreaTitle the message area title (cannot be
<code>null</code> or empty)
+ * @param messageAreaMessage the message area message (cannot be
<code>null</code> or empty)
+ * @param messageType the message type (see {@link IMessageProvider})
+ * @param messages the messages being displayed (cannot be
<code>null</code>)
+ */
+ public MessageSummaryDialog( final Shell parent,
+ final String dialogTitle,
+ final String messageAreaTitle,
+ final String messageAreaMessage,
+ final int messageType,
+ final IMessage[] messages ) {
+ super(parent);
+ this.dialogTitle = dialogTitle;
+ this.messages = messages;
+ this.messageAreaTitle = messageAreaTitle;
+ this.messageAreaMessage = messageAreaMessage;
+ this.messageType = messageType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell( final Shell newShell ) {
+ super.configureShell(newShell);
+ newShell.setText(this.dialogTitle);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar( Composite parent ) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent( final IManagedForm managedForm ) {
+ final ScrolledForm scrolledForm = managedForm.getForm();
+ scrolledForm.setText(this.messageAreaTitle); // set header area title
+ scrolledForm.setMessage(this.messageAreaMessage, this.messageType,
this.messages);
+ scrolledForm.getBody().setLayout(new GridLayout());
+ scrolledForm.getBody().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
+
+ final FormToolkit toolkit = managedForm.getToolkit();
+ final Composite container =
toolkit.createComposite(managedForm.getForm().getBody());
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ toolkit.paintBordersFor(container);
+
+ int count = this.messages.length;
+
+ if (count > 20) {
+ count = 20;
+ } else {
+ count += 2;
+ }
+
+ final Table table = FormUtils.createTable(toolkit, container);
+ final GridData gd = (GridData)table.getLayoutData();
+ gd.heightHint = table.getItemHeight() * count;
+ gd.minimumHeight = gd.heightHint;
+
+ final TableViewer viewer = new TableViewer(table);
+ viewer.setLabelProvider(new LabelProvider());
+ viewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ return getMessages();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( final Viewer viewer,
+ final Object oldInput,
+ final Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ { // create message type column
+ final TableViewerColumn messageTypeColumn = new TableViewerColumn(viewer,
SWT.CENTER);
+ UiUtils.configureColumn(messageTypeColumn, new MessageLabelProvider(true),
UiUtils.EMPTY_STRING, UiUtils.EMPTY_STRING,
+ false, false);
+ }
+
+ { // create message column
+ final TableViewerColumn messageColumn = new TableViewerColumn(viewer,
SWT.LEFT);
+ UiUtils.configureColumn(messageColumn, new MessageLabelProvider(false),
UiMessages.messageColumnHeader,
+ UiUtils.EMPTY_STRING, false, true);
+ }
+
+ // this will sort by child node name
+ viewer.setSorter(new MessageViewerSorter());
+
+ // populate table with data
+ viewer.setInput(this);
+
+ // size columns to the data
+ UiUtils.pack(viewer);
+ }
+
+ IMessage[] getMessages() {
+ return this.messages;
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageSummaryDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageViewerSorter.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageViewerSorter.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageViewerSorter.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -0,0 +1,33 @@
+/*
+ * 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.ui.forms;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.ui.forms.IMessage;
+
+/**
+ * A structured viewer sorter for {@link IMessage}s.
+ */
+public class MessageViewerSorter extends ViewerSorter {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int compare( Viewer viewer,
+ Object thisMessage,
+ Object thatMessage ) {
+ int thisMsgType = ((IMessage)thisMessage).getMessageType();
+ int thatMsgType = ((IMessage)thatMessage).getMessageType();
+
+ return Integer.valueOf(thisMsgType).compareTo(Integer.valueOf(thatMsgType));
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageViewerSorter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties 2012-03-30
18:35:02 UTC (rev 39948)
@@ -6,5 +6,6 @@
errorDialogTitle = Error
infoDialogTitle = Info
+messageColumnHeader = Message
questionDialogTitle = Question
warningDialogTitle = Warning
\ No newline at end of file
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-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -195,11 +195,16 @@
}
@Test
- public void shouldAddQueryOperator() {
- final QueryOperator OP = QueryOperator.GREATER_THAN_EQUALS;
- assertTrue(this.propDefn.addQueryOperator(OP));
- assertEquals(1, this.propDefn.getAvailableQueryOperators().length);
- assertEquals(OP.toString(), this.propDefn.getAvailableQueryOperators()[0]);
+ public void shouldSupportAllQueryOperatorsInitially() {
+ // setup
+ String[] queryOps = this.propDefn.getAvailableQueryOperators();
+ QueryOperator[] allOperators = QueryOperator.values();
+
+ assertEquals(allOperators.length, queryOps.length);
+
+ for (String queryOp : queryOps) {
+ QueryOperator.find(queryOp); // throws exception if not found
+ }
}
@Test
@@ -378,9 +383,7 @@
@Test
public void shouldNotAddDuplicateQueryOperator() {
- final QueryOperator OP = QueryOperator.GREATER_THAN_EQUALS;
- assertTrue(this.propDefn.addQueryOperator(OP));
- assertFalse(this.propDefn.addQueryOperator(OP));
+ assertFalse(this.propDefn.addQueryOperator(QueryOperator.EQUALS));
}
@Test
@@ -460,6 +463,7 @@
@Test
public void shouldNotRemoveQueryOperatorThatDoesNotExist() {
+
assertTrue(this.propDefn.removeQueryOperator(QueryOperator.GREATER_THAN_EQUALS));
assertFalse(this.propDefn.removeQueryOperator(QueryOperator.GREATER_THAN_EQUALS));
}
@@ -621,12 +625,15 @@
@Test
public void shouldReceiveEventWhenQueryOperatorIsAdded() {
+ // setup
+ final QueryOperator OP = QueryOperator.GREATER_THAN_EQUALS;
+ assertTrue(this.propDefn.removeQueryOperator(OP));
+
final Listener l = new Listener();
assertTrue(this.propDefn.addListener(l));
- final QueryOperator OP = QueryOperator.GREATER_THAN_EQUALS;
+ // test
assertTrue(this.propDefn.addQueryOperator(OP));
-
assertEquals(1, l.getCount());
assertEquals(PropertyName.QUERY_OPS.toString(), l.getPropertyName());
assertEquals(OP, l.getNewValue());
@@ -636,8 +643,6 @@
@Test
public void shouldReceiveEventWhenQueryOperatorIsRemoved() {
final QueryOperator OP = QueryOperator.GREATER_THAN_EQUALS;
- assertTrue(this.propDefn.addQueryOperator(OP));
-
final Listener l = new Listener();
assertTrue(this.propDefn.addListener(l));
@@ -658,9 +663,7 @@
@Test
public void shouldRemoveQueryOperator() {
- final QueryOperator OP = QueryOperator.GREATER_THAN_EQUALS;
- assertTrue(this.propDefn.addQueryOperator(OP));
- assertTrue(this.propDefn.removeQueryOperator(OP));
+
assertTrue(this.propDefn.removeQueryOperator(QueryOperator.GREATER_THAN_EQUALS));
}
@Test
@@ -808,8 +811,6 @@
@Test
public void shouldSetQueryOperators() {
- assertTrue(this.propDefn.addQueryOperator(QueryOperator.GREATER_THAN_EQUALS));
-
final String OP1 = QueryOperator.EQUALS.toString();
final String OP2 = QueryOperator.LESS_THAN.toString();
final String OP3 = QueryOperator.GREATER_THAN.toString();
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributesTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributesTest.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PropertyAttributesTest.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -97,10 +97,10 @@
}
@Test
- public void shouldNotHaveQueryOpsAfterConstruction() {
+ public void shouldSupportQueryOpsAfterConstruction() {
final QueryOperators attribute = this.attributes.getQueryOps();
- assertTrue(attribute.isNot());
- assertFalse(attribute.is());
+ assertTrue(attribute.is());
+ assertFalse(attribute.isNot());
assertFalse(attribute.isVariant());
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperatorsTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperatorsTest.java 2012-03-30
17:13:09 UTC (rev 39947)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/QueryOperatorsTest.java 2012-03-30
18:35:02 UTC (rev 39948)
@@ -36,10 +36,17 @@
@Before
public void beforeEach() {
- this.attribute = new QueryOperators();
+ this.attribute = new QueryOperators(); // initially supports all operators
}
@Test
+ public void shouldSupportAllOperatorsAfterConstruction() {
+ for (final QueryOperator operator : QueryOperator.values()) {
+ assertTrue(this.attribute.supports(operator));
+ }
+ }
+
+ @Test
public void initialCndNotationShouldBeEmpty() {
assertTrue(Utils.isEmpty(this.attribute.toCndNotation(CndElement.NotationType.LONG)));
assertTrue(Utils.isEmpty(this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED)));
@@ -53,28 +60,39 @@
}
@Test
+ public void shouldAddUsingOperatorNotation() {
+ // setup
+ remove(OPERATOR_ONE);
+ assertTrue(this.attribute.add(OPERATOR_ONE.toString()));
+
+ // test
+ assertTrue(this.attribute.supports(OPERATOR_ONE));
+ }
+
+ @Test
+ public void shouldRemoveUsingOperatorNotation() {
+ assertTrue(this.attribute.remove(OPERATOR_ONE.toString()));
+ }
+
+ @Test
public void verifyAddedItem() {
// setup
+ remove(OPERATOR_ONE);
add(OPERATOR_ONE);
// tests
- assertEquals(1, this.attribute.getSupportedItems().size());
- assertTrue(this.attribute.getSupportedItems().contains(OPERATOR_ONE));
+ assertTrue(this.attribute.supports(OPERATOR_ONE));
}
@Test
- public void verifyInitiallyNoSupportedItems() {
- assertEquals(0, this.attribute.getSupportedItems().size());
+ public void verifyInitialStateShouldBeIs() {
+ assertEquals(AttributeState.Value.IS, this.attribute.get());
}
@Test
- public void verifyInitialStateShouldBeIsNot() {
- assertEquals(AttributeState.Value.IS_NOT, this.attribute.get());
- }
-
- @Test
public void verifyMultipleElementsCndNotation() {
// setup
+ assertTrue(this.attribute.clear());
add(OPERATOR_ONE);
add(OPERATOR_TWO);
add(OPERATOR_THREE);
@@ -88,6 +106,7 @@
@Test
public void verifyOneElementCndNotation() {
// setup
+ assertTrue(this.attribute.clear());
add(OPERATOR_ONE);
// tests
@@ -99,44 +118,26 @@
@Test
public void verifyRemoveItem() {
// setup
- add(OPERATOR_ONE);
- add(OPERATOR_TWO);
remove(OPERATOR_ONE);
// tests
- assertFalse(this.attribute.getSupportedItems().contains(OPERATOR_ONE));
+ assertFalse(this.attribute.supports(OPERATOR_ONE));
}
@Test
public void verifySameElementIsNotAdded() {
- // setup
- add(OPERATOR_ONE);
-
// tests
if (this.attribute.add(OPERATOR_ONE)) {
fail();
}
-
- assertEquals(1, this.attribute.getSupportedItems().size());
}
@Test
- public void verifyStateShouldBeIsAfterAdd() {
+ public void verifyStateShouldBeIsNotAfterClear() {
// setup
- add(QueryOperator.EQUALS);
+ assertTrue(this.attribute.clear());
// tests
- assertEquals(AttributeState.Value.IS, this.attribute.get());
- }
-
- @Test
- public void verifyStateShouldBeIsNotWhenEmpty() {
- // setup
- add(OPERATOR_ONE);
- remove(OPERATOR_ONE);
-
- // tests
- assertEquals(0, this.attribute.getSupportedItems().size());
assertEquals(AttributeState.Value.IS_NOT, this.attribute.get());
}
@@ -150,5 +151,4 @@
assertEquals(QUERY_OPS_VARIANT_COMPRESSED_FORM,
this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(QUERY_OPS_VARIANT_LONG_FORM,
this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
-
}