Преглед на файлове

FrameContainers now manage ConfigManagers instead of requiring their descendents to implement a getConfigManager method

git-svn-id: http://svn.dmdirc.com/trunk@3739 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith преди 16 години
родител
ревизия
62e107af7a

+ 13
- 24
src/com/dmdirc/Channel.java Целия файл

@@ -76,9 +76,6 @@ public final class Channel extends MessageTarget
76 76
     /** The tabcompleter used for this channel. */
77 77
     private final TabCompleter tabCompleter;
78 78
 
79
-    /** The config manager for this channel. */
80
-    private final ConfigManager configManager;
81
-
82 79
     /** A list of previous topics we've seen. */
83 80
     private final RollingList<Topic> topics;
84 81
 
@@ -105,23 +102,21 @@ public final class Channel extends MessageTarget
105 102
      * this channel
106 103
      */
107 104
     public Channel(final Server newServer, final ChannelInfo newChannelInfo) {
108
-        super("channel");
105
+        super("channel", new ConfigManager(newServer.getIrcd(), newServer.getNetwork(),
106
+                newServer.getName(), newChannelInfo.getName()));
109 107
 
110 108
         channelInfo = newChannelInfo;
111 109
         server = newServer;
112 110
 
113
-        configManager = new ConfigManager(server.getIrcd(), server.getNetwork(),
114
-                server.getName(), channelInfo.getName());
115
-
116
-        configManager.addChangeListener("channel", this);
117
-        configManager.addChangeListener("ui", "shownickcoloursintext", this);
111
+        getConfigManager().addChangeListener("channel", this);
112
+        getConfigManager().addChangeListener("ui", "shownickcoloursintext", this);
118 113
 
119
-        topics = new RollingList<Topic>(configManager.getOptionInt("channel",
114
+        topics = new RollingList<Topic>(getConfigManager().getOptionInt("channel",
120 115
                 "topichistorysize", 10));
121 116
 
122
-        sendWho = configManager.getOptionBool("channel", "sendwho", false);
123
-        showModePrefix = configManager.getOptionBool("channel", "showmodeprefix", false);
124
-        showColours = configManager.getOptionBool("ui", "shownickcoloursintext", false);
117
+        sendWho = getConfigManager().getOptionBool("channel", "sendwho", false);
118
+        showModePrefix = getConfigManager().getOptionBool("channel", "showmodeprefix", false);
119
+        showColours = getConfigManager().getOptionBool("ui", "shownickcoloursintext", false);
125 120
 
126 121
         tabCompleter = new TabCompleter(server.getTabCompleter());
127 122
         tabCompleter.addEntries(TabCompletionType.COMMAND,
@@ -148,7 +143,7 @@ public final class Channel extends MessageTarget
148 143
      */
149 144
     private void registerCallbacks() {
150 145
         eventHandler.registerCallbacks();
151
-        configManager.migrate(server.getIrcd(), server.getNetwork(),
146
+        getConfigManager().migrate(server.getIrcd(), server.getNetwork(),
152 147
                 server.getName(), channelInfo.getName());
153 148
     }
154 149
 
@@ -159,12 +154,6 @@ public final class Channel extends MessageTarget
159 154
         window.open();
160 155
     }
161 156
 
162
-    /** {@inheritDoc} */
163
-    @Override
164
-    public ConfigManager getConfigManager() {
165
-        return configManager;
166
-    }
167
-
168 157
     /** {@inheritDoc} */
169 158
     @Override
170 159
     public void sendLine(final String line) {
@@ -362,7 +351,7 @@ public final class Channel extends MessageTarget
362 351
         }
363 352
 
364 353
         // 3: Trigger any actions neccessary
365
-        part(configManager.getOption("general", "partmessage"));
354
+        part(getConfigManager().getOption("general", "partmessage"));
366 355
 
367 356
         // 4: Trigger action for the window closing
368 357
         ActionManager.processEvent(CoreActionType.CHANNEL_CLOSED, null, this);
@@ -498,11 +487,11 @@ public final class Channel extends MessageTarget
498 487
     @Override
499 488
     public void configChanged(final String domain, final String key) {
500 489
         if ("sendwho".equals(key)) {
501
-            sendWho = configManager.getOptionBool("channel", "sendwho", false);
490
+            sendWho = getConfigManager().getOptionBool("channel", "sendwho", false);
502 491
         } else if ("showmodeprefix".equals(key)) {
503
-            showModePrefix = configManager.getOptionBool("channel", "showmodeprefix", false);
492
+            showModePrefix = getConfigManager().getOptionBool("channel", "showmodeprefix", false);
504 493
         } else if ("shownickcoloursintext".equals(key)) {
505
-            showColours = configManager.getOptionBool("ui", "shownickcoloursintext", false);
494
+            showColours = getConfigManager().getOptionBool("ui", "shownickcoloursintext", false);
506 495
         }
507 496
     }
508 497
 

+ 2
- 10
src/com/dmdirc/CustomWindow.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
27 26
 import com.dmdirc.ui.WindowManager;
28 27
 import com.dmdirc.ui.interfaces.Window;
@@ -55,7 +54,7 @@ public class CustomWindow extends FrameContainer {
55 54
      */
56 55
     public CustomWindow(final String name, final String title,
57 56
             final Window parent) {
58
-        super("custom");
57
+        super("custom", parent.getConfigManager());
59 58
 
60 59
         this.name = name;
61 60
         this.title = title;
@@ -76,7 +75,7 @@ public class CustomWindow extends FrameContainer {
76 75
      * @param title The parent of this custom window
77 76
      */
78 77
     public CustomWindow(final String name, final String title) {
79
-        super("custom");
78
+        super("custom", IdentityManager.getGlobalConfig());
80 79
 
81 80
         this.name = name;
82 81
         this.title = title;
@@ -144,11 +143,4 @@ public class CustomWindow extends FrameContainer {
144 143
         return title;
145 144
     }
146 145
 
147
-    /** {@inheritDoc} */
148
-    @Override
149
-    public ConfigManager getConfigManager() {
150
-        return parent == null ? IdentityManager.getGlobalConfig() : parent
151
-                .getConfigManager();
152
-    }
153
-
154 146
 }

+ 10
- 2
src/com/dmdirc/FrameContainer.java Целия файл

@@ -53,14 +53,20 @@ public abstract class FrameContainer {
53 53
 
54 54
     /** The name of the icon being used for this container's frame. */
55 55
     private String icon;
56
+    
57
+    /** The config manager for this container. */
58
+    private final ConfigManager config;
56 59
 
57 60
     /**
58 61
      * Instantiate new frame container.
59 62
      * 
60 63
      * @param icon The icon to use for this container
64
+     * @param config The config manager for this container
61 65
      */
62
-    public FrameContainer(final String icon) {
66
+    public FrameContainer(final String icon, final ConfigManager config) {
63 67
         setIcon(icon);
68
+        
69
+        this.config = config;
64 70
     }
65 71
 
66 72
     /**
@@ -132,7 +138,9 @@ public abstract class FrameContainer {
132 138
      *
133 139
      * @return the associated config manager
134 140
      */
135
-    public abstract ConfigManager getConfigManager();
141
+    public final ConfigManager getConfigManager() {
142
+        return config;
143
+    }
136 144
 
137 145
     /**
138 146
      * Requests that this object's frame be activated.

+ 1
- 8
src/com/dmdirc/GlobalWindow.java Целия файл

@@ -25,7 +25,6 @@ package com.dmdirc;
25 25
 import com.dmdirc.commandparser.CommandManager;
26 26
 import com.dmdirc.commandparser.CommandType;
27 27
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
28
-import com.dmdirc.config.ConfigManager;
29 28
 import com.dmdirc.config.IdentityManager;
30 29
 import com.dmdirc.ui.WindowManager;
31 30
 import com.dmdirc.ui.input.TabCompleter;
@@ -44,7 +43,7 @@ public class GlobalWindow extends WritableFrameContainer {
44 43
 
45 44
     /** Creates a new instance of GlobalWindow. */
46 45
     public GlobalWindow() {
47
-        super("icon");
46
+        super("icon", IdentityManager.getGlobalConfig());
48 47
 
49 48
         final TabCompleter tabCompleter = new TabCompleter();
50 49
         tabCompleter.addEntries(TabCompletionType.COMMAND,
@@ -108,10 +107,4 @@ public class GlobalWindow extends WritableFrameContainer {
108 107
         return 0;
109 108
     }
110 109
 
111
-    /** {@inheritDoc} */
112
-    @Override
113
-    public ConfigManager getConfigManager() {
114
-        return IdentityManager.getGlobalConfig();
115
-    }
116
-
117 110
 }

+ 5
- 2
src/com/dmdirc/MessageTarget.java Целия файл

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
+import com.dmdirc.config.ConfigManager;
26
+
25 27
 /**
26 28
  * Defines common methods for objects that you can send messages to (such as
27 29
  * channels and queries).
@@ -34,9 +36,10 @@ public abstract class MessageTarget extends WritableFrameContainer {
34 36
      * Creates a new MessageTarget.
35 37
      * 
36 38
      * @param icon The icon to use for this target
39
+     * @param config The config manager to use for this target
37 40
      */
38
-    public MessageTarget(final String icon) {
39
-        super(icon);
41
+    public MessageTarget(final String icon, final ConfigManager config) {
42
+        super(icon, config);
40 43
     }
41 44
 
42 45
     /**

+ 1
- 16
src/com/dmdirc/Query.java Целия файл

@@ -26,8 +26,6 @@ import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27 27
 import com.dmdirc.commandparser.CommandManager;
28 28
 import com.dmdirc.commandparser.CommandType;
29
-import com.dmdirc.config.ConfigManager;
30
-import com.dmdirc.config.IdentityManager;
31 29
 import com.dmdirc.logger.ErrorLevel;
32 30
 import com.dmdirc.logger.Logger;
33 31
 import com.dmdirc.parser.ClientInfo;
@@ -82,7 +80,7 @@ public final class Query extends MessageTarget implements
82 80
      * @param newServer The server object that this Query belongs to
83 81
      */
84 82
     public Query(final Server newServer, final String newHost) {
85
-        super("query");
83
+        super("query", newServer.getConfigManager());
86 84
 
87 85
         this.server = newServer;
88 86
         this.host = newHost;
@@ -386,17 +384,4 @@ public final class Query extends MessageTarget implements
386 384
         Main.getUI().getMainWindow().setActiveFrame(window);
387 385
     }
388 386
 
389
-    /** {@inheritDoc} */
390
-    @Override
391
-    public ConfigManager getConfigManager() {
392
-        if (server == null) {
393
-            Logger.appError(ErrorLevel.LOW, "Tried to retrieve config manager"
394
-                    + " from a query with no server",
395
-                    new IllegalStateException("My host: " + host));
396
-            return IdentityManager.getGlobalConfig();
397
-        }
398
-
399
-        return server.getConfigManager();
400
-    }
401
-
402 387
 }

+ 1
- 8
src/com/dmdirc/Raw.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.logger.ErrorLevel;
27 26
 import com.dmdirc.logger.Logger;
28 27
 import com.dmdirc.parser.IRCParser;
@@ -61,7 +60,7 @@ public final class Raw extends WritableFrameContainer implements IDataIn,
61 60
      * @param newServer the server to monitor
62 61
      */
63 62
     public Raw(final Server newServer) {
64
-        super("raw");
63
+        super("raw", newServer.getConfigManager());
65 64
 
66 65
         this.server = newServer;
67 66
 
@@ -153,10 +152,4 @@ public final class Raw extends WritableFrameContainer implements IDataIn,
153 152
         return server.getMaxLineLength();
154 153
     }
155 154
 
156
-    /** {@inheritDoc} */
157
-    @Override
158
-    public ConfigManager getConfigManager() {
159
-        return server.getConfigManager();
160
-    }
161
-
162 155
 }

+ 29
- 36
src/com/dmdirc/Server.java Целия файл

@@ -109,8 +109,6 @@ public final class Server extends WritableFrameContainer implements Serializable
109 109
     private final TabCompleter tabCompleter = new TabCompleter();
110 110
     /** The last activated internal frame for this server. */
111 111
     private FrameContainer activeFrame = this;
112
-    /** The config manager for this server. */
113
-    private ConfigManager configManager;
114 112
 
115 113
     /** Our reason for being away, if any. */
116 114
     private String awayMessage;
@@ -153,13 +151,11 @@ public final class Server extends WritableFrameContainer implements Serializable
153 151
      */
154 152
     public Server(final String server, final int port, final String password,
155 153
             final boolean ssl, final Identity profile, final List<String> autochannels) {
156
-        super("server-disconnected");
154
+        super("server-disconnected", new ConfigManager("", "", server));
157 155
 
158 156
         serverInfo = new ServerInfo(server, port, password);
159 157
         serverInfo.setSSL(ssl);
160 158
 
161
-        configManager = new ConfigManager("", "", server);
162
-
163 159
         window = Main.getUI().getServer(this);
164 160
 
165 161
         ServerManager.getServerManager().registerServer(this);
@@ -189,9 +185,9 @@ public final class Server extends WritableFrameContainer implements Serializable
189 185
                     channel.checkWho();
190 186
                 }
191 187
             }
192
-        }, 0, configManager.getOptionInt(DOMAIN_GENERAL, "whotime", 60000));
188
+        }, 0, getConfigManager().getOptionInt(DOMAIN_GENERAL, "whotime", 60000));
193 189
 
194
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "showrawwindow", false)) {
190
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL, "showrawwindow", false)) {
195 191
             addRaw();
196 192
         }
197 193
 
@@ -227,7 +223,7 @@ public final class Server extends WritableFrameContainer implements Serializable
227 223
                 return;
228 224
             case CONNECTED:
229 225
             case CONNECTING:
230
-                disconnect(configManager.getOption(DOMAIN_GENERAL, "quitmessage"));
226
+                disconnect(getConfigManager().getOption(DOMAIN_GENERAL, "quitmessage"));
231 227
                 break;
232 228
             case DISCONNECTING:
233 229
                 onSocketClosed();
@@ -249,7 +245,7 @@ public final class Server extends WritableFrameContainer implements Serializable
249 245
 
250 246
         this.profile = profile;
251 247
 
252
-        configManager = new ConfigManager("", "", server);
248
+        getConfigManager().migrate("", "", server);
253 249
 
254 250
         updateIcon();
255 251
 
@@ -262,8 +258,8 @@ public final class Server extends WritableFrameContainer implements Serializable
262 258
         parser.setCreateFake(true);
263 259
         parser.setIgnoreList(ignoreList);
264 260
 
265
-        if (configManager.hasOption(DOMAIN_GENERAL, "bindip")) {
266
-            parser.setBindIP(configManager.getOption(DOMAIN_GENERAL, "bindip"));
261
+        if (getConfigManager().hasOption(DOMAIN_GENERAL, "bindip")) {
262
+            parser.setBindIP(getConfigManager().getOption(DOMAIN_GENERAL, "bindip"));
267 263
         }
268 264
 
269 265
         doCallbacks();
@@ -300,14 +296,14 @@ public final class Server extends WritableFrameContainer implements Serializable
300 296
      * Reconnects to the IRC server.
301 297
      */
302 298
     public void reconnect() {
303
-        reconnect(configManager.getOption(DOMAIN_GENERAL, "reconnectmessage"));
299
+        reconnect(getConfigManager().getOption(DOMAIN_GENERAL, "reconnectmessage"));
304 300
     }
305 301
 
306 302
     /**
307 303
      * Disconnects from the server with the default quit message.
308 304
      */
309 305
     public void disconnect() {
310
-        disconnect(configManager.getOption(DOMAIN_GENERAL, "quitmessage"));
306
+        disconnect(getConfigManager().getOption(DOMAIN_GENERAL, "quitmessage"));
311 307
     }
312 308
 
313 309
     /**
@@ -339,13 +335,13 @@ public final class Server extends WritableFrameContainer implements Serializable
339 335
             parser.disconnect(reason);
340 336
         }
341 337
 
342
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "closechannelsonquit", false)) {
338
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL, "closechannelsonquit", false)) {
343 339
             closeChannels();
344 340
         } else {
345 341
             clearChannels();
346 342
         }
347 343
 
348
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "closequeriesonquit", false)) {
344
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL, "closequeriesonquit", false)) {
349 345
             closeQueries();
350 346
         }
351 347
     }
@@ -355,7 +351,7 @@ public final class Server extends WritableFrameContainer implements Serializable
355 351
      */
356 352
     private void doDelayedReconnect() {
357 353
         final int delay = Math.max(1,
358
-                configManager.getOptionInt(DOMAIN_GENERAL, "reconnectdelay", 5000));
354
+                getConfigManager().getOptionInt(DOMAIN_GENERAL, "reconnectdelay", 5000));
359 355
 
360 356
         handleNotification("connectRetry", getName(), delay / 1000);
361 357
 
@@ -801,12 +797,6 @@ public final class Server extends WritableFrameContainer implements Serializable
801 797
         return window;
802 798
     }
803 799
 
804
-    /** {@inheritDoc} */
805
-    @Override
806
-    public ConfigManager getConfigManager() {
807
-        return configManager;
808
-    }
809
-
810 800
     /**
811 801
      * Retrieves the current state for this server.
812 802
      *
@@ -1046,11 +1036,11 @@ public final class Server extends WritableFrameContainer implements Serializable
1046 1036
         final String sansIrcd = "numeric_" + snumeric;
1047 1037
         String target = null;
1048 1038
 
1049
-        if (configManager.hasOption("formatter", withIrcd)) {
1039
+        if (getConfigManager().hasOption("formatter", withIrcd)) {
1050 1040
             target = withIrcd;
1051
-        } else if (configManager.hasOption("formatter", sansIrcd)) {
1041
+        } else if (getConfigManager().hasOption("formatter", sansIrcd)) {
1052 1042
             target = sansIrcd;
1053
-        } else if (configManager.hasOption("formatter", "numeric_unknown")) {
1043
+        } else if (getConfigManager().hasOption("formatter", "numeric_unknown")) {
1054 1044
             target = "numeric_unknown";
1055 1045
         }
1056 1046
 
@@ -1087,19 +1077,21 @@ public final class Server extends WritableFrameContainer implements Serializable
1087 1077
 
1088 1078
         updateIcon();
1089 1079
 
1090
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "closechannelsondisconnect", false)) {
1080
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL,
1081
+                "closechannelsondisconnect", false)) {
1091 1082
             closeChannels();
1092 1083
         } else {
1093 1084
             clearChannels();
1094 1085
         }
1095 1086
 
1096
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "closequeriesondisconnect", false)) {
1087
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL,
1088
+                "closequeriesondisconnect", false)) {
1097 1089
             closeQueries();
1098 1090
         }
1099 1091
 
1100 1092
         removeInvites();
1101 1093
 
1102
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "reconnectondisconnect", false)
1094
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL, "reconnectondisconnect", false)
1103 1095
                 && myState == ServerState.TRANSIENTLY_DISCONNECTED) {
1104 1096
             doDelayedReconnect();
1105 1097
         }
@@ -1147,7 +1139,8 @@ public final class Server extends WritableFrameContainer implements Serializable
1147 1139
 
1148 1140
         handleNotification("connectError", getName(), description);
1149 1141
 
1150
-        if (configManager.getOptionBool(DOMAIN_GENERAL, "reconnectonconnectfailure", false)) {
1142
+        if (getConfigManager().getOptionBool(DOMAIN_GENERAL,
1143
+                "reconnectonconnectfailure", false)) {
1151 1144
             doDelayedReconnect();
1152 1145
         }
1153 1146
     }
@@ -1165,7 +1158,7 @@ public final class Server extends WritableFrameContainer implements Serializable
1165 1158
                 Long.valueOf(parser.getPingTime(false)));
1166 1159
 
1167 1160
         if (parser.getPingTime(false)
1168
-                 >= configManager.getOptionInt(DOMAIN_SERVER, "pingtimeout", 60000)) {
1161
+                 >= getConfigManager().getOptionInt(DOMAIN_SERVER, "pingtimeout", 60000)) {
1169 1162
             handleNotification("stonedServer", getName());
1170 1163
             reconnect();
1171 1164
         }
@@ -1180,14 +1173,14 @@ public final class Server extends WritableFrameContainer implements Serializable
1180 1173
         }
1181 1174
         updateIcon();
1182 1175
 
1183
-        configManager = new ConfigManager(parser.getIRCD(true), getNetwork(), getName());
1176
+        getConfigManager().migrate(parser.getIRCD(true), getNetwork(), getName());
1184 1177
         updateIgnoreList();
1185 1178
 
1186 1179
         converter = parser.getIRCStringConverter();
1187 1180
 
1188 1181
         ActionManager.processEvent(CoreActionType.SERVER_CONNECTED, null, this);
1189 1182
 
1190
-        if (configManager.hasOption(DOMAIN_GENERAL, "rejoinchannels")) {
1183
+        if (getConfigManager().hasOption(DOMAIN_GENERAL, "rejoinchannels")) {
1191 1184
             for (Channel chan : channels.values()) {
1192 1185
                 chan.join();
1193 1186
             }
@@ -1213,13 +1206,13 @@ public final class Server extends WritableFrameContainer implements Serializable
1213 1206
         final StringBuffer missingUmodes = new StringBuffer();
1214 1207
 
1215 1208
         for (char mode : modes.toCharArray()) {
1216
-            if (!configManager.hasOption(DOMAIN_SERVER, "mode" + mode)) {
1209
+            if (!getConfigManager().hasOption(DOMAIN_SERVER, "mode" + mode)) {
1217 1210
                 missingModes.append(mode);
1218 1211
             }
1219 1212
         }
1220 1213
 
1221 1214
         for (char mode : umodes.toCharArray()) {
1222
-            if (!configManager.hasOption(DOMAIN_SERVER, "umode" + mode)) {
1215
+            if (!getConfigManager().hasOption(DOMAIN_SERVER, "umode" + mode)) {
1223 1216
                 missingUmodes.append(mode);
1224 1217
             }
1225 1218
         }
@@ -1248,7 +1241,7 @@ public final class Server extends WritableFrameContainer implements Serializable
1248 1241
                     + "IRCd: " + parser.getIRCD(false)
1249 1242
                     + " (" + parser.getIRCD(true) + ")\n"
1250 1243
                     + "Mode alias version: "
1251
-                    + configManager.getOption("identity", "modealiasversion", "none")
1244
+                    + getConfigManager().getOption("identity", "modealiasversion", "none")
1252 1245
                     + "\n\n"));
1253 1246
         }
1254 1247
     }
@@ -1270,7 +1263,7 @@ public final class Server extends WritableFrameContainer implements Serializable
1270 1263
      */
1271 1264
     public void updateIgnoreList() {
1272 1265
         ignoreList.clear();
1273
-        ignoreList.addAll(configManager.getOptionList("network", "ignorelist"));
1266
+        ignoreList.addAll(getConfigManager().getOptionList("network", "ignorelist"));
1274 1267
     }
1275 1268
 
1276 1269
     /**

+ 4
- 2
src/com/dmdirc/WritableFrameContainer.java Целия файл

@@ -24,6 +24,7 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.interfaces.ActionType;
27
+import com.dmdirc.config.ConfigManager;
27 28
 import com.dmdirc.logger.ErrorLevel;
28 29
 import com.dmdirc.logger.Logger;
29 30
 import com.dmdirc.ui.WindowManager;
@@ -52,9 +53,10 @@ public abstract class WritableFrameContainer extends FrameContainer {
52 53
      * Creates a new WritableFrameContainer.
53 54
      * 
54 55
      * @param icon The icon to use for this container
56
+     * @param config The config manager for this container
55 57
      */
56
-    public WritableFrameContainer(final String icon) {
57
-        super(icon);
58
+    public WritableFrameContainer(final String icon, final ConfigManager config) {
59
+        super(icon, config);
58 60
     }
59 61
     
60 62
     /**

+ 1
- 12
src/com/dmdirc/addons/dcc/DCCFrame.java Целия файл

@@ -30,7 +30,6 @@ import com.dmdirc.commandparser.commands.Command;
30 30
 import com.dmdirc.commandparser.commands.GlobalCommand;
31 31
 import com.dmdirc.commandparser.parsers.CommandParser;
32 32
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
33
-import com.dmdirc.config.ConfigManager;
34 33
 import com.dmdirc.config.IdentityManager;
35 34
 import com.dmdirc.ui.WindowManager;
36 35
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -170,7 +169,7 @@ public abstract class DCCFrame extends WritableFrameContainer {
170 169
 	 * @param defaultWindow Create default (empty) window.
171 170
 	 */
172 171
 	public DCCFrame(final DCCPlugin plugin, final String title, final boolean defaultWindow) {
173
-		super("raw");
172
+		super("raw", IdentityManager.getGlobalConfig());
174 173
 		this.title = title;
175 174
 		this.plugin = plugin;
176 175
 
@@ -234,16 +233,6 @@ public abstract class DCCFrame extends WritableFrameContainer {
234 233
 		return title;
235 234
 	}
236 235
 	
237
-	/**
238
-	 * Retrieves the config manager for this command window.
239
-	 *
240
-	 * @return This window's config manager
241
-	 */
242
-	@Override
243
-	public ConfigManager getConfigManager() {
244
-		return IdentityManager.getGlobalConfig();
245
-	}
246
-	
247 236
 	/**
248 237
 	 * Returns the server instance associated with this container.
249 238
 	 *

+ 2
- 8
src/com/dmdirc/addons/logging/HistoryWindow.java Целия файл

@@ -25,7 +25,6 @@ package com.dmdirc.addons.logging;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Main;
27 27
 import com.dmdirc.Server;
28
-import com.dmdirc.config.ConfigManager;
29 28
 import com.dmdirc.config.IdentityManager;
30 29
 import com.dmdirc.ui.WindowManager;
31 30
 import com.dmdirc.ui.interfaces.Window;
@@ -56,7 +55,7 @@ public class HistoryWindow extends FrameContainer {
56 55
      * @param parent The window this history window was opened from
57 56
      */
58 57
     public HistoryWindow(final String title, final ReverseFileReader reader, final Window parent) {
59
-        super("raw");
58
+        super("raw", parent.getConfigManager());
60 59
         
61 60
         this.title = title;
62 61
         this.parent = parent;
@@ -112,10 +111,5 @@ public class HistoryWindow extends FrameContainer {
112 111
     public Server getServer() {
113 112
         return parent.getContainer().getServer();
114 113
     }
115
-    
116
-    /** {@inheritDoc} */
117
-    @Override
118
-    public ConfigManager getConfigManager() {
119
-        return parent.getConfigManager();
120
-    }    
114
+
121 115
 }

+ 13
- 0
src/com/dmdirc/config/ConfigManager.java Целия файл

@@ -253,6 +253,19 @@ public class ConfigManager extends ConfigSource implements Serializable,
253 253
         return new ArrayList<Identity>(sources);
254 254
     }
255 255
     
256
+    /**
257
+     * Migrates this ConfigManager from its current configuration to the
258
+     * appropriate one for the specified new parameters, firing listeners where
259
+     * settings have changed.
260
+     * 
261
+     * @param ircd The new name of the ircd for this manager
262
+     * @param network The new name of the network for this manager
263
+     * @param server The new name of the server for this manager
264
+     */
265
+    public void migrate(final String ircd, final String network, final String server) {
266
+        migrate(ircd, network, server, "<Unknown>");
267
+    }   
268
+    
256 269
     /**
257 270
      * Migrates this ConfigManager from its current configuration to the
258 271
      * appropriate one for the specified new parameters, firing listeners where

+ 3
- 4
test/com/dmdirc/WritableFrameContainerTest.java Целия файл

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.config.IdentityManager;
26 27
 import com.dmdirc.ui.interfaces.InputWindow;
27 28
 
28 29
 import org.junit.Test;
@@ -57,6 +58,8 @@ class BasicWritableFrameContainer extends WritableFrameContainer {
57 58
     private final int lineLength;
58 59
     
59 60
     public BasicWritableFrameContainer(final int lineLength) {
61
+        super("raw", IdentityManager.getGlobalConfig());
62
+        
60 63
         this.lineLength = lineLength;
61 64
     }
62 65
     
@@ -83,8 +86,4 @@ class BasicWritableFrameContainer extends WritableFrameContainer {
83 86
     public Server getServer() {
84 87
         return null;
85 88
     }
86
-
87
-    public ConfigManager getConfigManager() {
88
-        return null;
89
-    }
90 89
 }

Loading…
Отказ
Запис