Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stp-dev] patch for bug 167787

Title: patch for bug 167787


Hello all,

I created a patch for bug 167787.
Please do me a favor to check it and apply if it's ok.

Many thanks.

Frank

### Eclipse Workspace Patch 1.0
#P features
Index: .project
===================================================================
RCS file: .project
diff -N .project
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ .project	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>features</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
#P org.eclipse.stp.common
Index: src/org/eclipse/stp/common/utils/JDTUtils.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.common/src/org/eclipse/stp/common/utils/JDTUtils.java,v
retrieving revision 1.3
diff -u -r1.3 JDTUtils.java
--- src/org/eclipse/stp/common/utils/JDTUtils.java	25 Dec 2006 05:57:37 -0000	1.3
+++ src/org/eclipse/stp/common/utils/JDTUtils.java	29 Dec 2006 05:01:17 -0000
@@ -18,7 +18,6 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -802,18 +801,17 @@
             exp = tl;
         } else if (value.getClass().isArray()) {
             //StringArray
-            String[] strings = (String[])value;
-            ArrayInitializer arrayInit = ast.newArrayInitializer();
-            List expList = arrayInit.expressions();
-
-            for (String str : strings) {
-                StringLiteral sl = ast.newStringLiteral();
-                sl.setLiteralValue(str);
-                expList.add(sl);
-            }
+       		String[] strings = (String[])value;
+       		ArrayInitializer arrayInit = ast.newArrayInitializer();
+       		List expList = arrayInit.expressions();
+
+       		for (String str : strings) {
+       			StringLiteral sl = ast.newStringLiteral();
+       			sl.setLiteralValue(str);
+       			expList.add(sl);
+       		}
 
-            exp = arrayInit;
-        
+       		exp = arrayInit;
         } else if (value.getClass().isEnum()) {
             LOG.debug("handling enum attribute");
 
@@ -835,6 +833,25 @@
 
             enumName = ast.newQualifiedName(enumName, ast.newSimpleName(value.toString()));
             exp = enumName;
+        } else if (value instanceof Class) {
+            LOG.debug("handling class attribute");
+
+        	// TODO rewrite that more elegantly :(
+            String classCanonicalName = ((Class)value).getCanonicalName();
+            int previousIndex = -1;
+            int nextIndex = classCanonicalName.indexOf('.');
+            Name className = ast.newSimpleName(classCanonicalName.substring(1 + previousIndex, nextIndex));
+            previousIndex = nextIndex;
+            nextIndex = classCanonicalName.indexOf('.', previousIndex + 1);
+            while (nextIndex != -1) {
+                String substring = classCanonicalName.substring(1 + previousIndex, nextIndex);
+                className = ast.newQualifiedName(className, ast.newSimpleName(substring));
+                previousIndex = nextIndex;
+                nextIndex = classCanonicalName.indexOf('.', previousIndex + 1);
+            }
+            String substring = classCanonicalName.substring(1 + previousIndex);
+            className = ast.newQualifiedName(className, ast.newSimpleName(substring));
+            exp = className;
         }
 
         valPair.setValue(exp);
