1 package org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel; 2 3 import org.apache.ojb.tools.mapping.reversedb2.events.StatusMessageListener; 4 5 19 20 28 29 public class DatabaseMetaDataTreeModel extends javax.swing.tree.DefaultTreeModel 30 implements java.io.Serializable 31 { 32 static final long serialVersionUID = -8045409456918534509L; transient private java.sql.DatabaseMetaData dbMetadata; 33 41 public DatabaseMetaDataTreeModel(java.sql.DatabaseMetaData pdbMetadata) 42 { 43 super(new javax.swing.tree.DefaultMutableTreeNode ("initializing")); 44 this.dbMetadata = pdbMetadata; 45 DBMetaRootNode rootNode = new DBMetaRootNode(dbMetadata, this); 46 super.setRoot(rootNode); 47 rootNode.loadWait(true, false, true); 48 } 49 50 51 55 public void setStatusBarMessage(final String message) 56 { 57 Object [] listeners = listenerList.getListenerList(); 59 for (int i = listeners.length-2; i>=0; i-=2) { 62 if (listeners[i]==StatusMessageListener.class) 63 { 64 ((StatusMessageListener)listeners[i+1]).statusMessageReceived(message); 65 } 66 } 67 } 68 69 73 public void addStatusMessageListener(StatusMessageListener listener) 74 { 75 listenerList.add(StatusMessageListener.class, listener); 76 } 77 78 82 public void removeStatusMessageListener(StatusMessageListener listener) 83 { 84 listenerList.remove(StatusMessageListener.class, listener); 85 } 86 87 93 public void reportSqlError(String message, java.sql.SQLException sqlEx) 94 { 95 StringBuffer strBufMessages = new StringBuffer (); 96 java.sql.SQLException currentSqlEx = sqlEx; 97 do 98 { 99 strBufMessages.append("\n" + sqlEx.getErrorCode() + ":" + sqlEx.getMessage()); 100 currentSqlEx = currentSqlEx.getNextException(); 101 } while (currentSqlEx != null); 102 System.err.println(message + strBufMessages.toString()); 103 sqlEx.printStackTrace(); 104 } 105 } 106 | Popular Tags |