File Source: AliasSubstitutionsPanel.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.aliases.AliasSubstitutionsPanel__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.actions.ActionSubstitutor;
26 import com.dmdirc.actions.CoreActionType;
27 import com.dmdirc.actions.interfaces.ActionType;
28 import com.dmdirc.addons.ui_swing.components.substitutions.Substitution;
29 import com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionLabel;
30 import com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionsPanel;
31
32 import java.util.ArrayList;
33 import java.util.Map.Entry;
34
35 import javax.swing.SwingUtilities;
36
37
38 /**
39 * Lists substitutions for aliases.
40 */
/*
P/P * Method: void access$700(AliasSubstitutionsPanel)
*
* Preconditions:
* x0 != null
* x0.alignment != null
* init'ed(x0.description)
* x0.substitutions != null
*/
41 public class AliasSubstitutionsPanel extends SubstitutionsPanel<ActionType> {
42
43 /**
44 * A version number for this class. It should be changed whenever the class
45 * structure is changed (or anything else that would prevent serialized
46 * objects being unserialized with the new class).
47 */
48 private static final long serialVersionUID = 1;
49
50 /** Instantiates the panel. */
51 public AliasSubstitutionsPanel() {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.aliases.AliasSubstitutionsPanel()
*
* Presumptions:
* init'ed(com.dmdirc.actions.CoreActionType.UNKNOWN_COMMAND)
*
* Postconditions:
* this.alignment == &com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionsPanel$Alignment__static_init.new SubstitutionsPanel$Alignment(SubstitutionsPanel$Alignment__static_init#2)
* this.description == &"Substitutions may be used in the response field"
*/
52 super("Substitutions may be used in the response field",
53 SubstitutionsPanel.Alignment.VERTICAL,
54 CoreActionType.UNKNOWN_COMMAND);
55 }
56
57 /**
58 * Sets the action type for this substitution panel.
59 *
60 * @param type New action type
61 */
62 @Override
63 public void setType(final ActionType type) {
/*
P/P * Method: void setType(ActionType)
*/
64 SwingUtilities.invokeLater(new Runnable() {
65
66 /** {@inheritDoc} */
67 @Override
68 public void run() {
/*
P/P * Method: void run()
*
* Preconditions:
* this.alignment != null
* init'ed(this.description)
*
* Presumptions:
* com.dmdirc.actions.ActionSubstitutor:getComponentSubstitutions(...)@74 != null
* com.dmdirc.actions.ActionSubstitutor:getConfigSubstitutions(...)@80 != null
* com.dmdirc.actions.ActionSubstitutor:getServerSubstitutions(...)@85 != null
* java.util.Iterator:next(...)@74 != null
* java.util.Iterator:next(...)@85 != null
* ...
*
* Postconditions:
* new ArrayList(run#1) num objects == 1
*
* Test Vectors:
* this.val$type: Addr_Set{null}, Inverse{null}
* java.util.Iterator:hasNext(...)@74: {0}, {1}
* java.util.Iterator:hasNext(...)@80: {0}, {1}
* java.util.Iterator:hasNext(...)@85: {0}, {1}
*/
69 substitutions = new ArrayList<SubstitutionLabel>();
70
71 if (type != null) {
72 final ActionSubstitutor sub = new ActionSubstitutor(type);
73
74 for (final Entry<String, String> entry : sub.getComponentSubstitutions().
75 entrySet()) {
76 substitutions.add(new SubstitutionLabel(new Substitution(entry.getValue(),
77 entry.getKey())));
78 }
79
80 for (final String entry : sub.getConfigSubstitutions()) {
81 substitutions.add(new SubstitutionLabel(new Substitution(entry,
82 entry)));
83 }
84
85 for (final Entry<String, String> entry : sub.getServerSubstitutions().
86 entrySet()) {
87 substitutions.add(new SubstitutionLabel(new Substitution(entry.getValue(),
88 entry.getKey())));
89 }
90
91 for (int i = 1; i < 4; i++) {
92 substitutions.add(new SubstitutionLabel(new Substitution("Argument #" + i, Integer.toString(i))));
93 }
94
95 for (int i = 1; i < 4; i++) {
96 substitutions.add(new SubstitutionLabel(new Substitution("Argument #" + i + " onwards", i + "-")));
97 }
98 }
99
100 layoutComponents();
101 validate();
102 layoutComponents();
103 }
104 });
105 }
106 }
SofCheck Inspector Build Version : 2.17854
| AliasSubstitutionsPanel.java |
2009-Jun-25 01:54:24 |
| AliasSubstitutionsPanel.class |
2009-Sep-02 17:04:16 |
| AliasSubstitutionsPanel$1.class |
2009-Sep-02 17:04:16 |