Browse Source

EDT EDT EDT EDT EDT DEAR GOD THE EDT.

Change-Id: I82a1ed787e47777cfafe5073df47cebe37b1f943
Reviewed-on: http://gerrit.dmdirc.com/876
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.4
Gregory Holmes 14 years ago
parent
commit
0e001a7b99
20 changed files with 577 additions and 242 deletions
  1. 11
    1
      src/com/dmdirc/addons/mediasource_vlc/VlcMediaSourcePlugin.java
  2. 94
    65
      src/com/dmdirc/addons/nickcolours/NickColourPlugin.java
  3. 16
    5
      src/com/dmdirc/addons/nowplaying/ConfigPanel.java
  4. 10
    1
      src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java
  5. 21
    11
      src/com/dmdirc/addons/ui_swing/components/SwingInputHandler.java
  6. 29
    19
      src/com/dmdirc/addons/ui_swing/components/TopicBar.java
  7. 26
    4
      src/com/dmdirc/addons/ui_swing/components/addonbrowser/DownloaderWindow.java
  8. 8
    1
      src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java
  9. 49
    29
      src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java
  10. 22
    10
      src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java
  11. 13
    6
      src/com/dmdirc/addons/ui_swing/components/pluginpanel/PluginPanel.java
  12. 8
    1
      src/com/dmdirc/addons/ui_swing/components/statusbar/StatusbarPopupPanel.java
  13. 16
    9
      src/com/dmdirc/addons/ui_swing/components/themepanel/ThemePanel.java
  14. 19
    4
      src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java
  15. 26
    11
      src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java
  16. 56
    25
      src/com/dmdirc/addons/ui_swing/dialogs/prefs/PrefsCategoryLoader.java
  17. 6
    5
      src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/FrameContainerMenuItem.java
  18. 125
    33
      src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java
  19. 9
    1
      src/com/dmdirc/addons/windowstatus/WindowStatusPanel.java
  20. 13
    1
      src/com/dmdirc/addons/windowstatus/WindowStatusPlugin.java

+ 11
- 1
src/com/dmdirc/addons/mediasource_vlc/VlcMediaSourcePlugin.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.mediasource_vlc;
24 24
 
25 25
 import com.dmdirc.addons.nowplaying.MediaSource;
26 26
 import com.dmdirc.addons.nowplaying.MediaSourceState;
27
+import com.dmdirc.addons.ui_swing.UIUtilities;
27 28
 import com.dmdirc.config.IdentityManager;
28 29
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
29 30
 import com.dmdirc.config.prefs.PreferencesCategory;
@@ -32,6 +33,7 @@ import com.dmdirc.config.prefs.PreferencesSetting;
32 33
 import com.dmdirc.config.prefs.PreferencesType;
33 34
 import com.dmdirc.plugins.Plugin;
34 35
 import com.dmdirc.util.Downloader;
36
+import com.dmdirc.util.ReturnableThread;
35 37
 
36 38
 import java.io.File;
37 39
 import java.io.IOException;
@@ -207,7 +209,15 @@ public class VlcMediaSourcePlugin extends Plugin implements MediaSource {
207 209
                 "", "category-vlc");
208 210
         final PreferencesCategory instr = new PluginPreferencesCategory(
209 211
                 getPluginInfo(), "Instructions",
210
-                "", new InstructionsPanel());
212
+                "", UIUtilities.invokeAndWait(
213
+                new ReturnableThread<InstructionsPanel>() {
214
+
215
+            /** {@inheritDoc} */
216
+            @Override
217
+            public void run() {
218
+                setObject(new InstructionsPanel());
219
+            }
220
+        }));
211 221
         
