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.BorderLayout;
24  import java.awt.FlowLayout;
25  import java.awt.Frame;
26  import java.awt.GridBagLayout;
27  import java.awt.event.ActionEvent;
28  import java.awt.event.ActionListener;
29  import java.awt.event.WindowEvent;
30  
31  import javax.swing.ImageIcon;
32  import javax.swing.JButton;
33  import javax.swing.JDialog;
34  import javax.swing.JLabel;
35  import javax.swing.JPanel;
36  import javax.swing.JTextArea;
37  import javax.swing.SwingConstants;
38  
39  
40  /**
41   * An about dialog for the introspector GUI.
42   *
43   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
44   * @version $Rev: 437012 $
45   */
46  public class AboutDialog extends JDialog
47  {
48      private static final long serialVersionUID = 3257853194544952884L;
49  
50      private String title = "About";
51      private String product = "Vendor: Apache Software Foundation";
52      private String version = "Version: 0.1";
53      private String copyright = "Copyright (c) 2003";
54      private String comments = "This is the btree partition introspector.\nParitions "
55          + "can be analyzed by using this tool to inspect\nthe state of system " + "indices and entry attributes.";
56      private JPanel contentPane = new JPanel();
57      private JLabel prodLabel = new JLabel();
58      private JLabel verLabel = new JLabel();
59      private JLabel copLabel = new JLabel();
60      private JTextArea commentField = new JTextArea();
61      private JPanel btnPanel = new JPanel();
62      private JButton okButton = new JButton();
63      private JLabel image = new JLabel();
64      private BorderLayout formLayout = new BorderLayout();
65      private GridBagLayout contentPaneLayout = new GridBagLayout();
66      private FlowLayout btnPaneLayout = new FlowLayout();
67      private JPanel jPanel1 = new JPanel();
68      private JPanel jPanel2 = new JPanel();
69  
70  
71      /** Creates new About Dialog */
72      public AboutDialog(Frame parent, boolean modal)
73      {
74          super( parent, modal );
75          initGUI();
76          pack();
77      }
78  
79  
80      public AboutDialog()
81      {
82          super();
83          setModal( true );
84          initGUI();
85          pack();
86      }
87  
88  
89      /** This method is called from within the constructor to initialize the dialog. */
90      private void initGUI()
91      {
92          addWindowListener( new java.awt.event.WindowAdapter()
93          {
94              public void windowClosing( WindowEvent evt )
95              {
96                  closeDialog( evt );
97              }
98          } );
99          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 }