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
 
24
 
25
 import com.dmdirc.addons.nowplaying.MediaSource;
25
 import com.dmdirc.addons.nowplaying.MediaSource;
26
 import com.dmdirc.addons.nowplaying.MediaSourceState;
26
 import com.dmdirc.addons.nowplaying.MediaSourceState;
27
+import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.config.IdentityManager;
28
 import com.dmdirc.config.IdentityManager;
28
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
29
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
29
 import com.dmdirc.config.prefs.PreferencesCategory;
30
 import com.dmdirc.config.prefs.PreferencesCategory;
32
 import com.dmdirc.config.prefs.PreferencesType;
33
 import com.dmdirc.config.prefs.PreferencesType;
33
 import com.dmdirc.plugins.Plugin;
34
 import com.dmdirc.plugins.Plugin;
34
 import com.dmdirc.util.Downloader;
35
 import com.dmdirc.util.Downloader;
36
+import com.dmdirc.util.ReturnableThread;
35
 
37
 
36
 import java.io.File;
38
 import java.io.File;
37
 import java.io.IOException;
39
 import java.io.IOException;
207
                 "", "category-vlc");
209
                 "", "category-vlc");
208
         final PreferencesCategory instr = new PluginPreferencesCategory(
210
         final PreferencesCategory instr = new PluginPreferencesCategory(
209
                 getPluginInfo(), "Instructions",
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
         general.addSetting(new PreferencesSetting(PreferencesType.TEXT, 
222
         general.addSetting(new PreferencesSetting(PreferencesType.TEXT, 
213
                 getDomain(), "host", "Hostname and port",
223
                 getDomain(), "host", "Hostname and port",

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

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

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

22
 
22
 
23
 package com.dmdirc.addons.nowplaying;
23
 package com.dmdirc.addons.nowplaying;
24
 
24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.addons.ui_swing.components.reorderablelist.ListReorderButtonPanel;
26
 import com.dmdirc.addons.ui_swing.components.reorderablelist.ListReorderButtonPanel;
26
 import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.config.prefs.PreferencesInterface;
28
 import com.dmdirc.config.prefs.PreferencesInterface;
30
 
31
 
31
 import com.dmdirc.logger.ErrorLevel;
32
 import com.dmdirc.logger.ErrorLevel;
32
 import com.dmdirc.logger.Logger;
33
 import com.dmdirc.logger.Logger;
34
+import com.dmdirc.util.ReturnableThread;
33
 import java.awt.event.KeyEvent;
35
 import java.awt.event.KeyEvent;
34
 import java.awt.event.KeyListener;
36
 import java.awt.event.KeyListener;
35
 import java.util.Arrays;
37
 import java.util.Arrays;
148
     private void updatePreview() {
150
     private void updatePreview() {
149
         updateTimer.cancel();
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
             source = new DummyMediaSource();
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
         SwingUtilities.invokeLater(new Runnable() {
169
         SwingUtilities.invokeLater(new Runnable() {
162
 
170
 
171
+            /** {@inheritDoc} */
163
             @Override
172
             @Override
164
             public void run() {
173
             public void run() {
174
+                preview.setText("Preview:\n" + text);
175
+                preview.repaint();
165
                 previewPanel.revalidate();
176
                 previewPanel.revalidate();
166
                 revalidate();
177
                 revalidate();
167
             }
178
             }

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

25
 import com.dmdirc.actions.ActionManager;
25
 import com.dmdirc.actions.ActionManager;
26
 import com.dmdirc.actions.interfaces.ActionType;
26
 import com.dmdirc.actions.interfaces.ActionType;
27
 import com.dmdirc.actions.CoreActionType;
27
 import com.dmdirc.actions.CoreActionType;
28
+import com.dmdirc.addons.ui_swing.UIUtilities;
28
 import com.dmdirc.commandparser.CommandManager;
29
 import com.dmdirc.commandparser.CommandManager;
29
 import com.dmdirc.config.IdentityManager;
30
 import com.dmdirc.config.IdentityManager;
30
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
31
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
34
 import com.dmdirc.plugins.Plugin;
35
 import com.dmdirc.plugins.Plugin;
35
 import com.dmdirc.plugins.PluginInfo;
36
 import com.dmdirc.plugins.PluginInfo;
36
 import com.dmdirc.plugins.PluginManager;
37
 import com.dmdirc.plugins.PluginManager;
38
+import com.dmdirc.util.ReturnableThread;
37
 
39
 
38
 import java.util.ArrayList;
40
 import java.util.ArrayList;
39
 import java.util.Collections;
41
 import java.util.Collections;
100
     /** {@inheritDoc} */
102
     /** {@inheritDoc} */
101
     @Override
103
     @Override
102
     public void showConfig(final PreferencesManager manager) {
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
         final PreferencesCategory category = new PluginPreferencesCategory(
114
         final PreferencesCategory category = new PluginPreferencesCategory(
106
                 getPluginInfo(), "Now Playing",
115
                 getPluginInfo(), "Now Playing",

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

87
             localTarget.getInputMap(JComponent.WHEN_FOCUSED).
87
             localTarget.getInputMap(JComponent.WHEN_FOCUSED).
88
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upArrow");
88
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upArrow");
89
         } else {
89
         } else {
90
-            localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
90
+            localTarget.getInputMap(
91
+                    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
91
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upArrow");
92
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upArrow");
92
         }
93
         }
93
     }
94
     }
120
             localTarget.getInputMap(JComponent.WHEN_FOCUSED).
121
             localTarget.getInputMap(JComponent.WHEN_FOCUSED).
121
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downArrow");
122
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downArrow");
122
         } else {
123
         } else {
123
-            localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
124
+            localTarget.getInputMap(
125
+                    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
124
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downArrow");
126
                     put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downArrow");
125
         }
127
         }
126
     }
128
     }
226
             public void actionPerformed(final ActionEvent e) {
228
             public void actionPerformed(final ActionEvent e) {
227
                 final String line = target.getText();
229
                 final String line = target.getText();
228
                 target.setText("");
230
                 target.setText("");
229
-                new LoggingSwingWorker() {
231
+                UIUtilities.invokeLater(new Runnable() {
230
 
232
 
231
                     /** {@inheritDoc} */
233
                     /** {@inheritDoc} */
232
                     @Override
234
                     @Override
233
-                    protected Object doInBackground() throws Exception {
235
+                    public void run() {
234
                         if (((JTextField) e.getSource()).isEditable()) {
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
         localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
252
         localTarget.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
256
      */
266
      */
257
     @Override
267
     @Override
258
     public void keyTyped(final KeyEvent e) {
268
     public void keyTyped(final KeyEvent e) {
259
-    //Ignore
269
+        //Ignore
260
     }
270
     }
261
 
271
 
262
     /** 
272
     /** 
266
      */
276
      */
267
     @Override
277
     @Override
268
     public void keyPressed(final KeyEvent e) {
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
             final String line = target.getText();
281
             final String line = target.getText();
272
             if (UIUtilities.isCtrlDown(e) && e.getKeyCode() == KeyEvent.VK_ENTER
282
             if (UIUtilities.isCtrlDown(e) && e.getKeyCode() == KeyEvent.VK_ENTER
273
                     && (flags & HANDLE_RETURN) == HANDLE_RETURN) {
283
                     && (flags & HANDLE_RETURN) == HANDLE_RETURN) {
292
      */
302
      */
293
     @Override
303
     @Override
294
     public void keyReleased(final KeyEvent e) {
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
     /** {@inheritDoc} */
198
     /** {@inheritDoc} */
199
     @Override
199
     @Override
200
     public void topicChanged(final Channel channel, final Topic topic) {
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
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
6
 package com.dmdirc.addons.ui_swing.components.addonbrowser;
7
 
7
 
8
 import com.dmdirc.Main;
8
 import com.dmdirc.Main;
9
+import com.dmdirc.addons.ui_swing.UIUtilities;
9
 import com.dmdirc.ui.CoreUIUtils;
10
 import com.dmdirc.ui.CoreUIUtils;
10
 import com.dmdirc.util.DownloadListener;
11
 import com.dmdirc.util.DownloadListener;
11
 import com.dmdirc.util.Downloader;
12
 import com.dmdirc.util.Downloader;
62
         try {
63
         try {
63
             Downloader.downloadPage("http://addons.dmdirc.com/feed", 
64
             Downloader.downloadPage("http://addons.dmdirc.com/feed", 
64
                     Main.getConfigDir() + File.separator + "addons.feed", this);
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
         } catch (IOException ex) {
74
         } catch (IOException ex) {
67
             removeAll();
75
             removeAll();
68
             add(new JLabel("Unable to download feed."));
76
             add(new JLabel("Unable to download feed."));
73
     
81
     
74
     /** {@inheritDoc} */
82
     /** {@inheritDoc} */
75
     @Override
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
     /** {@inheritDoc} */
95
     /** {@inheritDoc} */
81
     @Override
96
     @Override
82
     public void setIndeterminate(final boolean indeterminate) {
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
     }
279
     }
280
 
280
 
281
     private void saveSplitPanePosition() {
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
     /** {@inheritDoc} */
292
     /** {@inheritDoc} */

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

19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
+
22
 package com.dmdirc.addons.ui_swing.components.frames;
23
 package com.dmdirc.addons.ui_swing.components.frames;
23
 
24
 
24
 import com.dmdirc.WritableFrameContainer;
25
 import com.dmdirc.WritableFrameContainer;
94
      * @param owner WritableFrameContainer owning this frame.
95
      * @param owner WritableFrameContainer owning this frame.
95
      * @param controller Swing controller
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
         super(owner, controller);
100
         super(owner, controller);
99
 
101
 
100
         initComponents();
102
         initComponents();
130
             public void run() {
132
             public void run() {
131
                 InputTextFrame.super.open();
133
                 InputTextFrame.super.open();
132
                 if (useAwayIndicator && getContainer().
134
                 if (useAwayIndicator && getContainer().
133
-                    getServer() != null) {
135
+                        getServer() != null) {
134
                     awayLabel.setVisible(getContainer().getServer().isAway());
136
                     awayLabel.setVisible(getContainer().getServer().isAway());
135
                 }
137
                 }
136
 
138
 
183
 
185
 
184
         getInputField().getActionMap().put("paste",
186
         getInputField().getActionMap().put("paste",
185
                 new InputTextFramePasteAction(this));
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
                 "paste");
190
                 "paste");
188
-        getInputField().getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl V"),
191
+        getInputField().getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(
192
+                "ctrl V"),
189
                 "paste");
193
                 "paste");
190
     }
194
     }
191
 
195
 
253
      */
257
      */
254
     @Override
258
     @Override
255
     public void setAwayIndicator(final boolean awayState) {
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
             if (point != null) {
318
             if (point != null) {
308
                 initPopupMenu();
319
                 initPopupMenu();
309
                 inputFieldPopup.show(this, (int) point.getX(),
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
         super.processMouseEvent(e);
325
         super.processMouseEvent(e);
334
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
345
                     getSystemClipboard().getData(DataFlavor.stringFlavor);
335
             doPaste(clipboard);
346
             doPaste(clipboard);
336
         } catch (IOException ex) {
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
         } catch (UnsupportedFlavorException ex) {
350
         } catch (UnsupportedFlavorException ex) {
340
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
351
             Logger.userError(ErrorLevel.LOW, "Unsupported clipboard type", ex);
341
         }
352
         }
350
     protected void doPaste(final String clipboard) {
361
     protected void doPaste(final String clipboard) {
351
         String[] clipboardLines;
362
         String[] clipboardLines;
352
         //check theres something to paste
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
             final int caretPosition = getInputField().getCaretPosition();
366
             final int caretPosition = getInputField().getCaretPosition();
355
             final String inputFieldText = getInputField().getText();
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
             //check the limit
370
             //check the limit
358
             final Integer pasteTrigger = getConfigManager().getOptionInt("ui",
371
             final Integer pasteTrigger = getConfigManager().getOptionInt("ui",
359
                     "pasteProtectionLimit");
372
                     "pasteProtectionLimit");
360
             //check whether the number of lines is over the limit
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
                 //show the multi line paste dialog
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
                 inputField.setText("");
379
                 inputField.setText("");
365
             } else {
380
             } else {
366
                 //send the lines
381
                 //send the lines
391
 
406
 
392
         if ("ui".equals(domain) && getConfigManager() != null) {
407
         if ("ui".equals(domain) && getConfigManager() != null) {
393
             if (getInputField() != null) {
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
                             "ui", "inputbackgroundcolour",
413
                             "ui", "inputbackgroundcolour",
398
                             "ui", "backgroundcolour"));
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
                             "ui", "inputforegroundcolour",
419
                             "ui", "inputforegroundcolour",
403
                             "ui", "foregroundcolour"));
420
                             "ui", "foregroundcolour"));
404
-                    getInputField().setCaretColor(getConfigManager().getOptionColour(
421
+                    getInputField().setCaretColor(getConfigManager().
422
+                            getOptionColour(
405
                             "ui", "inputforegroundcolour",
423
                             "ui", "inputforegroundcolour",
406
                             "ui", "foregroundcolour"));
424
                             "ui", "foregroundcolour"));
407
                 }
425
                 }
444
                 menu.add(populatePopupMenu(new JMenu(menuItem.getName()),
462
                 menu.add(populatePopupMenu(new JMenu(menuItem.getName()),
445
                         menuItem.getSubMenu(), arguments));
463
                         menuItem.getSubMenu(), arguments));
446
             } else {
464
             } else {
447
-                menu.add(new JMenuItem(new CommandAction(getCommandParser(),
465
+                menu.add(
466
+                        new JMenuItem(
467
+                        new CommandAction(getCommandParser(),
448
                         this, menuItem.getName(), menuItem.getCommand(arguments))));
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
 import com.dmdirc.util.StringTranscoder;
48
 import com.dmdirc.util.StringTranscoder;
49
 import com.dmdirc.config.ConfigManager;
49
 import com.dmdirc.config.ConfigManager;
50
 import com.dmdirc.interfaces.ConfigChangeListener;
50
 import com.dmdirc.interfaces.ConfigChangeListener;
51
-import com.dmdirc.interfaces.FrameInfoAdapter;
51
+import com.dmdirc.interfaces.FrameInfoListener;
52
 import com.dmdirc.logger.ErrorLevel;
52
 import com.dmdirc.logger.ErrorLevel;
53
 import com.dmdirc.logger.Logger;
53
 import com.dmdirc.logger.Logger;
54
 import com.dmdirc.ui.IconManager;
54
 import com.dmdirc.ui.IconManager;
102
  */
102
  */
103
 public abstract class TextFrame extends JInternalFrame implements Window,
103
 public abstract class TextFrame extends JInternalFrame implements Window,
104
         PropertyChangeListener, InternalFrameListener,
104
         PropertyChangeListener, InternalFrameListener,
105
-        MouseListener, KeyListener, ConfigChangeListener {
105
+        MouseListener, KeyListener, ConfigChangeListener, FrameInfoListener {
106
 
106
 
107
     /** Logger to use. */
107
     /** Logger to use. */
108
     private static final java.util.logging.Logger LOGGER =
108
     private static final java.util.logging.Logger LOGGER =
165
 
165
 
166
         setFrameIcon(IconManager.getIconManager().getIcon(owner.getIcon()));
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
         try {
170
         try {
178
             transcoder = new StringTranscoder(Charset.forName(
171
             transcoder = new StringTranscoder(Charset.forName(
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
 
24
 
25
 import com.dmdirc.Main;
25
 import com.dmdirc.Main;
26
 import com.dmdirc.addons.ui_swing.SwingController;
26
 import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.addons.ui_swing.UIUtilities;
27
 import com.dmdirc.config.prefs.PreferencesInterface;
28
 import com.dmdirc.config.prefs.PreferencesInterface;
28
 import com.dmdirc.plugins.PluginInfo;
29
 import com.dmdirc.plugins.PluginInfo;
29
 import com.dmdirc.plugins.PluginManager;
30
 import com.dmdirc.plugins.PluginManager;
163
                 PluginManager.getPluginManager().getPossiblePluginInfos(true);
164
                 PluginManager.getPluginManager().getPossiblePluginInfos(true);
164
         Collections.sort(list);
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
         return pluginList;
179
         return pluginList;
173
     }
180
     }
174
 
181
 

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

131
      * @param text New text
131
      * @param text New text
132
      */
132
      */
133
     public void setText(final String text) {
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
 
22
 
23
 package com.dmdirc.addons.ui_swing.components.themepanel;
23
 package com.dmdirc.addons.ui_swing.components.themepanel;
24
 
24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.config.IdentityManager;
26
 import com.dmdirc.config.IdentityManager;
26
 import com.dmdirc.config.prefs.PreferencesInterface;
27
 import com.dmdirc.config.prefs.PreferencesInterface;
27
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
28
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
143
                 getAvailableThemes().values());
144
                 getAvailableThemes().values());
144
         Collections.sort(list);
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
         return themeList;
165
         return themeList;
159
     }
166
     }
160
 
167
 

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

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.dialogs.about;
23
 package com.dmdirc.addons.ui_swing.dialogs.about;
24
 
24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
26
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
26
 import com.dmdirc.logger.ErrorLevel;
27
 import com.dmdirc.logger.ErrorLevel;
27
 import com.dmdirc.logger.Logger;
28
 import com.dmdirc.logger.Logger;
121
 
122
 
122
     private void addLicensesToNode(final Map<String, InputStream> licences,
123
     private void addLicensesToNode(final Map<String, InputStream> licences,
123
             final DefaultMutableTreeNode root) {
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
         for (Entry<String, InputStream> entry : licences.entrySet()) {
134
         for (Entry<String, InputStream> entry : licences.entrySet()) {
127
             final Licence licence = createLicence(entry);
135
             final Licence licence = createLicence(entry);
128
             if (licence == null) {
136
             if (licence == null) {
129
                 continue;
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
 
117
 
118
         title = new TitlePanel(BorderFactory.createEtchedBorder(),
118
         title = new TitlePanel(BorderFactory.createEtchedBorder(),
119
                 "Preferences");
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
         add(title, "pushx, growx, h 45!");
123
         add(title, "pushx, growx, h 45!");
124
         add(scrollPane, "grow, push");
124
         add(scrollPane, "grow, push");
132
             @Override
132
             @Override
133
             public void correctBounds(final ComponentWrapper cw) {
133
             public void correctBounds(final ComponentWrapper cw) {
134
                 if (cw.getComponent() == scrollPane) {
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
                     }
209
                     }
210
                 }
210
                 }
211
             });
211
             });
212
-        }        
212
+        }
213
     }
213
     }
214
 
214
 
215
     /**
215
     /**
248
      * @param b
248
      * @param b
249
      */
249
      */
250
     public void setWaiting(final boolean b) {
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
      * @param message Message to display
264
      * @param message Message to display
258
      */
265
      */
259
     public void setError(final String message) {
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
             final JPanel panel, final String path) {
134
             final JPanel panel, final String path) {
135
 
135
 
136
         if (!category.getDescription().isEmpty()) {
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
                     "growx, pushx, wrap 2*unrel");
143
                     "growx, pushx, wrap 2*unrel");
144
+                }
145
+            });
139
         }
146
         }
140
 
147
 
141
         for (PreferencesCategory child : category.getSubcats()) {
148
         for (PreferencesCategory child : category.getSubcats()) {
191
             /** {@inheritDoc} */
198
             /** {@inheritDoc} */
192
             @Override
199
             @Override
193
             public void run() {
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
         categoryPanel.getToolTipPanel().registerTooltipHandler(label,
207
         categoryPanel.getToolTipPanel().registerTooltipHandler(label,
200
                 getTooltipText(setting, categoryPanel));
208
                 getTooltipText(setting, categoryPanel));
201
         categoryPanel.getToolTipPanel().registerTooltipHandler(option,
209
         categoryPanel.getToolTipPanel().registerTooltipHandler(option,
247
      * @return A TextLabel with the appropriate text and tooltip
255
      * @return A TextLabel with the appropriate text and tooltip
248
      */
256
      */
249
     private TextLabel getLabel(final PreferencesSetting setting) {
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
         return label;
274
         return label;
259
     }
275
     }
266
      */
282
      */
267
     private void addInlineCategory(final PreferencesCategory category,
283
     private void addInlineCategory(final PreferencesCategory category,
268
             final JPanel parent) {
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
         parent.add(panel, "span, growx, pushx, wrap");
301
         parent.add(panel, "span, growx, pushx, wrap");
278
 
302
 
279
         initCategory(category, panel, "");
303
         initCategory(category, panel, "");
287
      * @param namePrefix Category name prefix
311
      * @param namePrefix Category name prefix
288
      */
312
      */
289
     private JPanel addCategory(final PreferencesCategory category) {
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
         return panel;
330
         return panel;
300
     }
331
     }

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

61
      */
61
      */
62
     public FrameContainerMenuItem(final FrameContainer frame,
62
     public FrameContainerMenuItem(final FrameContainer frame,
63
             final WindowMenuFrameManager manager) {
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
         this.frame = frame;
67
         this.frame = frame;
67
         this.manager = manager;
68
         this.manager = manager;
78
             /** {@inheritDoc} */
79
             /** {@inheritDoc} */
79
             @Override
80
             @Override
80
             public void run() {
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
                     setIcon(IconManager.getIconManager().getIcon(icon));
84
                     setIcon(IconManager.getIconManager().getIcon(icon));
84
                 }
85
                 }
85
             }
86
             }
94
             /** {@inheritDoc} */
95
             /** {@inheritDoc} */
95
             @Override
96
             @Override
96
             public void run() {
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
                     setText(name);
100
                     setText(name);
100
                 }
101
                 }
101
             }
102
             }

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

25
 import com.dmdirc.FrameContainer;
25
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainerComparator;
26
 import com.dmdirc.FrameContainerComparator;
27
 import com.dmdirc.addons.ui_swing.SwingController;
27
 import com.dmdirc.addons.ui_swing.SwingController;
28
+import com.dmdirc.addons.ui_swing.UIUtilities;
28
 import com.dmdirc.config.IdentityManager;
29
 import com.dmdirc.config.IdentityManager;
29
 import com.dmdirc.interfaces.SelectionListener;
30
 import com.dmdirc.interfaces.SelectionListener;
30
 import com.dmdirc.ui.IconManager;
31
 import com.dmdirc.ui.IconManager;
31
 import com.dmdirc.ui.WindowManager;
32
 import com.dmdirc.ui.WindowManager;
32
 import com.dmdirc.ui.interfaces.Window;
33
 import com.dmdirc.ui.interfaces.Window;
33
 import com.dmdirc.ui.interfaces.FrameListener;
34
 import com.dmdirc.ui.interfaces.FrameListener;
35
+import com.dmdirc.util.ReturnableThread;
34
 
36
 
37
+import java.awt.Component;
35
 import java.awt.event.ActionEvent;
38
 import java.awt.event.ActionEvent;
36
 import java.awt.event.ActionListener;
39
 import java.awt.event.ActionListener;
40
+import java.util.ArrayList;
41
+import java.util.Collection;
37
 import java.util.Collections;
42
 import java.util.Collections;
38
 import java.util.HashMap;
43
 import java.util.HashMap;
39
 import java.util.Map;
44
 import java.util.Map;
40
 import java.util.concurrent.atomic.AtomicBoolean;
45
 import java.util.concurrent.atomic.AtomicBoolean;
46
+import javax.swing.AbstractButton;
41
 
47
 
42
 import javax.swing.JMenu;
48
 import javax.swing.JMenu;
43
 import javax.swing.JMenuItem;
49
 import javax.swing.JMenuItem;
147
     /** {@inheritDoc} */
153
     /** {@inheritDoc} */
148
     @Override
154
     @Override
149
     public void addWindow(final FrameContainer window) {
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
         items.put(window, item);
166
         items.put(window, item);
153
-        add(item, getIndex(window, this));
167
+        final int index = getIndex(window, this);
154
         window.addSelectionListener(this);
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
     /** {@inheritDoc} */
179
     /** {@inheritDoc} */
158
     @Override
180
     @Override
159
     public void delWindow(final FrameContainer window) {
181
     public void delWindow(final FrameContainer window) {
182
+        final AbstractButton item;
160
         if (items.containsKey(window)) {
183
         if (items.containsKey(window)) {
161
-            remove(items.get(window));
184
+            item = items.get(window);
162
             items.remove(window);
185
             items.remove(window);
163
         } else if (menus.containsKey(window)) {
186
         } else if (menus.containsKey(window)) {
164
-            remove(menus.get(window));
187
+            item = menus.get(window);
165
             menus.remove(window);
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
         window.removeSelectionListener(this);
200
         window.removeSelectionListener(this);
168
     }
201
     }
169
 
202
 
171
     @Override
204
     @Override
172
     public void addWindow(final FrameContainer parent,
205
     public void addWindow(final FrameContainer parent,
173
             final FrameContainer window) {
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
         if (!menus.containsKey(parent)) {
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
             replaceItemWithMenu(getParentMenu(parent), items.get(parent),
228
             replaceItemWithMenu(getParentMenu(parent), items.get(parent),
181
                     replacement);
229
                     replacement);
182
             parentMenu = replacement;
230
             parentMenu = replacement;
184
             parentMenu = menus.get(parent);
232
             parentMenu = menus.get(parent);
185
         }
233
         }
186
         items.put(window, item);
234
         items.put(window, item);
187
-        parentMenu.add(item, getIndex(window, parentMenu));
188
         window.addSelectionListener(this);
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
     /** {@inheritDoc} */
246
     /** {@inheritDoc} */
194
             final FrameContainer window) {
249
             final FrameContainer window) {
195
         if (items.containsKey(window)) {
250
         if (items.containsKey(window)) {
196
             final JMenu menu = getParentMenu(window);
251
             final JMenu menu = getParentMenu(window);
197
-            menu.remove(items.get(window));
252
+            final FrameContainerMenuItem item = items.get(window);
198
             items.remove(window);
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
         } else if (menus.containsKey(window)) {
267
         } else if (menus.containsKey(window)) {
204
             menus.get(parent).remove(menus.get(window));
268
             menus.get(parent).remove(menus.get(window));
205
             menus.remove(window);
269
             menus.remove(window);
222
 
286
 
223
     private void replaceItemWithMenu(final JMenu parentMenu,
287
     private void replaceItemWithMenu(final JMenu parentMenu,
224
             final FrameContainerMenuItem item, final FrameContainerMenu menu) {
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
         items.remove(item.getFrame());
298
         items.remove(item.getFrame());
229
         menus.put(menu.getFrame(), menu);
299
         menus.put(menu.getFrame(), menu);
230
         menuItems.put(item.getFrame(), item);
300
         menuItems.put(item.getFrame(), item);
259
     /** {@inheritDoc} */
329
     /** {@inheritDoc} */
260
     @Override
330
     @Override
261
     public void selectionChanged(final Window window) {
331
     public void selectionChanged(final Window window) {
332
+        final Collection<SelectionListener> values =
333
+                new ArrayList<SelectionListener>();
262
         synchronized (menus) {
334
         synchronized (menus) {
263
             synchronized (items) {
335
             synchronized (items) {
264
                 synchronized (menuItems) {
336
                 synchronized (menuItems) {
265
                     activeWindow = window;
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
      */
396
      */
323
     private int getIndex(final FrameContainer newChild, final JMenu menu) {
397
     private int getIndex(final FrameContainer newChild, final JMenu menu) {
324
         final int count = menu == this ? itemCount : 0;
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
                 continue;
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
             if (sortBefore(newChild, child)) {
423
             if (sortBefore(newChild, child)) {
332
                 return i;
424
                 return i;
333
             } else if (!sortAfter(newChild, child) && IdentityManager.
425
             } else if (!sortAfter(newChild, child) && IdentityManager.

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

22
 
22
 
23
 package com.dmdirc.addons.windowstatus;
23
 package com.dmdirc.addons.windowstatus;
24
 
24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25
 import com.dmdirc.ui.interfaces.StatusBarComponent;
26
 import com.dmdirc.ui.interfaces.StatusBarComponent;
26
 import com.dmdirc.ui.messages.Styliser;
27
 import com.dmdirc.ui.messages.Styliser;
27
 
28
 
58
      * @param text New text
59
      * @param text New text
59
      */
60
      */
60
     public void setText(final String text) {
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
 import com.dmdirc.actions.ActionManager;
30
 import com.dmdirc.actions.ActionManager;
31
 import com.dmdirc.actions.CoreActionType;
31
 import com.dmdirc.actions.CoreActionType;
32
 import com.dmdirc.actions.interfaces.ActionType;
32
 import com.dmdirc.actions.interfaces.ActionType;
33
+import com.dmdirc.addons.ui_swing.UIUtilities;
33
 import com.dmdirc.config.IdentityManager;
34
 import com.dmdirc.config.IdentityManager;
34
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
35
 import com.dmdirc.config.prefs.PluginPreferencesCategory;
35
 import com.dmdirc.config.prefs.PreferencesCategory;
36
 import com.dmdirc.config.prefs.PreferencesCategory;
45
 import com.dmdirc.ui.WindowManager;
46
 import com.dmdirc.ui.WindowManager;
46
 import com.dmdirc.ui.interfaces.InputWindow;
47
 import com.dmdirc.ui.interfaces.InputWindow;
47
 import com.dmdirc.ui.interfaces.Window;
48
 import com.dmdirc.ui.interfaces.Window;
49
+import com.dmdirc.util.ReturnableThread;
48
 
50
 
49
 import java.util.Hashtable;
51
 import java.util.Hashtable;
50
 import java.util.Map;
52
 import java.util.Map;
58
 public final class WindowStatusPlugin extends Plugin implements ActionListener, ConfigChangeListener {
60
 public final class WindowStatusPlugin extends Plugin implements ActionListener, ConfigChangeListener {
59
 
61
 
60
     /** The panel we use in the status bar. */
62
     /** The panel we use in the status bar. */
61
-    private final WindowStatusPanel panel = new WindowStatusPanel();
63
+    private final WindowStatusPanel panel;
62
     private boolean showname, shownone;
64
     private boolean showname, shownone;
63
     private String nonePrefix;
65
     private String nonePrefix;
64
 
66
 
65
     /** Creates a new instance of WindowStatusPlugin. */
67
     /** Creates a new instance of WindowStatusPlugin. */
66
     public WindowStatusPlugin() {
68
     public WindowStatusPlugin() {
67
         super();
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