소스 검색

Use some more events.

Remove some deprecated methods in ChannelFrame.

Change-Id: Id5e2318d2432c81cbf9d2f64aa062c888e12bcae
Reviewed-on: http://gerrit.dmdirc.com/3249
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/49/3249/2
Chris Smith 10 년 전
부모
커밋
e9fcd57058

+ 9
- 5
src/com/dmdirc/addons/ui_swing/MainFrame.java 파일 보기

@@ -35,6 +35,8 @@ import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
35 35
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
36 36
 import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
37 37
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
38
+import com.dmdirc.events.ClientFocusGainedEvent;
39
+import com.dmdirc.events.ClientFocusLostEvent;
38 40
 import com.dmdirc.interfaces.FrameInfoListener;
39 41
 import com.dmdirc.interfaces.LifecycleController;
40 42
 import com.dmdirc.interfaces.NotificationListener;
@@ -49,6 +51,8 @@ import com.dmdirc.ui.WindowManager;
49 51
 import com.dmdirc.util.collections.ListenerList;
50 52
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
51 53
 
54
+import com.google.common.eventbus.EventBus;
55
+
52 56
 import java.awt.Dimension;
53 57
 import java.awt.Font;
54 58
 import java.awt.event.WindowEvent;
@@ -139,6 +143,7 @@ public class MainFrame extends JFrame implements WindowListener,
139 143
      * @param quitWorker          The quit worker to use when quitting the app.
140 144
      * @param iconManager         The icon manager to use to get icons.
141 145
      * @param windowManager       Window management
146
+     * @param eventBus            The event bus to post events to.
142 147
      */
143 148
     public MainFrame(
144 149
             final Apple apple,
@@ -148,7 +153,8 @@ public class MainFrame extends JFrame implements WindowListener,
148 153
             final AggregateConfigProvider globalConfig,
149 154
             final Provider<QuitWorker> quitWorker,
150 155
             final IconManager iconManager,
151
-            final WindowManager windowManager) {
156
+            final WindowManager windowManager,
157
+            final EventBus eventBus) {
152 158
         super();
153 159
 
154 160
         this.apple = apple;
@@ -181,15 +187,13 @@ public class MainFrame extends JFrame implements WindowListener,
181 187
             /** {@inheritDoc} */
182 188
             @Override
183 189
             public void windowGainedFocus(final WindowEvent e) {
184
-                ActionManager.getActionManager().triggerEvent(
185
-                        CoreActionType.CLIENT_FOCUS_GAINED, null);
190
+                eventBus.post(new ClientFocusGainedEvent());
186 191
             }
187 192
 
188 193
             /** {@inheritDoc} */
189 194
             @Override
190 195
             public void windowLostFocus(final WindowEvent e) {
191
-                ActionManager.getActionManager().triggerEvent(
192
-                        CoreActionType.CLIENT_FOCUS_LOST, null);
196
+                eventBus.post(new ClientFocusLostEvent());
193 197
             }
194 198
         });
195 199
 

+ 10
- 5
src/com/dmdirc/addons/ui_swing/QuitWorker.java 파일 보기

@@ -23,12 +23,13 @@
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25 25
 import com.dmdirc.ServerManager;
26
-import com.dmdirc.actions.ActionManager;
27
-import com.dmdirc.actions.CoreActionType;
26
+import com.dmdirc.events.ClientClosingEvent;
28 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 28
 import com.dmdirc.interfaces.config.ConfigProvider;
30 29
 import com.dmdirc.interfaces.config.IdentityController;
31 30
 
31
+import com.google.common.eventbus.EventBus;
32
+
32 33
 import javax.inject.Inject;
33 34
 import javax.swing.SwingWorker;
34 35
 
