View Javadoc

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.partition.impl.btree.gui;
18  
19  
20  import java.awt.BorderLayout;
21  import java.awt.FlowLayout;
22  import java.awt.Frame;
23  import java.awt.GridBagLayout;
24  import java.awt.event.ActionEvent;
25  import java.awt.event.ActionListener;
26  import java.awt.event.WindowEvent;
27  
28  import javax.swing.ImageIcon;
29  import javax.swing.JButton;
30  import javax.swing.JDialog;
31  import javax.swing.JLabel;
32  import javax.swing.JPanel;
33  import javax.swing.JTextArea;
34  
35  
36  /***
37   * An about dialog for the introspector GUI.
38   *
39   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
40   * @version $Rev: 264732 $
41   */
42  public class AboutDialog extends JDialog
43  {
44      private static final long serialVersionUID = 3257853194544952884L;
45  
46      private String title = "About";
47      private String product = "Eve jdbm partition inspector";
48      private String version = "0.1";
49      private String copyright = "Copyright (c) 2003";
50      private String comments =
51          "This is the jdbm partition viewer or introspector.\nIrregular behavior "
52        + "can be analyzed by using this tool to inspect\nthe state of system "
53        + "indices and entry attributes within the partition's database.";
54      private JPanel contentPane = new JPanel();
55      private JLabel prodLabel = new JLabel();
56      private JLabel verLabel = new JLabel();
57      private JLabel copLabel = new JLabel();
58      private JTextArea commentField = new JTextArea();
59      private JPanel btnPanel = new JPanel();
60      private JButton okButton = new JButton();
61      private JLabel image = new JLabel();
62      private BorderLayout formLayout = new BorderLayout();
63      private GridBagLayout contentPaneLayout = new GridBagLayout();
64      private FlowLayout btnPaneLayout = new FlowLayout();
65      private JPanel jPanel1 = new JPanel();
66      private JPanel jPanel2 = new JPanel();
67  
68  
69      /*** Creates new About Dialog */
70      public AboutDialog(Frame parent, boolean modal)
71      {
72          super(parent, modal);
73          initGUI();
74          pack();
75      }
76  
77  
78      public AboutDialog()
79      {
80          super();
81          setModal(true);
82          initGUI();
83          pack();
84      }
85  
86  
87      /*** This method is called from within the constructor to initialize the dialog. */
88      private void initGUI()
89      {
90          addWindowListener(
91              new java.awt.event.WindowAdapter() {
92                  public void windowClosing(WindowEvent evt) {
93                      closeDialog(evt);
94                  }
95              });
96          getContentPane().setLayout(formLayout);
97          contentPane.setLayout(contentPaneLayout);
98          contentPane.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(
99          new java.awt.Color(153, 153, 153), 1), "Directory Project: Eve", javax.swing.border.TitledBorder.LEADING, javax.swing.border.TitledBorder.TOP,
100         new java.awt.Font("SansSerif", 0, 14), new java.awt.Color(60, 60, 60)));
101         prodLabel.setText(product);
102         prodLabel.setAlignmentX(0.5f);
103         contentPane.add(prodLabel,
104         new java.awt.GridBagConstraints(java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.RELATIVE,
105         java.awt.GridBagConstraints.REMAINDER, 1, 0.0, 0.0, java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.NONE,
106         new java.awt.Insets(5, 5, 0, 0), 5, 0));
107         verLabel.setText(version);
108         contentPane.add(verLabel,
109         new java.awt.GridBagConstraints(java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.RELATIVE,
110         java.awt.GridBagConstraints.REMAINDER, 1, 0.0, 0.0, java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.NONE,
111         new java.awt.Insets(5, 5, 0, 0), 0, 0));
112         copLabel.setText(copyright);
113         contentPane.add(copLabel,
114         new java.awt.GridBagConstraints(java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.RELATIVE,
115         java.awt.GridBagConstraints.REMAINDER, 1, 0.0, 0.0, java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.NONE,
116         new java.awt.Insets(5, 5, 0, 0), 0, 0));
117         commentField.setBackground(getBackground());
118         commentField.setForeground(copLabel.getForeground());
119         commentField.setFont(copLabel.getFont());
120         commentField.setText(comments);
121         commentField.setEditable(false);
122         commentField.setBorder(null);
123         contentPane.add(commentField,
124         new java.awt.GridBagConstraints(java.awt.GridBagConstraints.RELATIVE, java.awt.GridBagConstraints.RELATIVE,
125         java.awt.GridBagConstraints.REMAINDER, 3, 0.0, 1.0, java.awt.GridBagConstraints.NORTHWEST, java.awt.GridBagConstraints.BOTH,
126         new java.awt.Insets(5, 5, 5, 0), 0, 0));
127 
128         image.setText("Eve");
129         image.setIcon( new ImageIcon( getClass().getResource( "server.gif" ) ) );
130 
131         image.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
132         image.setMinimumSize(new java.awt.Dimension(98,44));
133         image.setMaximumSize(new java.awt.Dimension(98,44));
134         image.setAlignmentX(0.5f);
135         image.setBorder(javax.swing.BorderFactory.createEmptyBorder());
136         image.setPreferredSize(new java.awt.Dimension(98,44));
137         image.setSize(new java.awt.Dimension(98,200));
138         btnPanel.setLayout(btnPaneLayout);
139         okButton.setText("OK");
140         okButton.addActionListener(
141             new ActionListener() {
142                 public void actionPerformed(ActionEvent e) {
143                     setVisible(false);
144                     dispose();
145                 }
146             });
147         btnPanel.add(okButton);
148         getContentPane().add(image, BorderLayout.WEST);
149         getContentPane().add(contentPane, BorderLayout.CENTER);
150         getContentPane().add(btnPanel, BorderLayout.SOUTH);
151         getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
152         getContentPane().add(jPanel2, java.awt.BorderLayout.EAST);
153         setTitle(title);
154         setResizable(false);
155         setFont(new java.awt.Font("Dialog",java.awt.Font.BOLD,12));
156         formLayout.setHgap(15);
157         jPanel1.setMinimumSize(new java.awt.Dimension(10, 30));
158         jPanel1.setPreferredSize(new java.awt.Dimension(10, 30));
159         jPanel1.setSize(new java.awt.Dimension(564, 35));
160         jPanel2.setMinimumSize(new java.awt.Dimension(72, 165));
161         jPanel2.setPreferredSize(new java.awt.Dimension(80, 165));
162         jPanel2.setSize(new java.awt.Dimension(72, 170));
163         jPanel2.setMaximumSize(new java.awt.Dimension(80,165));
164     }
165 
166 
167     /*** Closes the dialog */
168     private void closeDialog(WindowEvent evt)
169     {
170         evt.getWindow();
171         setVisible( false );
172         dispose();
173     }
174 }