View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.core.partition.impl.btree.gui;
21  
22  
23  import java.awt.Frame;
24  import java.awt.event.ActionEvent;
25  import java.awt.event.ActionListener;
26  
27  import javax.naming.directory.Attributes;
28  import javax.swing.JButton;
29  import javax.swing.JComboBox;
30  import javax.swing.JDialog;
31  import javax.swing.JLabel;
32  import javax.swing.JPanel;
33  import javax.swing.JScrollPane;
34  import javax.swing.JTable;
35  import javax.swing.JTextField;
36  
37  
38  /**
39   * Allows for operations on entries.
40   * 
41   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
42   * @version $Rev: 510365 $
43   */
44  public class EntryDialog extends JDialog
45  {
46      private static final long serialVersionUID = 3761684611092001592L;
47  
48      private JPanel m_namePnl = new JPanel();
49      private JPanel m_attrPnl = new JPanel();
50      private JPanel m_buttonPnl = new JPanel();
51      private JPanel m_rdnPnl = new JPanel();
52      private JPanel m_dnPnl = new JPanel();
53      private JLabel m_rdnLbl = new JLabel();
54      private JComboBox m_rdnChoice = new JComboBox();
55      private JTextField m_dnText = new JTextField();
56      private JScrollPane m_attrScrollPnl = new JScrollPane();
57      private JTable m_attrTbl = new JTable();
58      private JButton m_doneBut = new JButton();
59      private JButton m_cancelBut = new JButton();
60  
61  
62      //    private String m_opMode = "Add" ;
63      //    private String m_dn ;
64      //    private String m_rdn ;
65      //    private Attributes m_entry ;
66  
67      /**
68       * Creates new form JDialog
69       *  
70       * @param parent
71       * @param modal
72       */
73      public EntryDialog( Frame parent, boolean modal )
74      {
75          super( parent, modal );
76          initGUI();
77      }
78  
79  
80      /** 
81       * This method is called from within the constructor to initialize the form.
82       */
83      private void initGUI()
84      {
85          addWindowListener( new java.awt.event.WindowAdapter()
86          {
87              public void windowClosing( java.awt.event.WindowEvent evt )
88              {
89                  closeDialog();
90              }
91          } );
92          pack();
93          setBounds( new java.awt.Rectangle( 0, 0, 447, 364 ) );
94          setTitle( "Entry Dialog" );
95          getContentPane().setLayout( new java.awt.GridBagLayout() );
96          getContentPane().add(
97              m_namePnl,
98              new java.awt.GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, java.awt.GridBagConstraints.NORTH,
99                  java.awt.GridBagConstraints.HORIZONTAL, new java.awt.Insets( 5, 5, 5, 5 ), 0, 0 ) );
100         getContentPane().add(
101             m_attrPnl,
102             new java.awt.GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, java.awt.GridBagConstraints.CENTER,
103                 java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 5, 5, 5, 5 ), 0, 0 ) );
104         getContentPane().add(
105             m_buttonPnl,
106             new java.awt.GridBagConstraints( 0, 2, 1, 1, 1.0, 0.05, java.awt.GridBagConstraints.CENTER,
107                 java.awt.GridBagConstraints.HORIZONTAL, new java.awt.Insets( 0, 0, 0, 20 ), 0, 0 ) );
108         m_namePnl.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
109             new java.awt.Color( 153, 153, 153 ), 1 ), "Naming", javax.swing.border.TitledBorder.LEADING,
110             javax.swing.border.TitledBorder.TOP, new java.awt.Font( "SansSerif", 0, 14 ), new java.awt.Color( 60, 60,
111                 60 ) ) );
112         m_namePnl.setLayout( new javax.swing.BoxLayout( m_namePnl, javax.swing.BoxLayout.Y_AXIS ) );
113         m_namePnl.add( m_rdnPnl );
114         m_namePnl.add( m_dnPnl );
115         m_rdnLbl.setText( "Rdn:" );
116         m_rdnPnl.setLayout( new java.awt.GridBagLayout() );
117         m_rdnPnl.add( m_rdnChoice, new java.awt.GridBagConstraints( 1, 0, 1, 1, 1.0, 0.0,
118             java.awt.GridBagConstraints.WEST, java.awt.GridBagConstraints.NONE, new java.awt.Insets( 0, 10, 0, 0 ), 0,
119             0 ) );
120         m_rdnPnl.add( m_rdnLbl, new java.awt.GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0,
121             java.awt.GridBagConstraints.WEST, java.awt.GridBagConstraints.NONE, new java.awt.Insets( 0, 10, 0, 0 ), 0,
122             0 ) );
123         m_dnPnl.setLayout( new java.awt.GridBagLayout() );
124         m_dnPnl.add( m_dnText, new java.awt.GridBagConstraints( 1, 0, 1, 1, 1.0, 0.0, java.awt.GridBagConstraints.WEST,
125             java.awt.GridBagConstraints.HORIZONTAL, new java.awt.Insets( 0, 5, 0, 0 ), 0, 0 ) );
126         m_dnText.setText( "unknown" );
127         m_dnText.setEditable( false );
128         m_dnText.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createLineBorder(
129             new java.awt.Color( 153, 153, 153 ), 1 ), "Dn", javax.swing.border.TitledBorder.LEADING,
130             javax.swing.border.TitledBorder.TOP, new java.awt.Font( "SansSerif", 0, 14 ), new java.awt.Color( 60, 60,
131                 60 ) ) );
132         m_rdnChoice.setEditable( true );
133         m_rdnChoice.setMaximumRowCount( 6 );
134 
135         m_rdnChoice.setSize( new java.awt.Dimension( 130, 24 ) );
136         m_attrPnl.setLayout( new java.awt.BorderLayout() );
137         m_attrPnl.add( m_attrScrollPnl, java.awt.BorderLayout.CENTER );
138         m_attrScrollPnl.getViewport().add( m_attrTbl );
139         m_attrTbl.setBounds( new java.awt.Rectangle( 78, 60, 32, 32 ) );
140         m_attrTbl.setEditingColumn( 1 );
141         m_attrTbl.setCellSelectionEnabled( true );
142         m_doneBut.setText( "Done" );
143         m_buttonPnl.setLayout( new java.awt.FlowLayout( java.awt.FlowLayout.RIGHT, 10, 5 ) );
144         m_buttonPnl.add( m_doneBut );
145         m_buttonPnl.add( m_cancelBut );
146         m_cancelBut.setText( "Cancel" );
147         m_cancelBut.addActionListener( new ActionListener()
148         {
149             public void actionPerformed( ActionEvent a_evt )
150             {
151                 closeDialog();
152             }
153         } );
154         m_attrScrollPnl.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory
155             .createLineBorder( new java.awt.Color( 153, 153, 153 ), 1 ), "Attributes",
156             javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, new java.awt.Font(
157                 "SansSerif", 0, 14 ), new java.awt.Color( 60, 60, 60 ) ) );
158     }
159 
160 
161     /** Closes the dialog */
162     private void closeDialog()
163     {
164         setVisible( false );
165         dispose();
166     }
167 
168 
169     public void setDn( String a_dn )
170     {
171         //        m_dn = a_dn ;
172         m_dnText.setText( a_dn );
173     }
174 
175 
176     public void setRdn( String a_rdn )
177     {
178         //        m_rdn = a_rdn ;
179         // m_rdnChoice.setSelectedItem(  ) ;
180     }
181 
182 
183     public void setEntry( Attributes a_entry )
184     {
185         //        m_entry = a_entry ;
186     }
187 }