Results 1 to 3 of 3
  1. #1
    paulgray is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default Missing annotations in Eclipse plugin

    Hello everyone,

    We are creating the plugin for the BIRT for creating the reports from the objects we pass to it. During the report creation phase, we will be using the graph representation of the objects network.

    To provide the user-friendly graph, we decided to use annotations to indicate, which fields should be displayable and what should be their names on graph.

    The annotation:
    Java Code:
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.FIELD)
    public @interface BIRTVertex {
    	String displayableName() default "[unset]";
    	boolean expandable() default false;
    }
    Then, when user points the place where the properly annotated classes are placed, we are loading them (using our own class loader) and look for the annotated fields:
    Java Code:
    for(Field f : cl.getFields()) {
    	System.out.println("Checking field " + f.getName());
    	if(f.isAnnotationPresent(BIRTVertex.class)) {
    		System.out.println("Is annotation " + f.getName());
    		BIRTVertex vertex = f.getAnnotation(BIRTVertex.class);
    		DisplayableField field = new DisplayableField();
    				
    		field.setDisplayableName(vertex.displayableName());
    		field.setExpandable(vertex.expandable());
    		field.setRealName(f.getName());
    		field.setField(f);
    		field.setType(f.getType());
    				
    		if(f.isAnnotationPresent(BIRTIterable.class)) {
    			field.setIterable(true);
    		}
    				
    		fields.add(field);
    	}
    	System.out.println("Checked field " + f.getName());
    }
    It works great as long as we are testing it as a simple Java program. The result of the AnnotationGetter for:
    Java Code:
    public class Contractor {
    	@BIRTVertex(displayableName = "Simple Contractor", expandable = true)
    	public NameBox nm = new NameBox("SomeNAME");
    }
    is:
    Java Code:
    Checking field nm
    Is annotation nm
    Checked field nm
    and everything is ok. Then comes the toughest part: we are trying to run the code inside the new eclipse application (inside the BIRT plugin). The same code (copy/paste pattern), different behavior:
    Java Code:
    Checking field nm
    Checked field nm
    The BIRTVertex class is available in the plugin environment, I have even loaded it manually (Class.forName).

    We have tried a hundreds of configurations, classpath settings and so on: the annotations are invisible...

    Can anyone tell me what I am doing wrong or propose the solution of the problem?

  2. #2
    ahfang09 is offline Member
    Join Date
    Jun 2009
    Posts
    1
    Rep Power
    0

    Default Missing annotations in Eclipse plugin

    I meet the same prolem.If someone knows the problem and solved it ,please mail to ahfang09@163.com.I appreciate your help very much.

  3. #3
    paulgray is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default

    The problem was with the fields permissions: in the annotation definition, there should be:

    Java Code:
    public String displayableName() default "[unset]";
    public boolean expandable() default false;
    instead of:
    Java Code:
    String displayableName() default "[unset]";
    boolean expandable() default false;
    After that small change everything works smoothly...

Similar Threads

  1. Help with Eclipse SWT - OLE plugin
    By nmarathe in forum Eclipse
    Replies: 4
    Last Post: 03-11-2009, 02:37 PM
  2. Replies: 1
    Last Post: 12-15-2008, 09:11 PM
  3. Eclipse Plugin Dev
    By eva in forum Eclipse
    Replies: 1
    Last Post: 01-21-2008, 11:56 PM
  4. AnyEdit Plugin For Eclipse Plugin
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-18-2007, 01:28 PM
  5. plugin for eclipse
    By sin in forum Eclipse
    Replies: 1
    Last Post: 05-10-2007, 08:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •