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.partition.impl.btree.gui ;
18  
19  
20  import java.awt.Frame;
21  import java.awt.event.ActionEvent;
22  import java.awt.event.ActionListener;
23  import java.awt.event.WindowEvent;
24  
25  import javax.swing.JButton;
26  import javax.swing.JDialog;
27  import javax.swing.JPanel;
28  import javax.swing.JScrollPane;
29  import javax.swing.JTextArea;
30  import javax.swing.JTree;
31  import javax.swing.tree.TreeModel;
32  
33  
34  /***
35   * Dialog for showing annotated filter trees.
36   *
37   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
38   * @version $Rev: 264732 $
39   */
40  public class AnnotatedFilterTreeDialog
41      extends JDialog
42  {
43      private static final long serialVersionUID = 3690476917916513074L;
44      private JPanel jPanel1 = new JPanel();
45      private JTree jTree1 = new JTree();
46      private JPanel jPanel2 = new JPanel();
47      private JPanel jPanel3 = new JPanel();
48      private JTextArea jTextArea1 = new JTextArea();
49      private JScrollPane jScrollPane1 = new JScrollPane();
50      private JButton jButton1 = new JButton();
51  
52      /*** Creates new form JDialog */
53      public AnnotatedFilterTreeDialog(Frame parent, boolean modal) {
54          super(parent, modal);
55          initGUI();
56      }
57  
58      /*** This method is called from within the constructor to initialize the form. */
59      private void initGUI() {
60          addWindowListener(
61              new java.awt.event.WindowAdapter() {
62                  public void windowClosing(java.awt.event.WindowEvent evt) {
63                      closeDialog(evt);
64                  }
65              });
66          pack();
67          getContentPane().setLayout(new java.awt.GridBagLayout());
68          getContentPane().add(jPanel1,
69          new java.awt.GridBagConstraints(0, 0, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.NORTH, java.awt.GridBagConstraints.BOTH,
70          new java.awt.Insets(10, 5, 5, 5), 0, 0));
71          getContentPane().add(jPanel2,
72          new java.awt.GridBagConstraints(0, 1, 1, 1, 1.0, 0.8, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH,
73          new java.awt.Insets(5, 5, 5, 5), 0, 0));
74          getContentPane().add(jPanel3,
75          new java.awt.GridBagConstraints(0, 2, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.SOUTH, java.awt.GridBagConstraints.HORIZONTAL,
76          new java.awt.Insets(0, 0, 0, 0), 0, 0));
77          jPanel1.setLayout(new java.awt.BorderLayout(10, 10));
78          jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
79          new java.awt.Color(153, 153, 153), 1), "Search Filter", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
80          new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
81          jPanel1.add(jTextArea1, java.awt.BorderLayout.CENTER);
82          jScrollPane1.getViewport().add(jTree1);
83          jTree1.setBounds(new java.awt.Rectangle(238,142,82,80));
84          jTextArea1.setText("");
85          jTextArea1.setEditable(false);
86          setBounds(new java.awt.Rectangle(0,0,485,414));
87          jPanel2.setLayout(new java.awt.BorderLayout());
88          jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
89          new java.awt.Color(153, 153, 153), 1),
90          "Filter Expression Tree", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
91          new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
92          jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);
93          jButton1.setText("Done");
94          jButton1.setActionCommand("Done");
95  		jButton1.addActionListener(new ActionListener() {
96              public void actionPerformed(ActionEvent a_event) {
97                  AnnotatedFilterTreeDialog.this.setVisible(false) ;
98  				AnnotatedFilterTreeDialog.this.dispose() ;
99              }
100         }) ;
101         jButton1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
102         jButton1.setAlignmentX(0.5f);
103         jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
104         jPanel3.setPreferredSize(new java.awt.Dimension(79, 41));
105         jPanel3.setMinimumSize(new java.awt.Dimension(79, 41));
106         jPanel3.setSize(new java.awt.Dimension(471,35));
107         jPanel3.setToolTipText("");
108         jPanel3.add(jButton1);
109     }
110 
111     /*** Closes the dialog */
112     private void closeDialog(WindowEvent evt) {
113         evt.getWindow();
114         setVisible(false);
115         dispose();
116     }
117 
118 
119     public void setModel(TreeModel a_model)
120     {
121         this.jTree1.setModel(a_model) ;
122     }
123 
124 
125     public void setFilter(String a_filter)
126     {
127         this.jTextArea1.setText(a_filter) ;
128     }
129 }