Просмотр исходного кода

Inject Apple into things

Change-Id: Ie1a76a811cfbdc03422c45c81c466cc46cfa19ce
Reviewed-on: http://gerrit.dmdirc.com/3243
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/43/3243/5
Greg Holmes 10 лет назад
Родитель
Сommit
b68d6331eb

+ 0
- 8
src/com/dmdirc/addons/osx_integration/OsxIntegrationModule.java Просмотреть файл

@@ -22,19 +22,11 @@
22 22
 
23 23
 package com.dmdirc.addons.osx_integration;
24 24
 
25
-import com.dmdirc.addons.ui_swing.Apple;
26
-import com.dmdirc.addons.ui_swing.SwingController;
27 25
 import com.dmdirc.addons.ui_swing.injection.SwingModule;
28 26
 
29 27
 import dagger.Module;
30
-import dagger.Provides;
31 28
 
32 29
 @Module(injects = DockBounceCommand.class, addsTo = SwingModule.class)
33 30
 public class OsxIntegrationModule {
34 31
 
35
-    @Provides
36
-    public Apple getApple(final SwingController controller) {
37
-        return controller.getApple();
38
-    }
39
-
40 32
 }

+ 6
- 1
src/com/dmdirc/addons/ui_swing/Apple.java Просмотреть файл

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25
+import com.dmdirc.ClientModule.GlobalConfig;
25 26
 import com.dmdirc.ServerManager;
26 27
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
27 28
 import com.dmdirc.events.ClientOpenedEvent;
@@ -46,6 +47,8 @@ import java.util.ArrayList;
46 47
 import java.util.EventObject;
47 48
 import java.util.List;
48 49
 
50
+import javax.inject.Inject;
51
+import javax.inject.Singleton;
49 52
 import javax.swing.JMenu;
50 53
 import javax.swing.JMenuBar;
51 54
 import javax.swing.JMenuItem;
@@ -54,6 +57,7 @@ import javax.swing.UIManager;
54 57
 /**
55 58
  * Integrate DMDirc with OS X better.
56 59
  */
