KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > dbschema > nodes > SchemaElementNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.dbschema.nodes;
21
22 import org.openide.nodes.*;
23
24 import org.netbeans.modules.dbschema.*;
25
26 public class SchemaElementNode extends DBElementNode {
27     /** Creates new SchemaElementNode */
28     public SchemaElementNode(SchemaElement element, Children children, boolean writeable) {
29         super(element, children, writeable);
30     }
31
32     /* Resolve the current icon base.
33     * @return icon base string.
34     */

35     protected String JavaDoc resolveIconBase() {
36         return SCHEMA;
37     }
38
39     /* Creates property set for this node */
40     protected Sheet createSheet () {
41         Sheet sheet = Sheet.createDefault();
42         Sheet.Set ps = sheet.get(Sheet.PROPERTIES);
43         ps.put(createNameProperty(writeable));
44         ps.put(createSchemaProperty(writeable));
45         ps.put(createCatalogProperty(writeable));
46         ps.put(createDatabaseProductNameProperty(writeable));
47         ps.put(createDatabaseProductVersionProperty(writeable));
48         ps.put(createDriverNameProperty(writeable));
49         ps.put(createDriverVersionProperty(writeable));
50         ps.put(createDriverProperty(writeable));
51         ps.put(createUrlProperty(writeable));
52         ps.put(createUsernameProperty(writeable));
53
54         return sheet;
55     }
56
57     /** Create a property for the schema schema.
58      * @param canW <code>false</code> to force property to be read-only
59      * @return the property
60      */

61     protected Node.Property createSchemaProperty (boolean canW) {
62         return new ElementProp(PROP_SCHEMA, String JavaDoc.class, canW) {
63             /** Gets the value */
64             public Object JavaDoc getValue () {
65                 return ((SchemaElement) element).getSchema().getName();
66             }
67         };
68     }
69     
70     /** Create a property for the schema catalog.
71      * @param canW <code>false</code> to force property to be read-only
72      * @return the property
73      */

74     protected Node.Property createCatalogProperty (boolean canW) {
75         return new ElementProp(PROP_CATALOG, String JavaDoc.class, canW) {
76             /** Gets the value */
77             public Object JavaDoc getValue () {
78                 return ((SchemaElement) element).getCatalog().getName();
79             }
80         };
81     }
82     
83     /** Create a property for the schema database product name.
84      * @param canW <code>false</code> to force property to be read-only
85      * @return the property
86      */

87     protected Node.Property createDatabaseProductNameProperty (boolean canW) {
88         return new ElementProp("databaseProductName", String JavaDoc.class, canW) { //NOI18N
89
/** Gets the value */
90             public Object JavaDoc getValue () {
91                 return ((SchemaElement) element).getDatabaseProductName();
92             }
93         };
94     }
95
96     /** Create a property for the schema database product version.
97      * @param canW <code>false</code> to force property to be read-only
98      * @return the property
99      */

100     protected Node.Property createDatabaseProductVersionProperty (boolean canW) {
101         return new ElementProp("databaseProductVersion", String JavaDoc.class, canW) { //NOI18N
102
/** Gets the value */
103             public Object JavaDoc getValue () {
104                 return ((SchemaElement) element).getDatabaseProductVersion();
105             }
106         };
107     }
108
109     /** Create a property for the schema driver name.
110      * @param canW <code>false</code> to force property to be read-only
111      * @return the property
112      */

113     protected Node.Property createDriverNameProperty (boolean canW) {
114         return new ElementProp("driverName", String JavaDoc.class, canW) { //NOI18N
115
/** Gets the value */
116             public Object JavaDoc getValue () {
117                 return ((SchemaElement) element).getDriverName();
118             }
119         };
120     }
121
122     /** Create a property for the schema driver version.
123      * @param canW <code>false</code> to force property to be read-only
124      * @return the property
125      */

126     protected Node.Property createDriverVersionProperty (boolean canW) {
127         return new ElementProp("driverVersion", String JavaDoc.class, canW) { //NOI18N
128
/** Gets the value */
129             public Object JavaDoc getValue () {
130                 return ((SchemaElement) element).getDriverVersion();
131             }
132         };
133     }
134
135     /** Create a property for the schema driver URL.
136      * @param canW <code>false</code> to force property to be read-only
137      * @return the property
138      */

139     protected Node.Property createDriverProperty (boolean canW) {
140         return new ElementProp("driver", String JavaDoc.class, canW) { //NOI18N
141
/** Gets the value */
142             public Object JavaDoc getValue () {
143                 return ((SchemaElement) element).getDriver();
144             }
145         };
146     }
147
148     /** Create a property for the schema url.
149      * @param canW <code>false</code> to force property to be read-only
150      * @return the property
151      */

152     protected Node.Property createUrlProperty (boolean canW) {
153         return new ElementProp("url", String JavaDoc.class, canW) { //NOI18N
154
/** Gets the value */
155             public Object JavaDoc getValue () {
156                 return ((SchemaElement) element).getUrl();
157             }
158         };
159     }
160
161     /** Create a property for the schema username.
162      * @param canW <code>false</code> to force property to be read-only
163      * @return the property
164      */

165     protected Node.Property createUsernameProperty (boolean canW) {
166         return new ElementProp("username", String JavaDoc.class, canW) { //NOI18N
167
/** Gets the value */
168             public Object JavaDoc getValue () {
169                 return ((SchemaElement) element).getUsername();
170             }
171         };
172     }
173
174 }
175
Popular Tags