1 package org.apache.ojb.tools.mapping.reversedb2.ojbmetatreemodel; 2 3 import org.apache.ojb.broker.metadata.ClassDescriptor; 4 import org.apache.ojb.broker.metadata.DescriptorRepository; 5 import org.apache.ojb.tools.mapping.reversedb2.events.StatusMessageListener; 6 7 21 22 30 31 public class OjbMetaDataTreeModel extends javax.swing.tree.DefaultTreeModel 32 { 33 private DescriptorRepository ojbMetaData; 34 35 43 public OjbMetaDataTreeModel (DescriptorRepository pOjbMetaData) 44 { 45 super(new javax.swing.tree.DefaultMutableTreeNode ("dummy")); 46 this.ojbMetaData = pOjbMetaData; 47 OjbMetaRootNode rootNode = new OjbMetaRootNode(ojbMetaData, this); 48 super.setRoot(rootNode); 49 rootNode.load(); 50 } 51 52 public DescriptorRepository getRepository() 53 { 54 return ojbMetaData; 55 } 56 57 58 62 public void setStatusBarMessage(final String message) 63 { 64 Object [] listeners = listenerList.getListenerList(); 66 for (int i = listeners.length-2; i>=0; i-=2) { 69 if (listeners[i]==StatusMessageListener.class) 70 { 71 ((StatusMessageListener)listeners[i+1]).statusMessageReceived(message); 72 } 73 } 74 } 75 76 80 public void addStatusMessageListener(StatusMessageListener listener) 81 { 82 listenerList.add(StatusMessageListener.class, listener); 83 } 84 85 89 public void removeStatusMessageListener(StatusMessageListener listener) 90 { 91 listenerList.remove(StatusMessageListener.class, listener); 92 } 93 94 100 public void reportSqlError(String message, java.sql.SQLException sqlEx) 101 { 102 StringBuffer strBufMessages = new StringBuffer (); 103 java.sql.SQLException currentSqlEx = sqlEx; 104 do 105 { 106 strBufMessages.append("\n" + sqlEx.getErrorCode() + ":" + sqlEx.getMessage()); 107 currentSqlEx = currentSqlEx.getNextException(); 108 } while (currentSqlEx != null); 109 System.err.println(message + strBufMessages.toString()); 110 sqlEx.printStackTrace(); 111 } 112 113 public OjbMetaClassDescriptorNode getClassDescriptorNodeForClassDescriptor(ClassDescriptor cld) 114 { 115 return ((OjbMetaRootNode)this.getRoot()).getClassDescriptorNodeForClassDescriptor(cld); 116 } 117 } 118 | Popular Tags |