Browse Source

Mass singleton removal spree. Minor tidying in edited classes.

This tidying introduces a DialogManager class which ensures only a
single instance of a dialog can exist at any one time.  This will be
expanded in the future to support management of all dialogs.

Change-Id: I506d7dde623628e38fddcd5f81221d9f2cc832ca
Reviewed-on: http://gerrit.dmdirc.com/2246
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 12 years ago
parent
commit
4d80c32e27
100 changed files with 1397 additions and 1418 deletions
  1. 0
    1
      src/com/dmdirc/addons/activewindow/ActiveCommand.java
  2. 0
    1
      src/com/dmdirc/addons/contactlist/ContactListCommand.java
  3. 1
    1
      src/com/dmdirc/addons/dcc/PlaceholderContainer.java
  4. 5
    3
      src/com/dmdirc/addons/lagdisplay/ServerInfoDialog.java
  5. 6
    4
      src/com/dmdirc/addons/nickcolours/NickColourInputDialog.java
  6. 3
    6
      src/com/dmdirc/addons/serverlistdialog/AddEntryInputDialog.java
  7. 2
    5
      src/com/dmdirc/addons/serverlistdialog/AddGroupInputDialog.java
  8. 6
    8
      src/com/dmdirc/addons/serverlistdialog/Perform.java
  9. 3
    2
      src/com/dmdirc/addons/serverlistdialog/ServerListDialog.java
  10. 91
    94
      src/com/dmdirc/addons/ui_swing/Apple.java
  11. 14
    19
      src/com/dmdirc/addons/ui_swing/MainFrame.java
  12. 14
    12
      src/com/dmdirc/addons/ui_swing/PrefsComponentFactory.java
  13. 50
    35
      src/com/dmdirc/addons/ui_swing/SwingController.java
  14. 1
    1
      src/com/dmdirc/addons/ui_swing/cinch/ConfirmAction.java
  15. 6
    7
      src/com/dmdirc/addons/ui_swing/cinch/InputAction.java
  16. 4
    7
      src/com/dmdirc/addons/ui_swing/components/MDIBar.java
  17. 0
    6
      src/com/dmdirc/addons/ui_swing/components/SearchValidator.java
  18. 13
    14
      src/com/dmdirc/addons/ui_swing/components/SendWorker.java
  19. 0
    1
      src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java
  20. 6
    11
      src/com/dmdirc/addons/ui_swing/components/ToolTipPanel.java
  21. 13
    17
      src/com/dmdirc/addons/ui_swing/components/TopicBar.java
  22. 24
    21
      src/com/dmdirc/addons/ui_swing/components/URLProtocolPanel.java
  23. 0
    1
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonFilter.java
  24. 69
    135
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfo.java
  25. 0
    7
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfoCellRenderer.java
  26. 9
    3
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfoLabel.java
  27. 9
    2
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/BrowserWindow.java
  28. 16
    10
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java
  29. 10
    4
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallListener.java
  30. 6
    5
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallerWindow.java
  31. 5
    10
      src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java
  32. 11
    6
      src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonToggle.java
  33. 6
    5
      src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java
  34. 3
    2
      src/com/dmdirc/addons/ui_swing/components/addonpanel/ThemePanel.java
  35. 33
    21
      src/com/dmdirc/addons/ui_swing/components/colours/ColourChooser.java
  36. 19
    39
      src/com/dmdirc/addons/ui_swing/components/colours/ColourPickerDialog.java
  37. 4
    9
      src/com/dmdirc/addons/ui_swing/components/colours/ColourPickerPanel.java
  38. 37
    24
      src/com/dmdirc/addons/ui_swing/components/colours/OptionalColourChooser.java
  39. 19
    11
      src/com/dmdirc/addons/ui_swing/components/durationeditor/DurationDisplay.java
  40. 14
    9
      src/com/dmdirc/addons/ui_swing/components/durationeditor/DurationEditor.java
  41. 11
    13
      src/com/dmdirc/addons/ui_swing/components/expandingsettings/CurrentOptionsPanel.java
  42. 6
    10
      src/com/dmdirc/addons/ui_swing/components/expandingsettings/SettingsPanel.java
  43. 5
    10
      src/com/dmdirc/addons/ui_swing/components/frames/AppleJFrame.java
  44. 4
    10
      src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java
  45. 12
    12
      src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java
  46. 4
    14
      src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java
  47. 6
    6
      src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java
  48. 13
    13
      src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputField.java
  49. 9
    34
      src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java
  50. 16
    12
      src/com/dmdirc/addons/ui_swing/components/inputfields/TextAreaInputField.java
  51. 12
    10
      src/com/dmdirc/addons/ui_swing/components/inputfields/TextFieldInputField.java
  52. 12
    10
      src/com/dmdirc/addons/ui_swing/components/inputfields/TextPaneInputField.java
  53. 4
    7
      src/com/dmdirc/addons/ui_swing/components/inputfields/ValidatingTextFieldInputField.java
  54. 4
    14
      src/com/dmdirc/addons/ui_swing/components/menubar/HelpMenu.java
  55. 3
    3
      src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java
  56. 1
    1
      src/com/dmdirc/addons/ui_swing/components/menubar/ServerMenu.java
  57. 6
    16
      src/com/dmdirc/addons/ui_swing/components/menubar/SettingsMenu.java
  58. 1
    5
      src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java
  59. 1
    5
      src/com/dmdirc/addons/ui_swing/components/modes/ModesComparator.java
  60. 2
    0
      src/com/dmdirc/addons/ui_swing/components/modes/ModesPane.java
  61. 14
    14
      src/com/dmdirc/addons/ui_swing/components/performpanel/PerformPanel.java
  62. 0
    7
      src/com/dmdirc/addons/ui_swing/components/renderers/AddonCellRenderer.java
  63. 15
    12
      src/com/dmdirc/addons/ui_swing/components/renderers/CertificateChainEntryCellRenderer.java
  64. 11
    9
      src/com/dmdirc/addons/ui_swing/components/renderers/ErrorLevelIconCellRenderer.java
  65. 1
    1
      src/com/dmdirc/addons/ui_swing/components/renderers/MapEntryRenderer.java
  66. 1
    1
      src/com/dmdirc/addons/ui_swing/components/renderers/NicklistRenderer.java
  67. 0
    7
      src/com/dmdirc/addons/ui_swing/components/renderers/ReorderableJListCellRenderer.java
  68. 0
    7
      src/com/dmdirc/addons/ui_swing/components/renderers/TopicCellRenderer.java
  69. 4
    8
      src/com/dmdirc/addons/ui_swing/components/statusbar/ErrorPanel.java
  70. 15
    15
      src/com/dmdirc/addons/ui_swing/components/statusbar/ErrorPopup.java
  71. 3
    6
      src/com/dmdirc/addons/ui_swing/components/statusbar/FeedbackNag.java
  72. 6
    3
      src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java
  73. 6
    4
      src/com/dmdirc/addons/ui_swing/components/statusbar/InvitePopup.java
  74. 12
    11
      src/com/dmdirc/addons/ui_swing/components/statusbar/MessageLabel.java
  75. 12
    12
      src/com/dmdirc/addons/ui_swing/components/statusbar/MessagePopup.java
  76. 7
    4
      src/com/dmdirc/addons/ui_swing/components/statusbar/StatusbarPopupWindow.java
  77. 4
    5
      src/com/dmdirc/addons/ui_swing/components/statusbar/SwingStatusBar.java
  78. 4
    9
      src/com/dmdirc/addons/ui_swing/components/statusbar/UpdaterLabel.java
  79. 6
    3
      src/com/dmdirc/addons/ui_swing/components/statusbar/UpdaterPopup.java
  80. 0
    2
      src/com/dmdirc/addons/ui_swing/dialogs/ChannelJoinDialog.java
  81. 4
    4
      src/com/dmdirc/addons/ui_swing/dialogs/ConfirmQuitDialog.java
  82. 210
    0
      src/com/dmdirc/addons/ui_swing/dialogs/DialogManager.java
  83. 18
    67
      src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java
  84. 14
    75
      src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java
  85. 111
    8
      src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java
  86. 5
    6
      src/com/dmdirc/addons/ui_swing/dialogs/StandardInputDialog.java
  87. 7
    8
      src/com/dmdirc/addons/ui_swing/dialogs/StandardMessageDialog.java
  88. 31
    3
      src/com/dmdirc/addons/ui_swing/dialogs/StandardQuestionDialog.java
  89. 8
    59
      src/com/dmdirc/addons/ui_swing/dialogs/about/AboutDialog.java
  90. 4
    9
      src/com/dmdirc/addons/ui_swing/dialogs/about/InfoPanel.java
  91. 28
    19
      src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java
  92. 26
    23
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java
  93. 37
    29
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsListPanel.java
  94. 6
    10
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsPanel.java
  95. 24
    121
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionEditorDialog.java
  96. 19
    15
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanel.java
  97. 23
    13
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersListPanel.java
  98. 27
    15
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersPanel.java
  99. 10
    10
      src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsGroupPanel.java
  100. 0
    0
      src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java

+ 0
- 1
src/com/dmdirc/addons/activewindow/ActiveCommand.java View File

@@ -31,7 +31,6 @@ import com.dmdirc.commandparser.CommandInfo;
31 31
 import com.dmdirc.commandparser.CommandType;
32 32
 import com.dmdirc.commandparser.commands.Command;
33 33
 import com.dmdirc.commandparser.commands.IntelligentCommand;
34
-import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
35 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
36 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 36
 import com.dmdirc.ui.input.TabCompleter;

+ 0
- 1
src/com/dmdirc/addons/contactlist/ContactListCommand.java View File

@@ -29,7 +29,6 @@ import com.dmdirc.commandparser.CommandInfo;
29 29
 import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32
-import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
33 32
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
34 33
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 34
 import com.dmdirc.ui.input.AdditionalTabTargets;

+ 1
- 1
src/com/dmdirc/addons/dcc/PlaceholderContainer.java View File