@@ -45,6 +46,8 @@ public class QuitWorker extends SwingWorker<Void, Void> {
45 46
     private final ServerManager serverManager;
46 47
     /** The main frame to interact with. */
47 48
     private final MainFrame mainFrame;
49
+    /** Bus to despatch events on. */
50
+    private final EventBus eventBus;
48 51
 
49 52
     /**
50 53
      * Creates a new {@link QuitWorker}.
@@ -52,23 +55,25 @@ public class QuitWorker extends SwingWorker<Void, Void> {
52 55
      * @param identityController The identity controller to use to read/write settings.
53 56
      * @param serverManager      The server manager to use to disconnect all servers.
54 57
      * @param mainFrame          The main frame to interact with.
58
+     * @param eventBus           Bus to despatch events on.
55 59
      */
56 60
     @Inject
57 61
     public QuitWorker(
58 62
             final IdentityController identityController,
59 63
             final ServerManager serverManager,
60
-            final MainFrame mainFrame) {
64
+            final MainFrame mainFrame,
65
+            final EventBus eventBus) {
61 66
         this.globalIdentity = identityController.getUserSettings();
62 67
         this.globalConfig = identityController.getGlobalConfiguration();
63 68
         this.serverManager = serverManager;
64 69
         this.mainFrame = mainFrame;
70
+        this.eventBus = eventBus;
65 71
     }
66 72
 
67 73
     /** {@inheritDoc} */
68 74
     @Override
69 75
     protected Void doInBackground() {
70
-        ActionManager.getActionManager().triggerEvent(
71
-                CoreActionType.CLIENT_CLOSING, null);
76
+        eventBus.post(new ClientClosingEvent());
72 77
         serverManager.closeAll(globalConfig.getOption("general", "closemessage"));
73 78
         globalIdentity.setOption("ui", "frameManagerSize",
74 79
                 String.valueOf(mainFrame.getFrameManagerSize()));

+ 27
- 26
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java 파일 보기

@@ -25,8 +25,6 @@ package com.dmdirc.addons.ui_swing.components.frames;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.ServerState;
28
-import com.dmdirc.actions.ActionManager;
29
-import com.dmdirc.actions.CoreActionType;
30 28
 import com.dmdirc.addons.ui_swing.SwingController;
31 29
 import com.dmdirc.addons.ui_swing.UIUtilities;
32 30
 import com.dmdirc.addons.ui_swing.components.NickList;
@@ -34,12 +32,16 @@ import com.dmdirc.addons.ui_swing.components.SplitPane;
34 32
 import com.dmdirc.addons.ui_swing.components.TopicBar;
35 33
 import com.dmdirc.addons.ui_swing.components.TopicBarFactory;
36 34
 import com.dmdirc.commandparser.PopupType;
37
-import com.dmdirc.interfaces.actions.ActionType;
35
+import com.dmdirc.events.ClientClosingEvent;
36
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
38 37
 import com.dmdirc.interfaces.config.ConfigProvider;
39 38
 import com.dmdirc.interfaces.config.IdentityFactory;
40 39
 import com.dmdirc.util.annotations.factory.Factory;
41 40
 import com.dmdirc.util.annotations.factory.Unbound;
42 41
 
42
+import com.google.common.eventbus.EventBus;
43
+import com.google.common.eventbus.Subscribe;
44
+
43 45
 import java.awt.Dimension;
44 46
 import java.awt.event.ActionEvent;
45 47
 import java.awt.event.ActionListener;
@@ -54,8 +56,7 @@ import net.miginfocom.swing.MigLayout;
54 56
  * The channel frame is the GUI component that represents a channel to the user.
55 57
  */
56 58
 @Factory(inject = true, singleton = true, providers = true)
57
-public final class ChannelFrame extends InputTextFrame implements ActionListener,
58
-        com.dmdirc.interfaces.ActionListener {
59
+public final class ChannelFrame extends InputTextFrame implements ActionListener {
59 60
 
60 61
     /**
61 62
      * A version number for this class. It should be changed whenever the class structure is changed
@@ -75,6 +76,10 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
75 76
     private TopicBar topicBar;
76 77
     /** UI controller. */
77 78
     private final SwingController controller;
79
+    /** Event bus to despatch events on. */
80
+    private final EventBus eventBus;
81
+    /** Config to read settings from. */
82
+    private final AggregateConfigProvider globalConfig;
78 83
 
79 84
     /**
80 85
      * Creates a new instance of ChannelFrame. Sets up callbacks and handlers, and default options
@@ -91,16 +96,16 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
91 96
             final TopicBarFactory topicBarFactory,
92 97
             @Unbound final Channel owner) {
93 98
         super(deps, owner);
94
-        this.controller = getController();
99
+
100
+        this.controller = deps.controller;
101
+        this.eventBus = deps.eventBus;
102
+        this.globalConfig = deps.globalConfig;
95 103
 
96 104
         initComponents(topicBarFactory);
97 105
 
98
-        controller.getGlobalConfig().addChangeListener("ui",
99
-                "channelSplitPanePosition", this);
100
-        controller.getGlobalConfig().addChangeListener(
101
-                controller.getDomain(), "shownicklist", this);
102
-        ActionManager.getActionManager().registerListener(this,
103
-                CoreActionType.CLIENT_CLOSING);
106
+        globalConfig.addChangeListener("ui", "channelSplitPanePosition", this);
107
+        globalConfig.addChangeListener(controller.getDomain(), "shownicklist", this);
108
+        eventBus.register(this);
104 109
 
105 110
         identity = identityFactory.createChannelConfig(owner.getConnection().getNetwork(),
106 111
                 owner.getChannelInfo().getName());
@@ -137,8 +142,7 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
137 142
         settingsMI = new JMenuItem("Settings");
138 143
         settingsMI.addActionListener(this);
139 144
 
140
-        splitPane = new SplitPane(controller.getGlobalConfig(),
141
-                SplitPane.Orientation.HORIZONTAL);
145
+        splitPane = new SplitPane(globalConfig, SplitPane.Orientation.HORIZONTAL);
142 146
 
143 147
         setLayout(new MigLayout("fill, ins 0, hidemode 3, wrap 1"));
144 148
 
@@ -148,8 +152,8 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
148 152
         add(inputPanel, "growx");
149 153
 
150 154
         splitPane.setLeftComponent(getTextPane());
151
-        if (getContainer().getConfigManager().getOptionBool(getController()
152
-                .getDomain(), "shownicklist")) {
155
+        if (getContainer().getConfigManager().getOptionBool(
156
+                controller.getDomain(), "shownicklist")) {
153 157
             splitPane.setRightComponent(nicklist);
154 158
         } else {
155 159
             splitPane.setRightComponent(null);
@@ -166,7 +170,7 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
166 170
     @Override
167 171
     public void actionPerformed(final ActionEvent actionEvent) {
168 172
         if (actionEvent.getSource() == settingsMI) {
169
-            getController().showChannelSettingsDialog((Channel) getContainer());
173
+            controller.showChannelSettingsDialog((Channel) getContainer());
170 174
         }
171 175
     }
172 176
 
@@ -179,7 +183,6 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
179 183
         return splitPane;
180 184
     }
181 185
 
182
-    /** {@inheritDoc} */
183 186
     @Override
184 187
     public void configChanged(final String domain, final String key) {
185 188
         super.configChanged(domain, key);
@@ -199,8 +202,8 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
199 202
             });
200 203
         }
201 204
         if ("shownicklist".equals(key)) {
202
-            if (getContainer().getConfigManager().getOptionBool(getController()
203
-                    .getDomain(), "shownicklist")) {
205
+            if (getContainer().getConfigManager()
206
+                    .getOptionBool(controller.getDomain(), "shownicklist")) {
204 207
                 splitPane.setRightComponent(nicklist);
205 208
             } else {
206 209
                 splitPane.setRightComponent(null);
@@ -208,10 +211,8 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
208 211
         }
209 212
     }
210 213
 
211
-    /** {@inheritDoc} */
212
-    @Override
213
-    public void processEvent(final ActionType type, final StringBuffer format,
214
-            final Object... arguments) {
214
+    @Subscribe
215
+    public void handleClientClosing(final ClientClosingEvent event) {
215 216
         saveSplitPanePosition();
216 217
     }
217 218
 
@@ -279,8 +280,8 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
279 280
     /** {@inheritDoc} */
280 281
     @Override
281 282
     public void dispose() {
282
-        ActionManager.getActionManager().unregisterListener(this);
283
-        controller.getGlobalConfig().removeListener(this);
283
+        eventBus.unregister(this);
284
+        globalConfig.removeListener(this);
284 285
         super.dispose();
285 286
     }
286 287
 

+ 34
- 25
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java 파일 보기

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
+import com.dmdirc.ClientModule.GlobalConfig;
25 26
 import com.dmdirc.FrameContainer;
26 27
 import com.dmdirc.actions.ActionManager;
27 28
 import com.dmdirc.actions.CoreActionType;
@@ -63,6 +64,8 @@ import com.dmdirc.ui.IconManager;
63 64
 import com.dmdirc.ui.core.util.URLHandler;
64 65
 import com.dmdirc.ui.messages.ColourManager;
65 66
 
67
+import com.google.common.eventbus.EventBus;
68
+
66 69
 import java.awt.Point;
67 70
 import java.awt.event.KeyEvent;
68 71
 import java.awt.event.MouseEvent;
@@ -256,26 +259,26 @@ public abstract class TextFrame extends JPanel implements Window,
256 259
 
257 260
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
258 261
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
259
-                "pageUpAction");
262
+                        "pageUpAction");
260 263
 
261 264
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
262 265
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
263
-                "pageDownAction");
266
+                        "pageDownAction");
264 267
 
