KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 JavaDoc;
43 import java.lang.reflect.InvocationTargetException JavaDoc;
44 import java.util.ResourceBundle JavaDoc;
45 import java.beans.PropertyEditor JavaDoc;
46 import java.beans.PropertyEditorSupport JavaDoc;
47 import java.awt.Component JavaDoc;
48 import java.awt.Image JavaDoc;
49 import javax.swing.ImageIcon JavaDoc;
50
51 /** A node to represent this object.
52  *
53  * @author rees0234
54  */

55 public class XMLCDataNode extends DataNode implements PropertyKeys
56 {
57     public static final String JavaDoc PROP_SHEET_NAME = "xmlc.sheet";
58     protected Sheet.Set propSet = null;
59     private static ResourceBundle JavaDoc bundle = NbBundle.getBundle (XMLCDataNode.class);
60     private static final String JavaDoc 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 JavaDoc 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         /** A property for a boolean property and its value. */
115     private class BooleanProp extends PropertySupport.ReadWrite
116     {
117         /** The property name. */
118         private String JavaDoc property;
119         /** Make a property.
120          * @param property the property name to use
121          */

122         public BooleanProp (String JavaDoc property, String JavaDoc disp, String JavaDoc desc)
123         {
124             super (property, String JavaDoc.class, disp, desc);
125             this.property = property;
126         }
127
128         public Object JavaDoc getValue ()
129         {
130             return getXMLCDataObject().getProperty(property);
131         }
132
133         public void setValue (Object JavaDoc nue) {
134             getXMLCDataObject().setProperty(property, (String JavaDoc)nue);
135         }
136
137         public PropertyEditor JavaDoc getPropertyEditor()
138         {
139             return new BoolEd();
140         }
141     }
142
143     public static class BoolEd extends PropertyEditorSupport JavaDoc {
144
145         private static final String JavaDoc[] tags = {
146             NbBundle.getMessage (XMLCSettings.class, "LBL_true"),
147             NbBundle.getMessage (XMLCSettings.class, "LBL_false")
148     };
149
150         public String JavaDoc[] getTags () {
151             return tags;
152         }
153
154         public String JavaDoc getAsText () {
155              return tags[((String JavaDoc)getValue()).equals(tags[0]) ? 0 : 1];
156         }
157
158         public void setAsText (String JavaDoc text) throws IllegalArgumentException JavaDoc {
159            setValue(text);
160         }
161
162     }
163 }
164
Popular Tags