@@ -68,7 +68,7 @@ public class PlaceholderContainer extends FrameContainer {
68 68
         if (dccs > 0) {
69 69
             new StandardQuestionDialog(((SwingController) PluginManager
70 70
                     .getPluginManager().getPluginInfoByName("ui_swing")
71
-                    .getPlugin()).getMainFrame(), ModalityType.MODELESS,
71
+                    .getPlugin()), ModalityType.MODELESS,
72 72
                     "Close confirmation",
73 73
                     "Closing this window will cause all existing DCCs "
74 74
                     + "to terminate, are you sure you want to do this?") {

+ 5
- 3
src/com/dmdirc/addons/lagdisplay/ServerInfoDialog.java View File

@@ -61,10 +61,12 @@ public class ServerInfoDialog extends StatusbarPopupWindow {
61 61
      * @param parent The {@link JPanel} to use for positioning
62 62
      */
63 63
     public ServerInfoDialog(final LagDisplayPlugin ldp, final StatusbarPanel parent) {
64
-        super(parent, ((SwingController) PluginManager.getPluginManager()
64
+        super(((SwingController) PluginManager.getPluginManager()
65
+                .getPluginInfoByName("ui_swing").getPlugin()), parent,
66
+                ((SwingController) PluginManager.getPluginManager()
65 67
                 .getPluginInfoByName("ui_swing").getPlugin()).getMainFrame());
66 68
 
67
-        this.plugin = ldp;
69
+        plugin = ldp;
68 70
     }
69 71
 
70 72
     /** {@inheritDoc} */
@@ -80,7 +82,7 @@ public class ServerInfoDialog extends StatusbarPopupWindow {
80 82
                 panel.add(new JSeparator(), "span, grow, wrap");
81 83
             }
82 84
 
83
-            for (Server server : servers) {
85
+            for (final Server server : servers) {
84 86
                 panel.add(new JLabel(server.getName()));
85 87
                 panel.add(new JLabel(server.getState() == ServerState.CONNECTED
86 88
                         ? server.getNetwork() : "---", JLabel.CENTER), "grow");

+ 6
- 4
src/com/dmdirc/addons/nickcolours/NickColourInputDialog.java View File

@@ -52,7 +52,7 @@ public class NickColourInputDialog extends StandardDialog
52 52
     /** Whether or not this is a new entry (as opposed to editing an old one). */
53 53
     private boolean isnew;
54 54
     /** The row we're editing, if this isn't a new entry. */
55
-    private int row;
55
+    private final int row;
56 56
     /** The NickColourPanel we're reporting to. */
57 57
     private final NickColourPanel panel;
58 58
     /** nickname textfield. */
@@ -78,7 +78,7 @@ public class NickColourInputDialog extends StandardDialog
78 78
             final String nickname, final String network,
79 79
             final String textcolour, final String nickcolour) {
80 80
         super(((SwingController) PluginManager.getPluginManager()
81
-                .getPluginInfoByName("ui_swing").getPlugin()).getMainFrame(), false);
81
+                .getPluginInfoByName("ui_swing").getPlugin()), false);
82 82
 
83 83
         this.panel = panel;
84 84
         this.row = row;
@@ -119,8 +119,10 @@ public class NickColourInputDialog extends StandardDialog
119 119
 
120 120
         nickname = new JTextField(defaultNickname);
121 121
         network = new JTextField(defaultNetwork);
122
-        textColour = new ColourChooser(defaultTextColour, true, true);
123
-        nicklistColour = new ColourChooser(defaultNickColour, true, true);
122
+        textColour = new ColourChooser(getController().getIconManager(),
123
+                defaultTextColour, true, true);
124
+        nicklistColour = new ColourChooser(getController().getIconManager(),
125
+                defaultNickColour, true, true);
124 126
     }
125 127
 
126 128
     /** Initialises the listeners. */

+ 3
- 6
src/com/dmdirc/addons/serverlistdialog/AddEntryInputDialog.java View File

@@ -71,8 +71,6 @@ public class AddEntryInputDialog extends StandardDialog {
71 71
     private final JTree items;
72 72
     /** Parent model. */
73 73
     private final ServerListModel model;
74
-    /** Swing controller. */
75
-    private final SwingController controller;
76 74
 
77 75
     /**
78 76
      * Instantiates a new standard input dialog.
@@ -85,9 +83,8 @@ public class AddEntryInputDialog extends StandardDialog {
85 83
     public AddEntryInputDialog(final SwingController controller,
86 84
             final Window owner, final JTree items,
87 85
             final ServerListModel model) {
88
-        super(owner, ModalityType.MODELESS);
86
+        super(controller, owner, ModalityType.MODELESS);
89 87
 
90
-        this.controller = controller;
91 88
         this.items = items;
92 89
         this.model = model;
93 90
         this.entryValidator = new NotEmptyValidator();
@@ -123,8 +120,8 @@ public class AddEntryInputDialog extends StandardDialog {
123 120
      */
124 121
     private void initComponents() {
125 122
         orderButtons(new JButton(), new JButton());
126
-        entryName = new ValidatingJTextField(controller.getIconManager(), entryValidator);
127
-        uri = new ValidatingJTextField(controller.getIconManager(), new URIJTextField(), uriValidator);
123
+        entryName = new ValidatingJTextField(getIconManager(), entryValidator);
124
+        uri = new ValidatingJTextField(getIconManager(), new URIJTextField(), uriValidator);
128 125
         blurb = new TextLabel(message);
129 126
         validateText();
130 127
     }

+ 2
- 5
src/com/dmdirc/addons/serverlistdialog/AddGroupInputDialog.java View File

@@ -68,8 +68,6 @@ public class AddGroupInputDialog extends StandardDialog {
68 68
     private final JTree tree;
69 69
     /** Parent model. */
70 70
     private final ServerListModel serverListModel;
71
-    /** Swing controller. */
72
-    private final SwingController controller;
73 71
 
74 72
     /**
75 73
      * Instantiates a new standard input dialog.
@@ -82,9 +80,8 @@ public class AddGroupInputDialog extends StandardDialog {
82 80
     public AddGroupInputDialog(final SwingController controller,
83 81
             final Window owner, final JTree items,
84 82
             final ServerListModel model) {
85
-        super(owner, ModalityType.MODELESS);
83
+        super(controller, owner, ModalityType.MODELESS);
86 84
 
87
-        this.controller = controller;
88 85
         this.tree = items;
89 86
         this.serverListModel = model;
90 87
         this.validator = new NotEmptyValidator();
@@ -132,7 +129,7 @@ public class AddGroupInputDialog extends StandardDialog {
132 129
      */
133 130
     private void initComponents() {
134 131
         orderButtons(new JButton(), new JButton());
135
-        groupName = new ValidatingJTextField(controller.getIconManager(), validator);
132
+        groupName = new ValidatingJTextField(getIconManager(), validator);
136 133
         networkName = new JTextField();
137 134
         blurb = new TextLabel(message);
138 135
         validateText();

+ 6
- 8
src/com/dmdirc/addons/serverlistdialog/Perform.java View File

@@ -22,8 +22,9 @@
22 22
 
23 23
 package com.dmdirc.addons.serverlistdialog;
24 24
 
25
-import com.dmdirc.addons.ui_swing.components.performpanel.PerformPanel;
26 25
 import com.dmdirc.addons.serverlists.ServerGroupItem;
26
+import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.components.performpanel.PerformPanel;
27 28
 
28 29
 import javax.swing.BorderFactory;
29 30
 import javax.swing.JPanel;
@@ -37,11 +38,7 @@ import net.miginfocom.swing.MigLayout;
37 38
  */
38 39
 public class Perform extends JPanel implements ServerListListener {
39 40
 
40
-    /**
41
-     * A version number for this class. It should be changed whenever the class
42
-     * structure is changed (or anything else that would prevent serialized
43
-     * objects being unserialized with the new class).
44
-     */
41
+    /** Serial version UID. */
45 42
     private static final long serialVersionUID = 2;
46 43
     /** Perform panel. */
47 44
     private final PerformPanel performPanel;
@@ -53,13 +50,14 @@ public class Perform extends JPanel implements ServerListListener {
53 50
     /**
54 51
      * Creates a new perform panel backed by the specified model.
55 52
      *
53
+     * @param controller Swing controller
56 54
      * @param model Backing model
57 55
      */
58
-    public Perform(final ServerListModel model) {
56
+    public Perform(final SwingController controller, final ServerListModel model) {
59 57
         super();
60 58
 
61 59
         this.model = model;
62
-        performPanel = new PerformPanel();
60
+        performPanel = new PerformPanel(controller);
63 61
 
64 62
         addListeners();
65 63
         if (model.getSelectedItemPerformDescription() != null) {

+ 3
- 2
src/com/dmdirc/addons/serverlistdialog/ServerListDialog.java View File

@@ -80,7 +80,7 @@ public final class ServerListDialog extends StandardDialog implements
80 80
      */
81 81
     public ServerListDialog(final SwingController controller,
82 82
             final URLHandler urlHandler) {
83
-        super(controller.getMainFrame(), ModalityType.MODELESS);
83
+        super(controller, controller.getMainFrame(), ModalityType.MODELESS);
84 84
 
85 85
         setTitle("Server List");
86 86
         model = new ServerListModel();
@@ -102,7 +102,8 @@ public final class ServerListDialog extends StandardDialog implements
102 102
                 null)));
103 103
         profileLayer = new JXLayer<Profiles>(new Profiles(model, controller),
104 104
                 profileLock);
105
-        performLayer = new JXLayer<Perform>(new Perform(model), performLock);
105
+        performLayer = new JXLayer<Perform>(new Perform(controller, model),
106
+                performLock);
106 107
         settingsLayer = new JXLayer<Settings>(new Settings(controller, model),
107 108
                 settingsLock);
108 109
         infoLayer = new JXLayer<Info>(new Info(model, urlHandler), infoLock);

+ 91
- 94
src/com/dmdirc/addons/ui_swing/Apple.java View File

@@ -25,11 +25,11 @@ package com.dmdirc.addons.ui_swing;
25 25
 import com.dmdirc.ServerManager;
26 26
 import com.dmdirc.actions.ActionManager;
27 27
 import com.dmdirc.actions.CoreActionType;
28
-import com.dmdirc.interfaces.actions.ActionType;
29 28
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
30 29
 import com.dmdirc.commandparser.commands.global.NewServer;
31
-import com.dmdirc.config.IdentityManager;
30
+import com.dmdirc.config.ConfigManager;
32 31
 import com.dmdirc.interfaces.ActionListener;
32
+import com.dmdirc.interfaces.actions.ActionType;
33 33
 import com.dmdirc.logger.ErrorLevel;
34 34
 import com.dmdirc.logger.Logger;
35 35
 
@@ -57,7 +57,8 @@ public final class Apple implements InvocationHandler, ActionListener {
57 57
     /**
58 58
      * Dummy interface for ApplicationEvent from the Apple UI on non-Apple
59 59
      * platforms.
60
-     * http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/ApplicationEvent.html
60
+     * http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/
61
+     * api/com/apple/eawt/ApplicationEvent.html
61 62
      */
62 63
     public interface ApplicationEvent {
63 64
 
@@ -98,53 +99,44 @@ public final class Apple implements InvocationHandler, ActionListener {
98 99
         String toString();
99 100
     }
100 101
 
101
-    /** The singleton instance of Apple. */
102
-    private static Apple me;
102
+    /** Store any addresses that are opened before CLIENT_OPENED. */
103
+    private final List<URI> addresses = new ArrayList<URI>();
104
+    /** Config manager used to read settings. */
105
+    private final ConfigManager configManager;
103 106
     /** The "Application" object used to do stuff on OS X. */
104
-    private static Object application;
107
+    private Object application;
105 108
     /** The "NSApplication" object used to do cocoa stuff on OS X. */
106
-    private static Object nsApplication;
109
+    private Object nsApplication;
107 110
     /** Are we listening? */
108 111
     private boolean isListener = false;
109 112
     /** The MenuBar for the application. */
110 113
     private MenuBar menuBar = null;
111 114
     /** Has the CLIENT_OPENED action been called? */
112 115
     private boolean clientOpened = false;
113
-    /** Store any addresses that are opened before CLIENT_OPENED. */
114
-    private final List<URI> addresses = new ArrayList<URI>();
115
-
116
-    /**
117
-     * Get the "Apple" instance.
118
-     *
119
-     * @return Apple instance.
120
-     */
121
-    public static Apple getApple() {
122
-        synchronized (Apple.class) {
123
-            if (me == null) {
124
-                me = new Apple();
125
-            }
126
-            return me;
127
-        }
128
-    }
129 116
 
130 117
     /**
131 118
      * Create the Apple class.
132
-     * <p>This attempts to:</p>
119
+     * <p>
120
+     * This attempts to:
121
+     * </p>
133 122
      *
134 123
      * <ul>
135
-     *  <li>load the JNI library</li>
136
-     *  <li>register the callback</li>
137
-     *  <li>register a CLIENT_OPENED listener</li>
124
+     * <li>load the JNI library</li>
125
+     * <li>register the callback</li>
126
+     * <li>register a CLIENT_OPENED listener</li>
138 127
      * </ul>
128
+     *
129
+     * @param configManager Config manager
139 130
      */
140
-    private Apple() {
131
+    public Apple(final ConfigManager configManager) {
132
+        this.configManager = configManager;
141 133
         if (isApple()) {
142 134
             try {
143
-                System.loadLibrary("DMDirc-Apple"); //NOPMD
135
+                System.loadLibrary("DMDirc-Apple"); // NOPMD
144 136
                 registerOpenURLCallback();
145 137
                 ActionManager.getActionManager().registerListener(this,
146 138
                         CoreActionType.CLIENT_OPENED);
147
-            } catch (UnsatisfiedLinkError ule) {
139
+            } catch (final UnsatisfiedLinkError ule) {
148 140
                 Logger.userError(ErrorLevel.MEDIUM,
149 141
                         "Unable to load JNI library.", ule);
150 142
             }
@@ -156,7 +148,7 @@ public final class Apple implements InvocationHandler, ActionListener {
156 148
      *
157 149
      * @return Object that on OSX will be an "Application"
158 150
      */
159
-    public static Object getApplication() {
151
+    public Object getApplication() {
160 152
         synchronized (Apple.class) {
161 153
             if (isApple() && application == null) {
162 154
                 try {
@@ -165,17 +157,17 @@ public final class Apple implements InvocationHandler, ActionListener {
165 157
                     final Method method = app.getMethod("getApplication",
166 158
                             new Class[0]);
167 159
                     application = method.invoke(null, new Object[0]);
168
-                } catch (ClassNotFoundException ex) {
160
+                } catch (final ClassNotFoundException ex) {
169 161
                     application = null;
170
-                } catch (NoSuchMethodException ex) {
162
+                } catch (final NoSuchMethodException ex) {
171 163
                     application = null;
172
-                } catch (SecurityException ex) {
164
+                } catch (final SecurityException ex) {
173 165
                     application = null;
174
-                } catch (IllegalAccessException ex) {
166
+                } catch (final IllegalAccessException ex) {
175 167
                     application = null;
176
-                } catch (IllegalArgumentException ex) {
168
+                } catch (final IllegalArgumentException ex) {
177 169
                     application = null;
178
-                } catch (InvocationTargetException ex) {
170
+                } catch (final InvocationTargetException ex) {
179 171
                     application = null;
180 172
                 }
181 173
             }
@@ -188,26 +180,26 @@ public final class Apple implements InvocationHandler, ActionListener {
188 180
      *
189 181
      * @return Object that on OSX will be an "NSApplication"
190 182
      */
191
-    public static Object getNSApplication() {
183
+    public Object getNSApplication() {
192 184
         synchronized (Apple.class) {
193
-           if (isApple() && nsApplication == null) {
194
-               try {
185
+            if (isApple() && nsApplication == null) {
186
+                try {
195 187
                     final Class<?> app = Class.forName(
196 188
                             "com.apple.cocoa.application.NSApplication");
197 189
                     final Method method = app.getMethod("sharedApplication",
198 190
                             new Class[0]);
199 191
                     nsApplication = method.invoke(null, new Object[0]);
200
-               } catch (ClassNotFoundException ex) {
201
-                   nsApplication = null;
202
-               } catch (NoSuchMethodException ex) {
192
+                } catch (final ClassNotFoundException ex) {
203 193
                     nsApplication = null;
204
-                } catch (IllegalAccessException ex) {
194
+                } catch (final NoSuchMethodException ex) {
205 195
                     nsApplication = null;
206
-               } catch (InvocationTargetException ex) {
207
-                  nsApplication = null;
208
-               }
209
-          }
210
-         return nsApplication;
196
+                } catch (final IllegalAccessException ex) {
197
+                    nsApplication = null;
198
+                } catch (final InvocationTargetException ex) {
199
+                    nsApplication = null;
200
+                }
201
+            }
202
+            return nsApplication;
211 203
         }
212 204
     }
213 205
 
@@ -239,8 +231,8 @@ public final class Apple implements InvocationHandler, ActionListener {
239 231
         }
240 232
 
241 233
         // Set some Apple OS X related stuff from http://tinyurl.com/6xwuld
242
-        final String aaText = IdentityManager.getGlobalConfig().getOptionBool(
243
-                "ui", "antialias") ? "on" : "off";
234
+        final String aaText = configManager
235
+                .getOptionBool("ui", "antialias") ? "on" : "off";
244 236
 
245 237
         System.setProperty("apple.awt.antialiasing", aaText);
246 238
         System.setProperty("apple.awt.textantialiasing", aaText);
@@ -257,7 +249,7 @@ public final class Apple implements InvocationHandler, ActionListener {
257 249
      * Request user attention (Bounce the dock).
258 250
      *
259 251
      * @param isCritical If this is false, the dock icon only bounces once,
260
-     *                   otherwise it will bounce until clicked on.
252
+     *            otherwise it will bounce until clicked on.
261 253
      */
262 254
     public void requestUserAttention(final boolean isCritical) {
263 255
         if (!isApple()) {
@@ -266,18 +258,19 @@ public final class Apple implements InvocationHandler, ActionListener {
266 258
 
267 259
         try {
268 260
             final Field type = isCritical ? getNSApplication().getClass().
269
-                    getField("UserAttentionRequestCritical") : getNSApplication().
270
-                    getClass().getField("Informational");
261
+                    getField("UserAttentionRequestCritical")
262
+                    : getNSApplication().
263
+                            getClass().getField("Informational");
271 264
             final Method method = getNSApplication().getClass().getMethod(
272
-                    "requestUserAttention", new Class[]{Integer.TYPE});
273
-            method.invoke(getNSApplication(), new Object[]{type.get(null)});
274
-        } catch (NoSuchFieldException ex) {
265
+                    "requestUserAttention", new Class[] { Integer.TYPE });
266
+            method.invoke(getNSApplication(), new Object[] { type.get(null) });
267
+        } catch (final NoSuchFieldException ex) {
275 268
             Logger.userError(ErrorLevel.LOW, "Unable to find OS X classes");
276
-        } catch (NoSuchMethodException ex) {
269
+        } catch (final NoSuchMethodException ex) {
277 270
             Logger.userError(ErrorLevel.LOW, "Unable to find OS X classes");
278
-        } catch (IllegalAccessException ex) {
271
+        } catch (final IllegalAccessException ex) {
279 272
             Logger.userError(ErrorLevel.LOW, "Unable to find OS X classes");
280
-        } catch (InvocationTargetException ex) {
273
+        } catch (final InvocationTargetException ex) {
281 274
             Logger.userError(ErrorLevel.LOW, "Unable to find OS X classes");
282 275
         }
283 276
     }
@@ -293,33 +286,34 @@ public final class Apple implements InvocationHandler, ActionListener {
293 286
         }
294 287
 
295 288
         try {
296
-            final Class listenerClass = Class.forName(
289
+            final Class<?> listenerClass = Class.forName(
297 290
                     "com.apple.eawt.ApplicationListener");
298 291
             final Object listener = Proxy.newProxyInstance(getClass().
299
-                    getClassLoader(), new Class[]{listenerClass}, this);
292
+                    getClassLoader(), new Class[] { listenerClass }, this);
300 293
 
301 294
             Method method = getApplication().getClass().getMethod(
302
-                    "addApplicationListener", new Class[]{listenerClass});
295
+                    "addApplicationListener", new Class[] { listenerClass });
303 296
             method.invoke(getApplication(), listener);
304 297
 
305 298
             isListener = true;
306 299
 
307 300
             method = getApplication().getClass().getMethod(
308
-                    "setEnabledPreferencesMenu", new Class[]{Boolean.TYPE});
309
-            method.invoke(getApplication(), new Object[]{Boolean.TRUE});
301
+                    "setEnabledPreferencesMenu", new Class[] { Boolean.TYPE });
302
+            method.invoke(getApplication(), new Object[] { Boolean.TRUE });
310 303
 
311 304
             method =
312
-                    getApplication().getClass().getMethod("setEnabledAboutMenu",
313
-                    new Class[]{Boolean.TYPE});
314
-            method.invoke(getApplication(), new Object[]{Boolean.TRUE});
305
+                    getApplication().getClass().getMethod(
306
+                            "setEnabledAboutMenu",
307
+                            new Class[] { Boolean.TYPE });
308
+            method.invoke(getApplication(), new Object[] { Boolean.TRUE });
315 309
             return true;
316
-        } catch (ClassNotFoundException ex) {
310
+        } catch (final ClassNotFoundException ex) {
317 311
             return false;
318
-        } catch (NoSuchMethodException ex) {
312
+        } catch (final NoSuchMethodException ex) {
319 313
             return false;
320
-        } catch (IllegalAccessException ex) {
314
+        } catch (final IllegalAccessException ex) {
321 315
             return false;
322
-        } catch (InvocationTargetException ex) {
316
+        } catch (final InvocationTargetException ex) {
323 317
             return false;
324 318
         }
325 319
     }
@@ -338,21 +332,24 @@ public final class Apple implements InvocationHandler, ActionListener {
338 332
 
339 333
         try {
340 334
             final ApplicationEvent event = (ApplicationEvent) Proxy.
341
-                    newProxyInstance(getClass().getClassLoader(), new Class[]{
342
-                        ApplicationEvent.class}, new InvocationHandler() {
343
-
344
-                /** {@inheritDoc} */
345
-                @Override
346
-                public Object invoke(final Object p, final Method m,
347
-                        final Object[] a) throws Throwable {
348
-                    return args[0].getClass().getMethod(m.getName(), m.
349
-                            getParameterTypes()).invoke(args[0], a);
350
-                }
351
-            });
335
+                    newProxyInstance(getClass().getClassLoader(), new Class[] {
336
+                            ApplicationEvent.class }, new InvocationHandler() {
337
+
338
+                                /** {@inheritDoc} */
339
+                                @Override
340
+                                public Object invoke(final Object p,
341
+                                        final Method m,
342
+                                        final Object[] a) throws Throwable {
343
+                                    return args[0].getClass()
344
+                                            .getMethod(m.getName(), m.
345
+                                                    getParameterTypes())
346
+                                            .invoke(args[0], a);
347
+                                }
348
+                            });
352 349
             final Method thisMethod = this.getClass().getMethod(
353
-                    method.getName(), new Class[]{ApplicationEvent.class});
350
+                    method.getName(), new Class[] { ApplicationEvent.class });
354 351
             return thisMethod.invoke(this, event);
355
-        } catch (NoSuchMethodException e) {
352
+        } catch (final NoSuchMethodException e) {
356 353
             if (method.getName().equals("equals") && args.length == 1) {
357 354
                 return Boolean.valueOf(proxy == args[0]);
358 355
             }
@@ -368,7 +365,7 @@ public final class Apple implements InvocationHandler, ActionListener {
368 365
      * @param newMenuBar MenuBar to use to send events to,
369 366
      */
370 367
     public void setMenuBar(final MenuBar newMenuBar) {
371
-        this.menuBar = newMenuBar;
368
+        menuBar = newMenuBar;
372 369
         if (!isAppleUI()) {
373 370
             return;
374 371
         }
@@ -439,7 +436,7 @@ public final class Apple implements InvocationHandler, ActionListener {
439 436
      * @param event an ApplicationEvent object
440 437
      */
441 438
     public void handleOpenApplication(final ApplicationEvent event) {
442
-        //We don't currently support this
439
+        // We don't currently support this
443 440
     }
444 441
 
445 442
     /**
@@ -448,7 +445,7 @@ public final class Apple implements InvocationHandler, ActionListener {
448 445
      * @param event an ApplicationEvent object
449 446
      */
450 447
     public void handleOpenFile(final ApplicationEvent event) {
451
-        //We don't currently support this
448
+        // We don't currently support this
452 449
     }
453 450
 
454 451
     /**
@@ -457,7 +454,7 @@ public final class Apple implements InvocationHandler, ActionListener {
457 454
      * @param event an ApplicationEvent object
458 455
      */
459 456
     public void handlePrintFile(final ApplicationEvent event) {
460
-        //We don't currently support this
457
+        // We don't currently support this
461 458
     }
462 459
 
463 460
     /**
@@ -466,7 +463,7 @@ public final class Apple implements InvocationHandler, ActionListener {
466 463
      * @param event an ApplicationEvent object
467 464
      */
468 465
     public void handleReopenApplication(final ApplicationEvent event) {
469
-        //We don't currently support this
466
+        // We don't currently support this
470 467
     }
471 468
 
472 469
     /** {@inheritDoc} */
@@ -476,7 +473,7 @@ public final class Apple implements InvocationHandler, ActionListener {
476 473
         if (type == CoreActionType.CLIENT_OPENED) {
477 474
             synchronized (addresses) {
478 475
                 clientOpened = true;
479
-                for (URI addr : addresses) {
476
+                for (final URI addr : addresses) {
480 477
                     ServerManager.getServerManager().connectToAddress(addr);
481 478
                 }
482 479
                 addresses.clear();
@@ -504,7 +501,7 @@ public final class Apple implements InvocationHandler, ActionListener {
504 501
                     // ContextClassLoader set, which causes an NPE in
505 502
                     // IconManager if no servers have been connected to yet.
506 503
                     if (Thread.currentThread().getContextClassLoader()
507
-                            == null) {
504
+                    == null) {
508 505
                         Thread.currentThread().setContextClassLoader(
509 506
                                 ClassLoader.getSystemClassLoader());
510 507
                     }
@@ -512,8 +509,8 @@ public final class Apple implements InvocationHandler, ActionListener {
512 509
                 } else {
513 510
                     addresses.add(addr);
514 511
                 }
515
-            } catch (URISyntaxException iae) {
516
-                //Do nothing
512
+            } catch (final URISyntaxException iae) {
513
+                // Do nothing
517 514
             }
518 515
         }
519 516
     }

+ 14
- 19
src/com/dmdirc/addons/ui_swing/MainFrame.java View File

@@ -46,9 +46,9 @@ import com.dmdirc.logger.Logger;
46 46
 import com.dmdirc.ui.Colour;
47 47
 import com.dmdirc.ui.CoreUIUtils;
48 48
 import com.dmdirc.ui.IconManager;
49
+import com.dmdirc.util.ReturnableThread;
49 50
 import com.dmdirc.util.collections.ListenerList;
50 51
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
51
-import com.dmdirc.util.ReturnableThread;
52 52
 
53 53
 import java.awt.Dimension;
54 54
 import java.awt.event.WindowEvent;
@@ -334,28 +334,28 @@ public final class MainFrame extends JFrame implements WindowListener,
334 334
                 try {
335 335
                     mainFrameManager = (FrameManager) Class.forName(manager)
336 336
                             .getConstructor().newInstance();
337
-                } catch (InvocationTargetException ex) {
337
+                } catch (final InvocationTargetException ex) {
338 338
                     Logger.appError(ErrorLevel.MEDIUM, "Unable to load frame "
339 339
                             + "manager, falling back to default.", ex);
340
-                } catch (InstantiationException ex) {
340
+                } catch (final InstantiationException ex) {
341 341
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
342 342
                             + "manager, falling back to default.", ex);
343
-                } catch (NoSuchMethodException ex) {
343
+                } catch (final NoSuchMethodException ex) {
344 344
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
345 345
                             + "manager, falling back to default.", ex);
346
-                } catch (SecurityException ex) {
346
+                } catch (final SecurityException ex) {
347 347
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
348 348
                             + "manager, falling back to default.", ex);
349
-                } catch (IllegalAccessException ex) {
349
+                } catch (final IllegalAccessException ex) {
350 350
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
351 351
                             + "manager, falling back to default.", ex);
352
-                } catch (IllegalArgumentException ex) {
352
+                } catch (final IllegalArgumentException ex) {
353 353
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
354 354
                             + "manager, falling back to default.", ex);
355
-                } catch (ClassNotFoundException ex) {
355
+                } catch (final ClassNotFoundException ex) {
356 356
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
357 357
                             + "manager, falling back to default.", ex);
358
-                } catch (LinkageError ex) {
358
+                } catch (final LinkageError ex) {
359 359
                     Logger.userError(ErrorLevel.MEDIUM, "Unable to load frame "
360 360
                             + "manager, falling back to default.", ex);
361 361
                 } finally {
@@ -384,7 +384,7 @@ public final class MainFrame extends JFrame implements WindowListener,
384 384
         mainSplitPane = initSplitPane();
385 385
 
386 386
         final MenuBar menu = new MenuBar(controller, this);
387
-        Apple.getApple().setMenuBar(menu);
387
+        controller.getApple().setMenuBar(menu);
388 388
         setJMenuBar(menu);
389 389
 
390 390
         setPreferredSize(new Dimension(800, 600));
@@ -492,14 +492,9 @@ public final class MainFrame extends JFrame implements WindowListener,
492 492
     public void quit(final int exitCode) {
493 493
         if (exitCode == 0 && controller.getGlobalConfig().getOptionBool(
494 494
                 "ui", "confirmQuit")) {
495
-            final StandardQuestionDialog dialog = new ConfirmQuitDialog(this) {
496
-
497
-                /**
498
-                 * A version number for this class. It should be changed
499
-                 * whenever the class structure is changed (or anything else
500
-                 * that would prevent serialized objects being unserialized
501
-                 * with the new class).
502
-                 */
495
+            final StandardQuestionDialog dialog = new ConfirmQuitDialog(controller) {
496
+
497
+                /** Serial version UID. */
503 498
                 private static final long serialVersionUID = 9;
504 499
 
505 500
                 /** {@inheritDoc} */
@@ -623,7 +618,7 @@ public final class MainFrame extends JFrame implements WindowListener,
623 618
                     activeFrame.activateFrame();
624 619
                 }
625 620
 
626
-                for (SelectionListener listener : listeners.get(
621
+                for (final SelectionListener listener : listeners.get(
627 622
                         SelectionListener.class)) {
628 623
                     listener.selectionChanged(activeFrame);
629 624
                 }

+ 14
- 12
src/com/dmdirc/addons/ui_swing/PrefsComponentFactory.java View File

@@ -199,7 +199,7 @@ public final class PrefsComponentFactory {
199 199
         option.setRenderer(new MapEntryRenderer());
200 200
         option.setEditable(false);
201 201
 
202
-        for (Map.Entry<String, String> entry : setting.getComboOptions()
202
+        for (final Map.Entry<String, String> entry : setting.getComboOptions()
203 203
                 .entrySet()) {
204 204
             if (entry.getKey().equals(setting.getValue())) {
205 205
                 option.setSelectedItem(entry);
@@ -211,11 +211,12 @@ public final class PrefsComponentFactory {
211 211
 
212 212
             /** {@inheritDoc} */
213 213
             @Override
214
+            @SuppressWarnings("unchecked")
214 215
             public void actionPerformed(final ActionEvent e) {
215 216
                 final Object selected = ((JComboBox) e.getSource())
216 217
                         .getSelectedItem();
217 218
                 if (selected != null) {
218
-                    setting.setValue((String) ((Map.Entry) selected).getKey());
219
+                    setting.setValue(((Map.Entry<String, String>) selected).getKey());
219 220
                 }
220 221
             }
221 222
         });
@@ -252,7 +253,7 @@ public final class PrefsComponentFactory {
252 253
                 option = new JSpinner(new SpinnerNumberModel());
253 254
                 option.setValue(Integer.parseInt(setting.getValue()));
254 255
             }
255
-        } catch (NumberFormatException ex) {
256
+        } catch (final NumberFormatException ex) {
256 257
             option = new JSpinner(new SpinnerNumberModel());
257 258
         }
258 259
 
@@ -283,8 +284,8 @@ public final class PrefsComponentFactory {
283 284
                 .getValue().substring(1 + setting.getValue().indexOf(':'));
284 285
 
285 286
         OptionalJSpinner option;
286
-        final Validator optionalValidator = setting.getValidator();
287
-        Validator numericalValidator = null;
287
+        final Validator<?> optionalValidator = setting.getValidator();
288
+        Validator<?> numericalValidator = null;
288 289
         if (optionalValidator instanceof OptionalValidator) {
289 290
             numericalValidator = ((OptionalValidator) setting.getValidator()).
290 291
                     getValidator();
@@ -305,7 +306,7 @@ public final class PrefsComponentFactory {
305 306
                         ((NumericalValidator) numericalValidator).getMax(),
306 307
                         1), state);
307 308
             }
308
-        } catch (NumberFormatException ex) {
309
+        } catch (final NumberFormatException ex) {
309 310
             option = new OptionalJSpinner(new SpinnerNumberModel(), state);
310 311
         }
311 312
 
@@ -334,9 +335,10 @@ public final class PrefsComponentFactory {
334 335
         DurationDisplay option;
335 336
 
336 337
         try {
337
-            option = new DurationDisplay(Integer.parseInt(setting.getValue()));
338
-        } catch (NumberFormatException ex) {
339
-            option = new DurationDisplay();
338
+            option = new DurationDisplay(controller, Integer.parseInt(
339
+                    setting.getValue()));
340
+        } catch (final NumberFormatException ex) {
341
+            option = new DurationDisplay(controller);
340 342
         }
341 343
 
342 344
         option.addDurationListener(new DurationListener() {
@@ -360,7 +362,7 @@ public final class PrefsComponentFactory {
360 362
     private JComponent getColourOption(
361 363
             final PreferencesSetting setting) {
362 364
         final OptionalColourChooser option = new OptionalColourChooser(
363
-                setting.getValue(), true, true, true);
365
+                controller.getIconManager(), setting.getValue(), true, true, true);
364 366
 
365 367
         option.addActionListener(new ActionListener() {
366 368
 
@@ -391,8 +393,8 @@ public final class PrefsComponentFactory {
391 393
         final String colour = setting.getValue() == null ? "0" : setting
392 394
                 .getValue().substring(1 + setting.getValue().indexOf(':'));
393 395
 
394
-        final OptionalColourChooser option = new OptionalColourChooser(colour,
395
-                state, true, true);
396
+        final OptionalColourChooser option = new OptionalColourChooser(
397
+                controller.getIconManager(), colour, state, true, true);
396 398
 
397 399
         option.addActionListener(new ActionListener() {
398 400
 

+ 50
- 35
src/com/dmdirc/addons/ui_swing/SwingController.java View File

@@ -25,11 +25,17 @@ package com.dmdirc.addons.ui_swing;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28
-import com.dmdirc.addons.ui_swing.commands.*; //NOPMD
28
+import com.dmdirc.addons.ui_swing.commands.ChannelSettings;
29
+import com.dmdirc.addons.ui_swing.commands.Input;
30
+import com.dmdirc.addons.ui_swing.commands.PopInCommand;
31
+import com.dmdirc.addons.ui_swing.commands.PopOutCommand;
32
+import com.dmdirc.addons.ui_swing.commands.ServerSettings;
29 33
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
30 34
 import com.dmdirc.addons.ui_swing.components.statusbar.FeedbackNag;
31 35
 import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
32 36
 import com.dmdirc.addons.ui_swing.dialogs.DialogKeyListener;
37
+import com.dmdirc.addons.ui_swing.dialogs.DialogManager;
38
+import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
33 39
 import com.dmdirc.addons.ui_swing.dialogs.StandardMessageDialog;
34 40
 import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
35 41
 import com.dmdirc.addons.ui_swing.dialogs.error.ErrorListDialog;
@@ -46,7 +52,6 @@ import com.dmdirc.config.prefs.PreferencesCategory;
46 52
 import com.dmdirc.config.prefs.PreferencesDialogModel;
47 53
 import com.dmdirc.config.prefs.PreferencesSetting;
48 54
 import com.dmdirc.config.prefs.PreferencesType;
49
-import com.dmdirc.interfaces.ui.InputWindow;
50 55
 import com.dmdirc.interfaces.ui.UIController;
51 56
 import com.dmdirc.interfaces.ui.Window;
52 57
 import com.dmdirc.logger.ErrorLevel;
@@ -81,7 +86,6 @@ import javax.swing.UIManager.LookAndFeelInfo;
81 86
 import javax.swing.UnsupportedLookAndFeelException;
82 87
 
83 88
 import lombok.Getter;
84
-
85 89
 import net.miginfocom.layout.PlatformDefaults;
86 90
 
87 91
 /**
@@ -89,14 +93,6 @@ import net.miginfocom.layout.PlatformDefaults;
89 93
  */
90 94
 @SuppressWarnings("PMD.UnusedPrivateField")
91 95
 public class SwingController extends BasePlugin implements UIController {
92
-
93
-    /**
94
-     * A version number for this class. It should be changed whenever the class
95
-     * structure is changed (or anything else that would prevent serialized
96
-     * objects being unserialized with the new class).
97
-     */
98
-    private static final long serialVersionUID = 1;
99
-
100 96
     /** Window factory. */
101 97
     @Getter
102 98
     private final SwingWindowFactory windowFactory =
@@ -140,6 +136,12 @@ public class SwingController extends BasePlugin implements UIController {
140 136
     /** Prefs component factory instance. */
141 137
     @Getter
142 138
     private final PrefsComponentFactory prefsComponentFactory;
139
+    /** Dialog manager. */
140
+    @Getter
141
+    private final DialogManager dialogManager;
142
+    /** Apple handler, deals with Mac specific code. */
143
+    @Getter
144
+    private final Apple apple;
143 145
 
144 146
     /**
145 147
      * Instantiates a new SwingController.
@@ -151,11 +153,13 @@ public class SwingController extends BasePlugin implements UIController {
151 153
         super();
152 154
         this.pluginInfo = pluginInfo;
153 155
         this.identityManager = identityManager;
156
+        apple = new Apple(getGlobalConfig());
154 157
         globalConfig = identityManager.getGlobalConfiguration();
155 158
         globalIdentity = identityManager.getGlobalConfigIdentity();
156 159
         addonIdentity = identityManager.getGlobalAddonIdentity();
157 160
         iconManager = new IconManager(globalConfig);
158 161
         prefsComponentFactory = new PrefsComponentFactory(this);
162
+        dialogManager = new DialogManager(this);
159 163
         setAntiAlias();
160 164
         windows = new ArrayList<java.awt.Window>();
161 165
         registerCommand(new ServerSettings(), ServerSettings.INFO);
@@ -226,9 +230,8 @@ public class SwingController extends BasePlugin implements UIController {
226 230
             /** {@inheritDoc} */
227 231
             @Override
228 232
             public void run() {
229
-                ChannelSettingsDialog.showChannelSettingsDialog(
230
-                        SwingController.this, channel, getMainFrame(),
231
-                        (InputWindow) getWindowFactory().getSwingWindow(channel));
233
+                showDialog(ChannelSettingsDialog.class, channel,
234
+                        getWindowFactory().getSwingWindow(channel));
232 235
             }
233 236
         });
234 237
     }
@@ -241,12 +244,27 @@ public class SwingController extends BasePlugin implements UIController {
241 244
             /** {@inheritDoc} */
242 245
             @Override
243 246
             public void run() {
244
-                ServerSettingsDialog.showServerSettingsDialog(
245
-                        SwingController.this, server, getMainFrame());
247
+                showDialog(ServerSettingsDialog.class,
248
+                        server, getWindowFactory().getSwingWindow(server));
246 249
             }
247 250
         });
248 251
     }
249 252
 
253
+    /**
254
+     * Proxy method to {@link DialogManager} that shows a dialog in the client.
255
+     * For more details on what parameters might be required see
256
+     * {@link DialogManager#getDialog(Class, Object...)}
257
+     *
258
+     * @see DialogManager#getDialog(Class, Object...) getDialog
259
+     *
260
+     * @param klass The class of the dialog to show
261
+     * @param params Any non standard parameters required
262
+     */
263
+    public <T extends StandardDialog> void showDialog(final Class<T> klass,
264
+            final Object... params) {
265
+        dialogManager.showDialog(klass, params);
266
+    }
267
+
250 268
     /**
251 269
      * Updates the look and feel to the current config setting.
252 270
      */
@@ -292,16 +310,16 @@ public class SwingController extends BasePlugin implements UIController {
292 310
                     getMainFrame().setExtendedState(state);
293 311
                 }
294 312
             });
295
-        } catch (ClassNotFoundException ex) {
313
+        } catch (final ClassNotFoundException ex) {
296 314
             Logger.userError(ErrorLevel.LOW,
297 315
                     "Unable to change Look and Feel: " + ex.getMessage());
298
-        } catch (InstantiationException ex) {
316
+        } catch (final InstantiationException ex) {
299 317
             Logger.userError(ErrorLevel.LOW,
300 318
                     "Unable to change Look and Feel: " + ex.getMessage());
301
-        } catch (IllegalAccessException ex) {
319
+        } catch (final IllegalAccessException ex) {
302 320
             Logger.userError(ErrorLevel.LOW,
303 321
                     "Unable to change Look and Feel: " + ex.getMessage());
304
-        } catch (UnsupportedLookAndFeelException ex) {
322
+        } catch (final UnsupportedLookAndFeelException ex) {
305 323
             Logger.userError(ErrorLevel.LOW,
306 324
                     "Unable to change Look and Feel: " + ex.getMessage());
307 325
         }
@@ -313,8 +331,6 @@ public class SwingController extends BasePlugin implements UIController {
313 331
     private void initUISettings() {
314 332
         // This will do nothing on non OS X Systems
315 333
         if (Apple.isApple()) {
316
-            final Apple apple = Apple.getApple();
317
-
318 334
             apple.setUISettings();
319 335
             apple.setListener();
320 336
         }
@@ -331,15 +347,15 @@ public class SwingController extends BasePlugin implements UIController {
331 347
             UIUtilities.initUISettings();
332 348
             UIManager.setLookAndFeel(UIUtilities.getLookAndFeel(
333 349
                     getGlobalConfig().getOption("ui", "lookandfeel")));
334
-        } catch (UnsupportedOperationException ex) {
350
+        } catch (final UnsupportedOperationException ex) {
335 351
             Logger.userError(ErrorLevel.LOW, "Unable to set UI Settings");
336
-        } catch (UnsupportedLookAndFeelException ex) {
352
+        } catch (final UnsupportedLookAndFeelException ex) {
337 353
             Logger.userError(ErrorLevel.LOW, "Unable to set UI Settings");
338
-        } catch (IllegalAccessException ex) {
354
+        } catch (final IllegalAccessException ex) {
339 355
             Logger.userError(ErrorLevel.LOW, "Unable to set UI Settings");
340
-        } catch (InstantiationException ex) {
356
+        } catch (final InstantiationException ex) {
341 357
             Logger.userError(ErrorLevel.LOW, "Unable to set UI Settings");
342
-        } catch (ClassNotFoundException ex) {
358
+        } catch (final ClassNotFoundException ex) {
343 359
             Logger.userError(ErrorLevel.LOW, "Unable to set UI Settings");
344 360
         }
345 361
 
@@ -357,8 +373,7 @@ public class SwingController extends BasePlugin implements UIController {
357 373
             /** {@inheritDoc} */
358 374
             @Override
359 375
             public void run() {
360
-                URLDialog.showURLDialog(url, getMainFrame(), getURLHandler());
361
-
376
+                showDialog(URLDialog.class, url, getURLHandler());
362 377
             }
363 378
         });
364 379
     }
@@ -384,8 +399,8 @@ public class SwingController extends BasePlugin implements UIController {
384 399
             /** {@inheritDoc} */
385 400
             @Override
386 401
             public void run() {
387
-                new StandardMessageDialog(getMainFrame(), ModalityType.MODELESS,
388
-                        title, message).display();
402
+                new StandardMessageDialog(SwingController.this, getMainFrame(),
403
+                        ModalityType.MODELESS, title, message).display();
389 404
             }
390 405
         });
391 406
     }
@@ -444,7 +459,7 @@ public class SwingController extends BasePlugin implements UIController {
444 459
                 getMainFrame().setVisible(true);
445 460
                 mainFrameCreated.set(true);
446 461
                 swingStatusBar = getMainFrame().getStatusBar();
447
-                errorDialog = new ErrorListDialog(getMainFrame());
462
+                errorDialog = new ErrorListDialog(SwingController.this);
448 463
                 StatusBarManager.getStatusBarManager().registerStatusBar(
449 464
                         getSwingStatusBar());
450 465
             }
@@ -471,7 +486,7 @@ public class SwingController extends BasePlugin implements UIController {
471 486
         eventQueue.pop();
472 487
         KeyboardFocusManager.getCurrentKeyboardFocusManager().
473 488
                 removeKeyEventDispatcher(keyListener);
474
-        for (java.awt.Window window : getTopLevelWindows()) {
489
+        for (final java.awt.Window window : getTopLevelWindows()) {
475 490
             window.dispose();
476 491
         }
477 492
         super.onUnload();
@@ -492,7 +507,7 @@ public class SwingController extends BasePlugin implements UIController {
492 507
      * @return Swing prefs dialog
493 508
      */
494 509
     public SwingPreferencesDialog getPrefsDialog() {
495
-        return SwingPreferencesDialog.getSwingPreferencesDialog(this);
510
+        return getDialogManager().getDialog(SwingPreferencesDialog.class);
496 511
     }
497 512
 
498 513
     /** {@inheritDoc} */
@@ -530,7 +545,7 @@ public class SwingController extends BasePlugin implements UIController {
530 545
         final LookAndFeelInfo[] plaf = UIManager.getInstalledLookAndFeels();
531 546
 
532 547
         lafs.put("Native", "Native");
533
-        for (LookAndFeelInfo laf : plaf) {
548
+        for (final LookAndFeelInfo laf : plaf) {
534 549
             lafs.put(laf.getName(), laf.getName());
535 550
         }
536 551
 

+ 1
- 1
src/com/dmdirc/addons/ui_swing/cinch/ConfirmAction.java View File

@@ -139,7 +139,7 @@ public @interface ConfirmAction {
139 139
                 /** {@inheritDoc} */
140 140
                 @Override
141 141
                 public void actionPerformed(final ActionEvent e) {
142
-                    new StandardQuestionDialog(
142
+                    new StandardQuestionDialog(null,
143 143
                             (Window) ((AbstractButton) actionObject)
144 144
                             .getTopLevelAncestor(), ModalityType.DOCUMENT_MODAL,
145 145
                             "Confirmaton", message) {

+ 6
- 7
src/com/dmdirc/addons/ui_swing/cinch/InputAction.java View File

@@ -27,7 +27,6 @@ import com.dmdirc.util.validators.PermissiveValidator;
27 27
 import com.dmdirc.util.validators.Validator;
28 28
 
29 29
 import com.google.common.collect.ImmutableList;
30
-
31 30
 import com.palantir.ptoss.cinch.core.Bindable;
32 31
 import com.palantir.ptoss.cinch.core.BindableModel;
33 32
 import com.palantir.ptoss.cinch.core.Binding;
@@ -116,12 +115,12 @@ public @interface InputAction {
116 115
         @Override
117 116
         public Collection<Binding> wire(final BindingContext context) {
118 117
             final List<Field> actions = context.getAnnotatedFields(InputAction.class);
119
-            for (Field field : actions) {
118
+            for (final Field field : actions) {
120 119
                 final InputAction action = field.getAnnotation(InputAction.class);
121 120
                 try {
122 121
                     wire(action.call(), action.message(), action.content(),
123 122
                             action.validator(), field, context);
124
-                } catch (Exception e) {
123
+                } catch (final Exception e) {
125 124
                     Throwables.throwUncheckedException(e);
126 125
                     throw new BindingException("could not wire up "
127 126
                             + "@InputAction on " + field.getName(), e);
@@ -180,7 +179,7 @@ public @interface InputAction {
180 179
             final Validator<String> validatorInstance;
181 180
             final Constructor<?> ctor = validator.getConstructor(
182 181
                     BindableModel.class);
183
-            validatorInstance = (Validator) ctor.newInstance(
182
+            validatorInstance = (Validator<String>) ctor.newInstance(
184 183
                     context.getBindableModels().toArray()[0]);
185 184
             aalMethod.invoke(actionObject, new ActionListener() {
186 185
 
@@ -208,10 +207,10 @@ public @interface InputAction {
208 207
                                 ofm.getMethod().setAccessible(true);
209 208
                                 ofm.getMethod().invoke(ofm.getObject(), getText());
210 209
                                 ofm.getMethod().setAccessible(accessible);
211
-                            } catch (InvocationTargetException itex) {
210
+                            } catch (final InvocationTargetException itex) {
212 211
                                 LOGGER.error("exception during action firing",
213 212
                                         itex.getCause());
214
-                            } catch (Exception ex) {
213
+                            } catch (final Exception ex) {
215 214
                                 LOGGER.error("exception during action firing", ex);
216 215
                             }
217 216
                             return true;
@@ -232,7 +231,7 @@ public @interface InputAction {
232 231
                                             .invoke(existingMethod.getObject());
233 232
                                     existingMethod.getMethod()
234 233
                                             .setAccessible(accessible);
235
-                                } catch (Exception e) {
234
+                                } catch (final Exception e) {
236 235
                                     content = "";
237 236
                                 }
238 237
                             } else {

+ 4
- 7
src/com/dmdirc/addons/ui_swing/components/MDIBar.java View File

@@ -28,9 +28,7 @@ import com.dmdirc.addons.ui_swing.SwingController;
28 28
 import com.dmdirc.addons.ui_swing.SwingWindowListener;
29 29
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
30 30
 import com.dmdirc.config.ConfigManager;
31
-import com.dmdirc.config.IdentityManager;
32 31
 import com.dmdirc.interfaces.ConfigChangeListener;
33
-import com.dmdirc.ui.IconManager;
34 32
 
35 33
 import java.awt.event.ActionEvent;
36 34
 import java.awt.event.ActionListener;
@@ -75,13 +73,12 @@ public class MDIBar extends JPanel implements SwingWindowListener,
75 73
         super();
76 74
 
77 75
         this.mainFrame = mainFrame;
78
-        this.config = IdentityManager.getGlobalConfig();
79
-        this.configDomain = controller.getDomain();
76
+        config = controller.getGlobalConfig();
77
+        configDomain = controller.getDomain();
80 78
         visibility = config.getOptionBool(configDomain, "mdiBarVisibility");
81 79
 
82
-        closeButton = new NoFocusButton(new IconManager(IdentityManager
83
-                .getGlobalConfig()).getScaledIcon("close-12", ICON_SIZE,
84
-                ICON_SIZE));
80
+        closeButton = new NoFocusButton(controller.getIconManager()
81
+                .getScaledIcon("close-12", ICON_SIZE,ICON_SIZE));
85 82
 
86 83
         setOpaque(false);
87 84
         setLayout(new MigLayout("hmax 17, ins 1 0 0 0, fill"));

+ 0
- 6
src/com/dmdirc/addons/ui_swing/components/SearchValidator.java View File

@@ -29,12 +29,6 @@ import com.dmdirc.util.validators.Validator;
29 29
  */
30 30
 public class SearchValidator implements Validator<String> {
31 31
 
32
-    /**
33
-     * A version number for this class. It should be changed whenever the
34
-     * class structure is changed (or anything else that would prevent
35
-     * serialized objects being unserialized with the new class).
36
-     */
37
-    private static final long serialVersionUID = 1;
38 32
     /** Validates. */
39 33
     private boolean validates = true;
40 34
 

+ 13
- 14
src/com/dmdirc/addons/ui_swing/components/SendWorker.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.components;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
26
-import com.dmdirc.config.IdentityManager;
27 26
 import com.dmdirc.util.io.Downloader;
28 27
 
29 28
 import java.io.IOException;
@@ -35,22 +34,22 @@ import java.util.Map;
35 34
 /**
36 35
  * Sends feedback worker thread.
37 36
  */
38
-public class SendWorker extends LoggingSwingWorker {
37
+public class SendWorker extends LoggingSwingWorker<Object, Void> {
39 38
 
40 39
     /** Parent feedback dialog. */
41
-    private FeedbackDialog dialog;
40
+    private final FeedbackDialog dialog;
42 41
     /** Name. */
43
-    private String name;
42
+    private final String name;
44 43
     /** Email. */
45
-    private String email;
44
+    private final String email;
46 45
     /** Feedback. */
47
-    private String feedback;
46
+    private final String feedback;
48 47
     /** Server name. */
49
-    private String serverInfo;
48
+    private final String serverInfo;
50 49
     /** DMDirc Info. */
51
-    private String dmdircInfo;
50
+    private final String dmdircInfo;
52 51
     /** Error/Success message. */
53
-    private StringBuilder error;
52
+    private final StringBuilder error;
54 53
 
55 54
     /**
56 55
      * Creates a new send worker to send feedback.
@@ -105,8 +104,8 @@ public class SendWorker extends LoggingSwingWorker {
105 104
         if (!feedback.isEmpty()) {
106 105
             postData.put("feedback", feedback);
107 106
         }
108
-        postData.put("version", IdentityManager.getGlobalConfig().getOption(
109
-                "version", "version"));
107
+        postData.put("version", dialog.getController().getGlobalConfig()
108
+                .getOption("version", "version"));
110 109
         if (!serverInfo.isEmpty()) {
111 110
             postData.put("serverInfo", serverInfo);
112 111
         }
@@ -131,15 +130,15 @@ public class SendWorker extends LoggingSwingWorker {
131 130
                     Downloader.getPage("http://www.dmdirc.com/feedback.php",
132 131
                     postData);
133 132
             if (response.size() >= 1) {
134
-                for (String responseLine : response) {
133
+                for (final String responseLine : response) {
135 134
                     error.append(responseLine).append("\n");
136 135
                 }
137 136
             } else {
138 137
                 error.append("Failure: Unknown response from the server.");
139 138
             }
140
-        } catch (MalformedURLException ex) {
139
+        } catch (final MalformedURLException ex) {
141 140
             error.append("Malformed feedback URL.");
142
-        } catch (IOException ex) {
141
+        } catch (final IOException ex) {
143 142
             error.append("Failure: ").append(ex.getMessage());
144 143
         }
145 144
     }

+ 0
- 1
src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java View File

@@ -30,7 +30,6 @@ import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
30 30
 import com.dmdirc.addons.ui_swing.textpane.TextPane;
31 31
 import com.dmdirc.interfaces.ConfigChangeListener;
32 32
 import com.dmdirc.interfaces.ui.SearchBar;
33
-import com.dmdirc.interfaces.ui.SearchBar.Direction;
34 33
 import com.dmdirc.ui.messages.IRCDocument;
35 34
 import com.dmdirc.ui.messages.IRCDocumentSearcher;
36 35
 import com.dmdirc.ui.messages.LinePosition;

+ 6
- 11
src/com/dmdirc/addons/ui_swing/components/ToolTipPanel.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.ui_swing.components;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
-import com.dmdirc.config.IdentityManager;
28 27
 import com.dmdirc.ui.IconManager;
29 28
 
30 29
 import java.awt.Color;
@@ -51,11 +50,7 @@ import org.jdesktop.jxlayer.plaf.LayerUI;
51 50
  */
52 51
 public class ToolTipPanel extends JPanel implements MouseListener {
53 52
 
54
-    /**
55
-     * A version number for this class. It should be changed whenever the
56
-     * class structure is changed (or anything else that would prevent
57
-     * serialized objects being unserialized with the new class).
58
-     */
53
+    /** Serial version UID. */
59 54
     private static final long serialVersionUID = -8929794537312606692L;
60 55
     /** Default tool tip. */
61 56
     private final String defaultHelp;
@@ -71,15 +66,15 @@ public class ToolTipPanel extends JPanel implements MouseListener {
71 66
     /**
72 67
      * Instantiates a new tool tip panel.
73 68
      *
69
+     * @param iconManager Icon Manager
74 70
      * @param helpText Default help message when idle
75 71
      */
76
-    public ToolTipPanel(final String helpText) {
72
+    public ToolTipPanel(final IconManager iconManager, final String helpText) {
77 73
         super(new MigLayout("hidemode 3"));
78 74
 
79 75
         defaultHelp = helpText;
80
-        this.tooltips = new HashMap<JComponent, String>();
81
-        this.icon = new JLabel(new IconManager(IdentityManager
82
-                .getGlobalConfig()).getIcon("warning"));
76
+        tooltips = new HashMap<JComponent, String>();
77
+        icon = new JLabel(iconManager.getIcon("warning"));
83 78
 
84 79
         setBackground(Color.WHITE);
85 80
         setForeground(Color.BLACK);
@@ -241,7 +236,7 @@ public class ToolTipPanel extends JPanel implements MouseListener {
241 236
     @Override
242 237
     public void mouseEntered(final MouseEvent e) {
243 238
         if (e.getSource() instanceof JComponent) {
244
-            setText(tooltips.get((JComponent) e.getSource()));
239
+            setText(tooltips.get(e.getSource()));
245 240
         }
246 241
     }
247 242
 

+ 13
- 17
src/com/dmdirc/addons/ui_swing/components/TopicBar.java View File

@@ -28,10 +28,9 @@ import com.dmdirc.addons.ui_swing.SwingController;
28 28
 import com.dmdirc.addons.ui_swing.UIUtilities;
29 29
 import com.dmdirc.addons.ui_swing.actions.ReplacePasteAction;
30 30
 import com.dmdirc.addons.ui_swing.components.frames.ChannelFrame;
31
-import com.dmdirc.addons.ui_swing.components.inputfields.TextPaneInputField;
32 31
 import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputHandler;
32
+import com.dmdirc.addons.ui_swing.components.inputfields.TextPaneInputField;
33 33
 import com.dmdirc.addons.ui_swing.components.text.WrapEditorKit;
34
-import com.dmdirc.config.IdentityManager;
35 34
 import com.dmdirc.interfaces.ConfigChangeListener;
36 35
 import com.dmdirc.interfaces.TopicChangeListener;
37 36
 import com.dmdirc.parser.common.ChannelJoinRequest;
@@ -69,11 +68,7 @@ public class TopicBar extends JComponent implements ActionListener,
69 68
         ConfigChangeListener, HyperlinkListener, MouseListener,
70 69
         DocumentListener, TopicChangeListener {
71 70
 
72
-    /**
73
-     * A version number for this class. It should be changed whenever the class
74
-     * structure is changed (or anything else that would prevent serialized
75
-     * objects being unserialized with the new class).
76
-     */
71
+    /** Serial version UID. */
77 72
     private static final long serialVersionUID = 1;
78 73
     /** Topic text. */
79 74
     private final TextPaneInputField topicText;
@@ -106,9 +101,10 @@ public class TopicBar extends JComponent implements ActionListener,
106 101
             final ChannelFrame channelFrame) {
107 102
         super();
108 103
 
109
-        this.channel = (Channel) channelFrame.getContainer();
104
+        channel = (Channel) channelFrame.getContainer();
110 105
         controller = channelFrame.getController();
111
-        topicText = new TextPaneInputField(parentWindow);
106
+        topicText = new TextPaneInputField(channelFrame.getController(),
107
+                parentWindow);
112 108
         topicLengthMax = channel.getMaxTopicLength();
113 109
         errorIcon = new JLabel(channelFrame.getIconManager()
114 110
                 .getIcon("input-error"));
@@ -119,10 +115,10 @@ public class TopicBar extends JComponent implements ActionListener,
119 115
 
120 116
         topicText.getActionMap().put("paste-from-clipboard",
121 117
                 new ReplacePasteAction("(\r\n|\n|\r)", " "));
122
-        topicEdit = new ImageButton("edit",
118
+        topicEdit = new ImageButton<Object>("edit",
123 119
                 channelFrame.getIconManager().getIcon("edit-inactive"),
124 120
                 channelFrame.getContainer().getIconManager().getIcon("edit"));
125
-        topicCancel = new ImageButton("cancel",
121
+        topicCancel = new ImageButton<Object>("cancel",
126 122
                 channelFrame.getIconManager().getIcon("close"),
127 123
                 channelFrame.getIconManager().getIcon("close-active"));
128 124
 
@@ -184,17 +180,17 @@ public class TopicBar extends JComponent implements ActionListener,
184 180
         topicText.addHyperlinkListener(this);
185 181
         topicText.addMouseListener(this);
186 182
         topicText.getDocument().addDocumentListener(this);
187
-        IdentityManager.getGlobalConfig().addChangeListener(
183
+        controller.getGlobalConfig().addChangeListener(
188 184
                 "ui", "backgroundcolour", this);
189
-        IdentityManager.getGlobalConfig().addChangeListener(
185
+        controller.getGlobalConfig().addChangeListener(
190 186
                 "ui", "foregroundcolour", this);
191
-        IdentityManager.getGlobalConfig().addChangeListener(
187
+        controller.getGlobalConfig().addChangeListener(
192 188
                 "ui", "inputbackgroundcolour", this);
193
-        IdentityManager.getGlobalConfig().addChangeListener(
189
+        controller.getGlobalConfig().addChangeListener(
194 190
                 "ui", "inputforegroundcolour", this);
195
-        IdentityManager.getGlobalConfig().addChangeListener(
191
+        controller.getGlobalConfig().addChangeListener(
196 192
                 controller.getDomain(), "showfulltopic", this);
197
-        IdentityManager.getGlobalConfig().addChangeListener(
193
+        controller.getGlobalConfig().addChangeListener(
198 194
                 controller.getDomain(), "hideEmptyTopicBar", this);
199 195
 
200 196
         topicText.setFocusable(false);

+ 24
- 21
src/com/dmdirc/addons/ui_swing/components/URLProtocolPanel.java View File

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.dialogs.url.URLSubsitutionsPanel;
26
-import com.dmdirc.config.IdentityManager;
27 27
 import com.dmdirc.ui.core.util.URLHandler;
28 28
 
29 29
 import java.awt.event.ActionEvent;
@@ -51,12 +51,14 @@ import net.miginfocom.swing.MigLayout;
51 51
 public class URLProtocolPanel extends JPanel implements ActionListener,
52 52
         DocumentListener {
53 53
 
54
-    /**
55
-     * A version number for this class. It should be changed whenever the class
56
-     * structure is changed (or anything else that would prevent serialized
57
-     * objects being unserialized with the new class).
58
-     */
54
+    /** Serial version UID. */
59 55
     private static final long serialVersionUID = 1;
56
+    /** Swing controller. */
57
+    private final SwingController controller;
58
+    /** URL. */
59
+    private final URI uri;
60
+    /** Show insets? */
61
+    private final boolean useInsets;
60 62
     /** Show file chooser. */
61 63
     private JButton showFileChooser;
62 64
     /** Command text field. */
@@ -75,23 +77,22 @@ public class URLProtocolPanel extends JPanel implements ActionListener,
75 77
     private JLabel subsLabel;
76 78
     /** example label. */
77 79
     private JLabel exampleLabel;
78
-    /** URL. */
79
-    private final URI uri;
80
-    /** Show insets? */
81
-    private final boolean useInsets;
82 80
     /** Substitutions panel. */
83 81
     private URLSubsitutionsPanel subsPanel;
84 82
 
85 83
     /**
86 84
      * Instantiates the URLDialog.
87 85
      *
86
+     * @param controller Swing controller
88 87
      * @param url URL to open once added
89 88
      * @param useInsets Show insets?
90 89
      */
91
-    public URLProtocolPanel(final URI url, final boolean useInsets) {
90
+    public URLProtocolPanel(final SwingController controller, final URI url,
91
+            final boolean useInsets) {
92 92
         super();
93 93
 
94
-        this.uri = url;
94
+        this.controller = controller;
95
+        uri = url;
95 96
         this.useInsets = useInsets;
96 97
 
97 98
         initComponents();
@@ -123,9 +124,11 @@ public class URLProtocolPanel extends JPanel implements ActionListener,
123 124
         optionType.add(mail);
124 125
         optionType.add(custom);
125 126
 
126
-        subsPanel = new URLSubsitutionsPanel(Arrays.asList(new String[]{"url",
127
-            "fragment", "host", "path", "port", "query", "protocol", "username",
128
-            "password"
127
+        subsPanel = new URLSubsitutionsPanel(Arrays.asList(new String[] {
128
+                "url",
129
+                "fragment", "host", "path", "port", "query", "protocol",
130
+                "username",
131
+                "password"
129 132
         }));
130 133
         subsPanel.setVisible(custom.isSelected());
131 134
 
@@ -163,7 +166,7 @@ public class URLProtocolPanel extends JPanel implements ActionListener,
163 166
 
164 167
     /** Saves the settings. */
165 168
     public void save() {
166
-        IdentityManager.getConfigIdentity().setOption("protocol",
169
+        controller.getGlobalIdentity().setOption("protocol",
167 170
                 uri.getScheme().toLowerCase(), getSelection());
168 171
     }
169 172
 
@@ -203,11 +206,11 @@ public class URLProtocolPanel extends JPanel implements ActionListener,
203 206
      * Updates the selection.
204 207
      */
205 208
     public void updateSelection() {
206
-        if (uri != null && IdentityManager.getGlobalConfig().hasOptionString(
209
+        if (uri != null && controller.getGlobalConfig().hasOptionString(
207 210
                 "protocol", uri.getScheme())) {
208 211
             final String option =
209
-                    IdentityManager.getGlobalConfig().getOption("protocol",
210
-                    uri.getScheme());
212
+                    controller.getGlobalConfig().getOption("protocol",
213
+                            uri.getScheme());
211 214
 
212 215
             if ("DMDIRC".equals(option)) {
213 216
                 optionType.setSelected(dmdirc.getModel(), true);
@@ -250,7 +253,7 @@ public class URLProtocolPanel extends JPanel implements ActionListener,
250 253
             fileChooser.addChoosableFileFilter(new ExecutableFileFilter());
251 254
             fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
252 255
             if (fileChooser.showDialog(this, "Select")
253
-                    == JFileChooser.APPROVE_OPTION) {
256
+                == JFileChooser.APPROVE_OPTION) {
254 257
                 commandPath.setText(fileChooser.getSelectedFile().toString());
255 258
             }
256 259
         } else {
@@ -285,6 +288,6 @@ public class URLProtocolPanel extends JPanel implements ActionListener,
285 288
     /** {@inheritDoc} */
286 289
     @Override
287 290
     public void changedUpdate(final DocumentEvent e) {
288
-        //Ignore
291
+        // Ignore
289 292
     }
290 293
 }

+ 0
- 1
src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonFilter.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.addons.ui_swing.components.addonbrowser;
25 25
 import javax.swing.ButtonModel;
26 26
 import javax.swing.JTextField;
27 27
 import javax.swing.RowFilter;
28
-import javax.swing.RowFilter.Entry;
29 28
 import javax.swing.table.DefaultTableModel;
30 29
 
31 30
 /**

+ 69
- 135
src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfo.java View File

@@ -22,7 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
-import com.dmdirc.config.IdentityManager;
25
+import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.interfaces.actions.ActionType;
26 27
 import com.dmdirc.updater.UpdateChannel;
27 28
 import com.dmdirc.updater.UpdateChecker;
28 29
 import com.dmdirc.updater.UpdateComponent;
@@ -33,22 +34,60 @@ import java.util.Map;
33 34
 
34 35
 import javax.swing.ImageIcon;
35 36
 
37
+import lombok.Getter;
38
+
36 39
 /**
37 40
  * Describes an addon.
38 41
  */
42
+@SuppressWarnings("PMD.UnusedPrivateField")
39 43
 public class AddonInfo {
44
+    /** Addon site ID. */
45
+    @Getter
40 46
     private final int id;
47
+    /**
48
+     * Stable download name. This should be prepended with
49
+     * http://addons.dmdirc.com/addondownload/ to get a full URL.
50
+     */
51
+    @Getter
41 52
     private final String stableDownload;
53
+    /**
54
+     * Stable download name. This should be prepended with
55
+     * http://addons.dmdirc.com/addondownload/ to get a full URL.
56
+     */
57
+    @Getter
42 58
     private final String unstableDownload;
59
+    /**
60
+     * Stable download name. This should be prepended with
61
+     * http://addons.dmdirc.com/addondownload/ to get a full URL.
62
+     */
63
+    @Getter
43 64
     private final String nightlyDownload;
65
+    /** Addon title. */
66
+    @Getter
44 67
     private final String title;
68
+    /** Addon author and email. */
69
+    @Getter
45 70
     private final String author;
71
+    /** Addon rating from 0-10. */
72
+    @Getter
46 73
     private final int rating;
74
+    /** Full text description. */
75
+    @Getter
47 76
     private final String description;
77
+    /** Addon type, {@link ActionType}. */
78
+    @Getter
48 79
     private final AddonType type;
80
+    /** Has this addon been verified by the developers? */
81
+    @Getter
49 82
     private final boolean verified;
83
+    /** Date this addon was updated. */
84
+    @Getter
50 85
     private final int date;
86
+    /** Screenshot image. */
87
+    @Getter
51 88
     private final ImageIcon screenshot;
89
+    /** Current client update channel. */
90
+    @Getter
52 91
     private UpdateChannel channel;
53 92
 
54 93
     /**
@@ -56,152 +95,47 @@ public class AddonInfo {
56 95
      *
57 96
      * @param entry List of entries
58 97
      */
59
-    public AddonInfo(final Map<String, String> entry) {
60
-        this.id = Integer.parseInt(entry.get("id"));
61
-        this.title = entry.get("title");
62
-        this.author = entry.get("user");
63
-        this.rating = Integer.parseInt(entry.get("rating"));
64
-        this.type = entry.get("type").equals("plugin") ?
65
-            AddonType.TYPE_PLUGIN : entry.get("type").equals("theme") ?
66
-                AddonType.TYPE_THEME : AddonType.TYPE_ACTION_PACK;
67
-        this.stableDownload = entry.containsKey("stable") ? entry.get("stable") : "";
68
-        this.unstableDownload = entry.containsKey("unstable") ? entry.get("unstable") : "";
69
-        this.nightlyDownload = entry.containsKey("nightly") ? entry.get("nightly") : "";
70
-        this.description = entry.get("description");
71
-        this.verified = entry.get("verified").equals("yes");
72
-        this.date = Integer.parseInt(entry.get("date"));
98
+    public AddonInfo(final ConfigManager configManager,
99
+            final Map<String, String> entry) {
100
+        id = Integer.parseInt(entry.get("id"));
101
+        title = entry.get("title");
102
+        author = entry.get("user");
103
+        rating = Integer.parseInt(entry.get("rating"));
104
+        type = entry.get("type").equals("plugin") ?
105
+                AddonType.TYPE_PLUGIN : entry.get("type").equals("theme") ?
106
+                        AddonType.TYPE_THEME : AddonType.TYPE_ACTION_PACK;
107
+        stableDownload = entry.containsKey("stable") ? entry.get("stable") : "";
108
+        unstableDownload = entry.containsKey("unstable") ? entry
109
+                .get("unstable") : "";
110
+        nightlyDownload = entry.containsKey("nightly") ? entry.get("nightly")
111
+                : "";
112
+        description = entry.get("description");
113
+        verified = entry.get("verified").equals("yes");
114
+        date = Integer.parseInt(entry.get("date"));
73 115
         if (entry.get("screenshot").equals("yes")) {
74
-            this.screenshot = new ImageIcon(URLBuilder.buildURL(
116
+            screenshot = new ImageIcon(URLBuilder.buildURL(
75 117
                     "http://addons.dmdirc.com/addonimg/" + id));
76
-            this.screenshot.setImage(this.screenshot.getImage().
77
-                   getScaledInstance(150, 150, Image.SCALE_SMOOTH));
118
+            screenshot.setImage(screenshot.getImage().
119
+                    getScaledInstance(150, 150, Image.SCALE_SMOOTH));
78 120
         } else {
79
-            this.screenshot = new ImageIcon(URLBuilder.buildURL(
121
+            screenshot = new ImageIcon(URLBuilder.buildURL(
80 122
                     "dmdirc://com/dmdirc/res/logo.png"));
81 123
         }
82 124
         try {
83
-            channel = UpdateChannel.valueOf(IdentityManager.getGlobalConfig()
84
-                    .getOption("updater", "channel"));
85
-        } catch (IllegalArgumentException ex) {
125
+            channel = UpdateChannel.valueOf(configManager.getOption(
126
+                    "updater", "channel"));
127
+        } catch (final IllegalArgumentException ex) {
86 128
             channel = UpdateChannel.NONE;
87 129
         }
88 130
     }
89 131
 
90
-    /**
91
-     * Returns the addon author.
92
-     *
93
-     * @return Addon author
94
-     */
95
-    public String getAuthor() {
96
-        return author;
97
-    }
98
-
99
-    /**
100
-     * Returns the addon date.
101
-     *
102
-     * @return Addon date
103
-     */
104
-    public int getDate() {
105
-        return date;
106
-    }
107
-
108
-    /**
109
-     * Returns the addon description.
110
-     *
111
-     * @return Addon description
112
-     */
113
-    public String getDescription() {
114
-        return description;
115
-    }
116
-
117
-    /**
118
-     * Returns the addon ID.
119
-     *
120
-     * @return Addon ID
121
-     */
122
-    public int getId() {
123
-        return id;
124
-    }
125
-
126
-    /**
127
-     * Returns the addon rating.
128
-     *
129
-     * @return Addon rating
130
-     */
131
-    public int getRating() {
132
-        return rating;
133
-    }
134
-
135
-    /**
136
-     * Returns the stable download location.
137
-     *
138
-     * @return Stable download location
139
-     */
140
-    public String getStableDownload() {
141
-        return stableDownload;
142
-    }
143
-
144
-    /**
145
-     * Returns the addon title.
146
-     *
147
-     * @return Addon title
148
-     */
149
-    public String getTitle() {
150
-        return title;
151
-    }
152
-
153
-    /**
154
-     * Returns the addon type.
155
-     *
156
-     * @return Addon type
157
-     */
158
-    public AddonType getType() {
159
-        return type;
160
-    }
161
-
162
-    /**
163
-     * Returns the unstable download location.
164
-     *
165
-     * @return Unstable download location
166
-     */
167
-    public String getUnstableDownload() {
168
-        return unstableDownload;
169
-    }
170
-
171
-    /**
172
-     * Returns the nightly download location.
173
-     *
174
-     * @return Nightly download location
175
-     */
176
-    public String getNightlyDownload() {
177
-        return nightlyDownload;
178
-    }
179
-
180
-    /**
181
-     * Returns whether the addon is verified.
182
-     *
183
-     * @return true iff the addon is verified
184
-     */
185
-    public boolean isVerified() {
186
-        return verified;
187
-    }
188
-
189
-    /**
190
-     * Returns the screen shot for the addon.
191
-     *
192
-     * @return Addon screenshot
193
-     */
194
-    public ImageIcon getScreenshot() {
195
-        return screenshot;
196
-    }
197
-
198 132
     /**
199 133
      * Is the plugin installed?
200 134
      *
201 135
      * @return true iff installed
202 136
      */
203 137
     public boolean isInstalled() {
204
-        for (UpdateComponent comp : UpdateChecker.getComponents()) {
138
+        for (final UpdateComponent comp : UpdateChecker.getComponents()) {
205 139
             if (comp.getName().equals("addon-" + getId())) {
206 140
                 return true;
207 141
             }
@@ -226,19 +160,19 @@ public class AddonInfo {
226 160
      */
227 161
     @SuppressWarnings("fallthrough")
228 162
     public String getDownload() {
229
-        switch (channel) { //NOPMD
163
+        switch (channel) { // NOPMD
230 164
             case NONE:
231
-                //fallthrough
165
+                // fallthrough
232 166
             case NIGHTLY:
233 167
                 if (!nightlyDownload.isEmpty()) {
234 168
                     return nightlyDownload;
235 169
                 }
236
-                //fallthrough
170
+                // fallthrough
237 171
             case UNSTABLE:
238 172
                 if (!unstableDownload.isEmpty()) {
239 173
                     return unstableDownload;
240 174
                 }
241
-                //fallthrough
175
+                // fallthrough
242 176
             case STABLE:
243 177
                 if (!stableDownload.isEmpty()) {
244 178
                     return stableDownload;

+ 0
- 7
src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfoCellRenderer.java View File

@@ -36,13 +36,6 @@ import javax.swing.table.TableCellRenderer;
36 36
  */
37 37
 public class AddonInfoCellRenderer implements TableCellRenderer {
38 38
 
39
-    /**
40
-     * A version number for this class. It should be changed whenever the class
41
-     * structure is changed (or anything else that would prevent serialized
42
-     * objects being unserialized with the new class).
43
-     */
44
-    private static final long serialVersionUID = 1;
45
-
46 39
     /**
47 40
      * {@inheritDoc}
48 41
      *

+ 9
- 3
src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfoLabel.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26 27
 
27 28
 import java.awt.Color;
@@ -50,17 +51,21 @@ public class AddonInfoLabel extends JPanel {
50 51
     private final AddonInfo addonInfo;
51 52
     /** Parent window. */
52 53
     private final BrowserWindow parentWindow;
54
+    /** Swing controller. */
55
+    private final SwingController controller;
53 56
 
54 57
     /**
55 58
      * Creates a new addon info label to describe the specified addon info.
56 59
      *
60
+     * @param controller Swing controller
57 61
      * @param addonInfo Addon to describe
58 62
      * @param parentWindow Parent window
59 63
      */
60
-    public AddonInfoLabel(final AddonInfo addonInfo,
61
-            final BrowserWindow parentWindow) {
64
+    public AddonInfoLabel(final SwingController controller,
65
+            final AddonInfo addonInfo, final BrowserWindow parentWindow) {
62 66
         super();
63 67
 
68
+        this.controller = controller;
64 69
         this.addonInfo = addonInfo;
65 70
         this.parentWindow = parentWindow;
66 71
 
@@ -90,7 +95,8 @@ public class AddonInfoLabel extends JPanel {
90 95
                 "wmax 100%-170, hmax 150, growy, wrap, pushy, gapleft 5");
91 96
 
92 97
         final JButton button = new JButton("Install");
93
-        button.addActionListener(new InstallListener(addonInfo, parentWindow));
98
+        button.addActionListener(new InstallListener(controller, addonInfo,
99
+                parentWindow));
94 100
         final boolean installed = addonInfo.isInstalled();
95 101
         add(button, "split, gapleft 5");
96 102
 

+ 9
- 2
src/com/dmdirc/addons/ui_swing/components/addonbrowser/BrowserWindow.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
26
+
25 27
 import java.awt.Window;
26 28
 import java.awt.event.ActionEvent;
27 29
 import java.awt.event.ActionListener;
@@ -83,14 +85,19 @@ public class BrowserWindow extends JDialog implements ActionListener {
83 85
     private final JRadioButton statusButton = new JRadioButton("Status", false);
84 86
     /** Row sorter. */
85 87
     private final AddonSorter sorter;
88
+    /** Swing controller. */
89
+    private final SwingController controller;
86 90
 
87 91
     /**
88 92
      * Creates and displays a new browser window.
89 93
      *
94
+     * @param controller Swing controller
90 95
      * @param parentWindow Parent window
91 96
      */
92
-    public BrowserWindow(final Window parentWindow) {
97
+    public BrowserWindow(final SwingController controller,
98
+            final Window parentWindow) {
93 99
         super(parentWindow, "DMDirc Addon Browser", ModalityType.MODELESS);
100
+        this.controller = controller;
94 101
         setIconImages(parentWindow.getIconImages());
95 102
         setResizable(false);
96 103
         setLayout(new MigLayout("fill, wmin 650, hmin 600"));
@@ -188,7 +195,7 @@ public class BrowserWindow extends JDialog implements ActionListener {
188 195
      * @param download Download new addon feed?
189 196
      */
190 197
     public final void loadData(final boolean download) {
191
-        new DataLoaderWorker(list, download, this, scrollPane)
198
+        new DataLoaderWorker(controller, list, download, this, scrollPane)
192 199
                 .executeInExecutor();
193 200
     }
194 201
 

+ 16
- 10
src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.addons.ui_swing.SwingController;
26 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
27 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28 29
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
@@ -67,19 +68,24 @@ public class DataLoaderWorker
67 68
     private final JProgressBar jpb = new JProgressBar(0, 100);
68 69
     /** Refresh addons feed? */
69 70
     private final boolean download;
71
+    /** Swing controller. */
72
+    private final SwingController controller;
70 73
 
71 74
     /**
72 75
      * Creates a new data loader worker.
73 76
      *
77
+     * @param controller Swing controller
74 78
      * @param table Table to load data into
75 79
      * @param download Download new addons feed?
76 80
      * @param browserWindow Browser window to pass to table objects
77 81
      * @param scrollPane Table's parent scrollpane
78 82
      */
79
-    public DataLoaderWorker(final AddonTable table, final boolean download,
83
+    public DataLoaderWorker(final SwingController controller,
84
+            final AddonTable table, final boolean download,
80 85
             final BrowserWindow browserWindow, final JScrollPane scrollPane) {
81 86
         super();
82 87
 
88
+        this.controller = controller;
83 89
         this.download = download;
84 90
         this.table = table;
85 91
         this.browserWindow = browserWindow;
@@ -104,7 +110,7 @@ public class DataLoaderWorker
104 110
                 Downloader.downloadPage("http://addons.dmdirc.com/feed",
105 111
                         Main.getConfigDir() + File.separator + "addons.feed",
106 112
                         this);
107
-            } catch (IOException ex) {
113
+            } catch (final IOException ex) {
108 114
                 loadingPanel.removeAll();
109 115
                 loadingPanel.add(new TextLabel("Unable to download feeds."));
110 116
                 return Collections.<AddonInfo>emptyList();
@@ -117,15 +123,15 @@ public class DataLoaderWorker
117 123
                 + File.separator + "addons.feed");
118 124
         try {
119 125
             data.read();
120
-        } catch (IOException ex) {
126
+        } catch (final IOException ex) {
121 127
             return Collections.<AddonInfo>emptyList();
122
-        } catch (InvalidConfigFileException ex) {
128
+        } catch (final InvalidConfigFileException ex) {
123 129
             return Collections.<AddonInfo>emptyList();
124 130
         }
125 131
 
126 132
         final List<AddonInfo> list = new ArrayList<AddonInfo>();
127
-        for (Map<String, String> entry : data.getKeyDomains().values()) {
128
-            list.add(new AddonInfo(entry));
133
+        for (final Map<String, String> entry : data.getKeyDomains().values()) {
134
+            list.add(new AddonInfo(controller.getGlobalConfig(), entry));
129 135
         }
130 136
         return list;
131 137
     }
@@ -140,9 +146,9 @@ public class DataLoaderWorker
140 146
         Collection<AddonInfo> data;
141 147
         try {
142 148
             data = get();
143
-        } catch (InterruptedException ex) {
149
+        } catch (final InterruptedException ex) {
144 150
             data = Collections.<AddonInfo>emptyList();
145
-        } catch (ExecutionException ex) {
151
+        } catch (final ExecutionException ex) {
146 152
             Logger.appError(ErrorLevel.MEDIUM, ex.getMessage(), ex);
147 153
             data = Collections.<AddonInfo>emptyList();
148 154
         }
@@ -153,9 +159,9 @@ public class DataLoaderWorker
153 159
             selectedRow = 0;
154 160
         }
155 161
         table.getModel().setRowCount(0);
156
-        for (AddonInfo info : data) {
162
+        for (final AddonInfo info : data) {
157 163
             table.getModel().addRow(new Object[]{
158
-                new AddonInfoLabel(info, browserWindow),
164
+                new AddonInfoLabel(controller, info, browserWindow),
159 165
             });
160 166
         }
161 167
         table.getSelectionModel().setSelectionInterval(selectedRow, selectedRow);

+ 10
- 4
src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallListener.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
26
+
25 27
 import java.awt.event.ActionEvent;
26 28
 import java.awt.event.ActionListener;
27 29
 
@@ -34,17 +36,21 @@ public class InstallListener implements ActionListener {
34 36
     private final AddonInfo info;
35 37
     /** Parent window. */
36 38
     private final BrowserWindow parentWindow;
39
+    /** Swing controller. */
40
+    private final SwingController controller;
37 41
 
38 42
     /**
39 43
      * Instantiates a new install listener.
40 44
      *
45
+     * @param controller Swing controller
41 46
      * @param info Addoninfo to install
42 47
      * @param parentWindow Parent window
43 48
      */
44
-    public InstallListener(final AddonInfo info,
45
-            final BrowserWindow parentWindow) {
49
+    public InstallListener(final SwingController controller,
50
+            final AddonInfo info, final BrowserWindow parentWindow) {
46 51
         super();
47 52
 
53
+        this.controller = controller;
48 54
         this.info = info;
49 55
         this.parentWindow = parentWindow;
50 56
     }
@@ -56,8 +62,8 @@ public class InstallListener implements ActionListener {
56 62
      */
57 63
     @Override
58 64
     public void actionPerformed(final ActionEvent e) {
59
-        final InstallerWindow installer = new InstallerWindow(parentWindow,
60
-                info);
65
+        final InstallerWindow installer = new InstallerWindow(controller,
66
+                parentWindow, info);
61 67
         installer.display(parentWindow);
62 68
         new InstallWorker(info, installer).executeInExecutor();
63 69
     }

+ 6
- 5
src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallerWindow.java View File

@@ -22,10 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26 27
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
27 28
 
28
-import java.awt.Dialog.ModalityType;
29 29
 import java.awt.event.ActionEvent;
30 30
 import java.awt.event.ActionListener;
31 31
 
@@ -57,12 +57,13 @@ public class InstallerWindow extends StandardDialog implements ActionListener {
57 57
     /**
58 58
      * Instantiates a new installer window.
59 59
      *
60
+     * @param controller Swing controller
60 61
      * @param parentWindow Parent window
61
-     * @param info Assocaited addon info
62
+     * @param info Associated addon info
62 63
      */
63
-    public InstallerWindow(final BrowserWindow parentWindow,
64
-            final AddonInfo info) {
65
-        super(parentWindow, ModalityType.MODELESS);
64
+    public InstallerWindow(final SwingController controller,
65
+            final BrowserWindow parentWindow, final AddonInfo info) {
66
+        super(controller, parentWindow, ModalityType.MODELESS);
66 67
         this.info = info;
67 68
         this.parentWindow = parentWindow;
68 69
         setTitle("Installing addon...");

+ 5
- 10
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java View File

@@ -28,7 +28,6 @@ import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28 28
 import com.dmdirc.addons.ui_swing.components.addonbrowser.BrowserWindow;
29 29
 import com.dmdirc.addons.ui_swing.components.renderers.AddonCellRenderer;
30 30
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
31
-import com.dmdirc.config.IdentityManager;
32 31
 import com.dmdirc.config.prefs.PreferencesInterface;
33 32
 import com.dmdirc.ui.IconManager;
34 33
 
@@ -56,16 +55,12 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
56 55
 
57 56
     /** List of addons. */
58 57
     protected JTable addonList;
59
-    /**
60
-     * A version number for this class. It should be changed whenever the class
61
-     * structure is changed (or anything else that would prevent serialized
62
-     * objects being unserialized with the new class).
63
-     */
58
+    /** Swing Controller. */
59
+    protected final SwingController controller;
60
+    /** Serial version UID. */
64 61
     private static final long serialVersionUID = 3;
65 62
     /** Parent Window. */
66 63
     private final Window parentWindow;
67
-    /** Swing Controller. */
68
-    private final SwingController controller;
69 64
     /** The icon manager used to retrieve icons. */
70 65
     private final IconManager iconManager;
71 66
     /** Addon list scroll pane. */
@@ -91,7 +86,7 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
91 86
 
92 87
         this.parentWindow = parentWindow;
93 88
         this.controller = controller;
94
-        this.iconManager = new IconManager(IdentityManager.getGlobalConfig());
89
+        iconManager = controller.getIconManager();
95 90
 
96 91
         initComponents();
97 92
         layoutComponents();
@@ -212,7 +207,7 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
212 207
     @Override
213 208
     public void hyperlinkUpdate(final HyperlinkEvent e) {
214 209
         if (e.getEventType() == EventType.ACTIVATED) {
215
-            new BrowserWindow(parentWindow);
210
+            new BrowserWindow(controller, parentWindow);
216 211
         }
217 212
     }
218 213
 

+ 11
- 6
src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonToggle.java View File

@@ -19,9 +19,10 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
+
22 23
 package com.dmdirc.addons.ui_swing.components.addonpanel;
23 24
 
24
-import com.dmdirc.config.IdentityManager;
25
+import com.dmdirc.config.Identity;
25 26
 import com.dmdirc.plugins.PluginInfo;
26 27
 import com.dmdirc.plugins.PluginManager;
27 28
 import com.dmdirc.ui.themes.Theme;
@@ -48,6 +49,8 @@ public final class AddonToggle {
48 49
     private boolean updateState;
49 50
     /** Listener list. */
50 51
     private final ListenerList listeners;
52
+    /** Identity to change update settings in. */
53
+    private final Identity identity;
51 54
 
52 55
     /**
53 56
      * Creates a new instance of AddonToggle to wrap the specified
@@ -56,11 +59,13 @@ public final class AddonToggle {
56 59
      * @param pi The PluginInfo to be wrapped can be null
57 60
      * @param theme The Theme to be wrapped can be null
58 61
      */
59
-    public AddonToggle(final PluginInfo pi, final Theme theme) {
62
+    public AddonToggle(final Identity identity, final PluginInfo pi,
63
+            final Theme theme) {
60 64
         if ((pi == null) == (theme == null)) {
61 65
             throw new IllegalArgumentException("You must wrap a plugin or "
62 66
                     + "a theme.");
63 67
         }
68
+        this.identity = identity;
64 69
         this.pi = pi;
65 70
         this.theme = theme;
66 71
         listeners = new ListenerList();
@@ -154,11 +159,11 @@ public final class AddonToggle {
154 159
                     PluginManager.getPluginManager().updateAutoLoad(pi);
155 160
                     if (getID() != -1) {
156 161
                         if (getUpdateState()) {
157
-                            IdentityManager.getConfigIdentity().unsetOption(
158
-                                    "updater", "enable-addon-" + getID());
162
+                            identity.unsetOption("updater", "enable-addon-"
163
+                                    + getID());
159 164
                         } else {
160
-                            IdentityManager.getConfigIdentity().setOption(
161
-                                   "updater", "enable-addon-" + getID(), false);
165
+                            identity.setOption("updater", "enable-addon-"
166
+                                    + getID(), false);
162 167
                         }
163 168
                     }
164 169
                 }

+ 6
- 5
src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java View File

@@ -24,10 +24,10 @@ package com.dmdirc.addons.ui_swing.components.addonpanel;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.interfaces.actions.ActionType;
28 27
 import com.dmdirc.addons.ui_swing.SwingController;
29 28
 import com.dmdirc.addons.ui_swing.UIUtilities;
30 29
 import com.dmdirc.interfaces.ActionListener;
30
+import com.dmdirc.interfaces.actions.ActionType;
31 31
 import com.dmdirc.plugins.PluginInfo;
32 32
 import com.dmdirc.plugins.PluginManager;
33 33
 
@@ -74,11 +74,11 @@ public class PluginPanel extends AddonPanel implements ActionListener {
74 74
         final List<PluginInfo> sortedList = new ArrayList<PluginInfo>();
75 75
         list.addAll(PluginManager.getPluginManager().getPluginInfos());
76 76
         Collections.sort(list);
77
-        for (PluginInfo plugin : list) {
77
+        for (final PluginInfo plugin : list) {
78 78
             if (plugin.getMetaData().getParents().length == 0) {
79 79
                 final List<PluginInfo> childList = new ArrayList<PluginInfo>();
80 80
                 sortedList.add(plugin);
81
-                for (PluginInfo child : plugin.getChildren()) {
81
+                for (final PluginInfo child : plugin.getChildren()) {
82 82
                     childList.add(child);
83 83
                 }
84 84
                 Collections.sort(childList);
@@ -93,10 +93,11 @@ public class PluginPanel extends AddonPanel implements ActionListener {
93 93
             @Override
94 94
             public void run() {
95 95
                 ((DefaultTableModel) table.getModel()).setNumRows(0);
96
-                for (PluginInfo plugin : sortedList) {
96
+                for (final PluginInfo plugin : sortedList) {
97 97
                     ((DefaultTableModel) table.getModel()).addRow(
98 98
                             new AddonCell[]{ new AddonCell(new AddonToggle(
99
-                            plugin, null), getIconManager()), });
99
+                                    controller.getGlobalIdentity(), plugin,
100
+                                    null), getIconManager()), });
100 101
                 }
101 102
                 table.repaint();
102 103
             }

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/addonpanel/ThemePanel.java View File

@@ -72,10 +72,11 @@ public class ThemePanel extends AddonPanel {
72 72
             @Override
73 73
             public void run() {
74 74
                 ((DefaultTableModel) addonList.getModel()).setRowCount(0);
75
-                for (Theme theme : list) {
75
+                for (final Theme theme : list) {
76 76
                     ((DefaultTableModel) addonList.getModel()).addRow(
77 77
                     new AddonCell[]{ new AddonCell(new AddonToggle(
78
-                            null, theme), getIconManager()), });
78
+                            controller.getGlobalIdentity(), null, theme),
79
+                            getIconManager()), });
79 80
                 }
80 81
 
81 82
                 addonList.repaint();

+ 33
- 21
src/com/dmdirc/addons/ui_swing/components/colours/ColourChooser.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.components.colours;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
+import com.dmdirc.ui.IconManager;
26 27
 import com.dmdirc.ui.messages.ColourManager;
27 28
 
28 29
 import java.awt.Color;
@@ -44,62 +45,68 @@ import net.miginfocom.swing.MigLayout;
44 45
  */
45 46
 public final class ColourChooser extends JPanel implements ActionListener {
46 47
 
47
-    /**
48
-     * A version number for this class. It should be changed whenever the class
49
-     * structure is changed (or anything else that would prevent serialized
50
-     * objects being unserialized with the new class).
51
-     */
48
+    /** Serial version UID. */
52 49
     private static final long serialVersionUID = 1;
53 50
     /** Edit button. */
54
-    private JButton editButton;
51
+    private final JButton editButton;
55 52
     /** Panel to show the colour preview. */
56
-    private JPanel previewPanel;
53
+    private final JPanel previewPanel;
54
+    /** Event listeners. */
55
+    private final EventListenerList listeners;
56
+    /** Icon manager. */
57
+    private final IconManager iconManager;
57 58
     /** Colours picking dialog. */
58 59
     private ColourPickerDialog cpd;
59 60
     /** show irc colours. */
60
-    private boolean showIRC;
61
+    private final boolean showIRC;
61 62
     /** show hex colours. */
62
-    private boolean showHex;
63
+    private final boolean showHex;
63 64
     /** The value of this component. */
64 65
     private String value;
65
-    /** Event listeners. */
66
-    private final EventListenerList listeners;
67 66
     /** Action command. */
68 67
     private String command;
69 68
     /** Parent window. */
70 69
     private Window window;
71 70
 
72
-    /** Creates a new instance of ColourChooser. */
73
-    public ColourChooser() {
74
-        this("ffffff", true, true);
71
+    /**
72
+     * Creates a new instance of ColourChooser.
73
+     *
74
+     * @param iconManager Icon manager
75
+     * */
76
+    public ColourChooser(final IconManager iconManager) {
77
+        this(iconManager, "ffffff", true, true);
75 78
     }
76 79
 
77 80
     /**
78 81
      * Creates a new instance of ColourChooser.
79 82
      *
83
+     * @param iconManager Icon Manager
80 84
      * @param window Parent window
81 85
      *
82 86
      * @since 0.6
83 87
      */
84
-    public ColourChooser(final Window window) {
85
-        this("ffffff", true, true, window);
88
+    public ColourChooser(final IconManager iconManager, final Window window) {
89
+        this(iconManager, "ffffff", true, true, window);
86 90
     }
87 91
 
88 92
     /**
89 93
      * Creates a new instance of ColourChooser.
90 94
      *
95
+     * @param iconManager Icon manager
91 96
      * @param initialColour Snitial colour
92 97
      * @param ircColours Show irc colours
93 98
      * @param hexColours Show hex colours
94 99
      */
95
-    public ColourChooser(final String initialColour, final boolean ircColours,
100
+    public ColourChooser(final IconManager iconManager,
101
+            final String initialColour, final boolean ircColours,
96 102
             final boolean hexColours) {
97
-        this(initialColour, ircColours, hexColours, null);
103
+        this(iconManager, initialColour, ircColours, hexColours, null);
98 104
     }
99 105
 
100 106
     /**
101 107
      * Creates a new instance of ColourChooser.
102 108
      *
109
+     * @param iconManager Icon manager
103 110
      * @param initialColour initial colour
104 111
      * @param ircColours show irc colours
105 112
      * @param hexColours show hex colours
@@ -107,10 +114,12 @@ public final class ColourChooser extends JPanel implements ActionListener {
107 114
      *
108 115
      * @since 0.6
109 116
      */
110
-    public ColourChooser(final String initialColour, final boolean ircColours,
117
+    public ColourChooser(final IconManager iconManager,
118
+            final String initialColour, final boolean ircColours,
111 119
             final boolean hexColours, final Window window) {
112 120
         super();
113 121
 
122
+        this.iconManager = iconManager;
114 123
         this.window = window;
115 124
         showIRC = ircColours;
116 125
         showHex = hexColours;
@@ -142,6 +151,7 @@ public final class ColourChooser extends JPanel implements ActionListener {
142 151
 
143 152
     /**
144 153
      * Returns the selected colour from this component.
154
+     *
145 155
      * @return This components colour, as a string
146 156
      */
147 157
     public String getColour() {
@@ -150,6 +160,7 @@ public final class ColourChooser extends JPanel implements ActionListener {
150 160
 
151 161
     /**
152 162
      * Sets the selected colour for this component.
163
+     *
153 164
      * @param newValue New colour
154 165
      */
155 166
     public void setColour(final String newValue) {
@@ -166,6 +177,7 @@ public final class ColourChooser extends JPanel implements ActionListener {
166 177
 
167 178
     /**
168 179
      * Updates the colour panel.
180
+     *
169 181
      * @param newColour The new colour to use.
170 182
      */
171 183
     private void updateColour(final String newColour) {
@@ -187,7 +199,7 @@ public final class ColourChooser extends JPanel implements ActionListener {
187 199
     @Override
188 200
     public void actionPerformed(final ActionEvent e) {
189 201
         if (e.getSource() == editButton) {
190
-            cpd = new ColourPickerDialog(showIRC, showHex, window);
202
+            cpd = new ColourPickerDialog(iconManager, showIRC, showHex, window);
191 203
             cpd.addActionListener(this);
192 204
             cpd.display(editButton);
193 205
         } else {
@@ -239,7 +251,7 @@ public final class ColourChooser extends JPanel implements ActionListener {
239 251
             if (localListenerList[i] == ActionListener.class) {
240 252
                 ((ActionListener) localListenerList[i + 1]).actionPerformed(
241 253
                         new ActionEvent(this,
242
-                        ActionEvent.ACTION_PERFORMED, command));
254
+                                ActionEvent.ACTION_PERFORMED, command));
243 255
             }
244 256
         }
245 257
     }

+ 19
- 39
src/com/dmdirc/addons/ui_swing/components/colours/ColourPickerDialog.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.components.colours;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
26
-import com.dmdirc.config.IdentityManager;
27 26
 import com.dmdirc.ui.IconManager;
28 27
 
29 28
 import java.awt.Window;
@@ -38,59 +37,61 @@ import javax.swing.JDialog;
38 37
  */
39 38
 public final class ColourPickerDialog extends StandardDialog {
40 39
 
41
-    /**
42
-     * A version number for this class. It should be changed whenever the class
43
-     * structure is changed (or anything else that would prevent serialized
44
-     * objects being unserialized with the new class).
45
-     */
40
+    /** Serial version UID. */
46 41
     private static final long serialVersionUID = 1;
47 42
     /** Colour chooser panel. */
48
-    private ColourPickerPanel colourChooser;
43
+    private final ColourPickerPanel colourChooser;
49 44
 
50 45
     /**
51 46
      * Creates a new instance of ColourPickerDialog.
52 47
      *
48
+     * @param iconManager Icon manager
49
+     *
53 50
      * @since 0.6
54 51
      */
55
-    public ColourPickerDialog() {
56
-        this(true, true);
52
+    public ColourPickerDialog(final IconManager iconManager) {
53
+        this(iconManager, true, true);
57 54
     }
58 55
 
59 56
     /**
60 57
      * Creates a new instance of ColourPickerDialog.
61 58
      *
59
+     * @param iconManager Icon manager
62 60
      * @param window Parent window
63 61
      *
64 62
      * @since 0.6
65 63
      */
66
-    public ColourPickerDialog(final Window window) {
67
-        this(true, true, window);
64
+    public ColourPickerDialog(final IconManager iconManager,
65
+            final Window window) {
66
+        this(iconManager, true, true, window);
68 67
     }
69 68
 
70 69
     /**
71 70
      * Creates a new instance of ColourPickerDialog.
72 71
      *
72
+     * @param iconManager Icon manager
73 73
      * @param showIRC show irc colours
74 74
      * @param showHex show hex colours
75 75
      */
76
-    public ColourPickerDialog(final boolean showIRC, final boolean showHex) {
77
-        this(showIRC, showHex, null);
78
-        setIconImage(new IconManager(IdentityManager.getGlobalConfig())
79
-                .getImage("icon"));
76
+    public ColourPickerDialog(final IconManager iconManager,
77
+            final boolean showIRC, final boolean showHex) {
78
+        this(iconManager, showIRC, showHex, null);
80 79
     }
81 80
 
82 81
     /**
83 82
      * Creates a new instance of ColourPickerDialog.
84 83
      *
84
+     * @param iconManager Icon manager
85 85
      * @param showIRC show irc colours
86 86
      * @param showHex show hex colours
87 87
      * @param window Parent window
88 88
      *
89 89
      * @since 0.6
90 90
      */
91
-    public ColourPickerDialog(final boolean showIRC, final boolean showHex,
92
-            final Window window) {
93
-        super(window, ModalityType.MODELESS);
91
+    public ColourPickerDialog(final IconManager iconManager,
92
+            final boolean showIRC, final boolean showHex, final Window window) {
93
+        super(null, window, ModalityType.MODELESS);
94
+        setIconImage(iconManager.getImage("icon"));
94 95
 
95 96
         colourChooser = new ColourPickerPanel(showIRC, showHex);
96 97
 
@@ -102,27 +103,6 @@ public final class ColourPickerDialog extends StandardDialog {
102 103
         setWindow(window);
103 104
     }
104 105
 
105
-    /**
106
-     * Creates and shows a new Colour picker dialog.
107
-     * @return Colour picker dialog
108
-     */
109
-    public static ColourPickerDialog showColourPicker() {
110
-        return showColourPicker(true, true);
111
-    }
112
-
113
-    /**
114
-     * Creates and shows a new Colour picker dialog.
115
-     * @return Colour picker dialog
116
-     * @param showIRC show irc colours
117
-     * @param showHex show hex colours
118
-     */
119
-    public static ColourPickerDialog showColourPicker(final boolean showIRC,
120
-            final boolean showHex) {
121
-        final ColourPickerDialog cpd = new ColourPickerDialog(showIRC, showHex);
122
-        cpd.display();
123
-        return cpd;
124
-    }
125
-
126 106
     /**
127 107
      * Adds an actions listener to this dialog.
128 108
      *

+ 4
- 9
src/com/dmdirc/addons/ui_swing/components/colours/ColourPickerPanel.java View File

@@ -45,16 +45,11 @@ import javax.swing.JPanel;
45 45
 /**
46 46
  * The ColourPickerPanel allows users to pick either an IRC colour or a hex
47 47
  * colour visually.
48
- * @author chris
49 48
  */
50 49
 public final class ColourPickerPanel extends JPanel implements MouseListener,
51 50
         MouseMotionListener, MouseWheelListener {
52 51
 
53
-    /**
54
-     * A version number for this class. It should be changed whenever the class
55
-     * structure is changed (or anything else that would prevent serialized
56
-     * objects being unserialized with the new class).
57
-     */
52
+    /** Serial version UID. */
58 53
     private static final long serialVersionUID = 1;
59 54
     /** ActionEvent ID for when a hex colour is selected. */
60 55
     public static final int ACTION_HEX = 10001;
@@ -103,8 +98,8 @@ public final class ColourPickerPanel extends JPanel implements MouseListener,
103 98
             final boolean newShowHex) {
104 99
         super();
105 100
 
106
-        this.showIrc = newShowIrc;
107
-        this.showHex = newShowHex;
101
+        showIrc = newShowIrc;
102
+        showHex = newShowHex;
108 103
 
109 104
         final int height = 110 + (showIrc ? 15 : 0) + (showHex ? 125 : 0);
110 105
 
@@ -282,7 +277,7 @@ public final class ColourPickerPanel extends JPanel implements MouseListener,
282 277
     private void throwAction(final int id, final String message) {
283 278
         final ActionEvent event = new ActionEvent(this, id, message);
284 279
 
285
-        for (ActionListener listener : listeners) {
280
+        for (final ActionListener listener : listeners) {
286 281
             listener.actionPerformed(event);
287 282
         }
288 283
     }

+ 37
- 24
src/com/dmdirc/addons/ui_swing/components/colours/OptionalColourChooser.java View File

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.components.colours;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
+import com.dmdirc.ui.IconManager;
26 27
 import com.dmdirc.ui.messages.ColourManager;
27 28
 import com.dmdirc.util.collections.ListenerList;
28 29
 
@@ -43,36 +44,39 @@ import net.miginfocom.swing.MigLayout;
43 44
 /**
44 45
  * Colour chooser widget.
45 46
  */
46
-public final class OptionalColourChooser extends JPanel implements ActionListener {
47
+public final class OptionalColourChooser extends JPanel implements
48
+        ActionListener {
47 49
 
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
-     */
50
+    /** Serial version UID. */
53 51
     private static final long serialVersionUID = 1;
52
+    private String value;
53
+    /** Our listeners. */
54
+    private final ListenerList listeners = new ListenerList();
55
+    /** Icon manager. */
56
+    private final IconManager iconManager;
54 57
     /** Enabled checkbox. */
55
-    private JCheckBox enabled;
58
+    private final JCheckBox enabled;
56 59
     /** Edit button. */
57
-    private JButton editButton;
60
+    private final JButton editButton;
58 61
     /** Panel to show the colour preview. */
59
-    private JPanel previewPanel;
62
+    private final JPanel previewPanel;
60 63
     /** Colours picking dialog. */
61 64
     private ColourPickerDialog cpd;
62 65
     /** show irc colours. */
63
-    private boolean showIRC;
66
+    private final boolean showIRC;
64 67
     /** show hex colours. */
65
-    private boolean showHex;
68
+    private final boolean showHex;
66 69
     /** The value of this component. */
67
-    private String value;
68
-    /** Our listeners. */
69
-    private final ListenerList listeners = new ListenerList();
70 70
     /** Parent window. */
71 71
     private Window window;
72 72
 
73
-    /** Creates a new instance of ColourChooser. */
74
-    public OptionalColourChooser() {
75
-        this("", false, true, true);
73
+    /**
74
+     * Creates a new instance of ColourChooser.
75
+     *
76
+     * @param iconManager Icon manager
77
+     */
78
+    public OptionalColourChooser(final IconManager iconManager) {
79
+        this(iconManager, "", false, true, true);
76 80
     }
77 81
 
78 82
     /**
@@ -82,27 +86,32 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
82 86
      *
83 87
      * @since 0.6
84 88
      */
85
-    public OptionalColourChooser(final Window window) {
86
-        this("", false, true, true, window);
89
+    public OptionalColourChooser(final IconManager iconManager,
90
+            final Window window) {
91
+        this(iconManager, "", false, true, true, window);
87 92
     }
88 93
 
89 94
     /**
90 95
      * Creates a new instance of ColourChooser.
91 96
      *
97
+     * @param iconManager Icon manager
92 98
      * @param initialColour Snitial colour
93 99
      * @param initialState Initial state
94 100
      * @param ircColours Show irc colours
95 101
      * @param hexColours Show hex colours
96 102
      */
97
-    public OptionalColourChooser(final String initialColour,
103
+    public OptionalColourChooser(final IconManager iconManager,
104
+            final String initialColour,
98 105
             final boolean initialState, final boolean ircColours,
99 106
             final boolean hexColours) {
100
-        this(initialColour, initialState, ircColours, hexColours, null);
107
+        this(iconManager, initialColour, initialState, ircColours, hexColours,
108
+                null);
101 109
     }
102 110
 
103 111
     /**
104 112
      * Creates a new instance of ColourChooser.
105 113
      *
114
+     * @param iconManager Icon manager
106 115
      * @param initialColour Snitial colour
107 116
      * @param initialState Initial state
108 117
      * @param ircColours Show irc colours
@@ -111,11 +120,13 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
111 120
      *
112 121
      * @since 0.6
113 122
      */
114
-    public OptionalColourChooser(final String initialColour,
123
+    public OptionalColourChooser(final IconManager iconManager,
124
+            final String initialColour,
115 125
             final boolean initialState, final boolean ircColours,
116 126
             final boolean hexColours, final Window window) {
117 127
         super();
118 128
 
129
+        this.iconManager = iconManager;
119 130
         this.window = window;
120 131
         showIRC = ircColours;
121 132
         showHex = hexColours;
@@ -180,6 +191,7 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
180 191
 
181 192
     /**
182 193
      * Updates the colour panel.
194
+     *
183 195
      * @param newColour The new colour to use.
184 196
      */
185 197
     private void updateColour(final String newColour) {
@@ -201,7 +213,7 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
201 213
     @Override
202 214
     public void actionPerformed(final ActionEvent e) {
203 215
         if (e.getSource() == editButton) {
204
-            cpd = new ColourPickerDialog(showIRC, showHex, window);
216
+            cpd = new ColourPickerDialog(iconManager, showIRC, showHex, window);
205 217
             cpd.addActionListener(this);
206 218
             cpd.display(editButton);
207 219
         } else if (e.getSource() == enabled) {
@@ -229,7 +241,8 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
229 241
      * Informs all action listeners that an action has occured.
230 242
      */
231 243
     protected void fireActionEvent() {
232
-        for (ActionListener listener : listeners.get(ActionListener.class)) {
244
+        for (final ActionListener listener : listeners
245
+                .get(ActionListener.class)) {
233 246
             listener.actionPerformed(new ActionEvent(this, 1, "stuffChanged"));
234 247
         }
235 248
     }

+ 19
- 11
src/com/dmdirc/addons/ui_swing/components/durationeditor/DurationDisplay.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.durationeditor;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.util.DateUtils;
27 28
 import com.dmdirc.util.collections.ListenerList;
@@ -49,22 +50,24 @@ public class DurationDisplay extends JPanel implements ActionListener,
49 50
      * objects being unserialized with the new class).
50 51
      */
51 52
     private static final long serialVersionUID = 1;
53
+    /** Listener list. */
54
+    private final ListenerList listeners;
55
+    /** Swing controller. */
56
+    private final SwingController controller;
52 57
     /** Current duration. */
53 58
     private int duration;
54 59
     /** Duration label. */
55 60
     private JLabel durationLabel;
56 61
     /** Edit button. */
57 62
     private JButton button;
58
-    /** Listener list. */
59
-    private final ListenerList listeners;
60 63
     /** Parent window. */
61 64
     private Window window;
62 65
 
63 66
     /**
64 67
      * Initialises a new duration display of 0 milliseconds.
65 68
      */
66
-    public DurationDisplay() {
67
-        this(0);
69
+    public DurationDisplay(final SwingController controller) {
70
+        this(controller, 0);
68 71
     }
69 72
 
70 73
     /**
@@ -74,8 +77,9 @@ public class DurationDisplay extends JPanel implements ActionListener,
74 77
      *
75 78
      * @since 0.6
76 79
      */
77
-    public DurationDisplay(final Window window) {
78
-        this(window, 0);
80
+    public DurationDisplay(final SwingController controller,
81
+            final Window window) {
82
+        this(controller, window, 0);
79 83
     }
80 84
 
81 85
     /**
@@ -83,8 +87,9 @@ public class DurationDisplay extends JPanel implements ActionListener,
83 87
      *
84 88
      * @param duration Starting duration
85 89
      */
86
-    public DurationDisplay(final long duration) {
87
-        this(null, duration);
90
+    public DurationDisplay(final SwingController controller,
91
+            final long duration) {
92
+        this(controller, null, duration);
88 93
     }
89 94
 
90 95
     /**
@@ -95,9 +100,11 @@ public class DurationDisplay extends JPanel implements ActionListener,
95 100
      *
96 101
      * @since 0.6
97 102
      */
98
-    public DurationDisplay(final Window window, final long duration) {
103
+    public DurationDisplay(final SwingController controller,
104
+            final Window window, final long duration) {
99 105
         super();
100 106
 
107
+        this.controller = controller;
101 108
         this.window = window;
102 109
         this.duration = (int) (duration / 1000);
103 110
         listeners = new ListenerList();
@@ -150,7 +157,8 @@ public class DurationDisplay extends JPanel implements ActionListener,
150 157
      */
151 158
     @Override
152 159
     public void actionPerformed(final ActionEvent e) {
153
-        final DurationEditor editor = new DurationEditor(window, duration);
160
+        final DurationEditor editor = new DurationEditor(controller, window,
161
+                duration);
154 162
         editor.display(this);
155 163
         editor.addDurationListener(this);
156 164
     }
@@ -206,7 +214,7 @@ public class DurationDisplay extends JPanel implements ActionListener,
206 214
      * @param newDuration New duration
207 215
      */
208 216
     protected void fireDurationListener(final int newDuration) {
209
-        for (DurationListener listener : listeners.get(DurationListener.class)) {
217
+        for (final DurationListener listener : listeners.get(DurationListener.class)) {
210 218
             listener.durationUpdated(newDuration);
211 219
         }
212 220
     }

+ 14
- 9
src/com/dmdirc/addons/ui_swing/components/durationeditor/DurationEditor.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.durationeditor;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
26 27
 import com.dmdirc.util.collections.ListenerList;
27 28
 
@@ -75,8 +76,8 @@ public class DurationEditor extends StandardDialog implements ActionListener {
75 76
     /**
76 77
      * Instantiates a new duration editor.
77 78
      */
78
-    public DurationEditor() {
79
-        this(0);
79
+    public DurationEditor(final SwingController controller) {
80
+        this(controller, 0);
80 81
     }
81 82
 
82 83
     /**
@@ -86,8 +87,9 @@ public class DurationEditor extends StandardDialog implements ActionListener {
86 87
      *
87 88
      * @since 0.6
88 89
      */
89
-    public DurationEditor(final Window window) {
90
-        this(window, 0);
90
+    public DurationEditor(final SwingController controller,
91
+            final Window window) {
92
+        this(controller, window, 0);
91 93
     }
92 94
 
93 95
     /**
@@ -95,20 +97,23 @@ public class DurationEditor extends StandardDialog implements ActionListener {
95 97
      *
96 98
      * @param duration Starting duration
97 99
      */
98
-    public DurationEditor(final long duration) {
99
-        this(null, duration);
100
+    public DurationEditor(final SwingController controller,
101
+            final long duration) {
102
+        this(controller, controller.getMainFrame(), duration);
100 103
     }
101 104
 
102 105
     /**
103 106
      * Instantiates a new duration editor.
104 107
      *
108
+     * @param controller Swing controller
105 109
      * @param window Parent window.
106 110
      * @param duration Starting duration
107 111
      *
108 112
      * @since 0.6
109 113
      */
110
-    public DurationEditor(final Window window, final long duration) {
111
-        super(window, ModalityType.MODELESS);
114
+    public DurationEditor(final SwingController controller,
115
+            final Window window, final long duration) {
116
+        super(controller, window, ModalityType.MODELESS);
112 117
 
113 118
         this.window = window;
114 119
 
@@ -234,7 +239,7 @@ public class DurationEditor extends StandardDialog implements ActionListener {
234 239
      * @param newDuration New duration
235 240
      */
236 241
     protected void fireDurationListener(final int newDuration) {
237
-        for (DurationListener listener : listeners.get(DurationListener.class)) {
242
+        for (final DurationListener listener : listeners.get(DurationListener.class)) {
238 243
             listener.durationUpdated(newDuration);
239 244
         }
240 245
     }

+ 11
- 13
src/com/dmdirc/addons/ui_swing/components/expandingsettings/CurrentOptionsPanel.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.ui_swing.components.expandingsettings;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.addons.ui_swing.components.ImageButton;
27
-import com.dmdirc.config.IdentityManager;
28 27
 import com.dmdirc.ui.IconManager;
29 28
 
30 29
 import java.awt.event.ActionEvent;
@@ -44,28 +43,29 @@ import net.miginfocom.swing.MigLayout;
44 43
 public final class CurrentOptionsPanel extends JPanel implements
45 44
         ActionListener {
46 45
 
47
-    /**
48
-     * A version number for this class. It should be changed whenever the class
49
-     * structure is changed (or anything else that would prevent serialized
50
-     * objects being unserialized with the new class).
51
-     */
46
+    /** Serial version UID. */
52 47
     private static final long serialVersionUID = 2;
53 48
     /** Parent settings panel. */
54 49
     private final SettingsPanel parent;
55 50
     /** Curent options to display. */
56 51
     private final List<JComponent> settings;
52
+    /** Icon manager. */
53
+    private final IconManager iconManager;
57 54
 
58 55
     /**
59 56
      * Creates a new instance of CurrentOptionsPanel.
60 57
      *
58
+     * @param iconManager IconManager
61 59
      * @param parent Parent settings panel.
62 60
      */
63
-    protected CurrentOptionsPanel(final SettingsPanel parent) {
61
+    protected CurrentOptionsPanel(final IconManager iconManager,
62
+            final SettingsPanel parent) {
64 63
         super();
65 64
 
65
+        this.iconManager = iconManager;
66 66
         this.parent = parent;
67 67
 
68
-        this.setOpaque(UIUtilities.getTabbedPaneOpaque());
68
+        setOpaque(UIUtilities.getTabbedPaneOpaque());
69 69
         settings = new ArrayList<JComponent>();
70 70
     }
71 71
 
@@ -107,10 +107,8 @@ public final class CurrentOptionsPanel extends JPanel implements
107 107
     private void addCurrentOption(final JComponent component) {
108 108
         final JLabel label = new JLabel();
109 109
         final ImageButton<JComponent> button = new ImageButton<JComponent>(
110
-                component.getName(),
111
-                new IconManager(IdentityManager.getGlobalConfig())
112
-                .getIcon("close-inactive"), new IconManager(IdentityManager
113
-                .getGlobalConfig()).getIcon("close-active"));
110
+                component.getName(), iconManager.getIcon("close-inactive"),
111
+                iconManager.getIcon("close-active"));
114 112
         button.setObject(component);
115 113
 
116 114
         label.setText(component.getName() + ": ");
@@ -132,7 +130,7 @@ public final class CurrentOptionsPanel extends JPanel implements
132 130
 
133 131
         removeAll();
134 132
 
135
-        for (JComponent setting : settings) {
133
+        for (final JComponent setting : settings) {
136 134
             addCurrentOption(setting);
137 135
         }
138 136
 

+ 6
- 10
src/com/dmdirc/addons/ui_swing/components/expandingsettings/SettingsPanel.java View File

@@ -27,7 +27,6 @@ import com.dmdirc.addons.ui_swing.UIUtilities;
27 27
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
28 28
 import com.dmdirc.config.prefs.PreferencesCategory;
29 29
 import com.dmdirc.config.prefs.PreferencesSetting;
30
-
31 30
 import com.dmdirc.util.collections.DoubleMap;
32 31
 
33 32
 import javax.swing.BorderFactory;
@@ -43,11 +42,7 @@ import net.miginfocom.swing.MigLayout;
43 42
  */
44 43
 public class SettingsPanel extends JPanel {
45 44
 
46
-    /**
47
-     * A version number for this class. It should be changed whenever the class
48
-     * structure is changed (or anything else that would prevent serialized
49
-     * objects being unserialized with the new class).
50
-     */
45
+    /** Serial version UID. */
51 46
     private static final long serialVersionUID = 3;
52 47
     /** Current Settings. */
53 48
     private final DoubleMap<PreferencesSetting, JComponent> settings;
@@ -92,7 +87,7 @@ public class SettingsPanel extends JPanel {
92 87
 
93 88
         settings = new DoubleMap<PreferencesSetting, JComponent>();
94 89
 
95
-        this.setOpaque(UIUtilities.getTabbedPaneOpaque());
90
+        setOpaque(UIUtilities.getTabbedPaneOpaque());
96 91
         this.padding = padding;
97 92
 
98 93
         initComponents(infoText);
@@ -109,7 +104,8 @@ public class SettingsPanel extends JPanel {
109 104
         infoLabel.setVisible(!infoText.isEmpty());
110 105
 
111 106
         addOptionPanel = new AddOptionPanel(this);
112
-        currentOptionsPanel = new CurrentOptionsPanel(this);
107
+        currentOptionsPanel = new CurrentOptionsPanel(controller
108
+                .getIconManager(), this);
113 109
         scrollPane = new JScrollPane(currentOptionsPanel);
114 110
 
115 111
         scrollPane.setBorder(BorderFactory.createTitledBorder(UIManager.
@@ -141,7 +137,7 @@ public class SettingsPanel extends JPanel {
141 137
     public void addOption(final PreferencesCategory category) {
142 138
         this.category = category;
143 139
 
144
-        for (PreferencesSetting setting : category.getSettings()) {
140
+        for (final PreferencesSetting setting : category.getSettings()) {
145 141
             if (settings.get(setting) == null) {
146 142
                 final JComponent component = controller
147 143
                         .getPrefsComponentFactory().getComponent(setting);
@@ -161,7 +157,7 @@ public class SettingsPanel extends JPanel {
161 157
         addOptionPanel.clearOptions();
162 158
         currentOptionsPanel.clearOptions();
163 159
 
164
-        for (PreferencesSetting setting : category.getSettings()) {
160
+        for (final PreferencesSetting setting : category.getSettings()) {
165 161
             if (setting.isSet()) {
166 162
                 addCurrentOption(settings.get(setting));
167 163
             } else {

+ 5
- 10
src/com/dmdirc/addons/ui_swing/components/frames/AppleJFrame.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
-import com.dmdirc.addons.ui_swing.Apple;
26 25
 import com.dmdirc.addons.ui_swing.MainFrame;
27 26
 import com.dmdirc.addons.ui_swing.SwingController;
28 27
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
@@ -32,15 +31,10 @@ import javax.swing.JFrame;
32 31
 /**
33 32
  * Haxy JFrame to allow Apple to show the MenuBar in otherwise parent-less
34 33
  * dialogs.
35
- *
36
- * @author shane
37 34
  */
38 35
 public class AppleJFrame extends JFrame {
39
-    /**
40
-     * A version number for this class. It should be changed whenever the class
41
-     * structure is changed (or anything else that would prevent serialized
42
-     * objects being unserialized with the new class).
43
-     */
36
+
37
+    /** Serial version UID. */
44 38
     private static final long serialVersionUID = 1;
45 39
 
46 40
     /**
@@ -48,10 +42,11 @@ public class AppleJFrame extends JFrame {
48 42
      *
49 43
      * @param parentWindow Main Window
50 44
      */
51
-    public AppleJFrame(final MainFrame parentWindow, final SwingController controller) {
45
+    public AppleJFrame(final MainFrame parentWindow,
46
+            final SwingController controller) {
52 47
         super();
53 48
         final MenuBar menu = new MenuBar(controller, parentWindow);
54
-        Apple.getApple().setMenuBar(menu);
49
+        controller.getApple().setMenuBar(menu);
55 50
         setJMenuBar(menu);
56 51
     }
57 52
 }

+ 4
- 10
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java View File

@@ -33,11 +33,8 @@ import com.dmdirc.addons.ui_swing.UIUtilities;
33 33
 import com.dmdirc.addons.ui_swing.components.NickList;
34 34
 import com.dmdirc.addons.ui_swing.components.SplitPane;
35 35
 import com.dmdirc.addons.ui_swing.components.TopicBar;
36
-import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
37 36
 import com.dmdirc.commandparser.PopupType;
38 37
 import com.dmdirc.config.Identity;
39
-import com.dmdirc.config.IdentityManager;
40
-import com.dmdirc.interfaces.ui.InputWindow;
41 38
 
42 39
 import java.awt.Dimension;
43 40
 import java.awt.event.ActionEvent;
@@ -96,8 +93,8 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
96 93
         ActionManager.getActionManager().registerListener(this,
97 94
                 CoreActionType.CLIENT_CLOSING);
98 95
 
99
-        identity = IdentityManager.getChannelConfig(owner.getServer().
100
-                getNetwork(), owner.getChannelInfo().getName());
96
+        identity = controller.getIdentityManager().createChannelConfig(
97
+                owner.getServer().getNetwork(), owner.getChannelInfo().getName());
101 98
     }
102 99
 
103 100
     /**
@@ -159,10 +156,7 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
159 156
     @Override
160 157
     public void actionPerformed(final ActionEvent actionEvent) {
161 158
         if (actionEvent.getSource() == settingsMI) {
162
-            ChannelSettingsDialog.showChannelSettingsDialog(controller,
163
-                    (Channel) getContainer(), getController().getMainFrame(),
164
-                    (InputWindow) getController().getWindowFactory()
165
-                    .getSwingWindow(frameParent));
159
+            getController().showChannelSettingsDialog((Channel) getContainer());
166 160
         }
167 161
     }
168 162
 
@@ -281,7 +275,7 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
281 275
     @Override
282 276
     public void dispose() {
283 277
         ActionManager.getActionManager().unregisterListener(this);
284
-        IdentityManager.getGlobalConfig().removeListener(this);
278
+        controller.getGlobalConfig().removeListener(this);
285 279
         super.dispose();
286 280
     }
287 281
 }

+ 12
- 12
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java View File

@@ -35,10 +35,10 @@ import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
35 35
 import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputHandler;
36 36
 import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialog;
37 37
 import com.dmdirc.config.ConfigManager;
38
+import com.dmdirc.interfaces.ui.InputWindow;
38 39
 import com.dmdirc.logger.ErrorLevel;
39 40
 import com.dmdirc.logger.Logger;
40 41
 import com.dmdirc.ui.input.InputHandler;
41
-import com.dmdirc.interfaces.ui.InputWindow;
42 42
 
43 43
 import java.awt.BorderLayout;
44 44
 import java.awt.Point;
@@ -62,12 +62,10 @@ import net.miginfocom.layout.PlatformDefaults;
62 62
 public abstract class InputTextFrame extends TextFrame implements InputWindow,
63 63
         MouseListener {
64 64
 
65
-    /**
66
-     * A version number for this class. It should be changed whenever the class
67
-     * structure is changed (or anything else that would prevent serialized
68
-     * objects being unserialized with the new class).
69
-     */
65
+    /** Serial version UID. */
70 66
     private static final long serialVersionUID = 3;
67
+    /** Swing controller. */
68
+    private final SwingController controller;
71 69
     /** Input field panel. */
72 70
     protected JPanel inputPanel;
73 71
     /** The InputHandler for our input field. */
@@ -86,6 +84,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
86 84
     /**
87 85
      * Creates a new instance of InputFrame.
88 86
      *
87
+     * @param controller Swing controller
89 88
      * @param owner WritableFrameContainer owning this frame.
90 89
      * @param controller Swing controller
91 90
      */
@@ -93,6 +92,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
93 92
             final WritableFrameContainer owner) {
94 93
         super(owner, controller);
95 94
 
95
+        this.controller = controller;
96 96
         initComponents();
97 97
 
98 98
         final ConfigManager config = owner.getConfigManager();
@@ -293,7 +293,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
293 293
                     isDataFlavorAvailable(DataFlavor.stringFlavor)) {
294 294
                 return;
295 295
             }
296
-        } catch (IllegalStateException ex) {
296
+        } catch (final IllegalStateException ex) {
297 297
             Logger.userError(ErrorLevel.LOW, "Unable to paste from clipboard.");
298 298
             return;
299 299
         }
@@ -304,10 +304,10 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
304 304
             clipboard = (String) Toolkit.getDefaultToolkit().
305 305
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
306 306
             doPaste(clipboard);
307
-        } catch (IOException ex) {
307
+        } catch (final IOException ex) {
308 308
             Logger.userError(ErrorLevel.LOW,
309 309
                     "Unable to get clipboard contents: " + ex.getMessage());
310
-        } catch (UnsupportedFlavorException ex) {
310
+        } catch (final UnsupportedFlavorException ex) {
311 311
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
312 312
         }
313 313
     }
@@ -336,11 +336,11 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
336 336
             if (pasteTrigger != null && getContainer().getNumLines(text)
337 337
                     > pasteTrigger) {
338 338
                 //show the multi line paste dialog
339
-                new PasteDialog(this, text, getController().getMainFrame()).
340
-                        display();
339
+                new PasteDialog(controller, this, text, getController()
340
+                        .getMainFrame()).display();
341 341
             } else {
342 342
                 //send the lines
343
-                for (String clipboardLine : clipboardLines) {
343
+                for (final String clipboardLine : clipboardLines) {
344 344
                     getContainer().sendLine(clipboardLine);
345 345
                 }
346 346
             }

+ 4
- 14
src/com/dmdirc/addons/ui_swing/components/frames/ServerFrame.java View File

@@ -50,11 +50,7 @@ import net.miginfocom.swing.MigLayout;
50 50
 public final class ServerFrame extends InputTextFrame implements
51 51
         ActionListener, CertificateProblemListener {
52 52
 
53
-    /**
54
-     * A version number for this class. It should be changed whenever the class
55
-     * structure is changed (or anything else that would prevent serialized
56
-     * objects being unserialized with the new class).
57
-     */
53
+    /** Serial version UID. */
58 54
     private static final long serialVersionUID = 9;
59 55
     /** Swing controller. */
60 56
     private final SwingController controller;
@@ -99,8 +95,7 @@ public final class ServerFrame extends InputTextFrame implements
99 95
     @Override
100 96
     public void actionPerformed(final ActionEvent actionEvent) {
101 97
         if (actionEvent.getSource() == settingsMI) {
102
-            ServerSettingsDialog.showServerSettingsDialog(controller,
103
-                    getContainer().getServer(), getController().getMainFrame());
98
+            controller.showDialog(ServerSettingsDialog.class);
104 99
         }
105 100
     }
106 101
 
@@ -149,7 +144,7 @@ public final class ServerFrame extends InputTextFrame implements
149 144
     public void certificateProblemEncountered(final X509Certificate[] chain,
150 145
             final Collection<CertificateException> problems,
151 146
             final CertificateManager certificateManager) {
152
-        sslDialog = new SSLCertificateDialog(getController().getMainFrame(),
147
+        sslDialog = new SSLCertificateDialog(getController(), getController().getMainFrame(),
153 148
                 new SSLCertificateDialogModel(chain, problems, certificateManager));
154 149
         sslDialog.display();
155 150
     }
@@ -165,12 +160,7 @@ public final class ServerFrame extends InputTextFrame implements
165 160
     /** {@inheritDoc} */
166 161
     @Override
167 162
     public void windowClosing(final FrameContainer window) {
168
-        if (ServerSettingsDialog.hasServerSettingsDialog()) {
169
-            ServerSettingsDialog.getServerSettingsDialog(controller,
170
-                    getContainer().getServer(),
171
-                    getController().getMainFrame()).dispose();
172
-        }
173
-
163
+        controller.getDialogManager().dispose(ServerSettingsDialog.class);
174 164
         super.windowClosing(window);
175 165
     }
176 166
 

+ 6
- 6
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java View File

@@ -53,10 +53,10 @@ import com.dmdirc.commandparser.parsers.GlobalCommandParser;
53 53
 import com.dmdirc.config.ConfigManager;
54 54
 import com.dmdirc.interfaces.ConfigChangeListener;
55 55
 import com.dmdirc.interfaces.FrameCloseListener;
56
-import com.dmdirc.parser.common.ChannelJoinRequest;
57
-import com.dmdirc.ui.IconManager;
58 56
 import com.dmdirc.interfaces.ui.InputWindow;
59 57
 import com.dmdirc.interfaces.ui.Window;
58
+import com.dmdirc.parser.common.ChannelJoinRequest;
59
+import com.dmdirc.ui.IconManager;
60 60
 
61 61
 import java.awt.Point;
62 62
 import java.awt.event.KeyEvent;
@@ -115,7 +115,7 @@ public abstract class TextFrame extends JPanel implements Window,
115 115
             final SwingController controller) {
116 116
         super();
117 117
         this.controller = controller;
118
-        this.frameParent = owner;
118
+        frameParent = owner;
119 119
 
120 120
         final ConfigManager config = owner.getConfigManager();
121 121
 
@@ -310,7 +310,7 @@ public abstract class TextFrame extends JPanel implements Window,
310 310
      * @param newTextPane new text pane to use
311 311
      */
312 312
     protected final void setTextPane(final TextPane newTextPane) {
313
-        this.textPane = newTextPane;
313
+        textPane = newTextPane;
314 314
     }
315 315
 
316 316
     /** {@inheritDoc} */
@@ -413,7 +413,7 @@ public abstract class TextFrame extends JPanel implements Window,
413 413
         final Object[][] arguments = new Object[parts.length][1];
414 414
 
415 415
         int i = 0;
416
-        for (String part : parts) {
416
+        for (final String part : parts) {
417 417
             arguments[i++][0] = part;
418 418
         }
419 419
 
@@ -500,7 +500,7 @@ public abstract class TextFrame extends JPanel implements Window,
500 500
     private JComponent populatePopupMenu(final JComponent menu,
501 501
             final PopupMenu popup,
502 502
             final Object[][] arguments) {
503
-        for (PopupMenuItem menuItem : popup.getItems()) {
503
+        for (final PopupMenuItem menuItem : popup.getItems()) {
504 504
             if (menuItem.isDivider()) {
505 505
                 menu.add(new JSeparator());
506 506
             } else if (menuItem.isSubMenu()) {

+ 13
- 13
src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputField.java View File

@@ -22,14 +22,14 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.inputfields;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.addons.ui_swing.components.colours.ColourPickerDialog;
27 28
 import com.dmdirc.addons.ui_swing.components.frames.InputTextFrame;
28
-import com.dmdirc.config.IdentityManager;
29 29
 import com.dmdirc.interfaces.ui.InputField;
30 30
 import com.dmdirc.interfaces.ui.InputValidationListener;
31
-import com.dmdirc.util.collections.ListenerList;
32 31
 import com.dmdirc.util.ReturnableThread;
32
+import com.dmdirc.util.collections.ListenerList;
33 33
 
34 34
 import java.awt.Color;
35 35
 import java.awt.FontMetrics;
@@ -54,11 +54,7 @@ import net.miginfocom.swing.MigLayout;
54 54
 public class SwingInputField extends JComponent implements InputField,
55 55
         KeyListener, InputValidationListener, PropertyChangeListener {
56 56
 
57
-    /**
58
-     * A version number for this class. It should be changed whenever the class
59
-     * structure is changed (or anything else that would prevent serialized
60
-     * objects being unserialized with the new class).
61
-     */
57
+    /** Serial version UID. */
62 58
     private static final long serialVersionUID = 1;
63 59
     /** Colour picker. */
64 60
     private ColourPickerDialog colourPicker;
@@ -72,6 +68,8 @@ public class SwingInputField extends JComponent implements InputField,
72 68
     private final ListenerList listeners;
73 69
     /** Parent Window. */
74 70
     private final Window parentWindow;
71
+    /** Swing controller. */
72
+    private final SwingController controller;
75 73
 
76 74
     /**
77 75
      * Instantiates a new swing input field.
@@ -83,6 +81,7 @@ public class SwingInputField extends JComponent implements InputField,
83 81
             final Window parentWindow) {
84 82
         super();
85 83
 
84
+        controller = textFrame.getController();
86 85
         this.parentWindow = parentWindow;
87 86
 
88 87
         listeners = new ListenerList();
@@ -151,9 +150,10 @@ public class SwingInputField extends JComponent implements InputField,
151 150
             /** {@inheritDoc} */
152 151
             @Override
153 152
             public void run() {
154
-                if (IdentityManager.getGlobalConfig().getOptionBool("general",
153
+                if (controller.getGlobalConfig().getOptionBool("general",
155 154
                         "showcolourdialog")) {
156
-                    colourPicker = new ColourPickerDialog(irc, hex, parentWindow);
155
+                    colourPicker = new ColourPickerDialog(controller
156
+                            .getIconManager(), irc, hex, parentWindow);
157 157
                     colourPicker.addActionListener(new ActionListener() {
158 158
 
159 159
                         @Override
@@ -162,7 +162,7 @@ public class SwingInputField extends JComponent implements InputField,
162 162
                                 textField.getDocument().
163 163
                                         insertString(textField.getCaretPosition(),
164 164
                                         actionEvent.getActionCommand(), null);
165
-                            } catch (BadLocationException ex) {
165
+                            } catch (final BadLocationException ex) {
166 166
                             //Ignore, wont happen
167 167
                             }
168 168
                             colourPicker.dispose();
@@ -483,7 +483,7 @@ public class SwingInputField extends JComponent implements InputField,
483 483
      */
484 484
     @Override
485 485
     public void keyTyped(final KeyEvent e) {
486
-        for (KeyListener listener : listeners.get(KeyListener.class)) {
486
+        for (final KeyListener listener : listeners.get(KeyListener.class)) {
487 487
             listener.keyTyped(e);
488 488
         }
489 489
     }
@@ -495,7 +495,7 @@ public class SwingInputField extends JComponent implements InputField,
495 495
      */
496 496
     @Override
497 497
     public void keyPressed(final KeyEvent e) {
498
-        for (KeyListener listener : listeners.get(KeyListener.class)) {
498
+        for (final KeyListener listener : listeners.get(KeyListener.class)) {
499 499
             listener.keyPressed(e);
500 500
         }
501 501
     }
@@ -507,7 +507,7 @@ public class SwingInputField extends JComponent implements InputField,
507 507
      */
508 508
     @Override
509 509
     public void keyReleased(final KeyEvent e) {
510
-        for (KeyListener listener : listeners.get(KeyListener.class)) {
510
+        for (final KeyListener listener : listeners.get(KeyListener.class)) {
511 511
             listener.keyReleased(e);
512 512
         }
513 513
     }

+ 9
- 34
src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java View File

@@ -27,10 +27,10 @@ import com.dmdirc.addons.ui_swing.Apple;
27 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
28 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29 29
 import com.dmdirc.commandparser.parsers.CommandParser;
30
+import com.dmdirc.interfaces.ui.InputField;
30 31
 import com.dmdirc.logger.ErrorLevel;
31 32
 import com.dmdirc.logger.Logger;
32 33
 import com.dmdirc.ui.input.InputHandler;
33
-import com.dmdirc.interfaces.ui.InputField;
34 34
 
35 35
 import java.awt.event.ActionEvent;
36 36
 import java.awt.event.KeyEvent;
@@ -76,12 +76,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
76 76
 
77 77
         localTarget.getActionMap().put("upArrow", new AbstractAction() {
78 78
 
79
-            /**
80
-             * A version number for this class. It should be changed whenever
81
-             * the class structure is changed (or anything else that would
82
-             * prevent serialized objects being unserialized with the new
83
-             * class).
84
-             */
79
+            /** Serial version UID. */
85 80
             private static final long serialVersionUID = 1;
86 81
 
87 82
             /** {@inheritDoc} */
@@ -114,12 +109,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
114 109
 
115 110
         localTarget.getActionMap().put("downArrow", new AbstractAction() {
116 111
 
117
-            /**
118
-             * A version number for this class. It should be changed whenever
119
-             * the class structure is changed (or anything else that would
120
-             * prevent serialized objects being unserialized with the new
121
-             * class).
122
-             */
112
+            /** Serial version UID. */
123 113
             private static final long serialVersionUID = 1;
124 114
 
125 115
             /** {@inheritDoc} */
@@ -154,18 +144,13 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
154 144
 
155 145
         localTarget.getActionMap().put("insert-tab", new AbstractAction() {
156 146
 
157
-            /**
158
-             * A version number for this class. It should be changed whenever
159
-             * the class structure is changed (or anything else that would
160
-             * prevent serialized objects being unserialized with the new
161
-             * class).
162
-             */
147
+            /** Serial version UID. */
163 148
             private static final long serialVersionUID = 1;
164 149
 
165 150
             /** {@inheritDoc} */
166 151
             @Override
167 152
             public void actionPerformed(final ActionEvent e) {
168
-                new LoggingSwingWorker() {
153
+                new LoggingSwingWorker<Object, Void>() {
169 154
 
170 155
                     /** {@inheritDoc} */
171 156
                     @Override
@@ -186,18 +171,13 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
186 171
         localTarget.getActionMap().put("insert-shift-tab",
187 172
                 new AbstractAction() {
188 173
 
189
-            /**
190
-             * A version number for this class. It should be changed whenever
191
-             * the class structure is changed (or anything else that would
192
-             * prevent serialized objects being unserialized with the new
193
-             * class).
194
-             */
174
+            /** Serial version UID. */
195 175
             private static final long serialVersionUID = 1;
196 176
 
197 177
             /** {@inheritDoc} */
198 178
             @Override
199 179
             public void actionPerformed(final ActionEvent e) {
200
-                new LoggingSwingWorker() {
180
+                new LoggingSwingWorker<Object, Void>() {
201 181
 
202 182
                     /** {@inheritDoc} */
203 183
                     @Override
@@ -236,12 +216,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
236 216
 
237 217
         localTarget.getActionMap().put("enterButton", new AbstractAction() {
238 218
 
239
-            /**
240
-             * A version number for this class. It should be changed whenever
241
-             * the class structure is changed (or anything else that would
242
-             * prevent serialized objects being unserialized with the new
243
-             * class).
244
-             */
219
+            /** Serial version UID. */
245 220
             private static final long serialVersionUID = 1;
246 221
 
247 222
             /** {@inheritDoc} */
@@ -267,7 +242,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
267 242
                             return;
268 243
                         }
269 244
                         if (source.isEditable()) {
270
-                            new LoggingSwingWorker() {
245
+                            new LoggingSwingWorker<Object, Void>() {
271 246
 
272 247
                                 /** {@inheritDoc} */
273 248
                                 @Override

+ 16
- 12
src/com/dmdirc/addons/ui_swing/components/inputfields/TextAreaInputField.java View File

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.inputfields;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.colours.ColourPickerDialog;
26
-import com.dmdirc.config.IdentityManager;
27 27
 import com.dmdirc.interfaces.ui.InputField;
28 28
 
29 29
 import java.awt.KeyboardFocusManager;
@@ -41,24 +41,24 @@ import javax.swing.text.BadLocationException;
41 41
 public class TextAreaInputField extends JTextArea implements InputField,
42 42
         PropertyChangeListener {
43 43
 
44
-    /**
45
-     * A version number for this class. It should be changed whenever the class
46
-     * structure is changed (or anything else that would prevent serialized
47
-     * objects being unserialized with the new class).
48
-     */
44
+    /** Serial version UID. */
49 45
     private static final long serialVersionUID = 2;
50
-
51 46
     /** Colour picker. */
52 47
     protected ColourPickerDialog colourPicker;
48
+    /** Swing controller. */
49
+    private final SwingController controller;
53 50
 
54 51
     /**
55 52
      * Creates a new text area with the specified number of rows and columns.
56 53
      *
54
+     * @param controller Swing controller
57 55
      * @param rows The number of rows to use
58 56
      * @param columns The number of columns to use
59 57
      */
60
-    public TextAreaInputField(final int rows, final int columns) {
58
+    public TextAreaInputField(final SwingController controller, final int rows,
59
+            final int columns) {
61 60
         super(rows, columns);
61
+        this.controller = controller;
62 62
         KeyboardFocusManager.getCurrentKeyboardFocusManager()
63 63
                 .addPropertyChangeListener(this);
64 64
     }
@@ -66,10 +66,13 @@ public class TextAreaInputField extends JTextArea implements InputField,
66 66
     /**
67 67
      * Creates a new text area containing the specified text.
68 68
      *
69
+     * @param controller Swing controller
69 70
      * @param text The text to contain initially
70 71
      */
71
-    public TextAreaInputField(final String text) {
72
+    public TextAreaInputField(final SwingController controller,
73
+            final String text) {
72 74
         super(text);
75
+        this.controller = controller;
73 76
         KeyboardFocusManager.getCurrentKeyboardFocusManager()
74 77
                 .addPropertyChangeListener(this);
75 78
     }
@@ -89,9 +92,10 @@ public class TextAreaInputField extends JTextArea implements InputField,
89 92
     /** {@inheritDoc} */
90 93
     @Override
91 94
     public void showColourPicker(final boolean irc, final boolean hex) {
92
-        if (IdentityManager.getGlobalConfig().getOptionBool("general",
95
+        if (controller.getGlobalConfig().getOptionBool("general",
93 96
                 "showcolourdialog")) {
94
-            colourPicker = new ColourPickerDialog(irc, hex);
97
+            colourPicker = new ColourPickerDialog(controller.getIconManager(),
98
+                    irc, hex);
95 99
             colourPicker.addActionListener(new ActionListener() {
96 100
 
97 101
                 @Override
@@ -99,7 +103,7 @@ public class TextAreaInputField extends JTextArea implements InputField,
99 103
                     try {
100 104
                         getDocument().insertString(getCaretPosition(),
101 105
                                 actionEvent.getActionCommand(), null);
102
-                    } catch (BadLocationException ex) {
106
+                    } catch (final BadLocationException ex) {
103 107
                         //Ignore, wont happen
104 108
                     }
105 109
                     colourPicker.dispose();

+ 12
- 10
src/com/dmdirc/addons/ui_swing/components/inputfields/TextFieldInputField.java View File

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.inputfields;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.colours.ColourPickerDialog;
26
-import com.dmdirc.config.IdentityManager;
27 27
 import com.dmdirc.interfaces.ui.InputField;
28 28
 
29 29
 import java.awt.KeyboardFocusManager;
@@ -41,21 +41,22 @@ import javax.swing.text.BadLocationException;
41 41
 public class TextFieldInputField extends JTextField implements InputField,
42 42
         PropertyChangeListener {
43 43
 
44
-    /**
45
-     * A version number for this class. It should be changed whenever the class
46
-     * structure is changed (or anything else that would prevent serialized
47
-     * objects being unserialized with the new class).
48
-     */
44
+    /** Serial version UID. */
49 45
     private static final long serialVersionUID = 1;
50 46
     /** Colour picker. */
51 47
     protected ColourPickerDialog colourPicker;
48
+    /** Swing controller. */
49
+    private final SwingController controller;
52 50
 
53 51
     /**
54 52
      * Creates a new text field input field.
53
+     *
54
+     * @param controller Swing controller
55 55
      */
56
-    public TextFieldInputField() {
56
+    public TextFieldInputField(final SwingController controller) {
57 57
         super();
58 58
 
59
+        this.controller = controller;
59 60
         KeyboardFocusManager.getCurrentKeyboardFocusManager()
60 61
                 .addPropertyChangeListener(this);
61 62
     }
@@ -63,9 +64,10 @@ public class TextFieldInputField extends JTextField implements InputField,
63 64
     /** {@inheritDoc} */
64 65
     @Override
65 66
     public void showColourPicker(final boolean irc, final boolean hex) {
66
-        if (IdentityManager.getGlobalConfig().getOptionBool("general",
67
+        if (controller.getGlobalConfig().getOptionBool("general",
67 68
                 "showcolourdialog")) {
68
-            colourPicker = new ColourPickerDialog(irc, hex);
69
+            colourPicker = new ColourPickerDialog(controller.getIconManager(),
70
+                    irc, hex);
69 71
             colourPicker.addActionListener(new ActionListener() {
70 72
 
71 73
                 @Override
@@ -73,7 +75,7 @@ public class TextFieldInputField extends JTextField implements InputField,
73 75
                     try {
74 76
                         getDocument().insertString(getCaretPosition(),
75 77
                                 actionEvent.getActionCommand(), null);
76
-                    } catch (BadLocationException ex) {
78
+                    } catch (final BadLocationException ex) {
77 79
                         //Ignore, wont happen
78 80
                     }
79 81
                     colourPicker.dispose();

+ 12
- 10
src/com/dmdirc/addons/ui_swing/components/inputfields/TextPaneInputField.java View File

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.inputfields;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.colours.ColourPickerDialog;
26
-import com.dmdirc.config.IdentityManager;
27 27
 import com.dmdirc.interfaces.ui.InputField;
28 28
 
29 29
 import java.awt.KeyboardFocusManager;
@@ -45,24 +45,25 @@ import javax.swing.text.BadLocationException;
45 45
 public class TextPaneInputField extends JEditorPane implements InputField,
46 46
         PropertyChangeListener {
47 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
-     */
48
+    /** Serial version UID. */
53 49
     private static final long serialVersionUID = 1;
54 50
     /** Parent window. */
55 51
     private final Window parentWindow;
56 52
     /** Colour picker. */
57 53
     protected ColourPickerDialog colourPicker;
54
+    /** Swing controller. */
55
+    private final SwingController controller;
58 56
 
59 57
     /**
60 58
      * Creates a new text pane input field.
61 59
      *
60
+     * @param controller Swing controller
62 61
      * @param parentWindow Parent window, can be null
63 62
      */
64
-    public TextPaneInputField(final Window parentWindow) {
63
+    public TextPaneInputField(final SwingController controller,
64
+            final Window parentWindow) {
65 65
         super();
66
+        this.controller = controller;
66 67
         KeyboardFocusManager.getCurrentKeyboardFocusManager()
67 68
                 .addPropertyChangeListener(this);
68 69
         this.parentWindow = parentWindow;
@@ -71,9 +72,10 @@ public class TextPaneInputField extends JEditorPane implements InputField,
71 72
     /** {@inheritDoc} */
72 73
     @Override
73 74
     public void showColourPicker(final boolean irc, final boolean hex) {
74
-        if (IdentityManager.getGlobalConfig().getOptionBool("general",
75
+        if (controller.getGlobalConfig().getOptionBool("general",
75 76
                 "showcolourdialog")) {
76
-            colourPicker = new ColourPickerDialog(irc, hex, parentWindow);
77
+            colourPicker = new ColourPickerDialog(controller.getIconManager(),
78
+                    irc, hex, parentWindow);
77 79
             colourPicker.addActionListener(new ActionListener() {
78 80
 
79 81
                 @Override
@@ -81,7 +83,7 @@ public class TextPaneInputField extends JEditorPane implements InputField,
81 83
                     try {
82 84
                         getDocument().insertString(getCaretPosition(),
83 85
                                 actionEvent.getActionCommand(), null);
84
-                    } catch (BadLocationException ex) {
86
+                    } catch (final BadLocationException ex) {
85 87
                         //Ignore, wont happen
86 88
                     }
87 89
                     colourPicker.dispose();

+ 4
- 7
src/com/dmdirc/addons/ui_swing/components/inputfields/ValidatingTextFieldInputField.java View File

@@ -40,11 +40,7 @@ import javax.swing.text.BadLocationException;
40 40
 public class ValidatingTextFieldInputField extends ValidatingJTextField
41 41
         implements InputField {
42 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
-     */
43
+    /** Serial version UID. */
48 44
     private static final long serialVersionUID = 2;
49 45
     /** Colour picker. */
50 46
     private ColourPickerDialog colourPicker;
@@ -92,7 +88,8 @@ public class ValidatingTextFieldInputField extends ValidatingJTextField
92 88
     public void showColourPicker(final boolean irc, final boolean hex) {
93 89
         if (controller.getGlobalConfig().getOptionBool("general",
94 90
                 "showcolourdialog")) {
95
-            colourPicker = new ColourPickerDialog(irc, hex);
91
+            colourPicker = new ColourPickerDialog(controller.getIconManager(),
92
+                    irc, hex);
96 93
             colourPicker.addActionListener(new ActionListener() {
97 94
 
98 95
                 @Override
@@ -100,7 +97,7 @@ public class ValidatingTextFieldInputField extends ValidatingJTextField
100 97
                     try {
101 98
                         getDocument().insertString(getCaretPosition(),
102 99
                                 actionEvent.getActionCommand(), null);
103
-                    } catch (BadLocationException ex) {
100
+                    } catch (final BadLocationException ex) {
104 101
                         //Ignore, wont happen
105 102
                     }
106 103
                     colourPicker.dispose();

+ 4
- 14
src/com/dmdirc/addons/ui_swing/components/menubar/HelpMenu.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.addons.ui_swing.components.menubar;
24 24
 
25 25
 import com.dmdirc.ServerManager;
26 26
 import com.dmdirc.addons.ui_swing.Apple;
27
-import com.dmdirc.addons.ui_swing.MainFrame;
28 27
 import com.dmdirc.addons.ui_swing.SwingController;
29 28
 import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
30 29
 import com.dmdirc.addons.ui_swing.dialogs.about.AboutDialog;
@@ -40,28 +39,19 @@ import javax.swing.JMenuItem;
40 39
  */
41 40
 public class HelpMenu extends JMenu implements ActionListener {
42 41
 
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
-     */
42
+    /** Serial version UID. */
48 43
     private static final long serialVersionUID = 1;
49 44
     /** Swing controller. */
50 45
     private final SwingController controller;
51
-    /** Main frame. */
52
-    private final MainFrame mainFrame;
53 46
 
54 47
     /**
55 48
      * Instantiates a new help menu.
56 49
      *
57 50
      * @param controller Swing controller
58
-     * @param mainFrame Main frame
59 51
      */
60
-    public HelpMenu(final SwingController controller,
61
-            final MainFrame mainFrame) {
52
+    public HelpMenu(final SwingController controller) {
62 53
         super("Help");
63 54
         this.controller = controller;
64
-        this.mainFrame = mainFrame;
65 55
         setMnemonic('h');
66 56
         initHelpMenu();
67 57
     }
@@ -104,11 +94,11 @@ public class HelpMenu extends JMenu implements ActionListener {
104 94
     @Override
105 95
     public void actionPerformed(final ActionEvent e) {
106 96
         if (e.getActionCommand().equals("About")) {
107
-            AboutDialog.showAboutDialog(controller);
97
+            controller.showDialog(AboutDialog.class);
108 98
         } else if (e.getActionCommand().equals("JoinDevChat")) {
109 99
             ServerManager.getServerManager().joinDevChat();
110 100
         } else if (e.getActionCommand().equals("feedback")) {
111
-            FeedbackDialog.showFeedbackDialog(mainFrame);
101
+            controller.showDialog(FeedbackDialog.class);
112 102
         }
113 103
     }
114 104
 }

+ 3
- 3
src/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java View File

@@ -65,9 +65,9 @@ public class MenuBar extends JMenuBar {
65 65
 
66 66
         add(new ServerMenu(controller, mainFrame));
67 67
         add(new ChannelMenu(controller, mainFrame));
68
-        add(new SettingsMenu(controller, mainFrame));
68
+        add(new SettingsMenu(controller));
69 69
         add(new WindowMenuFrameManager(controller, mainFrame));
70
-        add(new HelpMenu(controller, mainFrame));
70
+        add(new HelpMenu(controller));
71 71
         final int tempCount = getComponentCount();
72 72
         add(Box.createHorizontalGlue(), "growx, pushx");
73 73
         add(new MDIBar(controller, mainFrame));
@@ -106,6 +106,6 @@ public class MenuBar extends JMenuBar {
106 106
             add(menu);
107 107
         }
108 108
 
109
-        menu.add(menuItem);
109
+        menu.add(menuItem, 0);
110 110
     }
111 111
 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/menubar/ServerMenu.java View File

@@ -116,7 +116,7 @@ public class ServerMenu extends JMenu implements ActionListener,
116 116
     @Override
117 117
     public void actionPerformed(final ActionEvent e) {
118 118
         if ("NewServer".equals(e.getActionCommand())) {
119
-            NewServerDialog.showNewServerDialog(controller);
119
+            controller.showDialog(NewServerDialog.class);
120 120
         } else if (e.getActionCommand().equals("Exit")) {
121 121
             mainFrame.quit();
122 122
         } else if (e.getActionCommand().equals("ServerSettings")) {

+ 6
- 16
src/com/dmdirc/addons/ui_swing/components/menubar/SettingsMenu.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing.components.menubar;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.Apple;
26
-import com.dmdirc.addons.ui_swing.MainFrame;
27 26
 import com.dmdirc.addons.ui_swing.SwingController;
28 27
 import com.dmdirc.addons.ui_swing.dialogs.actionsmanager.ActionsManagerDialog;
29 28
 import com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog;
@@ -41,22 +40,14 @@ import javax.swing.JMenuItem;
41 40
  */
42 41
 public class SettingsMenu extends JMenu implements ActionListener {
43 42
 
44
-    /**
45
-     * A version number for this class. It should be changed whenever the class
46
-     * structure is changed (or anything else that would prevent serialized
47
-     * objects being unserialized with the new class).
48
-     */
43
+    /** Serial version UID. */
49 44
     private static final long serialVersionUID = 1;
50 45
     /** Swing controller. */
51 46
     private final SwingController controller;
52
-    /** Main frame. */
53
-    private final MainFrame mainFrame;
54 47
 
55
-    public SettingsMenu(final SwingController controller,
56
-            final MainFrame mainFrame) {
48
+    public SettingsMenu(final SwingController controller) {
57 49
         super("Settings");
58 50
         this.controller = controller;
59
-        this.mainFrame = mainFrame;
60 51
         setMnemonic('e');
61 52
         initSettingsMenu();
62 53
     }
@@ -102,14 +93,13 @@ public class SettingsMenu extends JMenu implements ActionListener {
102 93
     @Override
103 94
     public void actionPerformed(final ActionEvent e) {
104 95
         if ("Preferences".equals(e.getActionCommand())) {
105
-            SwingPreferencesDialog.showSwingPreferencesDialog(controller);
96
+            controller.showDialog(SwingPreferencesDialog.class);
106 97
         } else if (e.getActionCommand().equals("Profile")) {
107
-            ProfileManagerDialog.showProfileManagerDialog(controller);
98
+            controller.showDialog(ProfileManagerDialog.class);
108 99
         }  else if (e.getActionCommand().equals("Actions")) {
109
-            ActionsManagerDialog.showActionsManagerDialog(mainFrame,
110
-                    controller);
100
+            controller.showDialog(ActionsManagerDialog.class);
111 101
         } else if (e.getActionCommand().equals("Aliases")) {
112
-            AliasManagerDialog.showAliasManagerDialog(controller, mainFrame);
102
+            controller.showDialog(AliasManagerDialog.class);
113 103
         }
114 104
     }
115 105
 }

+ 1
- 5
src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java View File

@@ -29,11 +29,7 @@ import com.dmdirc.parser.interfaces.Parser;
29 29
 /** Non list mode panel. */
30 30
 public final class ChannelModesPane extends ModesPane {
31 31
 
32
-    /**
33
-     * A version number for this class. It should be changed whenever the class
34
-     * structure is changed (or anything else that would prevent serialized
35
-     * objects being unserialized with the new class).
36
-     */
32
+    /** Serial version UID. */
37 33
     private static final long serialVersionUID = 1;
38 34
     /** Parent channel. */
39 35
     private final Channel channel;

+ 1
- 5
src/com/dmdirc/addons/ui_swing/components/modes/ModesComparator.java View File

@@ -30,11 +30,7 @@ import java.util.Comparator;
30 30
  */
31 31
 class ModesComparator implements Comparator<String>, Serializable {
32 32
 
33
-    /**
34
-     * A version number for this class. It should be changed whenever the
35
-     * class structure is changed (or anything else that would prevent
36
-     * serialized objects being unserialized with the new class).
37
-     */
33
+    /** Serial version UID. */
38 34
     private static final long serialVersionUID = 1;
39 35
 
40 36
     /** {@inheritDoc} */

+ 2
- 0
src/com/dmdirc/addons/ui_swing/components/modes/ModesPane.java View File

@@ -44,6 +44,8 @@ import net.miginfocom.swing.MigLayout;
44 44
  */
45 45
 public abstract class ModesPane extends JPanel {
46 46
 
47
+    /** Serial version UID. */
48
+    private static final long serialVersionUID = 1;
47 49
     /** The checkboxes used for boolean modes. */
48 50
     private final Map<String, JCheckBox> modeCheckBoxes;
49 51
     /** The ParamModePanels used for parameter-requiring modes. */

+ 14
- 14
src/com/dmdirc/addons/ui_swing/components/performpanel/PerformPanel.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing.components.performpanel;
24 24
 
25 25
 import com.dmdirc.actions.wrappers.PerformWrapper;
26 26
 import com.dmdirc.actions.wrappers.PerformWrapper.PerformDescription;
27
+import com.dmdirc.addons.ui_swing.SwingController;
27 28
 import com.dmdirc.addons.ui_swing.components.inputfields.TextAreaInputField;
28 29
 
29 30
 import java.util.Collection;
@@ -42,19 +43,14 @@ import net.miginfocom.swing.MigLayout;
42 43
  * Creates a text area that fills whatever space it has available. This panel
43 44
  * facilitates modification of performs.
44 45
  *
45
- * @author Simon Mott
46 46
  * @since 0.6.4
47 47
  */
48 48
 public class PerformPanel extends JPanel {
49 49
 
50
-    /**
51
-     * A version number for this class. It should be changed whenever the class
52
-     * structure is changed (or anything else that would prevent serialized
53
-     * objects being unserialized with the new class).
54
-     */
50
+    /** Serial version UID. */
55 51
     private static final long serialVersionUID = 1;
56 52
     /** Text area that the perform is displayed in. */
57
-    private JTextArea performSpace;
53
+    private final JTextArea performSpace;
58 54
     /** Map of performs this panel can display. */
59 55
     private final Map<PerformDescription, String[]> performs = new
60 56
             HashMap<PerformDescription, String[]>();
@@ -66,9 +62,11 @@ public class PerformPanel extends JPanel {
66 62
      * performs at the time of creation.
67 63
      *
68 64
      * By default this panel displays a blank text area.
65
+     *
66
+     * @param controller Swing controller
69 67
      */
70
-    public PerformPanel() {
71
-        this(Collections.<PerformDescription>emptyList());
68
+    public PerformPanel(final SwingController controller) {
69
+        this(controller, Collections.<PerformDescription>emptyList());
72 70
     }
73 71
 
74 72
     /**
@@ -77,16 +75,18 @@ public class PerformPanel extends JPanel {
77 75
      *
78 76
      * By default this panel displays a blank text area.
79 77
      *
78
+     * @param controller Swing controller
80 79
      * @param performs Collection of PerformDescriptions to initialise
81 80
      */
82
-    public PerformPanel(final Collection<PerformDescription> performs) {
81
+    public PerformPanel(final SwingController controller,
82
+            final Collection<PerformDescription> performs) {
83 83
         super();
84 84
 
85
-        for (PerformDescription perform : performs) {
85
+        for (final PerformDescription perform : performs) {
86 86
             addPerform(perform);
87 87
         }
88 88
         setLayout(new MigLayout("ins 0, fill"));
89
-        performSpace = new TextAreaInputField("");
89
+        performSpace = new TextAreaInputField(controller, "");
90 90
         add(new JScrollPane(performSpace), "grow, push");
91 91
     }
92 92
 
@@ -118,7 +118,7 @@ public class PerformPanel extends JPanel {
118 118
         if (visiblePerform != null) {
119 119
             performs.put(visiblePerform, performSpace.getText().split("\n"));
120 120
         }
121
-        for (Entry<PerformDescription, String[]> perform
121
+        for (final Entry<PerformDescription, String[]> perform
122 122
                 : performs.entrySet()) {
123 123
             PerformWrapper.getPerformWrapper().setPerform(perform.getKey(),
124 124
                     perform.getValue());
@@ -158,7 +158,7 @@ public class PerformPanel extends JPanel {
158 158
     private String implode(final String[] lines) {
159 159
         final StringBuilder res = new StringBuilder();
160 160
 
161
-        for (String line : lines) {
161
+        for (final String line : lines) {
162 162
             res.append('\n');
163 163
             res.append(line);
164 164
         }

+ 0
- 7
src/com/dmdirc/addons/ui_swing/components/renderers/AddonCellRenderer.java View File

@@ -36,13 +36,6 @@ import javax.swing.table.TableCellRenderer;
36 36
  */
37 37
 public class AddonCellRenderer implements TableCellRenderer {
38 38
 
39
-    /**
40
-     * A version number for this class. It should be changed whenever the class
41
-     * structure is changed (or anything else that would prevent serialized
42
-     * objects being unserialized with the new class).
43
-     */
44
-    private static final long serialVersionUID = 1;
45
-
46 39
     /** {@inheritDoc} */
47 40
     @Override
48 41
     public Component getTableCellRendererComponent(final JTable table,

+ 15
- 12
src/com/dmdirc/addons/ui_swing/components/renderers/CertificateChainEntryCellRenderer.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.renderers;
24 24
 
25
-import com.dmdirc.config.IdentityManager;
26 25
 import com.dmdirc.ui.IconManager;
27 26
 import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateChainEntry;
28 27
 
@@ -37,21 +36,25 @@ import javax.swing.JList;
37 36
  */
38 37
 public class CertificateChainEntryCellRenderer extends DefaultListCellRenderer {
39 38
 
40
-    /**
41
-     * A version number for this class. It should be changed whenever the class
42
-     * structure is changed (or anything else that would prevent serialized
43
-     * objects being unserialized with the new class).
44
-     */
39
+    /** Serial version UID. */
45 40
     private static final long serialVersionUID = 1;
46 41
     /** Icon to use for invalid entries. */
47
-    private final Icon invalidIcon = new IconManager(IdentityManager
48
-            .getGlobalConfig()).getIcon("cross");
42
+    private final Icon invalidIcon;
49 43
     /** Icon to use for trusted entries. */
50
-    private final Icon trustedIcon = new IconManager(IdentityManager
51
-            .getGlobalConfig()).getIcon("tick");
44
+    private final Icon trustedIcon;
52 45
     /** Icon to use for other entries. */
53
-    private final Icon icon = new IconManager(IdentityManager
54
-            .getGlobalConfig()).getIcon("nothing");
46
+    private final Icon icon;
47
+
48
+    /**
49
+     * Creates a new renderer.
50
+     *
51
+     * @param iconManager Icon manager
52
+     */
53
+    public CertificateChainEntryCellRenderer(final IconManager iconManager) {
54
+        icon = iconManager.getIcon("nothing");
55
+        trustedIcon = iconManager.getIcon("tick");
56
+        invalidIcon = iconManager.getIcon("cross");
57
+    }
55 58
 
56 59
     /** {@inheritDoc} */
57 60
     @Override

+ 11
- 9
src/com/dmdirc/addons/ui_swing/components/renderers/ErrorLevelIconCellRenderer.java View File

@@ -22,26 +22,28 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.renderers;
24 24
 
25
-import com.dmdirc.config.IdentityManager;
26 25
 import com.dmdirc.logger.ErrorLevel;
27 26
 import com.dmdirc.ui.IconManager;
28 27
 
29 28
 import javax.swing.JLabel;
30
-
31 29
 import javax.swing.table.DefaultTableCellRenderer;
32 30
 
33 31
 /** List cell renderer for dates. */
34 32
 public final class ErrorLevelIconCellRenderer extends DefaultTableCellRenderer {
35 33
 
36
-    /**
37
-     * A version number for this class. It should be changed whenever the class
38
-     * structure is changed (or anything else that would prevent serialized
39
-     * objects being unserialized with the new class).
40
-     */
34
+    /** Serial version UID. */
41 35
     private static final long serialVersionUID = 1;
42 36
     /** Icon manager to get icons from. */
43
-    private final IconManager iconManager = new IconManager(IdentityManager
44
-            .getGlobalConfig());
37
+    private final IconManager iconManager;
38
+
39
+    /**
40
+     * Creates a new renderer.
41
+     *
42
+     * @param iconManager Icon manager
43
+     */
44
+    public ErrorLevelIconCellRenderer(final IconManager iconManager) {
45
+        this.iconManager = iconManager;
46
+    }
45 47
 
46 48
     /** {@inheritDoc} */
47 49
     @Override

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/renderers/MapEntryRenderer.java View File

@@ -50,7 +50,7 @@ public final class MapEntryRenderer extends DefaultListCellRenderer {
50 50
         if (value == null) {
51 51
             setText("Any");
52 52
         } else if (value instanceof Entry) {
53
-            setText((String) ((Entry) value).getValue());
53
+            setText((String) ((Entry<?, ?>) value).getValue());
54 54
         } else {
55 55
             setText(value.toString());
56 56
         }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/renderers/NicklistRenderer.java View File

@@ -91,7 +91,7 @@ public final class NicklistRenderer extends DefaultListCellRenderer implements
91 91
             setBackground(altBackgroundColour);
92 92
         }
93 93
 
94
-        final Map map = ((ChannelClientInfo) value).getMap();
94
+        final Map<?, ?> map = ((ChannelClientInfo) value).getMap();
95 95
 
96 96
         if (showColours && map != null) {
97 97
             if (map.containsKey(ChannelClientProperty.NICKLIST_FOREGROUND)) {

+ 0
- 7
src/com/dmdirc/addons/ui_swing/components/renderers/ReorderableJListCellRenderer.java View File

@@ -40,13 +40,6 @@ import net.miginfocom.swing.MigLayout;
40 40
  */
41 41
 public class ReorderableJListCellRenderer implements ListCellRenderer {
42 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 43
     /** Parent list. */
51 44
     private final ReorderableJList parent;
52 45
 

+ 0
- 7
src/com/dmdirc/addons/ui_swing/components/renderers/TopicCellRenderer.java View File

@@ -39,13 +39,6 @@ import net.miginfocom.swing.MigLayout;
39 39
  */
40 40
 public class TopicCellRenderer implements TableCellRenderer {
41 41
 
42
-    /**
43
-     * A version number for this class. It should be changed whenever the class
44
-     * structure is changed (or anything else that would prevent serialized
45
-     * objects being unserialized with the new class).
46
-     */
47
-    private static final long serialVersionUID = 1;
48
-
49 42
     /**
50 43
      * {@inheritDoc}
51 44
      *

+ 4
- 8
src/com/dmdirc/addons/ui_swing/components/statusbar/ErrorPanel.java View File

@@ -50,11 +50,7 @@ import javax.swing.SwingUtilities;
50 50
 public class ErrorPanel extends StatusbarPopupPanel<JLabel> implements
51 51
         ErrorListener, ActionListener {
52 52
 
53
-    /**
54
-     * A version number for this class. It should be changed whenever the class
55
-     * structure is changed (or anything else that would prevent serialized
56
-     * objects being unserialized with the new class).
57
-     */
53
+    /** Serial version UID. */
58 54
     private static final long serialVersionUID = 2;
59 55
     /** non error state image icon. */
60 56
     private final Icon DEFAULT_ICON;
@@ -109,7 +105,7 @@ public class ErrorPanel extends StatusbarPopupPanel<JLabel> implements
109 105
     /** {@inheritDoc} */
110 106
     @Override
111 107
     protected StatusbarPopupWindow getWindow() {
112
-        return new ErrorPopup(this, mainFrame);
108
+        return new ErrorPopup(controller, this, mainFrame);
113 109
     }
114 110
 
115 111
     /** Clears the error. */
@@ -149,7 +145,7 @@ public class ErrorPanel extends StatusbarPopupPanel<JLabel> implements
149 145
                 if (errors.isEmpty()) {
150 146
                     setVisible(false);
151 147
                 } else {
152
-                    for (ProgramError error : errors) {
148
+                    for (final ProgramError error : errors) {
153 149
                         if (errorLevel == null ||
154 150
                                 !error.getLevel().moreImportant(errorLevel)) {
155 151
                             errorLevel = error.getLevel();
@@ -251,7 +247,7 @@ public class ErrorPanel extends StatusbarPopupPanel<JLabel> implements
251 247
         } else {
252 248
             final Collection<ProgramError> errors =
253 249
                     ErrorManager.getErrorManager().getErrors();
254
-            for (ProgramError error : errors) {
250
+            for (final ProgramError error : errors) {
255 251
                 ErrorManager.getErrorManager().deleteError(error);
256 252
             }
257 253
         }

+ 15
- 15
src/com/dmdirc/addons/ui_swing/components/statusbar/ErrorPopup.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
-import com.dmdirc.config.IdentityManager;
25
+import com.dmdirc.addons.ui_swing.SwingController;
26 26
 import com.dmdirc.logger.ErrorLevel;
27 27
 import com.dmdirc.logger.ErrorManager;
28 28
 import com.dmdirc.logger.ErrorReportStatus;
@@ -39,27 +39,28 @@ import javax.swing.JPanel;
39 39
 import javax.swing.JSeparator;
40 40
 
41 41
 /**
42
- * Shows a breakdown of errors that have occured.
42
+ * Shows a breakdown of errors that have occurred.
43 43
  *
44 44
  * @since 0.6.3m1
45 45
  */
46 46
 public class ErrorPopup extends StatusbarPopupWindow {
47 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
-     */
48
+    /** Serial version UID. */
53 49
     private static final long serialVersionUID = 1;
50
+    /** Icon manager. */
51
+    private final IconManager iconManager;
54 52
 
55 53
     /**
56 54
      * Creates a new error popup.
57 55
      *
56
+     * @param controller Swing controller
58 57
      * @param parent Parent panel
59 58
      * @param parentWindow Parent window
60 59
      */
61
-    public ErrorPopup(final JPanel parent, final Window parentWindow) {
62
-        super(parent, parentWindow);
60
+    public ErrorPopup(final SwingController controller, final JPanel parent,
61
+            final Window parentWindow) {
62
+        super(controller, parent, parentWindow);
63
+        iconManager = controller.getIconManager();
63 64
     }
64 65
 
65 66
     /** {@inheritDoc} */
@@ -72,7 +73,7 @@ public class ErrorPopup extends StatusbarPopupWindow {
72 73
         final MapList<ErrorReportStatus, ProgramError> statuses
73 74
                 = new MapList<ErrorReportStatus, ProgramError>();
74 75
 
75
-        for (ProgramError error : errors) {
76
+        for (final ProgramError error : errors) {
76 77
             buckets.add(error.getLevel(), error);
77 78
             statuses.add(error.getReportStatus(), error);
78 79
         }
@@ -85,13 +86,12 @@ public class ErrorPopup extends StatusbarPopupWindow {
85 86
         header.setFont(header.getFont().deriveFont(Font.BOLD));
86 87
         panel.add(header, "growx, pushx, wrap");
87 88
 
88
-        for (ErrorLevel level : ErrorLevel.values()) {
89
+        for (final ErrorLevel level : ErrorLevel.values()) {
89 90
             if (buckets.containsKey(level)) {
90 91
                 final int count = buckets.values(level).size();
91 92
 
92
-                panel.add(new JLabel(level.toString(),
93
-                        new IconManager(IdentityManager.getGlobalConfig())
94
-                        .getIcon(level.getIcon()), JLabel.LEFT));
93
+                panel.add(new JLabel(level.toString(), iconManager.getIcon(
94
+                        level.getIcon()), JLabel.LEFT));
95 95
                 panel.add(new JLabel(String.valueOf(count), JLabel.RIGHT),
96 96
                         "growx, pushx, wrap");
97 97
             }
@@ -107,7 +107,7 @@ public class ErrorPopup extends StatusbarPopupWindow {
107 107
         header.setFont(header.getFont().deriveFont(Font.BOLD));
108 108
         panel.add(header, "growx, pushx, wrap");
109 109
 
110
-        for (ErrorReportStatus status : ErrorReportStatus.values()) {
110
+        for (final ErrorReportStatus status : ErrorReportStatus.values()) {
111 111
             if (statuses.containsKey(status)) {
112 112
                 final int count = statuses.values(status).size();
113 113
 

+ 3
- 6
src/com/dmdirc/addons/ui_swing/components/statusbar/FeedbackNag.java View File

@@ -24,8 +24,6 @@ package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.SwingController;
26 26
 import com.dmdirc.addons.ui_swing.dialogs.FeedbackDialog;
27
-import com.dmdirc.config.IdentityManager;
28
-import com.dmdirc.ui.IconManager;
29 27
 import com.dmdirc.interfaces.ui.StatusBarComponent;
30 28
 
31 29
 import java.awt.event.ActionEvent;
@@ -69,8 +67,7 @@ public class FeedbackNag extends JLabel implements StatusBarComponent,
69 67
         show = new JMenuItem("Open");
70 68
         final JMenuItem dismiss = new JMenuItem("Dismiss");
71 69
 
72
-        setIcon(new IconManager(IdentityManager.getGlobalConfig()).getIcon(
73
-                "feedback"));
70
+        setIcon(controller.getIconManager().getIcon("feedback"));
74 71
         setBorder(BorderFactory.createEtchedBorder());
75 72
         setToolTipText("We would appreciate any feedback you may have about "
76 73
                 + "DMDirc.");
@@ -112,7 +109,7 @@ public class FeedbackNag extends JLabel implements StatusBarComponent,
112 109
     @Override
113 110
     public void mouseReleased(final MouseEvent e) {
114 111
         if (e.getButton() == 1) {
115
-            FeedbackDialog.showFeedbackDialog(controller.getMainFrame());
112
+            controller.showDialog(FeedbackDialog.class);
116 113
             controller.getSwingStatusBar().removeComponent(this);
117 114
         }
118 115
         checkMouseEvent(e);
@@ -157,7 +154,7 @@ public class FeedbackNag extends JLabel implements StatusBarComponent,
157 154
     @Override
158 155
     public void actionPerformed(final ActionEvent e) {
159 156
         if (e.getSource() == show) {
160
-            FeedbackDialog.showFeedbackDialog(controller.getMainFrame());
157
+            controller.showDialog(FeedbackDialog.class);
161 158
         }
162 159
         controller.getSwingStatusBar().removeComponent(this);
163 160
     }

+ 6
- 3
src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java View File

@@ -70,6 +70,8 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
70 70
     private final JMenuItem accept;
71 71
     /** Main frame. */
72 72
     private final MainFrame mainFrame;
73
+    /** Swing controller. */
74
+    private final SwingController controller;
73 75
     /** Active server. */
74 76
     private Server activeServer;
75 77
 
@@ -83,6 +85,7 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
83 85
             final MainFrame mainFrame) {
84 86
         super(new JLabel());
85 87
 
88
+        this.controller = controller;
86 89
         this.mainFrame = mainFrame;
87 90
 
88 91
         setBorder(BorderFactory.createEtchedBorder());
@@ -97,7 +100,7 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
97 100
         accept.setActionCommand("acceptAll");
98 101
         accept.addActionListener(this);
99 102
 
100
-        for (Server server : ServerManager.getServerManager().getServers()) {
103
+        for (final Server server : ServerManager.getServerManager().getServers()) {
101 104
             server.addInviteListener(this);
102 105
         }
103 106
 
@@ -115,7 +118,7 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
115 118
     /** {@inheritDoc} */
116 119
     @Override
117 120
     protected StatusbarPopupWindow getWindow() {
118
-        return new InvitePopup(this, activeServer, mainFrame);
121
+        return new InvitePopup(controller, this, activeServer, mainFrame);
119 122
     }
120 123
 
121 124
     /**
@@ -125,7 +128,7 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel> implements
125 128
         menu.removeAll();
126 129
 
127 130
         final Collection<Invite> invites = activeServer.getInvites();
128
-        for (Invite invite : invites) {
131
+        for (final Invite invite : invites) {
129 132
             menu.add(new JMenuItem(new InviteAction(invite)));
130 133
         }
131 134
         menu.add(new JSeparator());

+ 6
- 4
src/com/dmdirc/addons/ui_swing/components/statusbar/InvitePopup.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25 25
 import com.dmdirc.Invite;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.addons.ui_swing.SwingController;
27 28
 import com.dmdirc.util.DateUtils;
28 29
 
29 30
 import java.awt.Window;
@@ -50,20 +51,21 @@ public class InvitePopup extends StatusbarPopupWindow {
50 51
     /**
51 52
      * Creates a new InvitePopup for the specified panel and server.
52 53
      *
54
+     * @param controller Swing controller
53 55
      * @param parent The parent of this popup
54 56
      * @param server The server to show invites for
55 57
      * @param parentWindow Parent window
56 58
      */
57
-    public InvitePopup(final JPanel parent, final Server server,
58
-            final Window parentWindow) {
59
-        super(parent, parentWindow);
59
+    public InvitePopup(final SwingController controller, final JPanel parent,
60
+            final Server server, final Window parentWindow) {
61
+        super(controller, parent, parentWindow);
60 62
         this.server = server;
61 63
     }
62 64
 
63 65
     /** {@inheritDoc} */
64 66
     @Override
65 67
     protected void initContent(final JPanel panel) {
66
-        for (Invite invite : server.getInvites()) {
68
+        for (final Invite invite : server.getInvites()) {
67 69
             panel.add(new JLabel(invite.getChannel()), "growx, pushx");
68 70
             panel.add(new JLabel(invite.getSource()[0], JLabel.CENTER),
69 71
                     "growx, pushx, al center");

+ 12
- 11
src/com/dmdirc/addons/ui_swing/components/statusbar/MessageLabel.java View File

@@ -22,11 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
-import com.dmdirc.config.ConfigManager;
27
-import com.dmdirc.ui.IconManager;
28
-import com.dmdirc.ui.StatusMessage;
29 27
 import com.dmdirc.interfaces.ui.StatusBarComponent;
28
+import com.dmdirc.ui.StatusMessage;
30 29
 
31 30
 import java.awt.Window;
32 31
 import java.awt.event.MouseEvent;
@@ -67,23 +66,25 @@ public class MessageLabel extends JPanel implements StatusBarComponent,
67 66
     private StatusMessage currentMessage;
68 67
     /** Timer to clear the message. */
69 68
     private transient TimerTask messageTimer;
70
-    /** Config manager to read settings from. */
71
-    private ConfigManager config;
69
+    /** Swing controller. */
70
+    private final SwingController controller;
72 71
 
73 72
     /**
74 73
      * Instantiates a new message label.
75 74
      *
75
+     * @param controller Swing controller
76 76
      * @param parentWindow Parent window
77
-     * @param config Config manager to read settings from
78 77
      */
79
-    public MessageLabel(final Window parentWindow, final ConfigManager config) {
78
+    public MessageLabel(final SwingController controller,
79
+            final Window parentWindow) {
80 80
         super(new MigLayout("fill, ins 0, gap 0  0"));
81
-        this.config = config;
81
+        this.controller = controller;
82 82
         queue = new ConcurrentLinkedQueue<StatusMessage>();
83
-        defaultMessage = new StatusMessage(null, "Ready.", null, -1, config);
83
+        defaultMessage = new StatusMessage(null, "Ready.", null, -1,
84
+                controller.getGlobalConfig());
84 85
         currentMessage = defaultMessage;
85 86
         label = new JLabel();
86
-        historyLabel = new MessagePopup(this, parentWindow, config);
87
+        historyLabel = new MessagePopup(this, parentWindow, controller);
87 88
         label.setText("Ready.");
88 89
         label.setBorder(new SidelessEtchedBorder(
89 90
                 SidelessEtchedBorder.Side.RIGHT));
@@ -117,7 +118,7 @@ public class MessageLabel extends JPanel implements StatusBarComponent,
117 118
                 if (currentMessage.getIconType() == null) {
118 119
                     label.setIcon(null);
119 120
                 } else {
120
-                    label.setIcon(new IconManager(config).getIcon(
121
+                    label.setIcon(controller.getIconManager().getIcon(
121 122
                             currentMessage.getIconType()));
122 123
                 }
123 124
                 label.setText(UIUtilities.clipStringifNeeded(MessageLabel.this,

+ 12
- 12
src/com/dmdirc/addons/ui_swing/components/statusbar/MessagePopup.java View File

@@ -22,8 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26
-import com.dmdirc.ui.IconManager;
25
+import com.dmdirc.addons.ui_swing.SwingController;
27 26
 import com.dmdirc.ui.StatusMessage;
28 27
 
29 28
 import java.awt.Color;
@@ -57,31 +56,31 @@ class MessagePopup extends StatusbarTogglePanel<JLabel> {
57 56
     private final List<StatusMessage> messages;
58 57
     /** Parent panel. */
59 58
     private final JPanel parent;
60
-    /** Config manager. */
61
-    private final ConfigManager configManager;
59
+    /** Swing controller. */
60
+    private final SwingController controller;
62 61
 
63 62
     /**
64 63
      * Creates a new message history popup.
65 64
      *
66 65
      * @param parent Parent to size against
67 66
      * @param parentWindow Parent window
68
-     * @param configManager Config manager
67
+     * @param controller Swing controller
69 68
      */
70 69
     public MessagePopup(final JPanel parent, final Window parentWindow,
71
-            final ConfigManager configManager) {
70
+            final SwingController controller) {
72 71
         super(new JLabel("^"),
73 72
                 new SidelessEtchedBorder(SidelessEtchedBorder.Side.LEFT),
74 73
                 new SidelessEtchedBorder(SidelessEtchedBorder.Side.TOP));
75 74
         this.parentWindow = parentWindow;
76 75
         this.parent = parent;
77
-        this.configManager = configManager;
76
+        this.controller = controller;
78 77
         messages = new ArrayList<StatusMessage>();
79 78
     }
80 79
 
81 80
     /* {@inheritDoc} */
82 81
     @Override
83 82
     protected StatusbarPopupWindow getWindow() {
84
-        return new MessageHistoryPanel(this);
83
+        return new MessageHistoryPanel(controller, this);
85 84
     }
86 85
 
87 86
     /* {@inheritDoc} */
@@ -144,8 +143,9 @@ class MessagePopup extends StatusbarTogglePanel<JLabel> {
144 143
          *
145 144
          * @param window Parent window
146 145
          */
147
-        public MessageHistoryPanel(final JPanel parent) {
148
-            super(parent, parentWindow);
146
+        public MessageHistoryPanel(final SwingController controller,
147
+                final JPanel parent) {
148
+            super(controller, parent, parentWindow);
149 149
         }
150 150
 
151 151
         /* {@inheritDoc} */
@@ -167,9 +167,9 @@ class MessagePopup extends StatusbarTogglePanel<JLabel> {
167 167
                 return;
168 168
             }
169 169
 
170
-            for (StatusMessage message : messages) {
170
+            for (final StatusMessage message : messages) {
171 171
                 panel.add(new JLabel(message.getMessage(), message.getIconType()
172
-                        == null ? null : new IconManager(configManager)
172
+                        == null ? null : controller.getIconManager()
173 173
                         .getIcon(message.getIconType()), SwingConstants.LEFT),
174 174
                         "grow, push, wrap");
175 175
             }

+ 7
- 4
src/com/dmdirc/addons/ui_swing/components/statusbar/StatusbarPopupWindow.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
26 27
 
27 28
 import java.awt.Point;
@@ -55,11 +56,13 @@ public abstract class StatusbarPopupWindow extends StandardDialog {
55 56
     /**
56 57
      * Creates a new status bar popup window.
57 58
      *
59
+     * @param controller Swing controller
58 60
      * @param parent The {@link JPanel} to use for positioning
59 61
      * @param parentWindow Parent window
60 62
      */
61
-    public StatusbarPopupWindow(final JPanel parent, final Window parentWindow) {
62
-        super(parentWindow, ModalityType.MODELESS);
63
+    public StatusbarPopupWindow(final SwingController controller,
64
+            final JPanel parent, final Window parentWindow) {
65
+        super(controller, parentWindow, ModalityType.MODELESS);
63 66
 
64 67
         this.parent = parent;
65 68
         this.parentWindow = parentWindow;
@@ -97,8 +100,8 @@ public abstract class StatusbarPopupWindow extends StandardDialog {
97 100
      */
98 101
     protected Point getPopupLocation() {
99 102
         final Point point = parent.getLocationOnScreen();
100
-        point.translate(parent.getWidth() / 2 - this.getWidth() / 2,
101
-                - this.getHeight());
103
+        point.translate(parent.getWidth() / 2 - getWidth() / 2,
104
+                - getHeight());
102 105
         final int maxX = Math.max(parentWindow.getLocationOnScreen().x
103 106
                 + parentWindow.getWidth() - 10 - getWidth(),
104 107
                 parent.getLocationOnScreen().x + parent.getWidth() - 1

+ 4
- 5
src/com/dmdirc/addons/ui_swing/components/statusbar/SwingStatusBar.java View File

@@ -24,11 +24,11 @@ package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.MainFrame;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.interfaces.ui.StatusBar;
28
+import com.dmdirc.interfaces.ui.StatusBarComponent;
27 29
 import com.dmdirc.logger.ErrorLevel;
28 30
 import com.dmdirc.logger.Logger;
29 31
 import com.dmdirc.ui.StatusMessage;
30
-import com.dmdirc.interfaces.ui.StatusBar;
31
-import com.dmdirc.interfaces.ui.StatusBarComponent;
32 32
 
33 33
 import java.awt.Component;
34 34
 import java.util.Arrays;
@@ -69,8 +69,7 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
69 69
             final MainFrame mainFrame) {
70 70
         super();
71 71
 
72
-        messageLabel = new MessageLabel(mainFrame,
73
-                controller.getGlobalConfig());
72
+        messageLabel = new MessageLabel(controller, mainFrame);
74 73
         errorPanel = new ErrorPanel(controller, mainFrame, this);
75 74
         updateLabel = new UpdaterLabel(controller);
76 75
         inviteLabel = new InviteLabel(controller, mainFrame);
@@ -104,7 +103,7 @@ public final class SwingStatusBar extends JPanel implements StatusBar {
104 103
                     "instance of java.awt.component"));
105 104
             return;
106 105
         }
107
-        if (!Arrays.asList(getComponents()).contains((Component) component)) {
106
+        if (!Arrays.asList(getComponents()).contains(component)) {
108 107
             SwingUtilities.invokeLater(new Runnable() {
109 108
 
110 109
                 /** {@inheritDoc} */

+ 4
- 9
src/com/dmdirc/addons/ui_swing/components/statusbar/UpdaterLabel.java View File

@@ -31,14 +31,11 @@ import com.dmdirc.updater.UpdateChecker;
31 31
 import com.dmdirc.updater.UpdateChecker.STATE;
32 32
 import com.dmdirc.updater.UpdateCheckerListener;
33 33
 
34
-import java.awt.Dialog.ModalityType;
35 34
 import java.awt.event.MouseEvent;
36 35
 
37 36
 import javax.swing.BorderFactory;
38 37
 import javax.swing.JLabel;
39 38
 
40
-import lombok.Getter;
41
-
42 39
 /**
43 40
  * Updater label is responsible for handling the display of updates in the
44 41
  * status bar.
@@ -53,7 +50,6 @@ public class UpdaterLabel extends StatusbarPopupPanel<JLabel> implements
53 50
      */
54 51
     private static final long serialVersionUID = 1;
55 52
     /** Swing controller. */
56
-    @Getter
57 53
     private final SwingController controller;
58 54
 
59 55
     /**
@@ -84,12 +80,11 @@ public class UpdaterLabel extends StatusbarPopupPanel<JLabel> implements
84 80
         if (mouseEvent.getButton() == MouseEvent.BUTTON1) {
85 81
             if (UpdateChecker.getStatus().equals(
86 82
                     UpdateChecker.STATE.RESTART_REQUIRED)) {
87
-                SwingRestartDialog.showSwingRestartDialog(controller
88
-                        .getMainFrame(), ModalityType.MODELESS);
83
+                controller.showDialog(SwingRestartDialog.class);
89 84
             } else if (!UpdateChecker.getStatus().equals(
90 85
                     UpdateChecker.STATE.CHECKING)) {
91
-                SwingUpdaterDialog.showSwingUpdaterDialog(UpdateChecker
92
-                        .getAvailableUpdates(), controller.getMainFrame());
86
+                controller.showDialog(SwingUpdaterDialog.class, UpdateChecker
87
+                        .getAvailableUpdates());
93 88
             }
94 89
         }
95 90
     }
@@ -118,6 +113,6 @@ public class UpdaterLabel extends StatusbarPopupPanel<JLabel> implements
118 113
     /** {@inheritDoc} */
119 114
     @Override
120 115
     protected StatusbarPopupWindow getWindow() {
121
-        return new UpdaterPopup(this, controller.getMainFrame());
116
+        return new UpdaterPopup(controller, this, controller.getMainFrame());
122 117
     }
123 118
 }

+ 6
- 3
src/com/dmdirc/addons/ui_swing/components/statusbar/UpdaterPopup.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.updater.Update;
26 27
 import com.dmdirc.updater.UpdateChecker;
27 28
 
@@ -49,11 +50,13 @@ public class UpdaterPopup extends StatusbarPopupWindow {
49 50
     /**
50 51
      * Creates a new popup window for the specified panel and window.
51 52
      *
53
+     * @param controller Swing controller
52 54
      * @param parent The panel that owns this popup
53 55
      * @param parentWindow The Window that owns this popup
54 56
      */
55
-    public UpdaterPopup(final JPanel parent, final Window parentWindow) {
56
-        super(parent, parentWindow);
57
+    public UpdaterPopup(final SwingController controller, final JPanel parent,
58
+            final Window parentWindow) {
59
+        super(controller, parent, parentWindow);
57 60
     }
58 61
 
59 62
     /** {@inheritDoc} */
@@ -79,7 +82,7 @@ public class UpdaterPopup extends StatusbarPopupWindow {
79 82
 
80 83
             panel.add(new JSeparator(), "span, growx, pushx, wrap");
81 84
 
82
-            for (Update update : updates) {
85
+            for (final Update update : updates) {
83 86
                 panel.add(new JLabel(update.getComponent().getFriendlyName()),
84 87
                         "growx, pushx");
85 88
                 panel.add(new JLabel(update.getRemoteVersion(), JLabel.CENTER),

+ 0
- 2
src/com/dmdirc/addons/ui_swing/dialogs/ChannelJoinDialog.java View File

@@ -26,8 +26,6 @@ import com.dmdirc.addons.ui_swing.MainFrame;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27 27
 import com.dmdirc.parser.common.ChannelJoinRequest;
28 28
 
29
-import java.awt.Dialog.ModalityType;
30
-
31 29
 /**
32 30
  * A dialog to prompt the user for a channel and then join that channel.
33 31
  */

+ 4
- 4
src/com/dmdirc/addons/ui_swing/dialogs/ConfirmQuitDialog.java View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 package com.dmdirc.addons.ui_swing.dialogs;
23 23
 
24
-import java.awt.Window;
24
+import com.dmdirc.addons.ui_swing.SwingController;
25 25
 
26 26
 /**
27 27
  * A simple dialog to confirm and handle the quitting of the client.
@@ -39,10 +39,10 @@ public abstract class ConfirmQuitDialog extends StandardQuestionDialog {
39 39
     /**
40 40
      * Creates a new client quit confirmation dialog.
41 41
      *
42
-     * @param window Parent window
42
+     * @param controller Swing controller
43 43
      */
44
-    public ConfirmQuitDialog(final Window window) {
45
-        super(window, ModalityType.APPLICATION_MODAL, "Quit confirm",
44
+    public ConfirmQuitDialog(final SwingController controller) {
45
+        super(controller, ModalityType.APPLICATION_MODAL, "Quit confirm",
46 46
                     "You are about to quit DMDirc, are you sure?");
47 47
     }
48 48
 

+ 210
- 0
src/com/dmdirc/addons/ui_swing/dialogs/DialogManager.java View File

@@ -0,0 +1,210 @@
1
+/*
2
+ * Copyright (c) 2006-2011 DMDirc Developers
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;
24
+
25
+import com.dmdirc.addons.ui_swing.MainFrame;
26
+import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.SwingWindowFactory;
28
+import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
29
+import com.dmdirc.config.ConfigManager;
30
+import com.dmdirc.config.IdentityManager;
31
+import com.dmdirc.interfaces.ui.StatusBar;
32
+import com.dmdirc.ui.IconManager;
33
+import com.dmdirc.ui.core.util.URLHandler;
34
+import com.dmdirc.util.SimpleInjector;
35
+
36
+import java.awt.Window;
37
+import java.util.Collections;
38
+import java.util.HashMap;
39
+import java.util.Map;
40
+
41
+/**
42
+ * Manages the DMDirc dialogs, creates and disposes as required to ensure only
43
+ * the required number exist at any one time.
44
+ */
45
+public class DialogManager {
46
+
47
+    /** Controller used for standard parameters for dependency injection. */
48
+    private final SwingController controller;
49
+    /** Stores all known dialogs in this manager. */
50
+    private final Map<Class<? extends StandardDialog>, StandardDialog> dialogs;
51
+
52
+    /**
53
+     * Creates a new instance of the dialog manager.
54
+     *
55
+     * @param controller Parent Swing controller
56
+     */
57
+    public DialogManager(final SwingController controller) {
58
+        this.controller = controller;
59
+        dialogs = Collections.synchronizedMap(
60
+                new HashMap<Class<? extends StandardDialog>, StandardDialog>());
61
+    }
62
+
63
+    /**
64
+     * Creates, or retrieves, an instance of the specified dialog and displays
65
+     * this dialog to the user. For more details on what parameters might be
66
+     * required see {@link DialogManager#getDialog(Class, Object...)}
67
+     *
68
+     * @see DialogManager#getDialog(Class, Object...) getDialog
69
+     *
70
+     * @param klass The class of the dialog to show
71
+     * @param params Any non standard parameters required
72
+     *
73
+     * @return Dialog instance
74
+     */
75
+    public <T extends StandardDialog> T showDialog(final Class<T> klass,
76
+            final Object... params) {
77
+        final T dialog = getDialog(klass, params);
78
+        dialog.display();
79
+        return dialog;
80
+    }
81
+
82
+    /**
83
+     * Creates, or retrieves, an instance of the specified dialog.
84
+     *
85
+     * The following parameters will automatically be provided when creating a
86
+     * dialog, any extra parameters will need to be provided.
87
+     * <ul>
88
+     *   <li>SwingController</li>
89
+     *   <li>IconManager</li>
90
+     *   <li>IdentityManager</li>
91
+     *   <li>ConfigManager</li>
92
+     *   <li>MainFrame</li>
93
+     *   <li>Window</li>
94
+     *   <li>SwingStatusBar</li>
95
+     *   <li>StatusBar</li>
96
+     *   <li>SwingWindowFactory</li>
97
+     *   <li>URLHandler</li>
98
+     *   <li>DialogManager</li>
99
+     * </ul>
100
+     *
101
+     * @param klass The class of the dialog to show
102
+     * @param params Any non standard parameters required
103
+     *
104
+     * @return Dialog instance
105
+     */
106
+    @SuppressWarnings("unchecked")
107
+    public <T extends StandardDialog> T getDialog(final Class<T> klass,
108
+            final Object... params) {
109
+        final T instance;
110
+        if (dialogs.containsKey(klass)) {
111
+            instance = (T) dialogs.get(klass);
112
+        } else {
113
+            final SimpleInjector injector = getInjector(params);
114
+            instance = injector.createInstance(klass);
115
+
116
+            dialogs.put(instance.getClass(), instance);
117
+        }
118
+        return instance;
119
+    }
120
+
121
+    /**
122
+     * Creates and initialises the a dependency injector that can be used to
123
+     * create a dialog.
124
+     *
125
+     * The following parameters will automatically be provided when creating a
126
+     * dialog, any extra parameters will need to be provided.
127
+     * <ul>
128
+     *   <li>SwingController</li>
129
+     *   <li>IconManager</li>
130
+     *   <li>IdentityManager</li>
131
+     *   <li>ConfigManager</li>
132
+     *   <li>MainFrame</li>
133
+     *   <li>Window</li>
134
+     *   <li>SwingStatusBar</li>
135
+     *   <li>StatusBar</li>
136
+     *   <li>SwingWindowFactory</li>
137
+     *   <li>URLHandler</li>
138
+     *   <li>DialogManager</li>
139
+     * </ul>
140
+     *
141
+     * @param params Extra parameters to inject.
142
+     *
143
+     * @return Injector with parameters added
144
+     */
145
+    private SimpleInjector getInjector(final Object... params) {
146
+        final SimpleInjector injector = new SimpleInjector();
147
+
148
+        injector.addParameter(SwingController.class, controller);
149
+        injector.addParameter(IconManager.class, controller.getIconManager());
150
+        injector.addParameter(IdentityManager.class, controller.getIdentityManager());
151
+        injector.addParameter(ConfigManager.class, controller.getGlobalConfig());
152
+        injector.addParameter(MainFrame.class, controller.getMainFrame());
153
+        injector.addParameter(Window.class, controller.getMainFrame());
154
+        injector.addParameter(SwingStatusBar.class, controller.getSwingStatusBar());
155
+        injector.addParameter(StatusBar.class, controller.getSwingStatusBar());
156
+        injector.addParameter(SwingWindowFactory.class, controller.getWindowFactory());
157
+        injector.addParameter(URLHandler.class, controller.getURLHandler());
158
+        injector.addParameter(DialogManager.class, this);
159
+
160
+        for (final Object param : params) {
161
+            injector.addParameter(param);
162
+        }
163
+
164
+        return injector;
165
+    }
166
+
167
+    /**
168
+     * Closes the previously created instance of a dialog.
169
+     *
170
+     * @param klass The class of the dialog to show
171
+     */
172
+    public void close(final Class<? extends StandardDialog> klass) {
173
+        final StandardDialog dialog = dispose(klass);
174
+        if (dialog != null) {
175
+            dialog.dispose();
176
+        }
177
+    }
178
+
179
+    /**
180
+     * Removes a previously created instance of a dialog from the dialog
181
+     * manager.
182
+     *
183
+     * @param klass The class of the dialog to show
184
+     *
185
+     * @return Instance of the dialog that has been removed or null if there
186
+     * was no dialog created
187
+     */
188
+    public StandardDialog dispose(final Class<? extends StandardDialog> klass) {
189
+        if (dialogs.containsKey(klass)) {
190
+            return dialogs.remove(dialogs.get(klass));
191
+        }
192
+        return null;
193
+    }
194
+
195
+    /**
196
+     * Removes a previously created instance of a dialog from the dialog
197
+     * manager.
198
+     *
199
+     * @param klass The class of the dialog to show
200
+     *
201
+     * @return Instance of the dialog that has been removed or null if there
202
+     * was no dialog created
203
+     */
204
+    public StandardDialog dispose(final StandardDialog dialog) {
205
+        if (dialogs.containsKey(dialog.getClass())) {
206
+            return dispose(dialog.getClass());
207
+        }
208
+        return null;
209
+    }
210
+}

+ 18
- 67
src/com/dmdirc/addons/ui_swing/dialogs/FeedbackDialog.java View File

@@ -32,7 +32,6 @@ import com.dmdirc.addons.ui_swing.components.text.TextLabel;
32 32
 import com.dmdirc.ui.core.util.Info;
33 33
 
34 34
 import java.awt.Insets;
35
-import java.awt.Window;
36 35
 import java.awt.event.ActionEvent;
37 36
 import java.awt.event.ActionListener;
38 37
 
@@ -46,20 +45,17 @@ import javax.swing.JTextField;
46 45
 import javax.swing.event.DocumentEvent;
47 46
 import javax.swing.event.DocumentListener;
48 47
 
48
+import lombok.AutoGenMethodStub;
49
+
49 50
 import net.miginfocom.swing.MigLayout;
50 51
 
51 52
 /** Feedback form. */
53
+@AutoGenMethodStub
52 54
 public final class FeedbackDialog extends StandardDialog implements
53 55
         ActionListener, DocumentListener {
54 56
 
55
-    /**
56
-     * A version number for this class. It should be changed whenever the class
57
-     * structure is changed (or anything else that would prevent serialized
58
-     * objects being unserialized with the new class).
59
-     */
57
+    /** Serial version UID. */
60 58
     private static final long serialVersionUID = 1;
61
-    /** A previously created instance of FeedbackDialog. */
62
-    private static FeedbackDialog me;
63 59
     /** Information label. */
64 60
     private TextLabel info;
65 61
     /** Name field. */
@@ -78,10 +74,10 @@ public final class FeedbackDialog extends StandardDialog implements
78 74
     /**
79 75
      * Instantiates the feedback dialog.
80 76
      *
81
-     * @param parentWindow Parent window
77
+     * @param controller Swing controller
82 78
      */
83
-    private FeedbackDialog(final Window parentWindow) {
84
-        super(parentWindow, ModalityType.MODELESS);
79
+    public FeedbackDialog(final SwingController controller) {
80
+        super(controller, ModalityType.MODELESS);
85 81
 
86 82
         initComponents();
87 83
         layoutComponents();
@@ -91,41 +87,6 @@ public final class FeedbackDialog extends StandardDialog implements
91 87
         setResizable(false);
92 88
     }
93 89
 
94
-    /**
95
-     * Creates the new feedback dialog if one doesn't exist, and displays it.
96
-     *
97
-     * @param parentWindow Parent window
98
-     */
99
-    public static void showFeedbackDialog(final Window parentWindow) {
100
-        me = getFeedbackDialog(parentWindow);
101
-
102
-        me.display();
103
-        me.requestFocusInWindow();
104
-    }
105
-
106
-    /**
107
-     * Returns the current instance of the FeedbackDialog.
108
-     *
109
-     * @param parentWindow Parent window
110
-     *
111
-     * @return The current FeedbackDialog instance
112
-     */
113
-    public static FeedbackDialog getFeedbackDialog(final Window parentWindow) {
114
-        synchronized (FeedbackDialog.class) {
115
-            if (me == null) {
116
-                me = new FeedbackDialog(parentWindow);
117
-                me.serverCheckbox.setEnabled(ServerManager.getServerManager().
118
-                        numServers() > 0);
119
-            } else if (!me.isVisible()) {
120
-                me = new FeedbackDialog(parentWindow);
121
-                me.serverCheckbox.setEnabled(ServerManager.getServerManager().
122
-                    numServers() > 0);
123
-            }
124
-        }
125
-
126
-        return me;
127
-    }
128
-
129 90
     /** Initialises the components. */
130 91
     private void initComponents() {
131 92
         orderButtons(new JButton(), new JButton());
@@ -258,7 +219,7 @@ public final class FeedbackDialog extends StandardDialog implements
258 219
             dmdircInfo.append("Look & Feel: ").append(
259 220
                     SwingController.getLookAndFeel());
260 221
         }
261
-        new SendWorker(me, name.getText().trim(), email.getText().trim(),
222
+        new SendWorker(this, name.getText().trim(), email.getText().trim(),
262 223
                 feedback.getText().trim(), serverInfo.toString().trim(),
263 224
                 dmdircInfo.toString().trim()).executeInExecutor();
264 225
     }
@@ -288,33 +249,23 @@ public final class FeedbackDialog extends StandardDialog implements
288 249
         }
289 250
     }
290 251
 
291
-    /** {@inheritDoc} */
252
+    /**
253
+     * @{inheritDoc}
254
+     *
255
+     * @param e Document event
256
+     */
292 257
     @Override
293 258
     public void insertUpdate(final DocumentEvent e) {
294 259
         validateInput();
295 260
     }
296 261
 
297
-    /** {@inheritDoc} */
262
+    /**
263
+     * {@inheritDoc}
264
+     *
265
+     * @param e Document event
266
+     */
298 267
     @Override
299 268
     public void removeUpdate(final DocumentEvent e) {
300 269
         validateInput();
301 270
     }
302
-
303
-    /** {@inheritDoc} */
304
-    @Override
305
-    public void changedUpdate(final DocumentEvent e) {
306
-    //Ignore
307
-    }
308
-
309
-    /** {@inheritDoc} */
310
-    @Override
311
-    public void dispose() {
312
-        if (me == null) {
313
-            return;
314
-        }
315
-        synchronized (me) {
316
-            super.dispose();
317
-            me = null;
318
-        }
319
-    }
320 271
 }

+ 14
- 75
src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java View File

@@ -32,7 +32,6 @@ import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxModel;
32 32
 import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxSelectionListener;
33 33
 import com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog;
34 34
 import com.dmdirc.config.Identity;
35
-import com.dmdirc.config.IdentityManager;
36 35
 import com.dmdirc.logger.ErrorLevel;
37 36
 import com.dmdirc.logger.Logger;
38 37
 import com.dmdirc.util.validators.PortValidator;
@@ -63,14 +62,8 @@ import net.miginfocom.swing.MigLayout;
63 62
 public final class NewServerDialog extends StandardDialog implements
64 63
         ActionListener, VetoableComboBoxSelectionListener {
65 64
 
66
-    /**
67
-     * A version number for this class. It should be changed whenever the class
68
-     * structure is changed (or anything else that would prevent serialized
69
-     * objects being unserialized with the new class).
70
-     */
65
+    /** Serial version UID. */
71 66
     private static final long serialVersionUID = 8;
72
-    /** A previously created instance of NewServerDialog. */
73
-    private static volatile NewServerDialog me;
74 67
     /** checkbox. */
75 68
     private JCheckBox newServerWindowCheck;
76 69
     /** checkbox. */
@@ -85,8 +78,6 @@ public final class NewServerDialog extends StandardDialog implements
85 78
     private JComboBox identityField;
86 79
     /** button. */
87 80
     private JButton editProfileButton;
88
-    /** Swing controller. */
89
-    private final SwingController controller;
90 81
     /**  Opening new server? */
91 82
     private boolean openingServer = false;
92 83
 
@@ -95,10 +86,8 @@ public final class NewServerDialog extends StandardDialog implements
95 86
      *
96 87
      * @param mainFrame Main frame
97 88
      */
98
-    private NewServerDialog(final SwingController controller) {
99
-        super(controller.getMainFrame(), ModalityType.MODELESS);
100
-
101
-        this.controller = controller;
89
+    public NewServerDialog(final SwingController controller) {
90
+        super(controller, controller.getMainFrame(), ModalityType.MODELESS);
102 91
 
103 92
         initComponents();
104 93
         layoutComponents();
@@ -117,51 +106,13 @@ public final class NewServerDialog extends StandardDialog implements
117 106
         serverField.requestFocus();
118 107
     }
119 108
 
120
-    /**
121
-     * Creates the new server dialog if one doesn't exist, and displays it.
122
-     *
123
-     * @param controller Swing controller
124
-     */
125
-    public static void showNewServerDialog(final SwingController controller) {
126
-        me = getNewServerDialog(controller);
127
-
128
-        me.display();
129
-    }
130
-
131
-    /**
132
-     * Returns the current instance of the NewServerDialog.
133
-     *
134
-     * @param controller Swing controller
135
-     *
136
-     * @return The current NewServerDialog instance
137
-     */
138
-    public static NewServerDialog getNewServerDialog(
139
-            final SwingController controller) {
140
-        synchronized (NewServerDialog.class) {
141
-            if (me == null) {
142
-                me = new NewServerDialog(controller);
143
-            }
144
-        }
145
-
146
-        return me;
147
-    }
148
-
149
-    /**
150
-     * Is the new server dialog showing?
151
-     *
152
-     * @return true iif the NSD is showing
153
-     */
154
-    public static synchronized boolean isNewServerDialogShowing() {
155
-        return me != null;
156
-    }
157
-
158 109
     /** Updates the values to defaults. */
159 110
     private void update() {
160
-        serverField.setText(controller.getGlobalConfig().getOption("general",
111
+        serverField.setText(getController().getGlobalConfig().getOption("general",
161 112
                 "server"));
162
-        portField.setText(controller.getGlobalConfig().getOption("general",
113
+        portField.setText(getController().getGlobalConfig().getOption("general",
163 114
                 "port"));
164
-        passwordField.setText(controller.getGlobalConfig().getOption("general",
115
+        passwordField.setText(getController().getGlobalConfig().getOption("general",
165 116
                 "password"));
166 117
         sslCheck.setSelected(false);
167 118
         newServerWindowCheck.setEnabled(false);
@@ -169,7 +120,7 @@ public final class NewServerDialog extends StandardDialog implements
169 120
         serverField.requestFocusInWindow();
170 121
 
171 122
         if (ServerManager.getServerManager().numServers() == 0 ||
172
-                controller.getMainFrame().getActiveFrame() == null) {
123
+                getController().getMainFrame().getActiveFrame() == null) {
173 124
             newServerWindowCheck.setSelected(true);
174 125
             newServerWindowCheck.setEnabled(false);
175 126
         } else {
@@ -194,9 +145,9 @@ public final class NewServerDialog extends StandardDialog implements
194 145
      * Initialises the components in this dialog.
195 146
      */
196 147
     private void initComponents() {
197
-        serverField = new ValidatingJTextField(controller.getIconManager(),
148
+        serverField = new ValidatingJTextField(getController().getIconManager(),
198 149
                 new ServerNameValidator());
199
-        portField = new ValidatingJTextField(controller.getIconManager(),
150
+        portField = new ValidatingJTextField(getController().getIconManager(),
200 151
                 new PortValidator());
201 152
         passwordField = new JPasswordField();
202 153
         newServerWindowCheck = new JCheckBox();
@@ -225,8 +176,8 @@ public final class NewServerDialog extends StandardDialog implements
225 176
 
226 177
     /** Populates the profiles list. */
227 178
     public void populateProfiles() {
228
-        final List<Identity> profiles = IdentityManager.getCustomIdentities(
229
-                "profile");
179
+        final List<Identity> profiles = getController().getIdentityManager()
180
+                .getIdentitiesByType("profile");
230 181
         ((DefaultComboBoxModel) identityField.getModel()).removeAllElements();
231 182
         for (Identity profile : profiles) {
232 183
             ((DefaultComboBoxModel) identityField.getModel()).addElement(profile);
@@ -291,7 +242,7 @@ public final class NewServerDialog extends StandardDialog implements
291 242
             // Open in a new window?
292 243
             if (newServerWindowCheck.isSelected()
293 244
                     || ServerManager.getServerManager().numServers() == 0
294
-                    || controller.getMainFrame().getActiveFrame() == null) {
245
+                    || getController().getMainFrame().getActiveFrame() == null) {
295 246
 
296 247
                 new LoggingSwingWorker<Void, Void>() {
297 248
                     @Override
@@ -302,7 +253,7 @@ public final class NewServerDialog extends StandardDialog implements
302 253
                     }
303 254
                 }.executeInExecutor();
304 255
             } else {
305
-                final Server server = controller.getMainFrame()
256
+                final Server server = getController().getMainFrame()
306 257
                         .getActiveFrame().getContainer().getServer();
307 258
 
308 259
                 new LoggingSwingWorker<Void, Void>() {
@@ -335,7 +286,7 @@ public final class NewServerDialog extends StandardDialog implements
335 286
         if (e.getSource() == getOkButton()) {
336 287
             save();
337 288
         } else if (e.getSource() == editProfileButton) {
338
-            ProfileManagerDialog.showProfileManagerDialog(controller);
289
+            getController().showDialog(ProfileManagerDialog.class);
339 290
         } else if (e.getSource() == getCancelButton()) {
340 291
             dispose();
341 292
         }
@@ -348,18 +299,6 @@ public final class NewServerDialog extends StandardDialog implements
348 299
         return true;
349 300
     }
350 301
 
351
-    /** {@inheritDoc} */
352
-    @Override
353
-    public void dispose() {
354
-        if (me == null) {
355
-            return;
356
-        }
357
-        synchronized (NewServerDialog.this) {
358
-            super.dispose();
359
-            me = null;
360
-        }
361
-    }
362
-
363 302
     /** {@inheritDoc} */
364 303
     @Override
365 304
     public boolean selectionChanged(final VetoableChangeEvent e) {

+ 111
- 8
src/com/dmdirc/addons/ui_swing/dialogs/StandardDialog.java View File

@@ -22,7 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs;
24 24
 
25
+import com.dmdirc.addons.ui_swing.MainFrame;
26
+import com.dmdirc.addons.ui_swing.SwingController;
25 27
 import com.dmdirc.ui.CoreUIUtils;
28
+import com.dmdirc.ui.IconManager;
26 29
 
27 30
 import java.awt.Component;
28 31
 import java.awt.Dialog;
@@ -37,17 +40,21 @@ import javax.swing.JButton;
37 40
 import javax.swing.JDialog;
38 41
 import javax.swing.SwingUtilities;
39 42
 
43
+import lombok.Getter;
44
+
40 45
 /**
41 46
  * Provides common methods for dialogs.
42 47
  */
48
+@SuppressWarnings("unused")
43 49
 public class StandardDialog extends JDialog {
44 50
 
45
-    /**
46
-     * A version number for this class. It should be changed whenever the class
47
-     * structure is changed (or anything else that would prevent serialized
48
-     * objects being unserialized with the new class).
49
-     */
51
+    /** Serial version UID. */
50 52
     private static final long serialVersionUID = 1;
53
+    /** Dialog manager. */
54
+    private final DialogManager dialogManager;
55
+    /** Swing controller. */
56
+    @Getter
57
+    private SwingController controller;
51 58
     /** The OK button for this frame. */
52 59
     private JButton okButton;
53 60
     /** The cancel button for this frame. */
@@ -55,14 +62,65 @@ public class StandardDialog extends JDialog {
55 62
     /** Parent window. */
56 63
     private Window owner;
57 64
 
65
+
66
+
67
+    /**
68
+     * Creates a new instance of StandardDialog.
69
+     *
70
+     * @param controller Parent swing controller
71
+     * @param modal Whether to display modally or not
72
+     */
73
+    public StandardDialog(final SwingController controller,
74
+            final ModalityType modal) {
75
+        super(controller.getMainFrame(), modal);
76
+        this.owner = controller.getMainFrame();
77
+        this.controller = controller;
78
+        dialogManager = controller.getDialogManager();
79
+
80
+        if (owner != null) {
81
+            setIconImages(owner.getIconImages());
82
+        }
83
+        orderButtons(new JButton(), new JButton());
84
+        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
85
+    }
86
+
58 87
     /**
59 88
      * Creates a new instance of StandardDialog.
89
+     *
90
+     * @param controller Parent swing controller
91
+     * @param modal Whether to display modally or not
92
+     */
93
+    public StandardDialog(final SwingController controller,
94
+            final boolean modal) {
95
+        super(controller.getMainFrame(), modal);
96
+        this.owner = controller.getMainFrame();
97
+        this.controller = controller;
98
+        dialogManager = controller.getDialogManager();
99
+
100
+        if (owner != null) {
101
+            setIconImages(owner.getIconImages());
102
+        }
103
+        orderButtons(new JButton(), new JButton());
104
+        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
105
+    }
106
+
107
+    /**
108
+     * Creates a new instance of StandardDialog.
109
+     *
110
+     * @param controller Parent swing controller
60 111
      * @param owner The frame that owns this dialog
61 112
      * @param modal Whether to display modally or not
62 113
      */
63
-    public StandardDialog(final Frame owner, final boolean modal) {
114
+    public StandardDialog(final SwingController controller, final Frame owner,
115
+            final boolean modal) {
64 116
         super(owner, modal);
65 117
         this.owner = owner;
118
+        this.controller = controller;
119
+        if (controller != null) {
120
+            dialogManager = controller.getDialogManager();
121
+        } else {
122
+            dialogManager = null;
123
+        }
66 124
 
67 125
         if (owner != null) {
68 126
             setIconImages(owner.getIconImages());
@@ -73,12 +131,21 @@ public class StandardDialog extends JDialog {
73 131
 
74 132
     /**
75 133
      * Creates a new instance of StandardDialog.
134
+     *
135
+     * @param controller Parent swing controller
76 136
      * @param owner The frame that owns this dialog
77 137
      * @param modal Whether to display modally or not
78 138
      */
79
-    public StandardDialog(final Window owner, final ModalityType modal) {
139
+    public StandardDialog(final SwingController controller, final Window owner,
140
+            final ModalityType modal) {
80 141
         super(owner, modal);
81 142
         this.owner = owner;
143
+        this.controller = controller;
144
+        if (controller != null) {
145
+            dialogManager = controller.getDialogManager();
146
+        } else {
147
+            dialogManager = null;
148
+        }
82 149
 
83 150
         if (owner != null) {
84 151
             setIconImages(owner.getIconImages());
@@ -89,12 +156,21 @@ public class StandardDialog extends JDialog {
89 156
 
90 157
     /**
91 158
      * Creates a new instance of StandardDialog.
159
+     *
160
+     * @param controller Parent swing controller
92 161
      * @param owner The frame that owns this dialog
93 162
      * @param modal Whether to display modally or not
94 163
      */
95
-    public StandardDialog(final Dialog owner, final boolean modal) {
164
+    public StandardDialog(final SwingController controller, final Dialog owner,
165
+            final boolean modal) {
96 166
         super(owner, modal);
97 167
         this.owner = owner;
168
+        this.controller = controller;
169
+        if (controller != null) {
170
+            dialogManager = controller.getDialogManager();
171
+        } else {
172
+            dialogManager = null;
173
+        }
98 174
 
99 175
         if (owner != null) {
100 176
             setIconImages(owner.getIconImages());
@@ -108,6 +184,15 @@ public class StandardDialog extends JDialog {
108 184
         super.setTitle("DMDirc: " + title);
109 185
     }
110 186
 
187
+    /** {@inheritDoc} */
188
+    @Override
189
+    public void dispose() {
190
+        if (dialogManager != null) {
191
+            dialogManager.dispose(this);
192
+        }
193
+        super.dispose();
194
+    }
195
+
111 196
     /**
112 197
      * Displays the dialog centering on the parent window.
113 198
      */
@@ -323,4 +408,22 @@ public class StandardDialog extends JDialog {
323 408
         executeAction(getCancelButton());
324 409
         return true;
325 410
     }
411
+
412
+    /**
413
+     * Returns the Swing main frame.
414
+     *
415
+     * @return Main frame
416
+     */
417
+    public MainFrame getMainFrame() {
418
+        return getController().getMainFrame();
419
+    }
420
+
421
+    /**
422
+     * Returns the icon manager.
423
+     *
424
+     * @return Icon manager
425
+     */
426
+    public IconManager getIconManager() {
427
+        return getController().getIconManager();
428
+    }
326 429
 }

+ 5
- 6
src/com/dmdirc/addons/ui_swing/dialogs/StandardInputDialog.java View File

@@ -48,6 +48,8 @@ import net.miginfocom.swing.MigLayout;
48 48
  */
49 49
 public abstract class StandardInputDialog extends StandardDialog {
50 50
 
51
+    /** Serial version UID. */
52
+    private static final long serialVersionUID = 1;
51 53
     /** Validator. */
52 54
     private Validator<String> validator;
53 55
     /** Text field. */
@@ -58,8 +60,6 @@ public abstract class StandardInputDialog extends StandardDialog {
58 60
     private String message;
59 61
     /** Are we saving? */
60 62
     protected final AtomicBoolean saving = new AtomicBoolean(false);
61
-    /** Swing controller. */
62
-    private final SwingController controller;
63 63
 
64 64
     /**
65 65
      * Instantiates a new standard input dialog.
@@ -97,9 +97,8 @@ public abstract class StandardInputDialog extends StandardDialog {
97 97
             final Window owner, final ModalityType modal,
98 98
             final String title, final String message,
99 99
             final Validator<String> validator) {
100
-        super(owner, modal);
100
+        super(controller, owner, modal);
101 101
 
102
-        this.controller = controller;
103 102
         this.validator = validator;
104 103
         this.message = message;
105 104
 
@@ -128,10 +127,10 @@ public abstract class StandardInputDialog extends StandardDialog {
128 127
      */
129 128
     private void initComponents() {
130 129
         orderButtons(new JButton(), new JButton());
131
-        if (controller == null) {
130
+        if (getController() == null) {
132 131
             textField = new ValidatingJTextField(new IconManager(new ConfigManager("", "", "", "")), validator);
133 132
         } else {
134
-            textField = new ValidatingJTextField(controller.getIconManager(), validator);
133
+            textField = new ValidatingJTextField(getController().getIconManager(), validator);
135 134
         }
136 135
         blurb = new TextLabel(message);
137 136
         validateText();

+ 7
- 8
src/com/dmdirc/addons/ui_swing/dialogs/StandardMessageDialog.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26 27
 
27 28
 import java.awt.Window;
@@ -39,11 +40,7 @@ import net.miginfocom.swing.MigLayout;
39 40
  */
40 41
 public class StandardMessageDialog extends StandardDialog {
41 42
 
42
-    /**
43
-     * A version number for this class. It should be changed whenever the class
44
-     * structure is changed (or anything else that would prevent serialized
45
-     * objects being unserialized with the new class).
46
-     */
43
+    /** Serial version UID. */
47 44
     private static final long serialVersionUID = 1;
48 45
     /** Message. */
49 46
     private final String message;
@@ -53,14 +50,16 @@ public class StandardMessageDialog extends StandardDialog {
53 50
     /**
54 51
      * Instantiates a new standard input dialog.
55 52
      *
53
+     * @param controller Swing controller
56 54
      * @param owner Dialog owner
57 55
      * @param modal modality type
58 56
      * @param title Dialog title
59 57
      * @param message Dialog message
60 58
      */
61
-    public StandardMessageDialog(final Window owner, final ModalityType modal,
62
-            final String title, final String message) {
63
-        super(owner, modal);
59
+    public StandardMessageDialog(final SwingController controller,
60
+            final Window owner, final ModalityType modal, final String title,
61
+            final String message) {
62
+        super(controller, owner, modal);
64 63
 
65 64
         this.message = message;
66 65
 

+ 31
- 3
src/com/dmdirc/addons/ui_swing/dialogs/StandardQuestionDialog.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
26 27
 
27 28
 import java.awt.Window;
@@ -39,6 +40,8 @@ import net.miginfocom.swing.MigLayout;
39 40
  */
40 41
 public abstract class StandardQuestionDialog extends StandardDialog {
41 42
 
43
+    /** Serial version UID. */
44
+    private static final long serialVersionUID = 1;
42 45
     /** Message. */
43 46
     private final String message;
44 47
     /** Blurb label. */
@@ -49,14 +52,39 @@ public abstract class StandardQuestionDialog extends StandardDialog {
49 52
     /**
50 53
      * Instantiates a new standard input dialog.
51 54
      *
55
+     * @param controller Swing controller
52 56
      * @param owner Dialog owner
53 57
      * @param modal modality type
54 58
      * @param title Dialog title
55 59
      * @param message Dialog message
56 60
      */
57
-    public StandardQuestionDialog(final Window owner, final ModalityType modal,
58
-            final String title, final String message) {
59
-        super(owner, modal);
61
+    public StandardQuestionDialog(final SwingController controller,
62
+            final Window owner, final ModalityType modal, final String title,
63
+            final String message) {
64
+        super(controller, owner, modal);
65
+
66
+        this.message = message;
67
+
68
+        setTitle(title);
69
+        setDefaultCloseOperation(StandardInputDialog.DISPOSE_ON_CLOSE);
70
+
71
+        initComponents();
72
+        addListeners();
73
+        layoutComponents();
74
+    }
75
+
76
+    /**
77
+     * Instantiates a new standard input dialog.
78
+     *
79
+     * @param controller Swing controller
80
+     * @param modal modality type
81
+     * @param title Dialog title
82
+     * @param message Dialog message
83
+     */
84
+    public StandardQuestionDialog(final SwingController controller,
85
+            final ModalityType modal, final String title,
86
+            final String message) {
87
+        super(controller, modal);
60 88
 
61 89
         this.message = message;
62 90
 

+ 8
- 59
src/com/dmdirc/addons/ui_swing/dialogs/about/AboutDialog.java View File

@@ -42,65 +42,25 @@ import net.miginfocom.swing.MigLayout;
42 42
 public final class AboutDialog extends StandardDialog implements
43 43
         ActionListener, ChangeListener {
44 44
 
45
-    /**
46
-     * A version number for this class. It should be changed whenever the class
47
-     * structure is changed (or anything else that would prevent serialized
48
-     * objects being unserialized with the new class).
49
-     */
45
+    /** Serial version UID. */
50 46
     private static final long serialVersionUID = 5;
51
-    /** Previously created instance of AboutDialog. */
52
-    private static AboutDialog me = null;
53 47
     /** Tabbed pane to use. */
54 48
     private JTabbedPane tabbedPane;
55 49
     /** Credits panel. */
56 50
     private CreditsPanel cp;
57 51
     /** Tab history. */
58 52
     private int history = 0;
59
-    /** Parent swing controller. */
60
-    private SwingController controller;
61
-
62 53
     /**
63 54
      * Creates a new instance of AboutDialog.
64 55
      *
65 56
      * @param controller Parent controller
66 57
      */
67
-    private AboutDialog(final SwingController controller) {
68
-        super(controller.getMainFrame(), ModalityType.MODELESS);
69
-
70
-        this.controller = controller;
58
+    public AboutDialog(final SwingController controller) {
59
+        super(controller, ModalityType.MODELESS);
71 60
 
72 61
         initComponents();
73 62
     }
74 63
 
75
-    /**
76
-     * Creates the dialog if one doesn't exist, and displays it.
77
-     *
78
-     * @param controller Parent controller
79
-     */
80
-    public static void showAboutDialog(final SwingController controller) {
81
-        me = getAboutDialog(controller);
82
-
83
-        me.display();
84
-        me.requestFocusInWindow();
85
-    }
86
-
87
-    /**
88
-     * Returns the current instance of the AboutDialog.
89
-     *
90
-     * @param controller Parent controller
91
-     *
92
-     * @return The current AboutDialog instance
93
-     */
94
-    public static AboutDialog getAboutDialog(final SwingController controller) {
95
-        synchronized (AboutDialog.class) {
96
-            if (me == null) {
97
-                me = new AboutDialog(controller);
98
-            }
99
-        }
100
-
101
-        return me;
102
-    }
103
-
104 64
     /** Initialises the main UI components. */
105 65
     private void initComponents() {
106 66
         tabbedPane = new JTabbedPane();
@@ -114,12 +74,13 @@ public final class AboutDialog extends StandardDialog implements
114 74
         getOkButton().addActionListener(this);
115 75
         getCancelButton().addActionListener(this);
116 76
 
117
-        cp = new CreditsPanel(controller.getURLHandler());
77
+        cp = new CreditsPanel(getController().getURLHandler());
118 78
 
119
-        tabbedPane.add("About", new AboutPanel(controller.getURLHandler()));
79
+        tabbedPane.add("About", new AboutPanel(getController().getURLHandler()));
120 80
         tabbedPane.add("Credits", cp);
121
-        tabbedPane.add("Licences", new LicencesPanel());
122
-        tabbedPane.add("Information", new InfoPanel(controller));
81
+        tabbedPane.add("Licences", new LicencesPanel(getController()
82
+                .getGlobalConfig()));
83
+        tabbedPane.add("Information", new InfoPanel(getController()));
123 84
         tabbedPane.addChangeListener(this);
124 85
 
125 86
         getContentPane().setLayout(new MigLayout("ins rel, wrap 1, fill, " +
@@ -145,18 +106,6 @@ public final class AboutDialog extends StandardDialog implements
145 106
         return true;
146 107
     }
147 108
 
148
-    /** {@inheritDoc} */
149
-    @Override
150
-    public void dispose() {
151
-        if (me == null) {
152
-            return;
153
-        }
154
-        synchronized (me) {
155
-            super.dispose();
156
-            me = null;
157
-        }
158
-    }
159
-
160 109
     /** {@inheritDoc} */
161 110
     @Override
162 111
     public void stateChanged(final ChangeEvent e) {

+ 4
- 9
src/com/dmdirc/addons/ui_swing/dialogs/about/InfoPanel.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.addons.ui_swing.dialogs.about;
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
28
-import com.dmdirc.config.IdentityManager;
29 28
 import com.dmdirc.ui.core.util.Info;
30 29
 import com.dmdirc.util.DateUtils;
31 30
 
@@ -45,14 +44,10 @@ import net.miginfocom.swing.MigLayout;
45 44
 /** Info panel. */
46 45
 public final class InfoPanel extends JPanel {
47 46
 
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
-     */
47
+    /** Serial version UID. */
53 48
     private static final long serialVersionUID = 1;
54 49
     /** Parent controller. */
55
-    private SwingController controller;
50
+    private final SwingController controller;
56 51
 
57 52
     /**
58 53
      * Creates a new instance of InfoPanel.
@@ -63,7 +58,7 @@ public final class InfoPanel extends JPanel {
63 58
         super();
64 59
 
65 60
         this.controller = controller;
66
-        this.setOpaque(UIUtilities.getTabbedPaneOpaque());
61
+        setOpaque(UIUtilities.getTabbedPaneOpaque());
67 62
         initComponents();
68 63
     }
69 64
 
@@ -79,7 +74,7 @@ public final class InfoPanel extends JPanel {
79 74
 
80 75
          infoPane.setText("<html>"
81 76
                  + "<b>DMDirc version: </b>" + Info.getDMDircVersion() + "<br>"
82
-                 + "<b>Mode Alises version: </b>" + IdentityManager
77
+                 + "<b>Mode Alises version: </b>" + controller
83 78
                  .getGlobalConfig().getOption("identity", "modealiasversion")
84 79
                  + "<br>"
85 80
                  + "<b>Swing UI version: </b>" + controller.getVersion()

+ 28
- 19
src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java View File

@@ -24,13 +24,13 @@ package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 26
 import com.dmdirc.addons.ui_swing.components.TreeScroller;
27
-import com.dmdirc.config.IdentityManager;
27
+import com.dmdirc.config.ConfigManager;
28 28
 import com.dmdirc.plugins.PluginInfo;
29 29
 
30 30
 import java.awt.Font;
31 31
 import java.awt.Rectangle;
32
-import javax.swing.BorderFactory;
33 32
 
33
+import javax.swing.BorderFactory;
34 34
 import javax.swing.JEditorPane;
35 35
 import javax.swing.JPanel;
36 36
 import javax.swing.JScrollPane;
@@ -50,14 +50,13 @@ import net.miginfocom.swing.MigLayout;
50 50
 /**
51 51
  * Licences panel.
52 52
  */
53
-public final class LicencesPanel extends JPanel implements TreeSelectionListener {
53
+public final class LicencesPanel extends JPanel implements
54
+        TreeSelectionListener {
54 55
 
55
-    /**
56
-     * A version number for this class. It should be changed whenever the class
57
-     * structure is changed (or anything else that would prevent serialized
58
-     * objects being unserialized with the new class).
59
-     */
56
+    /** Serial version UID. */
60 57
     private static final long serialVersionUID = 3;
58
+    /** Config manager. */
59
+    private final ConfigManager config;
61 60
     /** Licence scroll pane. */
62 61
     private JScrollPane scrollPane;
63 62
     /** Licence list model */
@@ -67,10 +66,15 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
67 66
     /** Licence list. */
68 67
     private JTree list;
69 68
 
70
-    /** Creates a new instance of LicencesPanel. */
71
-    public LicencesPanel() {
69
+    /**
70
+     * Creates a new instance of LicencesPanel.
71
+     *
72
+     * @param config Config manager
73
+     */
74
+    public LicencesPanel(final ConfigManager config) {
72 75
         super();
73 76
 
77
+        this.config = config;
74 78
         initComponents();
75 79
         addListeners();
76 80
         layoutComponents();
@@ -84,7 +88,7 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
84 88
     }
85 89
 
86 90
     /**
87
-     *  Lays out the components.
91
+     * Lays out the components.
88 92
      */
89 93
     private void layoutComponents() {
90 94
         setLayout(new MigLayout("ins rel, fill"));
@@ -99,8 +103,10 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
99 103
         list = new JTree(listModel) {
100 104
 
101 105
             /**
102
-             * A version number for this class. It should be changed whenever the class
103
-             * structure is changed (or anything else that would prevent serialized
106
+             * A version number for this class. It should be changed whenever
107
+             * the class
108
+             * structure is changed (or anything else that would prevent
109
+             * serialized
104 110
              * objects being unserialized with the new class).
105 111
              */
106 112
             private static final long serialVersionUID = 1;
@@ -145,17 +151,20 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
145 151
         final Object userObject = ((DefaultMutableTreeNode) e.getPath().
146 152
                 getLastPathComponent()).getUserObject();
147 153
         if (userObject instanceof Licence) {
148
-        licence.setText(((Licence) userObject).getBody());
154
+            licence.setText(((Licence) userObject).getBody());
149 155
         } else if (userObject instanceof PluginInfo) {
150 156
             final PluginInfo pi = (PluginInfo) userObject;
151
-            licence.setText("<b>Name:</b> " + pi.getMetaData().getFriendlyName() + "<br>"
152
-                    + "<b>Version:</b> " + pi.getMetaData().getFriendlyVersion() + "<br>"
157
+            licence.setText("<b>Name:</b> "
158
+                    + pi.getMetaData().getFriendlyName() + "<br>"
159
+                    + "<b>Version:</b> "
160
+                    + pi.getMetaData().getFriendlyVersion() + "<br>"
153 161
                     + "<b>Author:</b> " + pi.getMetaData().getAuthor() + "<br>"
154
-                    + "<b>Description:</b> " + pi.getMetaData().getDescription() + "<br>");
162
+                    + "<b>Description:</b> "
163
+                    + pi.getMetaData().getDescription() + "<br>");
155 164
         } else {
156 165
             licence.setText("<b>Name:</b> DMDirc<br>"
157
-                    + "<b>Version:</b> " + IdentityManager.getGlobalConfig().
158
-                    getOption("version", "version") + "<br>"
166
+                    + "<b>Version:</b> " + config
167
+                    .getOption("version", "version") + "<br>"
159 168
                     + "<b>Desciption:</b> The intelligent IRC client");
160 169
         }
161 170
         UIUtilities.resetScrollPane(scrollPane);

+ 26
- 23
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java View File

@@ -23,11 +23,10 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25 25
 import com.dmdirc.actions.ActionCondition;
26
-import com.dmdirc.interfaces.actions.ActionType;
27 26
 import com.dmdirc.addons.ui_swing.components.ImageButton;
28 27
 import com.dmdirc.addons.ui_swing.components.ImageToggleButton;
29 28
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
30
-import com.dmdirc.config.IdentityManager;
29
+import com.dmdirc.interfaces.actions.ActionType;
31 30
 import com.dmdirc.ui.IconManager;
32 31
 import com.dmdirc.util.collections.ListenerList;
33 32
 
@@ -44,21 +43,17 @@ import net.miginfocom.swing.MigLayout;
44 43
 /**
45 44
  * Action condition display panel.
46 45
  */
47
-public class ActionConditionDisplayPanel extends JPanel implements ActionListener,
48
-        PropertyChangeListener {
46
+public class ActionConditionDisplayPanel extends JPanel implements
47
+        ActionListener, PropertyChangeListener {
49 48
 
50
-    /**
51
-     * A version number for this class. It should be changed whenever the class
52
-     * structure is changed (or anything else that would prevent serialized
53
-     * objects being unserialized with the new class).
54
-     */
49
+    /** Serial version UID. */
55 50
     private static final long serialVersionUID = 1;
56 51
     /** Info label. */
57 52
     private TextLabel label;
58 53
     /** Edit button. */
59 54
     private JToggleButton editButton;
60 55
     /** Delete button. */
61
-    private ImageButton deleteButton;
56
+    private ImageButton<Object> deleteButton;
62 57
     /** Edit panel. */
63 58
     private ActionConditionEditorPanel editPanel;
64 59
     /** Listeners. */
@@ -71,11 +66,12 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
71 66
     /**
72 67
      * Instantiates the panel.
73 68
      *
69
+     * @param iconManager Icon Manager
74 70
      * @param condition Action condition
75 71
      * @param trigger Action trigger
76 72
      */
77
-    public ActionConditionDisplayPanel(final ActionCondition condition,
78
-            final ActionType trigger) {
73
+    public ActionConditionDisplayPanel(final IconManager iconManager,
74
+            final ActionCondition condition, final ActionType trigger) {
79 75
         super();
80 76
 
81 77
         this.trigger = trigger;
@@ -83,7 +79,7 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
83 79
                 condition.getComponent(), condition.getComparison(),
84 80
                 condition.getTarget());
85 81
 
86
-        initComponents();
82
+        initComponents(iconManager);
87 83
         addListeners();
88 84
         layoutComponents();
89 85
         setTrigger(trigger);
@@ -91,7 +87,8 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
91 87
         layoutComponents();
92 88
 
93 89
         if (condition.getArg() == -1 && condition.getComponent() == null &&
94
-                condition.getComparison() == null && condition.getTarget().isEmpty()) {
90
+                condition.getComparison() == null
91
+                && condition.getTarget().isEmpty()) {
95 92
             editPanel.setVisible(true);
96 93
             editButton.setSelected(true);
97 94
         }
@@ -123,14 +120,16 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
123 120
         label.setText(updateSentence());
124 121
     }
125 122
 
126
-    /** Initialises the components. */
127
-    private void initComponents() {
128
-        final IconManager iconManager = new IconManager(IdentityManager
129
-                .getGlobalConfig());
123
+    /**
124
+     * Initialises the components.
125
+     *
126
+     * @param iconManager Icon Manager
127
+     */
128
+    private void initComponents(final IconManager iconManager) {
130 129
         label = new TextLabel("", false);
131 130
         editButton = new ImageToggleButton("edit", iconManager.
132 131
                 getIcon("edit-inactive"), iconManager.getIcon("edit"));
133
-        deleteButton = new ImageButton("delete", iconManager.
132
+        deleteButton = new ImageButton<Object>("delete", iconManager.
134 133
                 getIcon("close-inactive"), iconManager.
135 134
                 getIcon("close-inactive"), iconManager.getIcon("close-active"));
136 135
 
@@ -177,7 +176,8 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
177 176
      *
178 177
      * @param listener Listener to add
179 178
      */
180
-    public void addConditionListener(final ActionConditionRemovalListener listener) {
179
+    public void addConditionListener(
180
+            final ActionConditionRemovalListener listener) {
181 181
         if (listener == null) {
182 182
             return;
183 183
         }
@@ -190,7 +190,8 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
190 190
      *
191 191
      * @param listener Listener to remove
192 192
      */
193
-    public void removeConditionListener(final ActionConditionRemovalListener listener) {
193
+    public void removeConditionListener(
194
+            final ActionConditionRemovalListener listener) {
194 195
         listeners.remove(ActionConditionRemovalListener.class, listener);
195 196
     }
196 197
 
@@ -199,8 +200,10 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
199 200
      *
200 201
      * @param condition Removed condition
201 202
      */
202
-    protected void fireConditionRemoved(final ActionConditionDisplayPanel condition) {
203
-        for (ActionConditionRemovalListener listener : listeners.get(ActionConditionRemovalListener.class)) {
203
+    protected void fireConditionRemoved(
204
+            final ActionConditionDisplayPanel condition) {
205
+        for (final ActionConditionRemovalListener listener : listeners
206
+                .get(ActionConditionRemovalListener.class)) {
204 207
             listener.conditionRemoved(condition);
205 208
         }
206 209
     }

+ 37
- 29
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsListPanel.java View File

@@ -23,16 +23,17 @@
23 23
 package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25 25
 import com.dmdirc.actions.ActionCondition;
26
-import com.dmdirc.interfaces.actions.ActionType;
27 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
27
+import com.dmdirc.interfaces.actions.ActionType;
28
+import com.dmdirc.ui.IconManager;
28 29
 
29 30
 import java.beans.PropertyChangeEvent;
30 31
 import java.beans.PropertyChangeListener;
31 32
 import java.util.ArrayList;
32 33
 import java.util.HashMap;
33 34
 import java.util.List;
34
-
35 35
 import java.util.Map;
36
+
36 37
 import javax.swing.JLabel;
37 38
 import javax.swing.JPanel;
38 39
 
@@ -41,44 +42,48 @@ import net.miginfocom.swing.MigLayout;
41 42
 /**
42 43
  * Action conditions list panel.
43 44
  */
44
-public class ActionConditionsListPanel extends JPanel implements ActionConditionRemovalListener,
45
+public class ActionConditionsListPanel extends JPanel implements
46
+        ActionConditionRemovalListener,
45 47
         PropertyChangeListener {
46 48
 
47
-    /**
48
-     * A version number for this class. It should be changed whenever the class
49
-     * structure is changed (or anything else that would prevent serialized
50
-     * objects being unserialized with the new class).
51
-     */
49
+    /** Serial version UID. */
52 50
     private static final long serialVersionUID = 1;
53
-    /** Action trigger. */
54
-    private ActionType trigger;
55 51
     /** Conditions list. */
56
-    private List<ActionConditionDisplayPanel> conditions;
52
+    private final List<ActionConditionDisplayPanel> conditions;
57 53
     /** Condition tree panel. */
58
-    private ActionConditionsTreePanel treePanel;
54
+    private final ActionConditionsTreePanel treePanel;
59 55
     /** Condition validation results. */
60
-    private Map<ActionConditionDisplayPanel, Boolean> validations;
56
+    private final Map<ActionConditionDisplayPanel, Boolean> validations;
57
+    /** Icon manager. */
58
+    private final IconManager iconManager;
59
+    /** Action trigger. */
60
+    private ActionType trigger;
61 61
     /** validates. */
62 62
     private boolean validates = true;
63 63
 
64 64
     /**
65 65
      * Instantiates the panel.
66 66
      *
67
+     * @param iconManager Icon manager
67 68
      * @param treePanel Condition tree panel.
68 69
      */
69
-    public ActionConditionsListPanel(final ActionConditionsTreePanel treePanel) {
70
-        this(null, new ArrayList<ActionConditionDisplayPanel>(), treePanel);
70
+    public ActionConditionsListPanel(final IconManager iconManager,
71
+            final ActionConditionsTreePanel treePanel) {
72
+        this(iconManager, null, new ArrayList<ActionConditionDisplayPanel>(),
73
+                treePanel);
71 74
     }
72 75
 
73 76
     /**
74 77
      * Instantiates the panel.
75 78
      *
79
+     * @param iconManager Icon manager
76 80
      * @param trigger Action trigger
77 81
      * @param treePanel Condition tree panel.
78 82
      */
79
-    public ActionConditionsListPanel(final ActionType trigger,
80
-            final ActionConditionsTreePanel treePanel) {
81
-        this(trigger, new ArrayList<ActionConditionDisplayPanel>(), treePanel);
83
+    public ActionConditionsListPanel(final IconManager iconManager,
84
+            final ActionType trigger, final ActionConditionsTreePanel treePanel) {
85
+        this(iconManager, trigger, new ArrayList<ActionConditionDisplayPanel>(),
86
+                treePanel);
82 87
     }
83 88
 
84 89
     /**
@@ -88,13 +93,15 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
88 93
      * @param conditions List of existing conditions;
89 94
      * @param treePanel Condition tree panel.
90 95
      */
91
-    public ActionConditionsListPanel(final ActionType trigger,
96
+    public ActionConditionsListPanel(final IconManager iconManager,
97
+            final ActionType trigger,
92 98
             final List<ActionConditionDisplayPanel> conditions,
93 99
             final ActionConditionsTreePanel treePanel) {
94 100
         super();
95 101
 
96 102
         validations = new HashMap<ActionConditionDisplayPanel, Boolean>();
97 103
 
104
+        this.iconManager = iconManager;
98 105
         this.trigger = trigger;
99 106
         this.conditions = new ArrayList<ActionConditionDisplayPanel>(conditions);
100 107
         this.treePanel = treePanel;
@@ -115,7 +122,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
115 122
 
116 123
     /** Adds the listeners. */
117 124
     private void addListeners() {
118
-        for (ActionConditionDisplayPanel condition : conditions) {
125
+        for (final ActionConditionDisplayPanel condition : conditions) {
119 126
             condition.addConditionListener(this);
120 127
         }
121 128
     }
@@ -126,14 +133,15 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
126 133
         removeAll();
127 134
         int index = 0;
128 135
         if (trigger == null) {
129
-            add(new TextLabel("You must add at least one trigger before you can add conditions."),
136
+            add(new TextLabel(
137
+                    "You must add at least one trigger before you can add conditions."),
130 138
                     "alignx center, aligny top, grow, push, w 90%!");
131 139
         } else if (trigger.getType().getArgNames().length == 0) {
132 140
             add(new TextLabel("Trigger does not have any arguments."),
133 141
                     "alignx center, aligny top, grow, push, w 90%!");
134 142
         } else {
135 143
             synchronized (conditions) {
136
-                for (ActionConditionDisplayPanel condition : conditions) {
144
+                for (final ActionConditionDisplayPanel condition : conditions) {
137 145
                     add(new JLabel(index + "."), "aligny top");
138 146
                     add(condition, "growx, pushx, aligny top");
139 147
                     index++;
@@ -155,7 +163,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
155 163
      */
156 164
     public void addCondition(final ActionCondition condition) {
157 165
         final ActionConditionDisplayPanel panel =
158
-                new ActionConditionDisplayPanel(condition, trigger);
166
+                new ActionConditionDisplayPanel(iconManager, condition, trigger);
159 167
         panel.addConditionListener(this);
160 168
         panel.addPropertyChangeListener("validationResult", this);
161 169
         validations.put(panel, panel.checkError());
@@ -176,7 +184,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
176 184
         ActionConditionDisplayPanel removeCondition = null;
177 185
 
178 186
         synchronized (conditions) {
179
-            for (ActionConditionDisplayPanel localCondition : conditions) {
187
+            for (final ActionConditionDisplayPanel localCondition : conditions) {
180 188
                 if (localCondition.getCondition().equals(condition)) {
181 189
                     removeCondition = localCondition;
182 190
                     break;
@@ -195,7 +203,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
195 203
      * Clear conditions.
196 204
      */
197 205
     public void clearConditions() {
198
-        for (ActionConditionDisplayPanel condition : conditions) {
206
+        for (final ActionConditionDisplayPanel condition : conditions) {
199 207
             delCondition(condition.getCondition());
200 208
         }
201 209
     }
@@ -210,7 +218,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
210 218
                 new ArrayList<ActionCondition>();
211 219
 
212 220
         synchronized (conditions) {
213
-            for (ActionConditionDisplayPanel condition : conditions) {
221
+            for (final ActionConditionDisplayPanel condition : conditions) {
214 222
                 conditionList.add(condition.getCondition());
215 223
             }
216 224
         }
@@ -228,7 +236,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
228 236
             conditions.clear();
229 237
         }
230 238
 
231
-        for (ActionConditionDisplayPanel panel : conditions) {
239
+        for (final ActionConditionDisplayPanel panel : conditions) {
232 240
             panel.setTrigger(trigger);
233 241
         }
234 242
         this.trigger = trigger;
@@ -250,7 +258,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
250 258
     /** {@inheritDoc} */
251 259
     @Override
252 260
     public void setEnabled(final boolean enabled) {
253
-        for (ActionConditionDisplayPanel condition : conditions) {
261
+        for (final ActionConditionDisplayPanel condition : conditions) {
254 262
             condition.setEnabled(enabled);
255 263
         }
256 264
     }
@@ -264,7 +272,7 @@ public class ActionConditionsListPanel extends JPanel implements ActionCondition
264 272
         }
265 273
 
266 274
         boolean pass = true;
267
-        for (boolean validation : validations.values()) {
275
+        for (final boolean validation : validations.values()) {
268 276
             if (!validation) {
269 277
                 pass = false;
270 278
                 break;

+ 6
- 10
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsPanel.java View File

@@ -26,8 +26,8 @@ import com.dmdirc.actions.ActionCondition;
26 26
 import com.dmdirc.actions.ConditionTree;
27 27
 import com.dmdirc.actions.ConditionTreeFactory.ConditionTreeFactoryType;
28 28
 import com.dmdirc.interfaces.actions.ActionType;
29
-
30 29
 import com.dmdirc.ui.IconManager;
30
+
31 31
 import java.awt.event.ActionEvent;
32 32
 import java.awt.event.ActionListener;
33 33
 import java.beans.PropertyChangeEvent;
@@ -39,8 +39,8 @@ import javax.swing.JButton;
39 39
 import javax.swing.JPanel;
40 40
 import javax.swing.JScrollPane;
41 41
 import javax.swing.JSeparator;
42
-
43 42
 import javax.swing.UIManager;
43
+
44 44
 import net.miginfocom.swing.MigLayout;
45 45
 
46 46
 /**
@@ -49,11 +49,7 @@ import net.miginfocom.swing.MigLayout;
49 49
 public class ActionConditionsPanel extends JPanel implements ActionListener,
50 50
         PropertyChangeListener {
51 51
 
52
-    /**
53
-     * A version number for this class. It should be changed whenever the class
54
-     * structure is changed (or anything else that would prevent serialized
55
-     * objects being unserialized with the new class).
56
-     */
52
+    /** Serial version UID. */
57 53
     private static final long serialVersionUID = 1;
58 54
     /** Tree panel. */
59 55
     private ActionConditionsTreePanel tree;
@@ -66,7 +62,7 @@ public class ActionConditionsPanel extends JPanel implements ActionListener,
66 62
     /** list validates? */
67 63
     private boolean listValidates = true;
68 64
     /** Icon manager. */
69
-    private IconManager iconManager;
65
+    private final IconManager iconManager;
70 66
 
71 67
     /**
72 68
      * Instantiates the panel.
@@ -106,7 +102,7 @@ public class ActionConditionsPanel extends JPanel implements ActionListener,
106 102
     /** Initialises the components. */
107 103
     private void initComponents() {
108 104
         tree = new ActionConditionsTreePanel(iconManager);
109
-        list = new ActionConditionsListPanel(tree);
105
+        list = new ActionConditionsListPanel(iconManager, tree);
110 106
         add = new JButton("Add");
111 107
     }
112 108
 
@@ -171,7 +167,7 @@ public class ActionConditionsPanel extends JPanel implements ActionListener,
171 167
     public void setConditions(final List<ActionCondition> conditions) {
172 168
         list.clearConditions();
173 169
 
174
-        for (ActionCondition condition : conditions) {
170
+        for (final ActionCondition condition : conditions) {
175 171
             list.addCondition(condition);
176 172
         }
177 173
     }

+ 24
- 121
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionEditorDialog.java View File

@@ -24,11 +24,10 @@ package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25 25
 import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.actions.ActionStatus;
27
+import com.dmdirc.addons.ui_swing.SwingController;
27 28
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
28
-import com.dmdirc.ui.IconManager;
29 29
 
30 30
 import java.awt.Dimension;
31
-import java.awt.Window;
32 31
 import java.awt.event.ActionEvent;
33 32
 import java.awt.event.ActionListener;
34 33
 import java.beans.PropertyChangeEvent;
@@ -42,17 +41,12 @@ import net.miginfocom.swing.MigLayout;
42 41
 /**
43 42
  * Action editor dialog.
44 43
  */
45
-public class ActionEditorDialog extends StandardDialog implements ActionListener,
44
+public class ActionEditorDialog extends StandardDialog implements
45
+        ActionListener,
46 46
         PropertyChangeListener {
47 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
-     */
48
+    /** Serial version UID. */
53 49
     private static final long serialVersionUID = 1;
54
-    /** Previously created instance of ActionEditorDialog. */
55
-    private static volatile ActionEditorDialog me;
56 50
     /** Name panel. */
57 51
     private ActionNamePanel name;
58 52
     /** Triggers panel. */
@@ -76,39 +70,34 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
76 70
     /** Are the conditions valid? */
77 71
     private boolean conditionsValid = false;
78 72
     /** Action to be edited. */
79
-    private Action action;
73
+    private final Action action;
80 74
     /** Action group. */
81
-    private String group;
82
-    /** Icon manager. */
83
-    private IconManager iconManager;
75
+    private final String group;
84 76
 
85 77
     /**
86 78
      * Instantiates the panel.
87 79
      *
88
-     * @param iconManager Icon manager
89
-     * @param window Parent window
80
+     * @param controller Swing controller
90 81
      * @param group Action's group
91 82
      */
92
-    private ActionEditorDialog(final IconManager iconManager,
93
-            final Window window, final String group) {
94
-        this(iconManager, window, group, null);
83
+    public ActionEditorDialog(final SwingController controller,
84
+            final String group) {
85
+        this(controller, group, null);
95 86
     }
96 87
 
97 88
     /**
98 89
      * Instantiates the panel.
99 90
      *
100
-     * @param iconManager Icon manager
101
-     * @param window Parent window
91
+     * @param controller Swing controller
102 92
      * @param action Action to be edited
103 93
      * @param group Action's group
104 94
      */
105
-    private ActionEditorDialog(final IconManager iconManager,
106
-            final Window window, final String group, final Action action) {
107
-        super(window, ModalityType.DOCUMENT_MODAL);
95
+    public ActionEditorDialog(final SwingController controller,
96
+            final String group, final Action action) {
97
+        super(controller, ModalityType.DOCUMENT_MODAL);
108 98
         setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
109 99
         setTitle("Action Editor");
110 100
 
111
-        this.iconManager = iconManager;
112 101
         this.group = group;
113 102
         this.action = action;
114 103
 
@@ -120,81 +109,6 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
120 109
         setResizable(false);
121 110
     }
122 111
 
123
-    /**
124
-     * Is the dialog open?
125
-     *
126
-     * @return is the dialog open
127
-     */
128
-    public static boolean isOpen() {
129
-        synchronized (ActionEditorDialog.class) {
130
-            return me != null;
131
-        }
132
-    }
133
-
134
-    /**
135
-     * Creates the dialog if one doesn't exist, and displays it.
136
-     *
137
-     * @param iconManager Icon manager
138
-     * @param window Parent window
139
-     * @param group Action's group
140
-     */
141
-    public static void showActionEditorDialog(final IconManager iconManager,
142
-            final Window window, final String group) {
143
-        showActionEditorDialog(iconManager, window, group, null);
144
-    }
145
-
146
-    /**
147
-     * Creates the dialog if one doesn't exist, and displays it.
148
-     *
149
-     * @param iconManager Icon manager
150
-     * @param window Parent window
151
-     * @param group Action's group
152
-     * @param action Action to be edited
153
-     */
154
-    public static void showActionEditorDialog(final IconManager iconManager,
155
-            final Window window, final String group, final Action action) {
156
-        getActionEditorDialog(iconManager, window, group, action);
157
-
158
-        me.display();
159
-    }
160
-
161
-    /**
162
-     * Returns the current instance of the ActionEditorDialog.
163
-     *
164
-     * @param iconManager Icon manager
165
-     * @param window Parent window
166
-     * @param group Action's group
167
-     *
168
-     * @return The current ActionEditorDialog instance
169
-     */
170
-    public static ActionEditorDialog getActionEditorDialog(
171
-            final IconManager iconManager, final Window window,
172
-            final String group) {
173
-        return getActionEditorDialog(iconManager, window, group, null);
174
-    }
175
-
176
-    /**
177
-     * Returns the current instance of the ActionEditorDialog.
178
-     *
179
-     * @param iconManager Icon manager
180
-     * @param window Parent window
181
-     * @param group Action's group
182
-     * @param action Action to be edited
183
-     *
184
-     * @return The current ActionEditorDialog instance
185
-     */
186
-    public static ActionEditorDialog getActionEditorDialog(
187
-            final IconManager iconManager, final Window window,
188
-            final String group, final Action action) {
189
-        synchronized (ActionEditorDialog.class) {
190
-            if (me == null) {
191
-                me = new ActionEditorDialog(iconManager, window, group, action);
192
-            }
193
-        }
194
-
195
-        return me;
196
-    }
197
-
198 112
     /** Sets components initial states and stuff. */
199 113
     private void doComponents() {
200 114
         triggers.setEnabled(action != null);
@@ -225,10 +139,10 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
225 139
     /** Initialises the components. */
226 140
     private void initComponents() {
227 141
         orderButtons(new JButton(), new JButton());
228
-        name = new ActionNamePanel(iconManager, "", group);
229
-        triggers = new ActionTriggersPanel();
230
-        response = new ActionResponsePanel();
231
-        conditions = new ActionConditionsPanel(iconManager);
142
+        name = new ActionNamePanel(getIconManager(), "", group);
143
+        triggers = new ActionTriggersPanel(getIconManager());
144
+        response = new ActionResponsePanel(getController());
145
+        conditions = new ActionConditionsPanel(getIconManager());
232 146
         substitutions = new ActionSubstitutionsPanel();
233 147
         advanced = new ActionAdvancedPanel();
234 148
         showSubstitutions = new JButton("Show Substitutions");
@@ -266,7 +180,7 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
266 180
     }
267 181
 
268 182
     /**
269
-     * @{inheritDoc}
183
+     * @{inheritDoc
270 184
      *
271 185
      * @param e Action event
272 186
      */
@@ -274,9 +188,10 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
274 188
     public void actionPerformed(final ActionEvent e) {
275 189
         if (e.getSource().equals(showSubstitutions)) {
276 190
             substitutions.setVisible(!substitutions.isVisible());
277
-            showSubstitutions.setText(substitutions.isVisible() ? "Hide Substitutions"
278
-                    : "Show Substitutions");
279
-                    pack();
191
+            showSubstitutions
192
+                    .setText(substitutions.isVisible() ? "Hide Substitutions"
193
+                            : "Show Substitutions");
194
+            pack();
280 195
         } else if (e.getSource().equals(showAdvanced)) {
281 196
             advanced.setVisible(!advanced.isVisible());
282 197
             showAdvanced.setText(advanced.isVisible() ? "Hide Advanced Options"
@@ -334,7 +249,7 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
334 249
         }
335 250
     }
336 251
 
337
-    /** @{inheritDoc} */
252
+    /** @{inheritDoc */
338 253
     @Override
339 254
     public void propertyChange(final PropertyChangeEvent evt) {
340 255
         if (evt.getSource().equals(name)) {
@@ -358,16 +273,4 @@ public class ActionEditorDialog extends StandardDialog implements ActionListener
358 273
 
359 274
         getOkButton().setEnabled(triggersValid && conditionsValid && nameValid);
360 275
     }
361
-
362
-    /** {@inheritDoc} */
363
-    @Override
364
-    public void dispose() {
365
-        if (me == null) {
366
-            return;
367
-        }
368
-        synchronized (me) {
369
-            super.dispose();
370
-            me = null;
371
-        }
372
-    }
373 276
 }

+ 19
- 15
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanel.java View File

@@ -22,9 +22,9 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25
+import com.dmdirc.addons.ui_swing.SwingController;
25 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.addons.ui_swing.components.inputfields.TextAreaInputField;
27
-import com.dmdirc.config.IdentityManager;
28 28
 
29 29
 import java.util.TreeSet;
30 30
 
@@ -44,11 +44,7 @@ import net.miginfocom.swing.MigLayout;
44 44
  */
45 45
 public class ActionResponsePanel extends JPanel {
46 46
 
47
-    /**
48
-     * A version number for this class. It should be changed whenever the class
49
-     * structure is changed (or anything else that would prevent serialized
50
-     * objects being unserialized with the new class).
51
-     */
47
+    /** Serial version UID. */
52 48
     private static final long serialVersionUID = 1;
53 49
     /** Response text area. */
54 50
     private JTextArea response;
@@ -57,18 +53,26 @@ public class ActionResponsePanel extends JPanel {
57 53
     /** Response scrollpane. */
58 54
     private JScrollPane scrollPane;
59 55
 
60
-    /** Instantiates the panel. */
61
-    public ActionResponsePanel() {
56
+    /**
57
+     * Instantiates the panel.
58
+     *
59
+     * @param controller Swing controller
60
+     */
61
+    public ActionResponsePanel(final SwingController controller) {
62 62
         super();
63 63
 
64
-        initComponents();
64
+        initComponents(controller);
65 65
         addListeners();
66 66
         layoutComponents();
67 67
     }
68 68
 
69
-    /** Initialises the components. */
70
-    private void initComponents() {
71
-        response = new TextAreaInputField("");
69
+    /**
70
+     * Initialises the components.
71
+     *
72
+     * @param controller Swing controller
73
+     */
74
+    private void initComponents(final SwingController controller) {
75
+        response = new TextAreaInputField(controller, "");
72 76
         scrollPane = new JScrollPane(response);
73 77
         response.setRows(4);
74 78
         //new SwingInputHandler(response, GlobalCommandParser
@@ -81,10 +85,10 @@ public class ActionResponsePanel extends JPanel {
81 85
 
82 86
         final TreeSet<String> formatters = new TreeSet<String>(
83 87
                 String.CASE_INSENSITIVE_ORDER);
84
-        formatters.addAll(IdentityManager.getGlobalConfig().getOptions(
85
-                "formatter").keySet());
88
+        formatters.addAll(controller.getGlobalConfig().getOptions("formatter")
89
+                .keySet());
86 90
 
87
-        for (String format : formatters) {
91
+        for (final String format : formatters) {
88 92
             ((DefaultComboBoxModel) formatter.getModel()).addElement(format);
89 93
         }
90 94
     }

+ 23
- 13
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersListPanel.java View File

@@ -22,10 +22,9 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25
-import com.dmdirc.interfaces.actions.ActionType;
26 25
 import com.dmdirc.addons.ui_swing.components.ImageButton;
27 26
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
28
-import com.dmdirc.config.IdentityManager;
27
+import com.dmdirc.interfaces.actions.ActionType;
29 28
 import com.dmdirc.ui.IconManager;
30 29
 import com.dmdirc.util.collections.ListenerList;
31 30
 
@@ -55,27 +54,40 @@ public class ActionTriggersListPanel extends JPanel {
55 54
     private final List<ActionType> triggers;
56 55
     /** Listeners. */
57 56
     private final ListenerList listeners = new ListenerList();
57
+    /** Icon manager. */
58
+    private final IconManager iconManager;
58 59
 
59
-    /** Instantiates the panel. */
60
-    public ActionTriggersListPanel() {
61
-        this(new ArrayList<ActionType>());
60
+    /**
61
+     * Instantiates the panel.
62
+     *
63
+     * @param iconManager Icon Manager
64
+     */
65
+    public ActionTriggersListPanel(final IconManager iconManager) {
66
+        this(iconManager, new ArrayList<ActionType>());
62 67
     }
63 68
 
64 69
     /**
65 70
      * Instantiates the panel.
66 71
      *
72
+     * @param iconManager Icon Manager
67 73
      * @param triggers Trigger list
68 74
      */
69
-    public ActionTriggersListPanel(final List<ActionType> triggers) {
75
+    public ActionTriggersListPanel(final IconManager iconManager,
76
+            final List<ActionType> triggers) {
70 77
         super();
71 78
 
79
+        this.iconManager = iconManager;
72 80
         this.triggers = new ArrayList<ActionType>(triggers);
73 81
 
74 82
         initComponents();
75 83
         layoutComponents();
76 84
     }
77 85
 
78
-    /** Initialises the components. */
86
+    /**
87
+     * Initialises the components.
88
+     *
89
+     * @param iconManager Icon Manager
90
+     */
79 91
     private void initComponents() {
80 92
         setOpaque(false);
81 93
         setLayout(new MigLayout("fillx, wrap 2"));
@@ -84,15 +96,13 @@ public class ActionTriggersListPanel extends JPanel {
84 96
     /** Lays out the components. */
85 97
     private void layoutComponents() {
86 98
         synchronized (triggers) {
87
-            final IconManager iconManager = new IconManager(IdentityManager
88
-                .getGlobalConfig());
89 99
             setVisible(false);
90 100
 
91 101
             removeAll();
92 102
 
93 103
             for (final ActionType trigger : triggers) {
94
-                final ImageButton button = new ImageButton("delete",
95
-                        iconManager.getIcon("close-inactive"),
104
+                final ImageButton<?> button = new ImageButton<Object>(
105
+                        "delete", iconManager.getIcon("close-inactive"),
96 106
                         iconManager.getIcon("close-active"));
97 107
                 button.addActionListener(new ActionListener() {
98 108
 
@@ -169,7 +179,7 @@ public class ActionTriggersListPanel extends JPanel {
169 179
      * Clears the trigger list.
170 180
      */
171 181
     public void clearTriggers() {
172
-        for (ActionType trigger : triggers) {
182
+        for (final ActionType trigger : triggers) {
173 183
             delTrigger(trigger);
174 184
         }
175 185
     }
@@ -237,7 +247,7 @@ public class ActionTriggersListPanel extends JPanel {
237 247
      * @param type Removed trigger
238 248
      */
239 249
     protected void fireTriggerRemoved(final ActionType type) {
240
-        for (ActionTriggerRemovalListener listener : listeners.get(
250
+        for (final ActionTriggerRemovalListener listener : listeners.get(
241 251
                 ActionTriggerRemovalListener.class)) {
242 252
             listener.triggerRemoved(type);
243 253
         }

+ 27
- 15
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersPanel.java View File

@@ -24,10 +24,11 @@ package com.dmdirc.addons.ui_swing.dialogs.actioneditor;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.ActionTypeComparator;
27
-import com.dmdirc.interfaces.actions.ActionType;
28 27
 import com.dmdirc.addons.ui_swing.ComboBoxWidthModifier;
29 28
 import com.dmdirc.addons.ui_swing.components.renderers.ActionTypeRenderer;
30 29
 import com.dmdirc.addons.ui_swing.components.text.TextLabel;
30
+import com.dmdirc.interfaces.actions.ActionType;
31
+import com.dmdirc.ui.IconManager;
31 32
 import com.dmdirc.util.collections.MapList;
32 33
 
33 34
 import java.awt.event.ActionEvent;
@@ -70,37 +71,45 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
70 71
     /** Triggers compatible with the currently added triggers. */
71 72
     private final List<ActionType> compatibleTriggers;
72 73
 
73
-    /** Instantiates the panel. */
74
-    public ActionTriggersPanel() {
74
+    /**
75
+     * Instantiates the panel.
76
+     *
77
+     * @param iconManager Icon manager
78
+     * */
79
+    public ActionTriggersPanel(final IconManager iconManager) {
75 80
         super();
76 81
 
77 82
         compatibleTriggers = new ArrayList<ActionType>();
78 83
 
79
-        initComponents();
84
+        initComponents(iconManager);
80 85
         addListeners();
81 86
         layoutComponents();
82 87
     }
83 88
 
84
-    /** Initialises the components. */
85
-    private void initComponents() {
89
+    /**
90
+     * Initialises the components.
91
+     *
92
+     * @param iconManager Icon manager
93
+     * */
94
+    private void initComponents(final IconManager iconManager) {
86 95
         setBorder(BorderFactory.createTitledBorder(UIManager.getBorder(
87 96
                 "TitledBorder.border"), "Triggers"));
88 97
 
89 98
         triggerGroup = new JComboBox(new DefaultComboBoxModel());
90
-        //Only fire events on selection not on highlight
99
+        // Only fire events on selection not on highlight
91 100
         triggerGroup.putClientProperty("JComboBox.isTableCellEditor",
92 101
                 Boolean.TRUE);
93 102
         triggerGroup.setRenderer(new ActionTypeRenderer());
94 103
         triggerGroup.addPopupMenuListener(new ComboBoxWidthModifier());
95 104
 
96 105
         triggerItem = new JComboBox(new DefaultComboBoxModel());
97
-        //Only fire events on selection not on highlight
106
+        // Only fire events on selection not on highlight
98 107
         triggerItem.putClientProperty("JComboBox.isTableCellEditor",
99 108
                 Boolean.TRUE);
100 109
         triggerItem.setRenderer(new ActionTypeRenderer());
101 110
         triggerItem.addPopupMenuListener(new ComboBoxWidthModifier());
102 111
 
103
-        triggerList = new ActionTriggersListPanel();
112
+        triggerList = new ActionTriggersListPanel(iconManager);
104 113
         addAll(ActionManager.getActionManager().getGroupedTypes());
105 114
     }
106 115
 
@@ -154,7 +163,7 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
154 163
     public void setTriggers(final ActionType[] triggers) {
155 164
         triggerList.clearTriggers();
156 165
 
157
-        for (ActionType localTrigger : triggers) {
166
+        for (final ActionType localTrigger : triggers) {
158 167
             triggerList.addTrigger(localTrigger);
159 168
         }
160 169
     }
@@ -197,7 +206,8 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
197 206
         compatibleTriggers.clear();
198 207
         ((DefaultComboBoxModel) triggerGroup.getModel()).removeAllElements();
199 208
         ((DefaultComboBoxModel) triggerItem.getModel()).removeAllElements();
200
-        for (Map.Entry<String, List<ActionType>> entry : mapList.entrySet()) {
209
+        for (final Map.Entry<String, List<ActionType>> entry : mapList
210
+                .entrySet()) {
201 211
             ((DefaultComboBoxModel) triggerGroup.getModel())
202 212
                     .addElement(entry.getKey());
203 213
         }
@@ -219,7 +229,7 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
219 229
                 .findCompatibleTypes(primaryType));
220 230
         ((DefaultComboBoxModel) triggerGroup.getModel()).removeAllElements();
221 231
         ((DefaultComboBoxModel) triggerItem.getModel()).removeAllElements();
222
-        for (ActionType thisType : compatibleTriggers) {
232
+        for (final ActionType thisType : compatibleTriggers) {
223 233
             final List<ActionType> types = triggerList.getTriggers();
224 234
             if (!types.contains(thisType)) {
225 235
                 ((DefaultComboBoxModel) triggerItem.getModel())
@@ -234,7 +244,8 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
234 244
         triggerGroup.setSelectedIndex(-1);
235 245
         triggerItem.setSelectedIndex(-1);
236 246
         if (triggerItem.getModel().getSize() == 0) {
237
-            ((DefaultComboBoxModel) triggerGroup.getModel()).removeAllElements();
247
+            ((DefaultComboBoxModel) triggerGroup.getModel())
248
+                    .removeAllElements();
238 249
         }
239 250
         triggerGroup.setEnabled(triggerGroup.getModel().getSize() > 0);
240 251
         triggerItem.setEnabled(triggerItem.getModel().getSize() > 0);
@@ -251,10 +262,11 @@ public class ActionTriggersPanel extends JPanel implements ActionListener,
251 262
         comboChange = true;
252 263
         ((DefaultComboBoxModel) triggerItem.getModel()).removeAllElements();
253 264
         Collections.sort(list, new ActionTypeComparator());
254
-        for (ActionType entry : list) {
265
+        for (final ActionType entry : list) {
255 266
             if (compatibleTriggers.isEmpty()
256 267
                     || compatibleTriggers.contains(entry)) {
257
-                ((DefaultComboBoxModel) triggerItem.getModel()).addElement(entry);
268
+                ((DefaultComboBoxModel) triggerItem.getModel())
269
+                        .addElement(entry);
258 270
             }
259 271
         }
260 272
         triggerItem.setSelectedIndex(-1);

+ 10
- 10
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsGroupPanel.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_swing.dialogs.actionsmanager;
25 25
 import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.actions.ActionGroup;
27 27
 import com.dmdirc.actions.ActionTypeComparator;
28
+import com.dmdirc.addons.ui_swing.SwingController;
28 29
 import com.dmdirc.addons.ui_swing.components.PackingTable;
29 30
 import com.dmdirc.addons.ui_swing.components.renderers.ActionTypeTableCellRenderer;
30 31
 import com.dmdirc.addons.ui_swing.components.renderers.ArrayCellRenderer;
@@ -32,7 +33,6 @@ import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
32 33
 import com.dmdirc.addons.ui_swing.dialogs.StringArrayComparator;
33 34
 import com.dmdirc.addons.ui_swing.dialogs.actioneditor.ActionEditorDialog;
34 35
 
35
-import com.dmdirc.ui.IconManager;
36 36
 import java.awt.Window;
37 37
 import java.awt.Dialog.ModalityType;
38 38
 import java.awt.event.ActionEvent;
@@ -82,21 +82,21 @@ public final class ActionsGroupPanel extends JPanel implements ActionListener,
82 82
     private JButton delete;
83 83
     /** Action group. */
84 84
     private ActionGroup group;
85
-    /** Prefs component factory. */
86
-    private IconManager iconManager;
85
+    /** Swing controller. */
86
+    private SwingController controller;
87 87
 
88 88
     /**
89 89
      * Creates a new instance of ActionsManagerDialog.
90 90
      *
91
-     * @param iconManager Prefs component factory
91
+     * @param controller Swing controller
92 92
      * @param parent Parent window
93 93
      * @param group Action group to display
94 94
      */
95
-    public ActionsGroupPanel(final IconManager iconManager,
95
+    public ActionsGroupPanel(final SwingController controller,
96 96
             final Window parent, final ActionGroup group) {
97 97
         super();
98 98
 
99
-        this.iconManager = iconManager;
99
+        this.controller = controller;
100 100
         this.parent = parent;
101 101
         this.group = group;
102 102
 
@@ -249,10 +249,10 @@ public final class ActionsGroupPanel extends JPanel implements ActionListener,
249 249
     @Override
250 250
     public void actionPerformed(final ActionEvent e) {
251 251
         if (e.getSource() == add) {
252
-            ActionEditorDialog.showActionEditorDialog(iconManager, parent,
252
+            controller.showDialog(ActionEditorDialog.class, parent,
253 253
                     group.getName());
254 254
         } else if (e.getSource() == edit) {
255
-            ActionEditorDialog.showActionEditorDialog(iconManager, parent,
255
+            controller.showDialog(ActionEditorDialog.class, parent,
256 256
                     group.getName(), model.getAction(
257 257
                     table.getRowSorter().convertRowIndexToModel(table.
258 258
                     getSelectedRow())));
@@ -261,8 +261,8 @@ public final class ActionsGroupPanel extends JPanel implements ActionListener,
261 261
                     model.getAction(
262 262
                     table.getRowSorter().convertRowIndexToModel(table.
263 263
                     getSelectedRow()));
264
-            new StandardQuestionDialog(parent, ModalityType.APPLICATION_MODAL,
265
-                    "Confirm deletion",
264
+            new StandardQuestionDialog(controller, parent,
265
+                    ModalityType.APPLICATION_MODAL, "Confirm deletion",
266 266
                     "Are you sure you wish to delete the action '" + action.
267 267
                     getName() + "'?") {
268 268
 

+ 0
- 0
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save