212 222
         general.addSetting(new PreferencesSetting(PreferencesType.TEXT, 
213 223
                 getDomain(), "host", "Hostname and port",

+ 94
- 65
src/com/dmdirc/addons/nickcolours/NickColourPlugin.java View File

@@ -27,6 +27,7 @@ import com.dmdirc.ChannelClientProperty;
27 27
 import com.dmdirc.actions.ActionManager;
28 28
 import com.dmdirc.actions.interfaces.ActionType;
29 29
 import com.dmdirc.actions.CoreActionType;
30
+import com.dmdirc.addons.ui_swing.UIUtilities;
30 31
 import com.dmdirc.config.IdentityManager;
31 32
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
32 33
 import com.dmdirc.config.prefs.PreferencesCategory;
@@ -40,6 +41,7 @@ import com.dmdirc.parser.interfaces.ChannelInfo;
40 41
 import com.dmdirc.parser.interfaces.ClientInfo;
41 42
 import com.dmdirc.plugins.Plugin;
42 43
 import com.dmdirc.ui.messages.ColourManager;
44
+import com.dmdirc.util.ReturnableThread;
43 45
 
44 46
 import java.awt.Color;
45 47
 import java.util.ArrayList;
@@ -53,85 +55,94 @@ import java.util.Map;
53 55
  */
54 56
 public final class NickColourPlugin extends Plugin implements ActionListener,
55 57
         ConfigChangeListener {
56
-    
58
+
57 59
     /** "Random" colours to use to colour nicknames. */
58
-    private String[] randColours = new String[] {
60
+    private String[] randColours = new String[]{
59 61
         "E90E7F", "8E55E9", "B30E0E", "18B33C",
60
-        "58ADB3", "9E54B3", "B39875", "3176B3",
61
-    };
62
+        "58ADB3", "9E54B3", "B39875", "3176B3",};
62 63
     private boolean useowncolour;
63 64
     private String owncolour;
64 65
     private boolean userandomcolour;
65 66
     private boolean settext;
66 67
     private boolean setnicklist;
67
-    
68
+
68 69
     /** Creates a new instance of NickColourPlugin. */
69 70
     public NickColourPlugin() {
70 71
         super();
71 72
     }
72
-    
73
+
73 74
     /** {@inheritDoc} */
74 75
     @Override
75 76
     public void processEvent(final ActionType type, final StringBuffer format,
76 77
             final Object... arguments) {
77 78
         if (type.equals(CoreActionType.CHANNEL_GOTNAMES)) {
78
-            final ChannelInfo chanInfo = ((Channel) arguments[0]).getChannelInfo();
79
-            final String network = ((Channel) arguments[0]).getServer().getNetwork();
80
-            
79
+            final ChannelInfo chanInfo =
80
+                    ((Channel) arguments[0]).getChannelInfo();
81
+            final String network = ((Channel) arguments[0]).getServer().
82
+                    getNetwork();
83
+
81 84
             for (ChannelClientInfo client : chanInfo.getChannelClients()) {
82 85
                 colourClient(network, client);
83 86
             }
84 87
         } else if (type.equals(CoreActionType.CHANNEL_JOIN)) {
85
-            final String network = ((Channel) arguments[0]).getServer().getNetwork();
86
-            
88
+            final String network = ((Channel) arguments[0]).getServer().
89
+                    getNetwork();
90
+
87 91
             colourClient(network, (ChannelClientInfo) arguments[1]);
88 92
         }
89 93
     }
90
-    
94
+
91 95
     /**
92 96
      * Colours the specified client according to the user's config.
93 97
      *
94 98
      * @param network The network to use for the colouring
95 99
      * @param client The client to be coloured
96 100
      */
97
-    private void colourClient(final String network, final ChannelClientInfo client) {
101
+    private void colourClient(final String network,
102
+            final ChannelClientInfo client) {
98 103
         final Map map = client.getMap();
99
-        final ClientInfo myself = client.getClient().getParser().getLocalClient();
104
+        final ClientInfo myself =
105
+                client.getClient().getParser().getLocalClient();
100 106
         final String nickOption1 = "color:"
101
-                + client.getClient().getParser().getStringConverter().toLowerCase(network + ":" + client.getClient().getNickname());
107
+                + client.getClient().getParser().getStringConverter().
108
+                toLowerCase(network + ":" + client.getClient().getNickname());
102 109
         final String nickOption2 = "color:"
103
-                + client.getClient().getParser().getStringConverter().toLowerCase("*:" + client.getClient().getNickname());
104
-        
110
+                + client.getClient().getParser().getStringConverter().
111
+                toLowerCase("*:" + client.getClient().getNickname());
112
+
105 113
         if (useowncolour && client.getClient().equals(myself)) {
106 114
             final Color color = ColourManager.parseColour(owncolour);
107 115
             putColour(map, color, color);
108
-        }  else if (userandomcolour) {
109
-            putColour(map, getColour(client.getClient().getNickname()), getColour(client.getClient().getNickname()));
116
+        } else if (userandomcolour) {
117
+            putColour(map, getColour(client.getClient().getNickname()), getColour(client.
118
+                    getClient().getNickname()));
110 119
         }
111
-        
120
+
112 121
         String[] parts = null;
113
-                
114
-        if (IdentityManager.getGlobalConfig().hasOptionString(getDomain(), nickOption1)) {
122
+
123
+        if (IdentityManager.getGlobalConfig().hasOptionString(getDomain(),
124
+                nickOption1)) {
115 125
             parts = getParts(nickOption1);
116
-        } else if (IdentityManager.getGlobalConfig().hasOptionString(getDomain(), nickOption2)) {
126
+        } else if (IdentityManager.getGlobalConfig().hasOptionString(
127
+                getDomain(), nickOption2)) {
117 128
             parts = getParts(nickOption2);
118 129
         }
119
-        
130
+
120 131
         if (parts != null) {
121 132
             Color textColor = null;
122 133
             Color nickColor = null;
123
-            
134
+
124 135
             if (parts[0] != null) {
125 136
                 textColor = ColourManager.parseColour(parts[0], null);
126 137
             }
127 138
             if (parts[1] != null) {
128 139
                 nickColor = ColourManager.parseColour(parts[1], null);
129 140
             }
130
-            
141
+
131 142
             putColour(map, textColor, nickColor);
132 143
         }
133 144
     }
134
-    
145
+
135 146
     /**
136 147
      * Puts the specified colour into the given map. The keys are determined
137 148
      * by config settings.
@@ -141,16 +152,17 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
141 152
      * @param nickColour Nick colour to be inserted
142 153
      */
143 154
     @SuppressWarnings("unchecked")
144
-    private void putColour(final Map map, final Color textColour, final Color nickColour) {
155
+    private void putColour(final Map map, final Color textColour,
156
+            final Color nickColour) {
145 157
         if (settext && textColour != null) {
146 158
             map.put(ChannelClientProperty.TEXT_FOREGROUND, textColour);
147 159
         }
148
-        
160
+
149 161
         if (setnicklist && nickColour != null) {
150 162
             map.put(ChannelClientProperty.NICKLIST_FOREGROUND, nickColour);
151 163
         }
152 164
     }
153
-    
165
+
154 166
     /**
155 167
      * Retrieves a pseudo-random colour for the specified nickname.
156 168
      *
@@ -159,16 +171,16 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
159 171
      */
160 172
     private Color getColour(final String nick) {
161 173
         int count = 0;
162
-        
174
+
163 175
         for (int i = 0; i < nick.length(); i++) {
164 176
             count += nick.charAt(i);
165 177
         }
166
-        
178
+
167 179
         count = count % randColours.length;
168
-        
180
+
169 181
         return ColourManager.parseColour(randColours[count]);
170 182
     }
171
-    
183
+
172 184
     /**
173 185
      * Reads the nick colour data from the config.
174 186
      *
@@ -176,30 +188,31 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
176 188
      */
177 189
     public Object[][] getData() {
178 190
         final List<Object[]> data = new ArrayList<Object[]>();
179
-        
180
-        for (String key : IdentityManager.getGlobalConfig().getOptions(getDomain()).keySet()) {
191
+
192
+        for (String key : IdentityManager.getGlobalConfig().getOptions(
193
+                getDomain()).keySet()) {
181 194
             if (key.startsWith("color:")) {
182 195
                 final String network = key.substring(6, key.indexOf(':', 6));
183 196
                 final String user = key.substring(1 + key.indexOf(':', 6));
184 197
                 final String[] parts = getParts(key);
185
-                
186
-                
198
+
199
+
187 200
                 data.add(new Object[]{network, user, parts[0], parts[1]});
188 201
             }
189 202
         }
190
-        
203
+
191 204
         final Object[][] res = new Object[data.size()][4];
192
-        
205
+
193 206
         int i = 0;
194 207
         for (Object[] row : data) {
195 208
             res[i] = row;
196
-            
209
+
197 210
             i++;
198 211
         }
199
-        
212
+
200 213
         return res;
201 214
     }
202
-    
215
+
203 216
     /**
204 217
      * Retrieves the config option with the specified key, and returns an
205 218
      * array of the colours that should be used for it.
@@ -208,17 +221,18 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
208 221
      * @return The colours specified by the given key
209 222
      */
210 223
     private String[] getParts(final String key) {
211
-        String[] parts = IdentityManager.getGlobalConfig().getOption(getDomain(), key).split(":");
212
-        
224
+        String[] parts = IdentityManager.getGlobalConfig().getOption(getDomain(),
225
+                key).split(":");
226
+
213 227
         if (parts.length == 0) {
214 228
             parts = new String[]{null, null};
215 229
         } else if (parts.length == 1) {
216 230
             parts = new String[]{parts[0], null};
217 231
         }
218
-        
232
+
219 233
         return parts;
220 234
     }
221
-    
235
+
222 236
     /** {@inheritDoc} */
223 237
     @Override
224 238
     public void onLoad() {
@@ -226,13 +240,13 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
226 240
         ActionManager.addListener(this, CoreActionType.CHANNEL_GOTNAMES,
227 241
                 CoreActionType.CHANNEL_JOIN);
228 242
     }
229
-    
243
+
230 244
     /** {@inheritDoc} */
231 245
     @Override
232 246
     public void onUnload() {
233 247
         ActionManager.removeListener(this);
234 248
     }
235
-    
249
+
236 250
     /** {@inheritDoc} */
237 251
     @Override
238 252
     public void showConfig(final PreferencesManager manager) {
@@ -241,14 +255,22 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
241 255
                 "General configuration for NickColour plugin.");
242 256
         final PreferencesCategory colours = new PluginPreferencesCategory(
243 257
                 getPluginInfo(), "Colours",
244
-                "Set colours for specific nicknames.", new NickColourPanel(this));
245
-        
258
+                "Set colours for specific nicknames.", UIUtilities.invokeAndWait(
259
+                new ReturnableThread<NickColourPanel>() {
260
+
261
+                    /** {@inheritDoc} */
262
+                    @Override
263
+                    public void run() {
264
+                        setObject(new NickColourPanel(NickColourPlugin.this));
265
+                    }
266
+                }));
267
+
246 268
         general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
247
-                "ui", "shownickcoloursintext", "Show colours in text" +
248
-                "area", "Colour nicknames in main text area?"));
269
+                "ui", "shownickcoloursintext", "Show colours in text" + "area",
270
+                "Colour nicknames in main text area?"));
249 271
         general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
250
-                "ui", "shownickcoloursinnicklist", "Show colours in" +
251
-                " nick list", "Colour nicknames in channel nick lists?"));
272
+                "ui", "shownickcoloursinnicklist", "Show colours in"
273
+                + " nick list", "Colour nicknames in channel nick lists?"));
252 274
         general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
253 275
                 getDomain(), "settext", "Set colours in textarea",
254 276
                 "Should the plugin set the textarea colour of nicks?"));
@@ -261,22 +283,30 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
261 283
         general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
262 284
                 getDomain(), "useowncolour", "Use colour for own nick",
263 285
                 "Always use the same colour for our own nickname?"));
264
-        general.addSetting(new PreferencesSetting(PreferencesType.COLOUR,
286
+        general.addSetting(
287
+                new PreferencesSetting(PreferencesType.COLOUR,
265 288
                 getDomain(), "owncolour", "Colour to use for own nick",
266
-                "Colour used for our own nickname, if above setting is enabled."));        
289
+                "Colour used for our own nickname, if above setting is enabled."));
267 290
 
268 291
         general.addSubCategory(colours);
269 292
         manager.getCategory("Plugins").addSubCategory(general);
270 293
     }
271 294
 
272 295
     private void setCachedSettings() {
273
-        useowncolour = IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "useowncolour");
274
-        owncolour = IdentityManager.getGlobalConfig().getOption(getDomain(), "owncolour");
275
-        userandomcolour = IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "userandomcolour");
276
-        settext = IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "settext");
277
-        setnicklist = IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "setnicklist");
278
-        if (IdentityManager.getGlobalConfig().hasOptionString(getDomain(), "randomcolours")) {
279
-            randColours = IdentityManager.getGlobalConfig().getOptionList(getDomain(), "randomcolours").toArray(new String[0]);
296
+        useowncolour = IdentityManager.getGlobalConfig().getOptionBool(
297
+                getDomain(), "useowncolour");
298
+        owncolour = IdentityManager.getGlobalConfig().getOption(getDomain(),
299
+                "owncolour");
300
+        userandomcolour = IdentityManager.getGlobalConfig().getOptionBool(
301
+                getDomain(), "userandomcolour");
302
+        settext = IdentityManager.getGlobalConfig().getOptionBool(getDomain(),
303
+                "settext");
304
+        setnicklist = IdentityManager.getGlobalConfig().getOptionBool(
305
+                getDomain(), "setnicklist");
306
+        if (IdentityManager.getGlobalConfig().hasOptionString(getDomain(),
307
+                "randomcolours")) {
308
+            randColours = IdentityManager.getGlobalConfig().getOptionList(
309
+                    getDomain(), "randomcolours").toArray(new String[0]);
280 310
         }
281 311
     }