60
+@Singleton
57 61
 public class Apple implements InvocationHandler {
58 62
 
59 63
     /** Store any addresses that are opened before CLIENT_OPENED. */
@@ -81,8 +85,9 @@ public class Apple implements InvocationHandler {
81 85
      * @param serverManager The server manager to use to connect to URLs.
82 86
      * @param eventBus      The bus to listen for events on.
83 87
      */
88
+    @Inject
84 89
     public Apple(
85
-            final AggregateConfigProvider configManager,
90
+            @GlobalConfig final AggregateConfigProvider configManager,
86 91
             final ServerManager serverManager,
87 92
             final EventBus eventBus) {
88 93
         this.configManager = configManager;

+ 12
- 4
src/com/dmdirc/addons/ui_swing/MainFrame.java Просмотреть файл

@@ -83,6 +83,8 @@ public class MainFrame extends JFrame implements WindowListener,
83 83
     private static final long serialVersionUID = 9;
84 84
     /** Focus queue. */
85 85
     private final QueuedLinkedHashSet<TextFrame> focusOrder;
86
+    /** Apple instance. */
87
+    private final Apple apple;
86 88
     /** Swing Controller. */
87 89
     private final SwingController controller;
88 90
     /** Controller to use to end the program. */
@@ -130,6 +132,7 @@ public class MainFrame extends JFrame implements WindowListener,
130 132
      * Creates new form MainFrame.
131 133
      *
132 134
      * @param controller          Swing controller
135
+     * @param apple               Apple instance
133 136
      * @param windowFactory       The window factory to use to create and listen for windows.
134 137
      * @param lifecycleController Controller to use to end the application.
135 138
      * @param globalConfig        The config to read settings from.
@@ -138,6 +141,7 @@ public class MainFrame extends JFrame implements WindowListener,
138 141
      * @param windowManager       Window management
139 142
      */
140 143
     public MainFrame(
144
+            final Apple apple,
141 145
             final SwingController controller,
142 146
             final SwingWindowFactory windowFactory,
143 147
             final LifecycleController lifecycleController,
@@ -147,6 +151,7 @@ public class MainFrame extends JFrame implements WindowListener,
147 151
             final WindowManager windowManager) {
148 152
         super();
149 153
 
154
+        this.apple = apple;
150 155
         this.controller = controller;
151 156
         this.windowFactory = windowFactory;
152 157
         this.lifecycleController = lifecycleController;
@@ -389,7 +394,8 @@ public class MainFrame extends JFrame implements WindowListener,
389 394
     /**
390 395
      * Sets the menu bar that this frame will use.
391 396
      *
392
-     * <p>Must be called prior to {@link #initComponents()}.
397
+     * <p>
398
+     * Must be called prior to {@link #initComponents()}.
393 399
      *
394 400
      * @param menuBar The menu bar to use.
395 401
      */
@@ -398,7 +404,7 @@ public class MainFrame extends JFrame implements WindowListener,
398 404
             /** {@inheritDoc} */
399 405
             @Override
400 406
             public void run() {
401
-                controller.getApple().setMenuBar(menuBar);
407
+                apple.setMenuBar(menuBar);
402 408
                 setJMenuBar(menuBar);
403 409
             }
404 410
         });
@@ -407,7 +413,8 @@ public class MainFrame extends JFrame implements WindowListener,
407 413
     /**
408 414
      * Sets the window manager that this frame will use.
409 415
      *
410
-     * <p>Must be called prior to {@link #initComponents()}.
416
+     * <p>
417
+     * Must be called prior to {@link #initComponents()}.
411 418
      *
412 419
      * @param windowManager The window manager to use.
413 420
      */
@@ -418,7 +425,8 @@ public class MainFrame extends JFrame implements WindowListener,
418 425
     /**
419 426
      * Sets the status bar that will be used.
420 427
      *
421
-     * <p>Must be called prior to {@link #initComponents()}.
428
+     * <p>
429
+     * Must be called prior to {@link #initComponents()}.
422 430
      *
423 431
      * @param statusBar The status bar to be used.
424 432
      */

+ 0
- 5
src/com/dmdirc/addons/ui_swing/SwingController.java Просмотреть файл

@@ -155,11 +155,6 @@ public class SwingController extends BaseCommandPlugin implements UIController {
155 155
         return pluginManager;
156 156
     }
157 157
 
158
-    @Deprecated
159
-    public Apple getApple() {
160
-        return apple;
161
-    }
162
-
163 158
     @Deprecated
164 159
     public ColourManager getColourManager() {
165 160
         return colourManager;

+ 5
- 5
src/com/dmdirc/addons/ui_swing/components/frames/AppleJFrame.java Просмотреть файл

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
+import com.dmdirc.addons.ui_swing.Apple;
25 26
 import com.dmdirc.addons.ui_swing.MainFrame;
26
-import com.dmdirc.addons.ui_swing.SwingController;
27 27
 
28 28
 import javax.swing.JFrame;
29 29
 
@@ -38,14 +38,14 @@ public class AppleJFrame extends JFrame {
38 38
     /**
39 39
      * Create a new Apple JFrame
40 40
      *
41
+     * @param apple        Apple instance
41 42
      * @param parentWindow Main Window
42
-     * @param controller   Parent swing controller
43 43
      */
44 44
     public AppleJFrame(
45
-            final MainFrame parentWindow,
46
-            final SwingController controller) {
45
+            final Apple apple,
46
+            final MainFrame parentWindow) {
47 47
         super();
48
-        controller.getApple().setMenuBar(parentWindow.getJMenuBar());
48
+        apple.setMenuBar(parentWindow.getJMenuBar());
49 49
         setJMenuBar(parentWindow.getJMenuBar());
50 50
     }
51 51
 

+ 3
- 2
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java Просмотреть файл

@@ -111,6 +111,7 @@ public class ActionsManagerDialog extends StandardDialog implements
111 111
     /**
112 112
      * Creates a new instance of ActionsManagerDialog.
113 113
      *
114
+     * @param apple             Apple instance
114 115
      * @param parentWindow      Parent window
115 116
      * @param controller        Parent controller
116 117
      * @param config            Config to save dialog state to
@@ -120,14 +121,14 @@ public class ActionsManagerDialog extends StandardDialog implements
120 121
      */
121 122
     @Inject
122 123
     public ActionsManagerDialog(
124
+            final Apple apple,
123 125
             final MainFrame parentWindow,
124 126
             final SwingController controller,
125 127
             @UserConfig final ConfigProvider config,
126 128
             final PrefsComponentFactory compFactory,
127 129
             @GlobalConfig final IconManager iconManager,
128 130
             final ActionsGroupPanelFactory groupPanelFactory) {
129
-        super(Apple.isAppleUI()
130
-                ? new AppleJFrame(parentWindow, controller)
131
+        super(Apple.isAppleUI() ? new AppleJFrame(apple, parentWindow)
131 132
                 : parentWindow, ModalityType.MODELESS);
132 133
         this.config = config;
133 134
         this.compFactory = compFactory;

+ 5
- 1
src/com/dmdirc/addons/ui_swing/injection/SwingModule.java Просмотреть файл

@@ -27,6 +27,7 @@ import com.dmdirc.ClientModule.GlobalConfig;
27 27
 import com.dmdirc.ClientModule.UserConfig;
28 28
 import com.dmdirc.ServerManager;
29 29
 import com.dmdirc.actions.ActionManager;
30
+import com.dmdirc.addons.ui_swing.Apple;
30 31
 import com.dmdirc.addons.ui_swing.MainFrame;
31 32
 import com.dmdirc.addons.ui_swing.QuitWorker;
32 33
 import com.dmdirc.addons.ui_swing.SwingController;
@@ -119,6 +120,7 @@ public class SwingModule {
119 120
     /**
120 121
      * Gets the main DMDirc window.
121 122
      *
123
+     * @param apple               Apple instance
122 124
      * @param swingController     The controller that will own the frame.
123 125
      * @param windowFactory       The window factory to use to create and listen for windows.
124 126
      * @param lifecycleController The controller to use to quit the application.
@@ -132,6 +134,7 @@ public class SwingModule {
132 134
     @Provides
133 135
     @Singleton
134 136
     public MainFrame getMainFrame(
137
+            final Apple apple,
135 138
             final SwingController swingController,
136 139
             final SwingWindowFactory windowFactory,
137 140
             final LifecycleController lifecycleController,
@@ -144,7 +147,8 @@ public class SwingModule {
144 147
             @Override
145 148
             public MainFrame call() {
146 149
                 return new MainFrame(
147
-                        swingController,
150
+                        apple,
151
+                        controller,
148 152
                         windowFactory,
149 153
                         lifecycleController,
150 154
                         globalConfig,

Загрузка…
Отмена
Сохранить