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.BorderLayout;
024    import java.awt.FlowLayout;
025    import java.awt.Frame;
026    import java.awt.GridBagLayout;
027    import java.awt.event.ActionEvent;
028    import java.awt.event.ActionListener;
029    import java.awt.event.WindowEvent;
030    
031    import javax.swing.ImageIcon;
032    import javax.swing.JButton;
033    import javax.swing.JDialog;
034    import javax.swing.JLabel;
035    import javax.swing.JPanel;
036    import javax.swing.JTextArea;
037    import javax.swing.SwingConstants;
038    
039    
040    /**
041     * An about dialog for the introspector GUI.
042     *
043     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
044     * @version $Rev: 437012 $
045     */
046    public class AboutDialog extends JDialog
047    {
048        private static final long serialVersionUID = 3257853194544952884L;
049    
050        private String title = "About";
051        private String product = "Vendor: Apache Software Foundation";
052        private String version = "Version: 0.1";
053        private String copyright = "Copyright (c) 2003";
054        private String comments = "This is the btree partition introspector.\nParitions "
055            + "can be analyzed by using this tool to inspect\nthe state of system " + "indices and entry attributes.";
056        private JPanel contentPane = new JPanel();
057        private JLabel prodLabel = new JLabel();
058        private JLabel verLabel = new JLabel();
059        private JLabel copLabel = new JLabel();
060        private JTextArea commentField = new JTextArea();
061        private JPanel btnPanel = new JPanel();
062        private JButton okButton = new JButton();
063        private JLabel image = new JLabel();
064        private BorderLayout formLayout = new BorderLayout();
065        private GridBagLayout contentPaneLayout = new GridBagLayout();
066        private FlowLayout btnPaneLayout = new FlowLayout();
067        private JPanel jPanel1 = new JPanel();
068        private JPanel jPanel2 = new JPanel();
069    
070    
071        /** Creates new About Dialog */
072        public AboutDialog(Frame parent, boolean modal)
073        {
074            super( parent, modal );
075            initGUI();
076            pack();
077        }
078    
079    
080        public AboutDialog()
081        {
082            super();
083            setModal( true );
084            initGUI();
085            pack();
086        }
087    
088    
089        /** This method is called from within the constructor to initialize the dialog. */
090        private void initGUI()
091        {
092            addWindowListener( new java.awt.event.WindowAdapter()
093            {
094                public void windowClosing( WindowEvent evt )
095                {
096                    closeDialog( evt );
097                }
098            } );
099            getContentPane().setLayout( formLayout );
100            contentPane.setLayout( contentPaneLayout );
101            contentPane.setBorder( javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory
102                .createLineBorder( new java.awt.Color( 153, 153, 153 ), 1 ), "BTree Partition Inspector",
103                javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP, new java.awt.Font(
104                    "SansSerif", 0, 14 ), new java.awt.Color( 60, 60, 60 ) ) );
105            prodLabel.setText( product );
106            prodLabel.setAlignmentX( 0.5f );
107            contentPane.add( prodLabel, new java.awt.GridBagConstraints( java.awt.GridBagConstraints.RELATIVE,
108                java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
109                java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.NONE, new java.awt.Insets( 5, 5, 0, 0 ),
110                5, 0 ) );
111            verLabel.setText( version );
112            contentPane.add( verLabel, new java.awt.GridBagConstraints( java.awt.GridBagConstraints.RELATIVE,
113                java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
114                java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.NONE, new java.awt.Insets( 5, 5, 0, 0 ),
115                0, 0 ) );
116            copLabel.setText( copyright );
117            contentPane.add( copLabel, new java.awt.GridBagConstraints( java.awt.GridBagConstraints.RELATIVE,
118                java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
119                java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.NONE, new java.awt.Insets( 5, 5, 0, 0 ),
120                0, 0 ) );
121            commentField.setBackground( getBackground() );
122            commentField.setForeground( copLabel.getForeground() );
123            commentField.setFont( copLabel.getFont() );
124            commentField.setText( comments );
125            commentField.setEditable( false );
126            commentField.setBorder( null );
127            contentPane.add( commentField, new java.awt.GridBagConstraints( java.awt.GridBagConstraints.RELATIVE,
128                java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.REMAINDER, 3, 0.0, 1.0,
129                java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.BOTH, new java.awt.Insets( 5, 5, 5, 0 ),
130                0, 0 ) );
131    
132            image.setText( "ApacheDS" );
133            image.setVerticalTextPosition( SwingConstants.BOTTOM );
134            image.setHorizontalTextPosition( SwingConstants.CENTER );
135            image.setIcon( new ImageIcon( AboutDialog.class.getResource( "server.gif" ) ) );
136            image.setHorizontalAlignment( javax.swing.SwingConstants.CENTER );
137            image.setMinimumSize( new java.awt.Dimension( 120, 44 ) );
138            image.setMaximumSize( new java.awt.Dimension( 120, 44 ) );
139            image.setAlignmentX( 0.5f );
140            image.setBorder( javax.swing.BorderFactory.createEmptyBorder() );
141            image.setPreferredSize( new java.awt.Dimension( 98, 44 ) );
142            image.setSize( new java.awt.Dimension( 120, 200 ) );
143            btnPanel.setLayout( btnPaneLayout );
144            okButton.setText( "OK" );
145            okButton.addActionListener( new ActionListener()
146            {
147                public void actionPerformed( ActionEvent e )
148                {
149                    setVisible( false );
150                    dispose();
151                }
152            } );
153            btnPanel.add( okButton );
154            getContentPane().add( image, BorderLayout.WEST );
155            getContentPane().add( contentPane, BorderLayout.CENTER );
156            getContentPane().add( btnPanel, BorderLayout.SOUTH );
157            getContentPane().add( jPanel1, java.awt.BorderLayout.NORTH );
158            getContentPane().add( jPanel2, java.awt.BorderLayout.EAST );
159            setTitle( title );
160            setResizable( false );
161            setFont( new java.awt.Font( "Dialog", java.awt.Font.BOLD, 12 ) );
162            formLayout.setHgap( 15 );
163            jPanel1.setMinimumSize( new java.awt.Dimension( 10, 30 ) );
164            jPanel1.setPreferredSize( new java.awt.Dimension( 10, 30 ) );
165            jPanel1.setSize( new java.awt.Dimension( 564, 35 ) );
166            jPanel2.setMinimumSize( new java.awt.Dimension( 72, 165 ) );
167            jPanel2.setPreferredSize( new java.awt.Dimension( 80, 165 ) );
168            jPanel2.setSize( new java.awt.Dimension( 72, 170 ) );
169            jPanel2.setMaximumSize( new java.awt.Dimension( 80, 165 ) );
170        }
171    
172    
173        /** Closes the dialog */
174        private void closeDialog( WindowEvent evt )
175        {
176            evt.getWindow();
177            setVisible( false );
178            dispose();
179        }
180    }