282 312
 
@@ -285,5 +315,4 @@ public final class NickColourPlugin extends Plugin implements ActionListener,
285 315
     public void configChanged(final String domain, final String key) {
286 316
         setCachedSettings();
287 317
     }
288
-    
289 318
 }

+ 16
- 5
src/com/dmdirc/addons/nowplaying/ConfigPanel.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.nowplaying;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.addons.ui_swing.components.reorderablelist.ListReorderButtonPanel;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 import com.dmdirc.config.prefs.PreferencesInterface;
@@ -30,6 +31,7 @@ import com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList;
30 31
 
31 32
 import com.dmdirc.logger.ErrorLevel;
32 33
 import com.dmdirc.logger.Logger;
34
+import com.dmdirc.util.ReturnableThread;
33 35
 import java.awt.event.KeyEvent;
34 36
 import java.awt.event.KeyListener;
35 37
 import java.util.Arrays;
@@ -148,20 +150,29 @@ public class ConfigPanel extends JPanel implements PreferencesInterface,
148 150
     private void updatePreview() {
149 151
         updateTimer.cancel();
150 152
 
151
-        MediaSource source = plugin.getBestSource();
153
+        final MediaSource source;
152 154
 
153
-        if (source == null) {
155
+        if (plugin.getBestSource() == null) {
154 156
             source = new DummyMediaSource();
157
+        } else {
158
+            source = plugin.getBestSource();
155 159
         }
156 160
 
157
-        preview.setText("Preview:\n" + plugin.doSubstitution(textfield.getText(),
158
-                source));
159
-        preview.repaint();
161
+        final String text = plugin.doSubstitution(
162
+                        UIUtilities.invokeAndWait(new ReturnableThread<String>() {
160 163
 
164
+                    @Override
165
+                    public void run() {
166
+                        setObject(textfield.getText());
167
+                    }
168
+                }), source);
161 169
         SwingUtilities.invokeLater(new Runnable() {
162 170
 
171
+            /** {@inheritDoc} */
163 172
             @Override
164 173
             public void run() {
174
+                preview.setText("Preview:\n" + text);
175
+                preview.repaint();
165 176
                 previewPanel.revalidate();
166 177
                 revalidate();
167 178
             }

+ 10
- 1
src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.addons.nowplaying;
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.interfaces.ActionType;
27 27
 import com.dmdirc.actions.CoreActionType;
28
+import com.dmdirc.addons.ui_swing.UIUtilities;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.config.IdentityManager;
30 31
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
@@ -34,6 +35,7 @@ import com.dmdirc.interfaces.ActionListener;
34 35
 import com.dmdirc.plugins.Plugin;
35 36
 import com.dmdirc.plugins.PluginInfo;
36 37
 import com.dmdirc.plugins.PluginManager;
38
+import com.dmdirc.util.ReturnableThread;
37 39
 
38 40
 import java.util.ArrayList;
39 41
 import java.util.Collections;
@@ -100,7 +102,14 @@ public class NowPlayingPlugin extends Plugin implements ActionListener  {
100 102
     /** {@inheritDoc} */
101 103
     @Override
102 104
     public void showConfig(final PreferencesManager manager) {
103
-        final ConfigPanel configPanel = new ConfigPanel(this, order);
105
+        final ConfigPanel configPanel = UIUtilities.invokeAndWait(
106
+                new ReturnableThread<ConfigPanel>() {
107
+
108
+            @Override
109
+            public void run() {
110
+                setObject(new ConfigPanel(NowPlayingPlugin.this, order));
111
+            }
112
+        });
104 113
         
105 114
         final PreferencesCategory category = new PluginPreferencesCategory(
106 115
                 getPluginInfo(), "Now Playing",

+ 21
- 11
src/com/dmdirc/addons/ui_swing/components/SwingInputHandler.java View File

@@ -87,7 +87,8 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
87 87
             localTarget.getInputMap(JComponent.WHEN_FOCUSED).
88 88
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upArrow");
89 89
         } else {
90
-            localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
90
+            localTarget.getInputMap(
91
+                    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
91 92
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upArrow");
92 93
         }
93 94
     }
@@ -120,7 +121,8 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
120 121
             localTarget.getInputMap(JComponent.WHEN_FOCUSED).
121 122
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downArrow");
122 123
         } else {
123
-            localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
124
+            localTarget.getInputMap(
125
+                    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
124 126
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downArrow");
125 127
         }
126 128
     }
@@ -226,17 +228,25 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
226 228
             public void actionPerformed(final ActionEvent e) {
227 229
                 final String line = target.getText();
228 230
                 target.setText("");
229
-                new LoggingSwingWorker() {
231
+                UIUtilities.invokeLater(new Runnable() {
230 232
 
231 233
                     /** {@inheritDoc} */
232 234
                     @Override
233
-                    protected Object doInBackground() throws Exception {
235
+                    public void run() {
234 236
                         if (((JTextField) e.getSource()).isEditable()) {
235
-                            enterPressed(line);
237
+                            new LoggingSwingWorker() {
238
+
239
+                                /** {@inheritDoc} */
240
+                                @Override
241
+                                protected Object doInBackground() throws
242
+                                        Exception {
243
+                                    enterPressed(line);
244
+                                    return null;
245
+                                }
246
+                            }.execute();
236 247
                         }
237
-                        return null;
238 248
                     }
239
-                    }.execute();
249
+                });
240 250
             }
241 251
         });
242 252
         localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
@@ -256,7 +266,7 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
256 266
      */
257 267
     @Override
258 268
     public void keyTyped(final KeyEvent e) {
259
-    //Ignore
269
+        //Ignore
260 270
     }
261 271
 
262 272
     /** 
@@ -266,8 +276,8 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
266 276
      */
267 277
     @Override
268 278
     public void keyPressed(final KeyEvent e) {
269
-        if (e.getKeyCode() != KeyEvent.VK_TAB && e.getKeyCode() !=
270
-                KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) {
279
+        if (e.getKeyCode() != KeyEvent.VK_TAB && e.getKeyCode()
280
+                != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) {
271 281
             final String line = target.getText();
272 282
             if (UIUtilities.isCtrlDown(e) && e.getKeyCode() == KeyEvent.VK_ENTER
273 283
                     && (flags & HANDLE_RETURN) == HANDLE_RETURN) {
@@ -292,6 +302,6 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
292 302
      */
293 303
     @Override
294 304
     public void keyReleased(final KeyEvent e) {
295
-    //Ignore
305
+        //Ignore
296 306
     }
297 307
 }

+ 29
- 19
src/com/dmdirc/addons/ui_swing/components/TopicBar.java View File

@@ -198,25 +198,35 @@ public class TopicBar extends JComponent implements ActionListener,
198 198
     /** {@inheritDoc} */
199 199
     @Override
200 200
     public void topicChanged(final Channel channel, final Topic topic) {
201
-        if (topicText.isEditable()) {
202
-            return;
203
-        }
204
-        topicText.setText("");
205
-        if (channel.getCurrentTopic() != null) {
206
-            channel.getStyliser().addStyledString((StyledDocument) topicText.
207
-                    getDocument(),
208
-                    new String[]{Styliser.CODE_HEXCOLOUR + ColourManager.getHex(
209
-                        foregroundColour) + channel.getCurrentTopic().getTopic(),},
210
-                    as);
211
-        }
212
-        if (channel.getConfigManager().getOptionBool(controller.getDomain(),
213
-                "hideEmptyTopicBar")) {
214
-            setVisible(topicText.getDocument().getLength() != 0);
215
-        }
216
-        topicText.setCaretPosition(0);
217
-        validateTopic();
218
-        setVisible(false);
219
-        setVisible(true);
201
+        UIUtilities.invokeLater(new Runnable() {
202
+
203
+            /** {@inheritDoc} */
204
+            @Override
205
+            public void run() {
206
+                if (topicText.isEditable()) {
207
+                    return;
208
+                }
209
+                topicText.setText("");
210
+                if (channel.getCurrentTopic() != null) {
211
+                    channel.getStyliser().addStyledString((StyledDocument) topicText.
212
+                            getDocument(),
213
+                            new String[]{Styliser.CODE_HEXCOLOUR + ColourManager.
214
+                                getHex(
215
+                                foregroundColour) + channel.getCurrentTopic().
216
+                                getTopic(),},
217
+                            as);
218
+                }
219
+                if (channel.getConfigManager().getOptionBool(controller.
220
+                        getDomain(),
221
+                        "hideEmptyTopicBar")) {
222
+                    setVisible(topicText.getDocument().getLength() != 0);
223
+                }
224
+                topicText.setCaretPosition(0);
225
+                validateTopic();
226
+                setVisible(false);
227
+                setVisible(true);
228
+            }
229
+        });
220 230
     }
221 231
 
222 232
     /**

+ 26
- 4
src/com/dmdirc/addons/ui_swing/components/addonbrowser/DownloaderWindow.java View File

@@ -6,6 +6,7 @@
6 6
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
7 7
 
8 8
 import com.dmdirc.Main;
9
+import com.dmdirc.addons.ui_swing.UIUtilities;
9 10
 import com.dmdirc.ui.CoreUIUtils;
10 11
 import com.dmdirc.util.DownloadListener;
11 12
 import com.dmdirc.util.Downloader;
@@ -62,7 +63,14 @@ public class DownloaderWindow extends JDialog implements Runnable, DownloadListe
62 63
         try {
63 64
             Downloader.downloadPage("http://addons.dmdirc.com/feed", 
64 65
                     Main.getConfigDir() + File.separator + "addons.feed", this);
65
-            new BrowserWindow(parentWindow);
66
+            UIUtilities.invokeLater(new Runnable() {
67
+
68
+                /** {@inheritDoc} */
69
+                @Override
70
+                public void run() {
71
+                    new BrowserWindow(parentWindow);
72
+                }
73
+            });
66 74
         } catch (IOException ex) {
67 75
             removeAll();
68 76
             add(new JLabel("Unable to download feed."));
@@ -73,14 +81,28 @@ public class DownloaderWindow extends JDialog implements Runnable, DownloadListe
73 81
     
74 82
     /** {@inheritDoc} */
75 83
     @Override
76
-    public void downloadProgress(float percent) {
77
-        jpb.setValue((int) percent);
84
+    public void downloadProgress(final float percent) {
85
+        UIUtilities.invokeLater(new Runnable() {
86
+
87
+            /** {@inheritDoc} */
88
+            @Override
89
+            public void run() {
90
+                jpb.setValue((int) percent);
91
+            }
92
+        });
78 93
     }
79 94
 
80 95
     /** {@inheritDoc} */
81 96
     @Override
82 97
     public void setIndeterminate(final boolean indeterminate) {
83
-        jpb.setIndeterminate(indeterminate);
98
+        UIUtilities.invokeLater(new Runnable() {
99
+
100
+            /** {@inheritDoc} */
101
+            @Override
102
+            public void run() {
103
+                jpb.setIndeterminate(indeterminate);
104
+            }
105
+        });
84 106
     }
85 107
 
86 108
 }

+ 8
- 1
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java View File

@@ -279,7 +279,14 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
279 279
     }
280 280
 
281 281
     private void saveSplitPanePosition() {
282
-        identity.setOption("ui", "channelSplitPanePosition", nicklist.getWidth());
282
+        UIUtilities.invokeAndWait(new Runnable() {
283
+
284
+            /** {@inheritDoc} */
285
+            @Override
286
+            public void run() {
287
+                identity.setOption("ui", "channelSplitPanePosition", nicklist.getWidth());
288
+            }
289
+        });
283 290
     }
284 291
 
285 292
     /** {@inheritDoc} */

+ 49
- 29
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java View File

@@ -19,6 +19,7 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
+
22 23
 package com.dmdirc.addons.ui_swing.components.frames;
23 24
 
24 25
 import com.dmdirc.WritableFrameContainer;
@@ -94,7 +95,8 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
94 95
      * @param owner WritableFrameContainer owning this frame.
95 96
      * @param controller Swing controller
96 97
      */
97
-    public InputTextFrame(final WritableFrameContainer owner, final SwingController controller) {
98
+    public InputTextFrame(final WritableFrameContainer owner,
99
+            final SwingController controller) {
98 100
         super(owner, controller);
99 101
 
100 102
         initComponents();
@@ -130,7 +132,7 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
130 132
             public void run() {
131 133
                 InputTextFrame.super.open();
132 134
                 if (useAwayIndicator && getContainer().
133
-                    getServer() != null) {
135
+                        getServer() != null) {
134 136
                     awayLabel.setVisible(getContainer().getServer().isAway());
135 137
                 }
136 138
 
@@ -183,9 +185,11 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
183 185
 
184 186
         getInputField().getActionMap().put("paste",
185 187
                 new InputTextFramePasteAction(this));
186
-        getInputField().getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("shift INSERT"),
188
+        getInputField().getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(
189
+                "shift INSERT"),
187 190
                 "paste");
188
-        getInputField().getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl V"),
191
+        getInputField().getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(
192
+                "ctrl V"),
189 193
                 "paste");
190 194
     }
191 195
 
@@ -253,16 +257,23 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
253 257
      */
254 258
     @Override
255 259
     public void setAwayIndicator(final boolean awayState) {
256
-        final boolean awayIndicator = getConfigManager().
257
-                getOptionBool("ui", "awayindicator");
258
-        if (awayIndicator || !awayState) {
259
-            if (awayState) {
260
-                inputPanel.add(awayLabel, BorderLayout.LINE_START);
261
-                awayLabel.setVisible(true);
262
-            } else {
263
-                awayLabel.setVisible(false);
260
+        UIUtilities.invokeLater(new Runnable() {
261
+
262
+            /** {@inheritDoc} */
263
+            @Override
264
+            public void run() {
265
+                final boolean awayIndicator = getConfigManager().
266
+                        getOptionBool("ui", "awayindicator");
267
+                if (awayIndicator || !awayState) {
268
+                    if (awayState) {
269
+                        inputPanel.add(awayLabel, BorderLayout.LINE_START);
270
+                        awayLabel.setVisible(true);
271
+                    } else {
272
+                        awayLabel.setVisible(false);
273
+                    }
274
+                }
264 275
             }
265
-        }
276
+        });
266 277
     }
267 278
 
268 279
     /**
@@ -307,8 +318,8 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
307 318
             if (point != null) {
308 319
                 initPopupMenu();
309 320
                 inputFieldPopup.show(this, (int) point.getX(),
310
-                        (int) point.getY() + getTextPane().getHeight() +
311
-                        (int) PlatformDefaults.getUnitValueX("related").getValue());
321
+                        (int) point.getY() + getTextPane().getHeight() + (int) PlatformDefaults.
322
+                        getUnitValueX("related").getValue());
312 323
             }
313 324
         }
314 325
         super.processMouseEvent(e);
@@ -334,8 +345,8 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
334 345
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
335 346
             doPaste(clipboard);
336 347
         } catch (IOException ex) {
337
-            Logger.userError(ErrorLevel.LOW, "Unable to get clipboard contents: " +
338
-                    ex.getMessage());
348
+            Logger.userError(ErrorLevel.LOW, "Unable to get clipboard contents: " + ex.
349
+                    getMessage());
339 350
         } catch (UnsupportedFlavorException ex) {
340 351
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
341 352
         }
@@ -350,17 +361,21 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
350 361
     protected void doPaste(final String clipboard) {
351 362
         String[] clipboardLines;
352 363
         //check theres something to paste
353
-        if (clipboard != null && (clipboardLines = getSplitLine(clipboard)).length > 1) {
364
+        if (clipboard != null && (clipboardLines = getSplitLine(clipboard)).length
365
+                > 1) {
354 366
             final int caretPosition = getInputField().getCaretPosition();
355 367
             final String inputFieldText = getInputField().getText();
356
-            final String text = inputFieldText.substring(0, caretPosition) + clipboard + inputFieldText.substring(caretPosition);
368
+            final String text = inputFieldText.substring(0, caretPosition)
369
+                    + clipboard + inputFieldText.substring(caretPosition);
357 370
             //check the limit
358 371
             final Integer pasteTrigger = getConfigManager().getOptionInt("ui",
359 372
                     "pasteProtectionLimit");
360 373
             //check whether the number of lines is over the limit
361
-            if (pasteTrigger != null && getContainer().getNumLines(text) > pasteTrigger) {
374
+            if (pasteTrigger != null && getContainer().getNumLines(text)
375
+                    > pasteTrigger) {
362 376
                 //show the multi line paste dialog
363
-                new PasteDialog(this, text, getController().getMainFrame()).display();
377
+                new PasteDialog(this, text, getController().getMainFrame()).
378
+                        display();
364 379
                 inputField.setText("");
365 380
             } else {
366 381
                 //send the lines
@@ -391,17 +406,20 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
391 406
 
392 407
         if ("ui".equals(domain) && getConfigManager() != null) {
393 408
             if (getInputField() != null) {
394
-                if ("inputbackgroundcolour".equals(key) ||
395
-                        "backgroundcolour".equals(key)) {
396
-                    getInputField().setBackground(getConfigManager().getOptionColour(
409
+                if ("inputbackgroundcolour".equals(key) || "backgroundcolour".
410
+                        equals(key)) {
411
+                    getInputField().setBackground(getConfigManager().
412
+                            getOptionColour(
397 413
                             "ui", "inputbackgroundcolour",
398 414
                             "ui", "backgroundcolour"));
399
-                } else if ("inputforegroundcolour".equals(key) ||
400
-                        "foregroundcolour".equals(key)) {
401
-                    getInputField().setForeground(getConfigManager().getOptionColour(
415
+                } else if ("inputforegroundcolour".equals(key) || "foregroundcolour".
416
+                        equals(key)) {
417
+                    getInputField().setForeground(getConfigManager().
418
+                            getOptionColour(
402 419
                             "ui", "inputforegroundcolour",
403 420
                             "ui", "foregroundcolour"));
404
-                    getInputField().setCaretColor(getConfigManager().getOptionColour(
421
+                    getInputField().setCaretColor(getConfigManager().
422
+                            getOptionColour(
405 423
                             "ui", "inputforegroundcolour",
406 424
                             "ui", "foregroundcolour"));
407 425
                 }
@@ -444,7 +462,9 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
444 462
                 menu.add(populatePopupMenu(new JMenu(menuItem.getName()),
445 463
                         menuItem.getSubMenu(), arguments));
446 464
             } else {
447
-                menu.add(new JMenuItem(new CommandAction(getCommandParser(),
465
+                menu.add(
466
+                        new JMenuItem(
467
+                        new CommandAction(getCommandParser(),
448 468
                         this, menuItem.getName(), menuItem.getCommand(arguments))));
449 469
             }
450 470
         }

+ 22
- 10
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java View File

@@ -48,7 +48,7 @@ import com.dmdirc.commandparser.parsers.GlobalCommandParser;
48 48
 import com.dmdirc.util.StringTranscoder;
49 49
 import com.dmdirc.config.ConfigManager;
50 50
 import com.dmdirc.interfaces.ConfigChangeListener;
51
-import com.dmdirc.interfaces.FrameInfoAdapter;
51
+import com.dmdirc.interfaces.FrameInfoListener;
52 52
 import com.dmdirc.logger.ErrorLevel;
53 53
 import com.dmdirc.logger.Logger;
54 54
 import com.dmdirc.ui.IconManager;
@@ -102,7 +102,7 @@ import net.miginfocom.swing.MigLayout;
102 102
  */
103 103
 public abstract class TextFrame extends JInternalFrame implements Window,
104 104
         PropertyChangeListener, InternalFrameListener,
105
-        MouseListener, KeyListener, ConfigChangeListener {
105
+        MouseListener, KeyListener, ConfigChangeListener, FrameInfoListener {
106 106
 
107 107
     /** Logger to use. */
108 108
     private static final java.util.logging.Logger LOGGER =
@@ -165,14 +165,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
165 165
 
166 166
         setFrameIcon(IconManager.getIconManager().getIcon(owner.getIcon()));
167 167
 
168
-        owner.addFrameInfoListener(new FrameInfoAdapter() {
169
-
170
-            /** {@inheritDoc} */
171
-            @Override
172
-            public void iconChanged(final Window window, final String icon) {
173
-                setFrameIcon(IconManager.getIconManager().getIcon(icon));
174
-            }
175
-        });
168
+        owner.addFrameInfoListener(this);
176 169
 
177 170
         try {
178 171
             transcoder = new StringTranscoder(Charset.forName(
@@ -1179,4 +1172,23 @@ public abstract class TextFrame extends JInternalFrame implements Window,
1179 1172
             }
1180 1173
         }
1181 1174
     }
1175
+
1176
+    /** {@inheritDoc} */
1177
+    @Override
1178
+    public void iconChanged(final Window window, final String icon) {
1179
+        UIUtilities.invokeLater(new Runnable() {
1180
+
1181
+            /** {@inheritDoc} */
1182
+            @Override
1183
+            public void run() {
1184
+                setFrameIcon(IconManager.getIconManager().getIcon(icon));
1185
+            }
1186
+        });
1187
+    }
1188
+
1189
+    /** {@inheritDoc} */
1190
+    @Override
1191
+    public void nameChanged(final Window window, final String name) {
1192
+        //Ignore
1193
+    }
1182 1194
 }

+ 13
- 6
src/com/dmdirc/addons/ui_swing/components/pluginpanel/PluginPanel.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.addons.ui_swing.components.pluginpanel;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.UIUtilities;
27 28
 import com.dmdirc.config.prefs.PreferencesInterface;
28 29
 import com.dmdirc.plugins.PluginInfo;
29 30
 import com.dmdirc.plugins.PluginManager;
@@ -163,12 +164,18 @@ public final class PluginPanel extends JPanel implements
163 164
                 PluginManager.getPluginManager().getPossiblePluginInfos(true);
164 165
         Collections.sort(list);
165 166
 
166
-        ((DefaultListModel) pluginList.getModel()).clear();
167
-        for (PluginInfo plugin : list) {
168
-            ((DefaultListModel) pluginList.getModel()).addElement(new PluginInfoToggle(
169
-                    plugin));
170
-        }
171
-        pluginList.repaint();
167
+        UIUtilities.invokeLater(new Runnable() {
168
+
169
+            @Override
170
+            public void run() {
171
+                ((DefaultListModel) pluginList.getModel()).clear();
172
+                for (PluginInfo plugin : list) {
173
+                    ((DefaultListModel) pluginList.getModel()).addElement(new PluginInfoToggle(
174
+                            plugin));
175
+                }
176
+                pluginList.repaint();
177
+            }
178
+        });
172 179
         return pluginList;
173 180
     }
174 181
 

+ 8
- 1
src/com/dmdirc/addons/ui_swing/components/statusbar/StatusbarPopupPanel.java View File

@@ -131,7 +131,14 @@ public abstract class StatusbarPopupPanel extends JPanel
131 131
      * @param text New text
132 132
      */
133 133
     public void setText(final String text) {
134
-        label.setText(text);
134
+        UIUtilities.invokeLater(new Runnable() {
135
+
136
+            /** {@inheritDoc} */
137
+            @Override
138
+            public void run() {
139
+                label.setText(text);
140
+            }
141
+        });
135 142
     }
136 143
 
137 144
     /**

+ 16
- 9
src/com/dmdirc/addons/ui_swing/components/themepanel/ThemePanel.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.themepanel;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.config.IdentityManager;
26 27
 import com.dmdirc.config.prefs.PreferencesInterface;
27 28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
@@ -143,18 +144,24 @@ public final class ThemePanel extends JPanel implements
143 144
                 getAvailableThemes().values());
144 145
         Collections.sort(list);
145 146
 
146
-        ((DefaultListModel) themeList.getModel()).clear();
147
+        UIUtilities.invokeLater(new Runnable() {
147 148
 
148
-        for (Theme plugin : list) {
149
-            ((DefaultListModel) themeList.getModel()).addElement(new ThemeToggle(
150
-                    plugin));
151
-        }
149
+            /** {@inheritDoc} */
150
+            @Override
151
+            public void run() {
152
+                ((DefaultListModel) themeList.getModel()).clear();
153
+                for (Theme plugin : list) {
154
+                    ((DefaultListModel) themeList.getModel()).addElement(
155
+                            new ThemeToggle(plugin));
156
+                }
152 157
 
153
-        if (((DefaultListModel) themeList.getModel()).size() > 0) {
154
-            toggleButton.setEnabled(true);
155
-        }
158
+                if (((DefaultListModel) themeList.getModel()).size() > 0) {
159
+                    toggleButton.setEnabled(true);
160
+                }
156 161
 
157
-        themeList.repaint();
162
+                themeList.repaint();
163
+            }
164
+        });
158 165
         return themeList;
159 166
     }
160 167
 

+ 19
- 4
src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
26 27
 import com.dmdirc.logger.ErrorLevel;
27 28
 import com.dmdirc.logger.Logger;
@@ -121,15 +122,29 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
121 122
 
122 123
     private void addLicensesToNode(final Map<String, InputStream> licences,
123 124
             final DefaultMutableTreeNode root) {
124
-        model.insertNodeInto(root, (DefaultMutableTreeNode) model.getRoot(),
125
-                model.getChildCount(model.getRoot()));
125
+        UIUtilities.invokeAndWait(new Runnable() {
126
+
127
+            /** {@inheritDoc} */
128
+            @Override
129
+            public void run() {
130
+                model.insertNodeInto(root, (DefaultMutableTreeNode) model.
131
+                        getRoot(), model.getChildCount(model.getRoot()));
132
+            }
133
+        });
126 134
         for (Entry<String, InputStream> entry : licences.entrySet()) {
127 135
             final Licence licence = createLicence(entry);
128 136
             if (licence == null) {
129 137
                 continue;
130 138
             }
131
-            model.insertNodeInto(new DefaultMutableTreeNode(licence), root,
132
-                    model.getChildCount(root));
139
+            UIUtilities.invokeAndWait(new Runnable() {
140
+
141
+                /** {@inheritDoc} */
142
+                @Override
143
+                public void run() {
144
+                    model.insertNodeInto(new DefaultMutableTreeNode(licence),
145
+                            root, model.getChildCount(root));
146
+                }
147
+            });
133 148
         }
134 149
     }
135 150
 

+ 26
- 11
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java View File

@@ -117,8 +117,8 @@ public class CategoryPanel extends JPanel {
117 117
 
118 118
         title = new TitlePanel(BorderFactory.createEtchedBorder(),
119 119
                 "Preferences");
120
-        tooltip = new ToolTipPanel("Hover over a setting to see a " +
121
-                    "description, if available.");
120
+        tooltip = new ToolTipPanel("Hover over a setting to see a "
121
+                + "description, if available.");
122 122
 
123 123
         add(title, "pushx, growx, h 45!");
124 124
         add(scrollPane, "grow, push");
@@ -132,8 +132,8 @@ public class CategoryPanel extends JPanel {
132 132
             @Override
133 133
             public void correctBounds(final ComponentWrapper cw) {
134 134
                 if (cw.getComponent() == scrollPane) {
135
-                   parent.setPanelHeight((int) (scrollPane.getViewport().
136
-                           getExtentSize().height * 0.95));
135
+                    parent.setPanelHeight((int) (scrollPane.getViewport().
136
+                            getExtentSize().height * 0.95));
137 137
                 }
138 138
             }
139 139
         });
@@ -209,7 +209,7 @@ public class CategoryPanel extends JPanel {
209 209
                     }
210 210
                 }
211 211
             });
