Browse Source

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 years ago
parent
commit
30ec4be44f

+ 4
- 6
src/com/dmdirc/Main.java View File

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

+ 30
- 0
src/com/dmdirc/events/FeedbackNagEvent.java View File

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 View File

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 View File

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 View File

22
 
22
 
23
 package com.dmdirc.interfaces.ui;
23
 package com.dmdirc.interfaces.ui;
24
 
24
 
25
-
26
-import java.net.URI;
27
-
28
 /**
25
 /**
29
  * Defines the methods that should be implemented by UI controllers. Controllers handle the various
26
  * Defines the methods that should be implemented by UI controllers. Controllers handle the various
30
  * aspects of a UI implementation.
27
  * aspects of a UI implementation.
31
  */
28
  */
32
 public interface UIController {
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 View File

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

Loading…
Cancel
Save