Browse Source

Fixes issue 617: window closing procedure

git-svn-id: http://svn.dmdirc.com/trunk@3115 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 years ago
parent
commit
4d4040f520

+ 20
- 31
src/com/dmdirc/Channel.java View File

342
         window.updateNames(new ArrayList<ChannelClientInfo>());
342
         window.updateNames(new ArrayList<ChannelClientInfo>());
343
     }
343
     }
344
     
344
     
345
-    /**
346
-     * Parts the channel and then closes the window.
347
-     */
345
+    /** {@inheritDoc} */
348
     @Override
346
     @Override
349
-    public void close() {
347
+    public void windowClosing() {
348
+        // 1: Make the window non-visible
349
+        window.setVisible(false);
350
+        
351
+        // 2: Remove any callbacks or listeners
352
+        eventHandler.unregisterCallbacks();
353
+        
354
+        // 3: Trigger any actions neccessary
350
         part(configManager.getOption("general", "partmessage"));
355
         part(configManager.getOption("general", "partmessage"));
351
-        closeWindow();
352
-    }
353
-    
354
-    /**
355
-     * Closes the window without parting the channel.
356
-     */
357
-    public void closeWindow() {
358
-        closeWindow(true);
359
-    }
360
-    
361
-    /**
362
-     * Closes the window without parting the channel.
363
-     *
364
-     * @param shouldRemove Whether we should remove the window from the server
365
-     */
366
-    public void closeWindow(final boolean shouldRemove) {
367
-        if (server.getParser() != null) {
368
-            server.getParser().getCallbackManager().delAllCallback(eventHandler);
369
-        }
370
         
356
         
357
+        // 4: Trigger action for the window closing
371
         ActionManager.processEvent(CoreActionType.CHANNEL_CLOSED, null, this);
358
         ActionManager.processEvent(CoreActionType.CHANNEL_CLOSED, null, this);
372
         
359
         
373
-        if (shouldRemove) {
374
-            server.delChannel(channelInfo.getName());
375
-        }
360
+        // 5: Inform any parents that the window is closing
361
+        server.delChannel(channelInfo.getName());
376
         
362
         
377
-        window.setVisible(false);
378
-        Main.getUI().getMainWindow().delChild(window);
363
+        // 6: Remove the window from the window manager
379
         WindowManager.removeWindow(window);
364
         WindowManager.removeWindow(window);
380
-        window.close();
381
-        window = null;
382
-        server = null;
365
+        if (server.getParser() != null) {
366
+            server.getParser().getCallbackManager().delAllCallback(eventHandler);
367
+        }
368
+        
369
+        // 7: Remove any references to the window and parents
370
+        window = null; // NOPMD
371
+        server = null; // NOPMD
383
     }
372
     }
384
     
373
     
385
     /**
374
     /**

+ 11
- 4
src/com/dmdirc/CustomWindow.java View File

93
 
93
 
94
     /** {@inheritDoc} */
94
     /** {@inheritDoc} */
95
     @Override
95
     @Override
96
-    public void close() {
96
+    public void windowClosing() {
97
+        // 1: Make the window non-visible
97
         window.setVisible(false);
98
         window.setVisible(false);
98
-
99
+        
100
+        // 2: Remove any callbacks or listeners
101
+        // 3: Trigger any actions neccessary
102
+        // 4: Trigger action for the window closing
103
+        // 5: Inform any parents that the window is closing
104
+        
105
+        // 6: Remove the window from the window manager
99
         WindowManager.removeWindow(window);
106
         WindowManager.removeWindow(window);
100
-        Main.getUI().getMainWindow().delChild(window);
101
         
107
         
102
-        window.close();
108
+        // 7: Remove any references to the window and parents
103
         window = null; // NOPMD
109
         window = null; // NOPMD
110
+        parent = null; // NOPMD
104
     }
111
     }
105
 
112
 
106
     /** {@inheritDoc} */
113
     /** {@inheritDoc} */

+ 8
- 1
src/com/dmdirc/EventHandler.java View File

56
             Logger.appError(ErrorLevel.FATAL, "Unable to register callbacks",
56
             Logger.appError(ErrorLevel.FATAL, "Unable to register callbacks",
57
                     exception);
57
                     exception);
58
         }
58
         }
59
-    }    
59
+    }
60
+    
61
+    /**
62
+     * Unregisters all callbacks that have been registered by this event handler.
63
+     */
64
+    public void unregisterCallbacks() {
65
+        getParser().getCallbackManager().delAllCallback(this);
66
+    }
60
     
67
     
61
     /**
68
     /**
62
      * Adds a callback to this event handler.
69
      * Adds a callback to this event handler.

+ 8
- 4
src/com/dmdirc/FrameContainer.java View File

77
     /**
77
     /**
78
      * Closes this container (and it's associated frame).
78
      * Closes this container (and it's associated frame).
79
      */
79
      */
80
-    public abstract void close();
80
+    public final void close() {
81
+        if (getFrame() == null) {
82
+            throw new IllegalStateException("No frame associated with this container!");
83
+        } else {
84
+            getFrame().close();
85
+        }
86
+    }
81
 
87
 
82
     /**
88
     /**
83
      * Returns the server instance associated with this container.
89
      * Returns the server instance associated with this container.
179
     /**
185
     /**
180
      * Invoked when our window is closing.
186
      * Invoked when our window is closing.
181
      */
187
      */
182
-    public void windowClosing() {
183
-        close();
184
-    }
188
+    public abstract void windowClosing();
185
 
189
 
186
     /**
190
     /**
187
      * Invoked when our window has been closed.
191
      * Invoked when our window has been closed.

+ 24
- 3
src/com/dmdirc/GlobalWindow.java View File

61
         window.open();
61
         window.open();
62
     }
62
     }
63
 
63
 
64
+    /** {@inheritDoc} */
65
+    @Override    
64
     public InputWindow getFrame() {
66
     public InputWindow getFrame() {
65
         return window;
67
         return window;
66
     }
68
     }
67
 
69
 
70
+    /** {@inheritDoc} */
71
+    @Override
68
     public String toString() {
72
     public String toString() {
69
         return "Global";
73
         return "Global";
70
     }
74
     }
71
 
75
 
