1 19 20 package org.netbeans.modules.db.explorer.nodes; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 25 import org.openide.options.SystemOption; 26 import org.openide.util.NbBundle; 27 28 import org.netbeans.lib.ddl.impl.SpecificationFactory; 29 import org.netbeans.modules.db.explorer.DatabaseOption; 30 31 34 import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo; 35 import org.netbeans.modules.db.explorer.infos.RootNodeInfo; 36 37 41 public class RootNode extends DatabaseNode { 42 43 private static DatabaseOption option = null; 44 private static RootNode rootNode = null; 45 46 47 SpecificationFactory sfactory; 48 49 public static DatabaseOption getOption() { 50 if (option == null) 51 option = (DatabaseOption)SystemOption.findObject(DatabaseOption.class, true); 52 53 return option; 54 } 55 56 public static RootNode getInstance() { 57 if (rootNode == null) { 58 rootNode = new RootNode(); 59 } 60 return rootNode; 61 } 62 63 private RootNode() { 64 setDisplayName(NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("NDN_Databases")); try { 66 sfactory = new SpecificationFactory(); 67 initDebugListening(); 69 70 74 DatabaseNodeInfo nfo = RootNodeInfo.getInstance(); 75 if (sfactory != null) nfo.setSpecificationFactory(sfactory); 76 else throw new Exception (NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("EXC_NoSpecificationFactory")); 77 78 setInfo(nfo); 79 getInfo().setNode(this); 80 } catch (Exception e) { 81 e.printStackTrace(); 82 } 83 } 84 85 public boolean canRename() { 86 return false; 87 } 88 89 92 void initDebugListening() { 93 if ( (getOption() == null) || (sfactory == null) ) { 94 initDebugListening(); 95 } 96 option.addPropertyChangeListener(new PropertyChangeListener () { 97 public void propertyChange(PropertyChangeEvent e) { 98 if (e.getPropertyName() == null) { 99 sfactory.setDebugMode(option.getDebugMode()); 100 return; 101 } 102 if (e.getPropertyName().equals(DatabaseOption.PROP_DEBUG_MODE)) 103 sfactory.setDebugMode(((Boolean ) e.getNewValue()).booleanValue()); 104 } 105 }); 106 sfactory.setDebugMode(option.getDebugMode()); 107 } 108 109 127 public String getShortDescription() { 128 return NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("ND_Root"); } 130 } 131 | Popular Tags |