1 15 16 package org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel; 17 18 import org.apache.ojb.broker.metadata.DescriptorRepository; 19 import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor; 20 21 25 public class OjbMetaJdbcConnectionDescriptorNode extends OjbMetaTreeNode 26 { 27 28 29 public static final String ATT_DBALIAS = "Database Alias"; 30 public static final String ATT_DBMS = "DBMS"; 31 public static final String ATT_DATASOURCE_NAME = "Datasource Name"; 32 public static final String ATT_DRIVER = "Driver"; 33 public static final String ATT_DESCRIPTOR_PBKEY = "PBKey"; 34 public static final String ATT_JDBC_LEVEL = "JDBC Level"; 35 public static final String ATT_PASSWORD = "Password"; 36 public static final String ATT_PROTOCOL = "Protocol"; 37 public static final String ATT_SUBPROTOCOL = "Sub Protocol"; 38 public static final String ATT_USERNAME = "Username"; 39 40 private static java.util.ArrayList supportedActions = new java.util.ArrayList (); 41 42 private JdbcConnectionDescriptor connDescriptor; 43 44 public OjbMetaJdbcConnectionDescriptorNode(DescriptorRepository pRepository, 45 OjbMetaDataTreeModel pTreeModel, 46 OjbMetaTreeNode pparent, 47 JdbcConnectionDescriptor pConnDescriptor) 48 { 49 super(pRepository, pTreeModel, pparent); 50 this.connDescriptor = pConnDescriptor; 51 } 52 53 57 protected boolean _load () 58 { 59 return true; 60 } 61 62 public boolean getAllowsChildren () 63 { 64 return false; 65 } 66 67 public Object getAttribute (String key) 68 { 69 if (key.equals(ATT_DBALIAS)) 70 { 71 return connDescriptor.getDbAlias(); 72 } 73 else if (key.equals(ATT_DATASOURCE_NAME)) 74 { 75 return connDescriptor.getDatasourceName(); 76 } 77 else if (key.equals(ATT_DRIVER)) 78 { 79 return connDescriptor.getDriver(); 80 } 81 else if (key.equals(ATT_JDBC_LEVEL )) 82 { 83 return new Double (connDescriptor.getJdbcLevel()); 84 } 85 else if (key.equals(ATT_DESCRIPTOR_PBKEY)) 86 { 87 return connDescriptor.getPBKey(); 88 } 89 else if (key.equals(ATT_PASSWORD)) 90 { 91 return connDescriptor.getPassWord(); 92 } 93 else if (key.equals(ATT_PROTOCOL)) 94 { 95 return connDescriptor.getProtocol(); 96 } 97 else if (key.equals(ATT_SUBPROTOCOL)) 98 { 99 return connDescriptor.getSubProtocol(); 100 } 101 else if (key.equals(ATT_USERNAME)) 102 { 103 return connDescriptor.getUserName(); 104 } 105 else if (key.equals(ATT_DBMS)) 106 { 107 return connDescriptor.getDbms(); 108 } 109 else 110 { 111 return super.getAttribute(key); 112 } 113 } 114 115 public Class getPropertyEditorClass () 116 { 117 return org.apache.ojb.tools.mapping.reversedb2.propertyEditors.JPnlPropertyEditorOJBMetaJdbcConnectionDescriptor.class; 118 } 119 120 public boolean isLeaf () 121 { 122 return true; 123 } 124 125 public void setAttribute (String key, Object value) 126 { 127 if (key.equals(ATT_DBALIAS)) 128 { 129 Object oldValue = connDescriptor.getDbAlias(); 130 connDescriptor.setDbAlias(value.toString()); 131 propertyChangeDelegate.firePropertyChange(ATT_DBALIAS, oldValue, value); 132 this.getOjbMetaTreeModel().nodeChanged(this); 134 } 135 else if (key.equals(ATT_DATASOURCE_NAME)) 136 { 137 Object oldValue = connDescriptor.getDatasourceName(); 138 connDescriptor.setDatasourceName(value.toString()); 139 propertyChangeDelegate.firePropertyChange(ATT_DATASOURCE_NAME, oldValue, value); 140 } 141 else if (key.equals(ATT_DRIVER)) 142 { 143 Object oldValue = connDescriptor.getDatasourceName(); 144 connDescriptor.setDriver(value.toString()); 145 propertyChangeDelegate.firePropertyChange(ATT_DRIVER, oldValue, value); 146 } 147 else if (key.equals(ATT_DESCRIPTOR_PBKEY)) 148 { 149 150 propertyChangeDelegate.firePropertyChange(ATT_DESCRIPTOR_PBKEY, connDescriptor.getPBKey(), connDescriptor.getPBKey()); 151 } 152 else if (key.equals(ATT_JDBC_LEVEL)) 153 { 154 Object oldValue = new Double (connDescriptor.getJdbcLevel()); 155 connDescriptor.setJdbcLevel(value.toString()); 156 propertyChangeDelegate.firePropertyChange(ATT_JDBC_LEVEL, oldValue, new Double (connDescriptor.getJdbcLevel())); 157 } 158 else if (key.equals(ATT_PASSWORD)) 159 { 160 Object oldValue = connDescriptor.getPassWord(); 161 connDescriptor.setPassWord(value.toString()); 162 propertyChangeDelegate.firePropertyChange(ATT_PASSWORD, oldValue, value); 163 } 164 else if (key.equals(ATT_PROTOCOL)) 165 { 166 Object oldValue = connDescriptor.getProtocol(); 167 connDescriptor.setProtocol(value.toString()); 168 propertyChangeDelegate.firePropertyChange(ATT_PROTOCOL, oldValue, value); 169 } 170 else if (key.equals(ATT_SUBPROTOCOL)) 171 { 172 Object oldValue = connDescriptor.getSubProtocol(); 173 connDescriptor.setSubProtocol(value.toString()); 174 propertyChangeDelegate.firePropertyChange(ATT_SUBPROTOCOL, oldValue, value); 175 } 176 else if (key.equals(ATT_USERNAME)) 177 { 178 Object oldValue = connDescriptor.getUserName(); 179 connDescriptor.setUserName(value.toString()); 180 propertyChangeDelegate.firePropertyChange(ATT_USERNAME, oldValue, value); 181 } 182 else if (key.equals(ATT_DBMS)) 183 { 184 Object oldValue = connDescriptor.getDbms(); 185 connDescriptor.setDbms(value.toString()); 186 propertyChangeDelegate.firePropertyChange(ATT_DBMS, oldValue, value); 187 } 188 else 189 { 190 super.setAttribute(key, value); 191 } 192 } 193 194 public String toString() 195 { 196 return "ConnectionDescriptor: " + connDescriptor.getDbAlias(); 197 } 198 199 202 public java.util.Iterator getActions() 203 { 204 return supportedActions.iterator(); 205 } 206 207 210 public boolean actionListCachable() 211 { 212 return true; 213 } 214 215 public boolean actionListStatic() 216 { 217 return true; 218 } 219 220 225 public Object getAssociatedDescriptor() 226 { 227 return connDescriptor; 228 } 229 230 } 231 | Popular Tags |