72
-    public void close() {
76
+    /** {@inheritDoc} */
77
+    @Override    
78
+    public void windowClosing() {
79
+        // 1: Make the window non-visible
73
         window.setVisible(false);
80
         window.setVisible(false);
74
-        window.close();
81
+        
82
+        // 2: Remove any callbacks or listeners
83
+        // 3: Trigger any actions neccessary
84
+        // 4: Trigger action for the window closing
85
+        // 5: Inform any parents that the window is closing
86
+        
87
+        // 6: Remove the window from the window manager
75
         WindowManager.removeWindow(window);
88
         WindowManager.removeWindow(window);
76
-        Main.getUI().getMainWindow().delChild(window);
89
+        
90
+        // 7: Remove any references to the window and parents        
77
     }
91
     }
78
 
92
 
93
+    /** {@inheritDoc} */
94
+    @Override    
79
     public Server getServer() {
95
     public Server getServer() {
80
         return null;
96
         return null;
81
     }
97
     }
82
 
98
 
99
+    /** {@inheritDoc} */
100
+    @Override    
83
     public void sendLine(final String line) {
101
     public void sendLine(final String line) {
84
         GlobalCommandParser.getGlobalCommandParser().parseCommand(window, 
102
         GlobalCommandParser.getGlobalCommandParser().parseCommand(window, 
85
                 CommandManager.getCommandChar() + line);
103
                 CommandManager.getCommandChar() + line);
86
     }
104
     }
87
 
105
 
106
+    /** {@inheritDoc} */
107
+    @Override    
88
     public int getMaxLineLength() {
108
     public int getMaxLineLength() {
89
         return 0;
109
         return 0;
90
     }
110
     }
91
     
111
     
112
+    /** {@inheritDoc} */
92
     @Override
113
     @Override