212
-        }        
212
+        }
213 213
     }
214 214
 
215 215
     /**
@@ -248,7 +248,14 @@ public class CategoryPanel extends JPanel {
248 248
      * @param b
249 249
      */
250 250
     public void setWaiting(final boolean b) {
251
-        scrollPane.setViewportView(waitingCategory);
251
+        UIUtilities.invokeLater(new Runnable() {
252
+
253
+            /** {@inheritDoc} */
254
+            @Override
255
+            public void run() {
256
+                scrollPane.setViewportView(waitingCategory);
257
+            }
258
+        });
252 259
     }
253 260
 
254 261
     /**
@@ -257,10 +264,18 @@ public class CategoryPanel extends JPanel {
257 264
      * @param message Message to display
258 265
      */
259 266
     public void setError(final String message) {
260
-        final JPanel panel = new JPanel(new MigLayout("fillx"));
261
-        panel.add(new TextLabel("An error has occurred loading the " +
262
-                "preferences dialog, an error has been raised: "), "wrap");
263
-        panel.add(new TextLabel(message));
264
-        scrollPane.setViewportView(panel);
267
+        UIUtilities.invokeLater(new Runnable() {
268
+
269
+            /** {@inheritDoc} */
270
+            @Override
271
+            public void run() {
272
+                final JPanel panel = new JPanel(new MigLayout("fillx"));
273
+                panel.add(new TextLabel("An error has occurred loading the "
274
+                        + "preferences dialog, an error has been raised: "),
275
+                        "wrap");
276
+                panel.add(new TextLabel(message));
277
+                scrollPane.setViewportView(panel);
278
+            }
279
+        });
265 280
     }
