001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.dbschema.nodes;
043:
044: import org.openide.nodes.*;
045:
046: import org.netbeans.modules.dbschema.*;
047:
048: public class SchemaElementNode extends DBElementNode {
049: /** Creates new SchemaElementNode */
050: public SchemaElementNode(SchemaElement element, Children children,
051: boolean writeable) {
052: super (element, children, writeable);
053: }
054:
055: /* Resolve the current icon base.
056: * @return icon base string.
057: */
058: protected String resolveIconBase() {
059: return SCHEMA;
060: }
061:
062: /* Creates property set for this node */
063: protected Sheet createSheet() {
064: Sheet sheet = Sheet.createDefault();
065: Sheet.Set ps = sheet.get(Sheet.PROPERTIES);
066: ps.put(createNameProperty(writeable));
067: ps.put(createSchemaProperty(writeable));
068: ps.put(createCatalogProperty(writeable));
069: ps.put(createDatabaseProductNameProperty(writeable));
070: ps.put(createDatabaseProductVersionProperty(writeable));
071: ps.put(createDriverNameProperty(writeable));
072: ps.put(createDriverVersionProperty(writeable));
073: ps.put(createDriverProperty(writeable));
074: ps.put(createUrlProperty(writeable));
075: ps.put(createUsernameProperty(writeable));
076:
077: return sheet;
078: }
079:
080: /** Create a property for the schema schema.
081: * @param canW <code>false</code> to force property to be read-only
082: * @return the property
083: */
084: protected Node.Property createSchemaProperty(boolean canW) {
085: return new ElementProp(PROP_SCHEMA, String.class, canW) {
086: /** Gets the value */
087: public Object getValue() {
088: return ((SchemaElement) element).getSchema().getName();
089: }
090: };
091: }
092:
093: /** Create a property for the schema catalog.
094: * @param canW <code>false</code> to force property to be read-only
095: * @return the property
096: */
097: protected Node.Property createCatalogProperty(boolean canW) {
098: return new ElementProp(PROP_CATALOG, String.class, canW) {
099: /** Gets the value */
100: public Object getValue() {
101: return ((SchemaElement) element).getCatalog().getName();
102: }
103: };
104: }
105:
106: /** Create a property for the schema database product name.
107: * @param canW <code>false</code> to force property to be read-only
108: * @return the property
109: */
110: protected Node.Property createDatabaseProductNameProperty(
111: boolean canW) {
112: return new ElementProp("databaseProductName", String.class,
113: canW) { //NOI18N
114: /** Gets the value */
115: public Object getValue() {
116: return ((SchemaElement) element)
117: .getDatabaseProductName();
118: }
119: };
120: }
121:
122: /** Create a property for the schema database product version.
123: * @param canW <code>false</code> to force property to be read-only
124: * @return the property
125: */
126: protected Node.Property createDatabaseProductVersionProperty(
127: boolean canW) {
128: return new ElementProp("databaseProductVersion", String.class,
129: canW) { //NOI18N
130: /** Gets the value */
131: public Object getValue() {
132: return ((SchemaElement) element)
133: .getDatabaseProductVersion();
134: }
135: };
136: }
137:
138: /** Create a property for the schema driver name.
139: * @param canW <code>false</code> to force property to be read-only
140: * @return the property
141: */
142: protected Node.Property createDriverNameProperty(boolean canW) {
143: return new ElementProp("driverName", String.class, canW) { //NOI18N
144: /** Gets the value */
145: public Object getValue() {
146: return ((SchemaElement) element).getDriverName();
147: }
148: };
149: }
150:
151: /** Create a property for the schema driver version.
152: * @param canW <code>false</code> to force property to be read-only
153: * @return the property
154: */
155: protected Node.Property createDriverVersionProperty(boolean canW) {
156: return new ElementProp("driverVersion", String.class, canW) { //NOI18N
157: /** Gets the value */
158: public Object getValue() {
159: return ((SchemaElement) element).getDriverVersion();
160: }
161: };
162: }
163:
164: /** Create a property for the schema driver URL.
165: * @param canW <code>false</code> to force property to be read-only
166: * @return the property
167: */
168: protected Node.Property createDriverProperty(boolean canW) {
169: return new ElementProp("driver", String.class, canW) { //NOI18N
170: /** Gets the value */
171: public Object getValue() {
172: return ((SchemaElement) element).getDriver();
173: }
174: };
175: }
176:
177: /** Create a property for the schema url.
178: * @param canW <code>false</code> to force property to be read-only
179: * @return the property
180: */
181: protected Node.Property createUrlProperty(boolean canW) {
182: return new ElementProp("url", String.class, canW) { //NOI18N
183: /** Gets the value */
184: public Object getValue() {
185: return ((SchemaElement) element).getUrl();
186: }
187: };
188: }
189:
190: /** Create a property for the schema username.
191: * @param canW <code>false</code> to force property to be read-only
192: * @return the property
193: */
194: protected Node.Property createUsernameProperty(boolean canW) {
195: return new ElementProp("username", String.class, canW) { //NOI18N
196: /** Gets the value */
197: public Object getValue() {
198: return ((SchemaElement) element).getUsername();
199: }
200: };
201: }
202:
203: }
|