File Source: AboutDialog.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog$1__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.addons.ui_swing.dialogs.about;
24
25 import com.dmdirc.addons.ui_swing.components.StandardDialog;
26
27 import java.awt.Window;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30
31 import java.awt.event.KeyEvent;
32 import javax.swing.JButton;
33 import javax.swing.JComponent;
34 import javax.swing.JTabbedPane;
35 import javax.swing.KeyStroke;
36 import javax.swing.WindowConstants;
37 import javax.swing.event.ChangeEvent;
38 import javax.swing.event.ChangeListener;
39
40 import net.miginfocom.swing.MigLayout;
41
42 /**
43 * About dialog.
44 */
45 public final class AboutDialog extends StandardDialog implements
46 ActionListener, ChangeListener {
47
48 /**
49 * A version number for this class. It should be changed whenever the class
50 * structure is changed (or anything else that would prevent serialized
51 * objects being unserialized with the new class).
52 */
53 private static final long serialVersionUID = 5;
54 /** Previously created instance of AboutDialog. */
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog__static_init
*
* Postconditions:
* me == null
*/
55 private static volatile AboutDialog me = null;
56 /** Tabbed pane to use. */
57 private JTabbedPane tabbedPane;
58 /** Credits panel. */
59 private CreditsPanel cp;
60 /** Tab history. */
61 private int history = 0;
62
63 /**
64 * Creates a new instance of AboutDialog.
65 *
66 * @param parentWindow Parent window
67 */
68 private AboutDialog(final Window parentWindow) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog(Window)
*
* Presumptions:
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getRootPane(...)@80 != null
* init'ed(java.awt.Dialog$ModalityType.MODELESS)
*
* Postconditions:
* this.cp == &new CreditsPanel(initComponents#4)
* init'ed(this.history)
* this.tabbedPane == &new JTabbedPane(initComponents#1)
* new CreditsPanel(initComponents#4) num objects == 1
* new HTMLLabel(initComponents#1) num objects == 1
* new JTabbedPane(initComponents#1) num objects == 1
* new CreditsPanel(initComponents#4).about == &new HTMLLabel(initComponents#1)
*/
69 super(parentWindow, ModalityType.MODELESS);
70 initComponents();
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog$1(AboutDialog)
*/
71 final ActionListener enterListener = new ActionListener() {
72
73 /** {@inheritDoc} */
74 @Override
75 public void actionPerformed(final ActionEvent actionEvent) {
/*
P/P * Method: void actionPerformed(ActionEvent)
*
* Presumptions:
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getOkButton(...)@76 != null
*/
76 getOkButton().doClick();
77 }
78 };
79 final KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
80 getRootPane().registerKeyboardAction(enterListener, enter,
81 JComponent.WHEN_IN_FOCUSED_WINDOW);
82 }
83
84 /**
85 * Creates the dialog if one doesn't exist, and displays it.
86 *
87 * @param parentWindow Parent window*/
88 public static void showAboutDialog(final Window parentWindow) {
/*
P/P * Method: void showAboutDialog(Window)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == One-of{old me, &new AboutDialog(getAboutDialog#1)}
* me != null
* new AboutDialog(getAboutDialog#1) num objects <= 1
*/
89 me = getAboutDialog(parentWindow);
90
91 me.setLocationRelativeTo(parentWindow);
92 me.setVisible(true);
93 me.requestFocusInWindow();
94 }
95
96 /**
97 * Returns the current instance of the AboutDialog.
98 *
99 * @param parentWindow Parent window
100 *
101 * @return The current AboutDialog instance
102 */
103 public static AboutDialog getAboutDialog(final Window parentWindow) {
/*
P/P * Method: AboutDialog getAboutDialog(Window)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == One-of{old me, &new AboutDialog(getAboutDialog#1)}
* me != null
* return_value == One-of{old me, &new AboutDialog(getAboutDialog#1)}
* return_value != null
* new AboutDialog(getAboutDialog#1) num objects <= 1
*/
104 synchronized (AboutDialog.class) {
105 if (me == null) {
106 me = new AboutDialog(parentWindow);
107 }
108 }
109
110 return me;
111 }
112
113 /** Initialises the main UI components. */
114 private void initComponents() {
/*
P/P * Method: void initComponents()
*
* Presumptions:
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getCancelButton(...)@124 != null
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getContentPane(...)@134 != null
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getContentPane(...)@135 != null
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getContentPane(...)@136 != null
* com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog:getOkButton(...)@123 != null
*
* Postconditions:
* this.cp == &new CreditsPanel(initComponents#4)
* this.tabbedPane == &new JTabbedPane(initComponents#1)
* new CreditsPanel(initComponents#4) num objects == 1
* new HTMLLabel(initComponents#1) num objects == 1
* new JTabbedPane(initComponents#1) num objects == 1
* this.cp.about == &new HTMLLabel(initComponents#1)
*/
115 tabbedPane = new JTabbedPane();
116
117 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
118 setTitle("About DMDirc");
119 setResizable(false);
120
121 orderButtons(new JButton(), new JButton());
122
123 getOkButton().addActionListener(this);
124 getCancelButton().addActionListener(this);
125
126 cp = new CreditsPanel();
127
128 tabbedPane.add("About", new AboutPanel());
129 tabbedPane.add("Credits", cp);
130 tabbedPane.add("License", new LicensePanel());
131 tabbedPane.add("Information", new InfoPanel());
132 tabbedPane.addChangeListener(this);
133
134 getContentPane().setLayout(new MigLayout("ins rel, wrap 1, fill, wmax 550, hmax 300"));
135 getContentPane().add(tabbedPane, "grow, push");
136 getContentPane().add(getOkButton(), "right");
137
138 pack();
139 }
140
141 /**
142 * {@inheritDoc}.
143 *
144 * @param e Action event
145 */
146 @Override
147 public void actionPerformed(final ActionEvent e) {
/*
P/P * Method: void actionPerformed(ActionEvent)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == null
*/
148 dispose();
149 }
150
151 /** {@inheritDoc} */
152 @Override
153 public void dispose() {
/*
P/P * Method: void dispose()
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == null
*
* Test Vectors:
* me: Inverse{null}, Addr_Set{null}
*/
154 if (me == null) {
155 return;
156 }
157 synchronized (me) {
158 super.dispose();
159 me = null;
160 }
161 }
162
163 /** {@inheritDoc} */
164 @Override
165 public void stateChanged(ChangeEvent e) {
/*
P/P * Method: void stateChanged(ChangeEvent)
*
* Preconditions:
* init'ed(this.history)
* this.tabbedPane != null
* (soft) this.cp != null
* (soft) this.cp.about != null
*
* Presumptions:
* (this.history%10_000)*10 + javax.swing.JTabbedPane:getSelectedIndex(...)@166 in {-231..232-1}
*
* Postconditions:
* init'ed(this.history)
*
* Test Vectors:
* (this.history%10_000)*10 + javax.swing.JTabbedPane:getSelectedIndex(...)@166: {-231..30_320, 30_322..232-1}, {30_321}
*/
166 history = 10 * (history % 10000) + tabbedPane.getSelectedIndex();
167
168 if (history == 30321) {
169 cp.showEE();
170 }
171 }
172 }
SofCheck Inspector Build Version : 2.17854
| AboutDialog.java |
2009-Jun-25 01:54:24 |
| AboutDialog.class |
2009-Sep-02 17:04:15 |
| AboutDialog$1.class |
2009-Sep-02 17:04:15 |