Parcourir la source

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 il y a 10 ans
Parent
révision
e9fcd57058

+ 9
- 5
src/com/dmdirc/addons/ui_swing/MainFrame.java Voir le fichier

35
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
35
 import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
36
 import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
36
 import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
37
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
37
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
38
+import com.dmdirc.events.ClientFocusGainedEvent;
39
+import com.dmdirc.events.ClientFocusLostEvent;
38
 import com.dmdirc.interfaces.FrameInfoListener;
40
 import com.dmdirc.interfaces.FrameInfoListener;
39
 import com.dmdirc.interfaces.LifecycleController;
41
 import com.dmdirc.interfaces.LifecycleController;
40
 import com.dmdirc.interfaces.NotificationListener;
42
 import com.dmdirc.interfaces.NotificationListener;
49
 import com.dmdirc.util.collections.ListenerList;
51
 import com.dmdirc.util.collections.ListenerList;
50
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
52
 import com.dmdirc.util.collections.QueuedLinkedHashSet;
51
 
53
 
54
+import com.google.common.eventbus.EventBus;
55
+
52
 import java.awt.Dimension;
56
 import java.awt.Dimension;
53
 import java.awt.Font;
57
 import java.awt.Font;
54
 import java.awt.event.WindowEvent;
58
 import java.awt.event.WindowEvent;
139
      * @param quitWorker          The quit worker to use when quitting the app.
143
      * @param quitWorker          The quit worker to use when quitting the app.
140
      * @param iconManager         The icon manager to use to get icons.
144
      * @param iconManager         The icon manager to use to get icons.
141
      * @param windowManager       Window management
145
      * @param windowManager       Window management
146
+     * @param eventBus            The event bus to post events to.
142
      */
147
      */
