瀏覽代碼

Remove deprecations from the OSD plugin.

Change-Id: I8a3c3d0ae68a7319655729e54f521982af50fe96
Reviewed-on: http://gerrit.dmdirc.com/3191
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 年之前
父節點
當前提交
6368650310

+ 12
- 12
src/com/dmdirc/addons/osd/OsdManager.java 查看文件

@@ -25,6 +25,7 @@ package com.dmdirc.addons.osd;
25 25
 import com.dmdirc.addons.ui_swing.MainFrame;
26 26
 import com.dmdirc.addons.ui_swing.UIUtilities;
27 27
 import com.dmdirc.interfaces.config.IdentityController;
28
+import com.dmdirc.plugins.PluginInfo;
28 29
 import com.dmdirc.ui.messages.ColourManager;
29 30
 
30 31
 import java.util.ArrayList;
@@ -35,8 +36,6 @@ import java.util.concurrent.Callable;
35 36
 
36 37
 /**
37 38
  * Class to manage OSD Windows.
38
- *
39
- * @since 0.6.3
40 39
  */
41 40
 public class OsdManager {
42 41
 
@@ -52,13 +51,17 @@ public class OsdManager {
52 51
     private final List<OsdWindow> windowList = new ArrayList<>();
53 52
     /** List of messages to be queued. */
54 53
     private final Queue<QueuedMessage> windowQueue = new LinkedList<>();
54
+    /** This plugin's settings domain. */
55
+    private final String domain;
55 56
 
56 57
     public OsdManager(final MainFrame mainFrame, final IdentityController identityController,
57
-            final OsdPlugin plugin, final ColourManager colourManager) {
58
+            final OsdPlugin plugin, final ColourManager colourManager,
59
+            final PluginInfo pluginInfo) {
58 60
         this.mainFrame = mainFrame;
59 61
         this.identityController = identityController;
60 62
         this.plugin = plugin;
61 63
         this.colourManager = colourManager;
64
+        this.domain = pluginInfo.getDomain();
62 65
     }
63 66
 
64 67
     /**
@@ -77,7 +80,7 @@ public class OsdManager {
77 80
      */
78 81
     private synchronized void displayWindows() {
79 82
         final Integer maxWindows = identityController.getGlobalConfiguration()
80
-                .getOptionInt(plugin.getDomain(), "maxWindows", false);
83
+                .getOptionInt(domain, "maxWindows", false);
81 84
 
82 85
         QueuedMessage nextItem;
83 86
 
@@ -100,10 +103,9 @@ public class OsdManager {
100 103
      */
101 104
     private synchronized void displayWindow(final int timeout, final String message) {
102 105
         final OsdPolicy policy = OsdPolicy.valueOf(identityController.getGlobalConfiguration()
103
-                .getOption(plugin.getDomain(), "newbehaviour")
104
-                .toUpperCase());
106
+                .getOption(domain, "newbehaviour").toUpperCase());
105 107
         final int startY = identityController.getGlobalConfiguration()
106
-                .getOptionInt(plugin.getDomain(), "locationY");
108
+                .getOptionInt(domain, "locationY");
107 109
 
108 110
         windowList.add(UIUtilities.invokeAndWait(
109 111
                 new Callable<OsdWindow>() {
@@ -112,11 +114,10 @@ public class OsdManager {
112 114
             public OsdWindow call() {
113 115
                 return new OsdWindow(
114 116
                         mainFrame,
115
-                        identityController, plugin, OsdManager.this, colourManager,
117
+                        identityController, OsdManager.this, colourManager,
116 118
                         timeout, message, false,
117 119
                         identityController.getGlobalConfiguration().getOptionInt(
118
-                        plugin.getDomain(), "locationX"), policy.getYPosition(
119
-                        OsdManager.this, startY));
120
+                        domain, "locationX"), policy.getYPosition(OsdManager.this, startY), domain);
120 121
             }
121 122
         }));
122 123
     }
@@ -129,8 +130,7 @@ public class OsdManager {
129 130
     public synchronized void closeWindow(final OsdWindow window) {
130 131
         final OsdPolicy policy = OsdPolicy.valueOf(
131 132
                 identityController.getGlobalConfiguration()
132
-                .getOption(plugin.getDomain(), "newbehaviour")
133
-                .toUpperCase());
133
+                .getOption(domain, "newbehaviour").toUpperCase());
134 134
 
135 135
         int oldY = window.getDesiredY();
136 136
         final int closedIndex = windowList.indexOf(window);

+ 18
- 20
src/com/dmdirc/addons/osd/OsdPlugin.java 查看文件

@@ -53,7 +53,7 @@ public class OsdPlugin extends BaseCommandPlugin implements
53 53
     /** Config OSD Window. */
54 54
     private OsdWindow osdWindow;
55 55
     /** The OSD Manager that this plugin is using. */
56
-    private OsdManager osdManager;
56
+    private final OsdManager osdManager;
57 57
     /** X-axis position of OSD. */
58 58
     private int x;
59 59
     /** Y-axis potion of OSD. */
@@ -73,6 +73,8 @@ public class OsdPlugin extends BaseCommandPlugin implements
73 73
     private final ColourManager colourManager;
74 74
     /** The window that the OSDs will be associated with. */
75 75
     private final MainFrame mainFrame;
76
+    /** This plugin's settings domain. */
77
+    private final String domain;
76 78
 
77 79
     /**
78 80
      * Creates a new instance of this plugin.
@@ -93,46 +95,46 @@ public class OsdPlugin extends BaseCommandPlugin implements
93 95
         this.identityController = identityController;
94 96
         this.colourManager = colourManager;
95 97
         this.mainFrame = swingController.getMainFrame();
96
-        osdManager = new OsdManager(mainFrame, identityController, this, colourManager);
98
+        this.domain = pluginInfo.getDomain();
99
+        osdManager = new OsdManager(mainFrame, identityController, this, colourManager, pluginInfo);
97 100
         registerCommand(new OsdCommand(commandController, osdManager), OsdCommand.INFO);
98 101
     }
99 102
 
100
-    /** {@inheritDoc} */
101 103
     @Override
102 104
     public void showConfig(final PreferencesDialogModel manager) {
103 105
         x = identityController.getGlobalConfiguration()
104
-                .getOptionInt(getDomain(), "locationX");
106
+                .getOptionInt(domain, "locationX");
105 107
         y = identityController.getGlobalConfiguration()
106
-                .getOptionInt(getDomain(), "locationY");
108
+                .getOptionInt(domain, "locationY");
107 109
 
108 110
         final PreferencesCategory category = new PluginPreferencesCategory(
109 111
                 pluginInfo, "OSD",
110 112
                 "General configuration for OSD plugin.", "category-osd");
111 113
 
112 114
         fontSizeSetting = new PreferencesSetting(PreferencesType.INTEGER,
113
-                getDomain(), "fontSize", "Font size", "Changes the font " + "size of the OSD",
115
+                domain, "fontSize", "Font size", "Changes the font " + "size of the OSD",
114 116
                 manager.getConfigManager(),
115 117
                 manager.getIdentity()).registerChangeListener(this);
116 118
         backgroundSetting = new PreferencesSetting(PreferencesType.COLOUR,
117
-                getDomain(), "bgcolour", "Background colour",
119
+                domain, "bgcolour", "Background colour",
118 120
                 "Background colour for the OSD", manager.getConfigManager(),
119 121
                 manager.getIdentity()).registerChangeListener(this);
120 122
         foregroundSetting = new PreferencesSetting(PreferencesType.COLOUR,
121
-                getDomain(), "fgcolour", "Foreground colour",
123
+                domain, "fgcolour", "Foreground colour",
122 124
                 "Foreground colour for the OSD", manager.getConfigManager(),
123 125
                 manager.getIdentity()).registerChangeListener(this);
124 126
         widthSetting = new PreferencesSetting(PreferencesType.INTEGER,
125
-                getDomain(), "width", "OSD Width", "Width of the OSD Window",
127
+                domain, "width", "OSD Width", "Width of the OSD Window",
126 128
                 manager.getConfigManager(), manager.getIdentity())
127 129
                 .registerChangeListener(this);
128 130
         timeoutSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
129 131
                 new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
130
-                getDomain(), "timeout", "Timeout", "Length of time in "
132
+                domain, "timeout", "Timeout", "Length of time in "
131 133
                 + "seconds before the OSD window closes", manager.getConfigManager(),
132 134
                 manager.getIdentity());
133 135
         maxWindowsSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
134 136
                 new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
135
-                getDomain(), "maxWindows", "Maximum open windows",
137
+                domain, "maxWindows", "Maximum open windows",
136 138
                 "Maximum number of OSD windows that will be displayed at any given time",
137 139
                 manager.getConfigManager(), manager.getIdentity());
138 140
 
@@ -150,7 +152,7 @@ public class OsdPlugin extends BaseCommandPlugin implements
150 152
             posOptions.put(policy.name(), policy.getDescription());
151 153
         }
152 154
 
153
-        category.addSetting(new PreferencesSetting(getDomain(), "newbehaviour",
155
+        category.addSetting(new PreferencesSetting(domain, "newbehaviour",
154 156
                 "New window policy", "What to do when an OSD Window "
155 157
                 + "is opened when there are other, existing windows open",
156 158
                 posOptions, manager.getConfigManager(), manager.getIdentity()));
@@ -163,10 +165,8 @@ public class OsdPlugin extends BaseCommandPlugin implements
163 165
     /** {@inheritDoc} */
164 166
     @Override
165 167
     public void categorySelected(final PreferencesCategory category) {
166
-        osdWindow = new OsdWindow(
167
-                mainFrame,
168
-                identityController, this, osdManager, colourManager, -1,
169
-                "Please drag this OSD to position", true, x, y);
168
+        osdWindow = new OsdWindow(mainFrame, identityController, osdManager, colourManager,
169
+                -1, "Please drag this OSD to position", true, x, y, domain);
170 170
         osdWindow.setBackgroundColour(backgroundSetting.getValue());
171 171
         osdWindow.setForegroundColour(foregroundSetting.getValue());
172 172
         osdWindow.setFontSize(Integer.parseInt(fontSizeSetting.getValue()));
@@ -185,10 +185,8 @@ public class OsdPlugin extends BaseCommandPlugin implements
185 185
     /** {@inheritDoc} */
186 186
     @Override
187 187
     public void save() {
188
-        identityController.getUserSettings()
189
-                .setOption(getDomain(), "locationX", x);
190
-        identityController.getUserSettings()
191
-                .setOption(getDomain(), "locationY", y);
188
+        identityController.getUserSettings().setOption(domain, "locationX", x);
189
+        identityController.getUserSettings().setOption(domain, "locationY", y);
192 190
     }
193 191
 
194 192
     /** {@inheritDoc} */

+ 0
- 5
src/com/dmdirc/addons/osd/OsdPolicy.java 查看文件

@@ -24,9 +24,6 @@ package com.dmdirc.addons.osd;
24 24
 
25 25
 /**
26 26
  * Enumerates OSD Policies.
27
- *
28
- * @author simon
29
- * @since 0.6.3
30 27
  */
31 28
 public enum OsdPolicy {
32 29
 
@@ -117,8 +114,6 @@ public enum OsdPolicy {
117 114
         return changesPosition;
118 115
     }
119 116
 
120
-    ;
121
-
122 117
     /**
123 118
      * Return a description of what each policy does.
124 119
      *

+ 14
- 25
src/com/dmdirc/addons/osd/OsdWindow.java 查看文件

@@ -48,17 +48,10 @@ import net.miginfocom.swing.MigLayout;
48 48
 /**
49 49
  * The OSD Window is an always-on-top window designed to convey information about events to the
50 50
  * user.
51
- *
52
- * @author chris
53 51
  */
54
-public class OsdWindow extends JDialog implements MouseListener,
55
-        MouseMotionListener {
52
+public class OsdWindow extends JDialog implements MouseListener, MouseMotionListener {
56 53
 
57
-    /**
58
-     * A version number for this class. It should be changed whenever the class structure is changed
59
-     * (or anything else that would prevent serialized objects being unserialized with the new
60
-     * class).
61
-     */
54
+    /** A version number for this class. */
62 55
     private static final long serialVersionUID = 2;
63 56
     /** The OSD Manager that owns this window. */
64 57
     private final OsdManager osdManager;
@@ -91,15 +84,15 @@ public class OsdWindow extends JDialog implements MouseListener,
91 84
      *                           to be moved)
92 85
      * @param x                  The x-axis position for the OSD Window
93 86
      * @param y                  The y-axis position for the OSD window
94
-     * @param plugin             Parent OSD Plugin
95 87
      * @param osdManager         The manager that owns this OSD Window
88
+     * @param domain             This plugin's settings domain
96 89
      */
97 90
     public OsdWindow(
98 91
             final MainFrame mainFrame,
99
-            final IdentityController identityController, final OsdPlugin plugin,
92
+            final IdentityController identityController,
100 93
             final OsdManager osdManager, final ColourManager colourManager,
101 94
             final int timeout, final String text, final boolean config, final int x,
102
-            final int y) {
95
+            final int y, final String domain) {
103 96
         super(mainFrame, false);
104 97
 
105 98
         this.colourManager = colourManager;
@@ -107,8 +100,8 @@ public class OsdWindow extends JDialog implements MouseListener,
107 100
         this.osdManager = osdManager;
108 101
 
109 102
         if (timeout < 0) {
110
-            this.timeout = identityController.getGlobalConfiguration().getOptionInt(
111
-                    osdManager.getPlugin().getDomain(), "timeout", false);
103
+            this.timeout = identityController.getGlobalConfiguration().getOptionInt(domain,
104
+            "timeout", false);
112 105
         } else {
113 106
             this.timeout = timeout;
114 107
         }
@@ -128,23 +121,19 @@ public class OsdWindow extends JDialog implements MouseListener,
128 121
         panel = new JPanel();
129 122
         panel.setBorder(new LineBorder(Color.BLACK));
130 123
         panel.setBackground(UIUtilities.convertColour(
131
-                colourManager.getColourFromString(
132
-                identityController.getGlobalConfiguration()
133
-                .getOptionString(plugin.getDomain(), "bgcolour"), null)));
124
+                colourManager.getColourFromString(identityController.getGlobalConfiguration()
125
+                        .getOptionString(domain, "bgcolour"), null)));
134 126
 
135
-        final int width = identityController.getGlobalConfiguration()
136
-                .getOptionInt(plugin.getDomain(), "width");
127
+        final int width = identityController.getGlobalConfiguration().getOptionInt(domain, "width");
137 128
         setContentPane(panel);
138 129
         setLayout(new MigLayout("wmin " + width + ", wmax " + width + ", ins rel, fill"));
139 130
 
140 131
         label = new JLabel(text);
141 132
         label.setForeground(UIUtilities.convertColour(
142
-                colourManager.getColourFromString(
143
-                identityController.getGlobalConfiguration()
144
-                .getOptionString(plugin.getDomain(), "fgcolour"), null)));
145
-        label.setFont(label.getFont().deriveFont(
146
-                (float) identityController
147
-                .getGlobalConfiguration().getOptionInt(plugin.getDomain(), "fontSize")));
133
+                colourManager.getColourFromString(identityController.getGlobalConfiguration()
134
+                        .getOptionString(domain, "fgcolour"), null)));
135
+        label.setFont(label.getFont().deriveFont((float) identityController
136
+                .getGlobalConfiguration().getOptionInt(domain, "fontSize")));
148 137
         label.setHorizontalAlignment(SwingConstants.CENTER);
149 138
         add(label, "alignx center, hmin " + label.getFont().getSize());
150 139
 

Loading…
取消
儲存