#P org.eclipse.stp.sc.jaxws.test
Index: src/org/eclipse/stp/sc/jaxws/utils/JAXWSAnnotationInitializerTest.java
===================================================================
RCS file: src/org/eclipse/stp/sc/jaxws/utils/JAXWSAnnotationInitializerTest.java
diff -N src/org/eclipse/stp/sc/jaxws/utils/JAXWSAnnotationInitializerTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/sc/jaxws/utils/JAXWSAnnotationInitializerTest.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,230 @@
+package org.eclipse.stp.sc.jaxws.utils;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IMethod;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.ArrayInitializer;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.QualifiedName;
+
+import org.eclipse.stp.common.utils.JDTUtils;
+import org.eclipse.stp.sc.jaxws.tests.ScProjectBaseTest;
+import org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer;
+import org.eclipse.stp.sc.common.annotations.ext.IAnnotationInitializer;
+
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebFault;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+
+import java.util.*;
+
+public class JAXWSAnnotationInitializerTest extends ScProjectBaseTest {
+
+	private static final String PROJECT_NAME = "JAXWSAnnotationInitializerTestProject";
+    
+    protected String[] projectFiles = new String[] {
+        "/src/com/iona/helloworld/HelloWorld.java"
+    };
+    
+    protected String[] resourceFiles = new String[] {
+        "/resources/HelloWorld.java_resource"
+    };
+    
+    private CompilationUnit astRoot = null;
+    private ICompilationUnit compilationUnit = null;
+    private IAnnotationInitializer initializer = null; 
+    
+    private IType jdtType = null;
+    private IField jdtField = null;
+    private IMethod jdtMethod = null;
+    
+	protected void setUp() throws Exception {
+		super.setUp();
+		initializer = new JAXWSAnnotationInitializer();
+		compilationUnit = JDTUtils.getJavaUnitFromFile(files[0]);
+        astRoot = JDTUtils.getDomRootCompilationUnit(JDTUtils.getJavaUnitFromFile(files[0]));        
+    	jdtType = (IType)compilationUnit.getElementAt(0x22);
+    	jdtField = (IField)compilationUnit.getElementAt(0x3e);
+    	jdtMethod = (IMethod)compilationUnit.getElementAt(0x67);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    protected String getProjectName() {
+        return PROJECT_NAME;
+    }
+
+    protected String[] getProjectFiles() {
+        return projectFiles;
+    }
+
+    protected String[] getResourceFiles() {
+        return resourceFiles;
+    }
+    
+    public void testRequestWrapper() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(RequestWrapper.class, astRoot, jdtMethod, null);
+    	assertTrue(mvpList.size() == 3);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("className"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("localName"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("targetNamespace"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("com.iona.helloworld.SayHiRequest"));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("SayHiRequest"));
+    	assertTrue(((StringLiteral)mvpList.get(2).getValue()).getLiteralValue().equals("http://helloworld.iona.com/";));
+    }
+
+    public void testResponseWrapper() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(ResponseWrapper.class, astRoot, jdtMethod, null);
+    	assertTrue(mvpList.size() == 3);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("className"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("localName"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("targetNamespace"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("com.iona.helloworld.SayHiResponse"));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("SayHiResponse"));
+    	assertTrue(((StringLiteral)mvpList.get(2).getValue()).getLiteralValue().equals("http://helloworld.iona.com/";));
+    }
+
+    public void testServiceMode() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(ServiceMode.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 1);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("value"));
+    	assertTrue(((QualifiedName)mvpList.get(0).getValue()).getFullyQualifiedName().equals("javax.xml.ws.Service.Mode.PAYLOAD"));
+    }
+
+    public void testWebFault() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebFault.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 3);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("faultBean"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("name"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("targetNamespace"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("com.iona.helloworld.HelloWorldFaultBean"));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("HelloWorldFault"));
+    	assertTrue(((StringLiteral)mvpList.get(2).getValue()).getLiteralValue().equals("http://helloworld.iona.com/";));
+    }
+
+    public void testWebServiceClient() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebServiceClient.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 3);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("name"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("targetNamespace"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("wsdlLocation"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("com.iona.helloworld.HelloWorld"));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("http://helloworld.iona.com/";));
+    	assertTrue(((StringLiteral)mvpList.get(2).getValue()).getLiteralValue().equals("http://helloworld.iona.com/helloworld.wsdl";));
+    }
+
+    public void testWebEndpoint() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebEndpoint.class, astRoot, jdtMethod, null);
+    	assertTrue(mvpList.size() == 1);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("name"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("HelloWorldHTTPPort"));
+    }
+
+    public void testWebServiceProvider() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebServiceProvider.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 4);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("portName"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("serviceName"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("targetNamespace"));
+    	assertTrue(mvpList.get(3).getName().getIdentifier().equals("wsdlLocation"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("HelloWorldPort"));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("HelloWorldService"));
+    	assertTrue(((StringLiteral)mvpList.get(2).getValue()).getLiteralValue().equals("http://helloworld.iona.com/";));
+    	assertTrue(((StringLiteral)mvpList.get(3).getValue()).getLiteralValue().equals("http://helloworld.iona.com/helloworld.wsdl";));
+    }
+
+    public void testBindingType() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(BindingType.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 1);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("value"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals("http://schemas.xmlsoap.org/wsdl/soap/http";));
+    }
+
+    public void testWebServiceRefType() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebServiceRef.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 5);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("mappedName"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("name"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("type"));
+    	assertTrue(mvpList.get(3).getName().getIdentifier().equals("value"));
+    	assertTrue(mvpList.get(4).getName().getIdentifier().equals("wsdlLocation"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals(""));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("<specify your reference name here>"));
+    	assertTrue(((QualifiedName)mvpList.get(2).getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    	assertTrue(((QualifiedName)mvpList.get(3).getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    	assertTrue(((StringLiteral)mvpList.get(4).getValue()).getLiteralValue().equals("http://helloworld.iona.com/helloworld.wsdl";));
+    }
+
+    public void testWebServiceRefField() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebServiceRef.class, astRoot, jdtField, null);
+    	assertTrue(mvpList.size() == 5);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("mappedName"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("name"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("type"));
+    	assertTrue(mvpList.get(3).getName().getIdentifier().equals("value"));
+    	assertTrue(mvpList.get(4).getName().getIdentifier().equals("wsdlLocation"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals(""));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals(""));
+    	assertTrue(((QualifiedName)mvpList.get(2).getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    	assertTrue(((QualifiedName)mvpList.get(3).getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    	assertTrue(((StringLiteral)mvpList.get(4).getValue()).getLiteralValue().equals("http://helloworld.iona.com/helloworld.wsdl";));
+    }
+
+    public void testWebServiceRefMethod() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebServiceRef.class, astRoot, jdtMethod, null);
+    	assertTrue(mvpList.size() == 5);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("mappedName"));
+    	assertTrue(mvpList.get(1).getName().getIdentifier().equals("name"));
+    	assertTrue(mvpList.get(2).getName().getIdentifier().equals("type"));
+    	assertTrue(mvpList.get(3).getName().getIdentifier().equals("value"));
+    	assertTrue(mvpList.get(4).getName().getIdentifier().equals("wsdlLocation"));
+    	assertTrue(((StringLiteral)mvpList.get(0).getValue()).getLiteralValue().equals(""));
+    	assertTrue(((StringLiteral)mvpList.get(1).getValue()).getLiteralValue().equals("<specify your reference name here>"));
+    	assertTrue(((QualifiedName)mvpList.get(2).getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    	assertTrue(((QualifiedName)mvpList.get(3).getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    	assertTrue(((StringLiteral)mvpList.get(4).getValue()).getLiteralValue().equals("http://helloworld.iona.com/helloworld.wsdl";));
+    }
+
+    public void testWebServiceRefs() throws Exception {
+    	List<MemberValuePair> mvpList = initializer.getDefaultAttributes(WebServiceRefs.class, astRoot, jdtType, null);
+    	assertTrue(mvpList.size() == 1);
+    	assertTrue(mvpList.get(0).getName().getIdentifier().equals("value"));
+    	ArrayInitializer arrayInit = ((ArrayInitializer)mvpList.get(0).getValue());
+    	List expList = arrayInit.expressions();
+    	for (Object obj : expList) {
+    		NormalAnnotation anno = (NormalAnnotation)obj;
+    		List pairList = anno.values();
+    		MemberValuePair mvp;
+    		mvp = (MemberValuePair)pairList.get(0);
+    		assertTrue(mvp.getName().getIdentifier().equals("mappedName"));
+        	assertTrue(((StringLiteral)mvp.getValue()).getLiteralValue().equals(""));
+    		mvp = (MemberValuePair)pairList.get(1);
+    		assertTrue(mvp.getName().getIdentifier().equals("name"));
+        	assertTrue(((StringLiteral)mvp.getValue()).getLiteralValue().equals("<specify your reference name here>"));
+    		mvp = (MemberValuePair)pairList.get(2);
+    		assertTrue(mvp.getName().getIdentifier().equals("type"));
+        	assertTrue(((QualifiedName)mvp.getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    		mvp = (MemberValuePair)pairList.get(3);
+    		assertTrue(mvp.getName().getIdentifier().equals("value"));
+        	assertTrue(((QualifiedName)mvp.getValue()).getFullyQualifiedName().equals("java.lang.Object"));
+    		mvp = (MemberValuePair)pairList.get(4);
+    		assertTrue(mvp.getName().getIdentifier().equals("wsdlLocation"));
+        	assertTrue(((StringLiteral)mvp.getValue()).getLiteralValue().equals("http://helloworld.iona.com/helloworld.wsdl";));
+    	}
+    }
+}
Index: src/resources/HelloWorld.java_resource
===================================================================
RCS file: src/resources/HelloWorld.java_resource
diff -N src/resources/HelloWorld.java_resource
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/resources/HelloWorld.java_resource	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,9 @@
+
+package com.iona.helloworld;
+
+public class HelloWorld {
+	public String myName = "anonymous";
+    public void sayHi(String msg) {
+    	System.out.println(msg);
+    }
+}
#P org.eclipse.stp.sc.jaxws
Index: plugin.xml
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.jaxws/plugin.xml,v
retrieving revision 1.11
diff -u -r1.11 plugin.xml
--- plugin.xml	26 Dec 2006 10:21:55 -0000	1.11
+++ plugin.xml	29 Dec 2006 05:01:24 -0000
@@ -335,13 +335,58 @@
             nature="org.eclipse.stp.sc.jaxws.nature"/>
       <annotation
             annotationClass="javax.xml.ws.RequestWrapper"
-            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.CoreAnnotationInitializer"
-            name="RequestWrapper"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="RequestWrapper"/>
             nature="org.eclipse.stp.sc.jaxws.nature"/>
       <annotation
             annotationClass="javax.xml.ws.ResponseWrapper"
-            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.CoreAnnotationInitializer"
-            name="ResponseWrapper"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="ResponseWrapper"/>
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+      <annotation
+            annotationClass="javax.xml.ws.ServiceMode"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="ServiceMode"
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+            classOnly="true"/>
+      <annotation
+            annotationClass="javax.xml.ws.WebFault"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="WebFault"/>
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+      <annotation
+            annotationClass="javax.xml.ws.WebServiceClient"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="WebServiceClient"
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+            classOnly="true"/>
+      <annotation
+            annotationClass="javax.xml.ws.WebEndpoint"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="WebEndpoint"
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+            classOnly="true" />
+      <annotation
+            annotationClass="javax.xml.ws.WebServiceProvider"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="WebServiceProvider"
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+            classOnly="true"/>
+      <annotation
+            annotationClass="javax.xml.ws.BindingType"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="BindingType"
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+            classOnly="true"/>
+      <annotation
+            annotationClass="javax.xml.ws.WebServiceRef"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="WebServiceRef"/>
+            nature="org.eclipse.stp.sc.jaxws.nature"/>
+      <annotation
+            annotationClass="javax.xml.ws.WebServiceRefs"
+            initializerClass="org.eclipse.stp.sc.jaxws.utils.ext.JAXWSAnnotationInitializer"
+            name="WebServiceRefs"/>
             nature="org.eclipse.stp.sc.jaxws.nature"/>
    </extension>
    <extension
Index: src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.jaxws/src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java,v
retrieving revision 1.16
diff -u -r1.16 CoreAnnotationInitializer.java
--- src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java	25 Dec 2006 06:30:06 -0000	1.16
+++ src/org/eclipse/stp/sc/jaxws/utils/ext/CoreAnnotationInitializer.java	29 Dec 2006 05:01:28 -0000
@@ -21,8 +21,6 @@
 import javax.jws.WebResult;
 import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
-import javax.xml.ws.RequestWrapper;
-import javax.xml.ws.ResponseWrapper;
 
 import org.eclipse.jdt.core.IMember;
 import org.eclipse.jdt.core.IMethod;
@@ -93,63 +91,6 @@
                                                         fullyQualifiedName));
             */
 
-        } else if  (annotationClass.equals(RequestWrapper.class)) {
-            /* sample output for a method : < String sayHi() > of the class < com.iona.helloworld.HelloWorld > 
-                @RequestWrapper(targetNamespace = "http://om.iona.helloworld.helloworld/";,
-                                className = "com.iona.helloworld.helloworld.SayHiRequest",
-                                localName = "SayHiRequest").
-            */
- 
-            annotValues = new ArrayList<MemberValuePair>();
-            
-            IMethod method = (IMethod)jdtMember;
-            IType type = method.getDeclaringType();
-
-            String packageName = type.getPackageFragment().getElementName();
-            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
-                                                        "targetNamespace",
-                                                        JDTUtils.getNamespace(packageName.toLowerCase())));
-
-            
-            String className = method.getElementName().substring(0, 1).toUpperCase()
-                                + method.getElementName().substring(1);
-            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
-                                                        "className",
-                                                        packageName + "." + className));
-            
-            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
-                                                        "localName",
-                                                        method.getElementName()));
-        
-        } else if  (annotationClass.equals(ResponseWrapper.class)) {
-            /* sample output for a method : < String sayHi() > of the class < com.iona.helloworld.HelloWorld > 
-                @ResponseWrapper(targetNamespace = "http://com.iona.helloworld.helloworld/";, 
-                                 className = "com.iona.helloworld.helloworld.SayHiResponse",
-                                 localName = "SayHiResponse")
-            */
-            
-            annotValues = new ArrayList<MemberValuePair>();
-            
-            IMethod method = (IMethod)jdtMember;
-            IType type = method.getDeclaringType();
-
-            String packageName = type.getPackageFragment().getElementName();
-            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
-                                                        "targetNamespace",
-                                                        JDTUtils.getNamespace(packageName)));
-
-            
-            String className = method.getElementName().substring(0, 1).toUpperCase()
-                + method.getElementName().substring(1)
-                + "Response";
-            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
-                                                        "className",
-                                                        packageName + "." + className));
-            String localName = method.getElementName() + "Response";
-            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
-                                                        "localName",
-                                                        localName));
-        
         } else if  (annotationClass.equals(SOAPBinding.class)) {
         	annotValues = new ArrayList<MemberValuePair>();
         	annotValues.add(JDTUtils.newMemberValuePair(astRoot,
Index: src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java
===================================================================
RCS file: src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java
diff -N src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/stp/sc/jaxws/utils/ext/JAXWSAnnotationInitializer.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,454 @@
+/*******************************************************************************
+* Copyright (c) 2006 IONA Technologies PLC
+* 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:
+*     IONA Technologies PLC - initial API and implementation
+*******************************************************************************/
+package org.eclipse.stp.sc.jaxws.utils.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import java.lang.annotation.Annotation;
+
+import javax.xml.ws.soap.SOAPBinding;
+
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebFault;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.ArrayInitializer;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+
+import org.eclipse.stp.sc.common.annotations.ext.IAnnotationInitializer;
+
+import org.eclipse.stp.common.utils.JDTUtils;
+
+public class JAXWSAnnotationInitializer implements IAnnotationInitializer {
+	
+	@SuppressWarnings("unchecked")
+    public List<MemberValuePair> getDefaultAttributes(Class<? extends Annotation> annotationClass,
+                                                      CompilationUnit astRoot,
+                                                      IMember jdtMember,
+                                                      SingleVariableDeclaration jdtMemberParam) {
+        List<MemberValuePair> annotValues = null;
+        
+        if  (annotationClass.equals(RequestWrapper.class)) {
+            /* 
+             * @Target(value=METHOD)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface RequestWrapper
+             * String className
+             * string localName
+             * String targetNamespace
+             * 
+             * sample output for a method: <String sayHi()> of the class <com.iona.helloworld.HelloWorld>
+             *  
+             * @RequestWrapper(className="com.iona.helloworld.SayHiRequest",
+             *                 localName="SayHiRequest",
+             *                 targetNamespace="http://helloworld.iona.com/";)
+             */
+ 
+            annotValues = new ArrayList<MemberValuePair>();
+            
+            IMethod method = (IMethod)jdtMember;
+            IType type = method.getDeclaringType();
+
+            String packageName = type.getPackageFragment().getElementName();
+
+            String className = method.getElementName().substring(0, 1).toUpperCase() +
+        		method.getElementName().substring(1) + "Request";
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "className",
+                                                        packageName + "." + className));
+        
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "localName",
+                                                        className));
+        
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "targetNamespace",
+                                                        JDTUtils.getNamespace(packageName)));
+
+        } else if  (annotationClass.equals(ResponseWrapper.class)) {
+            /* 
+             * @Target(value=METHOD)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface ResponseWrapper
+             * String className
+             * string localName
+             * String targetNamespace
+             * 
+             * sample output for a method: <String sayHi()> of the class <com.iona.helloworld.HelloWorld>
+             *  
+             * @ResponseWrapper(className="com.iona.helloworld.SayHiResponse",
+             *                  localName="SayHiResponse",
+             *                  targetNamespace="http://helloworld.iona.com/";)
+             */
+            
+            annotValues = new ArrayList<MemberValuePair>();
+            
+            IMethod method = (IMethod)jdtMember;
+            IType type = method.getDeclaringType();
+
+            String packageName = type.getPackageFragment().getElementName();
+
+            String className = method.getElementName().substring(0, 1).toUpperCase() +
+            	method.getElementName().substring(1) + "Response";
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "className",
+                                                        packageName + "." + className));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "localName",
+                                                        className));
+        
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                    "targetNamespace",
+                    JDTUtils.getNamespace(packageName)));
+
+        } else if (annotationClass.equals(ServiceMode.class)) {
+            /* 
+             * @Target(value=TYPE)
+             * @Retention(value=RUNTIME)
+             * @Inherited
+             * @Documented
+             * public @interface ServiceMode
+             * Service.Mode value
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * ServiceMode(value=javax.xml.ws.Service.Mode.PAYLOAD)
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+        	
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "value",
+                                                        javax.xml.ws.Service.Mode.PAYLOAD));
+
+        } else if (annotationClass.equals(WebFault.class)) {
+            /* 
+             * @Target(value=TYPE)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface WebFault
+             * String faultBean
+             * string name
+             * String targetNamespace
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * @WebFault(faultBean="com.iona.helloworld.HelloWorldFaultBean",
+             *           name="HelloWorldFault",
+             *           targetNamespace = "http://helloworld.iona.com/";)
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+        	
+            IType type = (IType)jdtMember;
+
+            String typeName = type.getElementName();
+            String packageName = type.getPackageFragment().getElementName();
+
+            String faultPostfix = "Fault";
+            String faultBeanPostfix = "FaultBean";
+            String[] faultPostfixes = { "Error", "Fault", "Exception" }; 
+
+            String shortName = type.getElementName();
+
+            for (String postfix : faultPostfixes) {
+            	if (typeName.endsWith(postfix)) {
+            		shortName = typeName.substring(0, typeName.length() - postfix.length());
+            		break;
+            	}
+            }
+            
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "faultBean",
+                                                        packageName + "."  + shortName.concat(faultBeanPostfix)));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "name",
+                                                        typeName.equals(shortName) ? shortName.concat(faultPostfix) : typeName));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "targetNamespace",
+                                                        JDTUtils.getNamespace(packageName)));
+
+        } else if (annotationClass.equals(WebServiceClient.class)) {
+            /* 
+             * @Target(value=TYPE)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface WebServiceClient
+             * String name
+             * string targetNamespace
+             * String wsdlLocation
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * @WebServiceClient(name="HelloWorld",
+             *                   targetNamespace="http://helloworld.iona.com/";,
+             *                   wsdlLocation="http://helloworld.iona.com/helloworld.wsdl";)
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+        	
+            IType type = (IType)jdtMember;
+
+            String packageName = type.getPackageFragment().getElementName();
+            String targetNamespace = JDTUtils.getNamespace(packageName);
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "name",
+                                                        packageName + "." + type.getElementName()));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "targetNamespace",
+                                                        JDTUtils.getNamespace(packageName)));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "wsdlLocation",
+                                                        targetNamespace + type.getElementName().toLowerCase() + "." + "wsdl"));
+
+            
+        } else if (annotationClass.equals(WebEndpoint.class)) {
+            /* 
+             * @Target(value=METHOD)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface WebEndpoint
+             * String name
+             * 
+             * sample output for a method: <String sayHi()> of the class <com.iona.helloworld.HelloWorld>
+             *  
+             * @WebEndpoint(name="HelloWorldHTTPPort")
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+        	
+            IMethod method = (IMethod)jdtMember;
+            IType type = method.getDeclaringType();
+            String typeName = type.getElementName();
+
+            String typePostfix = "Service";
+            String portPostfix = "HTTPPort";
+            String endpoint = typeName.endsWith(typePostfix) ? typeName.substring(0, typeName.length() - typePostfix.length()) : typeName;
+            endpoint = endpoint.concat(portPostfix);
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "name",
+                                                        endpoint));
+        	
+        } else if (annotationClass.equals(WebServiceProvider.class)) {
+            /* 
+             * @Target(value=TYPE)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface WebServiceProvider
+             * String portName
+             * String serviceName
+             * String targetNamespace
+             * String wsdlLocation
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * @WebServiceProvider(portName="HelloWorldPort",
+             *                     serviceName="HelloWorldService",
+             *                     targetNamespace="http://helloworld.iona.com/";,
+             *                     wsdlLocation="http://helloworld.iona.com/helloworld.wsdl";)
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+        	
+            IType type = (IType)jdtMember;
+            String typeName = type.getElementName();
+
+            String packageName = type.getPackageFragment().getElementName();
+            String targetNamespace = JDTUtils.getNamespace(packageName);
+
+            String portPostfix = "Port";
+            String servicePostfix = "Service";
+            String shortName = typeName.endsWith(servicePostfix) ? typeName.substring(0, typeName.length() - servicePostfix.length()) : typeName;
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "portName",
+                                                        shortName + portPostfix));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "serviceName",
+                                                        shortName + servicePostfix));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "targetNamespace",
+                                                        JDTUtils.getNamespace(packageName)));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "wsdlLocation",
+                                                        targetNamespace + type.getElementName().toLowerCase() + "." + "wsdl"));
+        	
+        } else if (annotationClass.equals(BindingType.class)) {
+            /* 
+             * @Target(value=TYPE)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface BindingType
+             * String value
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * @BindingType(value="http://schemas.xmlsoap.org/wsdl/soap/http";)
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "value",
+                                                        SOAPBinding.SOAP11HTTP_BINDING));
+        
+        } else if (annotationClass.equals(WebServiceRef.class)) {
+            /* 
+             * @Target(value={TYPE,METHOD,FIELD})
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface WebServiceRef
+             * String mappedName
+             * String name
+             * Class type
+             * Class value
+             * String wsdlLocation
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * @WebServiceRef(mappedName="",
+             *                name="<specify your reference name here>",
+             *                type=java.lang.Object.class,
+             *                value=java.lang.Object.class,
+             *                wsdlLocation="http://helloworld.iona.com/helloworld.wsdl";)
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+        	
+        	IType type = null;
+        	
+        	if (jdtMember instanceof IType) {
+        		type = (IType)jdtMember; 
+        	} else if (jdtMember instanceof IField) {
+        		type = ((IField)jdtMember).getDeclaringType();
+        	} else if (jdtMember instanceof IMethod) {
+        		type = ((IMethod)jdtMember).getDeclaringType();
+        	}
+
+            String packageName = type.getPackageFragment().getElementName();
+            String targetNamespace = JDTUtils.getNamespace(packageName);
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "mappedName",
+                                                        ""));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "name",
+                                                        jdtMember instanceof IField ? "" : "<specify your reference name here>"));
+
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "type",
+                                                        java.lang.Object.class));
+            
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "value",
+                                                        java.lang.Object.class));
+            
+            annotValues.add(JDTUtils.newMemberValuePair(astRoot,
+                                                        "wsdlLocation",
+                                                        targetNamespace + type.getElementName().toLowerCase() + "." + "wsdl"));
+
+        } else if (annotationClass.equals(WebServiceRefs.class)) {
+            /* 
+             * @Target(value=TYPE)
+             * @Retention(value=RUNTIME)
+             * @Documented
+             * public @interface WebServiceRefs
+             * WebServiceRef[] value
+             * 
+             * sample output for a class: <com.iona.helloworld.HelloWorld>
+             *  
+             * @WebServiceRefs({@WebServiceRef(mappedName="",
+             *                                 name="<specify your reference name here>",
+             *                                 type=java.lang.Object.class,
+             *                                 value=java.lang.Object.class,
+             *                                 wsdlLocation="http://helloworld.iona.com/helloworld.wsdl";),
+             *                  @WebServiceRef(mappedName="",
+             *                                 name="<specify your reference name here>",
+             *                                 type=java.lang.Object.class,
+             *                                 value=java.lang.Object.class,
+             *                                 wsdlLocation="http://helloworld.iona.com/helloworld.wsdl";)})
+             */
+
+        	annotValues = new ArrayList<MemberValuePair>();
+
+        	@WebServiceRef(mappedName="",
+                           name="<specify your reference name here>",
+                           type=java.lang.Object.class,
+                           value=java.lang.Object.class,
+                           wsdlLocation="http://helloworld.iona.com/helloworld.wsdl";)
+            class DummyClass {};
+            
+            Annotation[] annos = DummyClass.class.getAnnotations();
+            WebServiceRef[] refs = {(WebServiceRef)annos[0], (WebServiceRef)annos[0]}; 
+        	
+    		ArrayInitializer arrayInit = astRoot.getAST().newArrayInitializer();
+    		List<NormalAnnotation> expList = arrayInit.expressions();
+    		
+    		for (WebServiceRef ref : refs) {
+    			NormalAnnotation anno = astRoot.getAST().newNormalAnnotation();
+    			List<MemberValuePair> pairList = anno.values();
+    			pairList.add(JDTUtils.newMemberValuePair(astRoot,
+                                                         "mappedName",
+                                                         ref.mappedName()));
+    			pairList.add(JDTUtils.newMemberValuePair(astRoot,
+                                                         "name",
+                                                         ref.name()));
+    			pairList.add(JDTUtils.newMemberValuePair(astRoot,
+                                                         "type",
+                                                         ref.type()));
+    			pairList.add(JDTUtils.newMemberValuePair(astRoot,
+                                                         "value",
+                                                         ref.value()));
+    			pairList.add(JDTUtils.newMemberValuePair(astRoot,
+                                                         "wsdlLocation",
+                                                         ref.wsdlLocation()));
+    			expList.add(anno);
+    		}
+
+    		MemberValuePair pair = astRoot.getAST().newMemberValuePair();
+            pair.setName(astRoot.getAST().newSimpleName("value"));
+            pair.setValue(arrayInit);
+            annotValues.add(pair);
+        }
+
+        return annotValues;
+    }
+}
#P org.eclipse.stp.sc.common
Index: schema/AnnotationSupport.exsd
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.common/schema/AnnotationSupport.exsd,v
retrieving revision 1.2
diff -u -r1.2 AnnotationSupport.exsd
--- schema/AnnotationSupport.exsd	26 Dec 2006 10:21:59 -0000	1.2
+++ schema/AnnotationSupport.exsd	29 Dec 2006 05:01:34 -0000
@@ -78,6 +78,20 @@
                </documentation>
             </annotation>
          </attribute>