93
     public ConfigManager getConfigManager() {
114
     public ConfigManager getConfigManager() {
94
         return IdentityManager.getGlobalConfig();
115
         return IdentityManager.getGlobalConfig();

+ 87
- 98
src/com/dmdirc/Query.java View File

54
  */
54
  */
55
 public final class Query extends MessageTarget implements
55
 public final class Query extends MessageTarget implements
56
         IPrivateAction, IPrivateMessage, INickChanged, IQuit, Serializable {
56
         IPrivateAction, IPrivateMessage, INickChanged, IQuit, Serializable {
57
-    
57
+
58
     /**
58
     /**
59
      * A version number for this class. It should be changed whenever the class
59
      * A version number for this class. It should be changed whenever the class
60
      * structure is changed (or anything else that would prevent serialized
60
      * structure is changed (or anything else that would prevent serialized
61
      * objects being unserialized with the new class).
61
      * objects being unserialized with the new class).
62
      */
62
      */
63
     private static final long serialVersionUID = 1;
63
     private static final long serialVersionUID = 1;
64
-    
64
+
65
     /** The Server this Query is on. */
65
     /** The Server this Query is on. */
66
     private Server server;
66
     private Server server;
67
-    
67
+
68
     /** The QueryWindow used for this Query. */
68
     /** The QueryWindow used for this Query. */
69
     private QueryWindow window;
69
     private QueryWindow window;
70
-    
70
+
71
     /** The full host of the client associated with this Query. */
71
     /** The full host of the client associated with this Query. */
72
     private String host;
72
     private String host;
73
-    
73
+
74
     /** The tab completer for the query window. */
74
     /** The tab completer for the query window. */
75
     private final TabCompleter tabCompleter;
75
     private final TabCompleter tabCompleter;
76
-    
76
+
77
     /**
77
     /**
78
      * Creates a new instance of Query.
78
      * Creates a new instance of Query.
79
      *
79
      *
82
      */
82
      */
83
     public Query(final Server newServer, final String newHost) {
83
     public Query(final Server newServer, final String newHost) {
84
         super();
84
         super();
85
-        
85
+
86
         this.server = newServer;
86
         this.server = newServer;
87
         this.host = newHost;
87
         this.host = newHost;
88
-        
88
+
89
         icon = IconManager.getIconManager().getIcon("query");
89
         icon = IconManager.getIconManager().getIcon("query");
90
-        
90
+
91
         window = Main.getUI().getQuery(this);
91
         window = Main.getUI().getQuery(this);
92
         WindowManager.addWindow(server.getFrame(), window);
92
         WindowManager.addWindow(server.getFrame(), window);
93
-        
93
+
94
         ActionManager.processEvent(CoreActionType.QUERY_OPENED, null, this);
94
         ActionManager.processEvent(CoreActionType.QUERY_OPENED, null, this);
95
-        
95
+
96
         window.setFrameIcon(icon);
96
         window.setFrameIcon(icon);
97
-        
97
+
98
         if (!server.getConfigManager().getOptionBool("general", "hidequeries", false)) {
98
         if (!server.getConfigManager().getOptionBool("general", "hidequeries", false)) {
99
             window.open();
99
             window.open();
100
         }
100
         }
101
-        
101
+
102
         tabCompleter = new TabCompleter(server.getTabCompleter());
102
         tabCompleter = new TabCompleter(server.getTabCompleter());
103
         tabCompleter.addEntries(CommandManager.getCommandNames(CommandType.TYPE_QUERY));
103
         tabCompleter.addEntries(CommandManager.getCommandNames(CommandType.TYPE_QUERY));
104
         tabCompleter.addEntries(CommandManager.getCommandNames(CommandType.TYPE_CHAT));
104
         tabCompleter.addEntries(CommandManager.getCommandNames(CommandType.TYPE_CHAT));
105
         window.getInputHandler().setTabCompleter(tabCompleter);
105
         window.getInputHandler().setTabCompleter(tabCompleter);
106
-        
106
+
107
         reregister();
107
         reregister();
108
-        
108
+
109
         updateTitle();
109
         updateTitle();
110
     }
110
     }
111
-    
111
+
112
     /**
112
     /**
113
      * Shows this query's window.
113
      * Shows this query's window.
114
      */
114
      */
115
     public void show() {
115
     public void show() {
116
         window.open();
116
         window.open();
117
     }
117
     }
118
-    
118
+
119
     /** {@inheritDoc} */
119
     /** {@inheritDoc} */
120
     @Override
120
     @Override
121
     public InputWindow getFrame() {
121
     public InputWindow getFrame() {
122
         return window;
122
         return window;
123
     }
123
     }
124
-    
124
+
125
     /**
125
     /**
126
      * Returns the tab completer for this query.
126
      * Returns the tab completer for this query.
127
      *
127
      *
130
     public TabCompleter getTabCompleter() {
130
     public TabCompleter getTabCompleter() {
131
         return tabCompleter;
131
         return tabCompleter;
132
     }
132
     }
133
-    
133
+
134
     /** {@inheritDoc} */
134
     /** {@inheritDoc} */
135
     @Override
135
     @Override
136
     public void sendLine(final String line) {
136
     public void sendLine(final String line) {
138
             Toolkit.getDefaultToolkit().beep();
138
             Toolkit.getDefaultToolkit().beep();
139
             return;
139
             return;
140
         }
140
         }
141
-        
141
+
142
         if (line.indexOf('\n') > -1) {
142
         if (line.indexOf('\n') > -1) {
143
             for (String part : line.split("\n")) {
143
             for (String part : line.split("\n")) {
144
                 sendLine(part);
144
                 sendLine(part);
145
             }
145
             }
146
-            
146
+
147
             return;
147
             return;
148
         }
148
         }
149
 
149
 
150
         final ClientInfo client = server.getParser().getMyself();
150
         final ClientInfo client = server.getParser().getMyself();
151
-        
151
+
152
         if (line.length() <= getMaxLineLength()) {
152
         if (line.length() <= getMaxLineLength()) {
153
             server.getParser().sendMessage(ClientInfo.parseHost(host), window.getTranscoder().encode(line));
153
             server.getParser().sendMessage(ClientInfo.parseHost(host), window.getTranscoder().encode(line));
154
-            
154
+
155
             final StringBuffer buff = new StringBuffer("querySelfMessage");
155
             final StringBuffer buff = new StringBuffer("querySelfMessage");
156
-            
156
+
157
             ActionManager.processEvent(CoreActionType.QUERY_SELF_MESSAGE, buff, this, line);
157
             ActionManager.processEvent(CoreActionType.QUERY_SELF_MESSAGE, buff, this, line);
158
-            
158
+
159
             addLine(buff, client.getNickname(), client.getIdent(),
159
             addLine(buff, client.getNickname(), client.getIdent(),
160
                     client.getHost(), window.getTranscoder().encode(line));
160
                     client.getHost(), window.getTranscoder().encode(line));
161
         } else {
161
         } else {
163
             sendLine(line.substring(getMaxLineLength()));
163
             sendLine(line.substring(getMaxLineLength()));
164
         }
164
         }
165
     }
165
     }
166
-    
166
+
167
     /** {@inheritDoc} */
167
     /** {@inheritDoc} */
168
     @Override
168
     @Override
169
     public int getMaxLineLength() {
169
     public int getMaxLineLength() {
170
         return server.getParser().getMaxLength("PRIVMSG", host);
170
         return server.getParser().getMaxLength("PRIVMSG", host);
171
     }
171
     }
172
-    
172
+
173
     /**
173
     /**
174
      * Sends a private action to the remote user.
174
      * Sends a private action to the remote user.
175
      *
175
      *
181
             Toolkit.getDefaultToolkit().beep();
181
             Toolkit.getDefaultToolkit().beep();
182
             return;
182
             return;
183
         }
183
         }
184
-        
184
+
185
         final ClientInfo client = server.getParser().getMyself();
185
         final ClientInfo client = server.getParser().getMyself();
186
         final int maxLineLength = server.getParser().getMaxLength("PRIVMSG", host);
186
         final int maxLineLength = server.getParser().getMaxLength("PRIVMSG", host);
187
-        
187
+
188
         if (maxLineLength >= action.length() + 2) {
188
         if (maxLineLength >= action.length() + 2) {
189
             server.getParser().sendAction(ClientInfo.parseHost(host), window.getTranscoder().encode(action));
189
             server.getParser().sendAction(ClientInfo.parseHost(host), window.getTranscoder().encode(action));
190
-            
190
+
191
             final StringBuffer buff = new StringBuffer("querySelfAction");
191
             final StringBuffer buff = new StringBuffer("querySelfAction");
192
-            
192
+
193
             ActionManager.processEvent(CoreActionType.QUERY_SELF_ACTION, buff, this, action);
193
             ActionManager.processEvent(CoreActionType.QUERY_SELF_ACTION, buff, this, action);
194
-            
194
+
195
             addLine(buff, client.getNickname(), client.getIdent(),
195
             addLine(buff, client.getNickname(), client.getIdent(),
196
                     client.getHost(), window.getTranscoder().encode(action));
196
                     client.getHost(), window.getTranscoder().encode(action));
197
         } else {
197
         } else {
198
             addLine("actionTooLong", action.length());
198
             addLine("actionTooLong", action.length());
199
         }
199
         }
200
     }
200
     }
201
-    
201
+
202
     /**
202
     /**
203
      * Handles a private message event from the parser.
203
      * Handles a private message event from the parser.
204
      *
204
      *
210
     public void onPrivateMessage(final IRCParser parser, final String message,
210
     public void onPrivateMessage(final IRCParser parser, final String message,
211
             final String remoteHost) {
211
             final String remoteHost) {
212
         final String[] parts = ClientInfo.parseHostFull(remoteHost);
212
         final String[] parts = ClientInfo.parseHostFull(remoteHost);
213
-        
213
+
214
         final StringBuffer buff = new StringBuffer("queryMessage");
214
         final StringBuffer buff = new StringBuffer("queryMessage");
215
-        
215
+
216
         ActionManager.processEvent(CoreActionType.QUERY_MESSAGE, buff, this, message);
216
         ActionManager.processEvent(CoreActionType.QUERY_MESSAGE, buff, this, message);
217
-        
217
+
218
         addLine(buff, parts[0], parts[1], parts[2], message);
218
         addLine(buff, parts[0], parts[1], parts[2], message);
219
     }
219
     }
220
-    
220
+
221
     /**
221
     /**
222
      * Handles a private action event from the parser.
222
      * Handles a private action event from the parser.
223
      *
223
      *
229
     public void onPrivateAction(final IRCParser parser, final String message,
229
     public void onPrivateAction(final IRCParser parser, final String message,
230
             final String remoteHost) {
230
             final String remoteHost) {
231
         final String[] parts = ClientInfo.parseHostFull(host);
231
         final String[] parts = ClientInfo.parseHostFull(host);
232
-        
232
+
233
         final StringBuffer buff = new StringBuffer("queryAction");
233
         final StringBuffer buff = new StringBuffer("queryAction");
234
-        
234
+
235
         ActionManager.processEvent(CoreActionType.QUERY_ACTION, buff, this, message);
235
         ActionManager.processEvent(CoreActionType.QUERY_ACTION, buff, this, message);
236
-        
236
+
237
         addLine(buff, parts[0], parts[1], parts[2], message);
237
         addLine(buff, parts[0], parts[1], parts[2], message);
238
     }
238
     }
239
-    
239
+
240
     /**
240
     /**
241
      * Updates the QueryWindow's title.
241
      * Updates the QueryWindow's title.
242
      */
242
      */
243
     private void updateTitle() {
243
     private void updateTitle() {
244
         final String title = ClientInfo.parseHost(host);
244
         final String title = ClientInfo.parseHost(host);
245
-        
245
+
246
         window.setTitle(title);
246
         window.setTitle(title);
247
-        
247
+
248
         if (window.isMaximum() && window.equals(Main.getUI().getMainWindow().getActiveFrame())) {
248
         if (window.isMaximum() && window.equals(Main.getUI().getMainWindow().getActiveFrame())) {
249
             Main.getUI().getMainWindow().setTitle(Main.getUI().getMainWindow().getTitlePrefix() + " - " + title);
249
             Main.getUI().getMainWindow().setTitle(Main.getUI().getMainWindow().getTitlePrefix() + " - " + title);
250
         }
250
         }
251
     }
251
     }
252
-    
252
+
253
     /**
253
     /**
254
      * Reregisters query callbacks. Called when reconnecting to the server.
254
      * Reregisters query callbacks. Called when reconnecting to the server.
255
      */
255
      */
256
     public void reregister() {
256
     public void reregister() {
257
         final CallbackManager callbackManager = server.getParser().getCallbackManager();
257
         final CallbackManager callbackManager = server.getParser().getCallbackManager();
258
-        
258
+
259
         try {
259
         try {
260
             callbackManager.addCallback("onPrivateAction", this, ClientInfo.parseHost(host));
260
             callbackManager.addCallback("onPrivateAction", this, ClientInfo.parseHost(host));
261
             callbackManager.addCallback("onPrivateMessage", this, ClientInfo.parseHost(host));
261
             callbackManager.addCallback("onPrivateMessage", this, ClientInfo.parseHost(host));
265
             Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
265
             Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
266
         }
266
         }
267
     }
267
     }
268
-    
268
+
269
     /** {@inheritDoc} */
269
     /** {@inheritDoc} */
270
     @Override
270
     @Override
271
     public void onNickChanged(final IRCParser tParser, final ClientInfo cClient,
271
     public void onNickChanged(final IRCParser tParser, final ClientInfo cClient,
272
             final String sOldNick) {
272
             final String sOldNick) {
273
         if (sOldNick.equals(ClientInfo.parseHost(host))) {
273
         if (sOldNick.equals(ClientInfo.parseHost(host))) {
274
             final CallbackManager callbackManager = server.getParser().getCallbackManager();
274
             final CallbackManager callbackManager = server.getParser().getCallbackManager();
275
-            
275
+
276
             callbackManager.delCallback("onPrivateAction", this);
276
             callbackManager.delCallback("onPrivateAction", this);
277
             callbackManager.delCallback("onPrivateMessage", this);
277
             callbackManager.delCallback("onPrivateMessage", this);
278
-            
278
+
279
             try {
279
             try {
280
                 callbackManager.addCallback("onPrivateAction", this, cClient.getNickname());
280
                 callbackManager.addCallback("onPrivateAction", this, cClient.getNickname());
281
                 callbackManager.addCallback("onPrivateMessage", this, cClient.getNickname());
281
                 callbackManager.addCallback("onPrivateMessage", this, cClient.getNickname());
282
             } catch (CallbackNotFoundException ex) {
282
             } catch (CallbackNotFoundException ex) {
283
                 Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
283
                 Logger.appError(ErrorLevel.HIGH, "Unable to get query events", ex);
284
             }
284
             }
285
-            
285
+
286
             final StringBuffer format = new StringBuffer("queryNickChanged");
286
             final StringBuffer format = new StringBuffer("queryNickChanged");
287
-            
287
+
288
             ActionManager.processEvent(CoreActionType.QUERY_NICKCHANGE, format, this, sOldNick);
288
             ActionManager.processEvent(CoreActionType.QUERY_NICKCHANGE, format, this, sOldNick);
289
-            
289
+
290
             server.getTabCompleter().removeEntry(sOldNick);
290
             server.getTabCompleter().removeEntry(sOldNick);
291
             server.getTabCompleter().addEntry(cClient.getNickname());
291
             server.getTabCompleter().addEntry(cClient.getNickname());
292
-            
292
+
293
             addLine(format, sOldNick, cClient.getIdent(),
293
             addLine(format, sOldNick, cClient.getIdent(),
294
                     cClient.getHost(), cClient.getNickname());
294
                     cClient.getHost(), cClient.getNickname());
295
             host = cClient.getNickname() + "!" + cClient.getIdent() + "@" + cClient.getHost();
295
             host = cClient.getNickname() + "!" + cClient.getIdent() + "@" + cClient.getHost();
296
             updateTitle();
296
             updateTitle();
297
         }
297
         }
298
     }
298
     }
299
-    
299
+
300
     /** {@inheritDoc} */
300
     /** {@inheritDoc} */
301
     @Override
301
     @Override
302
     public void onQuit(final IRCParser tParser, final ClientInfo cClient,
302
     public void onQuit(final IRCParser tParser, final ClientInfo cClient,
304
         if (cClient.getNickname().equals(ClientInfo.parseHost(host))) {
304
         if (cClient.getNickname().equals(ClientInfo.parseHost(host))) {
305
             final StringBuffer format = new StringBuffer(sReason.isEmpty() ?
305
             final StringBuffer format = new StringBuffer(sReason.isEmpty() ?
306
                 "queryQuit" : "queryQuitReason");
306
                 "queryQuit" : "queryQuitReason");
307
-            
307
+
308
             ActionManager.processEvent(CoreActionType.QUERY_QUIT, format, this, sReason);
308
             ActionManager.processEvent(CoreActionType.QUERY_QUIT, format, this, sReason);
309
-            
309
+
310
             addLine(format, cClient.getNickname(),
310
             addLine(format, cClient.getNickname(),
311
                     cClient.getIdent(), cClient.getHost(), sReason);
311
                     cClient.getIdent(), cClient.getHost(), sReason);
312
         }
312
         }
313
     }
313
     }
314
-    
314
+
315
     /**
315
     /**
316
      * Returns the Server assocaited with this query.
316
      * Returns the Server assocaited with this query.
317
      *
317
      *
321
     public Server getServer() {
321
     public Server getServer() {
322
         return server;
322
         return server;
323
     }
323
     }
324
-    
325
-    /**
326
-     * Closes the query and associated window.
327
-     */
324
+
325
+    /** {@inheritDoc} */
328
     @Override
326
     @Override
329
-    public void close() {
330
-        close(true);
331
-    }
332
-    
333
-    /**
334
-     * Closes the query and associated window.
335
-     *
336
-     * @param shouldRemove Whether or not we should remove the window from the server.
337
-     */
338
-    public void close(final boolean shouldRemove) {
327
+    public void windowClosing() {
328
+        // 1: Make the window non-visible
329
+        window.setVisible(false);
330
+
331
+        // 2: Remove any callbacks or listeners
339
         if (server != null && server.getParser() != null) {
332
         if (server != null && server.getParser() != null) {
340
-            server.getParser().getCallbackManager().delCallback("onPrivateAction", this);
341
-            server.getParser().getCallbackManager().delCallback("onPrivateMessage", this);
342
-            server.getParser().getCallbackManager().delCallback("onNickChanged", this);
343
-            server.getParser().getCallbackManager().delCallback("onQuit", this);
333
+            server.getParser().getCallbackManager().delAllCallback(this);
344
         }
334
         }
345
-        
335
+
336
+        // 3: Trigger any actions neccessary
337
+
338
+        // 4: Trigger action for the window closing
346
         ActionManager.processEvent(CoreActionType.QUERY_CLOSED, null, this);
339
         ActionManager.processEvent(CoreActionType.QUERY_CLOSED, null, this);
347
-        
348
-        if (server != null && shouldRemove) {
349
-            server.delQuery(this);
350
-        }
351
-        
352
-        if (window != null) {
353
-            Main.getUI().getMainWindow().delChild(window);
354
-            WindowManager.removeWindow(window);
355
-            window.close();
356
-            window.setVisible(false);
357
-        }
358
-        
340
+
341
+        // 5: Inform any parents that the window is closing
342
+        server.delQuery(this);
343
+
344
+        // 6: Remove the window from the window manager
345
+        WindowManager.removeWindow(window);
346
+
347
+        // 7: Remove any references to the window and parents
359
         window = null;
348
         window = null;
360
         server = null;
349
         server = null;
361
     }
350
     }
362
-    
351
+
363
     /**
352
     /**
364
      * Returns this query's name.
353
      * Returns this query's name.
365
      *
354
      *
369
     public String toString() {
358
     public String toString() {
370
         return ClientInfo.parseHost(host);
359
         return ClientInfo.parseHost(host);
371
     }
360
     }
372
-    
361
+
373
     /**
362
     /**
374
      * Returns the host that this query is with.
363
      * Returns the host that this query is with.
375
      *
364
      *
378
     public String getHost() {
367
     public String getHost() {
379
         return host;
368
         return host;
380
     }
369
     }
381
-    
370
+
382
     /**
371
     /**
383
      * Returns the current nickname of the user that this query is with.
372
      * Returns the current nickname of the user that this query is with.
384
-     * 
373
+     *
385
      * @return The nickname of this query's user
374
      * @return The nickname of this query's user
386
      */
375
      */
387
     public String getNickname() {
376
     public String getNickname() {
388
         return ClientInfo.parseHost(host);
377
         return ClientInfo.parseHost(host);
389
     }
378
     }
390
-    
379
+
391
     /** {@inheritDoc} */
380
     /** {@inheritDoc} */
392
     @Override
381
     @Override
393
     public void activateFrame() {
382
     public void activateFrame() {
394
         if (window == null) {
383
         if (window == null) {
395
             return;
384
             return;
396
         }
385
         }
397
-        
386
+
398
         if (!window.isVisible()) {
387
         if (!window.isVisible()) {
399
             show();
388
             show();
400
         }
389
         }
401
-        
390
+
402
         Main.getUI().getMainWindow().setActiveFrame(window);
391
         Main.getUI().getMainWindow().setActiveFrame(window);
403
     }
392
     }
404
-    
393
+
405
     /** {@inheritDoc} */
394
     /** {@inheritDoc} */
406
     @Override
395
     @Override
407
     public ConfigManager getConfigManager() {
396
     public ConfigManager getConfigManager() {
410
                     " from a query with no server", new IllegalStateException("My host: " + host));
399
                     " from a query with no server", new IllegalStateException("My host: " + host));
411
             return IdentityManager.getGlobalConfig();
400
             return IdentityManager.getGlobalConfig();
412
         }
401
         }