265 268
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
266 269
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), "searchAction");
267 270
 
268 271
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
269 272
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_F,
270
-                UIUtilities.getCtrlDownMask()), "searchAction");
273
+                                UIUtilities.getCtrlDownMask()), "searchAction");
271 274
 
272 275
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
273 276
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
274
-                UIUtilities.getCtrlDownMask()), "homeAction");
277
+                                UIUtilities.getCtrlDownMask()), "homeAction");
275 278
 
276 279
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
277 280
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_END,
278
-                UIUtilities.getCtrlDownMask()), "endAction");
281
+                                UIUtilities.getCtrlDownMask()), "endAction");
279 282
 
280 283
         getSearchBar().getTextField().getInputMap().put(KeyStroke.getKeyStroke(
281 284
                 KeyEvent.VK_C, UIUtilities.getCtrlMask()), "textpaneCopy");
@@ -284,7 +287,7 @@ public abstract class TextFrame extends JPanel implements Window,
284 287
                 & KeyEvent.SHIFT_DOWN_MASK), "textpaneCopy");
285 288
         getSearchBar().getTextField().getActionMap().put("textpaneCopy",
286 289
                 new InputFieldCopyAction(getTextPane(),
287
-                getSearchBar().getTextField()));
290
+                        getSearchBar().getTextField()));
288 291
 
