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 32 import java.lang.IllegalAccessException ; 33 import java.lang.reflect.InvocationTargetException ; 34 import java.util.ResourceBundle ; 35 import java.beans.PropertyEditor ; 36 import java.beans.PropertyEditorSupport ; 37 import java.awt.Component ; 38 import java.awt.Image ; 39 import javax.swing.ImageIcon ; 40 41 import org.enhydra.kelp.common.properties.TemplateNodePropertyPanel; 42 import org.enhydra.kelp.common.node.OtterTextFileNode; 43 import org.enhydra.kelp.forte.DeploySettings; 44 import org.enhydra.kelp.common.node.PropertyKeys; 45 import org.enhydra.tool.common.ToolException; 46 47 51 public class DeployDataNode extends DataNode implements PropertyKeys { 52 public static final String PROP_SHEET_NAME = "deploy.sheet"; 53 protected Sheet.Set propSet = null; 54 private static ResourceBundle bundle = NbBundle.getBundle (DeployDataNode.class); 55 56 private static final String DEPLOY_ICON_BASE = "/org/enhydra/kelp/forte/enhydraObject"; 57 58 public DeployDataNode (DeployDataObject obj) 59 { 60 this (obj, Children.LEAF); 61 } 62 63 public DeployDataNode (DeployDataObject obj, Children ch) 64 { 65 super (obj, ch); 66 setIconBase (DEPLOY_ICON_BASE); 67 } 68 69 protected DeployDataObject getDeployDataObject () 70 { 71 return (DeployDataObject) getDataObject (); 72 } 73 74 80 public boolean hasCustomizer() 81 { 82 return true; 83 } 84 85 public Component getCustomizer() 86 { 87 TemplateNodePropertyPanel panel = new TemplateNodePropertyPanel(); 88 panel.setSaveOnClose(true); 89 panel.setIconView(true); 90 ForteTemplateNode node = null; 91 try 92 { 93 node = new ForteTemplateNode(getDeployDataObject()); 94 } catch (ToolException e) { 95 System.err.println(e); 96 } 97 if (node != null) 98 { 99 panel.read(node); 100 return panel; 101 } 102 return null; 103 } 104 105 protected Sheet createSheet () { 106 107 Sheet s = Sheet.createDefault (); 108 propSet = s.get (Sheet.PROPERTIES); 109 110 116 117 PropertySupport p = new BooleanProp(NAME_SELECTED,bundle.getString("LBL_Selected"), bundle.getString("HINT_Deploy_Selected")); 118 propSet.put (p); 119 120 return s; 121 } 122 123 124 private class BooleanProp extends PropertySupport.ReadWrite 125 { 126 127 private String property; 128 131 public BooleanProp (String property, String disp, String desc) 132 { 133 super (property, String .class, disp, desc); 134 this.property = property; 135 } 136 137 public Object getValue () 138 { 139 return getDeployDataObject().getProperty(property); 140 } 141 142 public void setValue (Object nue) 143 { 144 getDeployDataObject().setProperty(property, (String )nue); 145 } 146 147 public PropertyEditor getPropertyEditor() 148 { 149 return new BoolEd(); 150 } 151 } 152 153 public SystemAction getDefaultAction () { 154 return SystemAction.get (OpenAction.class); 155 } 156 157 public static class BoolEd extends PropertyEditorSupport { 158 159 private static final String [] tags = { 160 NbBundle.getMessage (DeploySettings.class, "LBL_true"), 161 NbBundle.getMessage (DeploySettings.class, "LBL_false") 162 }; 163 164 public String [] getTags () { 165 return tags; 166 } 167 168 public String getAsText () { 169 return tags[((String )getValue()).equals(tags[0]) ? 0 : 1]; 170 } 171 172 public void setAsText (String text) throws IllegalArgumentException { 173 setValue(text); 174 } 175 176 } 177 178 } 179 | Popular Tags |