143
     public MainFrame(
148
     public MainFrame(
144
             final Apple apple,
149
             final Apple apple,
148
             final AggregateConfigProvider globalConfig,
153
             final AggregateConfigProvider globalConfig,
149
             final Provider<QuitWorker> quitWorker,
154
             final Provider<QuitWorker> quitWorker,
150
             final IconManager iconManager,
155
             final IconManager iconManager,
151
-            final WindowManager windowManager) {
156
+            final WindowManager windowManager,
157
+            final EventBus eventBus) {
152
         super();
158
         super();
153
 
159
 
154
         this.apple = apple;
160
         this.apple = apple;
181
             /** {@inheritDoc} */
187
             /** {@inheritDoc} */
182
             @Override
188
             @Override
183
             public void windowGainedFocus(final WindowEvent e) {
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
             /** {@inheritDoc} */
193
             /** {@inheritDoc} */
189
             @Override
194
             @Override
190
             public void windowLostFocus(final WindowEvent e) {
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 Voir le fichier

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

+ 27
- 26
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java Voir le fichier

25
 import com.dmdirc.Channel;
25
 import com.dmdirc.Channel;
26
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
27
 import com.dmdirc.ServerState;
27
 import com.dmdirc.ServerState;
28
-import com.dmdirc.actions.ActionManager;
29
-import com.dmdirc.actions.CoreActionType;
30
 import com.dmdirc.addons.ui_swing.SwingController;
28
 import com.dmdirc.addons.ui_swing.SwingController;
31
 import com.dmdirc.addons.ui_swing.UIUtilities;
29
 import com.dmdirc.addons.ui_swing.UIUtilities;
32
 import com.dmdirc.addons.ui_swing.components.NickList;
30
 import com.dmdirc.addons.ui_swing.components.NickList;
34
 import com.dmdirc.addons.ui_swing.components.TopicBar;
32
 import com.dmdirc.addons.ui_swing.components.TopicBar;
35
 import com.dmdirc.addons.ui_swing.components.TopicBarFactory;
33
 import com.dmdirc.addons.ui_swing.components.TopicBarFactory;
36
 import com.dmdirc.commandparser.PopupType;
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
 import com.dmdirc.interfaces.config.ConfigProvider;
37
 import com.dmdirc.interfaces.config.ConfigProvider;
39
 import com.dmdirc.interfaces.config.IdentityFactory;
38
 import com.dmdirc.interfaces.config.IdentityFactory;
40
 import com.dmdirc.util.annotations.factory.Factory;
39
 import com.dmdirc.util.annotations.factory.Factory;
41
 import com.dmdirc.util.annotations.factory.Unbound;
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
 import java.awt.Dimension;
45
 import java.awt.Dimension;
44
 import java.awt.event.ActionEvent;
46
 import java.awt.event.ActionEvent;
45
 import java.awt.event.ActionListener;
47
 import java.awt.event.ActionListener;
54
  * The channel frame is the GUI component that represents a channel to the user.
56
  * The channel frame is the GUI component that represents a channel to the user.
55
  */
57
  */
56
 @Factory(inject = true, singleton = true, providers = true)
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
      * A version number for this class. It should be changed whenever the class structure is changed
62
      * A version number for this class. It should be changed whenever the class structure is changed
75
     private TopicBar topicBar;
76
     private TopicBar topicBar;
76
     /** UI controller. */
77
     /** UI controller. */
77
     private final SwingController controller;
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
      * Creates a new instance of ChannelFrame. Sets up callbacks and handlers, and default options
85
      * Creates a new instance of ChannelFrame. Sets up callbacks and handlers, and default options
91
             final TopicBarFactory topicBarFactory,
96
             final TopicBarFactory topicBarFactory,
92
             @Unbound final Channel owner) {
97
             @Unbound final Channel owner) {
93
         super(deps, owner);
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
         initComponents(topicBarFactory);
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
         identity = identityFactory.createChannelConfig(owner.getConnection().getNetwork(),
110
         identity = identityFactory.createChannelConfig(owner.getConnection().getNetwork(),
106
                 owner.getChannelInfo().getName());
111
                 owner.getChannelInfo().getName());
137
         settingsMI = new JMenuItem("Settings");
142
         settingsMI = new JMenuItem("Settings");
138
         settingsMI.addActionListener(this);
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
         setLayout(new MigLayout("fill, ins 0, hidemode 3, wrap 1"));
147
         setLayout(new MigLayout("fill, ins 0, hidemode 3, wrap 1"));
144
 
148
 
148
         add(inputPanel, "growx");
152
         add(inputPanel, "growx");
149
 
153
 
150
         splitPane.setLeftComponent(getTextPane());
154
         splitPane.setLeftComponent(getTextPane());
151
-        if (getContainer().getConfigManager().getOptionBool(getController()
152
-                .getDomain(), "shownicklist")) {
155
+        if (getContainer().getConfigManager().getOptionBool(
156
+                controller.getDomain(), "shownicklist")) {
153
             splitPane.setRightComponent(nicklist);
157
             splitPane.setRightComponent(nicklist);
154
         } else {
158
         } else {
155
             splitPane.setRightComponent(null);
159
             splitPane.setRightComponent(null);
166
     @Override
170
     @Override
167
     public void actionPerformed(final ActionEvent actionEvent) {
171
     public void actionPerformed(final ActionEvent actionEvent) {
168
         if (actionEvent.getSource() == settingsMI) {
172
         if (actionEvent.getSource() == settingsMI) {
169
-            getController().showChannelSettingsDialog((Channel) getContainer());
173
+            controller.showChannelSettingsDialog((Channel) getContainer());
170
         }
174
         }
171
     }
175
     }
172
 
176
 
179
         return splitPane;
183
         return splitPane;
180
     }
184
     }
181
 
185
 
182
-    /** {@inheritDoc} */
183
     @Override
186
     @Override
184
     public void configChanged(final String domain, final String key) {
187
     public void configChanged(final String domain, final String key) {
185
         super.configChanged(domain, key);
188
         super.configChanged(domain, key);
199
             });
202
             });
200
         }
203
         }
