View Javadoc

1   package com.melloware.jukes.gui.view.dialogs;
2   
3   import java.awt.BorderLayout;
4   import java.awt.Frame;
5   
6   import javax.swing.JButton;
7   import javax.swing.JComponent;
8   import javax.swing.JPanel;
9   import javax.swing.JTabbedPane;
10  
11  import com.jgoodies.forms.factories.Borders;
12  import com.jgoodies.forms.factories.ButtonBarFactory;
13  import com.jgoodies.forms.layout.Sizes;
14  import com.jgoodies.uif.AbstractDialog;
15  import com.jgoodies.uif.util.Resizer;
16  import com.jgoodies.uifextras.panel.HeaderPanel;
17  import com.melloware.jukes.gui.tool.Resources;
18  
19  /**
20   * Provides statistics about the application from Hibernate and other sources.
21   * <p>
22   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
23   * @author Emil A. Lefkof III <info@melloware.com>
24   * @version 4.0
25   */
26  public final class StatisticsDialog extends AbstractDialog {
27     private JButton buttonClose;
28     private JComponent buttonBar;
29  
30     /**
31      * Constructs a default about dialog using the given owner.
32      * @param owner the dialog's owner
33      */
34     public StatisticsDialog(Frame owner) {
35        super(owner);
36     }
37  
38     /**
39      * Builds and returns the dialog's system tab.
40      * @return the system tab component
41      */
42     protected JComponent buildApplicationTab() {
43        // JPanel table = new ApplicationStats();
44        final JPanel table = new PropertySheetApplicationStats();
45        int width = Sizes.dialogUnitXAsPixel(300, table);
46        table.setPreferredSize(Resizer.DEFAULT.fromWidth(width));
47        table.setBorder(Borders.DIALOG_BORDER);
48        return table;
49     }
50  
51     /**
52      * Builds and answers the dialog's content.
53      * @return the dialog's content with tabbed pane and button bar
54      */
55     @Override
56     protected JComponent buildContent() {
57        final JPanel content = new JPanel(new BorderLayout());
58        content.add(buildTabbedPane(), BorderLayout.CENTER);
59        // content.add(buildButtonBarWithClose(), BorderLayout.SOUTH);
60        buttonClose = createCancelButton();// AZ
61        buttonClose.setText(Resources.getString("label.Close")); // AZ
62        buttonClose.setEnabled(true);
63        buttonBar = ButtonBarFactory.buildRightAlignedBar(buttonClose);
64        content.add(buttonBar, BorderLayout.SOUTH);
65        return content;
66     }
67  
68     /**
69      * Builds and returns the dialog's system tab.
70      * @return the system tab component
71      */
72     protected JComponent buildDatabaseTab() {
73        final JPanel table = new PropertySheetHibernateStats();
74        int width = Sizes.dialogUnitXAsPixel(220, table);
75        table.setPreferredSize(Resizer.DEFAULT.fromWidth(width));
76        table.setBorder(Borders.DIALOG_BORDER);
77        return table;
78     }
79  
80     /**
81      * Builds and returns the dialog's header.
82      * @return the dialog's header component
83      */
84     @Override
85     protected JComponent buildHeader() {
86        return new HeaderPanel(Resources.getString("label.Statistics"), Resources.getString("label.StatisticsMessage"),
87                 Resources.STATS_LARGE_ICON);
88     }
89  
90     /**
91      * Builds and returns the dialog's tabbed pane.
92      * @return the dialog's tabbed pane component
93      */
94     protected JComponent buildTabbedPane() {
95        final JTabbedPane tabbedPane = new JTabbedPane();
96        tabbedPane.add(Resources.getString("label.Application"), buildApplicationTab());
97        tabbedPane.add(Resources.getString("label.Database"), buildDatabaseTab());
98        return tabbedPane;
99     }
100 
101    /**
102     * Resizes the given component to give it a quadratic aspect ratio.
103     * @param component the component to be resized
104     */
105    @Override
106    protected void resizeHook(JComponent component) {
107       Resizer.ONE2ONE.resizeDialogContent(component);
108    }
109 
110 }