413
-        
402
+
414
         return server.getConfigManager();
403
         return server.getConfigManager();
415
-    }    
416
-    
404
+    }
405
+
417
 }
406
 }

+ 22
- 8
src/com/dmdirc/Raw.java View File

92
     
92
     
93
     /** {@inheritDoc} */
93
     /** {@inheritDoc} */
94
     @Override
94
     @Override
95
-    public void close() {
96
-        if (server.getParser() != null) {
97
-            server.getParser().getCallbackManager().delCallback("OnDataIn", this);
98
-            server.getParser().getCallbackManager().delCallback("OnDataOut", this);
95
+    public void windowClosing() {
96
+        // 1: Make the window non-visible
97
+        window.setVisible(false);
98
+        
99
+        // 2: Remove any callbacks or listeners
100
+        if (server != null && server.getParser() != null) {
101
+            server.getParser().getCallbackManager().delAllCallback(this);
99
         }
102
         }
100
         
103
         
101
-        window.setVisible(false);
102
-        WindowManager.removeWindow(window);
103
-        Main.getUI().getMainWindow().delChild(window);
104
+        // 3: Trigger any actions neccessary
105
+        // 4: Trigger action for the window closing
104
         
106
         
107
+        // 5: Inform any parents that the window is closing
105
         server.delRaw();
108
         server.delRaw();
106
-        window.close();
109
+        
110
+        // 6: Remove the window from the window manager
111
+        WindowManager.removeWindow(window);
112
+        
113
+        // 7: Remove any references to the window and parents
107
         window = null;
114
         window = null;
108
         server = null;
115
         server = null;
109
     }
116
     }
