1 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.nodes.Node; 25 import org.openide.util.datatransfer.NewType; 26 import org.openide.src.ElementProperties; 27 import org.netbeans.jmi.javamodel.JavaEnum; 28 29 import java.util.Map ; 30 import java.util.HashMap ; 31 32 36 public final class EnumNode extends ElementNode { 37 38 private static final Map mapAttributeName; 39 40 static { 41 mapAttributeName = new HashMap (); 42 mapAttributeName.put(PROP_MODIFIERS, PROP_MODIFIERS); 43 mapAttributeName.put(ElementProperties.PROP_NAME, ElementProperties.PROP_NAME); 44 mapAttributeName.put("interfaceNames", PROP_INTERFACES); } 46 47 public EnumNode(JavaEnum element, Children children, boolean writeable) { 48 super(element, children, writeable); 49 setElementFormat0(getElementFormatProperty()); 50 } 51 52 protected String resolveIconBase() { 53 return IconStrings.ENUM; 54 } 55 56 protected ElementFormat getElementFormatProperty() { 57 return getSourceOptions().getEnumElementFormat(); 58 } 59 60 protected ElementFormat getHintElementFormat() { 61 return getSourceOptions().getEnumElementLongFormat(); 62 } 63 64 protected Map getAttributeNameMap() { 65 return mapAttributeName; 66 } 67 68 public NewType[] getNewTypes() { 69 if (writeable) { 70 return SourceEditSupport.createEnumNewTypes(getEnum()); 71 } else { 72 return super.getNewTypes(); 73 } 74 } 75 76 protected Sheet createSheet() { 77 Sheet s = Sheet.createDefault(); 78 Sheet.Set ps = s.get(Sheet.PROPERTIES); 79 ps.put(createModifiersProperty(writeable)); 80 ps.put(createNameProperty(getEnum())); 81 ps.put(createInterfacesProperty(writeable)); 82 return s; 83 } 84 85 90 private Node.Property createInterfacesProperty(boolean canW) { 91 Node.Property prop = ClassNode.createInterfacesProperty(getEnum(), canW); 92 93 prop.setValue("changeImmediate" , Boolean.FALSE); setModel(getEnum(), prop); 95 96 return prop; 97 } 98 99 private JavaEnum getEnum() { 100 return (JavaEnum) this.element; 101 } 102 } 103 | Popular Tags |