1 23 24 package org.enhydra.kelp.forte.node; 25 26 import org.openide.loaders.*; 27 import org.openide.nodes.*; 28 import org.openide.util.NbBundle; 29 import org.openide.util.actions.SystemAction; 30 import org.openide.actions.OpenAction; 31 import org.openide.actions.ViewAction; 32 import org.openide.filesystems.FileSystemCapability; 33 import org.openide.filesystems.FileStateInvalidException; 34 35 import org.enhydra.kelp.common.node.PropertyKeys; 36 import org.enhydra.kelp.common.PathUtil; 37 import org.enhydra.kelp.forte.node.ForteDocumentNode; 38 import org.enhydra.kelp.common.properties.XMLCNodePropertyPanel; 39 import org.enhydra.kelp.common.node.OtterXMLCNode; 40 import org.enhydra.kelp.forte.XMLCSettings; 41 42 import java.lang.IllegalAccessException ; 43 import java.lang.reflect.InvocationTargetException ; 44 import java.util.ResourceBundle ; 45 import java.beans.PropertyEditor ; 46 import java.beans.PropertyEditorSupport ; 47 import java.awt.Component ; 48 import java.awt.Image ; 49 import javax.swing.ImageIcon ; 50 51 55 public class XMLCDataNode extends DataNode implements PropertyKeys 56 { 57 public static final String PROP_SHEET_NAME = "xmlc.sheet"; 58 protected Sheet.Set propSet = null; 59 private static ResourceBundle bundle = NbBundle.getBundle (XMLCDataNode.class); 60 private static final String XMLC_ICON_BASE = "/org/enhydra/kelp/forte/enhydraObject"; 61 62 63 public XMLCDataNode (XMLCDataObject obj) 64 { 65 this (obj, Children.LEAF); 66 } 67 68 public XMLCDataNode (XMLCDataObject obj, Children ch) 69 { 70 super (obj, ch); 71 setIconBase (XMLC_ICON_BASE); 72 } 73 74 protected XMLCDataObject getXMLCDataObject () 75 { 76 return (XMLCDataObject) getDataObject (); 77 } 78 79 public boolean hasCustomizer() 80 { 81 return true; 82 } 83 84 public Component getCustomizer() 85 { 86 XMLCNodePropertyPanel panel = new XMLCNodePropertyPanel(); 87 panel.setSaveOnClose(true); 88 panel.read(new OtterXMLCNode(new ForteDocumentNode(getXMLCDataObject()))); 89 return panel; 90 } 91 92 protected Sheet createSheet () { 93 94 Sheet s = Sheet.createDefault (); 95 propSet = s.get (Sheet.PROPERTIES); 96 97 if (propSet == null) { 98 propSet = new Sheet.Set (); 99 propSet.setName (PROP_SHEET_NAME); 100 propSet.setDisplayName (bundle.getString("LBL_XMLC_sheet")); 101 propSet.setShortDescription (bundle.getString("HINT_XMLC_sheet")); 102 } 103 104 PropertySupport p = new BooleanProp(NAME_SELECTED,bundle.getString("LBL_Selected"), bundle.getString("HINT_Selected")); 105 propSet.put (p); 106 107 return s; 108 } 109 110 public SystemAction getDefaultAction () { 111 return SystemAction.get (ViewAction.class); 112 } 113 114 115 private class BooleanProp extends PropertySupport.ReadWrite 116 { 117 118 private String property; 119 122 public BooleanProp (String property, String disp, String desc) 123 { 124 super (property, String .class, disp, desc); 125 this.property = property; 126 } 127 128 public Object getValue () 129 { 130 return getXMLCDataObject().getProperty(property); 131 } 132 133 public void setValue (Object nue) { 134 getXMLCDataObject().setProperty(property, (String )nue); 135 } 136 137 public PropertyEditor getPropertyEditor() 138 { 139 return new BoolEd(); 140 } 141 } 142 143 public static class BoolEd extends PropertyEditorSupport { 144 145 private static final String [] tags = { 146 NbBundle.getMessage (XMLCSettings.class, "LBL_true"), 147 NbBundle.getMessage (XMLCSettings.class, "LBL_false") 148 }; 149 150 public String [] getTags () { 151 return tags; 152 } 153 154 public String getAsText () { 155 return tags[((String )getValue()).equals(tags[0]) ? 0 : 1]; 156 } 157 158 public void setAsText (String text) throws IllegalArgumentException { 159 setValue(text); 160 } 161 162 } 163 } 164 | Popular Tags |