110
     
117
     
111
     /** {@inheritDoc} */
118
     /** {@inheritDoc} */
119
+    @Override
112
     public InputWindow getFrame() {
120
     public InputWindow getFrame() {
113
         return window;
121
         return window;
114
     }
122
     }
115
     
123
     
116
     /** {@inheritDoc} */
124
     /** {@inheritDoc} */
125
+    @Override
117
     public void onDataIn(final IRCParser tParser, final String sData) {
126
     public void onDataIn(final IRCParser tParser, final String sData) {
118
         addLine("rawIn", sData);
127
         addLine("rawIn", sData);
119
     }
128
     }
120
     
129
     
121
     /** {@inheritDoc} */
130
     /** {@inheritDoc} */
131
+    @Override
122
     public void onDataOut(final IRCParser tParser, final String sData,
132
     public void onDataOut(final IRCParser tParser, final String sData,
123
             final boolean bFromParser) {
133
             final boolean bFromParser) {
124
         addLine("rawOut", sData);
134
         addLine("rawOut", sData);
125
     }
135
     }
126
     
136
     
127
     /** {@inheritDoc} */
137
     /** {@inheritDoc} */
138
+    @Override
128
     public String toString() {
139
     public String toString() {
129
         return "Raw";
140
         return "Raw";
130
     }
141
     }
