KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > db > gui > EntryDialog


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.naming.directory.Attributes JavaDoc;
21 import javax.swing.*;
22 import java.awt.*;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25
26
27 /**
28  * Allows for operations on entries.
29  *
30  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
31  * @version $Rev: 169198 $
32  */

33 public class EntryDialog extends JDialog
34 {
35     private static final long serialVersionUID = 3761684611092001592L;
36
37     private JPanel m_namePnl = new JPanel() ;
38     private JPanel m_attrPnl = new JPanel() ;
39     private JPanel m_buttonPnl = new JPanel() ;
40     private JPanel m_rdnPnl = new JPanel() ;
41     private JPanel m_dnPnl = new JPanel() ;
42     private JLabel m_rdnLbl = new JLabel() ;
43     private JComboBox m_rdnChoice = new JComboBox() ;
44     private JTextField m_dnText = new JTextField() ;
45     private JScrollPane m_attrScrollPnl = new JScrollPane() ;
46     private JTable m_attrTbl = new JTable() ;
47     private JButton m_doneBut = new JButton() ;
48     private JButton m_cancelBut = new JButton() ;
49
50     private String JavaDoc m_opMode = "Add" ;
51     private String JavaDoc m_dn ;
52     private String JavaDoc m_rdn ;
53     private Attributes JavaDoc m_entry ;
54
55
56     /**
57      * Creates new form JDialog
58      *
59      * @param a_parent
60      * @param a_modal
61      */

62     public EntryDialog( Frame a_parent, String JavaDoc a_opMode, boolean a_modal )
63     {
64         super( a_parent, a_modal ) ;
65         m_opMode = a_opMode ;
66         initGUI() ;
67     }
68
69
70     /**
71      * This method is called from within the constructor to initialize the form.
72      */

73     private void initGUI( )
74     {
75         addWindowListener( new java.awt.event.WindowAdapter JavaDoc( )
76         {
77             public void windowClosing( java.awt.event.WindowEvent JavaDoc evt )
78             {
79                 closeDialog( ) ;
80             }
81         } ) ;
82         pack( ) ;
83         setBounds( new java.awt.Rectangle JavaDoc( 0, 0, 447, 364 ) ) ;
84         setTitle( "Entry Dialog" ) ;
85         getContentPane( ).setLayout( new java.awt.GridBagLayout JavaDoc( ) ) ;
86         getContentPane( ).add(
87             m_namePnl,
88             new java.awt.GridBagConstraints JavaDoc(
89                 0,
90                 0,
91                 1,
92                 1,
93                 1.0,
94                 0.0,
95                 java.awt.GridBagConstraints.NORTH,
96                 java.awt.GridBagConstraints.HORIZONTAL,
97                 new java.awt.Insets JavaDoc( 5, 5, 5, 5 ),
98                 0,
99                 0 ) ) ;
100         getContentPane( ).add(
101             m_attrPnl,
102             new java.awt.GridBagConstraints JavaDoc(
103                 0,
104                 1,
105                 1,
106                 1,
107                 1.0,
108                 1.0,
109                 java.awt.GridBagConstraints.CENTER,
110                 java.awt.GridBagConstraints.BOTH,
111                 new java.awt.Insets JavaDoc( 5, 5, 5, 5 ),
112                 0,
113                 0 ) ) ;
114         getContentPane( ).add(
115             m_buttonPnl,
116             new java.awt.GridBagConstraints JavaDoc(
117                 0,
118                 2,
119                 1,
120                 1,
121                 1.0,
122                 0.05,
123                 java.awt.GridBagConstraints.CENTER,
124                 java.awt.GridBagConstraints.HORIZONTAL,
125                 new java.awt.Insets JavaDoc( 0, 0, 0, 20 ),
126                 0,
127                 0 ) ) ;
128         m_namePnl.setBorder(
129             javax.swing.BorderFactory.createTitledBorder(
130                 javax.swing.BorderFactory.createLineBorder(
131                     new java.awt.Color JavaDoc( 153, 153, 153 ),
132                     1 ),
133                 "Naming",
134                 javax.swing.border.TitledBorder.LEADING,
135                 javax.swing.border.TitledBorder.TOP,
136                 new java.awt.Font JavaDoc( "SansSerif", 0, 14 ),
137                 new java.awt.Color JavaDoc( 60, 60, 60 ) ) ) ;
138         m_namePnl.setLayout(
139             new javax.swing.BoxLayout JavaDoc( m_namePnl, javax.swing.BoxLayout.Y_AXIS ) ) ;
140         m_namePnl.add( m_rdnPnl ) ;
141         m_namePnl.add( m_dnPnl ) ;
142         m_rdnLbl.setText( "Rdn:" ) ;
143         m_rdnPnl.setLayout( new java.awt.GridBagLayout JavaDoc() ) ;
144         m_rdnPnl.add(
145             m_rdnChoice,
146             new java.awt.GridBagConstraints JavaDoc(
147                 1,
148                 0,
149                 1,
150                 1,
151                 1.0,
152                 0.0,
153                 java.awt.GridBagConstraints.WEST,
154                 java.awt.GridBagConstraints.NONE,
155                 new java.awt.Insets JavaDoc( 0, 10, 0, 0 ),
156                 0,
157                 0 ) ) ;
158         m_rdnPnl.add(
159             m_rdnLbl,
160             new java.awt.GridBagConstraints JavaDoc(
161                 0,
162                 0,
163                 1,
164                 1,
165                 0.0,
166                 0.0,
167                 java.awt.GridBagConstraints.WEST,
168                 java.awt.GridBagConstraints.NONE,
169                 new java.awt.Insets JavaDoc( 0, 10, 0, 0 ),
170                 0,
171                 0 ) ) ;
172         m_dnPnl.setLayout( new java.awt.GridBagLayout JavaDoc( ) ) ;
173         m_dnPnl.add(
174             m_dnText,
175             new java.awt.GridBagConstraints JavaDoc(
176                 1,
177                 0,
178                 1,
179                 1,
180                 1.0,
181                 0.0,
182                 java.awt.GridBagConstraints.WEST,
183                 java.awt.GridBagConstraints.HORIZONTAL,
184                 new java.awt.Insets JavaDoc( 0, 5, 0, 0 ),
185                 0,
186                 0 ) ) ;
187         m_dnText.setText( "unknown" ) ;
188         m_dnText.setEditable( false ) ;
189         m_dnText.setBorder(
190             javax.swing.BorderFactory.createTitledBorder(
191                 javax.swing.BorderFactory.createLineBorder(
192                     new java.awt.Color JavaDoc( 153, 153, 153 ),
193                     1 ),
194                 "Dn",
195                 javax.swing.border.TitledBorder.LEADING,
196                 javax.swing.border.TitledBorder.TOP,
197                 new java.awt.Font JavaDoc( "SansSerif", 0, 14 ),
198                 new java.awt.Color JavaDoc( 60, 60, 60 ) ) ) ;
199         m_rdnChoice.setEditable( true ) ;
200         m_rdnChoice.setMaximumRowCount( 6 ) ;
201         
202         m_rdnChoice.setSize( new java.awt.Dimension JavaDoc( 130, 24 ) ) ;
203         m_attrPnl.setLayout( new java.awt.BorderLayout JavaDoc( ) ) ;
204         m_attrPnl.add( m_attrScrollPnl, java.awt.BorderLayout.CENTER ) ;
205         m_attrScrollPnl.getViewport( ).add( m_attrTbl ) ;
206         m_attrTbl.setBounds( new java.awt.Rectangle JavaDoc( 78, 60, 32, 32 ) ) ;
207         m_attrTbl.setEditingColumn( 1 ) ;
208         m_attrTbl.setCellSelectionEnabled( true ) ;
209         m_doneBut.setText( "Done" ) ;
210         m_buttonPnl.setLayout(
211             new java.awt.FlowLayout JavaDoc( java.awt.FlowLayout.RIGHT, 10, 5 ) ) ;
212         m_buttonPnl.add( m_doneBut ) ;
213         m_buttonPnl.add( m_cancelBut ) ;
214         m_cancelBut.setText( "Cancel" ) ;
215         m_cancelBut.addActionListener( new ActionListener JavaDoc ()
216         {
217             public void actionPerformed( ActionEvent JavaDoc a_evt )
218             {
219                 closeDialog() ;
220             }
221         } ) ;
222         m_attrScrollPnl.setBorder(
223             javax.swing.BorderFactory.createTitledBorder(
224                 javax.swing.BorderFactory.createLineBorder(
225                     new java.awt.Color JavaDoc( 153, 153, 153 ),
226                     1 ),
227                 "Attributes",
228                 javax.swing.border.TitledBorder.LEADING,
229                 javax.swing.border.TitledBorder.TOP,
230                 new java.awt.Font JavaDoc( "SansSerif", 0, 14 ),
231                 new java.awt.Color JavaDoc( 60, 60, 60 ) ) ) ;
232     }
233
234
235     /** Closes the dialog */
236     private void closeDialog()
237     {
238         setVisible( false ) ;
239         dispose() ;
240     }
241
242
243     public void setDn( String JavaDoc a_dn )
244     {
245         m_dn = a_dn ;
246         m_dnText.setText( a_dn ) ;
247     }
248     
249     
250     public void setRdn( String JavaDoc a_rdn )
251     {
252         m_rdn = a_rdn ;
253         // m_rdnChoice.setSelectedItem( ) ;
254
}
255     
256     
257     public void setEntry( Attributes JavaDoc a_entry )
258     {
259         m_entry = a_entry ;
260     }
261 }
262
Popular Tags