KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > node > DeployDataNode


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Lisa Reese
21  *
22  */

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 JavaDoc;
33 import java.lang.reflect.InvocationTargetException JavaDoc;
34 import java.util.ResourceBundle JavaDoc;
35 import java.beans.PropertyEditor JavaDoc;
36 import java.beans.PropertyEditorSupport JavaDoc;
37 import java.awt.Component JavaDoc;
38 import java.awt.Image JavaDoc;
39 import javax.swing.ImageIcon JavaDoc;
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 /** A node to represent this object.
48  *
49  * @author rees0234
50  */

51 public class DeployDataNode extends DataNode implements PropertyKeys {
52     public static final String JavaDoc PROP_SHEET_NAME = "deploy.sheet";
53     protected Sheet.Set propSet = null;
54     private static ResourceBundle JavaDoc bundle = NbBundle.getBundle (DeployDataNode.class);
55
56     private static final String JavaDoc 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 /* public Image getIcon(int type)
75     {
76         ImageIcon icon = new ImageIcon("smallicon.gif");
77         return icon.getImage();
78     }
79 */

80         public boolean hasCustomizer()
81     {
82         return true;
83     }
84
85     public Component JavaDoc 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 /* if (propSet == null) {
111         propSet = new Sheet.Set ();
112         propSet.setName (PROP_SHEET_NAME);
113             propSet.setDisplayName (bundle.getString("LBL_Deploy_sheet"));
114             propSet.setShortDescription (bundle.getString("HINT_Deploy_sheet"));
115     }*/

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     /** A property for a boolean property and its value. */
124     private class BooleanProp extends PropertySupport.ReadWrite
125     {
126         /** The property name. */
127         private String JavaDoc property;
128         /** Make a property.
129          * @param property the property name to use
130          */

131         public BooleanProp (String JavaDoc property, String JavaDoc disp, String JavaDoc desc)
132         {
133             super (property, String JavaDoc.class, disp, desc);
134             this.property = property;
135         }
136
137         public Object JavaDoc getValue ()
138         {
139             return getDeployDataObject().getProperty(property);
140         }
141
142         public void setValue (Object JavaDoc nue)
143         {
144             getDeployDataObject().setProperty(property, (String JavaDoc)nue);
145         }
146
147         public PropertyEditor JavaDoc 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 JavaDoc {
158
159         private static final String JavaDoc[] tags = {
160             NbBundle.getMessage (DeploySettings.class, "LBL_true"),
161             NbBundle.getMessage (DeploySettings.class, "LBL_false")
162     };
163
164         public String JavaDoc[] getTags () {
165             return tags;
166         }
167
168         public String JavaDoc getAsText () {
169              return tags[((String JavaDoc)getValue()).equals(tags[0]) ? 0 : 1];
170         }
171
172         public void setAsText (String JavaDoc text) throws IllegalArgumentException JavaDoc {
173            setValue(text);
174         }
175
176     }
177
178 }
179
Popular Tags