131
     
142
     
132
     /** {@inheritDoc} */
143
     /** {@inheritDoc} */
144
+    @Override
133
     public Server getServer() {
145
     public Server getServer() {
134
         return server;
146
         return server;
135
     }
147
     }
136
     
148
     
137
     /** {@inheritDoc} */
149
     /** {@inheritDoc} */
150
+    @Override
138
     public void sendLine(final String line) {
151
     public void sendLine(final String line) {
139
         server.sendLine(window.getTranscoder().encode(line));
152
         server.sendLine(window.getTranscoder().encode(line));
140
     }
153
     }
141
     
154
     
142
     /** {@inheritDoc} */
155
     /** {@inheritDoc} */
156
+    @Override
143
     public int getMaxLineLength() {
157
     public int getMaxLineLength() {
144
         return server.getMaxLineLength();
158
         return server.getMaxLineLength();
145
     }
159
     }

+ 32
- 38
src/com/dmdirc/Server.java View File

296
     public void reconnect() {
296
     public void reconnect() {
297
         reconnect(configManager.getOption(DOMAIN_GENERAL, "reconnectmessage"));
297
         reconnect(configManager.getOption(DOMAIN_GENERAL, "reconnectmessage"));
298
     }
298
     }
299
+    
300
+    /**
301
+     * Disconnects from the server with the default quit message.
302
+     */
303
+    public void disconnect() {
304
+        disconnect(configManager.getOption(DOMAIN_GENERAL, "quitmessage"));
305
+    }
299
 
306
 
300
     /**
307
     /**
301
      * Disconnects from the server.
308
      * Disconnects from the server.
800
         return myState;
807
         return myState;
801
     }
808
     }
802
 
809
 
803
-    /**
804
-     * Closes this server connection and associated windows.
805
-     *
806
-     * @param reason reason for closing
807
-     */
808
-    public void close(final String reason) {
810
+    /** {@inheritDoc} */
811
+    @Override
812
+    public void windowClosing() {
813
+        // 1: Make the window non-visible
814
+        window.setVisible(false);
815
+        
816
+        // 2: Remove any callbacks or listeners
809
         if (parser != null) {
817
         if (parser != null) {
810
-            // Unregister parser callbacks
811
             parser.getCallbackManager().delAllCallback(eventHandler);
818
             parser.getCallbackManager().delAllCallback(eventHandler);
812
         }
819
         }
813
-
814
-        // Disconnect from the server
815
-        disconnect(reason);
816
-
820
+        
821
+        // 3: Trigger any actions neccessary
822
+        if (parser != null && parser.isReady()) {
823
+            disconnect();
824
+        }
825
+        
817
         myState = ServerState.CLOSING;
826
         myState = ServerState.CLOSING;
818
-
819
-        // Close all channel windows
820
         closeChannels();
827
         closeChannels();
821
-        // Close all query windows
822
         closeQueries();
828
         closeQueries();
823
-        // Close the raw window
829
+
824
         if (raw != null) {
830
         if (raw != null) {
825
             raw.close();
831
             raw.close();
826
         }
832
         }
827
         
833
         
828
-        // Unregister ourselves with the server manager
834
+        
835
+        // 4: Trigger action for the window closing
836
+        // 5: Inform any parents that the window is closing
829
         ServerManager.getServerManager().unregisterServer(this);
837
         ServerManager.getServerManager().unregisterServer(this);
830
-
831
-        if (window != null) {
832
-            window.setVisible(false);
833
-            WindowManager.removeWindow(window);
834
-            Main.getUI().getMainWindow().delChild(window);
835
-            window.close();
836
-            window = null; //NOPMD
837
-        }
838
-
839
-        // Ditch the parser
838
+        
839
+        // 6: Remove the window from the window manager
840
+        WindowManager.removeWindow(window);
841
+        
842
+        // 7: Remove any references to the window and parents
843
+        window = null; //NOPMD
840
         parser = null; //NOPMD
844
         parser = null; //NOPMD
841
     }
845
     }
842
 
846
 
843
-    /** {@inheritDoc} */
844
-    @Override
845
-    public void close() {
846
-        close(configManager.getOption(DOMAIN_GENERAL, "quitmessage"));
847
-    }
848
-
849
     /**
847
     /**
850
      * Closes all open channel windows associated with this server.
848
      * Closes all open channel windows associated with this server.
851
      */
849
      */
852
     private void closeChannels() {
850
     private void closeChannels() {
853
         for (Channel channel : new ArrayList<Channel>(channels.values())) {
851
         for (Channel channel : new ArrayList<Channel>(channels.values())) {
854
-            channel.closeWindow(false);
852
+            channel.close();
855
         }
853
         }
856
-
857
-        channels.clear();
858
     }
854
     }
859
 
855
 
860
     /**
856
     /**
871
      */
867
      */
872
     private void closeQueries() {
868
     private void closeQueries() {
873
         for (Query query : new ArrayList<Query>(queries)) {
869
         for (Query query : new ArrayList<Query>(queries)) {
874
-            query.close(false);
870
+            query.close();
875
         }
871
         }
876
-
877
-        queries.clear();
878
     }
872
     }
879
 
873
 
880
     /**
874
     /**

+ 8
- 20
src/com/dmdirc/ServerManager.java View File

23
 package com.dmdirc;
23
 package com.dmdirc;
24
 
24
 
25
 import com.dmdirc.config.IdentityManager;
25
 import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.ui.WindowManager;
27
 import com.dmdirc.ui.interfaces.Window;
26
 import com.dmdirc.ui.interfaces.Window;
28
 
27
 
29
 import java.util.ArrayList;
28
 import java.util.ArrayList;
40
     /** Singleton instance of ServerManager. */
39
     /** Singleton instance of ServerManager. */
41
     private static ServerManager me;
40
     private static ServerManager me;
42
     
41
     
43
-    /**
44
-     * Indicates that the server manager is in the process of closing all
45
-     * servers. Used to prevent concurrent access to the servers property.
46
-     */
47
-    private boolean closing;
48
-    
49
     /** All servers that currently exist. */
42
     /** All servers that currently exist. */
