View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.db.gui ;
18  
19  
20  import javax.swing.*;
21  import javax.swing.tree.TreeModel;
22  import java.awt.*;
23  import java.awt.event.ActionEvent;
24  import java.awt.event.ActionListener;
25  import java.awt.event.WindowEvent;
26  
27  
28  /***
29   * Dialog for showing annotated filter trees.
30   *
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   * @version $Rev: 159259 $
33   */
34  public class AnnotatedFilterTreeDialog
35      extends JDialog
36  {
37      private static final long serialVersionUID = 3690476917916513074L;
38      private JPanel jPanel1 = new JPanel();
39      private JTree jTree1 = new JTree();
40      private JPanel jPanel2 = new JPanel();
41      private JPanel jPanel3 = new JPanel();
42      private JTextArea jTextArea1 = new JTextArea();
43      private JScrollPane jScrollPane1 = new JScrollPane();
44      private JButton jButton1 = new JButton();
45  
46      /*** Creates new form JDialog */
47      public AnnotatedFilterTreeDialog(Frame parent, boolean modal) {
48          super(parent, modal);
49          initGUI();
50      }
51  
52      /*** This method is called from within the constructor to initialize the form. */
53      private void initGUI() {
54          addWindowListener(
55              new java.awt.event.WindowAdapter() {
56                  public void windowClosing(java.awt.event.WindowEvent evt) {
57                      closeDialog(evt);
58                  }
59              });
60          pack();
61          getContentPane().setLayout(new java.awt.GridBagLayout());
62          getContentPane().add(jPanel1,
63          new java.awt.GridBagConstraints(0, 0, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.NORTH, java.awt.GridBagConstraints.BOTH,
64          new java.awt.Insets(10, 5, 5, 5), 0, 0));
65          getContentPane().add(jPanel2,
66          new java.awt.GridBagConstraints(0, 1, 1, 1, 1.0, 0.8, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH,
67          new java.awt.Insets(5, 5, 5, 5), 0, 0));
68          getContentPane().add(jPanel3,
69          new java.awt.GridBagConstraints(0, 2, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.SOUTH, java.awt.GridBagConstraints.HORIZONTAL,
70          new java.awt.Insets(0, 0, 0, 0), 0, 0));
71          jPanel1.setLayout(new java.awt.BorderLayout(10, 10));
72          jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
73          new java.awt.Color(153, 153, 153), 1), "Search Filter", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
74          new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
75          jPanel1.add(jTextArea1, java.awt.BorderLayout.CENTER);
76          jScrollPane1.getViewport().add(jTree1);
77          jTree1.setBounds(new java.awt.Rectangle(238,142,82,80));
78          jTextArea1.setText("");
79          jTextArea1.setEditable(false);
80          setBounds(new java.awt.Rectangle(0,0,485,414));
81          jPanel2.setLayout(new java.awt.BorderLayout());
82          jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
83          new java.awt.Color(153, 153, 153), 1),
84          "Filter Expression Tree", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
85          new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
86          jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);
87          jButton1.setText("Done");
88          jButton1.setActionCommand("Done");
89  		jButton1.addActionListener(new ActionListener() {
90              public void actionPerformed(ActionEvent a_event) {
91                  AnnotatedFilterTreeDialog.this.setVisible(false) ;
92  				AnnotatedFilterTreeDialog.this.dispose() ;
93              }
94          }) ;
95          jButton1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
96          jButton1.setAlignmentX(0.5f);
97          jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
98          jPanel3.setPreferredSize(new java.awt.Dimension(79, 41));
99          jPanel3.setMinimumSize(new java.awt.Dimension(79, 41));
100         jPanel3.setSize(new java.awt.Dimension(471,35));
101         jPanel3.setToolTipText("");
102         jPanel3.add(jButton1);
103     }
104 
105     /*** Closes the dialog */
106     private void closeDialog(WindowEvent evt) {
107         evt.getWindow();
108         setVisible(false);
109         dispose();
110     }
111 
112 
113     public void setModel(TreeModel a_model)
114     {
115         this.jTree1.setModel(a_model) ;
116     }
117 
118 
119     public void setFilter(String a_filter)
120     {
121         this.jTextArea1.setText(a_filter) ;
122     }
123 }