001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.core.partition.impl.btree.gui;
021
022
023 import java.awt.Frame;
024 import java.awt.event.ActionEvent;
025 import java.awt.event.ActionListener;
026 import java.awt.event.WindowEvent;
027
028 import javax.swing.JButton;
029 import javax.swing.JDialog;
030 import javax.swing.JPanel;
031 import javax.swing.JScrollPane;
032 import javax.swing.JTextArea;
033 import javax.swing.JTree;
034 import javax.swing.tree.TreeModel;
035
036
037 /**
038 * Dialog for showing annotated filter trees.
039 *
040 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
041 * @version $Rev: 437012 $
042 */
043 public class AnnotatedFilterTreeDialog extends JDialog
044 {
045 private static final long serialVersionUID = 3690476917916513074L;
046 private JPanel jPanel1 = new JPanel();
047 private JTree jTree1 = new JTree();
048 private JPanel jPanel2 = new JPanel();
049 private JPanel jPanel3 = new JPanel();
050 private JTextArea jTextArea1 = new JTextArea();
051 private JScrollPane jScrollPane1 = new JScrollPane();
052 private JButton jButton1 = new JButton();
053
054
055 /** Creates new form JDialog */
056 public AnnotatedFilterTreeDialog(Frame parent, boolean modal)
057 {
058 super( parent, modal );
059 initGUI();
060 }
061
062
063 /** This method is called from within the constructor to initialize the form. */
064 private void initGUI()
065 {
066 addWindowListener( new java.awt.event.WindowAdapter()
067 {
068 public void windowClosing( java.awt.event.WindowEvent evt )
069 {
070 closeDialog( evt );
071 }
072 } );
073 pack();
074 getContentPane().setLayout( new java.awt.GridBagLayout() );
075 getContentPane().add(
076 jPanel1,
077 new java.awt.GridBagConstraints( 0, 0, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.NORTH,
078 java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 10, 5, 5, 5 ), 0, 0 ) );
079 getContentPane().add(
080 jPanel2,
081 new java.awt.GridBagConstraints( 0, 1, 1, 1, 1.0, 0.8, java.awt.GridBagConstraints.CENTER,
082 java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 5, 5, 5, 5 ), 0, 0 ) );
083 getContentPane().add(
084 jPanel3,
085 new java.awt.GridBagConstraints( 0, 2, 1, 1, 1.0, 0.1, java.awt.GridBagConstraints.SOUTH,
086 java.awt.GridBagConstraints.HORIZONTAL, new java.awt.Insets( 0, 0, 0, 0 ), 0, 0 ) );
087 jPanel1.setLayout( new java.awt.BorderLayout( 10, 10 ) );
088 jPanel1.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
089 new java.awt.Color( 153, 153, 153 ), 1 ), "Search Filter", javax.swing.border.TitledBorder.LEADING,
090 javax.swing.border.TitledBorder.TOP, new java.awt.Font( "SansSerif", 0, 14 ), new java.awt.Color( 60, 60,
091 60 ) ) );
092 jPanel1.add( jTextArea1, java.awt.BorderLayout.CENTER );
093 jScrollPane1.getViewport().add( jTree1 );
094 jTree1.setBounds( new java.awt.Rectangle( 238, 142, 82, 80 ) );
095 jTextArea1.setText( "" );
096 jTextArea1.setEditable( false );
097 setBounds( new java.awt.Rectangle( 0, 0, 485, 414 ) );
098 jPanel2.setLayout( new java.awt.BorderLayout() );
099 jPanel2.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
100 new java.awt.Color( 153, 153, 153 ), 1 ), "Filter Expression Tree",
101 javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, new java.awt.Font(
102 "SansSerif", 0, 14 ), new java.awt.Color( 60, 60, 60 ) ) );
103 jPanel2.add( jScrollPane1, java.awt.BorderLayout.CENTER );
104 jButton1.setText( "Done" );
105 jButton1.setActionCommand( "Done" );
106 jButton1.addActionListener( new ActionListener()
107 {
108 public void actionPerformed( ActionEvent a_event )
109 {
110 AnnotatedFilterTreeDialog.this.setVisible( false );
111 AnnotatedFilterTreeDialog.this.dispose();
112 }
113 } );
114 jButton1.setHorizontalAlignment( javax.swing.SwingConstants.CENTER );
115 jButton1.setAlignmentX( 0.5f );
116 jButton1.setHorizontalTextPosition( javax.swing.SwingConstants.CENTER );
117 jPanel3.setPreferredSize( new java.awt.Dimension( 79, 41 ) );
118 jPanel3.setMinimumSize( new java.awt.Dimension( 79, 41 ) );
119 jPanel3.setSize( new java.awt.Dimension( 471, 35 ) );
120 jPanel3.setToolTipText( "" );
121 jPanel3.add( jButton1 );
122 }
123
124
125 /** Closes the dialog */
126 private void closeDialog( WindowEvent evt )
127 {
128 evt.getWindow();
129 setVisible( false );
130 dispose();
131 }
132
133
134 public void setModel( TreeModel a_model )
135 {
136 this.jTree1.setModel( a_model );
137 }
138
139
140 public void setFilter( String a_filter )
141 {
142 this.jTextArea1.setText( a_filter );
143 }
144 }