Browse Source

EventBus logging for undo/redo actions

Change-Id: I3b9863cd1004af7c507c3b27594967546ec26bcc
Reviewed-on: http://gerrit.dmdirc.com/3724
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/24/3724/3
Greg Holmes 9 years ago
parent
commit
a4f30207f1

+ 5
- 3
src/com/dmdirc/addons/ui_swing/UIUtilities.java View File

@@ -27,6 +27,8 @@ import com.dmdirc.addons.ui_swing.actions.UndoAction;
27 27
 import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
28 28
 import com.dmdirc.ui.Colour;
29 29
 
30
+import com.google.common.eventbus.EventBus;
31
+
30 32
 import java.awt.Color;
31 33
 import java.awt.Font;
32 34
 import java.awt.FontMetrics;
@@ -88,7 +90,7 @@ public final class UIUtilities {
88 90
      *
89 91
      * @param component component Text component to add an undo manager to
90 92
      */
91
-    public static void addUndoManager(final JTextComponent component) {
93
+    public static void addUndoManager(final EventBus eventBus, final JTextComponent component) {
92 94
         final UndoManager undoManager = new UndoManager();
93 95
 
94 96
         // Listen for undo and redo events
@@ -96,13 +98,13 @@ public final class UIUtilities {
96 98
                 new DMDircUndoableEditListener(undoManager));
97 99
 
98 100
         // Create an undo action and add it to the text component
99
-        component.getActionMap().put("Undo", new UndoAction(undoManager));
101
+        component.getActionMap().put("Undo", new UndoAction(eventBus, undoManager));
100 102
 
101 103
         // Bind the undo action to ctl-Z
102 104
         component.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");
103 105
 
104 106
         // Create a redo action and add it to the text component
105
-        component.getActionMap().put("Redo", new RedoAction(undoManager));
107
+        component.getActionMap().put("Redo", new RedoAction(eventBus, undoManager));
106 108
 
107 109
         // Bind the redo action to ctl-Y
108 110
         component.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");

+ 9
- 8
src/com/dmdirc/addons/ui_swing/actions/RedoAction.java View File

@@ -22,8 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.actions;
24 24
 
25
+import com.dmdirc.events.UserErrorEvent;
25 26
 import com.dmdirc.logger.ErrorLevel;
26
-import com.dmdirc.logger.Logger;
27
+
28
+import com.google.common.eventbus.EventBus;
27 29
 
28 30
 import java.awt.event.ActionEvent;
29 31
 
@@ -40,23 +42,22 @@ public final class RedoAction extends AbstractAction {
40 42
     private static final long serialVersionUID = 1;
41 43
     /** Undo manager. */
42 44
     private final UndoManager undoManager;
45
+    /** The event bus to post errors to. */
46
+    private final EventBus eventBus;
43 47
 
44 48
     /**
45 49
      * Creates a new instance of RedoAction.
46 50
      *
51
+     * @param eventBus    The event bus to post errors to
47 52
      * @param undoManager UndoManager to use for this redo action
48 53
      */
49
-    public RedoAction(final UndoManager undoManager) {
54
+    public RedoAction(final EventBus eventBus, final UndoManager undoManager) {
50 55
         super("Undo");
51 56
 
52 57
         this.undoManager = undoManager;
58
+        this.eventBus = eventBus;
53 59
     }
54 60
 
55
-    /**
56
-     * {@inheritDoc}
57
-     *
58
-     * @param evt Action event
59
-     */
60 61
     @Override
61 62
     public void actionPerformed(final ActionEvent evt) {
62 63
         try {
@@ -64,7 +65,7 @@ public final class RedoAction extends AbstractAction {
64 65
                 undoManager.redo();
65 66
             }
66 67
         } catch (CannotUndoException ex) {
67
-            Logger.userError(ErrorLevel.LOW, "Unable to redo");
68
+            eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to redo", ""));
68 69
         }
69 70
     }
70 71
 

+ 17
- 16
src/com/dmdirc/addons/ui_swing/actions/ReplacePasteAction.java View File

@@ -22,8 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.actions;
24 24
 
25
+import com.dmdirc.events.UserErrorEvent;
25 26
 import com.dmdirc.logger.ErrorLevel;
26
-import com.dmdirc.logger.Logger;
27
+
28
+import com.google.common.eventbus.EventBus;
27 29
 
28 30
 import java.awt.datatransfer.Clipboard;
29 31
 import java.awt.datatransfer.DataFlavor;
@@ -47,32 +49,31 @@ public final class ReplacePasteAction extends AbstractAction {
47 49
     private final String replacementRegex;
48 50
     /** Replacement string. */
49 51
     private final String replacementString;
52
+    /** The event bus to post errors to. */
53
+    private final EventBus eventBus;
50 54
 
51 55
     /**
52 56
      * Creates a new instance of regex replacement paste action.
53 57
      *
54
-     * @param clipboard Clipboard to handle pasting
58
+     * @param eventBus          The event bus to post errors to
59
+     * @param clipboard         Clipboard to handle pasting
55 60
      * @param replacementRegex  Regex to match for replacement
56 61
      * @param replacementString Replacement string
57 62
      */
58
-    public ReplacePasteAction(final Clipboard clipboard, final String replacementRegex,
59
-            final String replacementString) {
63
+    public ReplacePasteAction(final EventBus eventBus, final Clipboard clipboard,
64
+            final String replacementRegex, final String replacementString) {
60 65
         super("NoSpacesPasteAction");
61 66
 
67
+        this.eventBus = eventBus;
62 68
         this.clipboard = clipboard;
63 69
         this.replacementRegex = replacementRegex;
64 70
         this.replacementString = replacementString;
65 71
     }
66 72
 
67
-    /**
68
-     * {@inheritDoc}
69
-     *
70
-     * @param e Action event
71
-     */
72 73
     @Override
73 74
     public void actionPerformed(final ActionEvent e) {
74
-        if (!(e.getSource() instanceof JTextComponent)
75
-                || !clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
75
+        if (!(e.getSource() instanceof JTextComponent) ||
76
+                !clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
76 77
             return;
77 78
         }
78 79
 
@@ -82,13 +83,13 @@ public final class ReplacePasteAction extends AbstractAction {
82 83
             //Replace the current selection with the contents of the clipboard
83 84
             ((JTextComponent) e.getSource()).replaceSelection(
84 85
                     ((String) clipboard.getData(DataFlavor.stringFlavor))
85
-                    .replaceAll(replacementRegex, replacementString));
86
+                            .replaceAll(replacementRegex, replacementString));
86 87
         } catch (IOException ex) {
87
-            Logger.userError(ErrorLevel.LOW, "Unable to get clipboard "
88
-                    + "contents: " + ex.getMessage());
88
+            eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex,
89
+                    "Unable to get clipboard contents: " + ex.getMessage(), ""));
89 90
         } catch (UnsupportedFlavorException ex) {
90
-            Logger.appError(ErrorLevel.LOW, "Unable to get clipboard "
91
-                    + "contents", ex);
91
+            eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex,
92
+                    "Unable to get clipboard contents", ""));
92 93
         }
93 94
     }
94 95
 

+ 9
- 8
src/com/dmdirc/addons/ui_swing/actions/UndoAction.java View File

@@ -22,8 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.actions;
24 24
 
25
+import com.dmdirc.events.UserErrorEvent;
25 26
 import com.dmdirc.logger.ErrorLevel;
26
-import com.dmdirc.logger.Logger;
27
+
28
+import com.google.common.eventbus.EventBus;
27 29
 
28 30
 import java.awt.event.ActionEvent;
29 31
 
@@ -40,23 +42,22 @@ public final class UndoAction extends AbstractAction {
40 42
     private static final long serialVersionUID = 1;
41 43
     /** Undo manager. */
42 44
     private final UndoManager undoManager;
45
+    /** The event bus to post errors to. */
46
+    private final EventBus eventBus;
43 47
 
44 48
     /**
45 49
      * Creates a new instance of UndoAction.
46 50
      *
51
+     * @param eventBus    The event bus to post errors to
47 52
      * @param undoManager UndoManager to use for this redo action
48 53
      */
49
-    public UndoAction(final UndoManager undoManager) {
54
+    public UndoAction(final EventBus eventBus, final UndoManager undoManager) {
50 55
         super("Undo");
51 56
 
52 57
         this.undoManager = undoManager;
58
+        this.eventBus = eventBus;
53 59
     }
54 60
 
55
-    /**
56
-     * {@inheritDoc}
57
-     *
58
-     * @param evt Action event
59
-     */
60 61
     @Override
61 62
     public void actionPerformed(final ActionEvent evt) {
62 63
         try {
@@ -64,7 +65,7 @@ public final class UndoAction extends AbstractAction {
64 65
                 undoManager.undo();
65 66
             }
66 67
         } catch (CannotUndoException ex) {
67
-            Logger.userError(ErrorLevel.LOW, "Unable to undo");
68
+            eventBus.post(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to undo", ""));
68 69
         }
69 70
     }
70 71
 

+ 5
- 2
src/com/dmdirc/addons/ui_swing/components/TopicBar.java View File

@@ -40,6 +40,7 @@ import com.dmdirc.ui.messages.ColourManager;
40 40
 import com.dmdirc.ui.messages.Styliser;
41 41
 
42 42
 import com.google.common.base.Optional;
43
+import com.google.common.eventbus.EventBus;
43 44
 
44 45
 import java.awt.Color;
45 46
 import java.awt.Window;
@@ -117,6 +118,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
117 118
      * @param channel           The channel that this topic bar is for.
118 119
      * @param window            The window this topic bar is for.
119 120
      * @param iconManager       The icon manager to use for this bar's icons.
121
+     * @param eventBus          The event bus to post errors to
120 122
      */
121 123
     public TopicBar(
122 124
             final Window parentWindow,
@@ -128,7 +130,8 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
128 130
             final CommandController commandController,
129 131
             final Channel channel,
130 132
             final ChannelFrame window,
131
-            final IconManager iconManager) {
133
+            final IconManager iconManager,
134
+            final EventBus eventBus) {
132 135
         this.channel = channel;
133 136
         this.domain = domain;
134 137
         this.colourManager = colourManager;
@@ -142,7 +145,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
142 145
                 new NewlinesDocumentFilter());
143 146
 
144 147
         topicText.getActionMap().put("paste-from-clipboard",
145
-                new ReplacePasteAction(clipboard, "(\r\n|\n|\r)", " "));
148
+                new ReplacePasteAction(eventBus, clipboard, "(\r\n|\n|\r)", " "));
146 149
         topicEdit = new ImageButton<>("edit",
147 150
                 iconManager.getIcon("edit-inactive"),
148 151
                 iconManager.getIcon("edit"));

+ 7
- 2
src/com/dmdirc/addons/ui_swing/components/TopicBarFactory.java View File

@@ -33,6 +33,8 @@ import com.dmdirc.plugins.PluginManager;
33 33
 import com.dmdirc.ui.IconManager;
34 34
 import com.dmdirc.ui.messages.ColourManager;
35 35
 
36
+import com.google.common.eventbus.EventBus;
37
+
36 38
 import java.awt.Window;
37 39
 import java.awt.datatransfer.Clipboard;
38 40
 
@@ -55,6 +57,7 @@ public class TopicBarFactory {
55 57
     private final PluginManager pluginManager;
56 58
     private final Clipboard clipboard;
57 59
     private final CommandController commandController;
60
+    private final EventBus eventBus;
58 61
 
59 62
     @Inject
60 63
     public TopicBarFactory(
@@ -64,7 +67,8 @@ public class TopicBarFactory {
64 67
             final ColourManager colourManager,
65 68
             final PluginManager pluginManager,
66 69
             final Clipboard clipboard,
67
-            final CommandController commandController) {
70
+            final CommandController commandController,
71
+            final EventBus eventBus) {
68 72
         this.parentWindow = parentWindow;
69 73
         this.globalConfig = globalConfig;
70 74
         this.domain = domain;
@@ -72,6 +76,7 @@ public class TopicBarFactory {
72 76
         this.pluginManager = pluginManager;
73 77
         this.clipboard = clipboard;
74 78
         this.commandController = commandController;
79
+        this.eventBus = eventBus;
75 80
     }
76 81
 
77 82
     public TopicBar getTopicBar(
@@ -79,7 +84,7 @@ public class TopicBarFactory {
79 84
             final ChannelFrame window,
80 85
             final IconManager iconManager) {
81 86
         return new TopicBar(parentWindow.get(), globalConfig, domain, colourManager, pluginManager,
82
-                clipboard, commandController, channel, window, iconManager);
87
+                clipboard, commandController, channel, window, iconManager, eventBus);
83 88
     }
84 89
 
85 90
 }

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

@@ -204,7 +204,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
204 204
      * Initialises the input field.
205 205
      */
206 206
     private void initInputField() {
207
-        UIUtilities.addUndoManager(getInputField().getTextField());
207
+        UIUtilities.addUndoManager(eventBus, getInputField().getTextField());
208 208
 
209 209
         getInputField().getActionMap().put("paste",
210 210
                 new InputTextFramePasteAction(clipboard, this));

+ 4
- 2
src/com/dmdirc/addons/ui_swing/dialogs/aliases/AliasManagerDialog.java View File

@@ -33,6 +33,8 @@ import com.dmdirc.interfaces.ui.AliasDialogModel;
33 33
 import com.dmdirc.ui.IconManager;
34 34
 import com.dmdirc.util.validators.NotEmptyValidator;
35 35
 
36
+import com.google.common.eventbus.EventBus;
37
+
36 38
 import java.awt.Dimension;
37 39
 import java.awt.Window;
38 40
 
@@ -56,7 +58,7 @@ public class AliasManagerDialog extends StandardDialog {
56 58
 
57 59
     @Inject
58 60
     public AliasManagerDialog(@MainWindow final Window mainFrame, final AliasDialogModel model,
59
-            @GlobalConfig final IconManager iconManager) {
61
+            @GlobalConfig final IconManager iconManager, final EventBus eventBus) {
60 62
         super(mainFrame, ModalityType.DOCUMENT_MODAL);
61 63
         final AliasManagerLinker linker = new AliasManagerLinker(model, this, iconManager);
62 64
         setTitle("Alias Manager");
@@ -93,7 +95,7 @@ public class AliasManagerDialog extends StandardDialog {
93 95
         add(getLeftButton(), "flowx, split 3, right, sg button");
94 96
         add(getRightButton(), "sg button");
95 97
 
96
-        UIUtilities.addUndoManager(response);
98
+        UIUtilities.addUndoManager(eventBus, response);
97 99
 
98 100
         linker.bindCommandList(aliasList);
99 101
         linker.bindCommand(command);

+ 10
- 4
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java View File

@@ -36,6 +36,8 @@ import com.dmdirc.interfaces.config.IdentityFactory;
36 36
 import com.dmdirc.interfaces.ui.InputWindow;
37 37
 import com.dmdirc.plugins.ServiceManager;
38 38
 
39
+import com.google.common.eventbus.EventBus;
40
+
39 41
 import java.awt.Window;
40 42
 import java.awt.datatransfer.Clipboard;
41 43
 import java.awt.event.ActionEvent;
@@ -85,6 +87,8 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
85 87
     private final Clipboard clipboard;
86 88
     /** The controller to use to retrieve command information. */
87 89
     private final CommandController commandController;
90
+    /** The event bus to post errors to. */
91
+    private final EventBus eventBus;
88 92
 
89 93
     /**
90 94
      * Creates a new instance of ChannelSettingsDialog.
@@ -110,7 +114,8 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
110 114
             final Channel channel,
111 115
             final Window parentWindow,
112 116
             final Clipboard clipboard,
113
-            final CommandController commandController) {
117
+            final CommandController commandController,
118
+            final EventBus eventBus) {
114 119
         super(parentWindow, ModalityType.MODELESS);
115 120
 
116 121
         this.userConfig = checkNotNull(userConfig);
@@ -120,10 +125,11 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
120 125
         this.channel = checkNotNull(channel);
121 126
         this.clipboard = clipboard;
122 127
         this.commandController = checkNotNull(commandController);
128
+        this.eventBus = eventBus;
123 129
 
124
-        this.identity = identityFactory.createChannelConfig(channel.getConnection().getNetwork(),
130
+        identity = identityFactory.createChannelConfig(channel.getConnection().getNetwork(),
125 131
                 channel.getChannelInfo().getName());
126
-        this.channelWindow = (InputWindow) windowFactory.getSwingWindow(channel);
132
+        channelWindow = (InputWindow) windowFactory.getSwingWindow(channel);
127 133
 
128 134
         initComponents();
129 135
         initListeners();
@@ -161,7 +167,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
161 167
     private void initTopicTab() {
162 168
         topicModesPane = new TopicPane(channel, channel.getIconManager(),
163 169
                 commandController, serviceManager,
164
-                this, channelWindow, clipboard);
170
+                this, channelWindow, clipboard, eventBus);
165 171
         tabbedPane.addTab("Topic", topicModesPane);
166 172
     }
167 173
 

+ 8
- 6
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicDisplayPane.java View File

@@ -37,6 +37,7 @@ import com.dmdirc.plugins.ServiceManager;
37 37
 import com.dmdirc.ui.IconManager;
38 38
 
39 39
 import com.google.common.base.Optional;
40
+import com.google.common.eventbus.EventBus;
40 41
 
41 42
 import java.awt.Color;
42 43
 import java.awt.datatransfer.Clipboard;
@@ -69,6 +70,8 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
69 70
     private final int topicLengthMax;
70 71
     /** Clipboard to copy and paste from. */
71 72
     private final Clipboard clipboard;
73
+    /** The event bus to post errors to. */
74
+    private final EventBus eventBus;
72 75
     /** label showing the number of characters left in a topic. */
73 76
     private JLabel topicLengthLabel;
74 77
     /** Topic text entry text area. */
@@ -87,16 +90,18 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
87 90
      * @param channelWindow     Channel window
88 91
      * @param clipboard         Clipboard to copy and paste
89 92
      * @param commandController The controller to use to retrieve command information.
93
+     * @param eventBus          The event bus to post errors to.
90 94
      */
91 95
     public TopicDisplayPane(final Channel channel, final IconManager iconManager,
92 96
             final ServiceManager serviceManager, final ChannelSettingsDialog parent,
93 97
             final InputWindow channelWindow, final Clipboard clipboard,
94
-            final CommandController commandController) {
98
+            final CommandController commandController, final EventBus eventBus) {
95 99
         this.clipboard = clipboard;
96 100
         this.channel = channel;
97 101
         this.parent = parent;
98 102
         topicLengthMax = channel.getConnection().getParser().getMaxTopicLength();
99 103
         this.channelWindow = channelWindow;
104
+        this.eventBus = eventBus;
100 105
 
101 106
         initComponents(iconManager, channel.getConfigManager(), serviceManager, commandController);
102 107
         addListeners();
@@ -126,13 +131,13 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
126 131
         handler.setTabCompleter(channel.getTabCompleter());
127 132
 
128 133
         topicText.getActionMap().put("paste-from-clipboard",
129
-                new ReplacePasteAction(clipboard, "(\r\n|\n|\r)", " "));
134
+                new ReplacePasteAction(eventBus, clipboard, "(\r\n|\n|\r)", " "));
130 135
         topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
131 136
                 0), new TopicEnterAction(parent));
132 137
         topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
133 138
                 UIUtilities.getCtrlDownMask()), new TopicEnterAction(parent));
134 139
 
135
-        UIUtilities.addUndoManager(topicText);
140
+        UIUtilities.addUndoManager(eventBus, topicText);
136 141
     }
137 142
 
138 143
     /** Adds listeners to the components. */
@@ -194,19 +199,16 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
194 199
         }
195 200
     }
196 201
 
197
-    /** {@inheritDoc}. */
198 202
     @Override
199 203
     public void insertUpdate(final DocumentEvent e) {
200 204
         topicChanged();
201 205
     }
202 206
 
203
-    /** {@inheritDoc}. */
204 207
     @Override
205 208
     public void removeUpdate(final DocumentEvent e) {
206 209
         topicChanged();
207 210
     }
208 211
 
209
-    /** {@inheritDoc}. */
210 212
     @Override
211 213
     public void changedUpdate(final DocumentEvent e) {
212 214
         //Ignore

+ 9
- 7
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/TopicPane.java View File

@@ -30,6 +30,7 @@ import com.dmdirc.plugins.ServiceManager;
30 30
 import com.dmdirc.ui.IconManager;
31 31
 
32 32
 import com.google.common.base.Optional;
33
+import com.google.common.eventbus.EventBus;
33 34
 
34 35
 import java.awt.datatransfer.Clipboard;
35 36
 import java.awt.event.ActionEvent;
@@ -67,14 +68,14 @@ public class TopicPane extends JPanel implements ActionListener {
67 68
      * @param parent            Parent dialog
68 69
      * @param channelWindow     Channel window
69 70
      * @param clipboard         Clipboard to copy and paste with
71
+     * @param eventBus          The event bus to post errors to
70 72
      */
71 73
     public TopicPane(final Channel channel, final IconManager iconManager,
72 74
             final CommandController commandController,
73 75
             final ServiceManager serviceManager, final ChannelSettingsDialog parent,
74
-            final InputWindow channelWindow, final Clipboard clipboard) {
75
-        super();
76
-
77
-        this.setOpaque(UIUtilities.getTabbedPaneOpaque());
76
+            final InputWindow channelWindow, final Clipboard clipboard,
77
+            final EventBus eventBus) {
78
+        setOpaque(UIUtilities.getTabbedPaneOpaque());
78 79
         this.channel = channel;
79 80
         this.parent = parent;
80 81
         this.channelWindow = channelWindow;
@@ -83,7 +84,7 @@ public class TopicPane extends JPanel implements ActionListener {
83 84
         setVisible(false);
84 85
 
85 86
         removeAll();
86
-        initTopicsPanel(iconManager, serviceManager, commandController);
87
+        initTopicsPanel(iconManager, serviceManager, commandController, eventBus);
87 88
         layoutComponents();
88 89
 
89 90
         topicHistoryPane.addActionListener(this);
@@ -94,9 +95,10 @@ public class TopicPane extends JPanel implements ActionListener {
94 95
     private void initTopicsPanel(
95 96
             final IconManager iconManager,
96 97
             final ServiceManager serviceManager,
97
-            final CommandController commandController) {
98
+            final CommandController commandController,
99
+            final EventBus eventBus) {
98 100
         topicDisplayPane = new TopicDisplayPane(channel, iconManager, serviceManager, parent,
99
-                channelWindow, clipboard, commandController);
101
+                channelWindow, clipboard, commandController, eventBus);
100 102
         topicHistoryPane = new TopicHistoryPane(channel);
101 103
     }
102 104
 

+ 3
- 16
src/com/dmdirc/addons/ui_swing/dialogs/paste/PasteDialog.java View File

@@ -79,8 +79,6 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
79 79
     private final AggregateConfigProvider config;
80 80
     /** The controller to use to retrieve command information. */
81 81
     private final CommandController commandController;
82
-    /** The bus to dispatch events on. */
83
-    private final EventBus eventBus;
84 82
 
85 83
     /**
86 84
      * Creates a new instance of PreferencesDialog.
@@ -111,9 +109,8 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
111 109
         this.config = config;
112 110
         this.pluginManager = pluginManager;
113 111
         this.commandController = commandController;
114
-        this.eventBus = eventBus;
115 112
 
116
-        initComponents(text);
113
+        initComponents(eventBus, text);
117 114
         initListeners();
118 115
 
119 116
         setFocusTraversalPolicy(new PasteDialogFocusTraversalPolicy(
@@ -129,13 +126,13 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
129 126
      *
130 127
      * @param text text to show in the dialog
131 128
      */
132
-    private void initComponents(final String text) {
129
+    private void initComponents(final EventBus eventBus, final String text) {
133 130
         scrollPane = new JScrollPane();
134 131
         textField = new TextAreaInputField(iconManager, config, text);
135 132
         editButton = new JButton("Edit");
136 133
         infoLabel = new TextLabel();
137 134
 
138
-        UIUtilities.addUndoManager(textField);
135
+        UIUtilities.addUndoManager(eventBus, textField);
139 136
 
140 137
         orderButtons(new JButton(), new JButton());
141 138
         getOkButton().setText("Send");
@@ -207,11 +204,6 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
207 204
                 KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "leftArrowAction");
208 205
     }
209 206
 
210
-    /**
211
-     * Handles the actions for the dialog.
212
-     *
213
-     * @param actionEvent Action event
214
-     */
215 207
     @Override
216 208
     public void actionPerformed(final ActionEvent actionEvent) {
217 209
         if (getOkButton().equals(actionEvent.getSource())) {
@@ -246,11 +238,6 @@ public final class PasteDialog extends StandardDialog implements ActionListener,
246 238
         }
247 239
     }
248 240
 
249
-    /**
250
-     * {@inheritDoc}
251
-     *
252
-     * @param e Key event
253
-     */
254 241
     @Override
255 242
     public void keyTyped(final KeyEvent e) {
256 243
         infoLabel.setText("This will be sent as "

+ 5
- 2
src/com/dmdirc/addons/ui_swing/injection/DialogModule.java View File

@@ -55,6 +55,8 @@ import com.dmdirc.ui.core.aliases.CoreAliasDialogModel;
55 55
 import com.dmdirc.ui.core.feedback.CoreFeedbackDialogModel;
56 56
 import com.dmdirc.ui.core.newserver.CoreNewServerDialogModel;
57 57
 
58
+import com.google.common.eventbus.EventBus;
59
+
58 60
 import java.awt.Window;
59 61
 import java.awt.datatransfer.Clipboard;
60 62
 
@@ -176,13 +178,14 @@ public class DialogModule {
176 178
             final PrefsComponentFactory compFactory,
177 179
             @MainWindow final Window parentWindow,
178 180
             final Clipboard clipboard,
179
-            final CommandController commandController) {
181
+            final CommandController commandController,
182
+            final EventBus eventBus) {
180 183
         return new KeyedDialogProvider<Channel, ChannelSettingsDialog>() {
181 184
             @Override
182 185
             protected ChannelSettingsDialog getInstance(final Channel key) {
183 186
                 return new ChannelSettingsDialog(identityFactory, windowFactory,
184 187
                         userConfig, serviceManager, preferencesManager,
185
-                        compFactory, key, parentWindow, clipboard, commandController);
188
+                        compFactory, key, parentWindow, clipboard, commandController, eventBus);
186 189
             }
187 190
         };
188 191
     }

Loading…
Cancel
Save