289 292
         getActionMap().put("pageUpAction",
290 293
                 new TextPanePageUpAction(getTextPane()));
@@ -352,8 +355,8 @@ public abstract class TextFrame extends JPanel implements Window,
352 355
             case CHANNEL:
353 356
                 if (frameParent.getConnection() != null && ActionManager
354 357
                         .getActionManager().triggerEvent(
355
-                        CoreActionType.LINK_CHANNEL_CLICKED, null, this,
356
-                        clickType.getValue())) {
358
+                                CoreActionType.LINK_CHANNEL_CLICKED, null, this,
359
+                                clickType.getValue())) {
357 360
                     frameParent.getConnection().join(
358 361
                             new ChannelJoinRequest(clickType.getValue()));
359 362
                 }
@@ -368,11 +371,11 @@ public abstract class TextFrame extends JPanel implements Window,
368 371
             case NICKNAME:
369 372
                 if (frameParent.getConnection() != null && ActionManager
370 373
                         .getActionManager().triggerEvent(
371
-                        CoreActionType.LINK_NICKNAME_CLICKED, null, this,
372
-                        clickType.getValue())) {
374
+                                CoreActionType.LINK_NICKNAME_CLICKED, null, this,
375
+                                clickType.getValue())) {
373 376
                     getController().requestWindowFocus(getController()
374 377
                             .getWindowFactory().getSwingWindow(getContainer()
375
-                            .getConnection().getQuery(clickType.getValue())));
378
+                                    .getConnection().getQuery(clickType.getValue())));
376 379
                 }
377 380
                 break;
378 381
             default:
@@ -582,12 +585,12 @@ public abstract class TextFrame extends JPanel implements Window,
582 585
         final ColourManager colourManager = new ColourManager(getContainer().getConfigManager());
583 586
         getTextPane().setForeground(UIUtilities.convertColour(
584 587
                 colourManager.getColourFromString(
585
-                getContainer().getConfigManager().getOptionString(
586
-                "ui", "foregroundcolour"), null)));
588
+                        getContainer().getConfigManager().getOptionString(
589
+                                "ui", "foregroundcolour"), null)));
587 590
         getTextPane().setBackground(UIUtilities.convertColour(
588 591
                 colourManager.getColourFromString(
589
-                getContainer().getConfigManager().getOptionString(
590
-                "ui", "backgroundcolour"), null)));
592
+                        getContainer().getConfigManager().getOptionString(
593
+                                "ui", "backgroundcolour"), null)));
591 594
     }
592 595
 
593 596
     /** Disposes of this window, removing any listeners. */
@@ -599,18 +602,20 @@ public abstract class TextFrame extends JPanel implements Window,
599 602
     /**
600 603
      * Bundle of dependencies required by {@link TextFrame}.
601 604
      *
602
-     * <p>Because of the number of dependencies and the amount of subclassing, collect the
603
-     * dependencies together here so they can be easily modified without having to modify all
604
-     * subclasses.
605
+     * <p>
606
+     * Because of the number of dependencies and the amount of subclassing, collect the dependencies
607
+     * together here so they can be easily modified without having to modify all subclasses.
605 608
      */
