1 17 package org.apache.ldap.server.db.gui ; 18 19 20 import javax.naming.directory.Attributes ; 21 import javax.swing.*; 22 import java.awt.*; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 26 27 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 m_opMode = "Add" ; 51 private String m_dn ; 52 private String m_rdn ; 53 private Attributes m_entry ; 54 55 56 62 public EntryDialog( Frame a_parent, String a_opMode, boolean a_modal ) 63 { 64 super( a_parent, a_modal ) ; 65 m_opMode = a_opMode ; 66 initGUI() ; 67 } 68 69 70 73 private void initGUI( ) 74 { 75 addWindowListener( new java.awt.event.WindowAdapter ( ) 76 { 77 public void windowClosing( java.awt.event.WindowEvent evt ) 78 { 79 closeDialog( ) ; 80 } 81 } ) ; 82 pack( ) ; 83 setBounds( new java.awt.Rectangle ( 0, 0, 447, 364 ) ) ; 84 setTitle( "Entry Dialog" ) ; 85 getContentPane( ).setLayout( new java.awt.GridBagLayout ( ) ) ; 86 getContentPane( ).add( 87 m_namePnl, 88 new java.awt.GridBagConstraints ( 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 ( 5, 5, 5, 5 ), 98 0, 99 0 ) ) ; 100 getContentPane( ).add( 101 m_attrPnl, 102 new java.awt.GridBagConstraints ( 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 ( 5, 5, 5, 5 ), 112 0, 113 0 ) ) ; 114 getContentPane( ).add( 115 m_buttonPnl, 116 new java.awt.GridBagConstraints ( 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 ( 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 ( 153, 153, 153 ), 132 1 ), 133 "Naming", 134 javax.swing.border.TitledBorder.LEADING, 135 javax.swing.border.TitledBorder.TOP, 136 new java.awt.Font ( "SansSerif", 0, 14 ), 137 new java.awt.Color ( 60, 60, 60 ) ) ) ; 138 m_namePnl.setLayout( 139 new javax.swing.BoxLayout ( 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 () ) ; 144 m_rdnPnl.add( 145 m_rdnChoice, 146 new java.awt.GridBagConstraints ( 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 ( 0, 10, 0, 0 ), 156 0, 157 0 ) ) ; 158 m_rdnPnl.add( 159 m_rdnLbl, 160 new java.awt.GridBagConstraints ( 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 ( 0, 10, 0, 0 ), 170 0, 171 0 ) ) ; 172 m_dnPnl.setLayout( new java.awt.GridBagLayout ( ) ) ; 173 m_dnPnl.add( 174 m_dnText, 175 new java.awt.GridBagConstraints ( 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 ( 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 ( 153, 153, 153 ), 193 1 ), 194 "Dn", 195 javax.swing.border.TitledBorder.LEADING, 196 javax.swing.border.TitledBorder.TOP, 197 new java.awt.Font ( "SansSerif", 0, 14 ), 198 new java.awt.Color ( 60, 60, 60 ) ) ) ; 199 m_rdnChoice.setEditable( true ) ; 200 m_rdnChoice.setMaximumRowCount( 6 ) ; 201 202 m_rdnChoice.setSize( new java.awt.Dimension ( 130, 24 ) ) ; 203 m_attrPnl.setLayout( new java.awt.BorderLayout ( ) ) ; 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 ( 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 ( 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 () 216 { 217 public void actionPerformed( ActionEvent 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 ( 153, 153, 153 ), 226 1 ), 227 "Attributes", 228 javax.swing.border.TitledBorder.LEADING, 229 javax.swing.border.TitledBorder.TOP, 230 new java.awt.Font ( "SansSerif", 0, 14 ), 231 new java.awt.Color ( 60, 60, 60 ) ) ) ; 232 } 233 234 235 236 private void closeDialog() 237 { 238 setVisible( false ) ; 239 dispose() ; 240 } 241 242 243 public void setDn( String a_dn ) 244 { 245 m_dn = a_dn ; 246 m_dnText.setText( a_dn ) ; 247 } 248 249 250 public void setRdn( String a_rdn ) 251 { 252 m_rdn = a_rdn ; 253 } 255 256 257 public void setEntry( Attributes a_entry ) 258 { 259 m_entry = a_entry ; 260 } 261 } 262 | Popular Tags |