Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-10-20 13:50:13 -0400
committerpfullbright2010-10-20 13:50:13 -0400
commitb27d333956fc327a2aaf49c927ba2982b9a766ee (patch)
treed23cf5045e8df47f09f3ff950851cb0ef6c4f6d3
parent0d2bac952a0bff2007aaf3270e0c45b873a47865 (diff)
downloadwebtools.dali-b27d333956fc327a2aaf49c927ba2982b9a766ee.tar.gz
webtools.dali-b27d333956fc327a2aaf49c927ba2982b9a766ee.tar.xz
webtools.dali-b27d333956fc327a2aaf49c927ba2982b9a766ee.zip
XmlSchema/XmlNs annotation resource model
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaAnnotationDefinition.java52
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java150
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaAnnotation.java355
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaAnnotation.java11
7 files changed, 567 insertions, 13 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java
index 65d03799a9..abe8c013d8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java
@@ -33,6 +33,7 @@ import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlMimeTypeAnnotationDef
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlMixedAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRegistryAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlRootElementAnnotationDefinition;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSchemaAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlSeeAlsoAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTransientAnnotationDefinition;
import org.eclipse.jpt.jaxb.core.internal.resource.java.XmlTypeAnnotationDefinition;
@@ -71,6 +72,7 @@ public class GenericJaxbAnnotationDefinitionProvider
definitions.add(XmlAccessorTypeAnnotationDefinition.instance());
definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance());
definitions.add(XmlJavaTypeAdaptersAnnotationDefinition.instance());
+ definitions.add(XmlSchemaAnnotationDefinition.instance());
}
@Override
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaAnnotationDefinition.java
new file mode 100644
index 0000000000..75ba72c656
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlSchemaAnnotationDefinition.java
@@ -0,0 +1,52 @@
+package org.eclipse.jpt.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlSchemaAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+
+public class XmlSchemaAnnotationDefinition
+ implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new XmlSchemaAnnotationDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private XmlSchemaAnnotationDefinition() {
+ super();
+ }
+
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ return new SourceXmlSchemaAnnotation((JavaResourcePackage) parent, (AnnotatedPackage) annotatedElement);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return JAXB.XML_SCHEMA;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java
new file mode 100644
index 0000000000..cb86783910
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlNsAnnotation.java
@@ -0,0 +1,150 @@
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
+
+
+public class SourceXmlNsAnnotation
+ extends SourceAnnotation<AnnotatedPackage>
+ implements XmlNsAnnotation {
+
+ private final DeclarationAnnotationElementAdapter<String> namespaceDeclarationAdapter;
+ private final AnnotationElementAdapter<String> namespaceAdapter;
+ private String namespace;
+
+ private final DeclarationAnnotationElementAdapter<String> prefixDeclarationAdapter;
+ private final AnnotationElementAdapter<String> prefixAdapter;
+ private String prefix;
+
+
+ public SourceXmlNsAnnotation(JavaResourceNode parent, AnnotatedPackage pack, IndexedDeclarationAnnotationAdapter idaa) {
+ super(parent, pack, idaa, new ElementIndexedAnnotationAdapter(pack, idaa));
+ this.namespaceDeclarationAdapter = buildNamespaceDeclarationAdapter(idaa);
+ this.namespaceAdapter = buildAdapter(this.namespaceDeclarationAdapter);
+ this.prefixDeclarationAdapter = buildPrefixDeclarationAdapter(idaa);
+ this.prefixAdapter = buildAdapter(this.prefixDeclarationAdapter);
+ }
+
+
+ protected DeclarationAnnotationElementAdapter<String> buildNamespaceDeclarationAdapter(
+ DeclarationAnnotationAdapter daa) {
+
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JAXB.XML_NS__NAMESPACE_URI, false);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildPrefixDeclarationAdapter(
+ DeclarationAnnotationAdapter daa) {
+
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JAXB.XML_NS__PREFIX, false);
+ }
+
+ private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.namespace = buildNamespace(astRoot);
+ this.prefix = buildPrefix(astRoot);
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ syncNamespace(buildNamespace(astRoot));
+ syncPrefix(buildPrefix(astRoot));
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.namespace);
+ }
+
+
+ // **************** namespace *********************************************
+
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ if (attributeValueHasChanged(this.namespace, namespace)) {
+ this.namespace = namespace;
+ this.namespaceAdapter.setValue(namespace);
+ }
+ }
+
+ private String buildNamespace(CompilationUnit astRoot) {
+ return this.namespaceAdapter.getValue(astRoot);
+ }
+
+ private void syncNamespace(String namespace) {
+ String old = this.namespace;
+ this.namespace = namespace;
+ firePropertyChanged(NAMESPACE_PROPERTY, old, namespace);
+ }
+
+ public TextRange getNamespaceTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.namespaceDeclarationAdapter, astRoot);
+ }
+
+
+ // **************** prefix ************************************************
+
+ public String getPrefix() {
+ return this.prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ if (attributeValueHasChanged(this.prefix, prefix)) {
+ this.prefix = prefix;
+ this.prefixAdapter.setValue(prefix);
+ }
+ }
+
+ private String buildPrefix(CompilationUnit astRoot) {
+ return this.prefixAdapter.getValue(astRoot);
+ }
+
+ private void syncPrefix(String prefix) {
+ String old = this.prefix;
+ this.prefix = prefix;
+ firePropertyChanged(PREFIX_PROPERTY, old, prefix);
+ }
+
+ public TextRange getPrefixTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.prefixDeclarationAdapter, astRoot);
+ }
+
+
+ // **************** NestableAnnotation impl *******************************
+
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ XmlNsAnnotation oldXmlNsAnnotation = (XmlNsAnnotation) oldAnnotation;
+ this.setNamespace(oldXmlNsAnnotation.getNamespace());
+ this.setPrefix(oldXmlNsAnnotation.getPrefix());
+ }
+
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaAnnotation.java
new file mode 100644
index 0000000000..5911a2b5dc
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSchemaAnnotation.java
@@ -0,0 +1,355 @@
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import java.util.Vector;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.AnnotationContainer;
+import org.eclipse.jpt.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlNsForm;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaAnnotation;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterables.ListIterable;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
+
+
+public class SourceXmlSchemaAnnotation
+ extends SourceAnnotation<AnnotatedPackage>
+ implements XmlSchemaAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER
+ = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private static final DeclarationAnnotationElementAdapter<String> ATTRIBUTE_FORM_DEFAULT_ADAPTER =
+ buildAttributeFormDefaultAdapter();
+ private final AnnotationElementAdapter<String> attributeFormDefaultAdapter;
+ private XmlNsForm attributeFormDefault;
+
+ private static final DeclarationAnnotationElementAdapter<String> ELEMENT_FORM_DEFAULT_ADAPTER =
+ buildElementFormDefaultAdapter();
+ private final AnnotationElementAdapter<String> elementFormDefaultAdapter;
+ private XmlNsForm elementFormDefault;
+
+ private static final DeclarationAnnotationElementAdapter<String> LOCATION_ADAPTER =
+ buildLocationAdapter();
+ private final AnnotationElementAdapter<String> locationAdapter;
+ private String location;
+
+ private static final DeclarationAnnotationElementAdapter<String> NAMESPACE_ADAPTER =
+ buildNamespaceAdapter();
+ private final AnnotationElementAdapter<String> namespaceAdapter;
+ private String namespace;
+
+ private final Vector<XmlNsAnnotation> xmlns = new Vector<XmlNsAnnotation>();
+ private final XmlnsAnnotationContainer xmlnsContainer = new XmlnsAnnotationContainer();
+
+
+ private static DeclarationAnnotationElementAdapter<String> buildAttributeFormDefaultAdapter() {
+ return new EnumDeclarationAnnotationElementAdapter(
+ DECLARATION_ANNOTATION_ADAPTER, JAXB.XML_SCHEMA__ATTRIBUTE_FORM_DEFAULT, false); // false = do not remove annotation when empty
+ }
+
+ private static DeclarationAnnotationElementAdapter<String> buildElementFormDefaultAdapter() {
+ return new EnumDeclarationAnnotationElementAdapter(
+ DECLARATION_ANNOTATION_ADAPTER, JAXB.XML_SCHEMA__ELEMENT_FORM_DEFAULT, false); // false = do not remove annotation when empty
+ }
+
+ private static DeclarationAnnotationElementAdapter<String> buildLocationAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(
+ DECLARATION_ANNOTATION_ADAPTER, JAXB.XML_SCHEMA__LOCATION, false); // false = do not remove annotation when empty
+ }
+
+ private static DeclarationAnnotationElementAdapter<String> buildNamespaceAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(
+ DECLARATION_ANNOTATION_ADAPTER, JAXB.XML_SCHEMA__NAMESPACE, false); // false = do not remove annotation when empty
+ }
+
+
+ public SourceXmlSchemaAnnotation(JavaResourcePackage parent, AnnotatedPackage pack) {
+ this(parent, pack, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public SourceXmlSchemaAnnotation(JavaResourcePackage parent, AnnotatedPackage pack, DeclarationAnnotationAdapter daa) {
+ super(parent, pack, daa);
+ this.attributeFormDefaultAdapter = buildAnnotationElementAdapter(ATTRIBUTE_FORM_DEFAULT_ADAPTER);
+ this.elementFormDefaultAdapter = buildAnnotationElementAdapter(ELEMENT_FORM_DEFAULT_ADAPTER);
+ this.locationAdapter = buildAnnotationElementAdapter(LOCATION_ADAPTER);
+ this.namespaceAdapter = buildAnnotationElementAdapter(NAMESPACE_ADAPTER);
+ }
+
+
+ protected AnnotationElementAdapter<String> buildAnnotationElementAdapter(
+ DeclarationAnnotationElementAdapter<String> daea) {
+
+ return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.attributeFormDefault = buildAttributeFormDefault(astRoot);
+ this.elementFormDefault = buildElementFormDefault(astRoot);
+ this.location = buildLocation(astRoot);
+ this.namespace = buildNamespace(astRoot);
+ AnnotationContainerTools.initialize(this.xmlnsContainer, astRoot);
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ syncAttributeFormDefault(buildAttributeFormDefault(astRoot));
+ syncElementFormDefault(buildElementFormDefault(astRoot));
+ syncLocation(buildLocation(astRoot));
+ syncNamespace(buildNamespace(astRoot));
+ AnnotationContainerTools.synchronize(this.xmlnsContainer, astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.namespace);
+ }
+
+
+ // **************** attribute form default ********************************
+
+ public XmlNsForm getAttributeFormDefault() {
+ return this.attributeFormDefault;
+ }
+
+ public void setAttributeFormDefault(XmlNsForm attributeFormDefault) {
+ if (attributeValueHasChanged(this.attributeFormDefault, attributeFormDefault)) {
+ this.attributeFormDefault = attributeFormDefault;
+ this.attributeFormDefaultAdapter.setValue(XmlNsForm.toJavaAnnotationValue(attributeFormDefault));
+ }
+ }
+
+ private XmlNsForm buildAttributeFormDefault(CompilationUnit astRoot) {
+ return XmlNsForm.fromJavaAnnotationValue(this.attributeFormDefaultAdapter.getValue(astRoot));
+ }
+
+ private void syncAttributeFormDefault(XmlNsForm attributeFormDefault) {
+ XmlNsForm old = this.attributeFormDefault;
+ this.attributeFormDefault = attributeFormDefault;
+ firePropertyChanged(ATTRIBUTE_FORM_DEFAULT_PROPERTY, old, attributeFormDefault);
+ }
+
+ public TextRange getAttributeFormDefaultTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(ATTRIBUTE_FORM_DEFAULT_ADAPTER, astRoot);
+ }
+
+
+ // **************** element form default ********************************
+
+ public XmlNsForm getElementFormDefault() {
+ return this.elementFormDefault;
+ }
+
+ public void setElementFormDefault(XmlNsForm elementFormDefault) {
+ if (attributeValueHasChanged(this.elementFormDefault, elementFormDefault)) {
+ this.elementFormDefault = elementFormDefault;
+ this.elementFormDefaultAdapter.setValue(XmlNsForm.toJavaAnnotationValue(elementFormDefault));
+ }
+ }
+
+ private XmlNsForm buildElementFormDefault(CompilationUnit astRoot) {
+ return XmlNsForm.fromJavaAnnotationValue(this.elementFormDefaultAdapter.getValue(astRoot));
+ }
+
+ private void syncElementFormDefault(XmlNsForm elementFormDefault) {
+ XmlNsForm old = this.elementFormDefault;
+ this.elementFormDefault = elementFormDefault;
+ firePropertyChanged(ELEMENT_FORM_DEFAULT_PROPERTY, old, elementFormDefault);
+ }
+
+ public TextRange getElementFormDefaultTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(ELEMENT_FORM_DEFAULT_ADAPTER, astRoot);
+ }
+
+
+ // **************** location **********************************************
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ public void setLocation(String location) {
+ if (attributeValueHasChanged(this.location, location)) {
+ this.location = location;
+ this.locationAdapter.setValue(location);
+ }
+ }
+
+ private String buildLocation(CompilationUnit astRoot) {
+ return this.locationAdapter.getValue(astRoot);
+ }
+
+ private void syncLocation(String location) {
+ String old = this.location;
+ this.location = location;
+ firePropertyChanged(LOCATION_PROPERTY, old, location);
+ }
+
+ public TextRange getLocationTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(LOCATION_ADAPTER, astRoot);
+ }
+
+
+ // **************** namespace *********************************************
+
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ if (attributeValueHasChanged(this.namespace, namespace)) {
+ this.namespace = namespace;
+ this.namespaceAdapter.setValue(namespace);
+ }
+ }
+
+ private String buildNamespace(CompilationUnit astRoot) {
+ return this.namespaceAdapter.getValue(astRoot);
+ }
+
+ private void syncNamespace(String namespace) {
+ String old = this.namespace;
+ this.namespace = namespace;
+ firePropertyChanged(NAMESPACE_PROPERTY, old, namespace);
+ }
+
+ public TextRange getNamespaceTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(NAMESPACE_ADAPTER, astRoot);
+ }
+
+
+ // **************** xmlns *************************************************
+
+ public ListIterable<XmlNsAnnotation> getXmlns() {
+ return new LiveCloneListIterable<XmlNsAnnotation>(this.xmlns);
+ }
+
+ public int getXmlnsSize() {
+ return this.xmlns.size();
+ }
+
+ public XmlNsAnnotation xmlnsAt(int index) {
+ return this.xmlns.get(index);
+ }
+
+ public XmlNsAnnotation addXmlns(int index) {
+ return (XmlNsAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.xmlnsContainer);
+ }
+
+ protected XmlNsAnnotation addXmlns_() {
+ return addXmlns_(this.xmlns.size());
+ }
+
+ protected XmlNsAnnotation addXmlns_(int index) {
+ XmlNsAnnotation xmlns = buildXmlns(index);
+ this.xmlns.add(index, xmlns);
+ return xmlns;
+ }
+
+ private XmlNsAnnotation buildXmlns(int index) {
+ return new SourceXmlNsAnnotation(
+ this, this.annotatedElement, buildXmlnsIndexedDeclarationAnnotationAdapter(index));
+ }
+
+ private IndexedDeclarationAnnotationAdapter buildXmlnsIndexedDeclarationAnnotationAdapter(int index) {
+ return new NestedIndexedDeclarationAnnotationAdapter(
+ this.daa, JAXB.XML_SCHEMA__XMLNS, index, JAXB.XML_NS, false);
+ }
+
+ protected void syncAddXmlns(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
+ int index = this.xmlns.size();
+ XmlNsAnnotation xmlns = addXmlns(index);
+ xmlns.initialize((CompilationUnit) astAnnotation.getRoot());
+ this.fireItemAdded(XMLNS_LIST, index, xmlns);
+ }
+
+ public void moveXmlns(int targetIndex, int sourceIndex) {
+ AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.xmlnsContainer);
+ }
+
+ protected XmlNsAnnotation moveXmlns_(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.xmlns, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ public void removeXmlns(int index) {
+ AnnotationContainerTools.removeNestedAnnotation(index, this.xmlnsContainer);
+ }
+
+ protected XmlNsAnnotation removeXmlns_(int index) {
+ return this.xmlns.remove(index);
+ }
+
+ protected void syncRemoveXmlns(int index) {
+ this.removeItemsFromList(index, this.xmlns, XMLNS_LIST);
+ }
+
+ /**
+ * adapt the AnnotationContainer interface to the xml schema's xmlns
+ */
+ class XmlnsAnnotationContainer
+ implements AnnotationContainer<XmlNsAnnotation>
+ {
+ public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) {
+ return SourceXmlSchemaAnnotation.this.getAstAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return JAXB.XML_SCHEMA__XMLNS;
+ }
+
+ public String getNestedAnnotationName() {
+ return JAXB.XML_NS;
+ }
+
+ public Iterable<XmlNsAnnotation> getNestedAnnotations() {
+ return SourceXmlSchemaAnnotation.this.getXmlns();
+ }
+
+ public int getNestedAnnotationsSize() {
+ return SourceXmlSchemaAnnotation.this.getXmlnsSize();
+ }
+
+ public XmlNsAnnotation addNestedAnnotation() {
+ return SourceXmlSchemaAnnotation.this.addXmlns_();
+ }
+
+ public void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
+ SourceXmlSchemaAnnotation.this.syncAddXmlns(astAnnotation);
+ }
+
+ public XmlNsAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) {
+ return SourceXmlSchemaAnnotation.this.moveXmlns_(targetIndex, sourceIndex);
+ }
+
+ public XmlNsAnnotation removeNestedAnnotation(int index) {
+ return SourceXmlSchemaAnnotation.this.removeXmlns_(index);
+ }
+
+ public void syncRemoveNestedAnnotations(int index) {
+ SourceXmlSchemaAnnotation.this.syncRemoveXmlns(index);
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java
index 3493ce8bfa..fe3748e56b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JAXB.java
@@ -112,19 +112,19 @@ public interface JAXB {
String XML_ROOT_ELEMENT__NAME = "name";
String XML_ROOT_ELEMENT__NAMESPACE = "namespace";
- String XML_SCHEMA = PACKAGE + "XmlSchema";
+ String XML_SCHEMA = PACKAGE_ + "XmlSchema";
String XML_SCHEMA__ATTRIBUTE_FORM_DEFAULT = "attributeFormDefault";
String XML_SCHEMA__ELEMENT_FORM_DEFAULT = "elementFormDefault";
String XML_SCHEMA__LOCATION = "location";
String XML_SCHEMA__NAMESPACE = "namespace";
String XML_SCHEMA__XMLNS = "xmlns";
- String XML_SCHEMA_TYPE = PACKAGE + "XmlSchemaType";
+ String XML_SCHEMA_TYPE = PACKAGE_ + "XmlSchemaType";
String XML_SCHEMA_TYPE__NAME = "name";
String XML_SCHEMA_TYPE__NAMESPACE = "namespace";
String XML_SCHEMA_TYPE__TYPE = "type";
- String XML_SCHEMA_TYPES = PACKAGE + "XmlSchemaTypes";
+ String XML_SCHEMA_TYPES = PACKAGE_ + "XmlSchemaTypes";
String XML_SCHEMA_TYPES__VALUE = "value";
String XML_SEE_ALSO = PACKAGE_ + "XmlSeeAlso";
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java
index 6e4e76c18f..c467d4a29b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlNsAnnotation.java
@@ -10,7 +10,7 @@
package org.eclipse.jpt.jaxb.core.resource.java;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
/**
@@ -27,7 +27,7 @@ import org.eclipse.jpt.core.utility.TextRange;
* @since 3.0
*/
public interface XmlNsAnnotation
- extends Annotation {
+ extends NestableAnnotation {
String ANNOTATION_NAME = JAXB.XML_NS;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaAnnotation.java
index f33d928839..c874a8f022 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlSchemaAnnotation.java
@@ -121,14 +121,14 @@ public interface XmlSchemaAnnotation
int getXmlnsSize();
/**
- * Corresponds to the 'xmlns' element of the XmlSchema annotation.
+ * Corresponds to the 'xmlns' element of the XmlSchema annnotation.
*/
- void addXmlns(XmlNsAnnotation xmlns);
+ XmlNsAnnotation xmlnsAt(int index);
/**
* Corresponds to the 'xmlns' element of the XmlSchema annotation.
*/
- void addXmlns(int index, XmlNsAnnotation xmlns);
+ XmlNsAnnotation addXmlns(int index);
/**
* Corresponds to the 'xmlns' element of the XmlSchema annotation.
@@ -138,10 +138,5 @@ public interface XmlSchemaAnnotation
/**
* Corresponds to the 'xmlns' element of the XmlSchema annotation.
*/
- void removeXmlns(XmlNsAnnotation xmlns);
-
- /**
- * Corresponds to the 'xmlns' element of the XmlSchema annotation.
- */
void removeXmlns(int index);
}

Back to the top