diff options
author | kmoore | 2011-02-15 22:39:54 +0000 |
---|---|---|
committer | kmoore | 2011-02-15 22:39:54 +0000 |
commit | 542105a7f2293bad776fcea3c48a6691300c2b11 (patch) | |
tree | 0b037c3dc6df708942c2b80c9db5bb93903785b5 /jaxb/plugins | |
parent | 19af78230ff2c9ae094f0efebe1cc408e589fc24 (diff) | |
download | webtools.dali-542105a7f2293bad776fcea3c48a6691300c2b11.tar.gz webtools.dali-542105a7f2293bad776fcea3c48a6691300c2b11.tar.xz webtools.dali-542105a7f2293bad776fcea3c48a6691300c2b11.zip |
336388 - added preliminary JaxbTransientType support to the JAXB context
Diffstat (limited to 'jaxb/plugins')
15 files changed, 336 insertions, 43 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java index da31a03054..774cbfeb48 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java @@ -25,6 +25,7 @@ import org.eclipse.jpt.jaxb.core.context.JaxbPersistentField; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentProperty; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType; import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; +import org.eclipse.jpt.jaxb.core.context.JaxbTransientType; import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping; import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping; import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping; @@ -108,6 +109,8 @@ public interface JaxbFactory { JaxbPackageInfo buildJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage); JaxbRegistry buildRegistry(JaxbContextRoot parent, JavaResourceType resourceType); + + JaxbTransientType buildJavaTransientType(JaxbContextRoot parent, JavaResourceType resourceType); JaxbPersistentClass buildJavaPersistentClass(JaxbContextRoot parent, JavaResourceType resourceType); diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java index f5394b3a3c..c18c160de4 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextRoot.java @@ -99,8 +99,23 @@ public interface JaxbContextRoot * (There should typically be a max of 1, but there are invalid states ...) */ Iterable<JaxbRegistry> getRegistries(JaxbPackage jaxbPackage); - - + + /** + * The set of transient types. + */ + Iterable<JaxbTransientType> getTransientTypes(); + + /** + * Return the set of transient types that are in the given package + */ + Iterable<JaxbTransientType> getTransientTypes(JaxbPackage jaxbPackage); + + /** + * Return the transient type with the given fully qualified name + */ + JaxbTransientType getTransientType(String fullyQualifiedTypeName); + + // **************** validation ******************************************** /** diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTransientType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTransientType.java new file mode 100644 index 0000000000..c18a008dea --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbTransientType.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.context; + +/** + * Represents a transient JAXB type + * (A class with an explicit @XmlTransient annotation) + * <p> + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 3.0 + * @since 3.0 + */ +public interface JaxbTransientType extends JaxbType { + +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java index a38b3235eb..f78ca625ac 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java @@ -94,6 +94,11 @@ public interface JaxbType /** * A JaxbType of {@link Kind} REGISTRY may safely be cast as a {@link JaxbRegistry} */ - REGISTRY + REGISTRY, + + /** + * A JaxbType of {@link Kind} REGISTRY may safely be cast as a {@link JaxbTransientType} + */ + TRANSIENT } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java index 1061c9ab38..f65eb91a8c 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java @@ -29,6 +29,7 @@ import org.eclipse.jpt.jaxb.core.context.JaxbPersistentField; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentProperty; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentType; import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; +import org.eclipse.jpt.jaxb.core.context.JaxbTransientType; import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping; import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping; import org.eclipse.jpt.jaxb.core.context.XmlAttributeMapping; @@ -48,6 +49,7 @@ import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentEnum import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentField; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentProperty; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaRegistry; +import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaTransientType; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyAttributeMapping; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyElementMapping; import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAttributeMapping; @@ -110,6 +112,10 @@ public abstract class AbstractJaxbFactory return new GenericJavaRegistry(parent, resourceType); } + public JaxbTransientType buildJavaTransientType(JaxbContextRoot parent, JavaResourceType resourceType) { + return new GenericJavaTransientType(parent, resourceType); + } + public JaxbPersistentClass buildJavaPersistentClass(JaxbContextRoot parent, JavaResourceType resourceType) { return new GenericJavaPersistentClass(parent, resourceType); } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericContextRoot.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericContextRoot.java index 4ebf6c4991..05d7ed4c64 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericContextRoot.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericContextRoot.java @@ -28,6 +28,7 @@ import org.eclipse.jpt.jaxb.core.context.JaxbPackage; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum; import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; +import org.eclipse.jpt.jaxb.core.context.JaxbTransientType; import org.eclipse.jpt.jaxb.core.context.JaxbType; import org.eclipse.jpt.jaxb.core.context.JaxbType.Kind; import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType; @@ -82,6 +83,8 @@ public class GenericContextRoot // (registries can be determined purely by resource model) final Set<JavaResourceType> registries = calculateRegistries(); + final Set<JavaResourceType> initialTransientClasses = calculateInitialTransientClasses(); + // determine initial set of persistent classes // (persistent classes that can be determined purely by resource model) final Set<JavaResourceType> initialPersistentClasses = calculateInitialPersistentClasses(); @@ -89,6 +92,7 @@ public class GenericContextRoot final Set<JavaResourceEnum> initialPersistentEnums = calculateInitialPersistentEnums(); final Set<AbstractJavaResourceType> initialTypes = new HashSet<AbstractJavaResourceType>(registries); + initialTypes.addAll(initialTransientClasses); initialTypes.addAll(initialPersistentClasses); initialTypes.addAll(initialPersistentEnums); @@ -103,6 +107,10 @@ public class GenericContextRoot this.types.put(resourceType.getName(), buildRegistry(resourceType)); } + for (JavaResourceType resourceType : initialTransientClasses) { + this.types.put(resourceType.getName(), buildTransientType(resourceType)); + } + for (JavaResourceType resourceType : initialPersistentClasses) { this.types.put(resourceType.getName(), buildPersistentClass(resourceType)); } @@ -126,6 +134,8 @@ public class GenericContextRoot // (registries can be determined purely by resource model) final Set<JavaResourceType> registries = calculateRegistries(); + final Set<JavaResourceType> initialTransientClasses = calculateInitialTransientClasses(); + // determine initial set of persistent classes // (persistent classes that can be determined purely by resource model) final Set<JavaResourceType> initialPersistentClasses = calculateInitialPersistentClasses(); @@ -134,6 +144,7 @@ public class GenericContextRoot final Set<AbstractJavaResourceType> initialTypes = new HashSet<AbstractJavaResourceType>(registries); initialTypes.addAll(initialPersistentClasses); initialTypes.addAll(initialPersistentEnums); + initialTypes.addAll(initialTransientClasses); // determine initial set of packages final Set<String> initialPackages = calculateInitialPackageNames(initialTypes); @@ -170,6 +181,23 @@ public class GenericContextRoot } } + for (JavaResourceType resourceType : initialTransientClasses) { + String className = resourceType.getQualifiedName(); + typesToRemove.remove(className); + if (this.types.containsKey(className)) { + if (this.types.get(className).getKind() == Kind.TRANSIENT) { + typesToUpdate.add(className); + } + else { + this.removeType(className); // this will remove a type of another kind + this.addType(buildTransientType(resourceType)); + } + } + else { + this.addType(buildTransientType(resourceType)); + } + } + for (JavaResourceType resourceType : initialPersistentClasses) { String className = resourceType.getQualifiedName(); typesToRemove.remove(className); @@ -244,6 +272,23 @@ public class GenericContextRoot } /* + * Calculate set of transient types, those annotated with @XmlTransient. + * If an type annotated with @XmlTransient also contains other JAXB annotations, + * this will be a validation error + */ + protected Set<JavaResourceType> calculateInitialTransientClasses() { + return CollectionTools.set( + new FilteringIterable<JavaResourceType>( + getJaxbProject().getJavaSourceResourceTypes()) { + @Override + protected boolean accept(JavaResourceType o) { + return o.getAnnotation(JAXB.XML_TRANSIENT) != null + && o.getAnnotation(JAXB.XML_REGISTRY) == null; + } + }); + } + + /* * Calculate set of persistent classes that can be determined purely by resource model * (so far, this should be all resource types with the @XmlType annotation) * If both @XmlType and @XmlRegistry exist on a class, we will let @XmlRegistry take precedence @@ -254,7 +299,9 @@ public class GenericContextRoot getJaxbProject().getJavaSourceResourceTypes()) { @Override protected boolean accept(JavaResourceType o) { - return o.getAnnotation(JAXB.XML_TYPE) != null && o.getAnnotation(JAXB.XML_REGISTRY) == null && o.getAnnotation(JAXB.XML_ENUM) == null; + return o.getAnnotation(JAXB.XML_TYPE) != null + && o.getAnnotation(JAXB.XML_REGISTRY) == null + && o.getAnnotation(JAXB.XML_TRANSIENT) == null; } }); } @@ -270,7 +317,9 @@ public class GenericContextRoot getJaxbProject().getJavaSourceResourceEnums()) { @Override protected boolean accept(JavaResourceEnum o) { - return ((o.getAnnotation(JAXB.XML_ENUM) != null) || (o.getAnnotation(JAXB.XML_TYPE) != null)) && o.getAnnotation(JAXB.XML_REGISTRY) == null; + return ((o.getAnnotation(JAXB.XML_ENUM) != null) || (o.getAnnotation(JAXB.XML_TYPE) != null)) + && o.getAnnotation(JAXB.XML_REGISTRY) == null + && o.getAnnotation(JAXB.XML_TRANSIENT) == null; } }); } @@ -425,8 +474,42 @@ public class GenericContextRoot } }; } + + + // ********** transient types ********** + public Iterable<JaxbTransientType> getTransientTypes() { + return new SubIterableWrapper<JaxbType, JaxbTransientType>( + new FilteringIterable<JaxbType>(getTypes()) { + @Override + protected boolean accept(JaxbType o) { + return o.getKind() == Kind.TRANSIENT; + } + }); + } + protected JaxbTransientType buildTransientType(JavaResourceType resourceType) { + return this.getFactory().buildJavaTransientType(this, resourceType); + } + + public Iterable<JaxbTransientType> getTransientTypes(final JaxbPackage jaxbPackage) { + return new FilteringIterable<JaxbTransientType>(getTransientTypes()) { + @Override + protected boolean accept(JaxbTransientType o) { + return o.getPackageName().equals(jaxbPackage.getName()); + } + }; + } + + public JaxbTransientType getTransientType(String className) { + for (JaxbTransientType jaxbClass : this.getTransientTypes()) { + if (StringTools.stringsAreEqual(jaxbClass.getFullyQualifiedName(), className)) { + return jaxbClass; + } + } + return null; + } + // ********** persistent classes ********** public Iterable<JaxbPersistentClass> getPersistentClasses() { diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientType.java new file mode 100644 index 0000000000..ef2d3c99a7 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaTransientType.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.core.internal.context.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.common.core.utility.TextRange; +import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; +import org.eclipse.jpt.jaxb.core.context.JaxbTransientType; +import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType; +import org.eclipse.jpt.jaxb.core.resource.java.XmlTransientAnnotation; + + +public class GenericJavaTransientType + extends AbstractJavaType + implements JaxbTransientType { + + + public GenericJavaTransientType(JaxbContextRoot parent, JavaResourceType resourceType) { + super(parent, resourceType); + } + + @Override + public JavaResourceType getJavaResourceType() { + return (JavaResourceType) super.getJavaResourceType(); + } + + // ********** synchronize/update ********** + + public void synchronizeWithResourceModel() { + } + + public void update() { + } + + + // ********** xml transient annotation ********** + + protected XmlTransientAnnotation getXmlTransientAnnotation() { + return (XmlTransientAnnotation) this.getJavaResourceType().getNonNullAnnotation(XmlTransientAnnotation.ANNOTATION_NAME); + } + + + // ********** JaxbType impl ********** + + public Kind getKind() { + return Kind.TRANSIENT; + } + + + // **************** validation ******************************************** + + @Override + public TextRange getValidationTextRange(CompilationUnit astRoot) { + return getXmlTransientAnnotation().getTextRange(astRoot); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/registry.gif b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/registry.gif Binary files differnew file mode 100644 index 0000000000..baac236770 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/icons/full/obj16/registry.gif diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java index f5667f9e26..13cc8458a0 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiIcons.java @@ -20,6 +20,7 @@ public class JptJaxbUiIcons public static final String PERSISTENT_CLASS = "full/obj16/persistent_class"; public static final String PERSISTENT_ENUM = "full/obj16/persistent_enum"; public static final String TRANSIENT_CLASS = "full/obj16/transient_class"; + public static final String REGISTRY = "full/obj16/registry"; public static final String PERSISTENT_FIELD = "full/obj16/persistent_field"; public static final String PERSISTENT_PROPERTY = "full/obj16/persistent_property"; diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java index f943f3db3a..12ddba7c75 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/GenericJaxb_2_1_NavigatorItemLabelProviderFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * Copyright (c) 2010, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -15,10 +15,12 @@ import org.eclipse.jpt.common.ui.jface.ItemLabelProviderFactory; import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot; import org.eclipse.jpt.jaxb.core.context.JaxbEnumConstant; import org.eclipse.jpt.jaxb.core.context.JaxbPackage; +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentEnum; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentField; import org.eclipse.jpt.jaxb.core.context.JaxbPersistentProperty; -import org.eclipse.jpt.jaxb.core.context.JaxbType; +import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; +import org.eclipse.jpt.jaxb.core.context.JaxbTransientType; public class GenericJaxb_2_1_NavigatorItemLabelProviderFactory @@ -50,11 +52,17 @@ public class GenericJaxb_2_1_NavigatorItemLabelProviderFactory else if (item instanceof JaxbPackage) { return new JaxbPackageItemLabelProvider((JaxbPackage) item, contentAndLabelProvider); } + else if (item instanceof JaxbRegistry) { + return new JaxbRegistryItemLabelProvider((JaxbRegistry) item, contentAndLabelProvider); + } + else if (item instanceof JaxbPersistentClass) { + return new JaxbPersistentClassItemLabelProvider((JaxbPersistentClass) item, contentAndLabelProvider); + } else if (item instanceof JaxbPersistentEnum) { return new JaxbPersistentEnumItemLabelProvider((JaxbPersistentEnum) item, contentAndLabelProvider); } - else if (item instanceof JaxbType) { - return new JaxbTypeItemLabelProvider((JaxbType) item, contentAndLabelProvider); + else if (item instanceof JaxbTransientType) { + return new JaxbTransientTypeItemLabelProvider((JaxbTransientType) item, contentAndLabelProvider); } else if (item instanceof JaxbPersistentField) { return new JaxbPersistentFieldItemLabelProvider((JaxbPersistentField) item, contentAndLabelProvider); diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java new file mode 100644 index 0000000000..d13e1c3664 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentClassItemLabelProvider.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2010, 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.ui.internal.jaxb21; + +import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; +import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; +import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass; +import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; +import org.eclipse.swt.graphics.Image; + + +public class JaxbPersistentClassItemLabelProvider + extends JaxbTypeItemLabelProvider { + + public JaxbPersistentClassItemLabelProvider( + JaxbPersistentClass jaxbPersistentClass, DelegatingContentAndLabelProvider labelProvider) { + + super(jaxbPersistentClass, labelProvider); + } + + @Override + protected PropertyValueModel<Image> buildImageModel() { + return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_CLASS)); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java index 08d0114d95..36e6c40455 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbPersistentEnumItemLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * Copyright (c) 2010, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -9,7 +9,6 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.ui.internal.jaxb21; -import org.eclipse.jpt.common.ui.internal.jface.AbstractItemLabelProvider; import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; @@ -20,7 +19,7 @@ import org.eclipse.swt.graphics.Image; public class JaxbPersistentEnumItemLabelProvider - extends AbstractItemLabelProvider { + extends JaxbTypeItemLabelProvider { public JaxbPersistentEnumItemLabelProvider( JaxbPersistentEnum jaxbEnum, DelegatingContentAndLabelProvider labelProvider) { @@ -29,23 +28,7 @@ public class JaxbPersistentEnumItemLabelProvider } @Override - public JaxbPersistentEnum model() { - return (JaxbPersistentEnum) super.model(); - } - - @Override protected PropertyValueModel<Image> buildImageModel() { return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_ENUM)); } - - @Override - protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel(model().getTypeQualifiedName()); - } - - @Override - protected PropertyValueModel<String> buildDescriptionModel() { - return new StaticPropertyValueModel( - model().getFullyQualifiedName() + " - " + model().getResource().getFullPath().makeRelative()); - } } diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java new file mode 100644 index 0000000000..4d897515e1 --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbRegistryItemLabelProvider.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.ui.internal.jaxb21; + +import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; +import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; +import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.jaxb.core.context.JaxbRegistry; +import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; +import org.eclipse.swt.graphics.Image; + + +public class JaxbRegistryItemLabelProvider + extends JaxbTypeItemLabelProvider { + + public JaxbRegistryItemLabelProvider( + JaxbRegistry jaxbRegistry, DelegatingContentAndLabelProvider labelProvider) { + + super(jaxbRegistry, labelProvider); + } + + @Override + protected PropertyValueModel<Image> buildImageModel() { + return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.REGISTRY)); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientTypeItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientTypeItemLabelProvider.java new file mode 100644 index 0000000000..a699bcf74c --- /dev/null +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTransientTypeItemLabelProvider.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.jaxb.ui.internal.jaxb21; + +import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; +import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; +import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.jaxb.core.context.JaxbTransientType; +import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; +import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; +import org.eclipse.swt.graphics.Image; + + +public class JaxbTransientTypeItemLabelProvider + extends JaxbTypeItemLabelProvider { + + public JaxbTransientTypeItemLabelProvider( + JaxbTransientType jaxbTransientType, DelegatingContentAndLabelProvider labelProvider) { + + super(jaxbTransientType, labelProvider); + } + + @Override + protected PropertyValueModel<Image> buildImageModel() { + return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.TRANSIENT_CLASS)); + } +} diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java index 2e64650d86..20dac55e72 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/jaxb21/JaxbTypeItemLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * Copyright (c) 2010, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -14,36 +14,33 @@ import org.eclipse.jpt.common.ui.jface.DelegatingContentAndLabelProvider; import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel; import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; import org.eclipse.jpt.jaxb.core.context.JaxbType; -import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; -import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; -import org.eclipse.swt.graphics.Image; -public class JaxbTypeItemLabelProvider +public abstract class JaxbTypeItemLabelProvider extends AbstractItemLabelProvider { - public JaxbTypeItemLabelProvider( + protected JaxbTypeItemLabelProvider( JaxbType jaxbType, DelegatingContentAndLabelProvider labelProvider) { super(jaxbType, labelProvider); } - - @Override - protected PropertyValueModel<Image> buildImageModel() { - return new StaticPropertyValueModel<Image>(JptJaxbUiPlugin.getImage(JptJaxbUiIcons.PERSISTENT_CLASS)); + public JaxbType model() { + return (JaxbType) super.model(); } - + @Override protected PropertyValueModel<String> buildTextModel() { - return new StaticPropertyValueModel(((JaxbType) model()).getTypeQualifiedName()); + return new StaticPropertyValueModel<String>(model().getTypeQualifiedName()); } @Override protected PropertyValueModel<String> buildDescriptionModel() { - JaxbType type = (JaxbType) model(); - return new StaticPropertyValueModel( - type.getFullyQualifiedName() + " - " + type.getResource().getFullPath().makeRelative()); + StringBuilder sb = new StringBuilder(); + sb.append(model().getFullyQualifiedName()); + sb.append(" - "); //$NON-NLS-1$ + sb.append(model().getResource().getFullPath().makeRelative()); + return new StaticPropertyValueModel<String>(sb.toString()); } } |