Browse Source

DI the OS X integration plugin.

Change-Id: I090b16cd0c2f72bda1a90d22d24a584b513a71bf
Reviewed-on: http://gerrit.dmdirc.com/3217
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 years ago
parent
commit
203f3a186e

+ 3
- 0
src/com/dmdirc/addons/osx_integration/DockBounceCommand.java View File

@@ -31,6 +31,8 @@ import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
32 32
 import com.dmdirc.interfaces.CommandController;
33 33
 
34
+import javax.inject.Inject;
35
+
34 36
 /**
35 37
  * A command to bounce the icon in the OSX dock.
36 38
  */
@@ -54,6 +56,7 @@ public class DockBounceCommand extends Command {
54 56
      * @param controller The controller to use for command information.
55 57
      * @param apple      The UI wrapper for Apple-specific things
56 58
      */
59
+    @Inject
57 60
     public DockBounceCommand(final CommandController controller, final Apple apple) {
58 61
         super(controller);
59 62
         this.apple = apple;

+ 40
- 0
src/com/dmdirc/addons/osx_integration/OsxIntegrationModule.java View File

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.osx_integration;
24
+
25
+import com.dmdirc.addons.ui_swing.Apple;
26
+import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.injection.SwingModule;
28
+
29
+import dagger.Module;
30
+import dagger.Provides;
31
+
32
+@Module(injects = DockBounceCommand.class, addsTo = SwingModule.class)
33
+public class OsxIntegrationModule {
34
+
35
+    @Provides
36
+    public Apple getApple(final SwingController controller) {
37
+        return controller.getApple();
38
+    }
39
+
40
+}

+ 8
- 13
src/com/dmdirc/addons/osx_integration/OsxIntegrationPlugin.java View File

@@ -22,26 +22,21 @@
22 22
 
23 23
 package com.dmdirc.addons.osx_integration;
24 24
 
25
-import com.dmdirc.addons.ui_swing.SwingController;
26
-import com.dmdirc.interfaces.CommandController;
25
+import com.dmdirc.plugins.PluginInfo;
27 26
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
28 27
 
28
+import dagger.ObjectGraph;
29
+
29 30
 /**
30 31
  * A plugin which provides extra commands that integrate with the OS X environment.
31 32
  */
32 33
 public class OsxIntegrationPlugin extends BaseCommandPlugin {
33 34
 
34
-    /**
35
-     * Creates an instance of {@link OsxIntegrationPlugin}.
36
-     *
37
-     * @param controller        The Swing UI which runs on the OS X environment
38
-     * @param commandController Command controller to register commands
39
-     */
40
-    public OsxIntegrationPlugin(final SwingController controller,
41
-            final CommandController commandController) {
42
-        super(commandController);
43
-        registerCommand(new DockBounceCommand(commandController, controller.getApple()),
44
-                DockBounceCommand.INFO);
35
+    @Override
36
+    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
37
+        super.load(pluginInfo, graph);
38
+        setObjectGraph(graph.plus(new OsxIntegrationModule()));
39
+        registerCommand(DockBounceCommand.class, DockBounceCommand.INFO);
45 40
     }
46 41
 
47 42
 }

Loading…
Cancel
Save