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    
027    import javax.naming.directory.Attributes;
028    import javax.swing.JButton;
029    import javax.swing.JComboBox;
030    import javax.swing.JDialog;
031    import javax.swing.JLabel;
032    import javax.swing.JPanel;
033    import javax.swing.JScrollPane;
034    import javax.swing.JTable;
035    import javax.swing.JTextField;
036    
037    
038    /**
039     * Allows for operations on entries.
040     * 
041     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
042     * @version $Rev: 510365 $
043     */
044    public class EntryDialog extends JDialog
045    {
046        private static final long serialVersionUID = 3761684611092001592L;
047    
048        private JPanel m_namePnl = new JPanel();
049        private JPanel m_attrPnl = new JPanel();
050        private JPanel m_buttonPnl = new JPanel();
051        private JPanel m_rdnPnl = new JPanel();
052        private JPanel m_dnPnl = new JPanel();
053        private JLabel m_rdnLbl = new JLabel();
054        private JComboBox m_rdnChoice = new JComboBox();
055        private JTextField m_dnText = new JTextField();
056        private JScrollPane m_attrScrollPnl = new JScrollPane();
057        private JTable m_attrTbl = new JTable();
058        private JButton m_doneBut = new JButton();
059        private JButton m_cancelBut = new JButton();
060    
061    
062        //    private String m_opMode = "Add" ;
063        //    private String m_dn ;
064        //    private String m_rdn ;
065        //    private Attributes m_entry ;
066    
067        /**
068         * Creates new form JDialog
069         *  
070         * @param parent
071         * @param modal
072         */
073        public EntryDialog( Frame parent, boolean modal )
074        {
075            super( parent, modal );
076            initGUI();
077        }
078    
079    
080        /** 
081         * This method is called from within the constructor to initialize the form.
082         */
083        private void initGUI()
084        {
085            addWindowListener( new java.awt.event.WindowAdapter()
086            {
087                public void windowClosing( java.awt.event.WindowEvent evt )
088                {
089                    closeDialog();
090                }
091            } );
092            pack();
093            setBounds( new java.awt.Rectangle( 0, 0, 447, 364 ) );
094            setTitle( "Entry Dialog" );
095            getContentPane().setLayout( new java.awt.GridBagLayout() );
096            getContentPane().add(
097                m_namePnl,
098                new java.awt.GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, java.awt.GridBagConstraints.NORTH,
099                    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    }