File Source: AliasManagerDialog.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog__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.aliases;
24
25 import com.dmdirc.addons.ui_swing.components.renderers.ArrayCellRenderer;
26 import com.dmdirc.addons.ui_swing.components.renderers.ActionConditionCellRenderer;
27 import com.dmdirc.actions.wrappers.Alias;
28 import com.dmdirc.actions.Action;
29 import com.dmdirc.actions.ActionCondition;
30 import com.dmdirc.actions.ActionManager;
31 import com.dmdirc.actions.CoreActionComparison;
32 import com.dmdirc.actions.wrappers.AliasWrapper;
33 import com.dmdirc.addons.ui_swing.components.PackingTable;
34 import com.dmdirc.addons.ui_swing.components.StandardDialog;
35
36 import java.awt.Dimension;
37 import java.awt.Window;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42 import java.util.List;
43
44 import javax.swing.JButton;
45 import javax.swing.JOptionPane;
46 import javax.swing.JScrollPane;
47 import javax.swing.JSplitPane;
48 import javax.swing.JTable;
49 import javax.swing.ListSelectionModel;
50 import javax.swing.event.ListSelectionEvent;
51 import javax.swing.event.ListSelectionListener;
52 import javax.swing.table.TableCellRenderer;
53
54 import net.miginfocom.layout.PlatformDefaults;
55 import net.miginfocom.swing.MigLayout;
56
57 /**
58 * Alias manager dialog.
59 */
60 public final class AliasManagerDialog extends StandardDialog implements
61 ActionListener, ListSelectionListener {
62
63 /**
64 * A version number for this class. It should be changed whenever the class
65 * structure is changed (or anything else that would prevent serialized
66 * objects being unserialized with the new class).
67 */
68 private static final long serialVersionUID = 3;
69 /** Previously instantiated instance of AliasManagerDialog. */
70 private static volatile AliasManagerDialog me;
71 /** Table scrollpane. */
72 private JScrollPane scrollPane;
73 /** Error table. */
74 private JTable table;
75 /** Table model. */
76 private AliasTableModel tableModel;
77 /** Error detail panel. */
78 private AliasPanel aliasDetails;
79 /** Add/edit button. */
80 private JButton addButton;
81 /** Delete button. */
82 private JButton deleteButton;
83 /** Selected row. */
84 private int selectedRow;
85 /** Substitutions panel. */
86 private AliasSubstitutionsPanel subsPanel;
87 /** Show/Hide subsitution button. */
88 private JButton showSubs;
89
90 /**
91 * Creates a new instance of ErrorListDialog.
92 *
93 * @param parentWindow Parent window
94 */
95 private AliasManagerDialog(final Window parentWindow) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog(Window)
*
* Presumptions:
* init'ed(java.awt.Dialog$ModalityType.MODELESS)
*
* Postconditions:
* this.addButton == &new JButton(initComponents#5)
* this.aliasDetails == &new AliasPanel(initComponents#10)
* this.deleteButton == &new JButton(initComponents#6)
* this.scrollPane == &new JScrollPane(initComponents#7)
* init'ed(this.selectedRow)
* this.showSubs == &new JButton(initComponents#12)
* this.subsPanel == &new AliasSubstitutionsPanel(initComponents#11)
* this.table == &new AliasManagerDialog$1(initComponents#9)
* this.tableModel == &new AliasTableModel(initComponents#8)
* new ActionConditionCellRenderer(initComponents#2) num objects == 1
* ...
*/
96 super(parentWindow, ModalityType.MODELESS);
97
98 setTitle("DMDirc: Alias manager");
99
100 selectedRow = -1;
101
102 initComponents();
103 layoutComponents();
104 initListeners();
105 }
106
107 /**
108 * Creates the dialog if one doesn't exist, and displays it.
109 *
110 * @param parentWindow Parent window
111 */
112 public static void showAliasManagerDialog(final Window parentWindow) {
/*
P/P * Method: void showAliasManagerDialog(Window)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == One-of{old me, &new AliasManagerDialog(getAliasManagerDialog#1)}
* me != null
* new AliasManagerDialog(getAliasManagerDialog#1) num objects <= 1
*/
113 me = getAliasManagerDialog(parentWindow);
114
115 me.setLocationRelativeTo(parentWindow);
116 me.setVisible(true);
117 me.requestFocusInWindow();
118 }
119
120 /**
121 * Returns the instance of AliasManagerDialog.
122 *
123 * @param parentWindow Parent window
124 *
125 * @return Instance of AliasManagerDialog
126 */
127 public static AliasManagerDialog getAliasManagerDialog(final Window parentWindow) {
/*
P/P * Method: AliasManagerDialog getAliasManagerDialog(Window)
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == One-of{old me, &new AliasManagerDialog(getAliasManagerDialog#1)}
* me != null
* return_value == One-of{old me, &new AliasManagerDialog(getAliasManagerDialog#1)}
* return_value != null
* new AliasManagerDialog(getAliasManagerDialog#1) num objects <= 1
*/
128 synchronized (AliasManagerDialog.class) {
129 if (me == null) {
130 me = new AliasManagerDialog(parentWindow);
131 }
132 }
133
134 return me;
135 }
136
137 /** Initialises the components. */
138 private void initComponents() {
/*
P/P * Method: void initComponents()
*
* Presumptions:
* javax.swing.JTable:getRowSorter(...)@178 != null
* javax.swing.JTable:getTableHeader(...)@180 != null
*
* Postconditions:
* this.addButton == &new JButton(initComponents#5)
* this.aliasDetails == &new AliasPanel(initComponents#10)
* this.deleteButton == &new JButton(initComponents#6)
* this.scrollPane == &new JScrollPane(initComponents#7)
* this.showSubs == &new JButton(initComponents#12)
* this.subsPanel == &new AliasSubstitutionsPanel(initComponents#11)
* this.table == &new AliasManagerDialog$1(initComponents#9)
* this.tableModel == &new AliasTableModel(initComponents#8)
* new ActionConditionCellRenderer(initComponents#2) num objects == 1
* new AliasManagerDialog$1(initComponents#9) num objects == 1
* ...
*/
139 final TableCellRenderer arrayRenderer = new ArrayCellRenderer();
140 final TableCellRenderer conditionRenderer =
141 new ActionConditionCellRenderer();
142
143 orderButtons(new JButton(), new JButton());
144 addButton = new JButton("Add");
145 deleteButton = new JButton("Delete");
146
147 deleteButton.setEnabled(false);
148
149 scrollPane = new JScrollPane();
150
151 tableModel = new AliasTableModel(getTableData());
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog$1(AliasManagerDialog, TableModel, bool, JScrollPane, bool, TableCellRenderer, TableCellRenderer)
*
* Postconditions:
* this.val$arrayRenderer == Param_7
* init'ed(this.val$arrayRenderer)
* this.val$conditionRenderer == Param_6
* init'ed(this.val$conditionRenderer)
*/
152 table = new PackingTable(tableModel, false, scrollPane, false) {
153
154 private static final long serialVersionUID = 1;
155
156 @Override
157 public TableCellRenderer getCellRenderer(final int row,
158 final int column) {
/*
P/P * Method: TableCellRenderer getCellRenderer(int, int)
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* column: {1}, {2}, {-231..0, 3..232-1}
*/
159 switch (column) {
160 case 1:
161 return conditionRenderer;
162 case 2:
163 return arrayRenderer;
164 default:
165 return super.getCellRenderer(row, column);
166 }
167 }
168 };
169
170 table.setAutoCreateRowSorter(true);
171 table.setAutoCreateColumnsFromModel(true);
172 table.setColumnSelectionAllowed(false);
173 table.setCellSelectionEnabled(false);
174 table.setDragEnabled(false);
175 table.setFillsViewportHeight(false);
176 table.setRowSelectionAllowed(true);
177 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
178 table.getRowSorter().toggleSortOrder(0);
179
180 table.getTableHeader().setReorderingAllowed(false);
181
182 scrollPane.setViewportView(table);
183
184 aliasDetails = new AliasPanel();
185 subsPanel = new AliasSubstitutionsPanel();
186 subsPanel.setVisible(false);
187 showSubs = new JButton("Show Substitutions");
188 }
189
190 /**
191 * Updates the table data.
192 */
193 public void updateTableData() {
/*
P/P * Method: void updateTableData()
*
* Preconditions:
* this.tableModel != null
*
* Postconditions:
* this.tableModel.aliases == &new ArrayList(setAliases#1)
* new ArrayList(setAliases#1) num objects == 1
*/
194 tableModel.setAliases(getTableData());
195 }
196
197 /**
198 * Gets the table data fromt he alias wrapper.
199 *
200 * @return Alias list
201 */
202 private List<Alias> getTableData() {
/*
P/P * Method: List getTableData()
*
* Presumptions:
* com.dmdirc.actions.Action:getConditions(...)@206 != null
* init'ed(com.dmdirc.actions.CoreActionComparison.STRING_EQUALS)
* com.dmdirc.actions.wrappers.AliasWrapper:getAliasWrapper(...)@205 != null
* com.dmdirc.actions.wrappers.AliasWrapper:iterator(...)@205 != null
* java.util.Iterator:next(...)@205 != null
* ...
*
* Postconditions:
* return_value == &new ArrayList(getTableData#1)
* new ArrayList(getTableData#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@205: {0}, {1}
*/
203 final List<Alias> aliases = new ArrayList<Alias>();
204
205 for (Action loopAction : AliasWrapper.getAliasWrapper()) {
206 final List<ActionCondition> arguments = loopAction.getConditions();
207
208 ActionCondition argument;
209
210 argument = arguments.get(0);
211
212 if (argument.getComparison() != CoreActionComparison.STRING_EQUALS) {
213 argument = arguments.get(1);
214 }
215
216 aliases.add(new Alias(argument.getTarget(),
217 arguments, loopAction.getResponse()));
218 }
219
220 return aliases;
221 }
222
223 /** Initialises the listeners. */
224 private void initListeners() {
/*
P/P * Method: void initListeners()
*
* Preconditions:
* this.addButton != null
* this.deleteButton != null
* this.showSubs != null
* this.table != null
*
* Presumptions:
* com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog:getCancelButton(...)@227 != null
* com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog:getOkButton(...)@226 != null
* javax.swing.JTable:getSelectionModel(...)@225 != null
*/
225 table.getSelectionModel().addListSelectionListener(this);
226 getOkButton().addActionListener(this);
227 getCancelButton().addActionListener(this);
228 addButton.addActionListener(this);
229 deleteButton.addActionListener(this);
230 showSubs.addActionListener(this);
231 }
232
233 /** Lays out the components. */
234 private void layoutComponents() {
/*
P/P * Method: void layoutComponents()
*
* Preconditions:
* init'ed(this.addButton)
* init'ed(this.aliasDetails)
* init'ed(this.deleteButton)
* this.scrollPane != null
* init'ed(this.showSubs)
* init'ed(this.subsPanel)
* this.table != null
*
* Presumptions:
* (int) (net.miginfocom.layout.UnitValue:getValue(...)@241) in {-231..232-1}
* net.miginfocom.layout.PlatformDefaults:getPanelInsets(...)@241 != null
*/
235 setLayout(new MigLayout("fill, hidemode 3, pack"));
236 setMinimumSize(new Dimension(800, 400));
237 table.setPreferredScrollableViewportSize(new Dimension(800, 150));
238 scrollPane.setMinimumSize(new Dimension(750, 150));
239 final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
240 true, scrollPane, aliasDetails);
241 splitPane.setDividerSize((int) PlatformDefaults.getPanelInsets(0).
242 getValue());
243
244 add(splitPane, "spanx 5, grow, push, wrap");
245 add(subsPanel, "spanx 5, grow, pushy, wrap");
246 add(showSubs, "split 3, sgx button");
247 add(addButton, "sgx button, gap unrel");
248 add(deleteButton, "sgx button");
249 add(getLeftButton(), "sgx button, gap unrel");
250 add(getRightButton(), "sgx button");
251 }
252
253 /** {@inheritDoc}. */
254 @Override
255 public void valueChanged(final ListSelectionEvent e) {
/*
P/P * Method: void valueChanged(ListSelectionEvent)
*
* Preconditions:
* e != null
* (soft) init'ed(com.dmdirc.addons.ui_swing.dialogs.aliases.AliasPanel$1__static_init.new int[](AliasPanel$1__static_init#1)[...])
* (soft) init'ed(this.aliasDetails.alias)
* (soft) init'ed(this.selectedRow)
* (soft) this.aliasDetails != null
* (soft) this.aliasDetails.argumentComponent != null
* (soft) this.aliasDetails.argumentNumber != null
* (soft) this.aliasDetails.command != null
* (soft) this.aliasDetails.command.errorIcon != null
* (soft) this.aliasDetails.command.textField != null
* ...
*
* Presumptions:
* com.dmdirc.actions.CoreActionComparison:values(...).length >= 1
* javax.swing.JTable:getRowSorter(...)@258 != null
* javax.swing.JTable:getRowSorter(...)@264 != null
*
* Postconditions:
* init'ed(this.aliasDetails.alias)
* init'ed(this.selectedRow)
*
* Test Vectors:
* this.selectedRow: {-231..-1}, {0..232-2}
* javax.swing.JTable:getSelectedRow(...)@263: {-231..-1}, {0..232-1}
* javax.swing.event.ListSelectionEvent:getValueIsAdjusting(...)@256: {1}, {0}
*/
256 if (!e.getValueIsAdjusting()) {
257
258 if (selectedRow > -1 && selectedRow < tableModel.getRowCount() && aliasDetails.getAlias() == tableModel.getAlias(
259 table.getRowSorter().convertRowIndexToModel(selectedRow))) {
260 updateAlias();
261 }
262
263 if (table.getSelectedRow() > -1) {
264 aliasDetails.setAlias(tableModel.getAlias(table.getRowSorter().
265 convertRowIndexToModel(table.getSelectedRow())));
266 deleteButton.setEnabled(true);
267 } else {
268 aliasDetails.clear();
269 deleteButton.setEnabled(false);
270 }
271
272 selectedRow = table.getSelectedRow();
273 }
274 }
275
276 /** Updates the selected alias with the edited details. */
277 private void updateAlias() {
/*
P/P * Method: void updateAlias()
*
* Preconditions:
* this.aliasDetails != null
* this.aliasDetails.argumentComponent != null
* this.aliasDetails.command != null
* this.aliasDetails.command.textField != null
* this.aliasDetails.response != null
* init'ed(this.selectedRow)
* this.table != null
* this.tableModel != null
* this.tableModel.aliases != null
* (soft) init'ed(com.dmdirc.addons.ui_swing.dialogs.aliases.AliasPanel$1__static_init.new int[](AliasPanel$1__static_init#1)[...])
* ...
*
* Presumptions:
* com.dmdirc.actions.CoreActionComparison:values(...).length >= 1
* java.util.List:get(...)@175 != null
* javax.swing.JTable:getRowSorter(...)@278 != null
*/
278 final Alias alias = tableModel.getAlias(table.getRowSorter().
279 convertRowIndexToModel(selectedRow));
280
281 alias.update(aliasDetails.getNewAlias());
282
283 tableModel.fireTableRowsUpdated(tableModel.indexOf(alias),
284 tableModel.indexOf(alias));
285 }
286
287 /**
288 * {@inheritDoc}
289 *
290 * @param e Action event
291 */
292 @Override
293 public void actionPerformed(final ActionEvent e) {
/*
P/P * Method: void actionPerformed(ActionEvent)
*
* Preconditions:
* e != null
* init'ed(this.deleteButton)
* (soft) init'ed(com.dmdirc.addons.ui_swing.dialogs.aliases.AliasPanel$1__static_init.new int[](AliasPanel$1__static_init#1)[...])
* (soft) init'ed(me)
* (soft) init'ed(this.addButton)
* (soft) this.aliasDetails != null
* (soft) this.aliasDetails.argumentComponent != null
* (soft) this.aliasDetails.argumentNumber != null
* (soft) this.aliasDetails.command != null
* (soft) this.aliasDetails.command.textField != null
* ...
*
* Presumptions:
* com.dmdirc.actions.CoreActionComparison:values(...).length >= 1
*
* Postconditions:
* me == One-of{old me, null}
* init'ed(me)
*
* Test Vectors:
* com.dmdirc.addons.ui_swing.dialogs.aliases.AliasSubstitutionsPanel:isVisible(...)@314: {0}, {1}
* javax.swing.JTable:getSelectedRow(...)@301: {-1}, {-231..-2, 0..232-1}
*/
294 if (e.getSource() == deleteButton) {
295 delete();
296 } else if (e.getSource() == addButton) {
297 add();
298 } else if (e.getSource() == getCancelButton()) {
299 dispose();
300 } else if (e.getSource() == getOkButton()) {
301 if (table.getSelectedRow() != -1) {
302 updateAlias();
303 }
304 if (checkForDuplicates()) {
305 JOptionPane.showMessageDialog(this,
306 "There are duplicate aliases in the table, these need " +
307 "to be removed before saving", "Duplicates",
308 JOptionPane.WARNING_MESSAGE);
309 return;
310 }
311 save();
312 dispose();
313 } else if (e.getSource() == showSubs) {
314 if (subsPanel.isVisible()) {
315 subsPanel.setVisible(false);
316 showSubs.setText("Show Substitutions");
317 } else {
318 subsPanel.setVisible(true);
319 showSubs.setText("Hide Substitutions");
320 }
321 }
322 }
323
324 /** Adds an alias. */
325 private void add() {
/*
P/P * Method: void add()
*
* Preconditions:
* this.aliasDetails != null
* this.aliasDetails.command != null
* this.aliasDetails.command.textField != null
* this.table != null
* this.tableModel != null
* this.tableModel.aliases != null
*
* Presumptions:
* javax.swing.JTable:getRowSorter(...)@328 != null
* javax.swing.JTable:getSelectionModel(...)@330 != null
*/
326 final Alias alias = new Alias("");
327 tableModel.addRow(alias);
328 final int newRow = table.getRowSorter().
329 convertRowIndexToView(tableModel.indexOf(alias));
330 table.getSelectionModel().setSelectionInterval(newRow, newRow);
331 aliasDetails.focusCommand();
332 }
333
334 /** Deletes an alias. */
335 private void delete() {
/*
P/P * Method: void delete()
*
* Preconditions:
* this.table != null
* (soft) this.tableModel != null
* (soft) this.tableModel.aliases != null
*
* Presumptions:
* javax.swing.JTable:getRowSorter(...)@337 != null
*
* Test Vectors:
* javax.swing.JTable:getSelectedRow(...)@336: {-1}, {-231..-2, 0..232-1}
*/
336 if (table.getSelectedRow() != -1) {
337 tableModel.removeRow(table.getRowSorter().
338 convertRowIndexToModel(table.getSelectedRow()));
339 }
340 }
341
342 /** Saves the aliases. */
343 private void save() {
/*
P/P * Method: void save()
*
* Preconditions:
* this.tableModel != null
* init'ed(this.tableModel.aliases)
*
* Presumptions:
* com.dmdirc.actions.Action:getConditions(...)@357 != null
* com.dmdirc.actions.Action:getName(...)@357 != null
* com.dmdirc.actions.wrappers.AliasWrapper:getActions(...)@344 != null
* com.dmdirc.actions.wrappers.AliasWrapper:getAliasWrapper(...)@344 != null
* java.util.Iterator:next(...)@351 != null
* ...
*
* Test Vectors:
* java.lang.Object:equals(...)@357: {0}, {1}
* java.lang.String:equals(...)@357: {0}, {1}
* java.util.Arrays:equals(...)@357: {1}, {0}
* java.util.Iterator:hasNext(...)@351: {0}, {1}
* java.util.Iterator:hasNext(...)@366: {0}, {1}
*/
344 final List<Action> actions =
345 AliasWrapper.getAliasWrapper().getActions();
346 final List<Alias> aliases = tableModel.getAliases();
347
348 final List<Alias> newAliases = new ArrayList<Alias>();
349 final List<Alias> modifiedAliases = new ArrayList<Alias>();
350
351 for (Alias alias : aliases) {
352 final Action action = getAction(alias);
353
354 if (action == null) {
355 newAliases.add(alias);
356 } else {
357 if (!action.getName().equals(alias.getName()) || !action.getConditions().
358 equals(alias.getArguments()) ||
359 !Arrays.equals(action.getResponse(), alias.getResponse())) {
360 modifiedAliases.add(alias);
361 }
362 actions.remove(action);
363 }
364 }
365
366 for (Action action : actions) {
367 action.delete();
368 }
369
370 saveNewAliases(newAliases);
371
372 saveModifiedAliases(modifiedAliases);
373
374 ActionManager.loadActions();
375 }
376
377 /**
378 * Saves new aliases.
379 *
380 * @param aliases List of new aliases to save
381 */
382 private void saveNewAliases(final List<Alias> aliases) {
/*
P/P * Method: void saveNewAliases(List)
*
* Preconditions:
* aliases != null
*
* Presumptions:
* com.dmdirc.actions.wrappers.Alias:createAction(...)@384 != null
* java.util.Iterator:next(...)@383 != null
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@383: {0}, {1}
*/
383 for (Alias alias : aliases) {
384 alias.createAction().save();
385 }
386 }
387
388 /**
389 * Saves modified aliases.
390 *
391 * @param aliases List of modified aliases to save
392 */
393 private void saveModifiedAliases(final List<Alias> aliases) {
/*
P/P * Method: void saveModifiedAliases(List)
*
* Preconditions:
* aliases != null
*
* Presumptions:
* java.util.Iterator:next(...)@394 != null
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@394: {0}, {1}
*/
394 for (Alias alias : aliases) {
395 final Action action = getAction(alias);
396 if (action != null) {
397 action.setName(alias.getName());
398 action.setConditions(alias.getArguments());
399 action.setResponse(alias.getResponse());
400 action.save();
401 }
402 }
403 }
404
405 /**
406 * Returns the action corresponding to the specified alias.
407 *
408 * @param alias Alias to check
409 *
410 * @return Corresponding action or null if none found
411 */
412 private Action getAction(final Alias alias) {
/*
P/P * Method: Action getAction(Alias)
*
* Preconditions:
* (soft) alias != null
*
* Presumptions:
* com.dmdirc.actions.Action:getConditions(...)@418 != null
* com.dmdirc.actions.Action:getName(...)@418 != null
* com.dmdirc.actions.wrappers.AliasWrapper:getActions(...)@413 != null
* com.dmdirc.actions.wrappers.AliasWrapper:getAliasWrapper(...)@413 != null
* java.util.Iterator:next(...)@417 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* java.lang.Object:equals(...)@418: {0}, {1}
* java.lang.String:equals(...)@418: {0}, {1}
* java.util.Iterator:hasNext(...)@417: {0}, {1}
*/
413 final List<Action> actions =
414 AliasWrapper.getAliasWrapper().getActions();
415 Action action = null;
416
417 for (Action loopAction : actions) {
418 if (loopAction.getName().equals(alias.getName()) && loopAction.getConditions().
419 equals(alias.getArguments())) {
420 action = loopAction;
421 break;
422 }
423 }
424
425 return action;
426 }
427
428 /**
429 * Checks if ths alias matches another alias.
430 *
431 * @return true iif there are duplicate matches
432 */
433 private boolean checkForDuplicates() {
/*
P/P * Method: bool checkForDuplicates()
*
* Preconditions:
* this.tableModel != null
* init'ed(this.tableModel.aliases)
*
* Presumptions:
* java.util.Iterator:next(...)@439 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* com.dmdirc.actions.wrappers.Alias:matches(...)@440: {0}, {1}
* java.util.Iterator:hasNext(...)@436: {0}, {1}
* java.util.Iterator:hasNext(...)@439: {0}, {1}
*/
434 final List<Alias> aliases = tableModel.getAliases();
435
436 for (Alias alias : aliases) {
437 int matches = 0;
438
439 for (Alias loopAlias : aliases) {
440 if (loopAlias.matches(alias)) {
441 matches++;
442 }
443 }
444
445 if (matches > 1) {
446 return true;
447 }
448 }
449
450 return false;
451 }
452
453 /** {@inheritDoc} */
454 @Override
455 public void dispose() {
/*
P/P * Method: void dispose()
*
* Preconditions:
* init'ed(me)
*
* Postconditions:
* me == null
*
* Test Vectors:
* me: Inverse{null}, Addr_Set{null}
*/
456 if (me == null) {
457 return;
458 }
459 synchronized (me) {
460 super.dispose();
461 me = null;
462 }
463 }
464 }
SofCheck Inspector Build Version : 2.17854
| AliasManagerDialog.java |
2009-Jun-25 01:54:24 |
| AliasManagerDialog.class |
2009-Sep-02 17:04:16 |
| AliasManagerDialog$1.class |
2009-Sep-02 17:04:16 |