1 19 20 package org.netbeans.modules.mdrxml.looks; 21 22 import java.awt.datatransfer.Transferable ; 23 import java.awt.datatransfer.StringSelection ; 24 import java.io.IOException ; 25 import org.openide.nodes.*; 26 import org.openide.util.NbBundle; 27 import org.netbeans.api.looks.*; 28 import org.netbeans.spi.looks.*; 29 import xmlmodel.AttributeNode; 30 31 35 public class AttributeNodeLook extends NodeLook { 36 37 private static final String ICON = "org/netbeans/modules/mdrxml/resources/attributeNode"; 38 39 private static class ValueProperty extends PropertySupport.ReadWrite { 40 41 private AttributeNode node; 42 43 public ValueProperty (AttributeNode node) { 44 super (NbBundle.getMessage(AttributeNodeLook.class,"TXT_Value"),String .class,NbBundle.getMessage(AttributeNodeLook.class,"TXT_Value"),NbBundle.getMessage(AttributeNodeLook.class,"TIP_Value")); 45 this.node = node; 46 } 47 48 public Object getValue () { 49 if (this.node != null) 50 return this.node.getValue(); 51 else 52 return null; 53 } 54 55 public void setValue (Object value) { 56 if (value instanceof String && this.node != null) 57 node.setValue ((String )value); 58 } 59 } 60 61 62 public AttributeNodeLook() { 63 super (NbBundle.getMessage (AttributeNodeLook.class, "TXT_AttributeNodeLook")); 64 } 65 66 public String iconBase (Look.NodeSubstitute substitute) { 67 return ICON; 68 } 69 70 public Node.PropertySet[] getPropertySets (Look.NodeSubstitute substitute) { 71 Node.PropertySet[] sets = super.getPropertySets (substitute); 72 ((Sheet.Set)sets[0]).put ( new ValueProperty ((AttributeNode)substitute.getRepresentedObject())); 73 return sets; 74 } 75 76 public Transferable clipboardCopy (Look.NodeSubstitute substitute) throws IOException { 77 AttributeNode node = (AttributeNode) substitute.getRepresentedObject (); 78 String str = node.getName () + " = " + node.getValue (); return new StringSelection (str); 80 } 81 82 } 83 | Popular Tags |