Przeglądaj źródła

DI Conditional execute plugin.

Change-Id: I756b1d84dc4e134a1754967a7b3bbc0bd1e564fe
Reviewed-on: http://gerrit.dmdirc.com/3109
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 lat temu
rodzic
commit
e30ac75b13

+ 2
- 2
src/com/dmdirc/addons/calc/CalcModule.java Wyświetl plik

@@ -22,14 +22,14 @@
22 22
 
23 23
 package com.dmdirc.addons.calc;
24 24
 
25
-import com.dmdirc.addons.ui_swing.injection.SwingModule;
25
+import com.dmdirc.ClientModule;
26 26
 
27 27
 import dagger.Module;
28 28
 
29 29
 /**
30 30
  * DI Module for the calc plugin.
31 31
  */
32
-@Module(injects={CalcCommand.class}, addsTo = SwingModule.class)
32
+@Module(injects={CalcCommand.class}, addsTo = ClientModule.class)
33 33
 public class CalcModule {
34 34
 
35 35
 }

+ 3
- 0
src/com/dmdirc/addons/conditional_execute/ConditionalExecuteCommand.java Wyświetl plik

@@ -34,6 +34,8 @@ import com.dmdirc.interfaces.CommandController;
34 34
 import java.util.HashMap;
35 35
 import java.util.Map;
36 36
 
37
+import javax.inject.Inject;
38
+
37 39
 /**
38 40
  * The ConditionalExecute command allows the user to conditionally execute a
39 41
  * command based on external and pre-determined conditions.
@@ -52,6 +54,7 @@ public class ConditionalExecuteCommand extends Command {
52 54
      *
53 55
      * @param controller The controller to use for command information.
54 56
      */
57
+    @Inject
55 58
     public ConditionalExecuteCommand(final CommandController controller) {
56 59
         super(controller);
57 60
     }

+ 35
- 0
src/com/dmdirc/addons/conditional_execute/ConditionalExecuteModule.java Wyświetl plik

@@ -0,0 +1,35 @@
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.conditional_execute;
24
+
25
+import com.dmdirc.ClientModule;
26
+
27
+import dagger.Module;
28
+
29
+/**
30
+ * DI for the conditional execute plugin.
31
+ */
32
+@Module(injects={ConditionalExecuteCommand.class}, addsTo = ClientModule.class)
33
+public class ConditionalExecuteModule {
34
+
35
+}

+ 8
- 9
src/com/dmdirc/addons/conditional_execute/ConditionalExecutePlugin.java Wyświetl plik

@@ -22,22 +22,21 @@
22 22
 
23 23
 package com.dmdirc.addons.conditional_execute;
24 24
 
25
-import com.dmdirc.interfaces.CommandController;
25
+import com.dmdirc.plugins.PluginInfo;
26 26
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
27 27
 
28
+import dagger.ObjectGraph;
29
+
28 30
 /**
29 31
  * The ConditionalExecute plugin allows the user to run commands only if
30 32
  * external conditions have been met.
31 33
  */
32 34
 public final class ConditionalExecutePlugin extends BaseCommandPlugin {
33 35
 
34
-    /**
35
-     * Creates a new instance of this plugin.
36
-     *
37
-     * @param commandController Command controller to register commands
38
-     */
39
-    public ConditionalExecutePlugin(final CommandController commandController) {
40
-        super(commandController);
41
-        registerCommand(new ConditionalExecuteCommand(commandController), ConditionalExecuteCommand.INFO);
36
+    @Override
37
+    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
38
+        super.load(pluginInfo, graph);
39
+        setObjectGraph(graph.plus(new ConditionalExecuteModule()));
40
+        registerCommand(ConditionalExecuteCommand.class, ConditionalExecuteCommand.INFO);
42 41
     }
43 42
 }

Ładowanie…
Anuluj
Zapisz