Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 191786 Details for
Bug 325364
Annotation Properties view should resolve annotation classes from project classpath
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
annotations view patch
annotation_type_patch.txt (text/plain), 169.45 KB, created by
Shane Clarke
on 2011-03-23 15:20:02 EDT
(
hide
)
Description:
annotations view patch
Filename:
MIME Type:
Creator:
Shane Clarke
Created:
2011-03-23 15:20:02 EDT
Size:
169.45 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.ws.annotations.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Mar 2010 22:06:21 -0000 1.5 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:00 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName > Bundle-SymbolicName: org.eclipse.jst.ws.annotations.core;singleton:=true >-Bundle-Version: 1.0.0.qualifier >+Bundle-Version: 1.1.0.qualifier > Bundle-Localization: plugin > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-Vendor: %pluginProvider >@@ -18,6 +18,7 @@ > Export-Package: org.eclipse.jst.ws.annotations.core, > org.eclipse.jst.ws.annotations.core.initialization, > org.eclipse.jst.ws.annotations.core.processor, >- org.eclipse.jst.ws.annotations.core.utils >+ org.eclipse.jst.ws.annotations.core.utils, >+ org.eclipse.jst.ws.internal.annotations.core.utils;x-friends:="org.eclipse.jst.ws.jaxws.ui" > Bundle-Activator: org.eclipse.jst.ws.annotations.core.AnnotationsCorePlugin > Bundle-ActivationPolicy: lazy >Index: src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java,v >retrieving revision 1.7 >diff -u -r1.7 AnnotationDefinition.java >--- src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java 4 Nov 2009 22:06:51 -0000 1.7 >+++ src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java 23 Mar 2011 19:10:00 -0000 >@@ -19,6 +19,11 @@ > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.jdt.core.IAnnotation; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IMemberValuePair; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer; > > /** >@@ -46,8 +51,8 @@ > private static final String RESTRICTED_TO_INTERFACE_ONLY = "INTERFACE_ONLY"; > private static final String RESTRICTED_TO_ENUM_ONLY = "ENUM_ONLY"; > >- private static final String ELEM_TARGET_FILTER = "targetFilter"; //$NON-NLS-1$ >- private static final String ATT_TARGET = "target"; //$NON-NLS-1$ >+ private static final String ELEM_TARGET_FILTER = "targetFilter"; //$NON-NLS-1$ >+ private static final String ATT_TARGET = "target"; //$NON-NLS-1$ > > private IConfigurationElement configurationElement; > private String category; >@@ -61,6 +66,11 @@ > private boolean classOnly; > private boolean enumOnly; > >+ private IType annotationType; >+ private List<ElementType> annotationTypeTargets; >+ private IJavaProject javaProject; >+ private Boolean deprecated; >+ > /** > * Constructs an <code>AnnotationDefinition</code> using information from the > * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> extension point and category name. >@@ -133,16 +143,17 @@ > * <code>annotation<annotation> element in the <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> > * extension point. > * >- * @return the annotation class >+ * @return the annotation class or null if not found. >+ * @deprecated As of 1.1 replaced by {@link #getAnnotationType()} > */ > @SuppressWarnings("unchecked") >+ @Deprecated > public Class<? extends java.lang.annotation.Annotation> getAnnotationClass() { > if (annotationClass == null) { > try { > Class<?> aClass = Class.forName(annotationClassName); > if (aClass.isAnnotation()) { >- annotationClass = (Class<java.lang.annotation.Annotation>)Class.forName( >- annotationClassName); >+ annotationClass = (Class<java.lang.annotation.Annotation>) Class.forName(annotationClassName); > } > } catch(ClassNotFoundException cnfe) { > AnnotationsCorePlugin.log(cnfe); >@@ -152,6 +163,33 @@ > } > > /** >+ * Returns the annotation type as specified by the <code>class</code> attribute of the >+ * <code>annotation<annotation> element in the <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> >+ * extension point. >+ * >+ * @return the <code>org.eclipse.jdt.core.IType</code> which represents an annotation type or null if the java project >+ * has not been set, if the type cannot be found or if the type does not represent an annotation type. >+ * >+ * @see #setJavaProject(IJavaProject) >+ * @since 1.1 >+ */ >+ public IType getAnnotationType() { >+ if (annotationType == null) { >+ try { >+ if (javaProject != null) { >+ IType type = javaProject.findType(annotationClassName); >+ if (type != null && type.isAnnotation()) { >+ annotationType = type; >+ } >+ } >+ } catch (JavaModelException jme) { >+ AnnotationsCorePlugin.log(jme.getStatus()); >+ } >+ } >+ return annotationType; >+ } >+ >+ /** > * Returns a list of {@link ElementType} that specify the Java elements to which the annotation > * can be applied. > * <p> >@@ -162,28 +200,80 @@ > * the annotation. > * </p> > * @return a list of element types. >+ * @deprecated as of 1.1 replaced by {@link #getAnnotationTypeTargets()} > */ >+ @Deprecated > public List<ElementType> getTargets() { > if (targets == null) { >- targets = new LinkedList<ElementType>(); >+ targets = new LinkedList<ElementType>(); > > Class<? extends java.lang.annotation.Annotation> annotation = getAnnotationClass(); > if (annotation != null) { >- Target target = annotation.getAnnotation(Target.class); >- if (target != null) { >- targets.addAll(Arrays.asList(target.value())); >+ Target target = annotation.getAnnotation(Target.class); >+ if (target != null) { >+ targets.addAll(Arrays.asList(target.value())); > > List<ElementType> filteredTargets = getFilteredTargets(configurationElement); > if (targets.containsAll(filteredTargets) && filteredTargets.size() < targets.size()) { > targets.removeAll(filteredTargets); > } >- } >+ } > } > } > return targets; > } > > /** >+ * Returns a list of {@link ElementType} that specify the Java elements to which the annotation can be applied. >+ * <p> >+ * The element types are retrieved from the annotations >+ * {@link java.lang.annotation.Target} meta-annotation type. This list can >+ * be filtered using the <code>targetFilter</code> element on the >+ * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> >+ * extension point when defining the annotation. >+ * </p> >+ * @return a list of element types or null if the java project has not been set or if the annotation type cannot be >+ * found. >+ * @see #setJavaProject(IJavaProject) >+ * @since 1.1 >+ */ >+ public List<ElementType> getAnnotationTypeTargets() { >+ if (annotationTypeTargets == null) { >+ annotationTypeTargets = new LinkedList<ElementType>(); >+ try { >+ IType type = getAnnotationType(); >+ if (type != null) { >+ IAnnotation target = type.getAnnotation(Target.class.getCanonicalName()); >+ if (!target.exists()) { >+ target = type.getAnnotation(Target.class.getSimpleName()); >+ } >+ if (target.exists()) { >+ IMemberValuePair[] memberValuePairs = target.getMemberValuePairs(); >+ for (IMemberValuePair memberValuePair : memberValuePairs) { >+ Object value = memberValuePair.getValue(); >+ if (value.getClass().isArray() && value.getClass().getComponentType().equals(String.class)) { >+ String[] objs = (String[]) value; >+ for (String obj : objs) { >+ annotationTypeTargets.add(ElementType.valueOf(obj.substring(obj.lastIndexOf('.') + 1))); >+ } >+ } else { >+ annotationTypeTargets.add(ElementType.valueOf(value.toString().substring(value.toString().lastIndexOf('.') + 1))); >+ } >+ } >+ } >+ List<ElementType> filteredTargets = getFilteredTargets(configurationElement); >+ if (annotationTypeTargets.containsAll(filteredTargets) && filteredTargets.size() < annotationTypeTargets.size()) { >+ annotationTypeTargets.removeAll(filteredTargets); >+ } >+ } >+ } catch (JavaModelException jme) { >+ AnnotationsCorePlugin.log(jme.getStatus()); >+ } >+ } >+ return annotationTypeTargets; >+ } >+ >+ /** > * Returns the annotations attribute initializer as specified in the > * <code>org.eclipse.jst.ws.annotations.core.annotationInitializer</code> extension point or null if no > * initializer can be found. >@@ -196,8 +286,7 @@ > IConfigurationElement configurationElement = > AnnotationsManager.getAnnotationInitializerCache().get(getAnnotationClassName()); > if (configurationElement != null) { >- annotationInitializer = (IAnnotationAttributeInitializer)configurationElement >- .createExecutableExtension(ATT_CLASS); >+ annotationInitializer = (IAnnotationAttributeInitializer)configurationElement.createExecutableExtension(ATT_CLASS); > } > } catch (CoreException ce) { > AnnotationsCorePlugin.log(ce.getStatus()); >@@ -206,17 +295,50 @@ > return annotationInitializer; > } > >- private List<ElementType> getFilteredTargets(IConfigurationElement configurationElement) { >- List<ElementType> targets = new ArrayList<ElementType>(7); >- try { >- IConfigurationElement[] deprecatedTargets = configurationElement.getChildren(ELEM_TARGET_FILTER); >- for (IConfigurationElement deprecatedTargetElement : deprecatedTargets) { >- String target = AnnotationsManager.getAttributeValue(deprecatedTargetElement, ATT_TARGET); >- targets.add(ElementType.valueOf(target)); >- } >- } catch (IllegalArgumentException iae) { >- AnnotationsCorePlugin.log(iae); >- } >- return targets; >- } >+ private List<ElementType> getFilteredTargets(IConfigurationElement configurationElement) { >+ List<ElementType> targets = new ArrayList<ElementType>(7); >+ try { >+ IConfigurationElement[] deprecatedTargets = configurationElement.getChildren(ELEM_TARGET_FILTER); >+ for (IConfigurationElement deprecatedTargetElement : deprecatedTargets) { >+ String target = AnnotationsManager.getAttributeValue(deprecatedTargetElement, ATT_TARGET); >+ targets.add(ElementType.valueOf(target)); >+ } >+ } catch (IllegalArgumentException iae) { >+ AnnotationsCorePlugin.log(iae); >+ } >+ return targets; >+ } >+ >+ boolean isDeprecated() { >+ if (deprecated == null) { >+ IType type = getAnnotationType(); >+ if (type != null) { >+ IAnnotation annotation = type.getAnnotation(Deprecated.class.getCanonicalName()); >+ if (!annotation.exists()) { >+ annotation = type.getAnnotation(Deprecated.class.getSimpleName()); >+ } >+ deprecated = annotation.exists(); >+ } else { >+ deprecated = true; >+ } >+ } >+ return deprecated; >+ } >+ >+ /** >+ * Sets the <code>org.eclipse.jdt.core.IJavaProject</code> which is used to find the >+ * annotation type. >+ * >+ * @see {@link #getAnnotationType()} >+ * @see {@link #getAnnotationTypeTargets()} >+ * @since 1.1 >+ */ >+ public void setJavaProject(IJavaProject javaProject) { >+ if (this.javaProject == null || !this.javaProject.equals(javaProject)) { >+ this.javaProject = javaProject; >+ this.annotationType = null; >+ this.annotationTypeTargets = null; >+ this.deprecated = null; >+ } >+ } > } >Index: src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java,v >retrieving revision 1.12 >diff -u -r1.12 AnnotationsCore.java >--- src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java 8 Mar 2010 21:46:27 -0000 1.12 >+++ src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java 23 Mar 2011 19:10:00 -0000 >@@ -12,6 +12,8 @@ > > import java.util.List; > >+import org.eclipse.jdt.core.IField; >+import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.ArrayInitializer; > import org.eclipse.jdt.core.dom.BooleanLiteral; >@@ -174,8 +176,10 @@ > * @param value an object representing the <code>enum</code> value. > * @return a new member value pair with the given name and value. > */ >- public static MemberValuePair createEnumMemberValuePair(AST ast, String className, String name, >- Object value) { >+ public static MemberValuePair createEnumMemberValuePair(AST ast, String className, String name, Object value) { >+ if (value instanceof IField) { >+ return AnnotationsCore.createMemberValuePair(ast, name, createEnumLiteral(ast, className, (IField) value)); >+ } > return AnnotationsCore.createMemberValuePair(ast, name, createEnumLiteral(ast, className, value)); > } > >@@ -241,7 +245,7 @@ > * > * @param ast the {@link AST} that will be used to create the qualified name. > * @param className the fully qualified name of the enclosing class. >- * @param value sn object representing the <code>enum</code> value. >+ * @param value an object representing the <code>enum</code> value. > * @return a new qualified name. > */ > public static QualifiedName createEnumLiteral(AST ast, String className, Object value) { >@@ -267,6 +271,41 @@ > } > > /** >+ * Creates a new {@link QualifiedName} to represent an <code>enum</code> literal value. >+ * >+ * @param ast the {@link AST} that will be used to create the qualified name. >+ * @param className the fully qualified name of the enclosing class. >+ * @param value a {@link org.eclipse.jdt.core.IField} where <code>isEnumConstant()</code> is <code>true</code>. >+ * @return a new qualified name. >+ * @throws JavaModelException >+ * @since 1.1 >+ */ >+ public static QualifiedName createEnumLiteral(AST ast, String className, IField enumConstant) { >+ QualifiedName enumName = null; >+ SimpleName enumClassName = ast.newSimpleName(enumConstant.getDeclaringType().getElementName()); >+ SimpleName enumLiteral = ast.newSimpleName(enumConstant.getElementName()); >+ try { >+ if (enumConstant.getDeclaringType().isMember()) { >+ Name enumEnclosingClassName = null; >+ String enclosingClassName = enumConstant.getDeclaringType().getDeclaringType().getFullyQualifiedName(); >+ if (enclosingClassName.equals(className)) { >+ enumEnclosingClassName = ast.newSimpleName(enumConstant.getDeclaringType().getDeclaringType().getElementName()); >+ } else { >+ enumEnclosingClassName = ast.newName(enclosingClassName); >+ } >+ QualifiedName qualifiedName = ast.newQualifiedName(enumEnclosingClassName, enumClassName); >+ enumName = ast.newQualifiedName(qualifiedName, enumLiteral); >+ } else { >+ Name qualifiedName = ast.newName(enumConstant.getDeclaringType().getFullyQualifiedName()); >+ enumName = ast.newQualifiedName(qualifiedName, enumLiteral); >+ } >+ } catch (JavaModelException jme) { >+ AnnotationsCorePlugin.log(jme.getStatus()); >+ } >+ return enumName; >+ } >+ >+ /** > * Creates a new {@link TypeLiteral}. > * > * @param ast the {@link AST} that will be used to create the {@link TypeLiteral}. >Index: src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java,v >retrieving revision 1.12 >diff -u -r1.12 AnnotationsManager.java >--- src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java 26 Apr 2010 21:34:45 -0000 1.12 >+++ src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java 23 Mar 2011 19:10:00 -0000 >@@ -68,9 +68,6 @@ > private static final String ATT_NAME = "name"; //$NON-NLS-1$ > private static final String ATT_CATEGORY = "category"; //$NON-NLS-1$ > >- // private static final String ELEM_TARGET_FILTER = "targetFilter"; //$NON-NLS-1$ >- // private static final String ATT_TARGET = "target"; //$NON-NLS-1$ >- > private AnnotationsManager() { > } > >@@ -102,6 +99,39 @@ > } > > /** >+ * Returns a list of all the contributed annotations that target the given {@link org.eclipse.jdt.core.IJavaElement}. >+ * >+ * @param element one of >+ * <li>org.eclipse.jdt.core.IPackageDeclaration</li> >+ * <li>org.eclipse.jdt.core.IType</li> >+ * <li>org.eclipse.jdt.core.IField</li> >+ * <li>org.eclipse.jdt.core.IMethod</li> >+ * <li>org.eclipse.jdt.core.ILocalVariable</li> >+ * >+ * @return a list of types which represent annotation types. >+ * @since 1.1 >+ */ >+ public static List<IType> getAnnotationTypes(IJavaElement javaElement) { >+ List<IType> annotations = new ArrayList<IType>(); >+ >+ try { >+ List<AnnotationDefinition> annotationDefinitions = getAllAnnotationsForElement(javaElement); >+ >+ filterAnnotationsList(javaElement, annotationDefinitions); >+ >+ for (AnnotationDefinition annotationDefinition : annotationDefinitions) { >+ IType type = annotationDefinition.getAnnotationType(); >+ if (type != null) { >+ annotations.add(type); >+ } >+ } >+ } catch (JavaModelException jme) { >+ AnnotationsCorePlugin.log(jme.getStatus()); >+ } >+ return annotations; >+ } >+ >+ /** > * Returns a list of all the contributed {@link java.lang.annotation.Annotation} that target the given java element type. > * > * @param element one of >@@ -112,7 +142,9 @@ > * <li>org.eclipse.jdt.core.ILocalVariable</li> > * > * @return a list of annotations. >+ * @deprecated As of 1.1 replaced by {@link #getAnnotationTypes(IJavaElement)}} > */ >+ @Deprecated > public static List<Class<? extends Annotation>> getAnnotations(IJavaElement javaElement) { > List<Class<? extends Annotation>> annotations = new ArrayList<Class<? extends Annotation>>(); > >@@ -131,17 +163,15 @@ > } > > private static synchronized Map<String, AnnotationDefinition> getAnnotationToClassNameDefinitionMap() { >- > if (annotationClassNameToDefinitionMap == null) { > List<AnnotationDefinition> annotationDefinitions = getAnnotations(); > > annotationClassNameToDefinitionMap = new HashMap<String, AnnotationDefinition>(); > > for (AnnotationDefinition annotationDefinition : annotationDefinitions) { >- if (annotationDefinition.getAnnotationClass() != null) { >- annotationClassNameToDefinitionMap.put(annotationDefinition.getAnnotationClass() >- .getCanonicalName(), annotationDefinition); >- } >+ if (annotationDefinition.getAnnotationClassName() != null) { >+ annotationClassNameToDefinitionMap.put(annotationDefinition.getAnnotationClassName(), annotationDefinition); >+ } > } > } > return annotationClassNameToDefinitionMap; >@@ -195,6 +225,18 @@ > } > > /** >+ * Returns the {@link AnnotationDefinition} for the given {@link org.eclipse.jdt.core.IType} >+ * or null if no annotation definition can be found. >+ * >+ * @param annotationType an <code>org.eclipse.jdt.core.IType</code> which represents an annotation type. >+ * @return the annotation definition for the <code>org.eclipse.jdt.core.IType</code>. >+ * @since 1.1 >+ */ >+ public static AnnotationDefinition getAnnotationDefinitionForType(IType annotationType) { >+ return getAnnotationToClassNameDefinitionMap().get(annotationType.getFullyQualifiedName()); >+ } >+ >+ /** > * Returns the {@link IAnnotationAttributeInitializer} for the given {@link org.eclipse.jdt.core.dom.Name} > * or null if none can be found. > * @param name a {@link SimpleName} or {@link QualifiedName} for the annotation to search for. >@@ -254,7 +296,6 @@ > if (annotationCategoryCache != null) { > return annotationCategoryCache; > } >- > annotationCategoryCache = new HashMap<String, String>(); > > IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( >@@ -274,7 +315,6 @@ > if (annotationInitializerCache != null) { > return annotationInitializerCache; > } >- > annotationInitializerCache = new HashMap<String, IConfigurationElement>(); > > IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( >@@ -326,41 +366,39 @@ > return ""; //$NON-NLS-1$ > } > >- private static List<AnnotationDefinition> getAllAnnotationsForElement(IJavaElement javaElement) >- throws JavaModelException { >- >+ private static List<AnnotationDefinition> getAllAnnotationsForElement(IJavaElement javaElement) throws JavaModelException { > if (javaElement instanceof IPackageDeclaration) { >- return getAnnotationsForElementType(ElementType.PACKAGE); >+ return getAnnotationsForElementType(javaElement, ElementType.PACKAGE); > } > > if (javaElement instanceof IType) { > IType type = (IType) javaElement; > if (type.isAnnotation()) { >- return getAnnotationsForElementType(ElementType.ANNOTATION_TYPE); >+ return getAnnotationsForElementType(javaElement, ElementType.ANNOTATION_TYPE); > } >- return getAnnotationsForElementType(ElementType.TYPE); >+ return getAnnotationsForElementType(javaElement, ElementType.TYPE); > } > > if (javaElement instanceof IField) { >- return getAnnotationsForElementType(ElementType.FIELD); >+ return getAnnotationsForElementType(javaElement, ElementType.FIELD); > } > > if (javaElement instanceof IMethod) { >- return getAnnotationsForElementType(ElementType.METHOD); >+ return getAnnotationsForElementType(javaElement, ElementType.METHOD); > } > > if (javaElement instanceof ILocalVariable) { >- return getAnnotationsForElementType(ElementType.PARAMETER); >+ return getAnnotationsForElementType(javaElement, ElementType.PARAMETER); > } > > if (javaElement instanceof IAnnotation) { >- return getAnnotationsForElementType(ElementType.ANNOTATION_TYPE); >+ return getAnnotationsForElementType(javaElement, ElementType.ANNOTATION_TYPE); > } > > return Collections.emptyList(); > } > >- private static List<AnnotationDefinition> getAnnotationsForElementType(ElementType elementType) { >+ private static List<AnnotationDefinition> getAnnotationsForElementType(IJavaElement javaElement, ElementType elementType) { > List<AnnotationDefinition> annotationDefinitions = new ArrayList<AnnotationDefinition>(); > > if (annotationCache == null) { >@@ -368,8 +406,10 @@ > } > > for (AnnotationDefinition annotationDefinition : annotationCache) { >- if (annotationDefinition.getTargets().contains(elementType) && >- !isDeprecated(annotationDefinition)) { >+ annotationDefinition.setJavaProject(javaElement.getJavaProject()); >+ >+ if (annotationDefinition.getAnnotationTypeTargets().contains(elementType) && >+ !annotationDefinition.isDeprecated()) { > annotationDefinitions.add(annotationDefinition); > } > } >@@ -396,7 +436,7 @@ > annotationIter.remove(); > } > if (method.isConstructor() >- && !annotationDefinition.getTargets().contains(ElementType.CONSTRUCTOR)) { >+ && !annotationDefinition.getAnnotationTypeTargets().contains(ElementType.CONSTRUCTOR)) { > annotationIter.remove(); > } > >@@ -464,10 +504,4 @@ > } > return false; > } >- >- //TODO Move the Deprecated option to preferences >- private static boolean isDeprecated(AnnotationDefinition annotationDefinition) { >- Class<?> annotationClass = annotationDefinition.getAnnotationClass(); >- return annotationClass.getAnnotation(java.lang.Deprecated.class) != null; >- } > } >Index: src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java,v >retrieving revision 1.8 >diff -u -r1.8 AnnotationAttributeInitializer.java >--- src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java 9 Mar 2010 22:38:54 -0000 1.8 >+++ src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java 23 Mar 2011 19:10:00 -0000 >@@ -15,6 +15,7 @@ > import java.util.List; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.Expression; > import org.eclipse.jdt.core.dom.MemberValuePair; >@@ -40,59 +41,65 @@ > */ > public abstract class AnnotationAttributeInitializer implements IAnnotationAttributeInitializer { > >- protected static final String MISSING_IDENTIFER = "$missing$"; >+ protected static final String MISSING_IDENTIFER = "$missing$"; > >- protected AnnotationAttributeInitializer() { >+ protected AnnotationAttributeInitializer() { >+ } > >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getMemberValuePairs(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.AST, java.lang.Class) >- */ >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >- return Collections.emptyList(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getCompletionProposalsForMemberValuePair(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.MemberValuePair) >- */ >- public List<ICompletionProposal> getCompletionProposalsForMemberValuePair(IJavaElement javaElement, >- MemberValuePair memberValuePair) { >- return Collections.emptyList(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getCompletionProposalsForSingleMemberAnnotation(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.SingleMemberAnnotation) >- */ >- public List<ICompletionProposal> getCompletionProposalsForSingleMemberAnnotation(IJavaElement javaElement, >- SingleMemberAnnotation singleMemberAnnotation) { >- return Collections.emptyList(); >- } >- >- protected CompletionProposal createCompletionProposal(String proposal, Expression value) { >- Image image = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ISharedImages.IMG_OBJ_FILE); >- return createCompletionProposal(proposal, value, image, proposal); >- } >- >- protected CompletionProposal createCompletionProposal(String proposal, Expression value, Image image, >- String displayString) { >- int replacementOffset = value.getStartPosition(); >- int replacementLength = 0; >- if (value.toString().equals(MISSING_IDENTIFER)) { >- if (proposal.charAt(0) != '\"') { >- proposal = "\"" + proposal; >- } >- if (proposal.charAt(proposal.length() - 1) != '\"') { >- proposal = proposal + "\""; >- } >- } else { >- replacementOffset += 1; >- replacementLength = value.getLength() - 2; >- } >- >- return new CompletionProposal(proposal, replacementOffset, replacementLength, proposal.length(), >- image, displayString, null, null); >- } >+ /* (non-Javadoc) >+ * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getMemberValuePairs(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.AST, java.lang.Class) >+ */ >+ @Deprecated >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, Class<? extends Annotation> annotationClass) { >+ return Collections.emptyList(); >+ } >+ >+ /** >+ * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getMemberValuePairs(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.AST, java.lang.Class) >+ * @since 1.1 >+ */ >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType type) { >+ return Collections.emptyList(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getCompletionProposalsForMemberValuePair(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.MemberValuePair) >+ */ >+ public List<ICompletionProposal> getCompletionProposalsForMemberValuePair(IJavaElement javaElement, >+ MemberValuePair memberValuePair) { >+ return Collections.emptyList(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getCompletionProposalsForSingleMemberAnnotation(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.SingleMemberAnnotation) >+ */ >+ public List<ICompletionProposal> getCompletionProposalsForSingleMemberAnnotation(IJavaElement javaElement, >+ SingleMemberAnnotation singleMemberAnnotation) { >+ return Collections.emptyList(); >+ } >+ >+ protected CompletionProposal createCompletionProposal(String proposal, Expression value) { >+ Image image = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ISharedImages.IMG_OBJ_FILE); >+ return createCompletionProposal(proposal, value, image, proposal); >+ } >+ >+ protected CompletionProposal createCompletionProposal(String proposal, Expression value, Image image, String displayString) { >+ int replacementOffset = value.getStartPosition(); >+ int replacementLength = 0; >+ if (value.toString().equals(MISSING_IDENTIFER)) { >+ if (proposal.charAt(0) != '\"') { >+ proposal = "\"" + proposal; >+ } >+ if (proposal.charAt(proposal.length() - 1) != '\"') { >+ proposal = proposal + "\""; >+ } >+ } else { >+ replacementOffset += 1; >+ replacementLength = value.getLength() - 2; >+ } >+ >+ return new CompletionProposal(proposal, replacementOffset, replacementLength, proposal.length(), >+ image, displayString, null, null); >+ } > > } >Index: src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java,v >retrieving revision 1.8 >diff -u -r1.8 DefaultsAnnotationAttributeInitializer.java >--- src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java 7 Mar 2010 20:16:19 -0000 1.8 >+++ src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java 23 Mar 2011 19:10:00 -0000 >@@ -15,10 +15,18 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.jdt.core.IField; > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IMemberValuePair; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.MemberValuePair; > import org.eclipse.jst.ws.annotations.core.AnnotationsCore; >+import org.eclipse.jst.ws.annotations.core.AnnotationsCorePlugin; >+import org.eclipse.jst.ws.internal.annotations.core.utils.SignatureUtils; > > /** > * Constructs {@link MemberValuePair} from the defaults found in the given {@link java.lang.annotation.Annotation}. >@@ -40,13 +48,85 @@ > * @see org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer#getMemberValuePairs(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.dom.AST, java.lang.Class) > */ > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ @Deprecated >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, Class<? extends Annotation> annotationClass) { > return getMemberValuePairs(ast, annotationClass); > } > >- private List<MemberValuePair> getMemberValuePairs(AST ast, >- Class<? extends Annotation> annotationClass) { >+ @Override >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType type) { >+ return interalGetMemberValuePairs(javaElement, ast, type); >+ } >+ >+ private List<MemberValuePair> interalGetMemberValuePairs(IJavaElement javaElement, AST ast, IType type) { >+ List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); >+ >+ try { >+ IMethod[] methods = type.getMethods(); >+ for (IMethod method : methods) { >+ String name = method.getElementName(); >+ String returnType = method.getReturnType(); >+ IMemberValuePair defaultValue = method.getDefaultValue(); >+ if (defaultValue != null) { >+ if (SignatureUtils.isString(returnType)) { >+ memberValuePairs.add(AnnotationsCore.createStringMemberValuePair(ast, >+ name, defaultValue.getValue().toString())); >+ } >+ >+ if (SignatureUtils.isBoolean(returnType)) { >+ memberValuePairs.add(AnnotationsCore.createBooleanMemberValuePair(ast, >+ name, Boolean.parseBoolean(defaultValue.getValue().toString()))); >+ } >+ >+ int signatureKind = Signature.getTypeSignatureKind(returnType); >+ if (signatureKind == Signature.BASE_TYPE_SIGNATURE) { >+ if (returnType.charAt(0) == Signature.C_BYTE >+ || returnType.charAt(0) == Signature.C_SHORT >+ || returnType.charAt(0) == Signature.C_INT >+ || returnType.charAt(0) == Signature.C_LONG >+ || returnType.charAt(0) == Signature.C_FLOAT >+ || returnType.charAt(0) == Signature.C_DOUBLE) { >+ memberValuePairs.add(AnnotationsCore.createNumberMemberValuePair(ast, name, defaultValue.getValue().toString())); >+ } >+ } >+ >+ if (SignatureUtils.isArray(returnType)) { >+ memberValuePairs.add(AnnotationsCore.createArrayMemberValuePair(ast, method.getElementName(), >+ (Object[]) defaultValue.getValue())); >+ } >+ >+ if (SignatureUtils.isEnum(method)) { >+ if (defaultValue.getValueKind() == IMemberValuePair.K_QUALIFIED_NAME) { >+ String value = defaultValue.getValue().toString(); >+ String enumName = value.substring(0, value.lastIndexOf(".")); >+ String constant = value.substring(value.lastIndexOf(".") + 1, value.length()); >+ IType enumType = javaElement.getJavaProject().findType(enumName); >+ if (enumType != null && enumType.isEnum()) { >+ IField[] fields = enumType.getFields(); >+ for (IField field : fields) { >+ if (field.isEnumConstant() && field.getElementName().equals(constant)) { >+ memberValuePairs.add(AnnotationsCore.createEnumMemberValuePair(ast, >+ method.getDeclaringType().getFullyQualifiedName(), name, field)); >+ } >+ } >+ } >+ } >+ } >+ >+ if (SignatureUtils.isClass(returnType)) { >+ memberValuePairs.add(AnnotationsCore.createTypeMemberValuePair(ast, name, >+ defaultValue.getValue())); >+ } >+ } >+ } >+ } catch (JavaModelException jme) { >+ AnnotationsCorePlugin.log(jme.getStatus()); >+ } >+ >+ return memberValuePairs; >+ } >+ >+ private List<MemberValuePair> getMemberValuePairs(AST ast, Class<? extends Annotation> annotationClass) { > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > > Method[] declaredMethods = annotationClass.getDeclaredMethods(); >Index: src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java,v >retrieving revision 1.7 >diff -u -r1.7 IAnnotationAttributeInitializer.java >--- src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java 9 Mar 2010 22:38:54 -0000 1.7 >+++ src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java 23 Mar 2011 19:10:00 -0000 >@@ -13,6 +13,7 @@ > import java.util.List; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.MemberValuePair; > import org.eclipse.jdt.core.dom.SingleMemberAnnotation; >@@ -38,11 +39,23 @@ > * @param annotationClass the {@link java.lang.annotation.Annotation} class which may be > * used to query the declared members of the annotation type and the members default values. > * @return a list of member value pairs. >+ * @deprecated as of 1.1 replaced by {@link IAnnotationAttributeInitializer2#getMemberValuePairs(IJavaElement, AST, IType)} > */ >+ @Deprecated > public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, > Class<? extends java.lang.annotation.Annotation> annotationClass); > > /** >+ * Returns a list of {@link MemberValuePair} that may be added to a {@link NormalAnnotation}. >+ * @param javaElement the java element on which the annotation is declared. >+ * @param ast the <code>AST</code> with which to create the member value pairs. >+ * @param type the {@link org.eclipse.jdt.core.IType} which represents an annotation type,. >+ * @return a list of member value pairs. >+ * @since 1.1 >+ */ >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType type); >+ >+ /** > * Used to provide a list of {@link ICompletionProposal} for a {@link MemberValuePair} value. > * @param javaElement the java element on which the annotation is declared. > * @param memberValuePair the member value pair in which content assist was invoked. >Index: src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java,v >retrieving revision 1.23 >diff -u -r1.23 AnnotationUtils.java >--- src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java 17 Jan 2010 19:56:51 -0000 1.23 >+++ src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java 23 Mar 2011 19:10:00 -0000 >@@ -317,9 +317,10 @@ > final String annotationSimpleName = qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1); > final List<String> occurences = new ArrayList<String>(); > AnnotationDefinition annotationDefinition = AnnotationsManager.getAnnotationDefinitionForClass(qualifiedName); >+ annotationDefinition.setJavaProject(javaElement.getJavaProject()); > List<ElementType> elementTypes = Collections.emptyList(); > if (annotationDefinition != null) { >- elementTypes = annotationDefinition.getTargets(); >+ elementTypes = annotationDefinition.getAnnotationTypeTargets(); > } > for (ElementType elementType : elementTypes) { > if (elementType == ElementType.PACKAGE) { >Index: src/org/eclipse/jst/ws/internal/annotations/core/utils/SignatureUtils.java >=================================================================== >RCS file: src/org/eclipse/jst/ws/internal/annotations/core/utils/SignatureUtils.java >diff -N src/org/eclipse/jst/ws/internal/annotations/core/utils/SignatureUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/ws/internal/annotations/core/utils/SignatureUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,124 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Shane Clarke. >+ * 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: >+ * Shane Clarke - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jst.ws.internal.annotations.core.utils; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.jdt.core.IField; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.Signature; >+ >+public final class SignatureUtils { >+ >+ private SignatureUtils() { >+ } >+ >+ public static boolean isString(String returnType) { >+ int signatureKind = Signature.getTypeSignatureKind(returnType); >+ if (signatureKind == Signature.CLASS_TYPE_SIGNATURE) { >+ if (returnType.charAt(0) == Signature.C_RESOLVED) { >+ return Signature.toString(returnType).equals(java.lang.String.class.getCanonicalName()); >+ } >+ if (returnType.charAt(0) == Signature.C_UNRESOLVED) { >+ return Signature.toString(returnType).equals(java.lang.String.class.getSimpleName()); >+ } >+ } >+ return false; >+ } >+ >+ public static boolean isClass(String returnType) { >+ int signatureKind = Signature.getTypeSignatureKind(returnType); >+ if (signatureKind == Signature.CLASS_TYPE_SIGNATURE) { >+ if (returnType.charAt(0) == Signature.C_RESOLVED) { >+ returnType = Signature.getTypeErasure(returnType); >+ return Signature.toString(returnType).equals(java.lang.Class.class.getCanonicalName()); >+ } >+ if (returnType.charAt(0) == Signature.C_UNRESOLVED) { >+ returnType = Signature.getTypeErasure(returnType); >+ return Signature.toString(returnType).equals(java.lang.Class.class.getSimpleName()); >+ } >+ } >+ return false; >+ } >+ >+ public static boolean isBoolean(String returnType) { >+ int signatureKind = Signature.getTypeSignatureKind(returnType); >+ if (signatureKind == Signature.CLASS_TYPE_SIGNATURE) { >+ if (returnType.charAt(0) == Signature.C_RESOLVED) { >+ return Signature.toString(returnType).equals(java.lang.Boolean.class.getCanonicalName()); >+ } >+ if (returnType.charAt(0) == Signature.C_UNRESOLVED) { >+ return Signature.toString(returnType).equals(java.lang.Boolean.class.getSimpleName()); >+ } >+ } >+ if (signatureKind == Signature.BASE_TYPE_SIGNATURE) { >+ return returnType.charAt(0) == Signature.C_BOOLEAN; >+ } >+ return false; >+ } >+ >+ public static boolean isArray(String returnType) { >+ return Signature.getTypeSignatureKind(returnType) == Signature.ARRAY_TYPE_SIGNATURE; >+ } >+ >+ public static boolean isPrimitive(String returnType) { >+ return Signature.getTypeSignatureKind(returnType) == Signature.BASE_TYPE_SIGNATURE; >+ } >+ >+ public static boolean isEnum(IMethod method) throws JavaModelException { >+ return getEnumReturnType(method) != null; >+ } >+ >+ public static IType getEnumReturnType(IMethod method) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ int signatureKind = Signature.getTypeSignatureKind(returnType); >+ if (signatureKind == Signature.CLASS_TYPE_SIGNATURE) { >+ if (returnType.charAt(0) == Signature.C_RESOLVED) { >+ IType type = method.getJavaProject().findType(Signature.toString(returnType)); >+ if (type != null && type.isEnum()) { >+ return type; >+ } >+ } >+ } >+ return null; >+ } >+ >+ public static String[] getEnumConstantsNames(IType enumType) throws JavaModelException { >+ if (enumType.isEnum()) { >+ List<String> enumConstants = new ArrayList<String>(); >+ IField[] fields = getEnumConstants(enumType); >+ for (IField field : fields) { >+ enumConstants.add(field.getElementName()); >+ } >+ return enumConstants.toArray(new String[enumConstants.size()]); >+ } >+ return new String[] {}; >+ } >+ >+ public static IField[] getEnumConstants(IType enumType) throws JavaModelException { >+ if (enumType.isEnum()) { >+ List<IField> enumConstants = new ArrayList<IField>(); >+ IField[] fields = enumType.getFields(); >+ for (IField field : fields) { >+ if (field.isEnumConstant()) { >+ enumConstants.add(field); >+ } >+ } >+ return enumConstants.toArray(new IField[enumConstants.size()]); >+ } >+ return new IField[] {}; >+ } >+ >+ >+} >#P org.eclipse.jst.ws.cxf.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.cxf.core/META-INF/MANIFEST.MF,v >retrieving revision 1.22 >diff -u -r1.22 MANIFEST.MF >--- META-INF/MANIFEST.MF 25 Jan 2011 21:50:36 -0000 1.22 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:02 -0000 >@@ -46,7 +46,7 @@ > org.eclipse.ui.console;bundle-version="[3.3.0,4.0.0)", > org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)", > org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > org.eclipse.jst.ws.jaxws.core;bundle-version="[1.0.0,1.1.0)", > org.eclipse.wst.command.env.core;bundle-version="[1.0.204,1.1.0)", > javax.jws;bundle-version="[2.0.0,2.1.0)", >Index: src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java,v >retrieving revision 1.16 >diff -u -r1.16 CXFModelUtils.java >--- src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java 22 Mar 2010 22:23:06 -0000 1.16 >+++ src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java 23 Mar 2011 19:10:02 -0000 >@@ -40,6 +40,7 @@ > import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; > import org.eclipse.jdt.ui.CodeStyleConfiguration; > import org.eclipse.jdt.ui.SharedASTProvider; >+import org.eclipse.jst.ws.annotations.core.AnnotationDefinition; > import org.eclipse.jst.ws.annotations.core.AnnotationsCore; > import org.eclipse.jst.ws.annotations.core.AnnotationsManager; > import org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer; >@@ -124,13 +125,12 @@ > } else { > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > >- IAnnotationAttributeInitializer annotationAttributeInitializer = >- AnnotationsManager.getAnnotationDefinitionForClass(WebService.class). >- getAnnotationAttributeInitializer(); >+ AnnotationDefinition annotationDefinition = AnnotationsManager.getAnnotationDefinitionForClass(WebService.class.getCanonicalName()); >+ IAnnotationAttributeInitializer annotationAttributeInitializer = annotationDefinition.getAnnotationAttributeInitializer(); > >+ IType annotationType = annotationDefinition.getAnnotationType(); > if (annotationAttributeInitializer != null) { >- memberValuePairs = annotationAttributeInitializer.getMemberValuePairs(type, ast, >- WebService.class); >+ memberValuePairs = annotationAttributeInitializer.getMemberValuePairs(type, ast, annotationType); > } > > if (model.isUseServiceEndpointInterface() && type.isClass()) { >@@ -218,11 +218,13 @@ > > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > >- IAnnotationAttributeInitializer annotationAttributeInitializer = AnnotationsManager >- .getAnnotationDefinitionForClass(annotationClass).getAnnotationAttributeInitializer(); >+ AnnotationDefinition annotationDefinition = AnnotationsManager.getAnnotationDefinitionForClass(annotationClass.getCanonicalName()); >+ IAnnotationAttributeInitializer annotationAttributeInitializer = annotationDefinition.getAnnotationAttributeInitializer(); >+ >+ IType annotationType = annotationDefinition.getAnnotationType(); > > if (annotationAttributeInitializer != null) { >- memberValuePairs = annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, annotationClass); >+ memberValuePairs = annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, annotationType); > } > > return AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs); >#P org.eclipse.jst.ws.cxf.creation.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.cxf.creation.core/META-INF/MANIFEST.MF,v >retrieving revision 1.14 >diff -u -r1.14 MANIFEST.MF >--- META-INF/MANIFEST.MF 31 Mar 2010 12:19:24 -0000 1.14 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:03 -0000 >@@ -23,7 +23,7 @@ > org.eclipse.jst.j2ee;bundle-version="[1.1.100,1.2.0)", > org.eclipse.jst.j2ee.core;bundle-version="[1.1.0,1.3.0)", > org.eclipse.text;bundle-version="[3.4.0,4.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > org.eclipse.jst.ws.jaxws.core;bundle-version="[1.0.0,1.1.0)", > org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)", > org.eclipse.jem;bundle-version="[2.0.0,2.1.0)", >#P org.eclipse.jst.ws.cxf.creation.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.cxf.creation.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.17 >diff -u -r1.17 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Mar 2010 22:07:29 -0000 1.17 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:03 -0000 >@@ -29,7 +29,7 @@ > org.eclipse.jst.ws.creation.ui;bundle-version="[1.0.305,1.1.0)", > org.eclipse.jst.ws;bundle-version="[1.0.304,1.1.0)", > org.eclipse.ltk.core.refactoring;bundle-version="[3.4.0,4.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > org.eclipse.jst.ws.jaxws.core;bundle-version="[1.0.0,1.1.0)", > org.eclipse.emf.common;bundle-version="[2.4.0,3.0.0)", > javax.wsdl;bundle-version="[1.6.2,1.7.0)", >#P org.eclipse.jst.ws.jaxb.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxb.core/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Mar 2010 22:06:55 -0000 1.3 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:04 -0000 >@@ -6,11 +6,8 @@ > Bundle-Version: 1.0.0.qualifier > Bundle-ClassPath: . > Bundle-Localization: plugin >-Eclipse-RegisterBuddy: org.eclipse.jst.ws.annotations.core > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-Activator: org.eclipse.jst.ws.internal.jaxb.core.JAXBCorePlugin >-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)" >-Export-Package: org.eclipse.jst.ws.internal.jaxb.core >-Import-Package: javax.xml.bind.annotation;version="[2.1.0,2.2.0)", >- javax.xml.bind.annotation.adapters;version="[2.1.0,2.2.0)" >+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="1.1.0" > Bundle-ActivationPolicy: lazy >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxb.core/plugin.xml,v >retrieving revision 1.3 >diff -u -r1.3 plugin.xml >--- plugin.xml 7 Mar 2010 20:16:34 -0000 1.3 >+++ plugin.xml 23 Mar 2011 19:10:04 -0000 >@@ -17,15 +17,6 @@ > category="jaxb.category" > class="javax.xml.bind.annotation.XmlAccessorType" > name="XmlAccessorType"/> >- >- <!-- TODO Reinstate when XmlAdapter issue is solved >- <annotation >- category="jaxb.category" >- class="javax.xml.bind.annotation.adapters.XmlAdapter" >- name="XmlAdapter"> >- </annotation> >- --> >- > <annotation > category="jaxb.category" > class="javax.xml.bind.annotation.XmlAnyAttribute" >@@ -177,5 +168,5 @@ > name="XmlValue"> > </annotation> > </extension> >- >+ > </plugin> >#P org.eclipse.jst.ws.jaxb.core.tests >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/tests/org.eclipse.jst.ws.jaxb.core.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Mar 2010 22:06:16 -0000 1.5 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:05 -0000 >@@ -14,7 +14,7 @@ > org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ltk.core.refactoring;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ltk.ui.refactoring;bundle-version="[3.4.0,4.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)", > org.eclipse.text;bundle-version="[3.4.0,4.0.0)", > org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)" >#P org.eclipse.jst.ws.jaxws.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.core/META-INF/MANIFEST.MF,v >retrieving revision 1.24 >diff -u -r1.24 MANIFEST.MF >--- META-INF/MANIFEST.MF 25 Jan 2011 21:50:39 -0000 1.24 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:06 -0000 >@@ -6,7 +6,6 @@ > Bundle-Version: 1.0.100.qualifier > Bundle-ClassPath: . > Bundle-Localization: plugin >-Eclipse-RegisterBuddy: org.eclipse.jst.ws.annotations.core > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-Activator: org.eclipse.jst.ws.internal.jaxws.core.JAXWSCorePlugin > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", >@@ -14,7 +13,7 @@ > org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)", > org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)", > org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > javax.wsdl;bundle-version="[1.6.2,1.7.0)", > javax.xml.soap;bundle-version="[1.2.0,1.3.0)", > org.apache.xerces;bundle-version="[2.9.0,3.0.0)", >#P org.eclipse.jst.ws.jaxws.core.tests >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/tests/org.eclipse.jst.ws.jaxws.core.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.16 >diff -u -r1.16 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Mar 2010 22:06:39 -0000 1.16 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:06 -0000 >@@ -14,7 +14,7 @@ > org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ltk.core.refactoring;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ltk.ui.refactoring;bundle-version="[3.4.0,4.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)", > org.eclipse.text;bundle-version="[3.4.0,4.0.0)", > org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)" >#P org.eclipse.jst.ws.jaxws.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.13 >diff -u -r1.13 MANIFEST.MF >--- META-INF/MANIFEST.MF 5 Sep 2010 16:13:41 -0000 1.13 >+++ META-INF/MANIFEST.MF 23 Mar 2011 19:10:07 -0000 >@@ -17,7 +17,7 @@ > org.eclipse.ltk.core.refactoring;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ui.editors;bundle-version="[3.4.0,4.0.0)", > org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)", >- org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.1.0)", >+ org.eclipse.jst.ws.annotations.core;bundle-version="[1.0.0,1.2.0)", > org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)", > org.eclipse.jst.ws.jaxws.dom.runtime;bundle-version="[1.0.0,1.1.0)", > org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)" >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java,v >retrieving revision 1.4 >diff -u -r1.4 BindingTypeAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java 2 Nov 2009 00:05:31 -0000 1.4 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -11,14 +11,16 @@ > package org.eclipse.jst.ws.internal.jaxws.ui.annotations.initialization; > > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.VALUE; >-import java.lang.annotation.Annotation; >+ > import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; > import java.util.List; > import java.util.Map; >+ > import javax.xml.ws.http.HTTPBinding; > import javax.xml.ws.soap.SOAPBinding; >+ > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.dom.AST; >@@ -49,10 +51,9 @@ > JAXWSUIPlugin.getDefault().getImageRegistry().put(HTTP_BINDING, > JAXWSUIPlugin.getImageDescriptor("icons/obj16/httpbinding_obj.gif").createImage()); //$NON-NLS-1$ > } >- >+ > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > if (javaElement.getElementType() == IJavaElement.TYPE) { > MemberValuePair value = AnnotationsCore.createStringMemberValuePair(ast, VALUE, getDefault()); //$NON-NLS-1$ >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java,v >retrieving revision 1.4 >diff -u -r1.4 RequestWrapperAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java 17 Jan 2010 19:56:46 -0000 1.4 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -17,7 +17,6 @@ > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.OPERATION_NAME; > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.TARGET_NAMESPACE; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.List; > >@@ -40,10 +39,9 @@ > import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils; > > public class RequestWrapperAttributeInitializer extends AnnotationAttributeInitializer { >- >+ > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > if (javaElement.getElementType() == IJavaElement.METHOD) { > IMethod method = (IMethod) javaElement; >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/SOAPBindingAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/SOAPBindingAttributeInitializer.java,v >retrieving revision 1.1 >diff -u -r1.1 SOAPBindingAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/SOAPBindingAttributeInitializer.java 28 Jul 2009 20:39:12 -0000 1.1 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/SOAPBindingAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -14,7 +14,6 @@ > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.STYLE; > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.USE; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.List; > >@@ -24,16 +23,16 @@ > import javax.jws.soap.SOAPBinding.Use; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.MemberValuePair; > import org.eclipse.jst.ws.annotations.core.AnnotationsCore; > import org.eclipse.jst.ws.annotations.core.initialization.AnnotationAttributeInitializer; > > public class SOAPBindingAttributeInitializer extends AnnotationAttributeInitializer { >- >+ > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > > MemberValuePair styleValuePair = AnnotationsCore.createEnumMemberValuePair(ast, >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebMethodAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebMethodAttributeInitializer.java,v >retrieving revision 1.3 >diff -u -r1.3 WebMethodAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebMethodAttributeInitializer.java 17 Jan 2010 19:56:46 -0000 1.3 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebMethodAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -13,7 +13,6 @@ > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.ACTION; > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.OPERATION_NAME; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.List; > >@@ -30,22 +29,20 @@ > import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin; > > public class WebMethodAttributeInitializer extends AnnotationAttributeInitializer { >- >+ > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > > if (javaElement.getElementType() == IJavaElement.METHOD) { > IMethod method = (IMethod) javaElement; >- IType type = method.getCompilationUnit().findPrimaryType(); > > MemberValuePair operationValuePair = AnnotationsCore.createStringMemberValuePair(ast, >- OPERATION_NAME, getOperationNameValue(type, method)); >+ OPERATION_NAME, getOperationNameValue(method)); > > MemberValuePair actionValuePair = AnnotationsCore.createStringMemberValuePair(ast, >- ACTION, getActionValue(type, method)); >+ ACTION, getActionValue(method)); > > memberValuePairs.add(operationValuePair); > memberValuePairs.add(actionValuePair); >@@ -61,17 +58,16 @@ > > if (javaElement.getElementType() == IJavaElement.METHOD) { > IMethod method = (IMethod) javaElement; >- IType type = method.getCompilationUnit().findPrimaryType(); > > String memberValuePairName = memberValuePair.getName().getIdentifier(); > > if (memberValuePairName.equals(OPERATION_NAME)) { >- completionProposals.add(createCompletionProposal(getOperationNameValue(type, method), >+ completionProposals.add(createCompletionProposal(getOperationNameValue(method), > memberValuePair.getValue())); > } > > if (memberValuePairName.equals(ACTION)) { >- completionProposals.add(createCompletionProposal(getActionValue(type, method), >+ completionProposals.add(createCompletionProposal(getActionValue(method), > memberValuePair.getValue())); > } > >@@ -79,7 +75,7 @@ > return completionProposals; > } > >- private String getOperationNameValue(IType type, IMethod method) { >+ private String getOperationNameValue(IMethod method) { > try { > return method.getElementName() + JAXWSUtils.accountForOverloadedMethods(method); > } catch (JavaModelException jme) { >@@ -88,7 +84,7 @@ > return ""; //$NON-NLS-1$ > } > >- private String getActionValue(IType type, IMethod method) { >+ private String getActionValue(IMethod method) { > try { > String methodName = method.getElementName(); > return "urn:" + methodName.substring(0, 1).toUpperCase() //$NON-NLS-1$ >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java,v >retrieving revision 1.3 >diff -u -r1.3 WebParamAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java 2 Nov 2009 00:05:31 -0000 1.3 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -17,7 +17,6 @@ > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.PART_NAME; > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.TARGET_NAMESPACE; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.Arrays; > import java.util.List; >@@ -43,10 +42,9 @@ > import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils; > > public class WebParamAttributeInitializer extends AnnotationAttributeInitializer { >- >+ > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, >- AST ast, Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java,v >retrieving revision 1.2 >diff -u -r1.2 WebResultAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java 2 Nov 2009 00:05:31 -0000 1.2 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -18,7 +18,6 @@ > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.RETURN; > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.TARGET_NAMESPACE; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.List; > >@@ -47,8 +46,7 @@ > public class WebResultAttributeInitializer extends AnnotationAttributeInitializer { > > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > > if (javaElement.getElementType() == IJavaElement.METHOD) { >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebServiceAttributeInitializer.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebServiceAttributeInitializer.java,v >retrieving revision 1.1 >diff -u -r1.1 WebServiceAttributeInitializer.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebServiceAttributeInitializer.java 28 Jul 2009 20:39:11 -0000 1.1 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebServiceAttributeInitializer.java 23 Mar 2011 19:10:07 -0000 >@@ -18,7 +18,6 @@ > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.SERVICE_SUFFIX; > import static org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils.TARGET_NAMESPACE; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.Collections; > import java.util.List; >@@ -40,8 +39,7 @@ > public class WebServiceAttributeInitializer extends AnnotationAttributeInitializer { > > @Override >- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, >- Class<? extends Annotation> annotationClass) { >+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast, IType annotationType) { > > List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); > if (javaElement.getElementType() == IJavaElement.TYPE) { >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationArrayCellEditor.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationArrayCellEditor.java,v >retrieving revision 1.9 >diff -u -r1.9 AnnotationArrayCellEditor.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationArrayCellEditor.java 22 Mar 2010 22:23:13 -0000 1.9 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationArrayCellEditor.java 23 Mar 2011 19:10:07 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > >-import java.lang.reflect.Method; > import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; >@@ -20,9 +19,12 @@ > import java.util.Map.Entry; > > import org.eclipse.jdt.core.IAnnotation; >+import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IMemberValuePair; >+import org.eclipse.jdt.core.IMethod; > import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.search.SearchEngine; > import org.eclipse.jdt.ui.IJavaElementSearchConstants; > import org.eclipse.jdt.ui.ISharedImages; >@@ -39,6 +41,7 @@ > import org.eclipse.jface.viewers.TableViewer; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.window.Window; >+import org.eclipse.jst.ws.internal.annotations.core.utils.SignatureUtils; > import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIMessages; > import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin; > import org.eclipse.swt.SWT; >@@ -59,7 +62,7 @@ > import org.eclipse.ui.dialogs.SelectionStatusDialog; > > public class AnnotationArrayCellEditor extends DialogCellEditor { >- private Method method; >+ private IMethod method; > private Object[] values; > > private List<Object> originalValues; >@@ -89,7 +92,7 @@ > return values; > } > >- public void setMethod(Method method) { >+ public void setMethod(IMethod method) { > this.method = method; > if (updatedValues != null) { > updatedValues.clear(); >@@ -184,263 +187,296 @@ > protected Control createDialogArea(Composite parent) { > Composite mainComposite = (Composite) super.createDialogArea(parent); > >- GridLayout gridLayout = new GridLayout(3, false); >- mainComposite.setLayout(gridLayout); >- >- GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, false, false); >- gridData.widthHint = 800; >- mainComposite.setLayoutData(gridData); >- >- Composite typeComposite = new Composite(mainComposite, SWT.NONE); >- gridLayout = new GridLayout(3, false); >- typeComposite.setLayout(gridLayout); >- gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, true); >- typeComposite.setLayoutData(gridData); >- >- final Class<?> componentType = method.getReturnType().getComponentType(); >- if (componentType.isAnnotation()) { >- Label compontTypeLabel = new Label(typeComposite, SWT.NONE); >- compontTypeLabel.setText("@" + componentType.getName()); //$NON-NLS-1$ >- gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >- gridData.horizontalSpan = 3; >- compontTypeLabel.setLayoutData(gridData); >+ try { >+ GridLayout gridLayout = new GridLayout(3, false); >+ mainComposite.setLayout(gridLayout); > >- Method[] methods = componentType.getDeclaredMethods(); >- for (Method method : methods) { >- Label label = new Label(typeComposite, SWT.NONE); >- label.setText(method.getName() + ":"); //$NON-NLS-1$ >- createEntryFields(method, typeComposite); >+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, false, false); >+ gridData.widthHint = 800; >+ mainComposite.setLayoutData(gridData); >+ >+ Composite typeComposite = new Composite(mainComposite, SWT.NONE); >+ gridLayout = new GridLayout(3, false); >+ typeComposite.setLayout(gridLayout); >+ gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, true); >+ typeComposite.setLayoutData(gridData); >+ >+ final IType componentType = getComponentType(method); >+ if (componentType != null) { >+ if (componentType.isAnnotation()) { >+ Label compontTypeLabel = new Label(typeComposite, SWT.NONE); >+ compontTypeLabel.setText("@" + componentType.getFullyQualifiedName()); //$NON-NLS-1$ >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gridData.horizontalSpan = 3; >+ compontTypeLabel.setLayoutData(gridData); >+ >+ IMethod[] methods = componentType.getMethods(); >+ for (IMethod method : methods) { >+ Label label = new Label(typeComposite, SWT.NONE); >+ label.setText(method.getElementName() + ":"); //$NON-NLS-1$ >+ createEntryFields(method, typeComposite); >+ } >+ } else { >+ Label label = new Label(typeComposite, SWT.NONE); >+ label.setText(Signature.getSimpleName(Signature.toString(method.getReturnType()))); >+ createEntryFields(method, typeComposite); >+ } > } >- } else { >- Label label = new Label(typeComposite, SWT.NONE); >- label.setText(method.getReturnType().getSimpleName()); >- createEntryFields(method, typeComposite); >- } >- >- Composite buttonComposite = new Composite(mainComposite, SWT.NONE); >- gridLayout = new GridLayout(1, false); >- buttonComposite.setLayout(gridLayout); >- >- addButton = new Button(buttonComposite, SWT.PUSH); >- addButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_ADD_LABEL); >- addButton.addSelectionListener(new SelectionAdapter() { >- @Override >- public void widgetSelected(SelectionEvent event) { >- Set<Entry<String, Control>> entrySet = controls.entrySet(); >- Iterator<Map.Entry<String, Control>> iterator = entrySet.iterator(); >- List<Map<String, Object>> aList = new ArrayList<Map<String,Object>>(); >- while (iterator.hasNext()) { >- Map.Entry<String, Control> entry = iterator.next(); >- if (entry.getValue() instanceof Text) { >- Text textField = (Text) entry.getValue(); >- Method method = (Method) textField.getData(); >- if (textField.getText().trim().length() > 0) { >- if (componentType.isAnnotation()) { >- Map<String, Object> memberValuePairs = new HashMap<String, Object>(); >- memberValuePairs.put(method.getName(), textField.getText()); >- aList.add(memberValuePairs); >- } else { >- updatedValues.add(textField.getText()); >+ >+ Composite buttonComposite = new Composite(mainComposite, SWT.NONE); >+ gridLayout = new GridLayout(1, false); >+ buttonComposite.setLayout(gridLayout); >+ >+ addButton = new Button(buttonComposite, SWT.PUSH); >+ addButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_ADD_LABEL); >+ addButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent event) { >+ try { >+ Set<Entry<String, Control>> entrySet = controls.entrySet(); >+ Iterator<Map.Entry<String, Control>> iterator = entrySet.iterator(); >+ List<Map<String, Object>> aList = new ArrayList<Map<String,Object>>(); >+ while (iterator.hasNext()) { >+ Map.Entry<String, Control> entry = iterator.next(); >+ if (entry.getValue() instanceof Text) { >+ Text textField = (Text) entry.getValue(); >+ IMethod methodAA = (IMethod) textField.getData(); >+ if (textField.getText().trim().length() > 0) { >+ if (componentType != null && componentType.isAnnotation()) { >+ Map<String, Object> memberValuePairs = new HashMap<String, Object>(); >+ memberValuePairs.put(methodAA.getElementName(), textField.getText()); >+ aList.add(memberValuePairs); >+ } else { >+ updatedValues.add(textField.getText()); >+ } >+ } >+ } >+ if (entry.getValue() instanceof Button) { >+ Button button = (Button) entry.getValue(); >+ IMethod methodVV = (IMethod) button.getData(); >+ if (componentType != null && componentType.isAnnotation()) { >+ Map<String, Object> memberValuePairs = new HashMap<String, Object>(); >+ memberValuePairs.put(methodVV.getElementName(), button.getSelection()); >+ aList.add(memberValuePairs); >+ } else { >+ updatedValues.add(button.getSelection()); >+ } > } > } >- } >- if (entry.getValue() instanceof Button) { >- Button button = (Button) entry.getValue(); >- Method method = (Method) button.getData(); >- if (componentType.isAnnotation()) { >- Map<String, Object> memberValuePairs = new HashMap<String, Object>(); >- memberValuePairs.put(method.getName(), button.getSelection()); >- aList.add(memberValuePairs); >- } else { >- updatedValues.add(button.getSelection()); >+ if (aList.size() > 0) { >+ updatedValues.add(aList); > } >+ arrayValuesTableViewer.refresh(); >+ } catch (JavaModelException jme) { >+ JAXWSUIPlugin.log(jme.getStatus()); > } >+ } >+ }); >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >+ addButton.setLayoutData(gridData); > >+ removeButton = new Button(buttonComposite, SWT.PUSH); >+ removeButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_REMOVE_LABEL); >+ removeButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent event) { >+ ISelection selection = arrayValuesTableViewer.getSelection(); >+ if (selection != null && !selection.isEmpty()) { >+ int index = arrayValuesTable.getSelectionIndex(); >+ updatedValues.remove(index); >+ arrayValuesTableViewer.refresh(); >+ } > } >- if (aList.size() > 0) { >- updatedValues.add(aList); >+ }); >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >+ removeButton.setLayoutData(gridData); >+ >+ upButton = new Button(buttonComposite, SWT.PUSH); >+ upButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_UP_LABEL); >+ upButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ moveSelectedElememtUp(getSelectedElement(), getTableViewer()); > } >- arrayValuesTableViewer.refresh(); >- } >- }); >- gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >- addButton.setLayoutData(gridData); >- >- removeButton = new Button(buttonComposite, SWT.PUSH); >- removeButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_REMOVE_LABEL); >- removeButton.addSelectionListener(new SelectionAdapter() { >- @Override >- public void widgetSelected(SelectionEvent event) { >- ISelection selection = arrayValuesTableViewer.getSelection(); >- if (selection != null && !selection.isEmpty()) { >- int index = arrayValuesTable.getSelectionIndex(); >- updatedValues.remove(index); >- arrayValuesTableViewer.refresh(); >+ }); >+ >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >+ upButton.setLayoutData(gridData); >+ >+ downButton = new Button(buttonComposite, SWT.PUSH); >+ downButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_DOWN_LABEL); >+ downButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ moveSelectedElememtDown(getSelectedElement(), getTableViewer()); > } >- } >- }); >- gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >- removeButton.setLayoutData(gridData); >- >- upButton = new Button(buttonComposite, SWT.PUSH); >- upButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_UP_LABEL); >- upButton.addSelectionListener(new SelectionAdapter() { >- @Override >- public void widgetSelected(SelectionEvent e) { >- moveSelectedElememtUp(getSelectedElement(), getTableViewer()); >- } >- }); >+ }); >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >+ downButton.setLayoutData(gridData); > >- gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >- upButton.setLayoutData(gridData); >+ Composite valuesComposite = new Composite(mainComposite, SWT.NONE); >+ gridLayout = new GridLayout(1, false); >+ valuesComposite.setLayout(gridLayout); >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gridData.widthHint = 200; >+ valuesComposite.setLayoutData(gridData); > >- downButton = new Button(buttonComposite, SWT.PUSH); >- downButton.setText(JAXWSUIMessages.ANNOTATION_ARRAY_CELL_EDITOR_DOWN_LABEL); >- downButton.addSelectionListener(new SelectionAdapter() { >- @Override >- public void widgetSelected(SelectionEvent e) { >- moveSelectedElememtDown(getSelectedElement(), getTableViewer()); >- } >- }); >- gridData = new GridData(SWT.FILL, SWT.FILL, true, false); >- downButton.setLayoutData(gridData); >- >- Composite valuesComposite = new Composite(mainComposite, SWT.NONE); >- gridLayout = new GridLayout(1, false); >- valuesComposite.setLayout(gridLayout); >- gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >- gridData.widthHint = 200; >- valuesComposite.setLayoutData(gridData); >- >- Label valuesLabel = new Label(valuesComposite, SWT.NONE); >- valuesLabel.setText(method.getName() + ":"); //$NON-NLS-1$ >- >- arrayValuesTableViewer = new TableViewer(valuesComposite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL >- | SWT.H_SCROLL); >- arrayValuesTableViewer.setLabelProvider(new LabelProvider() { >- @Override >- public String getText(Object element) { >- if (element instanceof List<?>) { >- String annotationName = method.getReturnType().getComponentType().getSimpleName(); >- annotationName += "("; //$NON-NLS-1$ >- List<Map<String, Object>> valuesList = (List<Map<String, Object>>)element; >- Iterator<Map<String, Object>> valuesIterator = valuesList.iterator(); >- while (valuesIterator.hasNext()) { >- Map<String, Object> valuesMap = valuesIterator.next(); >- Set<Entry<String, Object>> entrySet = valuesMap.entrySet(); >- Iterator<Map.Entry<String, Object>> iterator = entrySet.iterator(); >- while (iterator.hasNext()) { >- Map.Entry<String, Object> entry = iterator.next(); >- Object value = entry.getValue(); >- boolean isString = value instanceof String && !value.toString(). >- endsWith(".class"); //$NON-NLS-1$ >- if (isString) { >- annotationName += entry.getKey() + "=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ >- } else { >- annotationName += entry.getKey() + "=" + value; //$NON-NLS-1$ >+ Label valuesLabel = new Label(valuesComposite, SWT.NONE); >+ valuesLabel.setText(method.getElementName() + ":"); //$NON-NLS-1$ >+ >+ arrayValuesTableViewer = new TableViewer(valuesComposite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL); >+ arrayValuesTableViewer.setLabelProvider(new LabelProvider() { >+ @Override >+ public String getText(Object element) { >+ if (element instanceof List<?>) { >+ String annotationName = componentType.getElementName(); >+ annotationName += "("; //$NON-NLS-1$ >+ @SuppressWarnings("unchecked") >+ List<Map<String, Object>> valuesList = (List<Map<String, Object>>) element; >+ Iterator<Map<String, Object>> valuesIterator = valuesList.iterator(); >+ while (valuesIterator.hasNext()) { >+ Map<String, Object> valuesMap = valuesIterator.next(); >+ Set<Entry<String, Object>> entrySet = valuesMap.entrySet(); >+ Iterator<Map.Entry<String, Object>> iterator = entrySet.iterator(); >+ while (iterator.hasNext()) { >+ Map.Entry<String, Object> entry = iterator.next(); >+ Object value = entry.getValue(); >+ boolean isString = value instanceof String && !value.toString().endsWith(".class"); //$NON-NLS-1$ >+ if (isString) { >+ annotationName += entry.getKey() + "=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ >+ } else { >+ annotationName += entry.getKey() + "=" + value; //$NON-NLS-1$ >+ } >+ } >+ if (valuesIterator.hasNext()) { >+ annotationName += ", "; //$NON-NLS-1$ > } > } >- if (valuesIterator.hasNext()) { >- annotationName += ", "; //$NON-NLS-1$ >- } >+ return annotationName += ")"; //$NON-NLS-1$ > } >- return annotationName += ")"; //$NON-NLS-1$ >+ return element.toString(); > } >- return element.toString(); >- } > >- @Override >- public Image getImage(Object element) { >- Class<?> returnType = method.getReturnType(); >- if (returnType.getComponentType().isAnnotation()) { >- return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_ANNOTATION); >- } if (returnType.equals(Class.class)) { >- return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CLASS); >- } else { >- return PlatformUI.getWorkbench().getSharedImages().getImage( >- org.eclipse.ui.ISharedImages.IMG_OBJ_FILE); >+ @Override >+ public Image getImage(Object element) { >+ try { >+ if (componentType != null && componentType.isAnnotation()) { >+ return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_ANNOTATION); >+ } else if (SignatureUtils.isClass(method.getReturnType())) { >+ return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CLASS); >+ } else { >+ return PlatformUI.getWorkbench().getSharedImages().getImage( >+ org.eclipse.ui.ISharedImages.IMG_OBJ_FILE); >+ } >+ } catch (JavaModelException jme) { >+ JAXWSUIPlugin.log(jme.getStatus()); >+ } >+ return null; > } >- } >- }); >+ }); > >- arrayValuesTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { >- public void selectionChanged(SelectionChangedEvent event) { >- int index = arrayValuesTable.getSelectionIndex(); >- int itemCount = arrayValuesTable.getItemCount(); >+ arrayValuesTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ int index = arrayValuesTable.getSelectionIndex(); >+ int itemCount = arrayValuesTable.getItemCount(); > >- if (index == 0 && itemCount <= 1) { >- upButton.setEnabled(false); >- downButton.setEnabled(false); >- } >+ if (index == 0 && itemCount <= 1) { >+ upButton.setEnabled(false); >+ downButton.setEnabled(false); >+ } > >- if (index == 0 && itemCount > 1) { >- upButton.setEnabled(false); >- downButton.setEnabled(true); >- } >+ if (index == 0 && itemCount > 1) { >+ upButton.setEnabled(false); >+ downButton.setEnabled(true); >+ } > >- if (index > 0 && index < itemCount - 1) { >- upButton.setEnabled(true); >- downButton.setEnabled(true); >- } >+ if (index > 0 && index < itemCount - 1) { >+ upButton.setEnabled(true); >+ downButton.setEnabled(true); >+ } > >- if (index > 0 && index == itemCount - 1) { >- upButton.setEnabled(true); >- downButton.setEnabled(false); >- } >+ if (index > 0 && index == itemCount - 1) { >+ upButton.setEnabled(true); >+ downButton.setEnabled(false); >+ } > >- if (index != -1) { >- removeButton.setEnabled(true); >- } else { >- removeButton.setEnabled(false); >+ if (index != -1) { >+ removeButton.setEnabled(true); >+ } else { >+ removeButton.setEnabled(false); >+ } > } >- } >- }); >+ }); > >- arrayValuesTableViewer.setContentProvider(new ArrayValuesContentProvider()); >+ arrayValuesTableViewer.setContentProvider(new ArrayValuesContentProvider()); > >- arrayValuesTable = arrayValuesTableViewer.getTable(); >- gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >- arrayValuesTable.setLayoutData(gridData); >+ arrayValuesTable = arrayValuesTableViewer.getTable(); >+ gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >+ arrayValuesTable.setLayoutData(gridData); > >- arrayValuesTableViewer.setInput(values); >+ arrayValuesTableViewer.setInput(values); > >- upButton.setEnabled(false); >- downButton.setEnabled(false); >- removeButton.setEnabled(false); >+ upButton.setEnabled(false); >+ downButton.setEnabled(false); >+ removeButton.setEnabled(false); >+ } catch (JavaModelException jme) { >+ jme.printStackTrace(); >+ } > > return mainComposite; > } > >- public void createEntryFields(Method method, Composite typeComposite) { >+ private IType getComponentType(IMethod method) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ if (SignatureUtils.isArray(returnType)) { >+ String elementType = Signature.getElementType(returnType); >+ IType declaringType = method.getDeclaringType(); >+ IJavaProject javaProject = declaringType.getJavaProject(); >+ if (javaProject != null) { >+ return javaProject.findType(Signature.toString(elementType)); >+ } >+ } >+ return null; >+ } >+ >+ private void createEntryFields(IMethod method, Composite typeComposite) throws JavaModelException { > //TODO Handle ENUMS >- Class<?> returnType = method.getReturnType(); >- Object defaultValue = method.getDefaultValue(); >- GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ String returnType = method.getReturnType(); >+ IMemberValuePair defaultValue = method.getDefaultValue(); >+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); > //String or String[] >- if (returnType.equals(String.class) || returnType.isArray() && returnType.getComponentType().equals(String.class)) { >+ if (SignatureUtils.isString(returnType) || SignatureUtils.isArray(returnType) && SignatureUtils.isString(Signature.getElementType(returnType))) { > Text text = new Text(typeComposite, SWT.BORDER); > text.setData(method); > gridData.horizontalSpan = 2; > text.setLayoutData(gridData); > if (defaultValue != null) { >- if (defaultValue instanceof String[] && ((String[]) defaultValue).length == 1) { >- String[] values = (String[]) defaultValue; >- text.setText(values[0]); >+ Object value = defaultValue.getValue(); >+ if (value instanceof Object[]) { >+ Object[] values = (Object[]) value; >+ if (values.length == 1) { >+ text.setText(values[0].toString()); >+ } >+ } else if (value instanceof String[]) { >+ String[] values = (String[]) value; >+ if (values.length == 1) { >+ text.setText(values[0]); >+ } > } else { >- text.setText(defaultValue.toString()); >+ text.setText(value.toString()); > } > } >- controls.put(method.getName(), text); >+ controls.put(method.getElementName(), text); > } > //Class or Class[] >- if (returnType.equals(Class.class) || returnType.isArray() && returnType.getComponentType().equals(Class.class)) { >+ if (SignatureUtils.isClass(returnType) || SignatureUtils.isArray(returnType) && SignatureUtils.isClass(Signature.getElementType(returnType))) { > final Text text = new Text(typeComposite, SWT.BORDER); > text.setData(method); >- gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); >+ gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); > text.setLayoutData(gridData); >- if (defaultValue != null) { >- Class<?> classValue = (Class<?>)defaultValue; >- text.setText(classValue.getCanonicalName() + ".class"); //$NON-NLS-1$ >+ if (defaultValue != null && defaultValue.getValueKind() == IMemberValuePair.K_CLASS) { >+ Object value = defaultValue.getValue(); >+ text.setText(value + ".class"); //$NON-NLS-1$ > } > Button browseClassButton = new Button(typeComposite, SWT.PUSH); > browseClassButton.setText(getBrowseButtonLabel()); >@@ -462,19 +498,19 @@ > } > }); > browse_button_count++; >- controls.put(method.getName(), text); >+ controls.put(method.getElementName(), text); > } > > //Boolean >- if (returnType.equals(Boolean.TYPE)) { >+ if (SignatureUtils.isBoolean(returnType)) { > Button checkbox = new Button(typeComposite, SWT.CHECK); > checkbox.setData(method); > gridData.horizontalSpan = 2; > checkbox.setLayoutData(gridData); > if (defaultValue != null) { >- checkbox.setSelection((Boolean)defaultValue); >+ checkbox.setSelection((Boolean) defaultValue.getValue()); > } >- controls.put(method.getName(), checkbox); >+ controls.put(method.getElementName(), checkbox); > } > } > >@@ -497,7 +533,7 @@ > } > } > >- public Object getSelectedElement() { >+ private Object getSelectedElement() { > IStructuredSelection selection= (IStructuredSelection) arrayValuesTableViewer.getSelection(); > return selection.getFirstElement(); > } >@@ -506,7 +542,7 @@ > return arrayValuesTableViewer; > } > >- public void moveSelectedElememtUp(Object selected, TableViewer tableViewer) { >+ private void moveSelectedElememtUp(Object selected, TableViewer tableViewer) { > int selectionIndex = tableViewer.getTable().getSelectionIndex(); > if (selectionIndex > 0) { > updatedValues.remove(selected); >@@ -518,7 +554,7 @@ > } > } > >- public void moveSelectedElememtDown(Object selected, TableViewer tableViewer) { >+ private void moveSelectedElememtDown(Object selected, TableViewer tableViewer) { > int selectionIndex = tableViewer.getTable().getSelectionIndex(); > int itemCount = tableViewer.getTable().getItemCount(); > if (selectionIndex < itemCount - 1) { >@@ -547,7 +583,7 @@ > } > } > >- public SelectionDialog getClassSelectionDialog() { >+ private SelectionDialog getClassSelectionDialog() { > try { > return JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), > SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_CLASSES, >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsColumnLabelProvider.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsColumnLabelProvider.java,v >retrieving revision 1.2 >diff -u -r1.2 AnnotationsColumnLabelProvider.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsColumnLabelProvider.java 19 Jul 2009 17:35:50 -0000 1.2 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsColumnLabelProvider.java 23 Mar 2011 19:10:07 -0000 >@@ -10,8 +10,8 @@ > *******************************************************************************/ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > >-import java.lang.reflect.Method; >- >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.ui.ISharedImages; > import org.eclipse.jdt.ui.JavaUI; > import org.eclipse.jface.viewers.ColumnLabelProvider; >@@ -22,22 +22,22 @@ > > @Override > public String getText(Object element) { >- if (element instanceof Class) { >- return ((Class<?>)element).getName(); >+ if (element instanceof IType) { >+ return ((IType) element).getFullyQualifiedName(); > } > >- if (element instanceof Method) { >- return ((Method)element).getName(); >+ if (element instanceof IMethod) { >+ return ((IMethod) element).getElementName(); > } > return ""; //$NON-NLS-1$ > } > > @Override > public Image getImage(Object element) { >- if (element instanceof Class) { >+ if (element instanceof IType) { > return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_ANNOTATION); > } >- if (element instanceof Method) { >+ if (element instanceof IMethod) { > return PlatformUI.getWorkbench().getSharedImages().getImage( > org.eclipse.ui.ISharedImages.IMG_OBJ_FILE); > } >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesColumnLabelProvider.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesColumnLabelProvider.java,v >retrieving revision 1.8 >diff -u -r1.8 AnnotationsValuesColumnLabelProvider.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesColumnLabelProvider.java 18 Nov 2009 19:52:45 -0000 1.8 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesColumnLabelProvider.java 23 Mar 2011 19:10:07 -0000 >@@ -10,11 +10,13 @@ > *******************************************************************************/ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > >-import java.lang.reflect.Method; > import java.util.List; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.dom.Annotation; > import org.eclipse.jdt.core.dom.ArrayInitializer; > import org.eclipse.jdt.core.dom.BooleanLiteral; >@@ -25,6 +27,7 @@ > import org.eclipse.jface.viewers.ColumnLabelProvider; > import org.eclipse.jface.viewers.TreeViewer; > import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils; >+import org.eclipse.jst.ws.internal.annotations.core.utils.SignatureUtils; > import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin; > import org.eclipse.swt.graphics.Image; > >@@ -43,13 +46,17 @@ > > @Override > public String getText(Object element) { >- if (element instanceof Method) { >- return getTextForMethod((Method)element); >+ if (element instanceof IMethod) { >+ try { >+ return getTextForMethod((IMethod) element); >+ } catch (JavaModelException jme) { >+ JAXWSUIPlugin.log(jme.getStatus()); >+ } > } > return ""; //$NON-NLS-1$ > } > >- private String getTextForMethod(Method method) { >+ private String getTextForMethod(IMethod method) throws JavaModelException { > if (annotationTreeViewer.getInput() instanceof IJavaElement) { > IJavaElement javaElement = (IJavaElement) annotationTreeViewer.getInput(); > if (javaElement.exists()) { >@@ -59,47 +66,51 @@ > return ""; //$NON-NLS-1$ > } > >- private String getTextForMethod(Method method, IJavaElement annotatedElement) { >+ private String getTextForMethod(IMethod method, IJavaElement annotatedElement) throws JavaModelException { > List<Annotation> annotations = AnnotationUtils.getAnnotations(annotatedElement); > for (Annotation annotation : annotations) { > String annotationName = AnnotationUtils.getAnnotationName(annotation); >- Class<?> declaringClass = method.getDeclaringClass(); >- if (annotationName.equals(declaringClass.getSimpleName()) >- || annotationName.equals(declaringClass.getCanonicalName())) { >+ IType type = method.getDeclaringType(); >+ if (type != null && annotationName.equals(type.getElementName()) >+ || annotationName.equals(type.getFullyQualifiedName())) { > if (annotation.isNormalAnnotation()) { > NormalAnnotation normalAnnotation = (NormalAnnotation) annotation; > @SuppressWarnings("unchecked") > List<MemberValuePair> memberValuePairs = normalAnnotation.values(); > for (MemberValuePair memberValuePair : memberValuePairs) { >- if (memberValuePair.getName().getIdentifier().equals(method.getName())) { >- return getTextForMethod(method.getReturnType(), memberValuePair.getValue()); >+ if (memberValuePair.getName().getIdentifier().equals(method.getElementName())) { >+ return getTextForMethod(method, memberValuePair.getValue()); > } > } > } else if (annotation.isSingleMemberAnnotation()) { > SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation; >- return getTextForMethod(method.getReturnType(), singleMemberAnnotation.getValue()); >+ return getTextForMethod(method, singleMemberAnnotation.getValue()); > } > } > } > return ""; //$NON-NLS-1$ > } > >- private String getTextForMethod(Class<?> returnType, Expression expression) { >- if (returnType.equals(String.class)) { >+ private String getTextForMethod(IMethod method, Expression expression) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ >+ if (SignatureUtils.isString(returnType) || SignatureUtils.isClass(returnType)) { > return expression.toString(); > } > >- if (returnType.equals(Class.class)) { >- return expression.toString() + ".class"; //$NON-NLS-1$ >+ if (SignatureUtils.isEnum(method)) { >+ String enumValue = expression.toString(); >+ return enumValue.substring(enumValue.lastIndexOf(".") + 1); //$NON-NLS-1$ > } >- if (returnType.isPrimitive() && (returnType.equals(Byte.TYPE) >- || returnType.equals(Short.TYPE) || returnType.equals(Integer.TYPE) >- || returnType.equals(Long.TYPE) || returnType.equals(Float.TYPE) >- || returnType.equals(Double.TYPE))) { >+ >+ if (SignatureUtils.isPrimitive(returnType) && (returnType.charAt(0) == Signature.C_BYTE >+ || returnType.charAt(0) == Signature.C_SHORT || returnType.charAt(0) == Signature.C_INT >+ || returnType.charAt(0) == Signature.C_LONG || returnType.charAt(0) == Signature.C_FLOAT >+ || returnType.charAt(0) == Signature.C_DOUBLE)) { > return expression.toString(); > } > >- if (returnType.isArray() && expression instanceof ArrayInitializer) { >+ if (SignatureUtils.isArray(returnType) && expression instanceof ArrayInitializer) { > ArrayInitializer arrayInitializer = (ArrayInitializer) expression; > if (arrayInitializer.expressions().size() > 0) { > return "[]{...}"; //$NON-NLS-1$ >@@ -107,21 +118,17 @@ > return "[]{}"; //$NON-NLS-1$ > } > } >- if (returnType.isEnum()) { >- String enumValue = expression.toString(); >- return enumValue.substring(enumValue.lastIndexOf(".") + 1); //$NON-NLS-1$ >- } > return ""; //$NON-NLS-1$ > } > > @Override > public Image getImage(Object element) { > try { >- if (element instanceof Class) { >- return getImageForClass((Class<?>) element); >+ if (element instanceof IType) { >+ return getImageForClass((IType) element); > } >- if (element instanceof Method) { >- return getImageForMethod((Method) element); >+ if (element instanceof IMethod) { >+ return getImageForMethod((IMethod) element); > } > } catch (JavaModelException jme) { > JAXWSUIPlugin.log(jme.getStatus()); >@@ -129,30 +136,30 @@ > return null; > } > >- private Image getImageForClass(Class<?> aClass) throws JavaModelException { >+ private Image getImageForClass(IType type) throws JavaModelException { > if (annotationTreeViewer.getInput() instanceof IJavaElement) { > IJavaElement javaElement = (IJavaElement) annotationTreeViewer.getInput(); > if (javaElement.exists()) { >- return getImageForClass(aClass, javaElement); >+ return getImageForClass(type, javaElement); > } > } > return null; > } > >- private Image getImageForClass(Class<?> aClass, IJavaElement javaElement) throws JavaModelException { >+ private Image getImageForClass(IType type, IJavaElement javaElement) throws JavaModelException { > List<Annotation> annotations = AnnotationUtils.getAnnotations(javaElement); > for (Annotation annotation : annotations) { > String annotationName = AnnotationUtils.getAnnotationName(annotation); >- if (annotationName.equals(aClass.getSimpleName()) || >- annotationName.equals(aClass.getCanonicalName())) { >+ if (annotationName.equals(type.getElementName()) || >+ annotationName.equals(type.getFullyQualifiedName())) { > return true_image; > } > } > return false_image; > } > >- private Image getImageForMethod(Method method) throws JavaModelException { >- if (method.getReturnType().equals(Boolean.TYPE) && annotationTreeViewer.getInput() instanceof IJavaElement) { >+ private Image getImageForMethod(IMethod method) throws JavaModelException { >+ if (SignatureUtils.isBoolean(method.getReturnType()) && annotationTreeViewer.getInput() instanceof IJavaElement) { > IJavaElement javaElement = (IJavaElement) annotationTreeViewer.getInput(); > if (javaElement.exists()) { > return getImageForMethod(method, javaElement); >@@ -161,19 +168,19 @@ > return null; > } > >- private Image getImageForMethod(Method method, IJavaElement javaElement) throws JavaModelException { >+ private Image getImageForMethod(IMethod method, IJavaElement javaElement) throws JavaModelException { > List<Annotation> annotations = AnnotationUtils.getAnnotations(javaElement); > for (Annotation annotation : annotations) { > String annotationName = AnnotationUtils.getAnnotationName(annotation); >- Class<?> declaringClass = method.getDeclaringClass(); >- if (annotationName.equals(declaringClass.getSimpleName()) >- || annotationName.equals(declaringClass.getCanonicalName())) { >+ IType declaringType = method.getDeclaringType(); >+ if (declaringType != null && annotationName.equals(declaringType.getElementName()) >+ || annotationName.equals(declaringType.getFullyQualifiedName())) { > if (annotation.isNormalAnnotation()) { > NormalAnnotation normalAnnotation = (NormalAnnotation) annotation; > @SuppressWarnings("unchecked") > List<MemberValuePair> memberValuePairs = normalAnnotation.values(); > for (MemberValuePair memberValuePair : memberValuePairs) { >- if (memberValuePair.getName().getIdentifier().equals(method.getName()) >+ if (memberValuePair.getName().getIdentifier().equals(method.getElementName()) > && memberValuePair.getValue() instanceof BooleanLiteral) { > if (((BooleanLiteral) memberValuePair.getValue()).booleanValue()) { > return true_image; >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java,v >retrieving revision 1.17 >diff -u -r1.17 AnnotationsValuesEditingSupport.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java 7 Mar 2010 20:16:23 -0000 1.17 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java 23 Mar 2011 19:10:07 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > >-import java.lang.reflect.Method; > import java.util.ArrayList; > import java.util.Collections; > import java.util.Iterator; >@@ -27,8 +26,13 @@ > import org.eclipse.jdt.core.IAnnotation; > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.ILocalVariable; > import org.eclipse.jdt.core.IMemberValuePair; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; > import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.ASTNode; > import org.eclipse.jdt.core.dom.Annotation; >@@ -51,6 +55,7 @@ > import org.eclipse.jst.ws.annotations.core.AnnotationsManager; > import org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer; > import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils; >+import org.eclipse.jst.ws.internal.annotations.core.utils.SignatureUtils; > import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIMessages; > import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin; > import org.eclipse.ltk.core.refactoring.Change; >@@ -61,6 +66,7 @@ > import org.eclipse.text.edits.MultiTextEdit; > > public class AnnotationsValuesEditingSupport extends EditingSupport { >+ > private AnnotationsView annotationsView; > private TreeViewer treeViewer; > >@@ -83,104 +89,112 @@ > > @Override > protected boolean canEdit(Object element) { >- if (element instanceof Method) { >- Method method = (Method)element; >- return (Boolean) getValue(method.getDeclaringClass()); >+ if (element instanceof IMethod) { >+ IMethod method = (IMethod) element; >+ return (Boolean) getValue(method.getDeclaringType()); > } > return true; > } > > @Override > protected CellEditor getCellEditor(Object element) { >- if (element instanceof Class) { >+ if (element instanceof IType) { > return checkboxCellEditor; > } >- if (element instanceof Method) { >- Method method = (Method) element; >- final Class<?> returnType = method.getReturnType(); >- if (returnType.isEnum()) { >- Object[] enumConstants = returnType.getEnumConstants(); >- String[] values = new String[enumConstants.length]; >- for (int i = 0; i < enumConstants.length; i++) { >- values[i] = enumConstants[i].toString(); >- } >- comboBoxCellEditor.setItems(values); >- return comboBoxCellEditor; >- } >- if (returnType.equals(Boolean.TYPE)) { >- return checkboxCellEditor; >- } >- >- if (returnType.equals(Class.class)) { >- return classDialogCellEditor; >- } >- >- if (returnType.isArray()) { >- annotationArrayCellEditor.setMethod(method); >- return annotationArrayCellEditor; >- } >- if (returnType.isPrimitive()) { >- textCellEditor.setValidator(new ICellEditorValidator() { >- public String isValid(Object value) { >- try { >- if (returnType.equals(Byte.TYPE)) { >- Byte.parseByte((String) value); >- } >- if (returnType.equals(Short.TYPE)) { >- Short.parseShort((String) value); >- } >- if (returnType.equals(Integer.TYPE)) { >- Integer.parseInt((String) value); >- } >- if (returnType.equals(Long.TYPE)) { >- Long.parseLong((String) value); >- } >- if (returnType.equals(Float.TYPE)) { >- Float.parseFloat((String) value); >- } >- if (returnType.equals(Double.TYPE)) { >- Double.parseDouble((String) value); >+ if (element instanceof IMethod) { >+ try { >+ IMethod method = (IMethod) element; >+ >+ IType enumType = SignatureUtils.getEnumReturnType(method); >+ if (enumType != null) { >+ comboBoxCellEditor.setItems(SignatureUtils.getEnumConstantsNames(enumType)); >+ return comboBoxCellEditor; >+ } >+ >+ final String returnType = method.getReturnType(); >+ >+ if (SignatureUtils.isBoolean(returnType)) { >+ return checkboxCellEditor; >+ } >+ >+ if (SignatureUtils.isClass(returnType)) { >+ return classDialogCellEditor; >+ } >+ >+ if (SignatureUtils.isArray(returnType)) { >+ annotationArrayCellEditor.setMethod(method); >+ return annotationArrayCellEditor; >+ } >+ if (SignatureUtils.isPrimitive(returnType)) { >+ textCellEditor.setValidator(new ICellEditorValidator() { >+ public String isValid(Object value) { >+ try { >+ if (returnType.charAt(0) == Signature.C_BYTE) { >+ Byte.parseByte((String) value); >+ } >+ if (returnType.charAt(0) == Signature.C_SHORT) { >+ Short.parseShort((String) value); >+ } >+ if (returnType.charAt(0) == Signature.C_INT) { >+ Integer.parseInt((String) value); >+ } >+ if (returnType.charAt(0) == Signature.C_LONG) { >+ Long.parseLong((String) value); >+ } >+ if (returnType.charAt(0) == Signature.C_FLOAT) { >+ Float.parseFloat((String) value); >+ } >+ if (returnType.charAt(0) == Signature.C_DOUBLE) { >+ Double.parseDouble((String) value); >+ } >+ } catch (NumberFormatException nfe) { >+ return JAXWSUIMessages.ANNOTATION_EDITING_SUPPORT_NOT_VALID_MESSAGE_PREFIX + value; > } >- } catch (NumberFormatException nfe) { >- return JAXWSUIMessages.ANNOTATION_EDITING_SUPPORT_NOT_VALID_MESSAGE_PREFIX >- + returnType.getSimpleName(); >+ return null; > } >- return null; >- } >- }); >+ }); >+ return textCellEditor; >+ } > return textCellEditor; >+ } catch (JavaModelException jme) { >+ JAXWSUIPlugin.log(jme.getStatus()); > } >- return textCellEditor; > } > return checkboxCellEditor; > } > > @Override > protected Object getValue(Object element) { >- if (element instanceof Class) { >- return getValueForClass((Class<?>) element); >+ if (element instanceof IType) { >+ return getValueForClass((IType) element); > } >- if (element instanceof Method) { >- return getValueForMethod((Method) element); >+ if (element instanceof IMethod) { >+ return getValueForMethod((IMethod) element); > } > return null; > } > >- private Object getValueForClass(Class<?> aClass) { >+ private Object getValueForClass(IType type) { > if (treeViewer.getInput() instanceof IAnnotatable) { >- return getValueForClass(aClass, (IAnnotatable) treeViewer.getInput()); >+ return getValueForClass(type, (IAnnotatable) treeViewer.getInput()); > } > return Boolean.FALSE; > } > >- private Object getValueForClass(Class<?> aClass, IAnnotatable annotatedElement) { >+ private Object getValueForClass(IType type, IAnnotatable annotatedElement) { >+ if (annotatedElement instanceof ILocalVariable) { >+ ILocalVariable localVariable = getLocalVariable(annotatedElement); >+ if (localVariable != null) { >+ annotatedElement = localVariable; >+ } >+ } > try { > IAnnotation[] annotations = annotatedElement.getAnnotations(); > for (IAnnotation annotation : annotations) { > String annotationName = annotation.getElementName(); > if (AnnotationUtils.isAnnotationPresent((IJavaElement)annotatedElement, annotationName) >- && (annotationName.equals(aClass.getSimpleName()) >- || annotationName.equals(aClass.getCanonicalName()))) { >+ && (annotationName.equals(type.getElementName()) >+ || annotationName.equals(type.getFullyQualifiedName()))) { > return Boolean.TRUE; > } > } >@@ -190,7 +204,7 @@ > return Boolean.FALSE; > } > >- private Object getValueForMethod(Method method) { >+ private Object getValueForMethod(IMethod method) { > Object value = null; > try { > if (treeViewer.getInput() instanceof IAnnotatable) { >@@ -202,44 +216,65 @@ > return value; > } > >- private Object getValueForMethod(Method method, IAnnotatable annotatedElement) throws JavaModelException { >- Class<?> returnType = method.getReturnType(); >+ private ILocalVariable getLocalVariable(IAnnotatable annotatedElement) { >+ if (annotatedElement instanceof ILocalVariable) { >+ ILocalVariable localVariable = (ILocalVariable) annotatedElement; >+ if (localVariable.getParent() instanceof IMethod) { >+ IMethod parent = (IMethod) localVariable.getParent(); >+ localVariable = AnnotationUtils.getLocalVariable(parent, localVariable.getElementName()); >+ if (localVariable != null) { >+ return localVariable; >+ } >+ } >+ } >+ return null; >+ } >+ >+ private Object getValueForMethod(IMethod method, IAnnotatable annotatedElement) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ if (annotatedElement instanceof ILocalVariable) { >+ ILocalVariable localVariable = getLocalVariable(annotatedElement); >+ if (localVariable != null) { >+ annotatedElement = localVariable; >+ } >+ } > IAnnotation[] annotations = annotatedElement.getAnnotations(); > for (IAnnotation annotation : annotations) { >- Class<?> declaringClass = method.getDeclaringClass(); >+ IType declaringType = method.getDeclaringType(); >+ > String annotationName = annotation.getElementName(); >- if (annotationName.equals(declaringClass.getSimpleName()) >- || annotationName.equals(declaringClass.getCanonicalName())) { >+ if (annotationName.equals(declaringType.getElementName()) >+ || annotationName.equals(declaringType.getFullyQualifiedName())) { > IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs(); > for (IMemberValuePair memberValuePair : memberValuePairs) { >- if (memberValuePair.getMemberName().equals(method.getName())) { >- if (returnType.equals(String.class)) { >+ if (memberValuePair.getMemberName().equals(method.getElementName())) { >+ if (SignatureUtils.isString(returnType)) { > return memberValuePair.getValue(); > } > >- if (returnType.isEnum()) { >+ IType enumType = SignatureUtils.getEnumReturnType(method); >+ if (enumType != null) { > String enumValue = memberValuePair.getValue().toString(); > String literal = enumValue.substring(enumValue.lastIndexOf(".") + 1); //$NON-NLS-1$ >- Object[] enumConstants = method.getReturnType().getEnumConstants(); >+ String[] enumConstants = SignatureUtils.getEnumConstantsNames(enumType); > for (int i = 0; i < enumConstants.length; i++) { >- if (enumConstants[i].toString().equals(literal)) { >+ if (enumConstants[i].equals(literal)) { > return i; > } > } > } >- >- if (returnType.equals(Class.class)) { >+ if (SignatureUtils.isClass(returnType)) { > return memberValuePair.getValue(); > } > >- if (returnType.equals(Boolean.TYPE)) { >+ if (SignatureUtils.isBoolean(returnType)) { > return memberValuePair.getValue(); > } > >- if (returnType.isPrimitive()) { >+ if (SignatureUtils.isPrimitive(returnType)) { > return ""; //$NON-NLS-1$ > } >- if (returnType.isArray()) { >+ if (SignatureUtils.isArray(returnType)) { > if (memberValuePair.getValueKind() == IMemberValuePair.K_CLASS) { > Object[] arrayValues = (Object[])memberValuePair.getValue(); > for (int i = 0; i < arrayValues.length; i++) { >@@ -252,28 +287,35 @@ > } > } > } >- return getDefaultValueForMethod(returnType); >+ return getDefaultValueForMethod(method); > } > } > return null; > } > >- private Object getDefaultValueForMethod(Class<?> returnType) { >- if (returnType.equals(String.class)) { >+ private Object getDefaultValueForMethod(IMethod method) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ >+ if (SignatureUtils.isString(returnType)) { > return ""; //$NON-NLS-1$ > } >- if (returnType.equals(Boolean.TYPE)) { >+ >+ if (SignatureUtils.isBoolean(returnType)) { > return Boolean.FALSE; > } >- if (returnType.isEnum()) { >+ >+ if (SignatureUtils.isEnum(method)) { > return -1; > } >- if (returnType.isPrimitive()) { >+ >+ if (SignatureUtils.isPrimitive(returnType)) { > return ""; //$NON-NLS-1$ > } >- if (returnType.isArray()) { >+ >+ if (SignatureUtils.isArray(returnType)) { > return new Object[] {}; > } >+ > return null; > } > >@@ -284,41 +326,34 @@ > } > > try { >- if (element instanceof Class && ((Class<?>) element).isAnnotation()) { >- @SuppressWarnings("unchecked") >- Class<? extends java.lang.annotation.Annotation> annotationClass = >- (Class<? extends java.lang.annotation.Annotation>) element; >- if (annotationClass != null) { >- setValueForClass(annotationClass, (Boolean) value); >- } >+ if (element instanceof IType && ((IType) element).isAnnotation()) { >+ setValueForClass((IType) element, (Boolean) value); > } >- if (element instanceof Method) { >- setValueForMethod((Method) element, value); >+ >+ if (element instanceof IMethod) { >+ setValueForMethod((IMethod) element, value); > } > } catch (CoreException ce) { > JAXWSUIPlugin.log(ce.getStatus()); > } > } > >- private void setValueForClass(Class<? extends java.lang.annotation.Annotation> annotationClass, >- Boolean annotate) throws CoreException { >+ private void setValueForClass(IType type, Boolean annotate) throws CoreException { > Object viewerInput = treeViewer.getInput(); > > IAnnotationAttributeInitializer annotationAttributeInitializer = >- AnnotationsManager.getAnnotationDefinitionForClass(annotationClass).getAnnotationAttributeInitializer(); >+ AnnotationsManager.getAnnotationDefinitionForClass(type.getFullyQualifiedName()).getAnnotationAttributeInitializer(); > > if (viewerInput instanceof IJavaElement) { >- setValueForClass(annotationClass, annotate, (IJavaElement) viewerInput, annotationAttributeInitializer); >+ setValueForClass(type, annotate, (IJavaElement) viewerInput, annotationAttributeInitializer); > } > } > >- private Annotation getAnnotation(AST ast, Class<? extends java.lang.annotation.Annotation> annotationClass, >- List<MemberValuePair> memberValuePairs) { >- >+ private Annotation getAnnotation(AST ast, IType type, List<MemberValuePair> memberValuePairs) throws JavaModelException { > Annotation annotation = null; >- int numberOfDeclaredMethods = annotationClass.getDeclaredMethods().length; >+ int numberOfDeclaredMethods = type.getMethods().length; > if (numberOfDeclaredMethods == 0) { >- annotation = AnnotationsCore.createMarkerAnnotation(ast, annotationClass.getSimpleName()); >+ annotation = AnnotationsCore.createMarkerAnnotation(ast, type.getElementName()); > } else if (numberOfDeclaredMethods == 1) { > Expression value = null; > if (memberValuePairs != null && memberValuePairs.size() == 1) { >@@ -328,28 +363,27 @@ > } > } > if (value != null) { >- annotation = AnnotationsCore.createSingleMemberAnnotation(ast, annotationClass.getSimpleName(), value); >+ annotation = AnnotationsCore.createSingleMemberAnnotation(ast, type.getElementName(), value); > } else { >- annotation = AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs); >+ annotation = AnnotationsCore.createNormalAnnotation(ast, type.getElementName(), memberValuePairs); > } > } else if (numberOfDeclaredMethods > 1) { >- annotation = AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs); >+ annotation = AnnotationsCore.createNormalAnnotation(ast, type.getElementName(), memberValuePairs); > } > > return annotation; > } > >- private void setValueForClass(Class<? extends java.lang.annotation.Annotation> annotationClass, >- Boolean annotate, IJavaElement javaElement, IAnnotationAttributeInitializer annotationAttributeInitializer) >- throws CoreException { >+ private void setValueForClass(IType type, Boolean annotate, IJavaElement javaElement, >+ IAnnotationAttributeInitializer annotationAttributeInitializer) throws CoreException { > ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement); > CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null); > AST ast = compilationUnit.getAST(); > > List<MemberValuePair> memberValuePairs = getMemberValuePairs(annotationAttributeInitializer, javaElement, >- ast, annotationClass); >+ ast, type); > >- Annotation annotation = getAnnotation(ast, annotationClass, memberValuePairs); >+ Annotation annotation = getAnnotation(ast, type, memberValuePairs); > > TextFileChange change = new TextFileChange("Add/Remove Annotation", (IFile) source.getResource()); //$NON-NLS-1$ > MultiTextEdit multiTextEdit = new MultiTextEdit(); >@@ -361,8 +395,8 @@ > || javaElement.getElementType() == IJavaElement.FIELD > || javaElement.getElementType() == IJavaElement.METHOD > || javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) { >+ change.addEdit(AnnotationUtils.createAddImportTextEdit(javaElement, type.getFullyQualifiedName())); > change.addEdit(AnnotationUtils.createAddAnnotationTextEdit(javaElement, annotation)); >- change.addEdit(AnnotationUtils.createAddImportTextEdit(javaElement, annotationClass.getCanonicalName())); > } > } else { > if (javaElement.getElementType() == IJavaElement.PACKAGE_DECLARATION >@@ -371,24 +405,36 @@ > || javaElement.getElementType() == IJavaElement.METHOD > || javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) { > change.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(javaElement, annotation)); >- change.addEdit(AnnotationUtils.createRemoveImportTextEdit(javaElement, annotationClass.getCanonicalName())); >+ change.addEdit(AnnotationUtils.createRemoveImportTextEdit(javaElement, type.getFullyQualifiedName())); > } > } > executeChange(new NullProgressMonitor(), change); > } > >- private List<MemberValuePair> getMemberValuePairs( >- IAnnotationAttributeInitializer annotationAttributeInitializer, IJavaElement javaElement, AST ast, >- Class<?extends java.lang.annotation.Annotation> annotationClass) { >+ private List<MemberValuePair> getMemberValuePairs(IAnnotationAttributeInitializer annotationAttributeInitializer, >+ IJavaElement javaElement, AST ast, IType type) { > if (annotationAttributeInitializer != null) { >- return annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, annotationClass); >+ List<MemberValuePair> memberValuePairs = annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, type); >+ if (memberValuePairs.size() > 0) { >+ return memberValuePairs; >+ } else { >+ return annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, >+ AnnotationsManager.getAnnotationDefinitionForType(type).getAnnotationClass()); >+ } > } > return Collections.emptyList(); > } > >- >- private void setValueForMethod(Method method, Object value) throws CoreException { >- if (((Boolean) getValue(method.getDeclaringClass())).booleanValue()) { >+ private void setValueForMethod(IMethod method, Object value) throws CoreException { >+ if (value instanceof String) { >+ Object currentValue = getValue(method); >+ if (currentValue != null && currentValue instanceof String) { >+ if (((String) value).equals(currentValue)) { >+ return; >+ } >+ } >+ } >+ if (((Boolean) getValue(method.getDeclaringType())).booleanValue()) { > Object viewerInput = treeViewer.getInput(); > if (viewerInput instanceof IAnnotatable) { > setValueForMethod(method, value, (IJavaElement) viewerInput); >@@ -396,7 +442,7 @@ > } > } > >- private void setValueForMethod(Method method, Object value, IJavaElement javaElement) throws CoreException { >+ private void setValueForMethod(IMethod method, Object value, IJavaElement javaElement) throws CoreException { > ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement); > CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null); > AST ast = compilationUnit.getAST(); >@@ -409,14 +455,14 @@ > for (Annotation annotation : annotations) { > if (annotation instanceof NormalAnnotation) { > NormalAnnotation normalAnnotation = (NormalAnnotation) annotation; >- Class<?> declaringClass = method.getDeclaringClass(); >+ IType declaringType = method.getDeclaringType(); > String annotationName = normalAnnotation.getTypeName().getFullyQualifiedName(); >- if (annotationName.equals(declaringClass.getSimpleName()) || annotationName.equals(declaringClass.getCanonicalName())) { >+ if (annotationName.equals(declaringType.getElementName()) || annotationName.equals(declaringType.getFullyQualifiedName())) { > @SuppressWarnings("unchecked") > List<MemberValuePair> memberValuePairs = normalAnnotation.values(); > boolean hasMemberValuePair = false; > for (MemberValuePair memberValuePair : memberValuePairs) { >- if (memberValuePair.getName().getIdentifier().equals(method.getName())) { >+ if (memberValuePair.getName().getIdentifier().equals(method.getElementName())) { > ASTNode memberValue = getMemberValuePairValue(ast, method, value); > if (memberValue != null) { > change.addEdit(AnnotationUtils.createUpdateMemberValuePairTextEdit(memberValuePair, memberValue)); >@@ -435,9 +481,9 @@ > } > } else if (annotation instanceof SingleMemberAnnotation) { > SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation; >- Class<?> declaringClass = method.getDeclaringClass(); >+ IType declaringType = method.getDeclaringType(); > String annotationName = singleMemberAnnotation.getTypeName().getFullyQualifiedName(); >- if (annotationName.equals(declaringClass.getSimpleName()) || annotationName.equals(declaringClass.getCanonicalName())) { >+ if (annotationName.equals(declaringType.getElementName()) || annotationName.equals(declaringType.getFullyQualifiedName())) { > MemberValuePair memberValuePair = getMemberValuePair(ast, method, value); > if (memberValuePair != null) { > change.addEdit(AnnotationUtils.createUpdateSingleMemberAnnotationTextEdit(singleMemberAnnotation, memberValuePair.getValue())); >@@ -451,76 +497,108 @@ > executeChange(new NullProgressMonitor(), change); > } > >- private ASTNode getMemberValuePairValue(AST ast, Method method, Object value) { >- Class<?> returnType = method.getReturnType(); >- if (returnType.equals(String.class)) { >- return AnnotationsCore.createStringLiteral(ast, value.toString()); >- } >- if (returnType.equals(Boolean.TYPE)) { >- return AnnotationsCore.createBooleanLiteral(ast, ((Boolean) value).booleanValue()); >+ private MemberValuePair getMemberValuePair(AST ast, IMethod method, Object value) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ if (SignatureUtils.isString(returnType)) { >+ return AnnotationsCore.createStringMemberValuePair(ast, method.getElementName(), (String) value); >+ } >+ if (SignatureUtils.isBoolean(returnType)) { >+ return AnnotationsCore.createBooleanMemberValuePair(ast, method.getElementName(), (Boolean) value); >+ } >+ >+ if (SignatureUtils.isPrimitive(returnType)) { >+ if (returnType.charAt(0) == Signature.C_BYTE >+ || returnType.charAt(0) == Signature.C_SHORT >+ || returnType.charAt(0) == Signature.C_INT >+ || returnType.charAt(0) == Signature.C_LONG >+ || returnType.charAt(0) == Signature.C_FLOAT >+ || returnType.charAt(0) == Signature.C_DOUBLE) { >+ return AnnotationsCore.createNumberMemberValuePair(ast, method.getElementName(), value.toString()); >+ } > } >- if (returnType.isPrimitive() >- && (returnType.equals(Byte.TYPE) || returnType.equals(Short.TYPE) >- || returnType.equals(Integer.TYPE) || returnType.equals(Long.TYPE) >- || returnType.equals(Float.TYPE) || returnType.equals(Double.TYPE))) { >- return AnnotationsCore.createNumberLiteral(ast, value.toString()); >- } >- if (returnType.isArray()) { >- if (method.getReturnType().getComponentType().isAnnotation()) { >- return createArrayValueLiteral(ast, method, (Object[]) value); >- } else { >- return AnnotationsCore.createArrayValueLiteral(ast, (Object[]) value); >+ >+ if (SignatureUtils.isArray(returnType)) { >+ IType componentType = getComponentType(method); >+ if (componentType != null) { >+ if (componentType.isAnnotation()) { >+ return createArrayMemberValuePair(ast, method, (Object[]) value); >+ } else { >+ return AnnotationsCore.createArrayMemberValuePair(ast, method.getElementName(), (Object[]) value); >+ } > } > } > >- if (returnType.equals(Class.class)) { >- return AnnotationsCore.createTypeLiteral(ast, value.toString()); >+ if (SignatureUtils.isClass(returnType)) { >+ return AnnotationsCore.createTypeMemberValuePair(ast, method.getElementName(), value.toString()); > } > >- if (returnType.isEnum()) { >+ IType enumType = SignatureUtils.getEnumReturnType(method); >+ if (enumType != null) { > int selected = ((Integer) value).intValue(); > if (selected != -1) { >- return AnnotationsCore.createEnumLiteral(ast, method.getDeclaringClass().getCanonicalName(), >- method.getReturnType().getEnumConstants()[selected]); >+ if (enumType.isMember()) { >+ return AnnotationsCore.createEnumMemberValuePair(ast, enumType.getDeclaringType().getFullyQualifiedName(), >+ method.getElementName(), SignatureUtils.getEnumConstants(enumType)[selected]); >+ } else { >+ return AnnotationsCore.createEnumMemberValuePair(ast, enumType.getFullyQualifiedName(), >+ method.getElementName(), SignatureUtils.getEnumConstants(enumType)[selected]); >+ } > } > } > return null; > } > >- private MemberValuePair getMemberValuePair(AST ast, Method method, Object value) { >- Class<?> returnType = method.getReturnType(); >- if (returnType.equals(String.class)) { >- return AnnotationsCore.createStringMemberValuePair(ast, method.getName(), (String) value); >- } >- if (returnType.equals(Boolean.TYPE)) { >- return AnnotationsCore.createBooleanMemberValuePair(ast, method.getName(), (Boolean) value); >- } >- if (returnType.isPrimitive() >- && (returnType.equals(Byte.TYPE) || returnType.equals(Short.TYPE) >- || returnType.equals(Integer.TYPE) || returnType.equals(Long.TYPE) >- || returnType.equals(Float.TYPE) || returnType.equals(Double.TYPE))) { >- return AnnotationsCore.createNumberMemberValuePair(ast, method.getName(), value.toString()); >- } >- if (returnType.isArray()) { >- if (method.getReturnType().getComponentType().isAnnotation()) { >- return createArrayMemberValuePair(ast, method, (Object[]) value); >- } else { >- return AnnotationsCore.createArrayMemberValuePair(ast, method.getName(), (Object[]) value); >+ private ASTNode getMemberValuePairValue(AST ast, IMethod method, Object value) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ if (SignatureUtils.isString(returnType)) { >+ return AnnotationsCore.createStringLiteral(ast, value.toString()); >+ } >+ >+ if (SignatureUtils.isBoolean(returnType)) { >+ return AnnotationsCore.createBooleanLiteral(ast, ((Boolean) value).booleanValue()); >+ } >+ >+ if (SignatureUtils.isPrimitive(returnType)) { >+ if (returnType.charAt(0) == Signature.C_BYTE >+ || returnType.charAt(0) == Signature.C_SHORT >+ || returnType.charAt(0) == Signature.C_INT >+ || returnType.charAt(0) == Signature.C_LONG >+ || returnType.charAt(0) == Signature.C_FLOAT >+ || returnType.charAt(0) == Signature.C_DOUBLE) { >+ return AnnotationsCore.createNumberLiteral(ast, value.toString()); > } > } > >- if (returnType.equals(Class.class)) { >- return AnnotationsCore.createTypeMemberValuePair(ast, method.getName(), value.toString()); >+ if (SignatureUtils.isArray(returnType)) { >+ IType componentType = getComponentType(method); >+ if (componentType != null) { >+ if (componentType.isAnnotation()) { >+ return createArrayValueLiteral(ast, method, (Object[]) value); >+ } else { >+ return AnnotationsCore.createArrayValueLiteral(ast, (Object[]) value); >+ } >+ } >+ } >+ >+ if (SignatureUtils.isClass(returnType)) { >+ return AnnotationsCore.createTypeLiteral(ast, value.toString()); > } > >- if (returnType.isEnum()) { >+ >+ IType enumType = SignatureUtils.getEnumReturnType(method); >+ if (enumType != null) { > int selected = ((Integer) value).intValue(); > if (selected != -1) { >- return AnnotationsCore.createEnumMemberValuePair(ast, >- method.getDeclaringClass().getCanonicalName(), method.getName(), method.getReturnType() >- .getEnumConstants()[selected]); >+ if (enumType.isMember()) { >+ return AnnotationsCore.createEnumLiteral(ast, enumType.getDeclaringType().getFullyQualifiedName(), >+ SignatureUtils.getEnumConstants(enumType)[selected]); >+ } else { >+ return AnnotationsCore.createEnumLiteral(ast, enumType.getFullyQualifiedName(), >+ SignatureUtils.getEnumConstants(enumType)[selected]); >+ } > } > } >+ > return null; > } > >@@ -552,65 +630,76 @@ > annotationsView.refreshLabels(); > } > >- private MemberValuePair createArrayMemberValuePair(AST ast, Method method, Object[] values) { >- return AnnotationsCore.createMemberValuePair(ast, method.getName(), createArrayValueLiteral(ast, >+ private MemberValuePair createArrayMemberValuePair(AST ast, IMethod method, Object[] values) throws JavaModelException { >+ return AnnotationsCore.createMemberValuePair(ast, method.getElementName(), createArrayValueLiteral(ast, > method, values)); > } > >- @SuppressWarnings("unchecked") >- private ArrayInitializer createArrayValueLiteral(AST ast, Method method, Object[] values) { >+ private IType getComponentType(IMethod method) throws JavaModelException { >+ String returnType = method.getReturnType(); >+ if (SignatureUtils.isArray(returnType)) { >+ String elementType = Signature.getElementType(returnType); >+ IType declaringType = method.getDeclaringType(); >+ IJavaProject javaProject = declaringType.getJavaProject(); >+ if (javaProject != null) { >+ return javaProject.findType(Signature.toString(elementType)); >+ } >+ } >+ return null; >+ } >+ >+ private ArrayInitializer createArrayValueLiteral(AST ast, IMethod method, Object[] values) throws JavaModelException { > ArrayInitializer arrayInitializer = ast.newArrayInitializer(); > for (Object value : values) { >- if (value instanceof List) { >- Class<? extends java.lang.annotation.Annotation> annotationClass = >- (Class<? extends java.lang.annotation.Annotation>) method.getReturnType().getComponentType(); >- >- List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); >- >- List<Map<String, Object>> valuesList = (List<Map<String, Object>>) value; >- Iterator<Map<String, Object>> valuesIterator = valuesList.iterator(); >- while (valuesIterator.hasNext()) { >- Map<String, Object> annotationMap = valuesIterator.next(); >- Set<Entry<String, Object>> entrySet = annotationMap.entrySet(); >- Iterator<Map.Entry<String, Object>> iterator = entrySet.iterator(); >- while (iterator.hasNext()) { >- Map.Entry<java.lang.String, Object> entry = iterator.next(); >- String memberName = entry.getKey(); >- try { >- Method annotationMethod = annotationClass.getMethod(memberName, new Class[0]); >- if (annotationMethod != null) { >- Object memberValue = entry.getValue(); >- Class<?> returnType = annotationMethod.getReturnType(); >- if (returnType.equals(String.class)) { >- memberValuePairs.add(AnnotationsCore.createStringMemberValuePair(ast, memberName, >- memberValue.toString())); >- } >- if (returnType.equals(Boolean.TYPE)) { >- memberValuePairs.add(AnnotationsCore.createBooleanMemberValuePair(ast, memberName, >- (Boolean) memberValue)); >- } >- if (returnType.equals(Class.class)) { >- String className = memberValue.toString(); >- if (className.endsWith(".class")) { >- className = className.substring(0, className.lastIndexOf(".")); >+ if (value instanceof List<?>) { >+ IType componentType = getComponentType(method); >+ if (componentType != null) { >+ >+ List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>(); >+ @SuppressWarnings("unchecked") >+ List<Map<String, Object>> valuesList = (List<Map<String, Object>>) value; >+ Iterator<Map<String, Object>> valuesIterator = valuesList.iterator(); >+ while (valuesIterator.hasNext()) { >+ Map<String, Object> annotationMap = valuesIterator.next(); >+ Set<Entry<String, Object>> entrySet = annotationMap.entrySet(); >+ Iterator<Map.Entry<String, Object>> iterator = entrySet.iterator(); >+ while (iterator.hasNext()) { >+ Map.Entry<java.lang.String, Object> entry = iterator.next(); >+ String memberName = entry.getKey(); >+ try { >+ IMethod annotationMethod = componentType.getMethod(memberName, new String[] {}); >+ if (annotationMethod != null) { >+ Object memberValue = entry.getValue(); >+ String returnType = annotationMethod.getReturnType(); >+ if (SignatureUtils.isString(returnType)) { >+ memberValuePairs.add(AnnotationsCore.createStringMemberValuePair(ast, memberName, >+ memberValue.toString())); >+ } >+ if (SignatureUtils.isBoolean(returnType)) { >+ memberValuePairs.add(AnnotationsCore.createBooleanMemberValuePair(ast, memberName, >+ (Boolean) memberValue)); >+ } >+ if (SignatureUtils.isClass(returnType)) { >+ String className = memberValue.toString(); >+ if (className.endsWith(".class")) { >+ className = className.substring(0, className.lastIndexOf(".")); >+ } >+ memberValuePairs.add(AnnotationsCore.createMemberValuePair(ast, memberName, >+ AnnotationsCore.createTypeLiteral(ast, className))); > } >- memberValuePairs.add(AnnotationsCore.createMemberValuePair(ast, memberName, >- AnnotationsCore.createTypeLiteral(ast, className))); >+ // if (returnType.isPrimitive()) { >+ // memberValuePairs.add(getNumberMemberValuePair(ast, memberName, memberValue)); >+ // } > } >- // if (returnType.isPrimitive()) { >- // memberValuePairs.add(getNumberMemberValuePair(ast, memberName, memberValue)); >- // } >- } > >- } catch (SecurityException se) { >- AnnotationsCorePlugin.log(se); >- } catch (NoSuchMethodException nsme) { >- AnnotationsCorePlugin.log(nsme); >+ } catch (SecurityException se) { >+ AnnotationsCorePlugin.log(se); >+ } > } > } >+ arrayInitializer.expressions().add(AnnotationsCore.createNormalAnnotation(ast, componentType.getFullyQualifiedName(), >+ memberValuePairs)); > } >- arrayInitializer.expressions().add(AnnotationsCore.createNormalAnnotation(ast, annotationClass.getCanonicalName(), >- memberValuePairs)); > } > } > return arrayInitializer; >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsView.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsView.java,v >retrieving revision 1.13 >diff -u -r1.13 AnnotationsView.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsView.java 22 Mar 2010 22:23:13 -0000 1.13 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsView.java 23 Mar 2011 19:10:07 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > >-import java.lang.reflect.Method; > import java.util.ArrayList; > import java.util.List; > >@@ -136,13 +135,12 @@ > annotationTreeViewer.setComparator(new ViewerComparator() { > @Override > public int compare(Viewer viewer, Object obj1, Object obj2) { >- if (obj1 instanceof Class<?> && ((Class<?>) obj1).isAnnotation() >- && obj2 instanceof Class<?> && ((Class<?>) obj2).isAnnotation()) { >- return ((Class<? extends java.lang.annotation.Annotation>) obj1).getCanonicalName().compareTo( >- ((Class<? extends java.lang.annotation.Annotation>) obj2).getCanonicalName()); >+ if (obj1 instanceof IType && obj2 instanceof IType) { >+ return ((IType) obj1).getFullyQualifiedName().compareTo( >+ ((IType) obj2).getFullyQualifiedName()); > } >- if (obj1 instanceof Method && obj2 instanceof Method) { >- return ((Method)obj1).getName().compareTo(((Method)obj2).getName()); >+ if (obj1 instanceof IMethod && obj2 instanceof IMethod) { >+ return ((IMethod) obj1).getElementName().compareTo(((IMethod) obj2).getElementName()); > } > return super.compare(viewer, obj1, obj2); > } >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewCategoryFilter.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewCategoryFilter.java,v >retrieving revision 1.4 >diff -u -r1.4 AnnotationsViewCategoryFilter.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewCategoryFilter.java 2 Nov 2009 22:48:53 -0000 1.4 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewCategoryFilter.java 23 Mar 2011 19:10:07 -0000 >@@ -10,10 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > >-import java.lang.annotation.Annotation; > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.jdt.core.IType; > import org.eclipse.jface.viewers.StructuredViewer; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerFilter; >@@ -38,13 +38,12 @@ > > @Override > public boolean select(Viewer viewer, Object parentElement, Object element) { >- if (element instanceof Class && ((Class<?>) element).isAnnotation()) { >- AnnotationDefinition annotationDefinition = AnnotationsManager. >- getAnnotationDefinitionForClass((Class<? extends Annotation>)element); >+ if (element instanceof IType) { >+ AnnotationDefinition annotationDefinition = AnnotationsManager.getAnnotationDefinitionForType((IType) element); > if (annotationDefinition != null) { > return !categories.contains(annotationDefinition.getCategory()); > } >- } >+ } > return true; > } > >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java,v >retrieving revision 1.6 >diff -u -r1.6 AnnotationsViewContentProvider.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java 18 Nov 2009 19:52:45 -0000 1.6 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java 23 Mar 2011 19:10:07 -0000 >@@ -11,43 +11,54 @@ > package org.eclipse.jst.ws.internal.jaxws.ui.views; > > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jface.viewers.ITreeContentProvider; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jst.ws.annotations.core.AnnotationsManager; >+import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin; > > public class AnnotationsViewContentProvider implements ITreeContentProvider { > >- public Object[] getChildren(Object parentElement) { >- if (parentElement instanceof Class) { >- return ((Class<?>)parentElement).getDeclaredMethods(); >- } >- return new Object[] {}; >- } >- >- public Object getParent(Object element) { >- return null; >- } >- >- public boolean hasChildren(Object element) { >- if (element instanceof Class) { >- return ((Class<?>)element).getDeclaredMethods().length > 0; >- } >- return false; >- } >- >- public Object[] getElements(Object inputElement) { >- if (inputElement != null && inputElement instanceof IJavaElement && ((IJavaElement) inputElement).exists()) { >- IJavaElement javaElement = (IJavaElement) inputElement; >- return AnnotationsManager.getAnnotations(javaElement).toArray(); >- } >- return new Object[] {}; >- } >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof IType) { >+ try { >+ return ((IType) parentElement).getMethods(); >+ } catch (JavaModelException jme) { >+ JAXWSUIPlugin.log(jme.getStatus()); >+ } >+ } >+ return new Object[] {}; >+ } >+ >+ public Object getParent(Object element) { >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ if (element instanceof IType) { >+ try { >+ return ((IType) element).getMethods().length > 0; >+ } catch (JavaModelException jme) { >+ JAXWSUIPlugin.log(jme.getStatus()); >+ } >+ } >+ return false; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement != null && inputElement instanceof IJavaElement && ((IJavaElement) inputElement).exists()) { >+ IJavaElement javaElement = (IJavaElement) inputElement; >+ return AnnotationsManager.getAnnotationTypes(javaElement).toArray(); >+ } >+ return new Object[] {}; >+ } > >- public void dispose() { >+ public void dispose() { > >- } >+ } > >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- } >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } > > } >Index: src/org/eclipse/jst/ws/internal/jaxws/ui/views/ClassDialogCellEditor.java >=================================================================== >RCS file: /cvsroot/webtools/webservices/plugins/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/ClassDialogCellEditor.java,v >retrieving revision 1.4 >diff -u -r1.4 ClassDialogCellEditor.java >--- src/org/eclipse/jst/ws/internal/jaxws/ui/views/ClassDialogCellEditor.java 26 Jul 2009 21:02:18 -0000 1.4 >+++ src/org/eclipse/jst/ws/internal/jaxws/ui/views/ClassDialogCellEditor.java 23 Mar 2011 19:10:07 -0000 >@@ -56,7 +56,7 @@ > > @Override > protected void updateContents(Object value) { >- if (value != null) { >+ if (value != null && value.toString().trim().length() > 0) { > getDefaultLabel().setText(value.toString() + ".class"); //$NON-NLS-1$ > } else { > getDefaultLabel().setText(""); //$NON-NLS-1$
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 325364
:
190708
|
191786
|
191966