606 609
     public static class TextFrameDependencies {
607 610
 
608
-        private final TextPaneFactory textPaneFactory;
609
-        private final SwingController controller;
610
-        private final Provider<MainFrame> mainFrame;
611
-        private final PopupManager popupManager;
612
-        private final URLHandler urlHandler;
613
-        private final CommandController commandController;
611
+        final TextPaneFactory textPaneFactory;
612
+        final SwingController controller;
613
+        final Provider<MainFrame> mainFrame;
614
+        final PopupManager popupManager;
615
+        final URLHandler urlHandler;
616
+        final CommandController commandController;
617
+        final EventBus eventBus;
618
+        final AggregateConfigProvider globalConfig;
614 619
 
615 620
         @Inject
616 621
         public TextFrameDependencies(
@@ -619,13 +624,17 @@ public abstract class TextFrame extends JPanel implements Window,
619 624
                 final Provider<MainFrame> mainFrame,
620 625
                 final PopupManager popupManager,
621 626
                 final URLHandler urlHandler,
622
-                final CommandController commandController) {
627
+                final CommandController commandController,
628
+                final EventBus eventBus,
629
+                @GlobalConfig final AggregateConfigProvider globalConfig) {
623 630
             this.textPaneFactory = textPaneFactory;
624 631
             this.controller = controller;
625 632
             this.mainFrame = mainFrame;
626 633
             this.popupManager = popupManager;
627 634
             this.urlHandler = urlHandler;
628 635
             this.commandController = commandController;
636
+            this.eventBus = eventBus;
637
+            this.globalConfig = globalConfig;
629 638
         }
630 639
 
631 640
     }

+ 6
- 43
src/com/dmdirc/addons/ui_swing/injection/SwingModule.java 파일 보기

@@ -55,6 +55,8 @@ import com.dmdirc.ui.core.components.StatusBarManager;
55 55
 import com.dmdirc.ui.core.util.URLHandler;
56 56
 import com.dmdirc.util.URLBuilder;
57 57
 
58
+import com.google.common.eventbus.EventBus;
59
+
58 60
 import java.util.concurrent.Callable;
59 61
 
60 62
 import javax.inject.Provider;
@@ -84,53 +86,22 @@ public class SwingModule {
84 86
     /** The domain for plugin settings. */
85 87
     private final String domain;
86 88
 
87
-    /**
88
-     * Creates a new instance of {@link SwingModule}.
89
-     *
90
-     * @param controller The controller to return. This should be removed when SwingController is
91
-     *                   separated from the plugin implementation.
92
-     * @param domain     The domain for plugin settings.
93
-     */
94 89
     public SwingModule(final SwingController controller, final String domain) {
95 90
         this.controller = controller;
96 91
         this.domain = domain;
97 92
     }
98 93
 
99
-    /**
100
-     * Provides the domain that the swing settings should be stored under.
101
-     *
102
-     * @return The settings domain for the swing plugin.
103
-     */
104 94
     @Provides
105 95
     @PluginDomain(SwingController.class)
106 96
     public String getSettingsDomain() {
107 97
         return domain;
108 98
     }
109 99
 
110
-    /**
111
-     * Gets the swing controller to use.
112
-     *
113
-     * @return The swing controller.
114
-     */
115 100
     @Provides
116 101
     public SwingController getController() {
117 102
         return controller;
118 103
     }
119 104
 
120
-    /**
121
-     * Gets the main DMDirc window.
122
-     *
123
-     * @param apple               Apple instance
124
-     * @param swingController     The controller that will own the frame.
125
-     * @param windowFactory       The window factory to use to create and listen for windows.
126
-     * @param lifecycleController The controller to use to quit the application.
127
-     * @param globalConfig        The config to read settings from.
128
-     * @param quitWorker          The worker to use when quitting the application.
129
-     * @param urlBuilder          The URL builder to use to find icons.
130
-     * @param windowManager       The core window manager to use to find windows.
131
-     *
132
-     * @return The main window.
133
-     */
134 105
     @Provides
135 106
     @Singleton
136 107
     public MainFrame getMainFrame(
@@ -141,7 +112,8 @@ public class SwingModule {
141 112
             @GlobalConfig final AggregateConfigProvider globalConfig,
142 113
             final Provider<QuitWorker> quitWorker,
143 114
             final URLBuilder urlBuilder,
144
-            final WindowManager windowManager) {
115
+            final WindowManager windowManager,
116
+            final EventBus eventBus) {
145 117
         return UIUtilities.invokeAndWait(new Callable<MainFrame>() {
146 118
             /** {@inheritDoc} */
147 119
             @Override
@@ -154,21 +126,12 @@ public class SwingModule {
154 126
                         globalConfig,
155 127
                         quitWorker,
156 128
                         new IconManager(globalConfig, urlBuilder),
157
-                        windowManager);
129
+                        windowManager,
130
+                        eventBus);
158 131
             }
159 132
         });
160 133
     }
