瀏覽代碼

Remove UI controller methods.

Depends-On: Ia1f3b158e993542b4a8aee58d343c0cf0c9e181f
Change-Id: Ie936046e8eb98a52a9dff498b4f471c6e19e5697
Reviewed-on: http://gerrit.dmdirc.com/3297
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Greg Holmes 10 年之前
父節點
當前提交
30ec4be44f

+ 4
- 6
src/com/dmdirc/Main.java 查看文件

@@ -29,6 +29,8 @@ import com.dmdirc.commandline.CommandLineParser;
29 29
 import com.dmdirc.commandparser.CommandManager;
30 30
 import com.dmdirc.events.ClientClosedEvent;
31 31
 import com.dmdirc.events.ClientOpenedEvent;
32
+import com.dmdirc.events.FeedbackNagEvent;
33
+import com.dmdirc.events.FirstRunEvent;
32 34
 import com.dmdirc.interfaces.CommandController.CommandDetails;
33 35
 import com.dmdirc.interfaces.config.IdentityController;
34 36
 import com.dmdirc.interfaces.ui.UIController;
@@ -252,17 +254,13 @@ public class Main {
252 254
     private void doFirstRun() {
253 255
         if (identityManager.getGlobalConfiguration().getOptionBool("general", "firstRun")) {
254 256
             identityManager.getUserSettings().setOption("general", "firstRun", "false");
255
-            for (UIController controller : CONTROLLERS) {
256
-                controller.showFirstRunWizard();
257
-            }
257
+            eventBus.post(new FirstRunEvent());
258 258
 
259 259
             new Timer().schedule(new TimerTask() {
260 260
 
261 261
                 @Override
262 262
                 public void run() {
263
-                    for (UIController controller : CONTROLLERS) {
264
-                        controller.showFeedbackNag();
265
-                    }
263
+                    eventBus.post(new FeedbackNagEvent());
266 264
                 }
267 265
             }, FEEDBACK_DELAY);
268 266
         }

+ 30
- 0
src/com/dmdirc/events/FeedbackNagEvent.java 查看文件

@@ -0,0 +1,30 @@
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.events;
24
+
25
+/**
26
+ * Fired when its time to nag for feedback.
27
+ */
28
+public class FeedbackNagEvent extends DMDircEvent {
29
+
30
+}

+ 41
- 0
src/com/dmdirc/events/FirstRunEvent.java 查看文件

@@ -0,0 +1,41 @@
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.events;
24
+
25
+/**
26
+ * Fired when the client is first run.  Handled should be checked and set appropriately, only core
27
+ * first run events should occur if unhandled.
28
+ */
29
+public class FirstRunEvent extends DMDircEvent {
30
+
31
+    private boolean handled;
32
+
33
+    public boolean isHandled() {
34
+        return handled;
35
+    }
36
+
37
+    public void setHandled(final boolean handled) {
38
+        this.handled = handled;
39
+    }
40
+
41
+}

+ 52
- 0
src/com/dmdirc/events/UnknownURLEvent.java 查看文件

@@ -0,0 +1,52 @@
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.events;
24
+
25
+import java.net.URI;
26
+
27
+/**
28
+ * Fired when the URL handler encounters an unknown URL protocol.  The handled boolean should be
29
+ * checked, if it is true the event should be disregarded.
30
+ */
31
+public class UnknownURLEvent extends DMDircEvent {
32
+
33
+    private boolean handled;
34
+    private final URI uri;
35
+
36
+    public UnknownURLEvent(final URI uri) {
37
+        this.uri = uri;
38
+    }
39
+
40
+    public void setHandled(final boolean handled) {
41
+        this.handled = handled;
42
+    }
43
+
44
+    public boolean isHandled() {
45
+        return handled;
46
+    }
47
+
48
+    public URI getURI() {
49
+        return uri;
50
+    }
51
+
52
+}

+ 0
- 20
src/com/dmdirc/interfaces/ui/UIController.java 查看文件

@@ -22,30 +22,10 @@
22 22
 
23 23
 package com.dmdirc.interfaces.ui;
24 24
 
25
-
26
-import java.net.URI;
27
-
28 25
 /**
29 26
  * Defines the methods that should be implemented by UI controllers. Controllers handle the various
30 27
  * aspects of a UI implementation.
31 28
  */
32 29
 public interface UIController {
33 30
 
34
-    /**
35
-     * Shows the first run wizard for the ui.
36
-     */
37
-    void showFirstRunWizard();
38
-
39
-    /**
40
-     * Shows the unknown URL protocol handling dialog for a URL.
41
-     *
42
-     * @param url full url
43
-     */
44
-    void showURLDialog(final URI url);
45
-
46
-    /**
47
-     * Show feedback nag.
48
-     */
49
-    void showFeedbackNag();
50
-
51 31
 }

+ 12
- 7
src/com/dmdirc/ui/core/util/URLHandler.java 查看文件

@@ -23,14 +23,16 @@
23 23
 package com.dmdirc.ui.core.util;
24 24
 
25 25
 import com.dmdirc.ServerManager;
26
+import com.dmdirc.events.UnknownURLEvent;
26 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
-import com.dmdirc.interfaces.ui.UIController;
28 28
 import com.dmdirc.logger.ErrorLevel;
29 29
 import com.dmdirc.logger.Logger;
30 30
 import com.dmdirc.ui.StatusMessage;
31 31
 import com.dmdirc.ui.core.components.StatusBarManager;
32 32
 import com.dmdirc.util.CommandUtils;
33 33
 
34
+import com.google.common.eventbus.EventBus;
35
+
34 36
 import java.awt.Desktop;
35 37
 import java.io.IOException;
36 38
 import java.net.URI;
@@ -38,13 +40,15 @@ import java.net.URISyntaxException;
38 40
 import java.net.URL;
39 41
 import java.util.Date;
40 42
 
43
+import javax.inject.Inject;
44
+
41 45
 /** Handles URLs. */
42 46
 public class URLHandler {
43 47
 
44 48
     /** The time a browser was last launched. */
45 49
     private static Date lastLaunch;
46
-    /** The UI Controller that owns this handler. */
47
-    private final UIController controller;
50
+    /** Event bus to fire unknown protocol errors on. */
51
+    private final EventBus eventBus;
48 52
     /** Config manager. */
49 53
     private final AggregateConfigProvider config;
50 54
     /** Server manager to use to connect to servers. */
@@ -57,17 +61,18 @@ public class URLHandler {
57 61
     /**
58 62
      * Instantiates a new URL Handler.
59 63
      *
60
-     * @param controller       The UI controller to show dialogs etc on
64
+     * @param eventBus         Event bus to fire unknown protocol errors on.
61 65
      * @param globalConfig     Config to retrieve settings from
62 66
      * @param serverManager    Server manager to connect to servers
63 67
      * @param statusBarManager Status bar manager used to show messages
64 68
      */
69
+    @Inject
65 70
     public URLHandler(
66
-            final UIController controller,
71
+            final EventBus eventBus,
67 72
             final AggregateConfigProvider globalConfig,
68 73
             final ServerManager serverManager,
69 74
             final StatusBarManager statusBarManager) {
70
-        this.controller = controller;
75
+        this.eventBus = eventBus;
71 76
         this.config = globalConfig;
72 77
         this.serverManager = serverManager;
73 78
         this.statusBarManager = statusBarManager;
@@ -159,7 +164,7 @@ public class URLHandler {
159 164
         }
160 165
 
161 166
         if (!config.hasOptionString("protocol", uri.getScheme().toLowerCase())) {
162
-            controller.showURLDialog(uri);
167
+            eventBus.post(new UnknownURLEvent(uri));
163 168
             return;
164 169
         }
165 170
 

Loading…
取消
儲存