KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > explorer > nodes > DriverNode


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.db.explorer.nodes;
21
22 import java.beans.PropertyChangeEvent JavaDoc;
23 import java.beans.PropertyChangeListener JavaDoc;
24 import java.io.IOException JavaDoc;
25
26 import org.openide.util.NbBundle;
27
28 import org.netbeans.modules.db.explorer.DatabaseDriver;
29 import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
30 import org.netbeans.modules.db.explorer.infos.DriverListNodeInfo;
31 import org.openide.util.HelpCtx;
32
33 public class DriverNode extends LeafNode implements PropertyChangeListener JavaDoc {
34
35     public void setInfo(DatabaseNodeInfo info) {
36         super.setInfo(info);
37         DatabaseDriver drv = (DatabaseDriver)info.get(DatabaseNodeInfo.DBDRIVER);
38         if (drv != null) {
39             info.put(DatabaseNodeInfo.NAME, drv.getName());
40             info.put(DatabaseNodeInfo.URL, drv.getURL());
41             info.put(DatabaseNodeInfo.ADAPTOR_CLASSNAME, drv.getDatabaseAdaptor());
42             info.addDriverListener(this);
43         }
44     }
45
46     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
47         DatabaseNodeInfo info = getInfo();
48         String JavaDoc pname = evt.getPropertyName();
49         Object JavaDoc newval = evt.getNewValue();
50         DatabaseDriver drv = (DatabaseDriver)info.get(DatabaseNodeInfo.DBDRIVER);
51         if (pname.equals(DatabaseNodeInfo.NAME)) drv.setName((String JavaDoc)newval);
52         if (pname.equals(DatabaseNodeInfo.URL)) drv.setURL((String JavaDoc)newval);
53         if (pname.equals(DatabaseNodeInfo.PREFIX)) drv.setDatabasePrefix((String JavaDoc)newval);
54     }
55     
56     public String JavaDoc getShortDescription() {
57         return NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("ND_Driver"); //NOI18N
58
}
59
60     public void destroy() throws IOException JavaDoc {
61         final DriverListNodeInfo parent = (DriverListNodeInfo) getInfo().getParent();
62         getInfo().delete();
63     }
64
65     /** Help context where to find more about the paste type action.
66     * @return the help context for this action
67     */

68     public HelpCtx getHelpCtx() {
69         return new HelpCtx(DriverNode.class);
70     }
71
72 }
73
Popular Tags