1 19 20 package org.netbeans.modules.java.ui.nodes.elements; 21 22 import org.netbeans.jmi.javamodel.Method; 23 import org.openide.nodes.Children; 24 import org.openide.nodes.Sheet; 25 import org.openide.nodes.Node; 26 import org.openide.src.ElementProperties; 27 28 import javax.jmi.reflect.InvalidObjectException; 29 import java.util.Map ; 30 import java.util.HashMap ; 31 32 37 public class MethodNode extends ElementNode { 38 39 private static final Map mapAttributeName; 40 41 static { 42 mapAttributeName = new HashMap (); 43 mapAttributeName.put(PROP_MODIFIERS, PROP_MODIFIERS); 44 mapAttributeName.put(ElementProperties.PROP_NAME, ElementProperties.PROP_NAME); 45 mapAttributeName.put(PROP_PARAMETERS, PROP_PARAMETERS); 46 mapAttributeName.put("typeName", PROP_RETURN); mapAttributeName.put("exceptionNames", PROP_EXCEPTIONS); } 49 50 54 public MethodNode(Method element, boolean writeable) { 55 super(element, Children.LEAF, writeable); 56 setElementFormat0(getElementFormatProperty()); 57 superSetName(element.getName()); 58 } 59 60 protected String resolveIconBase() { 61 return IconResolver.getIconBaseForMethod(getMethod()); 62 } 63 64 protected ElementFormat getElementFormatProperty() { 65 return getSourceOptions().getMethodElementFormat(); 66 } 67 68 71 protected ElementFormat getHintElementFormat() { 72 return getSourceOptions().getMethodElementLongFormat(); 73 } 74 75 protected Map getAttributeNameMap() { 76 return mapAttributeName; 77 } 78 79 80 protected Sheet createSheet () { 81 Sheet sheet = Sheet.createDefault(); 82 Node.Property[] props = new Node.Property[6]; 83 try { 84 props[0] = createModifiersProperty(writeable); 85 props[1] = createNameProperty(getMethod()); 86 props[2] = createTypeParametersProperty(); 87 props[3] = createParametersProperty(false); 88 props[4] = createReturnProperty(writeable); 89 props[5] = createExceptionsProperty(writeable); 90 Sheet.Set ps = sheet.get(Sheet.PROPERTIES); 91 ps.put(props); 92 } catch (InvalidObjectException e) { 93 } 95 return sheet; 96 } 97 98 private Node.Property createParametersProperty(boolean canW) { 99 Node.Property p = createParametersProperty(getMethod(), canW); 101 p.setValue("changeImmediate" ,Boolean.FALSE); return p; 103 } 104 105 109 private Node.Property createExceptionsProperty(boolean canW) { 110 Node.Property p = createExceptionsProperty(getMethod(), canW); 111 p.setValue("changeImmediate" ,Boolean.FALSE); return p; 113 } 114 115 Node.Property createTypeParametersProperty() { 116 Node.Property np = createTypeParametersProperty(PROP_TYPE_PARAMETERS, getMethod(), false); 117 np.setValue("changeImmediate" , Boolean.FALSE); return np; 119 } 120 121 125 private Node.Property createReturnProperty(boolean canW) { 126 return createTypeProperty(PROP_RETURN, getMethod(), canW); 127 } 128 129 private Method getMethod() { 130 return (Method) this.element; 131 } 132 } 133 | Popular Tags |