001 /* 002 // $Id: //open/mondrian/src/main/mondrian/gui/JDBCExplorer.java#6 $ 003 // This software is subject to the terms of the Common Public License 004 // Agreement, available at the following URL: 005 // http://www.opensource.org/licenses/cpl.html. 006 // Copyright (C) 2002-2008 Julian Hyde and others 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.gui; 011 012 import java.sql.Connection; 013 014 import org.apache.log4j.Logger; 015 016 /** 017 * 018 * @author sean 019 * @version $Id: //open/mondrian/src/main/mondrian/gui/JDBCExplorer.java#6 $ 020 */ 021 public class JDBCExplorer extends javax.swing.JPanel { 022 023 private static final Logger LOGGER = Logger.getLogger(JDBCExplorer.class); 024 025 Connection connection; 026 JDBCTreeModel model; 027 028 /** Creates new form JDBCExplorer */ 029 public JDBCExplorer() { 030 initComponents(); 031 } 032 033 public JDBCExplorer(Connection c) { 034 this(); 035 setConnection(c); 036 } 037 038 public void setConnection(Connection c) { 039 try { 040 this.connection = c; 041 042 model = new JDBCTreeModel(c); 043 044 tree.setModel(model); 045 //tree.addTreeSelectionListener(this); 046 047 } catch (Exception ex) { 048 LOGGER.error(ex); 049 } 050 } 051 052 /** This method is called from within the constructor to 053 * initialize the form. 054 * WARNING: Do NOT modify this code. The content of this method is 055 * always regenerated by the Form Editor. 056 */ 057 private void initComponents() {//GEN-BEGIN:initComponents 058 jSplitPane1 = new javax.swing.JSplitPane(); 059 jScrollPane1 = new javax.swing.JScrollPane(); 060 tree = new javax.swing.JTree(); 061 jScrollPane2 = new javax.swing.JScrollPane(); 062 063 setLayout(new java.awt.BorderLayout()); 064 065 jSplitPane1.setDividerLocation(200); 066 jScrollPane1.setViewportView(tree); 067 068 jSplitPane1.setLeftComponent(jScrollPane1); 069 070 jSplitPane1.setRightComponent(jScrollPane2); 071 072 add(jSplitPane1, java.awt.BorderLayout.CENTER); 073 074 } //GEN-END:initComponents 075 076 077 // Variables declaration - do not modify//GEN-BEGIN:variables 078 private javax.swing.JScrollPane jScrollPane2; 079 private javax.swing.JScrollPane jScrollPane1; 080 private javax.swing.JTree tree; 081 private javax.swing.JSplitPane jSplitPane1; 082 // End of variables declaration//GEN-END:variables 083 084 } 085 086 // End JDBCExplorer.java