201
         if ("shownicklist".equals(key)) {
204
         if ("shownicklist".equals(key)) {
202
-            if (getContainer().getConfigManager().getOptionBool(getController()
203
-                    .getDomain(), "shownicklist")) {
205
+            if (getContainer().getConfigManager()
206
+                    .getOptionBool(controller.getDomain(), "shownicklist")) {
204
                 splitPane.setRightComponent(nicklist);
207
                 splitPane.setRightComponent(nicklist);
205
             } else {
208
             } else {
206
                 splitPane.setRightComponent(null);
209
                 splitPane.setRightComponent(null);
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
         saveSplitPanePosition();
216
         saveSplitPanePosition();
216
     }
217
     }
217
 
218
 
279
     /** {@inheritDoc} */
280
     /** {@inheritDoc} */
280
     @Override
281
     @Override
281
     public void dispose() {
282
     public void dispose() {
282
-        ActionManager.getActionManager().unregisterListener(this);
283
-        controller.getGlobalConfig().removeListener(this);
283
+        eventBus.unregister(this);
284
+        globalConfig.removeListener(this);
284
         super.dispose();
285
         super.dispose();
285
     }
286
     }
286
 
287
 

+ 34
- 25
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java Voir le fichier

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.components.frames;
23
 package com.dmdirc.addons.ui_swing.components.frames;
24
 
24
 
25
+import com.dmdirc.ClientModule.GlobalConfig;
25
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.actions.ActionManager;
27
 import com.dmdirc.actions.ActionManager;
27
 import com.dmdirc.actions.CoreActionType;
28
 import com.dmdirc.actions.CoreActionType;
63
 import com.dmdirc.ui.core.util.URLHandler;
64
 import com.dmdirc.ui.core.util.URLHandler;
64
 import com.dmdirc.ui.messages.ColourManager;
65
 import com.dmdirc.ui.messages.ColourManager;
65
 
66
 
67
+import com.google.common.eventbus.EventBus;
68
+
66
 import java.awt.Point;
69
 import java.awt.Point;
67
 import java.awt.event.KeyEvent;
70
 import java.awt.event.KeyEvent;
68
 import java.awt.event.MouseEvent;
71
 import java.awt.event.MouseEvent;
256
 
259
 
257
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
260
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
258
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
261
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
259
-                "pageUpAction");
262
+                        "pageUpAction");
260
 
263
 
261
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
264
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
262
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
265
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
263
-                "pageDownAction");
266
+                        "pageDownAction");
264
 
267
 
265
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
268
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
266
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), "searchAction");
269
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), "searchAction");
267
 
270
 
268
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
271
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
269
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_F,
272
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_F,
270
-                UIUtilities.getCtrlDownMask()), "searchAction");
273
+                                UIUtilities.getCtrlDownMask()), "searchAction");
271
 
274
 
272
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
275
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
273
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
276
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME,
274
-                UIUtilities.getCtrlDownMask()), "homeAction");
277
+                                UIUtilities.getCtrlDownMask()), "homeAction");
275
 
278
 
276
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
279
         getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
277
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_END,
280
                 put(KeyStroke.getKeyStroke(KeyEvent.VK_END,
278
-                UIUtilities.getCtrlDownMask()), "endAction");
281
+                                UIUtilities.getCtrlDownMask()), "endAction");
279
 
282
 
280
         getSearchBar().getTextField().getInputMap().put(KeyStroke.getKeyStroke(
283
         getSearchBar().getTextField().getInputMap().put(KeyStroke.getKeyStroke(
281
                 KeyEvent.VK_C, UIUtilities.getCtrlMask()), "textpaneCopy");
284
                 KeyEvent.VK_C, UIUtilities.getCtrlMask()), "textpaneCopy");
284
                 & KeyEvent.SHIFT_DOWN_MASK), "textpaneCopy");
287
                 & KeyEvent.SHIFT_DOWN_MASK), "textpaneCopy");
285
         getSearchBar().getTextField().getActionMap().put("textpaneCopy",
288
         getSearchBar().getTextField().getActionMap().put("textpaneCopy",
286
                 new InputFieldCopyAction(getTextPane(),
289
                 new InputFieldCopyAction(getTextPane(),
287
-                getSearchBar().getTextField()));
290
+                        getSearchBar().getTextField()));
288
 
291
 
289
         getActionMap().put("pageUpAction",
292
         getActionMap().put("pageUpAction",
290
                 new TextPanePageUpAction(getTextPane()));
293
                 new TextPanePageUpAction(getTextPane()));
352
             case CHANNEL:
355
             case CHANNEL:
353
                 if (frameParent.getConnection() != null && ActionManager
356
                 if (frameParent.getConnection() != null && ActionManager
354
                         .getActionManager().triggerEvent(
357
                         .getActionManager().triggerEvent(
355
-                        CoreActionType.LINK_CHANNEL_CLICKED, null, this,
356
-                        clickType.getValue())) {
358
+                                CoreActionType.LINK_CHANNEL_CLICKED, null, this,
359
+                                clickType.getValue())) {
357
                     frameParent.getConnection().join(
360
                     frameParent.getConnection().join(
358
                             new ChannelJoinRequest(clickType.getValue()));
361
                             new ChannelJoinRequest(clickType.getValue()));
359
                 }
362
                 }
368
             case NICKNAME:
371
             case NICKNAME:
