Parcourir la source

Add some more events

Change-Id: Ib227c72d5077d09487a771ffd9125d2fae021ac1
Reviewed-on: http://gerrit.dmdirc.com/3268
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith il y a 10 ans
Parent
révision
7b78512926

+ 2
- 0
src/com/dmdirc/actions/CoreActionType.java Voir le fichier

@@ -71,8 +71,10 @@ public enum CoreActionType implements ActionType {
71 71
     @Deprecated
72 72
     CLIENT_LINE_ADDED(ClientEvents.WINDOW_EVENT_WITH_MESSAGE, "Line added to a window"),
73 73
     /** Popup generated. */
74
+    @Deprecated
74 75
     CLIENT_POPUP_GENERATED(ClientEvents.POPUP_EVENT, "Popup menu generated"),
75 76
     /** Prefs dialog opened. */
77
+    @Deprecated
76 78
     CLIENT_PREFS_OPENED(ClientEvents.CLIENT_EVENT_WITH_PREFS, "Preferences dialog opened"),
77 79
     /** Context-specific prefs requested. */
78 80
     CLIENT_PREFS_REQUESTED(ClientEvents.CLIENT_EVENT_WITH_PREFS_CAT, "Preferences requested"),

+ 10
- 7
src/com/dmdirc/commandparser/PopupManager.java Voir le fichier

@@ -22,11 +22,12 @@
22 22
 
23 23
 package com.dmdirc.commandparser;
24 24
 
25
-import com.dmdirc.actions.ActionManager;
26
-import com.dmdirc.actions.CoreActionType;
25
+import com.dmdirc.events.ClientPopupGeneratedEvent;
27 26
 import com.dmdirc.interfaces.CommandController;
28 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 28
 
29
+import com.google.common.eventbus.EventBus;
30
+
30 31
 import javax.inject.Inject;
31 32
 
32 33
 /**
@@ -36,15 +37,19 @@ public class PopupManager {
36 37
 
37 38
     /** The command controller to use for items. */
38 39
     private final CommandController commandController;
40
+    /** The bus to despatch events on. */
41
+    private final EventBus eventBus;
39 42
 
40 43
     /**
41 44
      * Creates a new instance of PopupManager.
42 45
      *
43 46
      * @param commandController The controller to use for commands.
47
+     * @param eventBus          The bus to despatch events on.
44 48
      */
45 49
     @Inject
46
-    public PopupManager(final CommandController commandController) {
50
+    public PopupManager(final CommandController commandController, final EventBus eventBus) {
47 51
         this.commandController = commandController;
52
+        this.eventBus = eventBus;
48 53
     }
49 54
 
50 55
     /**
@@ -59,9 +64,7 @@ public class PopupManager {
59 64
     public PopupMenu getMenu(final PopupType menuType, final AggregateConfigProvider configManager) {
60 65
         final PopupMenu menu = getMenu(menuType.toString(), menuType, configManager);
61 66
 
62
-        ActionManager.getActionManager().triggerEvent(
63
-                CoreActionType.CLIENT_POPUP_GENERATED, null, menuType, menu,
64
-                configManager);
67
+        eventBus.post(new ClientPopupGeneratedEvent(menuType, menu, configManager));
65 68
 
66 69
         return menu;
67 70
     }
@@ -119,7 +122,7 @@ public class PopupManager {
119 122
             if (command.length() > 0 && command.charAt(0) == '<') {
120 123
                 res = new PopupMenuItem(commandController,
121 124
                         name, getMenu(command.substring(1),
122
-                        type, configManager));
125
+                                type, configManager));
123 126
             } else {
124 127
                 res = new PopupMenuItem(commandController,
125 128
                         name, type.getArity(), command);

+ 59
- 0
src/com/dmdirc/events/ClientPopupGeneratedEvent.java Voir le fichier

@@ -0,0 +1,59 @@
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 com.dmdirc.commandparser.PopupMenu;
26
+import com.dmdirc.commandparser.PopupType;
27
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
+
29
+/**
30
+ * Raised when a popup is being generated.
31
+ */
32
+public class ClientPopupGeneratedEvent extends DMDircEvent {
33
+
34
+    private final PopupType type;
35
+    private final PopupMenu menu;
36
+    private final AggregateConfigProvider config;
37
+
38
+    public ClientPopupGeneratedEvent(
39
+            final PopupType type,
40
+            final PopupMenu menu,
41
+            final AggregateConfigProvider config) {
42
+        this.type = type;
43
+        this.menu = menu;
44
+        this.config = config;
45
+    }
46
+
47
+    public PopupType getType() {
48
+        return type;
49
+    }
50
+
51
+    public PopupMenu getMenu() {
52
+        return menu;
53
+    }
54
+
55
+    public AggregateConfigProvider getConfig() {
56
+        return config;
57
+    }
58
+
59
+}

+ 42
- 0
src/com/dmdirc/events/ClientPrefsOpenedEvent.java Voir le fichier

@@ -0,0 +1,42 @@
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 com.dmdirc.config.prefs.PreferencesDialogModel;
26
+
27
+/**
28
+ * Raised when the preferences dialog is opened.
29
+ */
30
+public class ClientPrefsOpenedEvent extends DMDircEvent {
31
+
32
+    private final PreferencesDialogModel model;
33
+
34
+    public ClientPrefsOpenedEvent(final PreferencesDialogModel model) {
35
+        this.model = model;
36
+    }
37
+
38
+    public PreferencesDialogModel getModel() {
39
+        return model;
40
+    }
41
+
42
+}

Chargement…
Annuler
Enregistrer