1 19 20 package org.netbeans.modules.db.explorer.nodes; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.io.IOException ; 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 { 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 evt) { 47 DatabaseNodeInfo info = getInfo(); 48 String pname = evt.getPropertyName(); 49 Object newval = evt.getNewValue(); 50 DatabaseDriver drv = (DatabaseDriver)info.get(DatabaseNodeInfo.DBDRIVER); 51 if (pname.equals(DatabaseNodeInfo.NAME)) drv.setName((String )newval); 52 if (pname.equals(DatabaseNodeInfo.URL)) drv.setURL((String )newval); 53 if (pname.equals(DatabaseNodeInfo.PREFIX)) drv.setDatabasePrefix((String )newval); 54 } 55 56 public String getShortDescription() { 57 return NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("ND_Driver"); } 59 60 public void destroy() throws IOException { 61 final DriverListNodeInfo parent = (DriverListNodeInfo) getInfo().getParent(); 62 getInfo().delete(); 63 } 64 65 68 public HelpCtx getHelpCtx() { 69 return new HelpCtx(DriverNode.class); 70 } 71 72 } 73 | Popular Tags |