369
                 if (frameParent.getConnection() != null && ActionManager
372
                 if (frameParent.getConnection() != null && ActionManager
370
                         .getActionManager().triggerEvent(
373
                         .getActionManager().triggerEvent(
371
-                        CoreActionType.LINK_NICKNAME_CLICKED, null, this,
372
-                        clickType.getValue())) {
374
+                                CoreActionType.LINK_NICKNAME_CLICKED, null, this,
375
+                                clickType.getValue())) {
373
                     getController().requestWindowFocus(getController()
376
                     getController().requestWindowFocus(getController()
374
                             .getWindowFactory().getSwingWindow(getContainer()
377
                             .getWindowFactory().getSwingWindow(getContainer()
375
-                            .getConnection().getQuery(clickType.getValue())));
378
+                                    .getConnection().getQuery(clickType.getValue())));
376
                 }
379
                 }
377
                 break;
380
                 break;
378
             default:
381
             default:
582
         final ColourManager colourManager = new ColourManager(getContainer().getConfigManager());
585
         final ColourManager colourManager = new ColourManager(getContainer().getConfigManager());
583
         getTextPane().setForeground(UIUtilities.convertColour(
586
         getTextPane().setForeground(UIUtilities.convertColour(
584
                 colourManager.getColourFromString(
587
                 colourManager.getColourFromString(
585
-                getContainer().getConfigManager().getOptionString(
586
-                "ui", "foregroundcolour"), null)));
588
+                        getContainer().getConfigManager().getOptionString(
589
+                                "ui", "foregroundcolour"), null)));
587
         getTextPane().setBackground(UIUtilities.convertColour(
590
         getTextPane().setBackground(UIUtilities.convertColour(
588
                 colourManager.getColourFromString(
591
                 colourManager.getColourFromString(
589
-                getContainer().getConfigManager().getOptionString(
590
-                "ui", "backgroundcolour"), null)));
592
+                        getContainer().getConfigManager().getOptionString(
593
+                                "ui", "backgroundcolour"), null)));
591
     }
594
     }
592
 
595
 
593
     /** Disposes of this window, removing any listeners. */
596
     /** Disposes of this window, removing any listeners. */
599
     /**
602
     /**
600
      * Bundle of dependencies required by {@link TextFrame}.
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
     public static class TextFrameDependencies {
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
         @Inject
620
         @Inject
616
         public TextFrameDependencies(
621
         public TextFrameDependencies(
619
                 final Provider<MainFrame> mainFrame,
624
                 final Provider<MainFrame> mainFrame,
620
                 final PopupManager popupManager,
625
                 final PopupManager popupManager,
621
                 final URLHandler urlHandler,
626
                 final URLHandler urlHandler,
622
-                final CommandController commandController) {
627
+                final CommandController commandController,
628
+                final EventBus eventBus,
629
+                @GlobalConfig final AggregateConfigProvider globalConfig) {
623
             this.textPaneFactory = textPaneFactory;
630
             this.textPaneFactory = textPaneFactory;
624
             this.controller = controller;
631
             this.controller = controller;
625
             this.mainFrame = mainFrame;
632
             this.mainFrame = mainFrame;
626
             this.popupManager = popupManager;
633
             this.popupManager = popupManager;
627
             this.urlHandler = urlHandler;
634
             this.urlHandler = urlHandler;
628
             this.commandController = commandController;
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 Voir le fichier

55
 import com.dmdirc.ui.core.util.URLHandler;
55
 import com.dmdirc.ui.core.util.URLHandler;
56
 import com.dmdirc.util.URLBuilder;
56
 import com.dmdirc.util.URLBuilder;
57
 
57
 
58
+import com.google.common.eventbus.EventBus;
59
+
58
 import java.util.concurrent.Callable;
60
 import java.util.concurrent.Callable;
59
 
61
 
60
 import javax.inject.Provider;
62
 import javax.inject.Provider;
84
     /** The domain for plugin settings. */
86
     /** The domain for plugin settings. */