266 281
 }

+ 56
- 25
src/com/dmdirc/addons/ui_swing/dialogs/prefs/PrefsCategoryLoader.java View File

@@ -134,8 +134,15 @@ public class PrefsCategoryLoader extends SwingWorker<JPanel, Object> {
134 134
             final JPanel panel, final String path) {
135 135
 
136 136
         if (!category.getDescription().isEmpty()) {
137
-            panel.add(new TextLabel(category.getDescription()), "span, " +
137
+            UIUtilities.invokeAndWait(new Runnable() {
138
+
139
+                /** {@inheritDoc} */
140
+                @Override
141
+                public void run() {
142
+                    panel.add(new TextLabel(category.getDescription()), "span, " +
138 143
                     "growx, pushx, wrap 2*unrel");
144
+                }
145
+            });
139 146
         }
140 147
 
141 148
         for (PreferencesCategory child : category.getSubcats()) {
@@ -191,11 +198,12 @@ public class PrefsCategoryLoader extends SwingWorker<JPanel, Object> {
191 198
             /** {@inheritDoc} */
192 199
             @Override
193 200
             public void run() {
194
-                setObject(PrefsComponentFactory.getComponent(setting));
201
+                JComponent option = PrefsComponentFactory.getComponent(setting);
202
+                option.setToolTipText(null);
203
+                setObject(option);
195 204
             }
196 205
         });
197
-        
198
-        option.setToolTipText(null);
206
+
199 207
         categoryPanel.getToolTipPanel().registerTooltipHandler(label,
200 208
                 getTooltipText(setting, categoryPanel));
201 209
         categoryPanel.getToolTipPanel().registerTooltipHandler(option,
@@ -247,13 +255,21 @@ public class PrefsCategoryLoader extends SwingWorker<JPanel, Object> {
247 255
      * @return A TextLabel with the appropriate text and tooltip
248 256
      */
249 257
     private TextLabel getLabel(final PreferencesSetting setting) {
250
-        final TextLabel label = new TextLabel(setting.getTitle() + ": ", false);
258
+        final TextLabel label = UIUtilities.invokeAndWait(
259
+                new ReturnableThread<TextLabel>() {
251 260
 
252
-        if (setting.getHelptext().isEmpty()) {
253
-            label.setToolTipText("No help available.");
254
-        } else {
255
-            label.setToolTipText(setting.getHelptext());
256
-        }
261
+            @Override
262
+            public void run() {
263
+                final TextLabel label = new TextLabel(setting.getTitle() +
264
+                        ": ", false);
265
+                if (setting.getHelptext().isEmpty()) {
266
+                    label.setToolTipText("No help available.");
267
+                } else {
268
+                    label.setToolTipText(setting.getHelptext());
269
+                }
270
+                setObject(label);
271
+            }
272
+        });
257 273
 
258 274
         return label;
259 275
     }
@@ -266,14 +282,22 @@ public class PrefsCategoryLoader extends SwingWorker<JPanel, Object> {
266 282
      */
267 283
     private void addInlineCategory(final PreferencesCategory category,
268 284
             final JPanel parent) {
269
-        final JPanel panel =
270
-                new NoRemovePanel(new MigLayout("fillx, gap unrel, wrap 2, " +
271
-                "hidemode 3, pack, wmax 470-" + leftPadding + "-" +
272
-                rightPadding + "-2*" + padding));
273
-        panel.setName(category.getPath());
274
-        panel.setBorder(BorderFactory.createTitledBorder(UIManager.getBorder(
275
-                "TitledBorder.border"), category.getTitle()));
285
+        final JPanel panel = UIUtilities.invokeAndWait(
286
+                new ReturnableThread<JPanel>() {
276 287
 
288
+            @Override
289
+            public void run() {
290
+                final JPanel panel =
291
+                new NoRemovePanel(new MigLayout("fillx, gap unrel, wrap 2, " +
292
+                    "hidemode 3, pack, wmax 470-" + leftPadding + "-" +
293
+                    rightPadding + "-2*" + padding));
294
+                panel.setName(category.getPath());
295
+                panel.setBorder(BorderFactory.createTitledBorder(UIManager.
296
+                        getBorder("TitledBorder.border"), category.getTitle()));
297
+                setObject(panel);
298
+            }
299
+        });
300
+        
277 301
         parent.add(panel, "span, growx, pushx, wrap");
278 302
 
279 303
         initCategory(category, panel, "");
@@ -287,14 +311,21 @@ public class PrefsCategoryLoader extends SwingWorker<JPanel, Object> {
287 311
      * @param namePrefix Category name prefix
288 312
      */
289 313
     private JPanel addCategory(final PreferencesCategory category) {
290
-        final JPanel panel =
291
-                new NoRemovePanel(new MigLayout("fillx, gap unrel, " +
292
-                "wrap 2, pack, hidemode 3, wmax 470-" + leftPadding + "-" +
293
-                rightPadding + "-2*" + padding));
294
-        panel.setName(category.getPath());
295
-        final String path = category.getPath();
296
-
297
-        initCategory(category, panel, path);
314
+        final JPanel panel = UIUtilities.invokeAndWait(
315
+                new ReturnableThread<JPanel>() {
316
+
317
+            @Override
318
+            public void run() {
319
+                final JPanel panel = new NoRemovePanel(
320
+                        new MigLayout("fillx, gap unrel, wrap 2, pack, " +
321
+                        "hidemode 3, wmax 470-" + leftPadding + "-" +
322
+                        rightPadding + "-2*" + padding));
323
+                panel.setName(category.getPath());
324
+                setObject(panel);
325
+            }
326
+        });
327
+
328
+        initCategory(category, panel, category.getPath());
298 329
 
299 330
         return panel;
300 331
     }

+ 6
- 5
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/FrameContainerMenuItem.java View File

@@ -61,7 +61,8 @@ public class FrameContainerMenuItem extends JMenuItem implements FrameInfoListen
61 61
      */
62 62
     public FrameContainerMenuItem(final FrameContainer frame,
63 63
             final WindowMenuFrameManager manager) {
64
-        super(frame.toString(), IconManager.getIconManager().getIcon(frame.getIcon()));
64
+        super(frame.toString(), IconManager.getIconManager().getIcon(frame.
65
+                getIcon()));
65 66
 
66 67
         this.frame = frame;
67 68
         this.manager = manager;
@@ -78,8 +79,8 @@ public class FrameContainerMenuItem extends JMenuItem implements FrameInfoListen
78 79
             /** {@inheritDoc} */
79 80
             @Override
80 81
             public void run() {
81
-                if ((frame != null && window != null) &&
82
-                        frame.equals(window.getContainer())) {
82
+                if ((frame != null && window != null) && frame.equals(window.
83
+                        getContainer())) {
83 84
                     setIcon(IconManager.getIconManager().getIcon(icon));
84 85
                 }
85 86
             }
@@ -94,8 +95,8 @@ public class FrameContainerMenuItem extends JMenuItem implements FrameInfoListen
94 95
             /** {@inheritDoc} */
95 96
             @Override
96 97
             public void run() {
97
-                if ((frame != null && window != null) &&
98
-                        frame.equals(window.getContainer())) {
98
+                if ((frame != null && window != null) && frame.equals(window.
99
+                        getContainer())) {
99 100
                     setText(name);
100 101
                 }
101 102
             }

+ 125
- 33
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java View File

@@ -25,19 +25,25 @@ package com.dmdirc.addons.ui_swing.framemanager.windowmenu;
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.FrameContainerComparator;
27 27
 import com.dmdirc.addons.ui_swing.SwingController;
28
+import com.dmdirc.addons.ui_swing.UIUtilities;
28 29
 import com.dmdirc.config.IdentityManager;
29 30
 import com.dmdirc.interfaces.SelectionListener;
30 31
 import com.dmdirc.ui.IconManager;
31 32
 import com.dmdirc.ui.WindowManager;
32 33
 import com.dmdirc.ui.interfaces.Window;
33 34
 import com.dmdirc.ui.interfaces.FrameListener;
35
+import com.dmdirc.util.ReturnableThread;
34 36
 
37
+import java.awt.Component;
35 38
 import java.awt.event.ActionEvent;
36 39
 import java.awt.event.ActionListener;
40
+import java.util.ArrayList;
41
+import java.util.Collection;
37 42
 import java.util.Collections;
38 43
 import java.util.HashMap;
39 44
 import java.util.Map;
40 45
 import java.util.concurrent.atomic.AtomicBoolean;
46
+import javax.swing.AbstractButton;
41 47
 
42 48
 import javax.swing.JMenu;
43 49
 import javax.swing.JMenuItem;
@@ -147,23 +153,50 @@ public final class WindowMenuFrameManager extends JMenu implements
147 153
     /** {@inheritDoc} */
148 154
     @Override
149 155
     public void addWindow(final FrameContainer window) {
150
-        final FrameContainerMenuItem item = new FrameContainerMenuItem(window,
151
-                this);
156
+        final FrameContainerMenuItem item = UIUtilities.invokeAndWait(
157
+                new ReturnableThread<FrameContainerMenuItem>() {
158
+
159
+                    /** {@inheritDoc} */
160
+                    @Override
161
+                    public void run() {
162
+                        setObject(new FrameContainerMenuItem(window,
163
+                                WindowMenuFrameManager.this));
164
+                    }
165
+                });
152 166
         items.put(window, item);
153
-        add(item, getIndex(window, this));
167
+        final int index = getIndex(window, this);
154 168
         window.addSelectionListener(this);
169
+        UIUtilities.invokeLater(new Runnable() {
170
+
171
+            /** {@inheritDoc} */
172
+            @Override
173
+            public void run() {
174
+                add(item, index);
175
+            }
176
+        });
155 177
     }
156 178
 
157 179
     /** {@inheritDoc} */
158 180
     @Override
159 181
     public void delWindow(final FrameContainer window) {
182
+        final AbstractButton item;
160 183
         if (items.containsKey(window)) {
161
-            remove(items.get(window));
184
+            item = items.get(window);
162 185
             items.remove(window);
163 186
         } else if (menus.containsKey(window)) {
164
-            remove(menus.get(window));
187
+            item = menus.get(window);
165 188
             menus.remove(window);
189
+        } else {
190
+            item = null;
166 191
         }
192
+        UIUtilities.invokeLater(new Runnable() {
193
+
194
+            /** {@inheritDoc} */
195
+            @Override
196
+            public void run() {
197
+                remove(item);
198
+            }
199
+        });
167 200
         window.removeSelectionListener(this);
168 201
     }
169 202
 
@@ -171,12 +204,27 @@ public final class WindowMenuFrameManager extends JMenu implements
171 204
     @Override
172 205
     public void addWindow(final FrameContainer parent,
173 206
             final FrameContainer window) {
174
-        final FrameContainerMenuItem item = new FrameContainerMenuItem(window,
175
-                this);
176
-        JMenu parentMenu;
207
+        final FrameContainerMenuItem item = UIUtilities.invokeAndWait(
208
+                new ReturnableThread<FrameContainerMenuItem>() {
209
+
210
+                    /** {@inheritDoc} */
211
+                    @Override
212
+                    public void run() {
213
+                        setObject(new FrameContainerMenuItem(window,
214
+                                WindowMenuFrameManager.this));
215
+                    }
216
+                });
217
+        final JMenu parentMenu;
177 218
         if (!menus.containsKey(parent)) {
178
-            final FrameContainerMenu replacement =
179
-                    new FrameContainerMenu(parent, controller);
219
+            final FrameContainerMenu replacement = UIUtilities.invokeAndWait(
220
+                    new ReturnableThread<FrameContainerMenu>() {
221
+
222
+                        /** {@inheritDoc} */
223
+                        @Override
224
+                        public void run() {
225
+                            setObject(new FrameContainerMenu(parent, controller));
226
+                        }
227
+                    });
180 228
             replaceItemWithMenu(getParentMenu(parent), items.get(parent),
181 229
                     replacement);
182 230
             parentMenu = replacement;
@@ -184,8 +232,15 @@ public final class WindowMenuFrameManager extends JMenu implements
184 232
             parentMenu = menus.get(parent);
185 233
         }
186 234
         items.put(window, item);
187
-        parentMenu.add(item, getIndex(window, parentMenu));
188 235
         window.addSelectionListener(this);
236
+        UIUtilities.invokeLater(new Runnable() {
237
+
238
+            /** {@inheritDoc} */
239
+            @Override
240
+            public void run() {
241
+                parentMenu.add(item, getIndex(window, parentMenu));
242
+            }
243
+        });
189 244
     }
190 245
 
191 246
     /** {@inheritDoc} */
@@ -194,12 +249,21 @@ public final class WindowMenuFrameManager extends JMenu implements
194 249
             final FrameContainer window) {
195 250
         if (items.containsKey(window)) {
196 251
             final JMenu menu = getParentMenu(window);
197
-            menu.remove(items.get(window));
252
+            final FrameContainerMenuItem item = items.get(window);
198 253
             items.remove(window);
199
-            if (menu.getMenuComponentCount() == 1) {
200
-                replaceMenuWithItem(getParentMenu(parent), menus.get(parent),
201
-                        new FrameContainerMenuItem(parent, this));
202
-            }
254
+            UIUtilities.invokeAndWait(new Runnable() {
255
+
256
+                /** {@inheritDoc} */
257
+                @Override
258
+                public void run() {
259
+                    menu.remove(item);
260
+                    if (menu.getMenuComponentCount() == 1) {
261
+                        replaceMenuWithItem(getParentMenu(parent),
262
+                                menus.get(parent), new FrameContainerMenuItem(
263
+                                parent, WindowMenuFrameManager.this));
264
+                    }
265
+                }
266
+            });
203 267
         } else if (menus.containsKey(window)) {
204 268
             menus.get(parent).remove(menus.get(window));
205 269
             menus.remove(window);
@@ -222,9 +286,15 @@ public final class WindowMenuFrameManager extends JMenu implements
222 286
 
223 287
     private void replaceItemWithMenu(final JMenu parentMenu,
224 288
             final FrameContainerMenuItem item, final FrameContainerMenu menu) {
225
-        parentMenu.remove(item);
226
-        parentMenu.add(menu, getIndex(menu.getFrame(), parentMenu));
227
-        menu.add(item, getIndex(item.getFrame(), menu));
289
+        UIUtilities.invokeAndWait(new Runnable() {
290
+
291
+            @Override
292
+            public void run() {
293
+                parentMenu.remove(item);
294
+                parentMenu.add(menu, getIndex(menu.getFrame(), parentMenu));
295
+                menu.add(item, getIndex(item.getFrame(), menu));
296
+            }
297
+        });
228 298
         items.remove(item.getFrame());
229 299
         menus.put(menu.getFrame(), menu);
230 300
         menuItems.put(item.getFrame(), item);
@@ -259,23 +329,27 @@ public final class WindowMenuFrameManager extends JMenu implements
259 329
     /** {@inheritDoc} */
260 330
     @Override
261 331
     public void selectionChanged(final Window window) {
332
+        final Collection<SelectionListener> values =
333
+                new ArrayList<SelectionListener>();
262 334
         synchronized (menus) {
263 335
             synchronized (items) {
264 336
                 synchronized (menuItems) {
265 337
                     activeWindow = window;
266
-                    //iterate over menu items seperately here to simplify code in listeners
267
-                    for (SelectionListener menuItem : menus.values()) {
268
-                        menuItem.selectionChanged(window);
269
-                    }
270
-                    for (SelectionListener menuItem : items.values()) {
271
-                        menuItem.selectionChanged(window);
272
-                    }
273
-                    for (SelectionListener menuItem : menuItems.values()) {
274
-                        menuItem.selectionChanged(window);
275
-                    }
338
+                    values.addAll(menus.values());
339
+                    values.addAll(items.values());
340
+                    values.addAll(menuItems.values());
276 341
                 }
277 342
             }
278 343
         }
344
+        UIUtilities.invokeLater(new Runnable() {
345
+
346
+            @Override
347
+            public void run() {
348
+                for (SelectionListener menuItem : values) {
349
+                    menuItem.selectionChanged(window);
350
+                }
351
+            }
352
+        });
279 353
     }
280 354
 
281 355
     /**
@@ -322,12 +396,30 @@ public final class WindowMenuFrameManager extends JMenu implements
322 396
      */
323 397
     private int getIndex(final FrameContainer newChild, final JMenu menu) {
324 398
         final int count = menu == this ? itemCount : 0;
325
-        for (int i = count; i < menu.getMenuComponentCount(); i++) {
326
-            if (!(menu.getMenuComponent(i) instanceof FrameContainerMenuIterface)) {
399
+        final int menuItemCount = UIUtilities.invokeAndWait(
400
+                new ReturnableThread<Integer>() {
401
+
402
+                    /** {@inheritDoc} */
403
+                    @Override
404
+                    public void run() {
405
+                        setObject(menu.getMenuComponentCount());
406
+                    }
407
+                });
408
+        for (int i = count; i < menuItemCount; i++) {
409
+            if (!(menu.getMenuComponent(i) instanceof FrameContainerMenuItem)) {
327 410
                 continue;
328 411
             }
329
-            final FrameContainer child = ((FrameContainerMenuIterface)
330
-                    menu.getMenuComponent(i)).getFrame();
412
+            final int index = i;
413
+            final Component component = UIUtilities.invokeAndWait(
414
+                    new ReturnableThread<Component>() {
415
+
416
+                        @Override
417
+                        public void run() {
418
+                            setObject(menu.getMenuComponent(index));
419
+                        }
420
+                    });
421
+            final FrameContainer child =
422
+                    ((FrameContainerMenuItem) component).getFrame();
331 423
             if (sortBefore(newChild, child)) {
332 424
                 return i;
333 425
             } else if (!sortAfter(newChild, child) && IdentityManager.

+ 9
- 1
src/com/dmdirc/addons/windowstatus/WindowStatusPanel.java View File

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.windowstatus;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.ui.interfaces.StatusBarComponent;
26 27
 import com.dmdirc.ui.messages.Styliser;
27 28
 
@@ -58,7 +59,14 @@ public class WindowStatusPanel extends JPanel implements StatusBarComponent {
58 59
      * @param text New text
59 60
      */
60 61
     public void setText(final String text) {
61
-        label.setText(Styliser.stipControlCodes(text));
62
+        UIUtilities.invokeLater(new Runnable() {
63
+
64
+            /** {@inheritDoc} */
65
+            @Override
66
+            public void run() {
67
+                label.setText(Styliser.stipControlCodes(text));
68
+            }
69
+        });
62 70
     }
63 71
 
64 72
 }

+ 13
- 1
src/com/dmdirc/addons/windowstatus/WindowStatusPlugin.java View File

@@ -30,6 +30,7 @@ import com.dmdirc.Server;
30 30
 import com.dmdirc.actions.ActionManager;
31 31
 import com.dmdirc.actions.CoreActionType;
32 32
 import com.dmdirc.actions.interfaces.ActionType;
33
+import com.dmdirc.addons.ui_swing.UIUtilities;
33 34
 import com.dmdirc.config.IdentityManager;
34 35
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
35 36
 import com.dmdirc.config.prefs.PreferencesCategory;
@@ -45,6 +46,7 @@ import com.dmdirc.plugins.Plugin;
45 46
 import com.dmdirc.ui.WindowManager;
46 47
 import com.dmdirc.ui.interfaces.InputWindow;
47 48
 import com.dmdirc.ui.interfaces.Window;
49
+import com.dmdirc.util.ReturnableThread;
48 50
 
49 51
 import java.util.Hashtable;
50 52
 import java.util.Map;
@@ -58,13 +60,23 @@ import java.util.Map.Entry;
58 60
 public final class WindowStatusPlugin extends Plugin implements ActionListener, ConfigChangeListener {
59 61
 
60 62
     /** The panel we use in the status bar. */
61
-    private final WindowStatusPanel panel = new WindowStatusPanel();
63
+    private final WindowStatusPanel panel;
62 64
     private boolean showname, shownone;
63 65
     private String nonePrefix;
64 66
 
65 67
     /** Creates a new instance of WindowStatusPlugin. */
66 68
     public WindowStatusPlugin() {
67 69
         super();
70
+
71
+        panel = UIUtilities.invokeAndWait(
72
+                new ReturnableThread<WindowStatusPanel>() {
73
+
74
+            /** {@inheritDoc} */
75
+            @Override
76
+            public void run() {
77
+                setObject(new WindowStatusPanel());
78
+            }
79
+        });
68 80
     }
69 81
 
70 82
     /**

Loading…
Cancel
Save