1 package org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel; 2 16 17 24 public class DBMetaSchemaNode extends ReverseDbTreeNode 25 implements java.io.Serializable 26 { 27 static final long serialVersionUID = 2430983502951445144L; 28 public static final String ATT_SCHEMA_NAME = "Schema Name"; 29 36 public DBMetaSchemaNode(java.sql.DatabaseMetaData pdbMeta, 37 DatabaseMetaDataTreeModel pdbMetaTreeModel, 38 DBMetaCatalogNode pcatalogNode, 39 String pstrSchemaName) 40 { 41 super(pdbMeta, pdbMetaTreeModel, pcatalogNode); 42 this.setAttribute(ATT_SCHEMA_NAME, pstrSchemaName); 43 } 44 45 48 public boolean getAllowsChildren() 49 { 50 return true; 51 } 52 53 56 public boolean isLeaf() 57 { 58 return false; 59 } 60 61 65 public String getSchemaName() 66 { 67 return (String )this.getAttribute(ATT_SCHEMA_NAME); 68 } 69 70 76 public String toString() 77 { 78 if (this.getAttribute(ATT_SCHEMA_NAME) == null) return "Schema not specified"; 79 else return this.getAttribute(ATT_SCHEMA_NAME).toString(); 80 } 81 82 85 public DBMetaCatalogNode getCatalog() 86 { 87 return (DBMetaCatalogNode ) getParent(); 88 } 89 90 public Class getPropertyEditorClass() 91 { 92 return org.apache.ojb.tools.mapping.reversedb2.propertyEditors.JPnlPropertyEditorDBMetaSchema.class; 93 } 94 95 98 protected boolean _load () 99 { 100 java.sql.ResultSet rs = null; 101 try 102 { 103 synchronized(getDbMeta()) 108 { 109 getDbMetaTreeModel().setStatusBarMessage("Reading tables for schema " + getCatalog().getCatalogName() + "." + getSchemaName()); 110 rs = getDbMeta().getTables(getCatalog().getCatalogName(), 111 getSchemaName(), 112 "%", null); 113 final java.util.ArrayList alNew = new java.util.ArrayList (); 114 while (rs.next()) 115 { 116 getDbMetaTreeModel().setStatusBarMessage("Creating table " + getCatalog().getCatalogName() + "." + getSchemaName() + "." + rs.getString("TABLE_NAME")); 117 alNew.add(new DBMetaTableNode(getDbMeta(), 118 getDbMetaTreeModel(), 119 DBMetaSchemaNode.this, 120 rs.getString("TABLE_NAME"))); 121 } 122 alChildren = alNew; 123 javax.swing.SwingUtilities.invokeLater(new Runnable () 124 { 125 public void run() 126 { 127 getDbMetaTreeModel().nodeStructureChanged(DBMetaSchemaNode.this); 128 } 129 }); 130 rs.close(); 131 } 132 } 133 catch (java.sql.SQLException sqlEx) 134 { 135 getDbMetaTreeModel().reportSqlError("Error retrieving tables", sqlEx); 136 try 137 { 138 if (rs != null) rs.close (); 139 } 140 catch (java.sql.SQLException sqlEx2) 141 { 142 this.getDbMetaTreeModel().reportSqlError("Error retrieving tables", sqlEx2); 143 } 144 return false; 145 } 146 return true; 147 } 148 } 149 | Popular Tags |