50
     private final List<Server> servers = new ArrayList<Server>();
43
     private final List<Server> servers = new ArrayList<Server>();
51
     
44
     
83
      * @param server The server to be unregistered
76
      * @param server The server to be unregistered
84
      */
77
      */
85
     public void unregisterServer(final Server server) {
78
     public void unregisterServer(final Server server) {
86
-        if (!closing) {
87
-            servers.remove(server);
88
-        }
79
+        servers.remove(server);
89
     }
80
     }
90
     
81
     
91
     /**
82
     /**
112
      * Closes all servers with a default quit message.
103
      * Closes all servers with a default quit message.
113
      */
104
      */
114
     public void closeAll() {
105
     public void closeAll() {
115
-        closing = true;
116
-        for (Server server : servers) {
117
-            server.close(server.getConfigManager().getOption("general", "quitmessage"));
106
+        for (Server server : new ArrayList<Server>(servers)) {
107
+            server.disconnect();
108
+            server.close();
118
         }
109
         }
119
-        closing = false;
120
-        servers.clear();
121
     }
110
     }
122
     
111
     
123
     /**
112
     /**
126
      * @param message The quit message to send to the IRC servers
115
      * @param message The quit message to send to the IRC servers
127
      */
116
      */
128
     public void closeAll(final String message) {
117
     public void closeAll(final String message) {
129
-        closing = true;
130
-        for (Server server : servers) {
131
-            server.close(message);
118
+        for (Server server : new ArrayList<Server>(servers)) {
119
+            server.disconnect(message);
120
+            server.close();
132
         }
121
         }
133
-        closing = false;
134
-        servers.clear();
135
     }
122
     }
136
     
123
     
137
     /**
124
     /**
155
                 return server;
142
                 return server;
156
             }
143
             }
157
         }
144
         }
145
+        
158
         return null;
146
         return null;
159
     }
147
     }
160
     
148
     

+ 3
- 2
src/com/dmdirc/addons/dcc/DCCChatWindow.java View File

110
 	/**
110
 	/**
111
 	 * Closes this container (and it's associated frame).
111
 	 * Closes this container (and it's associated frame).
112
 	 */
112
 	 */
113
-	public void close() {
113
+        @Override
114
+	public void windowClosing() {
114
 		dcc.close();
115
 		dcc.close();
115
-		super.close();
116
+		super.windowClosing();
116
 	}
117
 	}
117
 }
118
 }

+ 27
- 19
src/com/dmdirc/addons/dcc/DCCFrame.java View File

22
 
22
 
23
 package com.dmdirc.addons.dcc;
23
 package com.dmdirc.addons.dcc;
24
 
24
 
25
+import com.dmdirc.IconManager;
26
+import com.dmdirc.Server;
25
 import com.dmdirc.WritableFrameContainer;
27
 import com.dmdirc.WritableFrameContainer;
26
-import com.dmdirc.config.ConfigManager;
27
-import com.dmdirc.config.IdentityManager;
28
-import com.dmdirc.ui.swing.components.InputTextFrame;
29
-import com.dmdirc.Main;
30
 import com.dmdirc.commandparser.CommandManager;
28
 import com.dmdirc.commandparser.CommandManager;
31
-import com.dmdirc.commandparser.parsers.GlobalCommandParser;
32
-import com.dmdirc.commandparser.parsers.CommandParser;
33
 import com.dmdirc.commandparser.commands.Command;
29
 import com.dmdirc.commandparser.commands.Command;
34
 import com.dmdirc.commandparser.commands.GlobalCommand;
30
 import com.dmdirc.commandparser.commands.GlobalCommand;
35
-
36
-import com.dmdirc.IconManager;
37
-import com.dmdirc.Server;
31
+import com.dmdirc.commandparser.parsers.CommandParser;
32
+import com.dmdirc.commandparser.parsers.GlobalCommandParser;
33
+import com.dmdirc.config.ConfigManager;
34
+import com.dmdirc.config.IdentityManager;
38
 import com.dmdirc.ui.WindowManager;
35
 import com.dmdirc.ui.WindowManager;
39
 import com.dmdirc.ui.interfaces.InputWindow;
36
 import com.dmdirc.ui.interfaces.InputWindow;
37
+import com.dmdirc.ui.swing.components.InputTextFrame;
40
 
38
 
41
 /**
39
 /**
42
  * This class links DCC objects to a window.
40
  * This class links DCC objects to a window.
81
 		private static final long serialVersionUID = 200711271;
79
 		private static final long serialVersionUID = 200711271;
82
 		
80
 		
83
 		/** Loads the relevant commands into the parser. */
81
 		/** Loads the relevant commands into the parser. */
82
+        @Override
84
 		protected void loadCommands() { CommandManager.loadGlobalCommands(this); }
83
 		protected void loadCommands() { CommandManager.loadGlobalCommands(this); }
85
 		
84
 		
86
 		/**
85
 		/**
91
 		 * @param command The command to be executed
90
 		 * @param command The command to be executed
92
 		 * @param args The arguments to the command
91
 		 * @param args The arguments to the command
93
 		 */
92
 		 */
93
+        @Override
94
 		protected void executeCommand(final InputWindow origin, final boolean isSilent, final Command command, final String... args) {
94
 		protected void executeCommand(final InputWindow origin, final boolean isSilent, final Command command, final String... args) {
95
 			((GlobalCommand) command).execute(origin, isSilent, args);
95
 			((GlobalCommand) command).execute(origin, isSilent, args);
96
 		}
96
 		}
103
 		 * @param origin The window in which the command was typed
103
 		 * @param origin The window in which the command was typed
104
 		 * @param line The line input by the user
104
 		 * @param line The line input by the user
105
 		 */
105
 		 */
106
+        @Override
106
 		protected void handleNonCommand(final InputWindow origin, final String line) {
107
 		protected void handleNonCommand(final InputWindow origin, final String line) {
107
 			if (origin.getContainer() instanceof WritableFrameContainer) {
108
 			if (origin.getContainer() instanceof WritableFrameContainer) {
108
 				((WritableFrameContainer)origin.getContainer()).sendLine(line);
109
 				((WritableFrameContainer)origin.getContainer()).sendLine(line);
225
 		return null;
226
 		return null;
226
 	}
227
 	}
227
 	
228
 	
228
-	/**
229
-	 * Closes this container (and it's associated frame).
230
-	 */
229
+	/** {@inheritDoc} */
231
 	@Override
230
 	@Override
232
-	public void close() {
233
-		plugin.delWindow(this);
234
-		myWindow.setVisible(false);
235
-		Main.getUI().getMainWindow().delChild(myWindow);
236
-		WindowManager.removeWindow(myWindow);
237
-                myWindow.close();
238
-                myWindow = null;
231
+	public void windowClosing() {
232
+                // 1: Make the window non-visible
233
+                myWindow.setVisible(false);
234
+
235
+                // 2: Remove any callbacks or listeners
236
+                // 3: Trigger any actions neccessary
237
+                // 4: Trigger action for the window closing
238
+                
239
+                // 5: Inform any parents that the window is closing
240
+                plugin.delWindow(this);
241
+
242
+                // 6: Remove the window from the window manager
243
+                WindowManager.removeWindow(myWindow);
244
+
245
+                // 7: Remove any references to the window and parents
246
+                myWindow = null; // NOPMD
239
 	}   
247
 	}   
240
 }
248
 }