85
     private final String domain;
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
     public SwingModule(final SwingController controller, final String domain) {
89
     public SwingModule(final SwingController controller, final String domain) {
95
         this.controller = controller;
90
         this.controller = controller;
96
         this.domain = domain;
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
     @Provides
94
     @Provides
105
     @PluginDomain(SwingController.class)
95
     @PluginDomain(SwingController.class)
106
     public String getSettingsDomain() {
96
     public String getSettingsDomain() {
107
         return domain;
97
         return domain;
108
     }
98
     }
109
 
99
 
110
-    /**
111
-     * Gets the swing controller to use.
112
-     *
113
-     * @return The swing controller.
114
-     */
115
     @Provides
100
     @Provides
116
     public SwingController getController() {
101
     public SwingController getController() {
117
         return controller;
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
     @Provides
105
     @Provides
135
     @Singleton
106
     @Singleton
136
     public MainFrame getMainFrame(
107
     public MainFrame getMainFrame(
141
             @GlobalConfig final AggregateConfigProvider globalConfig,
112
             @GlobalConfig final AggregateConfigProvider globalConfig,
142
             final Provider<QuitWorker> quitWorker,
113
             final Provider<QuitWorker> quitWorker,
143
             final URLBuilder urlBuilder,
114
             final URLBuilder urlBuilder,
144
-            final WindowManager windowManager) {
115
+            final WindowManager windowManager,
116
+            final EventBus eventBus) {
145
         return UIUtilities.invokeAndWait(new Callable<MainFrame>() {
117
         return UIUtilities.invokeAndWait(new Callable<MainFrame>() {
146
             /** {@inheritDoc} */
118
             /** {@inheritDoc} */
147
             @Override
119
             @Override
154
                         globalConfig,
126
                         globalConfig,
155
                         quitWorker,
127
                         quitWorker,
156
                         new IconManager(globalConfig, urlBuilder),
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
     @Provides
135
     @Provides
173
     @Singleton
136
     @Singleton
174
     public URLHandler getURLHandler(
137
     public URLHandler getURLHandler(

+ 16
- 15
src/com/dmdirc/addons/windowflashing/WindowFlashingManager.java Voir le fichier

23
 package com.dmdirc.addons.windowflashing;
23
 package com.dmdirc.addons.windowflashing;
24
 
24
 
25
 import com.dmdirc.ClientModule.GlobalConfig;
25
 import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.actions.CoreActionType;
27
 import com.dmdirc.addons.ui_swing.MainFrame;
26
 import com.dmdirc.addons.ui_swing.MainFrame;
28
 import com.dmdirc.config.ConfigBinder;
27
 import com.dmdirc.config.ConfigBinder;
29
 import com.dmdirc.config.ConfigBinding;
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
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
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
 import javax.inject.Inject;
35
 import javax.inject.Inject;
36
 
36
 
37
 import com.sun.jna.Native;
37
 import com.sun.jna.Native;
41
 import com.sun.jna.platform.win32.WinDef;
41
 import com.sun.jna.platform.win32.WinDef;
42
 import com.sun.jna.platform.win32.WinUser;
42
 import com.sun.jna.platform.win32.WinUser;
43
 
43
 
44
-public class WindowFlashingManager implements ActionListener {
44
+public class WindowFlashingManager {
45
 
45
 
46
     /** Swing main frame. */
46
     /** Swing main frame. */
47
     private final MainFrame mainFrame;
47
     private final MainFrame mainFrame;
48
-    /** Action controller. */
49
-    private final ActionController actionController;
48
+    /** Event bus. */
49
+    private final EventBus eventBus;
50
     /** Config binder. */
50
     /** Config binder. */
51
     private final ConfigBinder binder;
51
     private final ConfigBinder binder;
52
     /** Cached blink rate setting. */
52
     /** Cached blink rate setting. */
67
     private User32 user32;
67
     private User32 user32;
68
 
68
 
69
     @Inject
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
         this.mainFrame = mainFrame;
74
         this.mainFrame = mainFrame;
73
-        this.actionController = actionController;
75
+        this.eventBus = eventBus;
74
         binder = config.getBinder();
76
         binder = config.getBinder();
75
     }
77
     }
76
 
78
 
77
     public void onLoad() {
79
     public void onLoad() {
78
         user32 = (User32) Native.loadLibrary("user32", User32.class);
80
         user32 = (User32) Native.loadLibrary("user32", User32.class);
79
         binder.bind(this, WindowFlashing.class);
81
         binder.bind(this, WindowFlashing.class);
80
-        actionController.registerListener(this, CoreActionType.CLIENT_FOCUS_GAINED);
82
+        eventBus.register(this);
81
     }
83
     }
82
 
84
 
83
     public void onUnload() {
85
     public void onUnload() {
84
-        actionController.unregisterListener(this);
86
+        eventBus.unregister(this);
85
         binder.unbind(this);
87
         binder.unbind(this);
86
         user32 = null;
88
         user32 = null;
87
         NativeLibrary.getInstance("user32").dispose();
89
         NativeLibrary.getInstance("user32").dispose();
155
         return returnValue;
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
         if (mainFrame != null) {
162
         if (mainFrame != null) {
162
             user32.FlashWindowEx(stopFlashObject());
163
             user32.FlashWindowEx(stopFlashObject());
163
         }
164
         }

Chargement…
Annuler
Enregistrer