161 134
 
162
-    /**
163
-     * Provides an URL handler for use in the swing UI.
164
-     *
165
-     * @param swingController  The controller that will own the handler.
166
-     * @param globalConfig     The global configuration to read settings from.
167
-     * @param serverManager    The server manager to use to connect to servers.
168
-     * @param statusBarManager The status bar manager to add messages to.
169
-     *
170
-     * @return The URL handler to use.
171
-     */
172 135
     @Provides
173 136
     @Singleton
174 137
     public URLHandler getURLHandler(

+ 16
- 15
src/com/dmdirc/addons/windowflashing/WindowFlashingManager.java 파일 보기

@@ -23,15 +23,15 @@
23 23
 package com.dmdirc.addons.windowflashing;
24 24
 
25 25
 import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.actions.CoreActionType;
27 26
 import com.dmdirc.addons.ui_swing.MainFrame;
28 27
 import com.dmdirc.config.ConfigBinder;
29 28
 import com.dmdirc.config.ConfigBinding;
30
-import com.dmdirc.interfaces.ActionController;
31
-import com.dmdirc.interfaces.ActionListener;
32
-import com.dmdirc.interfaces.actions.ActionType;
29
+import com.dmdirc.events.ClientFocusGainedEvent;
33 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
34 31
 
32
+import com.google.common.eventbus.EventBus;
33
+import com.google.common.eventbus.Subscribe;
34
+
35 35
 import javax.inject.Inject;
36 36
 
37 37
 import com.sun.jna.Native;
@@ -41,12 +41,12 @@ import com.sun.jna.platform.win32.User32;
41 41
 import com.sun.jna.platform.win32.WinDef;
42 42
 import com.sun.jna.platform.win32.WinUser;
43 43
 
44
-public class WindowFlashingManager implements ActionListener {
44
+public class WindowFlashingManager {
45 45
 
46 46
     /** Swing main frame. */
47 47
     private final MainFrame mainFrame;
48
-    /** Action controller. */
49
-    private final ActionController actionController;
48
+    /** Event bus. */
49
+    private final EventBus eventBus;
50 50
     /** Config binder. */
51 51
     private final ConfigBinder binder;
52 52
     /** Cached blink rate setting. */
@@ -67,21 +67,23 @@ public class WindowFlashingManager implements ActionListener {
67 67
     private User32 user32;
68 68
 
69 69
     @Inject
70
-    public WindowFlashingManager(@GlobalConfig final AggregateConfigProvider config,
71
-            final MainFrame mainFrame, final ActionController actionController) {
70
+    public WindowFlashingManager(
71
+            @GlobalConfig final AggregateConfigProvider config,
72
+            final MainFrame mainFrame,
73
+            final EventBus eventBus) {
72 74
         this.mainFrame = mainFrame;
73
-        this.actionController = actionController;
75
+        this.eventBus = eventBus;
74 76
         binder = config.getBinder();
75 77
     }
76 78
 
77 79
     public void onLoad() {
78 80
         user32 = (User32) Native.loadLibrary("user32", User32.class);
79 81
         binder.bind(this, WindowFlashing.class);
80
-        actionController.registerListener(this, CoreActionType.CLIENT_FOCUS_GAINED);
82
+        eventBus.register(this);
81 83
     }
82 84
 
83 85
     public void onUnload() {
84
-        actionController.unregisterListener(this);
86
+        eventBus.unregister(this);
85 87
         binder.unbind(this);
86 88
         user32 = null;
87 89
         NativeLibrary.getInstance("user32").dispose();
@@ -155,9 +157,8 @@ public class WindowFlashingManager implements ActionListener {
155 157
         return returnValue;
156 158
     }
157 159
 
158
-    @Override
159
-    public void processEvent(final ActionType type, final StringBuffer format,
160
-            final Object... arguments) {
160
+    @Subscribe
161
+    public void handleFocusGained(final ClientFocusGainedEvent event) {
161 162
         if (mainFrame != null) {
162 163
             user32.FlashWindowEx(stopFlashObject());
163 164
         }

Loading…
취소
저장