KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > ui > nodes > elements > AnnotationTypeNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.ui.nodes.elements;
21
22 import org.openide.nodes.Children;
23 import org.openide.nodes.Sheet;
24 import org.openide.util.datatransfer.NewType;
25 import org.openide.src.ElementProperties;
26 import org.netbeans.jmi.javamodel.AnnotationType;
27
28 import java.util.Map JavaDoc;
29 import java.util.HashMap JavaDoc;
30
31 /**
32  * Node representing an annotation type
33  * @see org.netbeans.jmi.javamodel.AnnotationType
34  */

35 public final class AnnotationTypeNode extends ElementNode {
36
37     private static final Map JavaDoc mapAttributeName;
38
39     static {
40         mapAttributeName = new HashMap JavaDoc();
41         mapAttributeName.put(PROP_MODIFIERS, PROP_MODIFIERS);
42         mapAttributeName.put(ElementProperties.PROP_NAME, ElementProperties.PROP_NAME);
43     }
44     
45     public AnnotationTypeNode(AnnotationType element, Children children, boolean writeable) {
46         super(element, children, writeable);
47         setElementFormat0(getElementFormatProperty());
48     }
49
50     protected String JavaDoc resolveIconBase() {
51         return IconStrings.ANNOTATION_TYPE;
52     }
53
54     protected ElementFormat getElementFormatProperty() {
55         return getSourceOptions().getAnnTypeElementFormat();
56     }
57
58     protected ElementFormat getHintElementFormat() {
59         return getSourceOptions().getAnnTypeElementLongFormat();
60     }
61
62     protected Map JavaDoc getAttributeNameMap() {
63         return mapAttributeName;
64     }
65
66     public NewType[] getNewTypes() {
67         if (writeable) {
68             return SourceEditSupport.createInterfaceNewTypes(getAnnotationType());
69         } else {
70             return super.getNewTypes();
71         }
72     }
73
74     protected Sheet createSheet() {
75         Sheet s = Sheet.createDefault();
76         Sheet.Set ps = s.get(Sheet.PROPERTIES);
77         ps.put(createModifiersProperty(writeable));
78         ps.put(createNameProperty(getAnnotationType()));
79         return s;
80     }
81
82     private AnnotationType getAnnotationType() {
83         return (AnnotationType) this.element;
84     }
85 }
86
Popular Tags