+ 4
- 7
src/com/dmdirc/addons/dcc/DCCSendWindow.java View File

22
 
22
 
23
 package com.dmdirc.addons.dcc;
23
 package com.dmdirc.addons.dcc;
24
 
24
 
25
-import com.dmdirc.WritableFrameContainer;
26
-import com.dmdirc.IconManager;
27
-import com.dmdirc.Main;
28
-import com.dmdirc.Server;
29
-import com.dmdirc.config.IdentityManager;
30
 import com.dmdirc.ui.swing.JWrappingLabel;
25
 import com.dmdirc.ui.swing.JWrappingLabel;
31
 import com.dmdirc.ui.swing.components.TextFrame;
26
 import com.dmdirc.ui.swing.components.TextFrame;
27
+
32
 import javax.swing.SwingConstants;
28
 import javax.swing.SwingConstants;
29
+
33
 /**
30
 /**
34
  * This class links DCC Send objects to a window.
31
  * This class links DCC Send objects to a window.
35
  *
32
  *
89
 	/**
86
 	/**
90
 	 * Closes this container (and it's associated frame).
87
 	 * Closes this container (and it's associated frame).
91
 	 */
88
 	 */
92
-	public void close() {
89
+	public void windowClosing() {
93
 		dcc.close();
90
 		dcc.close();
94
-		super.close();
91
+		super.windowClosing();
95
 	}
92
 	}
96
 }
93
 }

+ 30
- 16
src/com/dmdirc/addons/logging/HistoryWindow.java View File

44
     private final String title;
44
     private final String title;
45
        
45
        
46
     /** The window we're using. */
46
     /** The window we're using. */
47
-    private Window myWindow;
47
+    private Window window;
48
     
48
     
49
     /** Our parent window. */
49
     /** Our parent window. */
50
-    private final Window parent;
50
+    private Window parent;
51
     
51
     
52
     /**
52
     /**
53
      * Creates a new HistoryWindow.
53
      * Creates a new HistoryWindow.
64
         
64
         
65
         icon = IconManager.getIconManager().getIcon("raw");
65
         icon = IconManager.getIconManager().getIcon("raw");
66
         
66
         
67
-        myWindow = Main.getUI().getWindow(this);
67
+        window = Main.getUI().getWindow(this);
68
         
68
         
69
-        WindowManager.addWindow(parent, myWindow);
69
+        WindowManager.addWindow(parent, window);
70
         
70
         
71
-        myWindow.setTitle(title);
72
-        myWindow.setFrameIcon(icon);
73
-        myWindow.setVisible(true);
71
+        window.setTitle(title);
72
+        window.setFrameIcon(icon);
73
+        window.setVisible(true);
74
         
74
         
75
         final Stack<String> lines = reader.getLines(
75
         final Stack<String> lines = reader.getLines(
76
-                IdentityManager.getGlobalConfig().getOptionInt("plugin-Logging", "history.lines", 50000));
76
+                IdentityManager.getGlobalConfig().getOptionInt("plugin-Logging",
77
+                "history.lines", 50000));
77
         while (lines.size() > 0) {
78
         while (lines.size() > 0) {
78
-            myWindow.addLine(lines.pop(), false);
79
+            window.addLine(lines.pop(), false);
79
         }
80
         }
80
     }
81
     }
81
     
82
     
82
     /** {@inheritDoc} */
83
     /** {@inheritDoc} */
84
+    @Override
83
     public Window getFrame() {
85
     public Window getFrame() {
84
-        return myWindow;
86
+        return window;
85
     }
87
     }
86
     
88
     
87
     /** {@inheritDoc} */
89
     /** {@inheritDoc} */
90
+    @Override
88
     public String toString() {
91
     public String toString() {
89
         return title;
92
         return title;
90
     }
93
     }
91
     
94
     
92
     /** {@inheritDoc} */
95
     /** {@inheritDoc} */
93
-    public void close() {
94
-        myWindow.setVisible(false);
95
-        Main.getUI().getMainWindow().delChild(myWindow);
96
-        WindowManager.removeWindow(myWindow);
97
-        myWindow.close();
98
-        myWindow = null;
96
+    @Override
97
+    public void windowClosing() {
98
+        // 1: Make the window non-visible
99
+        window.setVisible(false);
100
+        
101
+        // 2: Remove any callbacks or listeners
102
+        // 3: Trigger any actions neccessary
103
+        // 4: Trigger action for the window closing
104
+        // 5: Inform any parents that the window is closing
105
+        
106
+        // 6: Remove the window from the window manager
107
+        WindowManager.removeWindow(window);
108
+        
109
+        // 7: Remove any references to the window and parents
110
+        window = null; // NOPMD
111
+        parent = null; // NOPMD
99
     }
112
     }
100
     
113
     
101
     /** {@inheritDoc} */
114
     /** {@inheritDoc} */
115
+    @Override
102
     public Server getServer() {
116
     public Server getServer() {
103
         return parent.getContainer().getServer();
117
         return parent.getContainer().getServer();
104
     }
118
     }

+ 1
- 1
src/com/dmdirc/commandparser/commands/channel/Part.java View File

47
             final Channel channel, final boolean isSilent, final String... args) {
47
             final Channel channel, final boolean isSilent, final String... args) {
48
         channel.part(args.length > 0 ? implodeArgs(args)
48
         channel.part(args.length > 0 ? implodeArgs(args)
49
                 : origin.getConfigManager().getOption("general", "partmessage"));
49
                 : origin.getConfigManager().getOption("general", "partmessage"));
50
-        channel.closeWindow();
50
+        channel.close();
51
     }
51
     }
52
     
52
     
53
     /** {@inheritDoc} */
53
     /** {@inheritDoc} */

Loading…
Cancel
Save