+         <attribute name="interfaceOnly" type="boolean">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="classOnly" type="boolean">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
       </complexType>
    </element>
 
Index: src/org/eclipse/stp/sc/common/annotations/ScAnnotationSupportUtils.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.common/src/org/eclipse/stp/sc/common/annotations/ScAnnotationSupportUtils.java,v
retrieving revision 1.2
diff -u -r1.2 ScAnnotationSupportUtils.java
--- src/org/eclipse/stp/sc/common/annotations/ScAnnotationSupportUtils.java	26 Dec 2006 10:21:59 -0000	1.2
+++ src/org/eclipse/stp/sc/common/annotations/ScAnnotationSupportUtils.java	29 Dec 2006 05:01:35 -0000
@@ -43,6 +43,8 @@
     private static List<Class> methodAnnotations;
     private static List<Class> typeAnnotations;
     private static List<Class> paramAnnotations;
+    private static List<Class> fieldAnnotations;
+    private static List<Class> annoAnnotations;
 
     protected ScAnnotationSupportUtils() {
     }
@@ -70,6 +72,20 @@
         return paramAnnotations;
     }
 
+    public static List<Class> getAvailableAnnotationsForField(IProject project) {
+    	if (fieldAnnotations == null || fieldAnnotations.size() == 0) {
+    		fieldAnnotations = getAnnotationClassesForJavaElement(ElementType.FIELD, project);
+    	}
+    	return fieldAnnotations;
+    }
+
+    public static List<Class> getAvailableAnnotationsForAnno(IProject project) {
+    	if (annoAnnotations == null || annoAnnotations.size() == 0) {
+    		annoAnnotations = getAnnotationClassesForJavaElement(ElementType.ANNOTATION_TYPE, project);
+    	}
+    	return fieldAnnotations;
+    }
+
     public static String getAnnotationImport(Annotation annotation) {
         String annotationName = annotation.getTypeName().toString();
 
Index: src/org/eclipse/stp/sc/common/views/AnnotationViewerContentProvider.java
===================================================================
RCS file: /cvsroot/stp/org.eclipse.stp.servicecreation/org.eclipse.stp.sc.common/src/org/eclipse/stp/sc/common/views/AnnotationViewerContentProvider.java,v
retrieving revision 1.2
diff -u -r1.2 AnnotationViewerContentProvider.java
--- src/org/eclipse/stp/sc/common/views/AnnotationViewerContentProvider.java	26 Dec 2006 10:21:59 -0000	1.2
+++ src/org/eclipse/stp/sc/common/views/AnnotationViewerContentProvider.java	29 Dec 2006 05:01:35 -0000
@@ -15,6 +15,7 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.jdt.core.IMethod;
 import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.IField;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
 import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -51,26 +52,36 @@
      */
     public Object[] getElements(Object input) {
     	try {
-        if (input instanceof IMethod) {
-        	IMethod method = (IMethod)input;
-        	IProject project = method.getUnderlyingResource().getProject();
-        	List<Class> list = ScAnnotationSupportUtils.getAvailableAnnotationsForMethod(project);
-            LOG.debug("retrieved methods annotations: " + list);
-            return list.toArray();
-        }
-
-        if (input instanceof IType) {
-        	IType method = (IType)input;
-        	IProject project = method.getUnderlyingResource().getProject();
-        	return ScAnnotationSupportUtils.getAvailableAnnotationsForType(project).toArray();
-        }
+    		if (input instanceof IMethod) {
+    			IMethod method = (IMethod)input;
+    			IProject project = method.getUnderlyingResource().getProject();
+    			List<Class> list = ScAnnotationSupportUtils.getAvailableAnnotationsForMethod(project);
+    			LOG.debug("retrieved methods annotations: " + list);
+    			return list.toArray();
+    		}
+
+    		if (input instanceof IType) {
+    			IType type = (IType)input;
+    			IProject project = type.getUnderlyingResource().getProject();
+    			if (type.isAnnotation()) {
+    				return ScAnnotationSupportUtils.getAvailableAnnotationsForAnno(project).toArray();
+    			} else {
+    				return ScAnnotationSupportUtils.getAvailableAnnotationsForType(project).toArray();
+    			}
+    		}
         
-        if (input instanceof SingleVariableDeclaration) {
-        	SingleVariableDeclaration var = (SingleVariableDeclaration)input;
-        	CompilationUnit root = (CompilationUnit)var.getRoot();
-        	IProject project = root.getJavaElement().getCorrespondingResource().getProject();
-            return ScAnnotationSupportUtils.getAvailableAnnotationsForParam(project).toArray();
-        }
+    		if (input instanceof SingleVariableDeclaration) {
+    			SingleVariableDeclaration var = (SingleVariableDeclaration)input;
+    			CompilationUnit root = (CompilationUnit)var.getRoot();
+    			IProject project = root.getJavaElement().getCorrespondingResource().getProject();
+    			return ScAnnotationSupportUtils.getAvailableAnnotationsForParam(project).toArray();
+    		}
+        
+    		if (input instanceof IField) {
+    			IField field = (IField)input;
+    			IProject project = field.getUnderlyingResource().getProject();
+    			return ScAnnotationSupportUtils.getAvailableAnnotationsForField(project).toArray();
+    		}
     	} catch (Exception e) {
     		e.printStackTrace();
     	}

Back to the top