File Source: SwingPreferencesDialog.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog$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 package com.dmdirc.addons.ui_swing.dialogs.prefs;
23
24 import com.dmdirc.config.prefs.PreferencesCategory;
25 import com.dmdirc.config.prefs.PreferencesManager;
26 import com.dmdirc.addons.ui_swing.UIUtilities;
27 import com.dmdirc.addons.ui_swing.components.ListScroller;
28 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29 import com.dmdirc.addons.ui_swing.components.StandardDialog;
30 import com.dmdirc.config.IdentityManager;
31 import com.dmdirc.logger.ErrorLevel;
32 import com.dmdirc.logger.Logger;
33
34 import java.awt.Window;
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
37 import java.awt.event.WindowAdapter;
38 import java.awt.event.WindowEvent;
39 import java.util.Collection;
40 import java.util.List;
41 import java.util.concurrent.ExecutionException;
42
43 import javax.swing.BorderFactory;
44 import javax.swing.DefaultListModel;
45 import javax.swing.JButton;
46 import javax.swing.JList;
47 import javax.swing.JOptionPane;
48 import javax.swing.JScrollPane;
49 import javax.swing.ListSelectionModel;
50 import javax.swing.WindowConstants;
51 import javax.swing.event.ListSelectionEvent;
52 import javax.swing.event.ListSelectionListener;
53
54 import net.miginfocom.swing.MigLayout;
55
56 /**
57 * Allows the user to modify global client preferences.
58 */
/*
P/P * Method: void access$400(SwingPreferencesDialog)
*
* Preconditions:
* x0 != null
* x0.tabList != null
*/
59 public final class SwingPreferencesDialog extends StandardDialog implements
60 ActionListener, ListSelectionListener {
61
62 /**
63 * A version number for this class. It should be changed whenever the
64 * class structure is changed (or anything else that would prevent
65 * serialized objects being unserialized with the new class).
66 */
67 private static final long serialVersionUID = 9;
68 /**
69 * The maximum height clients may use if they don't want to scroll.
70 *
71 * @since 0.6.3m1
72 */
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog__static_init
*
* Postconditions:
* CLIENT_HEIGHT == 375
*/
73 public static int CLIENT_HEIGHT = 375;
74 /** Previously instantiated instance of SwingPreferencesDialog. */
75 private static volatile SwingPreferencesDialog me;
76 /** Preferences tab list, used to switch option types. */
77 private JList tabList;
78 /** Main panel. */
79 private CategoryPanel mainPanel;
80 /** Previously selected category. */
81 private PreferencesCategory selected;
82 /** Preferences Manager. */
83 private PreferencesManager manager;
84 /** Manager loading swing worker. */
85 private LoggingSwingWorker worker;
86 /** Parent window. */
87 private Window parentWindow;
88
89 /**
90 * Creates a new instance of SwingPreferencesDialog.
91 *
92 * @param parentWindow Parent window
93 */
94 private SwingPreferencesDialog(final Window parentWindow) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog(Window)
*
* Presumptions:
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@58) in {-231..232-1}
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@61) in {-231..232-1}
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@64) in {-231..232-1}
* init'ed(java.awt.Dialog$ModalityType.MODELESS)
* java.util.Collections:synchronizedMap(...)@109 != null
*
* Postconditions:
* this.mainPanel == &new CategoryPanel(initComponents#1)
* this.tabList == &new JList(initComponents#2)
* this.worker == &new SwingPreferencesDialog$1(SwingPreferencesDialog#1)
* new CategoryPanel(initComponents#1) num objects == 1
* new JList(initComponents#2) num objects == 1
* new JPanel(CategoryPanel#3) num objects == 1
* new JPanel(CategoryPanel#6) num objects == 1
* new JPanel(CategoryPanel#9) num objects == 1
* new JScrollPane(CategoryPanel#12) num objects == 1
* new SwingPreferencesDialog$1(SwingPreferencesDialog#1) num objects == 1
* ...
*/
95 super(parentWindow, ModalityType.MODELESS);
96
97 initComponents();
98
/*
P/P * Method: Object doInBackground()
*
* Preconditions:
* this.mainPanel != null
* this.mainPanel.scrollPane != null
* init'ed(this.mainPanel.waitingCategory)
*
* Postconditions:
* return_value == &new PreferencesManager(doInBackground#1*)
* new PreferencesManager(doInBackground#1*) num objects == 1
*/
99 worker = new LoggingSwingWorker<PreferencesManager, Void>() {
100
101 /** {@inheritDoc} */
102 @Override
103 protected PreferencesManager doInBackground() throws Exception {
/*
P/P * Method: PreferencesManager doInBackground()
*
* Preconditions:
* this.mainPanel != null
* this.mainPanel.scrollPane != null
* init'ed(this.mainPanel.waitingCategory)
*
* Postconditions:
* return_value == &new PreferencesManager(doInBackground#1)
* new PreferencesManager(doInBackground#1) num objects == 1
*/
104 mainPanel.setWaiting(true);
105 return new PreferencesManager();
106 }
107
108 /** {@inheritDoc} */
109 @Override
110 protected void done() {
/*
P/P * Method: void done()
*
* Preconditions:
* (soft) this.mainPanel != null
* (soft) this.mainPanel.panels != null
* (soft) this.mainPanel.scrollPane != null
* (soft) init'ed(this.mainPanel.waitingCategory)
* (soft) this.tabList != null
*
* Presumptions:
* com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog_1:get(...)@113 != null
* init'ed(com.dmdirc.logger.ErrorLevel.MEDIUM)
*
* Postconditions:
* this.mainPanel.category == One-of{old this.mainPanel.category, null}
* this.mainPanel.worker == One-of{old this.mainPanel.worker, &new PrefsCategoryLoader(setCategory#2)}
* new JPanel(PrefsCategoryLoader#1) num objects <= 1
* new PrefsCategoryLoader(setCategory#2) num objects <= 1
* init'ed(new PrefsCategoryLoader(setCategory#2).category)
* init'ed(new PrefsCategoryLoader(setCategory#2).categoryPanel)
* init'ed(new PrefsCategoryLoader(setCategory#2).errorCategory)
* init'ed(new PrefsCategoryLoader(setCategory#2).leftPadding)
* init'ed(new PrefsCategoryLoader(setCategory#2).padding)
* init'ed(new PrefsCategoryLoader(setCategory#2).rightPadding)
*
* Test Vectors:
* com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog_1:isCancelled(...)@111: {1}, {0}
*/
111 if (!isCancelled()) {
112 try {
113 setPrefsManager(get());
114 } catch (InterruptedException ex) {
115 //Ignore
116 } catch (ExecutionException ex) {
117 Logger.appError(ErrorLevel.MEDIUM, ex.getMessage(), ex);
118 }
119 }
120 }
121 };
122 worker.execute();
123 }
124
125 private void setPrefsManager(final PreferencesManager manager) {
/*
P/P * Method: void setPrefsManager(PreferencesManager)
*
* Preconditions:
* manager != null
* this.mainPanel != null
* this.mainPanel.panels != null
* this.mainPanel.scrollPane != null
* init'ed(this.mainPanel.waitingCategory)
* this.tabList != null
*
* Presumptions:
* com.dmdirc.config.prefs.PreferencesManager:getCategories(...)@131 != null
* javax.swing.JList:getModel(...)@128 != null
*
* Postconditions:
* this.mainPanel.category == null
* this.mainPanel.waiting == 0
* this.mainPanel.worker == One-of{&new PrefsCategoryLoader(setCategory#2), old this.mainPanel.worker}
* this.manager == manager
* this.manager != null
* new JPanel(PrefsCategoryLoader#1) num objects <= 1
* new PrefsCategoryLoader(setCategory#2) num objects == new JPanel(PrefsCategoryLoader#1) num objects
* init'ed(new PrefsCategoryLoader(setCategory#2).category)
* init'ed(new PrefsCategoryLoader(setCategory#2).categoryPanel)
* init'ed(new PrefsCategoryLoader(setCategory#2).errorCategory)
* ...
*/
126 this.manager = manager;
127
128 ((DefaultListModel) tabList.getModel()).clear();
129 mainPanel.setCategory(null);
130
131 final int count = countCategories(manager.getCategories());
132 tabList.setCellRenderer(new PreferencesListCellRenderer(count));
133
134 addCategories(manager.getCategories());
135 }
136
137 /**
138 * Returns the instance of SwingPreferencesDialog.
139 *
140 * @param parentWindow Parent window
141 */
142 public static void showSwingPreferencesDialog(final Window parentWindow) {
/*
P/P * Method: void showSwingPreferencesDialog(Window)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == One-of{old me, &new SwingPreferencesDialog(getSwingPreferencesDialog#1)}
* me != null
* new CategoryPanel(initComponents#1) num objects <= 1
* new JList(initComponents#2) num objects == new CategoryPanel(initComponents#1) num objects
* new JPanel(CategoryPanel#3) num objects == new CategoryPanel(initComponents#1) num objects
* new JPanel(CategoryPanel#6) num objects == new CategoryPanel(initComponents#1) num objects
* new JPanel(CategoryPanel#9) num objects == new CategoryPanel(initComponents#1) num objects
* new JScrollPane(CategoryPanel#12) num objects == new CategoryPanel(initComponents#1) num objects
* new SwingPreferencesDialog$1(SwingPreferencesDialog#1) num objects == new CategoryPanel(initComponents#1) num objects
* new SwingPreferencesDialog(getSwingPreferencesDialog#1) num objects == new CategoryPanel(initComponents#1) num objects
* ...
*/
143 me = getSwingPreferencesDialog(parentWindow);
144
145 me.display();
146 }
147
148 /**
149 * Returns the current instance of the ErrorListDialog.
150 *
151 * @param parentWindow Parent window
152 *
153 * @return The current PluginDErrorListDialogialog instance
154 */
155 public static SwingPreferencesDialog getSwingPreferencesDialog(final Window parentWindow) {
/*
P/P * Method: SwingPreferencesDialog getSwingPreferencesDialog(Window)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == One-of{old me, &new SwingPreferencesDialog(getSwingPreferencesDialog#1)}
* me != null
* return_value == One-of{old me, &new SwingPreferencesDialog(getSwingPreferencesDialog#1)}
* return_value != null
* new CategoryPanel(initComponents#1) num objects <= 1
* init'ed(new CategoryPanel(initComponents#1).category)
* init'ed(new CategoryPanel(initComponents#1).leftPadding)
* new CategoryPanel(initComponents#1).loading == &new JPanel(CategoryPanel#3)
* new CategoryPanel(initComponents#1).nullCategory == &new JPanel(CategoryPanel#6)
* init'ed(new CategoryPanel(initComponents#1).padding)
* ...
*/
156 synchronized (SwingPreferencesDialog.class) {
157 if (me == null) {
158 me = new SwingPreferencesDialog(parentWindow);
159 }
160 }
161
162 return me;
163 }
164
165 /**
166 * Initialises GUI components.
167 */
168 private void initComponents() {
/*
P/P * Method: void initComponents()
*
* Presumptions:
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@58) in {-231..232-1}
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@61) in {-231..232-1}
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@64) in {-231..232-1}
* com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog:getCancelButton(...)@196 != null
* com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog:getOkButton(...)@195 != null
* ...
*
* Postconditions:
* this.mainPanel == &new CategoryPanel(initComponents#1)
* this.tabList == &new JList(initComponents#2)
* new CategoryPanel(initComponents#1) num objects == 1
* new JList(initComponents#2) num objects == 1
* new JPanel(CategoryPanel#3) num objects == 1
* new JPanel(CategoryPanel#6) num objects == 1
* new JPanel(CategoryPanel#9) num objects == 1
* new JScrollPane(CategoryPanel#12) num objects == 1
* new TitlePanel(CategoryPanel#13) num objects == 1
* new ToolTipPanel(CategoryPanel#14) num objects == 1
* ...
*/
169 mainPanel = new CategoryPanel(this);
170
171 tabList = new JList(new DefaultListModel());
172 tabList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
173 tabList.addListSelectionListener(this);
174 new ListScroller(tabList);
175 final JScrollPane tabListScrollPane = new JScrollPane(tabList);
176 tabListScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
177
178 setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog$2(SwingPreferencesDialog)
*/
179 addWindowListener(new WindowAdapter() {
180
181 /** {@inheritDoc} */
182 @Override
183 public void windowClosing(final WindowEvent e) {
/*
P/P * Method: void windowClosing(WindowEvent)
*
* Preconditions:
* init'ed(com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.me)
* init'ed(this.manager)
* init'ed(this.selected)
* init'ed(this.worker)
* this.mainPanel != null
* this.mainPanel.panels != null
* (soft) init'ed(this.parentWindow)
* (soft) this.tabList != null
*
* Postconditions:
* com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.me == null
* this.mainPanel.worker == One-of{&new PrefsCategoryLoader(setCategory#2), old this.mainPanel.worker}
* this.manager == One-of{old this.manager, null}
* init'ed(this.manager)
* this.worker == One-of{old this.worker, null}
* init'ed(this.worker)
* new JPanel(PrefsCategoryLoader#1) num objects <= 1
* new PrefsCategoryLoader(setCategory#2) num objects == new JPanel(PrefsCategoryLoader#1) num objects
* init'ed(new PrefsCategoryLoader(setCategory#2).category)
* init'ed(new PrefsCategoryLoader(setCategory#2).categoryPanel)
* ...
*/
184 super.windowClosing(e);
185 actionPerformed(null);
186 }
187 });
188 setTitle("Preferences");
189 setResizable(false);
190
191 tabList.setBorder(BorderFactory.createEtchedBorder());
192
193 orderButtons(new JButton(), new JButton());
194
195 getOkButton().addActionListener(this);
196 getCancelButton().addActionListener(this);
197
198 setLayout(new MigLayout("pack"));
199 add(tabListScrollPane, "w 150!, hmax 545, growy, pushy");
200 add(mainPanel, "wrap, w 480!, pushy, growy, pushy");
201 add(getLeftButton(), "span, split, right");
202 add(getRightButton(), "right");
203 }
204
205 /**
206 * Adds the categories from the preferences manager, clearing existing
207 * categories first.
208 */
209 private void addCategories(final List<PreferencesCategory> categories) {
/*
P/P * Method: void addCategories(List)
*
* Preconditions:
* this.mainPanel != null
* this.mainPanel.scrollPane != null
* init'ed(this.mainPanel.waitingCategory)
*
* Postconditions:
* this.mainPanel.waiting == 0
*/
210 UIUtilities.invokeLater(new Runnable() {
211
212 @Override
213 public void run() {
/*
P/P * Method: void run()
*
* Preconditions:
* this.tabList != null
* this.val$categories != null
* (soft) this.mainPanel != null
* (soft) this.mainPanel.scrollPane != null
* (soft) init'ed(this.mainPanel.waitingCategory)
*
* Presumptions:
* java.util.Iterator:next(...)@215 != null
* javax.swing.JList:getModel(...)@217 != null
*
* Test Vectors:
* com.dmdirc.config.prefs.PreferencesCategory:isInline(...)@216: {1}, {0}
* java.util.Iterator:hasNext(...)@215: {0}, {1}
*/
214 tabList.removeListSelectionListener(SwingPreferencesDialog.this);
215 for (PreferencesCategory category : categories) {
216 if (!category.isInline()) {
217 ((DefaultListModel) tabList.getModel()).addElement(
218 category);
219 }
220 addCategories(category.getSubcats());
221 }
222 tabList.addListSelectionListener(SwingPreferencesDialog.this);
223 restoreActiveCategory();
224 }
225 });
226 mainPanel.setWaiting(false);
227 }
228
229 /**
230 * Counts the number of categories that will be displayed in the list panel.
231 *
232 * @param categories The collection of categories to inspect
233 * @return The number of those categories (including children) that will be displayed
234 * @since 0.6.3m1rc3
235 */
236 protected int countCategories(final Collection<PreferencesCategory> categories) {
/*
P/P * Method: int countCategories(Collection)
*
* Preconditions:
* categories != null
*
* Presumptions:
* com.dmdirc.config.prefs.PreferencesCategory:getSubcats(...)@241 != null
* java.util.Iterator:next(...)@239 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* com.dmdirc.config.prefs.PreferencesCategory:isInline(...)@240: {1}, {0}
* java.util.Iterator:hasNext(...)@239: {0}, {1}
*/
237 int count = 0;
238
239 for (PreferencesCategory cat : categories) {
240 if (!cat.isInline()) {
241 count += 1 + countCategories(cat.getSubcats());
242 }
243 }
244
245 return count;
246 }
247
248 /**
249 * Handles the actions for the dialog.
250 *
251 * @param actionEvent Action event
252 */
253 @Override
254 public void actionPerformed(final ActionEvent actionEvent) {
/*
P/P * Method: void actionPerformed(ActionEvent)
*
* Preconditions:
* init'ed(me)
* init'ed(this.manager)
* init'ed(this.selected)
* init'ed(this.worker)
* this.mainPanel != null
* this.mainPanel.panels != null
* (soft) init'ed(this.parentWindow)
* (soft) this.tabList != null
*
* Presumptions:
* com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog:getOkButton(...)@261 != null
* com.dmdirc.config.IdentityManager:getConfigIdentity(...)@264 != null
* javax.swing.JList:getSelectedValue(...)@263 != null
*
* Postconditions:
* me == null
* this.mainPanel.category == null
* this.mainPanel.worker == One-of{&new PrefsCategoryLoader(setCategory#2), old this.mainPanel.worker}
* this.manager == One-of{old this.manager, null}
* init'ed(this.manager)
* this.selected == null
* this.worker == One-of{old this.worker, null}
* init'ed(this.worker)
* new JPanel(PrefsCategoryLoader#1) num objects <= 1
* new PrefsCategoryLoader(setCategory#2) num objects == new JPanel(PrefsCategoryLoader#1) num objects
* ...
*
* Test Vectors:
* actionEvent: Addr_Set{null}, Inverse{null}
* this.manager: Addr_Set{null}, Inverse{null}
* this.selected: Addr_Set{null}, Inverse{null}
* java.lang.Object:equals(...)@261: {0}, {1}
* javax.swing.JList:getSelectedIndex(...)@262: {-231..-1}, {0..232-1}
*/
255 if (selected != null) {
256 selected.fireCategoryDeselected();
257 selected = null;
258 }
259 mainPanel.setCategory(null);
260
261 if (actionEvent != null && getOkButton().equals(actionEvent.getSource())) {
262 if (tabList.getSelectedIndex() > -1) {
263 final PreferencesCategory node = (PreferencesCategory) tabList.getSelectedValue();
264 IdentityManager.getConfigIdentity().setOption("dialogstate",
265 "preferences", node.getPath());
266 }
267 saveOptions();
268 }
269
270 if (manager != null) {
271 manager.dismiss();
272 }
273 dispose();
274 }
275
276 /**
277 * {@inheritDoc}
278 *
279 * @since 0.6.3m1
280 */
281 @Override
282 public void valueChanged(final ListSelectionEvent e) {
/*
P/P * Method: void valueChanged(ListSelectionEvent)
*
* Preconditions:
* e != null
* (soft) init'ed(this.selected)
* (soft) this.mainPanel != null
* (soft) this.mainPanel.panels != null
* (soft) this.tabList != null
*
* Postconditions:
* possibly_updated(this.mainPanel.category)
* this.mainPanel.worker == One-of{old this.mainPanel.worker, &new PrefsCategoryLoader(setCategory#2)}
* init'ed(this.selected)
* new JPanel(PrefsCategoryLoader#1) num objects <= 1
* new PrefsCategoryLoader(setCategory#2) num objects <= 1
* init'ed(new PrefsCategoryLoader(setCategory#2).category)
* init'ed(new PrefsCategoryLoader(setCategory#2).categoryPanel)
* init'ed(new PrefsCategoryLoader(setCategory#2).errorCategory)
* init'ed(new PrefsCategoryLoader(setCategory#2).leftPadding)
* init'ed(new PrefsCategoryLoader(setCategory#2).padding)
* ...
*
* Test Vectors:
* this.selected: Addr_Set{null}, Inverse{null}
* javax.swing.event.ListSelectionEvent:getValueIsAdjusting(...)@283: {1}, {0}
*/
283 if (!e.getValueIsAdjusting()) {
284 PreferencesCategory node = null;
285 try {
286 node = (PreferencesCategory) tabList.getSelectedValue();
287 } catch (ArrayIndexOutOfBoundsException ex) {
288 //I hate the JVM
289 }
290 if (node == null) {
291 tabList.setSelectedValue(selected, true);
292 return;
293 }
294
295 if (selected != null) {
296 selected.fireCategoryDeselected();
297 }
298 selected = node;
299 if (selected != null) {
300 selected.fireCategorySelected();
301 }
302 mainPanel.setCategory(selected);
303 }
304 }
305
306 /**
307 * Returns the selected category.
308 *
309 * @return Selected category
310 */
311 protected PreferencesCategory getSelectedCategory() {
/*
P/P * Method: PreferencesCategory getSelectedCategory()
*
* Preconditions:
* init'ed(this.selected)
*
* Postconditions:
* return_value == this.selected
* init'ed(return_value)
*/
312 return selected;
313 }
314
315 /** {@inheritDoc} */
316 public void saveOptions() {
/*
P/P * Method: void saveOptions()
*
* Preconditions:
* init'ed(this.manager)
* (soft) init'ed(this.parentWindow)
*
* Test Vectors:
* this.manager: Addr_Set{null}, Inverse{null}
* com.dmdirc.config.prefs.PreferencesManager:save(...)@318: {0}, {1}
*/
317 if (manager != null) {
318 if (manager.save()) {
319 JOptionPane.showMessageDialog(parentWindow,
320 "One or more of the changes you made " +
321 "won't take effect until you restart the client.",
322 "Restart needed",
323 JOptionPane.INFORMATION_MESSAGE);
324 }
325 }
326 }
327
328 private void restoreActiveCategory() {
/*
P/P * Method: void restoreActiveCategory()
*
* Preconditions:
* this.tabList != null
*
* Presumptions:
* com.dmdirc.config.ConfigManager:getOption(...)@329 != null
* com.dmdirc.config.IdentityManager:getGlobalConfig(...)@329 != null
* javax.swing.DefaultListModel:get(...)@334 != null
* javax.swing.JList:getModel(...)@331 != null
*
* Test Vectors:
* java.lang.String:equals(...)@336: {0}, {1}
*/
329 final String oldCategoryPath = IdentityManager.getGlobalConfig().
330 getOption("dialogstate", "preferences");
331 final DefaultListModel model = (DefaultListModel) tabList.getModel();
332 int indexToSelect = 0;
333 for (int i = 0; i < model.getSize(); i++) {
334 final PreferencesCategory category =
335 (PreferencesCategory) model.get(i);
336 if (oldCategoryPath.equals(category.getPath())) {
337 indexToSelect = i;
338 break;
339 }
340 }
341 tabList.setSelectedIndex(indexToSelect);
342 }
343
344 /** {@inheritDoc} */
345 @Override
346 public void display() {
/*
P/P * Method: void display()
*/
347 pack();
348 setLocationRelativeTo(getParent());
349 setVisible(true);
350 }
351
352 /** {@inheritDoc} */
353 @Override
354 public void dispose() {
/*
P/P * Method: void dispose()
*
* Preconditions:
* init'ed(me)
* init'ed(this.manager)
* init'ed(this.worker)
*
* Postconditions:
* me == null
* this.manager == One-of{old this.manager, null}
* init'ed(this.manager)
* this.worker == One-of{old this.worker, null}
* init'ed(this.worker)
*
* Test Vectors:
* me: Inverse{null}, Addr_Set{null}
* this.manager: Addr_Set{null}, Inverse{null}
* this.worker: Addr_Set{null}, Inverse{null}
* com.dmdirc.addons.ui_swing.components.LoggingSwingWorker:isDone(...)@356: {1}, {0}
*/
355 synchronized (SwingPreferencesDialog.this) {
356 if (worker != null && !worker.isDone()) {
357 worker.cancel(true);
358 }
359 if (manager != null) {
360 manager.close();
361 }
362 if (me == null) {
363 return;
364 }
365 super.dispose();
366 me = null;
367 worker = null;
368 manager = null;
369 }
370 }
371 }
SofCheck Inspector Build Version : 2.17854
| SwingPreferencesDialog.java |
2009-Jun-25 01:54:24 |
| SwingPreferencesDialog.class |
2009-Sep-02 17:04:16 |
| SwingPreferencesDialog$1.class |
2009-Sep-02 17:04:16 |
| SwingPreferencesDialog$2.class |
2009-Sep-02 17:04:16 |
| SwingPreferencesDialog$3.class |
2009-Sep-02 17:04:16 |