1 17 package org.apache.ldap.server.db.gui ; 18 19 20 import javax.swing.*; 21 import javax.swing.event.ListSelectionEvent ; 22 import javax.swing.event.ListSelectionListener ; 23 import javax.swing.table.TableModel ; 24 import javax.swing.tree.TreeModel ; 25 import java.awt.*; 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 import java.awt.event.WindowEvent ; 29 import java.math.BigInteger ; 30 31 32 38 public class SearchResultDialog extends JDialog implements ListSelectionListener 39 { 40 private static final long serialVersionUID = 3256999964914757684L; 41 42 private JPanel jPanel1 = new JPanel(); 43 private JTree jTree1 = new JTree(); 44 private JPanel jPanel2 = new JPanel(); 45 private JPanel jPanel3 = new JPanel(); 46 private JTextArea jTextArea1 = new JTextArea(); 47 private JScrollPane jScrollPane1 = new JScrollPane(); 48 private JButton jButton1 = new JButton(); 49 private JPanel jPanel4 = new JPanel(); 50 private JScrollPane jScrollPane2 = new JScrollPane(); 51 private JTable m_resultsTbl = new JTable(); 52 53 54 public SearchResultDialog(Frame parent, boolean modal) { 55 super(parent, modal); 56 initGUI(); 57 } 58 59 62 private void initGUI() { 63 addWindowListener( 64 new java.awt.event.WindowAdapter () { 65 public void windowClosing(java.awt.event.WindowEvent evt) { 66 closeDialog(evt); 67 } 68 }); 69 pack(); 70 getContentPane().setLayout(new java.awt.GridBagLayout ()); 71 getContentPane().add(jPanel1, 72 new java.awt.GridBagConstraints (0, 0, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.NORTH, java.awt.GridBagConstraints.BOTH, 73 new java.awt.Insets (10, 5, 5, 5), 0, 0)); 74 getContentPane().add(jPanel2, 75 new java.awt.GridBagConstraints (0, 1, 1, 1, 1.0, 0.4, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH, 76 new java.awt.Insets (5, 5, 5, 5), 0, 0)); 77 getContentPane().add(jPanel3, 78 new java.awt.GridBagConstraints (0, 3, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.SOUTH, java.awt.GridBagConstraints.BOTH, 79 new java.awt.Insets (0, 0, 0, 0), 0, 0)); 80 getContentPane().add(jPanel4, 81 new java.awt.GridBagConstraints (0, 2, 1, 1, 1.0, 0.4, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH, 82 new java.awt.Insets (5, 5, 5, 5), 0, 0)); 83 jPanel1.setLayout(new java.awt.BorderLayout (10, 10)); 84 jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder( 85 new java.awt.Color (153, 153, 153), 1), "Specifications", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, 86 new java.awt.Font ("SansSerif", 0, 14), new java.awt.Color (60, 60, 60))); 87 jPanel1.add(jTextArea1, java.awt.BorderLayout.CENTER); 88 jScrollPane1.getViewport().add(jTree1); 89 jTree1.setBounds(new java.awt.Rectangle (238,142,82,80)); 90 jTextArea1.setText(""); 91 jTextArea1.setEditable(false); 92 setBounds(new java.awt.Rectangle (0, 0, 485, 434)); 93 setTitle("Search Results"); 94 jPanel2.setLayout(new java.awt.BorderLayout ()); 95 jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder( 96 new java.awt.Color (153, 153, 153), 1), 97 "Filter Expression Tree", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, 98 new java.awt.Font ("SansSerif", 0, 14), new java.awt.Color (60, 60, 60))); 99 jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); 100 jButton1.setText("Done"); 101 jButton1.setActionCommand("Done"); 102 jButton1.addActionListener(new ActionListener () { 103 public void actionPerformed(ActionEvent event) { 104 SearchResultDialog.this.setVisible(false) ; 105 SearchResultDialog.this.dispose() ; 106 } 107 }) ; 108 jButton1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 109 jButton1.setAlignmentX(0.5f); 110 jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 111 jPanel3.setPreferredSize(new java.awt.Dimension (79, 41)); 112 jPanel3.setMinimumSize(new java.awt.Dimension (79, 41)); 113 jPanel3.setSize(new java.awt.Dimension (471,35)); 114 jPanel3.setToolTipText(""); 115 jPanel3.add(jButton1); 116 jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder( 117 new java.awt.Color (153, 153, 153), 1), "Search Results", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, 118 new java.awt.Font ("SansSerif", 0, 14), new java.awt.Color (60, 60, 60))); 119 jPanel4.setLayout(new java.awt.BorderLayout ()); 120 jPanel4.add(jScrollPane2, java.awt.BorderLayout.CENTER); 121 jScrollPane2.getViewport().add(m_resultsTbl); 122 m_resultsTbl.setSize(new java.awt.Dimension (450,10)); 123 m_resultsTbl.getSelectionModel().addListSelectionListener(this) ; 124 } 125 126 127 public void valueChanged(ListSelectionEvent an_event) 128 { 129 ListSelectionModel selectionModel = (ListSelectionModel) an_event.getSource() ; 130 int minIndex = selectionModel.getMinSelectionIndex() ; 131 int maxIndex = selectionModel.getMaxSelectionIndex() ; 132 133 for(int ii = minIndex ; ii <= maxIndex; ii++) { 134 if(selectionModel.isSelectedIndex(ii) && !an_event.getValueIsAdjusting()) { 135 BigInteger id = (BigInteger ) 136 m_resultsTbl.getModel().getValueAt(ii, 0) ; 137 ((MainFrame) getParent()).selectTreeNode(id) ; 138 } 139 } 140 } 141 142 143 144 private void closeDialog(WindowEvent evt) { 145 evt.getWindow(); 146 setVisible(false); 147 dispose(); 148 } 149 150 151 public void setTreeModel(TreeModel model) 152 { 153 this.jTree1.setModel(model) ; 154 } 155 156 157 public void setFilter(String filter) 158 { 159 this.jTextArea1.setText(filter) ; 160 } 161 162 163 public void setTableModel(TableModel model) 164 { 165 m_resultsTbl.setModel(model) ; 166 } 167 } 168 | Popular Tags |