瀏覽代碼

More J8 improvements.

pull/106/head
Chris Smith 9 年之前
父節點
當前提交
075d454abb
共有 36 個檔案被更改,包括 416 行新增920 行删除
  1. 38
    52
      dcc/src/com/dmdirc/addons/dcc/ui/TransferPanel.java
  2. 11
    41
      osd/src/com/dmdirc/addons/osd/OsdManager.java
  3. 1
    1
      osd/src/com/dmdirc/addons/osd/OsdPlugin.java
  4. 1
    7
      osd/src/com/dmdirc/addons/osd/OsdWindow.java
  5. 5
    28
      ui_swing/src/com/dmdirc/addons/ui_swing/SwingManager.java
  6. 16
    26
      ui_swing/src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java
  7. 4
    22
      ui_swing/src/com/dmdirc/addons/ui_swing/adapters/ObservableListTableModelAdapter.java
  8. 7
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/commands/PopInCommand.java
  9. 7
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/commands/PopOutCommand.java
  10. 7
    21
      ui_swing/src/com/dmdirc/addons/ui_swing/components/AwayLabel.java
  11. 1
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/components/SplitPane.java
  12. 2
    14
      ui_swing/src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java
  13. 1
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/components/ToolTipPanel.java
  14. 32
    75
      ui_swing/src/com/dmdirc/addons/ui_swing/components/TopicBar.java
  15. 2
    14
      ui_swing/src/com/dmdirc/addons/ui_swing/components/TreeScroller.java
  16. 1
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/components/TypingLabel.java
  17. 10
    20
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java
  18. 5
    8
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java
  19. 13
    17
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java
  20. 14
    18
      ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/ThemePanel.java
  21. 5
    9
      ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java
  22. 1
    6
      ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java
  23. 56
    210
      ui_swing/src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputField.java
  24. 19
    23
      ui_swing/src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java
  25. 7
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java
  26. 9
    15
      ui_swing/src/com/dmdirc/addons/ui_swing/components/statusbar/StatusbarPanel.java
  27. 9
    25
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/error/ErrorTableModel.java
  28. 21
    30
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java
  29. 9
    12
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java
  30. 8
    12
      ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/updater/SwingUpdaterDialog.java
  31. 1
    6
      ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/tree/Tree.java
  32. 54
    69
      ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java
  33. 7
    11
      ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuScroller.java
  34. 30
    60
      ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPane.java
  35. 1
    7
      ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPaneCanvas.java
  36. 1
    7
      windowstatus/src/com/dmdirc/addons/windowstatus/WindowStatusPanel.java

+ 38
- 52
dcc/src/com/dmdirc/addons/dcc/ui/TransferPanel.java 查看文件

@@ -173,26 +173,22 @@ public class TransferPanel extends JPanel implements ActionListener,
173 173
 
174 174
     @Override
175 175
     public void socketClosed(final DCCTransfer dcc) {
176
-        UIUtilities.invokeLater(new Runnable() {
176
+        UIUtilities.invokeLater(() -> {
177
+            if (transferContainer.isComplete()) {
178
+                status.setText("Status: Transfer Complete.");
177 179
 
178
-            @Override
179
-            public void run() {
180
-                if (transferContainer.isComplete()) {
181
-                    status.setText("Status: Transfer Complete.");
182
-
183
-                    if (transferContainer.shouldShowOpenButton()) {
184
-                        openButton.setVisible(true);
185
-                    }
180
+                if (transferContainer.shouldShowOpenButton()) {
181
+                    openButton.setVisible(true);
182
+                }
186 183
 
187
-                    progress.setValue(100);
188
-                    button.setText("Close Window");
184
+                progress.setValue(100);
185
+                button.setText("Close Window");
186
+            } else {
187
+                status.setText("Status: Transfer Failed.");
188
+                if (dcc.getType() == DCCTransfer.TransferType.SEND) {
189
+                    button.setText("Resend");
189 190
                 } else {
190
-                    status.setText("Status: Transfer Failed.");
191
-                    if (dcc.getType() == DCCTransfer.TransferType.SEND) {
192
-                        button.setText("Resend");
193
-                    } else {
194
-                        button.setText("Close Window");
195
-                    }
191
+                    button.setText("Close Window");
196 192
                 }
197 193
             }
198 194
         });
@@ -200,49 +196,39 @@ public class TransferPanel extends JPanel implements ActionListener,
200 196
 
201 197
     @Override
202 198
     public void socketOpened(final DCCTransfer dcc) {
203
-        UIUtilities.invokeLater(new Runnable() {
204
-
205
-            @Override
206
-            public void run() {
207
-                status.setText("Status: Socket Opened");
208
-            }
209
-        });
199
+        UIUtilities.invokeLater(() -> status.setText("Status: Socket Opened"));
210 200
     }
211 201
 
212 202
     @Override
213 203
     public void dataTransferred(final DCCTransfer dcc, final int bytes) {
214
-        UIUtilities.invokeLater(new Runnable() {
215
-
216
-            @Override
217
-            public void run() {
218
-                if (dcc.getType() == DCCTransfer.TransferType.SEND) {
219
-                    status.setText("Status: Sending");
220
-                } else {
221
-                    status.setText("Status: Receiving");
222
-                }
223
-
224
-                progress.setValue((int) transferContainer.getPercent());
204
+        UIUtilities.invokeLater(() -> {
205
+            if (dcc.getType() == DCCTransfer.TransferType.SEND) {
206
+                status.setText("Status: Sending");
207
+            } else {
208
+                status.setText("Status: Receiving");
209
+            }
225 210
 
226
-                final double bytesPerSecond = transferContainer
227
-                        .getBytesPerSecond();
211
+            progress.setValue((int) transferContainer.getPercent());
228 212
 
229
-                if (bytesPerSecond > 1048576) {
230
-                    speed.setText(String.format("Speed: %.2f MiB/s",
231
-                            bytesPerSecond / 1048576));
232
-                } else if (bytesPerSecond > 1024) {
233
-                    speed.setText(String.format("Speed: %.2f KiB/s",
234
-                            bytesPerSecond / 1024));
235
-                } else {
236
-                    speed.setText(String.format("Speed: %.2f B/s",
237
-                            bytesPerSecond));
238
-                }
213
+            final double bytesPerSecond = transferContainer
214
+                    .getBytesPerSecond();
239 215
 
240
-                remaining.setText(String.format("Time Remaining: %s",
241
-                        DateUtils.formatDurationAsTime((int) transferContainer.getRemainingTime())));
242
-                taken.setText(String.format("Time Taken: %s", transferContainer
243
-                        .getStartTime() == 0 ? "N/A" : DateUtils.formatDurationAsTime(
244
-                        (int) transferContainer.getElapsedTime())));
216
+            if (bytesPerSecond > 1048576) {
217
+                speed.setText(String.format("Speed: %.2f MiB/s",
218
+                        bytesPerSecond / 1048576));
219
+            } else if (bytesPerSecond > 1024) {
220
+                speed.setText(String.format("Speed: %.2f KiB/s",
221
+                        bytesPerSecond / 1024));
222
+            } else {
223
+                speed.setText(String.format("Speed: %.2f B/s",
224
+                        bytesPerSecond));
245 225
             }
226
+
227
+            remaining.setText(String.format("Time Remaining: %s",
228
+                    DateUtils.formatDurationAsTime((int) transferContainer.getRemainingTime())));
229
+            taken.setText(String.format("Time Taken: %s", transferContainer
230
+                    .getStartTime() == 0 ? "N/A" : DateUtils.formatDurationAsTime(
231
+                    (int) transferContainer.getElapsedTime())));
246 232
         });
247 233
     }
248 234
 

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

@@ -32,7 +32,6 @@ import java.util.ArrayList;
32 32
 import java.util.LinkedList;
33 33
 import java.util.List;
34 34
 import java.util.Queue;
35
-import java.util.concurrent.Callable;
36 35
 
37 36
 /**
38 37
  * Class to manage OSD Windows.
@@ -43,8 +42,6 @@ public class OsdManager {
43 42
     private final Window mainFrame;
44 43
     /** The controller to read/write settings with. */
45 44
     private final IdentityController identityController;
46
-    /** The Plugin that owns this OSD Manager. */
47
-    private final OsdPlugin plugin;
48 45
     /** The colour manager to use to parse colours. */
49 46
     private final ColourManager colourManager;
50 47
     /** List of OSD Windows. */
@@ -55,11 +52,9 @@ public class OsdManager {
55 52
     private final String domain;
56 53
 
57 54
     public OsdManager(final Window mainFrame, final IdentityController identityController,
58
-            final OsdPlugin plugin, final ColourManager colourManager,
59
-            final PluginInfo pluginInfo) {
55
+            final ColourManager colourManager, final PluginInfo pluginInfo) {
60 56
         this.mainFrame = mainFrame;
61 57
         this.identityController = identityController;
62
-        this.plugin = plugin;
63 58
         this.colourManager = colourManager;
64 59
         this.domain = pluginInfo.getDomain();
65 60
     }
@@ -95,10 +90,10 @@ public class OsdManager {
95 90
      * <p>
96 91
      * This method needs to be synchronised to ensure that the window list is not modified in
97 92
      * between the invocation of
98
-     * {@link OsdPolicy#getYPosition(com.dmdirc.addons.osd.OsdManager, int)} and the point at which
93
+     * {@link OsdPolicy#getYPosition(OsdManager, int)} and the point at which
99 94
      * the {@link OsdWindow} is added to the windowList.
100 95
      *
101
-     * @see OsdPolicy#getYPosition(com.dmdirc.addons.osd.OsdManager, int)
96
+     * @see OsdPolicy#getYPosition(OsdManager, int)
102 97
      * @param message Text to display in the OSD window.
103 98
      */
104 99
     private synchronized void displayWindow(final int timeout, final String message) {
@@ -107,20 +102,12 @@ public class OsdManager {
107 102
         final int startY = identityController.getGlobalConfiguration()
108 103
                 .getOptionInt(domain, "locationY");
109 104
 
110
-        windowList.add(UIUtilities.invokeAndWait(
111
-                new Callable<OsdWindow>() {
112
-
113
-                    @Override
114
-                    public OsdWindow call() {
115
-                        return new OsdWindow(
116
-                                mainFrame,
117
-                                identityController, OsdManager.this, colourManager,
118
-                                timeout, message, false,
119
-                                identityController.getGlobalConfiguration().getOptionInt(
120
-                                        domain, "locationX"), policy.getYPosition(OsdManager.this,
121
-                                        startY), domain);
122
-                    }
123
-                }));
105
+        windowList.add(UIUtilities.invokeAndWait(() -> new OsdWindow(
106
+                mainFrame,
107
+                identityController, this, colourManager,
108
+                timeout, message, false,
109
+                identityController.getGlobalConfiguration().getOptionInt(
110
+                        domain, "locationX"), policy.getYPosition(this, startY), domain)));
124 111
     }
125 112
 
126 113
     /**
@@ -142,13 +129,7 @@ public class OsdManager {
142 129
 
143 130
         windowList.remove(window);
144 131
 
145
-        UIUtilities.invokeLater(new Runnable() {
146
-
147
-            @Override
148
-            public void run() {
149
-                window.dispose();
150
-            }
151
-        });
132
+        UIUtilities.invokeLater(window::dispose);
152 133
 
153 134
         final List<OsdWindow> newList = getWindowList();
154 135
         for (OsdWindow otherWindow : newList.subList(closedIndex, newList.size())) {
@@ -165,9 +146,7 @@ public class OsdManager {
165 146
      * Destroy all OSD Windows.
166 147
      */
167 148
     public void closeAll() {
168
-        for (OsdWindow window : getWindowList()) {
169
-            closeWindow(window);
170
-        }
149
+        getWindowList().forEach(this::closeWindow);
171 150
     }
172 151
 
173 152
     /**
@@ -188,13 +167,4 @@ public class OsdManager {
188 167
         return windowList.size();
189 168
     }
190 169
 
191
-    /**
192
-     * Return the current plugin.
193
-     *
194
-     * @return Returns current plugin instance.
195
-     */
196
-    public OsdPlugin getPlugin() {
197
-        return plugin;
198
-    }
199
-
200 170
 }

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

@@ -96,7 +96,7 @@ public class OsdPlugin extends BaseCommandPlugin implements
96 96
         this.colourManager = colourManager;
97 97
         this.mainFrame = swingController.getMainFrame();
98 98
         this.domain = pluginInfo.getDomain();
99
-        osdManager = new OsdManager(mainFrame, identityController, this, colourManager, pluginInfo);
99
+        osdManager = new OsdManager(mainFrame, identityController, colourManager, pluginInfo);
100 100
         registerCommand(new OsdCommand(commandController, osdManager), OsdCommand.INFO);
101 101
     }
102 102
 

+ 1
- 7
osd/src/com/dmdirc/addons/osd/OsdWindow.java 查看文件

@@ -281,13 +281,7 @@ public class OsdWindow extends JDialog implements MouseListener, MouseMotionList
281 281
         this.desiredX = x;
282 282
         this.desiredY = y;
283 283
 
284
-        UIUtilities.invokeLater(new Runnable() {
285
-
286
-            @Override
287
-            public void run() {
288
-                setLocation(getDesiredX(), getDesiredY());
289
-            }
290
-        });
284
+        UIUtilities.invokeLater(() -> setLocation(getDesiredX(), getDesiredY()));
291 285
     }
292 286
 
293 287
     @Override

+ 5
- 28
ui_swing/src/com/dmdirc/addons/ui_swing/SwingManager.java 查看文件

@@ -162,13 +162,8 @@ public class SwingManager {
162 162
         eventBus.subscribe(this);
163 163
         eventBus.subscribe(mainFrame);
164 164
         eventBus.subscribe(linkHandler);
165
-        SwingUtilities.invokeLater(new Runnable() {
166
-
167
-            @Override
168
-            public void run() {
169
-                errorListDialogProvider.get().load(ErrorManager.getErrorManager());
170
-            }
171
-        });
165
+        SwingUtilities.invokeLater(
166
+                () -> errorListDialogProvider.get().load(ErrorManager.getErrorManager()));
172 167
     }
173 168
 
174 169
     /**
@@ -180,13 +175,7 @@ public class SwingManager {
180 175
         }
181 176
         windowManager.removeListener(windowFactory.get());
182 177
         windowFactory.get().dispose();
183
-        SwingUtilities.invokeLater(new Runnable() {
184
-
185
-            @Override
186
-            public void run() {
187
-                errorListDialogProvider.get().dispose();
188
-            }
189
-        });
178
+        SwingUtilities.invokeLater(() -> errorListDialogProvider.get().dispose());
190 179
         swingEventBus.unsubscribe(mainFrame);
191 180
         swingEventBus.unsubscribe(ctrlTabManager);
192 181
         mainFrame.dispose();
@@ -225,25 +214,13 @@ public class SwingManager {
225 214
     public void showURLDialog(final UnknownURLEvent event) {
226 215
         if (!event.isHandled()) {
227 216
             event.setHandled(true);
228
-            UIUtilities.invokeLater(new Runnable() {
229
-
230
-                @Override
231
-                public void run() {
232
-                    urlDialogFactory.getURLDialog(event.getURI()).display();
233
-                }
234
-            });
217
+            UIUtilities.invokeLater(() -> urlDialogFactory.getURLDialog(event.getURI()).display());
235 218
         }
236 219
     }
237 220
 
238 221
     @Handler
239 222
     public void showFeedbackNag(final FeedbackNagEvent event) {
240
-        UIUtilities.invokeLater(new Runnable() {
241
-
242
-            @Override
243
-            public void run() {
244
-                feedbackNagProvider.get();
245
-            }
246
-        });
223
+        UIUtilities.invokeLater(feedbackNagProvider::get);
247 224
     }
248 225
 
249 226
 }

+ 16
- 26
ui_swing/src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java 查看文件

@@ -118,22 +118,19 @@ public class SwingWindowFactory implements FrameListener {
118 118
     @Override
119 119
     public void addWindow(final FrameContainer parent, final FrameContainer window,
120 120
             final boolean focus) {
121
-        UIUtilities.invokeLater(new Runnable() {
122
-            @Override
123
-            public void run() {
124
-                final TextFrame parentWindow = getSwingWindow(parent);
125
-                final TextFrame childWindow = doAddWindow(window);
126
-
127
-                if (childWindow == null) {
128
-                    return;
129
-                }
130
-                swingEventBus.publish(new SwingWindowAddedEvent(
131
-                        Optional.ofNullable(parentWindow), childWindow));
132
-
133
-                if (focus) {
134
-                    swingEventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(
135
-                                    Optional.ofNullable(childWindow)));
136
-                }
121
+        UIUtilities.invokeLater(() -> {
122
+            final TextFrame parentWindow = getSwingWindow(parent);
123
+            final TextFrame childWindow = doAddWindow(window);
124
+
125
+            if (childWindow == null) {
126
+                return;
127
+            }
128
+            swingEventBus.publish(new SwingWindowAddedEvent(
129
+                    Optional.ofNullable(parentWindow), childWindow));
130
+
131
+            if (focus) {
132
+                swingEventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(
133
+                                Optional.ofNullable(childWindow)));
137 134
             }
138 135
         });
139 136
     }
@@ -170,13 +167,8 @@ public class SwingWindowFactory implements FrameListener {
170 167
         final TextFrame parentWindow = getSwingWindow(parent);
171 168
         final TextFrame childWindow = getSwingWindow(window);
172 169
         windows.remove(window);
173
-        UIUtilities.invokeLater(new Runnable() {
174
-            @Override
175
-            public void run() {
176
-                swingEventBus.publish(new SwingWindowDeletedEvent(
177
-                        Optional.ofNullable(parentWindow), childWindow));
178
-            }
179
-        });
170
+        UIUtilities.invokeLater(() -> swingEventBus.publish(new SwingWindowDeletedEvent(
171
+                Optional.ofNullable(parentWindow), childWindow)));
180 172
     }
181 173
 
182 174
     /**
@@ -193,9 +185,7 @@ public class SwingWindowFactory implements FrameListener {
193 185
 
194 186
     /** Disposes of this window factory, removing all listeners. */
195 187
     public void dispose() {
196
-        for (TextFrame frame : windows.values()) {
197
-            frame.dispose();
198
-        }
188
+        windows.values().forEach(TextFrame::dispose);
199 189
     }
200 190
 
201 191
     /**

+ 4
- 22
ui_swing/src/com/dmdirc/addons/ui_swing/adapters/ObservableListTableModelAdapter.java 查看文件

@@ -52,7 +52,7 @@ public abstract class ObservableListTableModelAdapter<T> extends AbstractTableMo
52 52
 
53 53
     @Override
54 54
     public int getRowCount() {
55
-        return this.list.size();
55
+        return list.size();
56 56
     }
57 57
 
58 58
     /**
@@ -63,37 +63,19 @@ public abstract class ObservableListTableModelAdapter<T> extends AbstractTableMo
63 63
         @Override
64 64
         public void onItemsAdded(final Object source, final int startIndex,
65 65
                 final int endIndex) {
66
-            UIUtilities.invokeLater(new Runnable() {
67
-
68
-                @Override
69
-                public void run() {
70
-                    fireTableRowsInserted(startIndex, endIndex);
71
-                }
72
-            });
66
+            UIUtilities.invokeLater(() -> fireTableRowsInserted(startIndex, endIndex));
73 67
         }
74 68
 
75 69
         @Override
76 70
         public void onItemsRemoved(final Object source, final int startIndex,
77 71
                 final int endIndex) {
78
-            UIUtilities.invokeLater(new Runnable() {
79
-
80
-                @Override
81
-                public void run() {
82
-                    fireTableRowsDeleted(startIndex, endIndex);
83
-                }
84
-            });
72
+            UIUtilities.invokeLater(() -> fireTableRowsDeleted(startIndex, endIndex));
85 73
         }
86 74
 
87 75
         @Override
88 76
         public void onItemsChanged(final Object source, final int startIndex,
89 77
                 final int endIndex) {
90
-            UIUtilities.invokeLater(new Runnable() {
91
-
92
-                @Override
93
-                public void run() {
94
-                    fireTableRowsUpdated(startIndex, endIndex);
95
-                }
96
-            });
78
+            UIUtilities.invokeLater(() -> fireTableRowsUpdated(startIndex, endIndex));
97 79
         }
98 80
 
99 81
     }

+ 7
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/commands/PopInCommand.java 查看文件

@@ -67,17 +67,13 @@ public class PopInCommand extends Command {
67 67
     @Override
68 68
     public void execute(@Nonnull final FrameContainer origin, final CommandArguments args,
69 69
             final CommandContext context) {
70
-        UIUtilities.invokeLater(new Runnable() {
71
-
72
-            @Override
73
-            public void run() {
74
-                final TextFrame swingWindow = windowFactory.getSwingWindow(origin);
75
-                if (swingWindow == null) {
76
-                    sendLine(origin, args.isSilent(), FORMAT_ERROR, "There is"
77
-                            + " currently no window to pop in.");
78
-                } else {
79
-                    swingWindow.setPopout(false);
80
-                }
70
+        UIUtilities.invokeLater(() -> {
71
+            final TextFrame swingWindow = windowFactory.getSwingWindow(origin);
72
+            if (swingWindow == null) {
73
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "There is"
74
+                        + " currently no window to pop in.");
75
+            } else {
76
+                swingWindow.setPopout(false);
81 77
             }
82 78
         });
83 79
     }

+ 7
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/commands/PopOutCommand.java 查看文件

@@ -67,17 +67,13 @@ public class PopOutCommand extends Command {
67 67
     @Override
68 68
     public void execute(@Nonnull final FrameContainer origin, final CommandArguments args,
69 69
             final CommandContext context) {
70
-        UIUtilities.invokeLater(new Runnable() {
71
-
72
-            @Override
73
-            public void run() {
74
-                final TextFrame swingWindow = windowFactory.getSwingWindow(origin);
75
-                if (swingWindow == null) {
76
-                    sendLine(origin, args.isSilent(), FORMAT_ERROR, "There is"
77
-                            + " currently no window to pop out.");
78
-                } else {
79
-                    swingWindow.setPopout(true);
80
-                }
70
+        UIUtilities.invokeLater(() -> {
71
+            final TextFrame swingWindow = windowFactory.getSwingWindow(origin);
72
+            if (swingWindow == null) {
73
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "There is"
74
+                        + " currently no window to pop out.");
75
+            } else {
76
+                swingWindow.setPopout(true);
81 77
             }
82 78
         });
83 79
     }

+ 7
- 21
ui_swing/src/com/dmdirc/addons/ui_swing/components/AwayLabel.java 查看文件

@@ -74,38 +74,24 @@ public class AwayLabel extends JLabel implements ConfigChangeListener,
74 74
         useAwayIndicator = container.getConfigManager()
75 75
                 .getOptionBool("ui", AWAY_INDICATOR);
76 76
         if (!useAwayIndicator) {
77
-            UIUtilities.invokeLater(new Runnable() {
78
-
79
-                @Override
80
-                public void run() {
81
-                    setVisible(false);
82
-                }
83
-            });
77
+            UIUtilities.invokeLater(() -> setVisible(false));
84 78
         }
85 79
     }
86 80
 
87 81
     @Override
88 82
     public void onAway(final String reason) {
89
-        UIUtilities.invokeLater(new Runnable() {
90
-
91
-            @Override
92
-            public void run() {
93
-                if (useAwayIndicator) {
94
-                    setVisible(true);
95
-                }
83
+        UIUtilities.invokeLater(() -> {
84
+            if (useAwayIndicator) {
85
+                setVisible(true);
96 86
             }
97 87
         });
98 88
     }
99 89
 
100 90
     @Override
101 91
     public void onBack() {
102
-        UIUtilities.invokeLater(new Runnable() {
103
-
104
-            @Override
105
-            public void run() {
106
-                if (useAwayIndicator) {
107
-                    setVisible(false);
108
-                }
92
+        UIUtilities.invokeLater(() -> {
93
+            if (useAwayIndicator) {
94
+                setVisible(false);
109 95
             }
110 96
         });
111 97
     }

+ 1
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/components/SplitPane.java 查看文件

@@ -106,13 +106,7 @@ public class SplitPane extends JSplitPane implements ConfigChangeListener {
106 106
         useOneTouchExpandable = config.getOptionBool(
107 107
                 "ui", "useOneTouchExpandable");
108 108
 
109
-        UIUtilities.invokeLater(new Runnable() {
110
-
111
-            @Override
112
-            public void run() {
113
-                setOneTouchExpandable(useOneTouchExpandable);
114
-            }
115
-        });
109
+        UIUtilities.invokeLater(() -> setOneTouchExpandable(useOneTouchExpandable));
116 110
     }
117 111
 
118 112
 }

+ 2
- 14
ui_swing/src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java 查看文件

@@ -368,24 +368,12 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
368 368
 
369 369
     @Override
370 370
     public void addKeyListener(final KeyListener l) {
371
-        UIUtilities.invokeLater(new Runnable() {
372
-
373
-            @Override
374
-            public void run() {
375
-                listeners.add(KeyListener.class, l);
376
-            }
377
-        });
371
+        UIUtilities.invokeLater(() -> listeners.add(KeyListener.class, l));
378 372
     }
379 373
 
380 374
     @Override
381 375
     public void removeKeyListener(final KeyListener l) {
382
-        UIUtilities.invokeLater(new Runnable() {
383
-
384
-            @Override
385
-            public void run() {
386
-                listeners.remove(KeyListener.class, l);
387
-            }
388
-        });
376
+        UIUtilities.invokeLater(() -> listeners.remove(KeyListener.class, l));
389 377
     }
390 378
 
391 379
     @Override

+ 1
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/components/ToolTipPanel.java 查看文件

@@ -182,13 +182,7 @@ public class ToolTipPanel extends JPanel implements MouseListener {
182 182
                     super.processMouseEvent(e, comp);
183 183
                 }
184 184
             };
185
-            UIUtilities.invokeLater(new Runnable() {
186
-
187
-                @Override
188
-                public void run() {
189
-                    ((JXLayer<JComponent>) component).setUI(layerUI);
190
-                }
191
-            });
185
+            UIUtilities.invokeLater(() -> ((JXLayer<JComponent>) component).setUI(layerUI));
192 186
         } else {
193 187
             component.addMouseListener(this);
194 188
         }

+ 32
- 75
ui_swing/src/com/dmdirc/addons/ui_swing/components/TopicBar.java 查看文件

@@ -225,26 +225,22 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
225 225
 
226 226
     @Override
227 227
     public final void topicChanged(final Channel channel, final Topic topic) {
228
-        UIUtilities.invokeLater(new Runnable() {
229
-
230
-            @Override
231
-            public void run() {
232
-                if (topicText.isEditable()) {
233
-                    return;
234
-                }
235
-                topicText.setText("");
236
-                if (topic != null) {
237
-                channel.getStyliser().addStyledString(
238
-                        (StyledDocument) topicText.getDocument(),
239
-                        new String[]{Styliser.CODE_HEXCOLOUR
240
-                            + UIUtilities.getHex(foregroundColour)
241
-                                + topic.getTopic(),}, as);
242
-                }
243
-                topicText.setCaretPosition(0);
244
-                validateTopic();
245
-                setVisible(false);
246
-                setVisible(true);
228
+        UIUtilities.invokeLater(() -> {
229
+            if (topicText.isEditable()) {
230
+                return;
231
+            }
232
+            topicText.setText("");
233
+            if (topic != null) {
234
+            channel.getStyliser().addStyledString(
235
+                    (StyledDocument) topicText.getDocument(),
236
+                    new String[]{Styliser.CODE_HEXCOLOUR
237
+                        + UIUtilities.getHex(foregroundColour)
238
+                            + topic.getTopic(),}, as);
247 239
             }
240
+            topicText.setCaretPosition(0);
241
+            validateTopic();
242
+            setVisible(false);
243
+            setVisible(true);
248 244
         });
249 245
     }
250 246
 
@@ -379,13 +375,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
379 375
      * @param position New position
380 376
      */
381 377
     public void setCaretPosition(final int position) {
382
-        UIUtilities.invokeLater(new Runnable() {
383
-
384
-            @Override
385
-            public void run() {
386
-                topicText.setCaretPosition(position);
387
-            }
388
-        });
378
+        UIUtilities.invokeLater(() -> topicText.setCaretPosition(position));
389 379
     }
390 380
 
391 381
     /**
@@ -394,24 +384,12 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
394 384
      * @param optionColour Colour for the caret
395 385
      */
396 386
     public void setCaretColor(final Color optionColour) {
397
-        UIUtilities.invokeLater(new Runnable() {
398
-
399
-            @Override
400
-            public void run() {
401
-                topicText.setCaretColor(optionColour);
402
-            }
403
-        });
387
+        UIUtilities.invokeLater(() -> topicText.setCaretColor(optionColour));
404 388
     }
405 389
 
406 390
     @Override
407 391
     public void setForeground(final Color optionColour) {
408
-        UIUtilities.invokeLater(new Runnable() {
409
-
410
-            @Override
411
-            public void run() {
412
-                topicText.setForeground(optionColour);
413
-            }
414
-        });
392
+        UIUtilities.invokeLater(() -> topicText.setForeground(optionColour));
415 393
     }
416 394
 
417 395
     /**
@@ -420,24 +398,12 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
420 398
      * @param optionColour Colour for the disabled text
421 399
      */
422 400
     public void setDisabledTextColour(final Color optionColour) {
423
-        UIUtilities.invokeLater(new Runnable() {
424
-
425
-            @Override
426
-            public void run() {
427
-                topicText.setDisabledTextColor(optionColour);
428
-            }
429
-        });
401
+        UIUtilities.invokeLater(() -> topicText.setDisabledTextColor(optionColour));
430 402
     }
431 403
 
432 404
     @Override
433 405
     public void setBackground(final Color optionColour) {
434
-        UIUtilities.invokeLater(new Runnable() {
435
-
436
-            @Override
437
-            public void run() {
438
-                topicText.setBackground(optionColour);
439
-            }
440
-        });
406
+        UIUtilities.invokeLater(() -> topicText.setBackground(optionColour));
441 407
     }
442 408
 
443 409
     @Override
@@ -471,24 +437,20 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
471 437
      * Validates the topic text and shows errors as appropriate.
472 438
      */
473 439
     public void validateTopic() {
474
-        UIUtilities.invokeLater(new Runnable() {
475
-
476
-            @Override
477
-            public void run() {
478
-                if (topicText.isEditable()) {
479
-                    final int charsLeft = topicLengthMax - topicText.getText().
480
-                            length();
481
-                    if (charsLeft < 0) {
482
-                        errorIcon.setVisible(true);
483
-                        errorIcon.setToolTipText("Topic too long: " + topicText.
484
-                                getText().length() + " of " + topicLengthMax);
485
-                    } else {
486
-                        errorIcon.setVisible(false);
487
-                        errorIcon.setToolTipText(null);
488
-                    }
440
+        UIUtilities.invokeLater(() -> {
441
+            if (topicText.isEditable()) {
442
+                final int charsLeft = topicLengthMax - topicText.getText().
443
+                        length();
444
+                if (charsLeft < 0) {
445
+                    errorIcon.setVisible(true);
446
+                    errorIcon.setToolTipText("Topic too long: " + topicText.
447
+                            getText().length() + " of " + topicLengthMax);
489 448
                 } else {
490 449
                     errorIcon.setVisible(false);
450
+                    errorIcon.setToolTipText(null);
491 451
                 }
452
+            } else {
453
+                errorIcon.setVisible(false);
492 454
             }
493 455
         });
494 456
     }
@@ -524,12 +486,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
524 486
     public void insertUpdate(final DocumentEvent e) {
525 487
         validateTopic();
526 488
         if (topicText.isEditable()) {
527
-            SwingUtilities.invokeLater(new Runnable() {
528
-                @Override
529
-                public void run() {
530
-                    applyAttributes();
531
-                }
532
-            });
489
+            SwingUtilities.invokeLater(this::applyAttributes);
533 490
         }
534 491
     }
535 492
 

+ 2
- 14
ui_swing/src/com/dmdirc/addons/ui_swing/components/TreeScroller.java 查看文件

@@ -88,13 +88,7 @@ public class TreeScroller implements MouseWheelListener {
88 88
      * @param tree Tree to scroll
89 89
      */
90 90
     public static void register(final JTree tree) {
91
-        UIUtilities.invokeLater(new Runnable() {
92
-
93
-            @Override
94
-            public void run() {
95
-                new TreeScroller(tree);
96
-            }
97
-        });
91
+        UIUtilities.invokeLater(() -> new TreeScroller(tree));
98 92
     }
99 93
 
100 94
     /**
@@ -107,13 +101,7 @@ public class TreeScroller implements MouseWheelListener {
107 101
     public static void register(final DefaultTreeModel model,
108 102
             final TreeSelectionModel selectionModel,
109 103
             final boolean rootVisible) {
110
-        UIUtilities.invokeLater(new Runnable() {
111
-
112
-            @Override
113
-            public void run() {
114
-                new TreeScroller(model, selectionModel, rootVisible);
115
-            }
116
-        });
104
+        UIUtilities.invokeLater(() -> new TreeScroller(model, selectionModel, rootVisible));
117 105
     }
118 106
 
119 107
     /**

+ 1
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/components/TypingLabel.java 查看文件

@@ -68,13 +68,7 @@ public class TypingLabel extends JLabel implements ConfigChangeListener {
68 68
     public void configChanged(final String domain, final String key) {
69 69
         useTypingIndicator = container.getConfigManager().getOptionBool("ui", CONFIG_KEY);
70 70
         if (!useTypingIndicator) {
71
-            UIUtilities.invokeLater(new Runnable() {
72
-
73
-                @Override
74
-                public void run() {
75
-                    setVisible(false);
76
-                }
77
-            });
71
+            UIUtilities.invokeLater(() -> setVisible(false));
78 72
         }
79 73
     }
80 74
 

+ 10
- 20
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonbrowser/DataLoaderWorker.java 查看文件

@@ -35,13 +35,7 @@ import com.dmdirc.util.io.ConfigFile;
35 35
 import com.dmdirc.util.io.DownloadListener;
36 36
 import com.dmdirc.util.io.Downloader;
37 37
 import com.dmdirc.util.io.InvalidConfigFileException;
38
-import net.miginfocom.swing.MigLayout;
39 38
 
40
-import javax.swing.Box;
41
-import javax.swing.JPanel;
42
-import javax.swing.JProgressBar;
43
-import javax.swing.JScrollPane;
44
-import javax.swing.text.StyleConstants;
45 39
 import java.io.IOException;
46 40
 import java.nio.file.Paths;
47 41
 import java.util.ArrayList;
@@ -51,6 +45,14 @@ import java.util.List;
51 45
 import java.util.Map;
52 46
 import java.util.concurrent.ExecutionException;
53 47
 
48
+import javax.swing.Box;
49
+import javax.swing.JPanel;
50
+import javax.swing.JProgressBar;
51
+import javax.swing.JScrollPane;
52
+import javax.swing.text.StyleConstants;
53
+
54
+import net.miginfocom.swing.MigLayout;
55
+
54 56
 /**
55 57
  * Loads the addon data feed into the addon browser.
56 58
  */
@@ -195,24 +197,12 @@ public class DataLoaderWorker
195 197
 
196 198
     @Override
197 199
     public void downloadProgress(final float percent) {
198
-        UIUtilities.invokeLater(new Runnable() {
199
-
200
-            @Override
201
-            public void run() {
202
-                jpb.setValue((int) percent);
203
-            }
204
-        });
200
+        UIUtilities.invokeLater(() -> jpb.setValue((int) percent));
205 201
     }
206 202
 
207 203
     @Override
208 204
     public void setIndeterminate(final boolean indeterminate) {
209
-        UIUtilities.invokeLater(new Runnable() {
210
-
211
-            @Override
212
-            public void run() {
213
-                jpb.setIndeterminate(indeterminate);
214
-            }
215
-        });
205
+        UIUtilities.invokeLater(() -> jpb.setIndeterminate(indeterminate));
216 206
     }
217 207
 
218 208
 }

+ 5
- 8
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/AddonPanel.java 查看文件

@@ -140,14 +140,11 @@ public abstract class AddonPanel extends JPanel implements AddonToggleListener,
140 140
             protected void done() {
141 141
                 super.done();
142 142
                 scrollPane.setViewportView(addonList);
143
-                UIUtilities.invokeLater(new Runnable() {
144
-                    @Override
145
-                    public void run() {
146
-                        addonList.getSelectionModel()
147
-                                .addListSelectionListener(AddonPanel.this);
148
-                        addonList.getSelectionModel()
149
-                                .setSelectionInterval(0, 0);
150
-                    }
143
+                UIUtilities.invokeLater(() -> {
144
+                    addonList.getSelectionModel()
145
+                            .addListSelectionListener(AddonPanel.this);
146
+                    addonList.getSelectionModel()
147
+                            .setSelectionInterval(0, 0);
151 148
                 });
152 149
             }
153 150
         }.execute();

+ 13
- 17
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java 查看文件

@@ -112,24 +112,20 @@ public class PluginPanel extends AddonPanel {
112 112
             }
113 113
         }
114 114
 
115
-        UIUtilities.invokeLater(new Runnable() {
116
-
117
-            @Override
118
-            public void run() {
119
-                ((DefaultTableModel) table.getModel()).setNumRows(0);
120
-                for (final PluginInfo plugin : sortedList) {
121
-                    ((DefaultTableModel) table.getModel()).addRow(
122
-                            new AddonCell[]{
123
-                                new AddonCell(
124
-                                        new AddonToggle(
125
-                                                updateManager,
126
-                                                userConfig,
127
-                                                pluginManager,
128
-                                                plugin),
129
-                                        iconManager),});
130
-                }
131
-                table.repaint();
115
+        UIUtilities.invokeLater(() -> {
116
+            ((DefaultTableModel) table.getModel()).setNumRows(0);
117
+            for (final PluginInfo plugin : sortedList) {
118
+                ((DefaultTableModel) table.getModel()).addRow(
119
+                        new AddonCell[]{
120
+                            new AddonCell(
121
+                                    new AddonToggle(
122
+                                            updateManager,
123
+                                            userConfig,
124
+                                            pluginManager,
125
+                                            plugin),
126
+                                    iconManager),});
132 127
             }
128
+            table.repaint();
133 129
         });
134 130
         return table;
135 131
     }

+ 14
- 18
ui_swing/src/com/dmdirc/addons/ui_swing/components/addonpanel/ThemePanel.java 查看文件

@@ -92,25 +92,21 @@ public class ThemePanel extends AddonPanel {
92 92
         final List<Theme> list = new ArrayList<>(themeManager.getAllThemes().values());
93 93
         Collections.sort(list);
94 94
 
95
-        UIUtilities.invokeLater(new Runnable() {
96
-
97
-            @Override
98
-            public void run() {
99
-                ((DefaultTableModel) addonList.getModel()).setRowCount(0);
100
-                for (final Theme theme : list) {
101
-                    ((DefaultTableModel) addonList.getModel()).addRow(
102
-                            new AddonCell[]{
103
-                                new AddonCell(
104
-                                        new AddonToggle(
105
-                                                updateManager,
106
-                                                userConfig,
107
-                                                themeManager,
108
-                                                theme),
109
-                                        iconManager),});
110
-                }
111
-
112
-                addonList.repaint();
95
+        UIUtilities.invokeLater(() -> {
96
+            ((DefaultTableModel) addonList.getModel()).setRowCount(0);
97
+            for (final Theme theme : list) {
98
+                ((DefaultTableModel) addonList.getModel()).addRow(
99
+                        new AddonCell[]{
100
+                            new AddonCell(
101
+                                    new AddonToggle(
102
+                                            updateManager,
103
+                                            userConfig,
104
+                                            themeManager,
105
+                                            theme),
106
+                                    iconManager),});
113 107
             }
108
+
109
+            addonList.repaint();
114 110
         });
115 111
         return addonList;
116 112
     }

+ 5
- 9
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java 查看文件

@@ -173,15 +173,11 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
173 173
         if ("channelSplitPanePosition".equals(key)) {
174 174
             final int splitPanePosition = getContainer().getConfigManager()
175 175
                     .getOptionInt("ui", "channelSplitPanePosition");
176
-            UIUtilities.invokeLater(new Runnable() {
177
-
178
-                @Override
179
-                public void run() {
180
-                    nicklist.setPreferredSize(
181
-                            new Dimension(splitPanePosition, 0));
182
-                    splitPane.setDividerLocation(splitPane.getWidth() - splitPane.
183
-                            getDividerSize() - splitPanePosition);
184
-                }
176
+            UIUtilities.invokeLater(() -> {
177
+                nicklist.setPreferredSize(
178
+                        new Dimension(splitPanePosition, 0));
179
+                splitPane.setDividerLocation(splitPane.getWidth() - splitPane.
180
+                        getDividerSize() - splitPanePosition);
185 181
             });
186 182
         }
187 183
         if ("shownicklist".equals(key)) {

+ 1
- 6
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java 查看文件

@@ -220,12 +220,7 @@ public abstract class TextFrame extends JPanel implements com.dmdirc.interfaces.
220 220
      * Called when the frame has been selected in the UI.
221 221
      */
222 222
     public void activateFrame() {
223
-        UIUtilities.invokeLater(new Runnable() {
224
-            @Override
225
-            public void run() {
226
-                frameParent.clearNotification();
227
-            }
228
-        });
223
+        UIUtilities.invokeLater(frameParent::clearNotification);
229 224
     }
230 225
 
231 226
     /**

+ 56
- 210
ui_swing/src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputField.java 查看文件

@@ -37,7 +37,6 @@ import java.awt.Color;
37 37
 import java.awt.FontMetrics;
38 38
 import java.awt.KeyboardFocusManager;
39 39
 import java.awt.Window;
40
-import java.awt.event.ActionEvent;
41 40
 import java.awt.event.ActionListener;
42 41
 import java.awt.event.KeyEvent;
43 42
 import java.awt.event.KeyListener;
@@ -131,68 +130,45 @@ public class SwingInputField extends JComponent implements InputField,
131 130
 
132 131
     @Override
133 132
     public void requestFocus() {
134
-        UIUtilities.invokeLater(new Runnable() {
135
-
136
-            @Override
137
-            public void run() {
138
-                textField.requestFocus();
139
-            }
140
-        });
133
+        UIUtilities.invokeLater(textField::requestFocus);
141 134
     }
142 135
 
143 136
     @Override
144 137
     public boolean requestFocusInWindow() {
145
-        return UIUtilities.invokeAndWait(new Callable<Boolean>() {
146
-
147
-            @Override
148
-            public Boolean call() {
149
-                return textField.requestFocusInWindow();
150
-            }
151
-        });
138
+        return UIUtilities.invokeAndWait((Callable<Boolean>) textField::requestFocusInWindow);
152 139
     }
153 140
 
154 141
     @Override
155 142
     public void showColourPicker(final boolean irc, final boolean hex) {
156
-        UIUtilities.invokeLater(new Runnable() {
157
-
158
-            @Override
159
-            public void run() {
160
-                if (globalConfig.getOptionBool("general", "showcolourdialog")) {
161
-                    colourPicker = new ColourPickerDialog(SwingInputField.this,
162
-                            colourManager, iconManager, irc, hex, parentWindow);
163
-                    colourPicker.addActionListener(new ActionListener() {
164
-                        @Override
165
-                        public void actionPerformed(final ActionEvent actionEvent) {
166
-                            try {
167
-                                textField.getDocument().
168
-                                        insertString(textField.getCaretPosition(),
169
-                                                actionEvent.getActionCommand(), null);
170
-                            } catch (final BadLocationException ex) {
171
-                                //Ignore, wont happen
172
-                            }
173
-                            colourPicker.dispose();
174
-                            colourPicker = null;
175
-                        }
176
-                    });
177
-                    colourPicker.setVisible(true);
178
-                    colourPicker.setLocation((int) textField.getLocationOnScreen().
179
-                            getX(),
180
-                            (int) textField.getLocationOnScreen().getY() - colourPicker.getHeight());
181
-                }
143
+        UIUtilities.invokeLater(() -> {
144
+            if (globalConfig.getOptionBool("general", "showcolourdialog")) {
145
+                colourPicker = new ColourPickerDialog(SwingInputField.this,
146
+                        colourManager, iconManager, irc, hex, parentWindow);
147
+                colourPicker.addActionListener(actionEvent -> {
148
+                    try {
149
+                        textField.getDocument().
150
+                                insertString(textField.getCaretPosition(),
151
+                                        actionEvent.getActionCommand(), null);
152
+                    } catch (final BadLocationException ex) {
153
+                        //Ignore, wont happen
154
+                    }
155
+                    colourPicker.dispose();
156
+                    colourPicker = null;
157
+                });
158
+                colourPicker.setVisible(true);
159
+                colourPicker.setLocation((int) textField.getLocationOnScreen().
160
+                        getX(),
161
+                        (int) textField.getLocationOnScreen().getY() - colourPicker.getHeight());
182 162
             }
183 163
         });
184 164
     }
185 165
 
186 166
     @Override
187 167
     public void hideColourPicker() {
188
-        UIUtilities.invokeLater(new Runnable() {
189
-
190
-            @Override
191
-            public void run() {
192
-                if (colourPicker != null) {
193
-                    colourPicker.dispose();
194
-                    colourPicker = null;
195
-                }
168
+        UIUtilities.invokeLater(() -> {
169
+            if (colourPicker != null) {
170
+                colourPicker.dispose();
171
+                colourPicker = null;
196 172
             }
197 173
         });
198 174
     }
@@ -203,134 +179,62 @@ public class SwingInputField extends JComponent implements InputField,
203 179
      * @return JTextField
204 180
      */
205 181
     public JTextField getTextField() {
206
-        return UIUtilities.invokeAndWait(new Callable<JTextField>() {
207
-
208
-            @Override
209
-            public JTextField call() {
210
-                return textField;
211
-            }
212
-        });
182
+        return UIUtilities.invokeAndWait(() -> textField);
213 183
     }
214 184
 
215 185
     @Override
216 186
     public void addActionListener(final ActionListener listener) {
217
-        UIUtilities.invokeLater(new Runnable() {
218
-
219
-            @Override
220
-            public void run() {
221
-                textField.addActionListener(listener);
222
-            }
223
-        });
187
+        UIUtilities.invokeLater(() -> textField.addActionListener(listener));
224 188
     }
225 189
 
226 190
     @Override
227 191
     public void addKeyListener(final KeyListener listener) {
228
-        UIUtilities.invokeLater(new Runnable() {
229
-
230
-            @Override
231
-            public void run() {
232
-                listeners.add(KeyListener.class, listener);
233
-            }
234
-        });
192
+        UIUtilities.invokeLater(() -> listeners.add(KeyListener.class, listener));
235 193
     }
236 194
 
237 195
     @Override
238 196
     public void removeActionListener(final ActionListener listener) {
239
-        UIUtilities.invokeLater(new Runnable() {
240
-
241
-            @Override
242
-            public void run() {
243
-                textField.removeActionListener(listener);
244
-            }
245
-        });
197
+        UIUtilities.invokeLater(() -> textField.removeActionListener(listener));
246 198
     }
247 199
 
248 200
     @Override
249 201
     public void removeKeyListener(final KeyListener listener) {
250
-        UIUtilities.invokeLater(new Runnable() {
251
-
252
-            @Override
253
-            public void run() {
254
-                listeners.remove(KeyListener.class, listener);
255
-            }
256
-        });
202
+        UIUtilities.invokeLater(() -> listeners.remove(KeyListener.class, listener));
257 203
     }
258 204
 
259 205
     @Override
260 206
     public String getSelectedText() {
261
-        return UIUtilities.invokeAndWait(new Callable<String>() {
262
-
263
-            @Override
264
-            public String call() {
265
-                return textField.getSelectedText();
266
-            }
267
-        });
207
+        return UIUtilities.invokeAndWait(textField::getSelectedText);
268 208
     }
269 209
 
270 210
     @Override
271 211
     public int getSelectionEnd() {
272
-        return UIUtilities.invokeAndWait(new Callable<Integer>() {
273
-
274
-            @Override
275
-            public Integer call() {
276
-                return textField.getSelectionEnd();
277
-            }
278
-        });
212
+        return UIUtilities.invokeAndWait(textField::getSelectionEnd);
279 213
     }
280 214
 
281 215
     @Override
282 216
     public int getSelectionStart() {
283
-        return UIUtilities.invokeAndWait(new Callable<Integer>() {
284
-
285
-            @Override
286
-            public Integer call() {
287
-                return textField.getSelectionStart();
288
-            }
289
-        });
217
+        return UIUtilities.invokeAndWait(textField::getSelectionStart);
290 218
     }
291 219
 
292 220
     @Override
293 221
     public String getText() {
294
-        return UIUtilities.invokeAndWait(new Callable<String>() {
295
-
296
-            @Override
297
-            public String call() {
298
-                return textField.getText();
299
-            }
300
-        });
222
+        return UIUtilities.invokeAndWait((Callable<String>) textField::getText);
301 223
     }
302 224
 
303 225
     @Override
304 226
     public void setText(final String text) {
305
-        UIUtilities.invokeLater(new Runnable() {
306
-
307
-            @Override
308
-            public void run() {
309
-                textField.setText(text);
310
-            }
311
-        });
227
+        UIUtilities.invokeLater(() -> textField.setText(text));
312 228
     }
313 229
 
314 230
     @Override
315 231
     public int getCaretPosition() {
316
-        return UIUtilities.invokeAndWait(new Callable<Integer>() {
317
-
318
-            @Override
319
-            public Integer call() {
320
-                return textField.getCaretPosition();
321
-            }
322
-        });
232
+        return UIUtilities.invokeAndWait(textField::getCaretPosition);
323 233
     }
324 234
 
325 235
     @Override
326 236
     public void setCaretPosition(final int position) {
327
-        UIUtilities.invokeLater(new Runnable() {
328
-
329
-            @Override
330
-            public void run() {
331
-                textField.setCaretPosition(position);
332
-            }
333
-        });
237
+        UIUtilities.invokeLater(() -> textField.setCaretPosition(position));
334 238
     }
335 239
 
336 240
     /**
@@ -339,13 +243,7 @@ public class SwingInputField extends JComponent implements InputField,
339 243
      * @param clipboard Text to replace selection with
340 244
      */
341 245
     public void replaceSelection(final String clipboard) {
342
-        UIUtilities.invokeLater(new Runnable() {
343
-
344
-            @Override
345
-            public void run() {
346
-                textField.replaceSelection(clipboard);
347
-            }
348
-        });
246
+        UIUtilities.invokeLater(() -> textField.replaceSelection(clipboard));
349 247
     }
350 248
 
351 249
     /**
@@ -354,13 +252,7 @@ public class SwingInputField extends JComponent implements InputField,
354 252
      * @param optionColour Colour for the caret
355 253
      */
356 254
     public void setCaretColor(final Color optionColour) {
357
-        UIUtilities.invokeLater(new Runnable() {
358
-
359
-            @Override
360
-            public void run() {
361
-                textField.setCaretColor(optionColour);
362
-            }
363
-        });
255
+        UIUtilities.invokeLater(() -> textField.setCaretColor(optionColour));
364 256
     }
365 257
 
366 258
     /**
@@ -370,13 +262,7 @@ public class SwingInputField extends JComponent implements InputField,
370 262
      */
371 263
     @Override
372 264
     public void setForeground(final Color optionColour) {
373
-        UIUtilities.invokeLater(new Runnable() {
374
-
375
-            @Override
376
-            public void run() {
377
-                textField.setForeground(optionColour);
378
-            }
379
-        });
265
+        UIUtilities.invokeLater(() -> textField.setForeground(optionColour));
380 266
     }
381 267
 
382 268
     /**
@@ -386,35 +272,17 @@ public class SwingInputField extends JComponent implements InputField,
386 272
      */
387 273
     @Override
388 274
     public void setBackground(final Color optionColour) {
389
-        UIUtilities.invokeLater(new Runnable() {
390
-
391
-            @Override
392
-            public void run() {
393
-                textField.setBackground(optionColour);
394
-            }
395
-        });
275
+        UIUtilities.invokeLater(() -> textField.setBackground(optionColour));
396 276
     }
397 277
 
398 278
     @Override
399 279
     public boolean hasFocus() {
400
-        return UIUtilities.invokeAndWait(new Callable<Boolean>() {
401
-
402
-            @Override
403
-            public Boolean call() {
404
-                return textField.hasFocus();
405
-            }
406
-        });
280
+        return UIUtilities.invokeAndWait(textField::hasFocus);
407 281
     }
408 282
 
409 283
     @Override
410 284
     public boolean isFocusOwner() {
411
-        return UIUtilities.invokeAndWait(new Callable<Boolean>() {
412
-
413
-            @Override
414
-            public Boolean call() {
415
-                return textField.isFocusOwner();
416
-            }
417
-        });
285
+        return UIUtilities.invokeAndWait(textField::isFocusOwner);
418 286
     }
419 287
 
420 288
     /**
@@ -423,12 +291,7 @@ public class SwingInputField extends JComponent implements InputField,
423 291
      * @param selectionStart Start index
424 292
      */
425 293
     public void setSelectionStart(final int selectionStart) {
426
-        UIUtilities.invokeLater(new Runnable() {
427
-            @Override
428
-            public void run() {
429
-                textField.setSelectionStart(selectionStart);
430
-            }
431
-        });
294
+        UIUtilities.invokeLater(() -> textField.setSelectionStart(selectionStart));
432 295
     }
433 296
 
434 297
     /**
@@ -437,12 +300,7 @@ public class SwingInputField extends JComponent implements InputField,
437 300
      * @param selectionEnd End index
438 301
      */
439 302
     public void setSelectionEnd(final int selectionEnd) {
440
-        UIUtilities.invokeLater(new Runnable() {
441
-            @Override
442
-            public void run() {
443
-                textField.setSelectionEnd(selectionEnd);
444
-            }
445
-        });
303
+        UIUtilities.invokeLater(() -> textField.setSelectionEnd(selectionEnd));
446 304
     }
447 305
 
448 306
     @Override
@@ -468,39 +326,27 @@ public class SwingInputField extends JComponent implements InputField,
468 326
 
469 327
     @Override
470 328
     public void illegalCommand(final String reason) {
471
-        UIUtilities.invokeLater(new Runnable() {
472
-
473
-            @Override
474
-            public void run() {
475
-                errorIndicator.setVisible(true);
476
-                errorIndicator.setToolTipText(reason);
477
-                wrapIndicator.setVisible(false);
478
-            }
329
+        UIUtilities.invokeLater(() -> {
330
+            errorIndicator.setVisible(true);
331
+            errorIndicator.setToolTipText(reason);
332
+            wrapIndicator.setVisible(false);
479 333
         });
480 334
     }
481 335
 
482 336
     @Override
483 337
     public void legalCommand() {
484
-        UIUtilities.invokeLater(new Runnable() {
485
-
486
-            @Override
487
-            public void run() {
488
-                errorIndicator.setVisible(false);
489
-                errorIndicator.setToolTipText(null);
490
-            }
338
+        UIUtilities.invokeLater(() -> {
339
+            errorIndicator.setVisible(false);
340
+            errorIndicator.setToolTipText(null);
491 341
         });
492 342
     }
493 343
 
494 344
     @Override
495 345
     public void wrappedText(final int count) {
496
-        UIUtilities.invokeLater(new Runnable() {
497
-
498
-            @Override
499
-            public void run() {
500
-                wrapIndicator.setVisible(count > 1);
501
-                wrapIndicator.setToolTipText(count + " lines");
502
-                errorIndicator.setVisible(false);
503
-            }
346
+        UIUtilities.invokeLater(() -> {
347
+            wrapIndicator.setVisible(count > 1);
348
+            wrapIndicator.setToolTipText(count + " lines");
349
+            errorIndicator.setVisible(false);
504 350
         });
505 351
     }
506 352
 

+ 19
- 23
ui_swing/src/com/dmdirc/addons/ui_swing/components/inputfields/SwingInputHandler.java 查看文件

@@ -220,30 +220,26 @@ public class SwingInputHandler extends InputHandler implements KeyListener {
220 220
             public void actionPerformed(final ActionEvent e) {
221 221
                 final String line = target.getText();
222 222
                 target.setText("");
223
-                UIUtilities.invokeLater(new Runnable() {
224
-
225
-                    @Override
226
-                    public void run() {
227
-                        final JTextField source;
228
-                        if (e.getSource() instanceof SwingInputField) {
229
-                            source = ((SwingInputField) e.getSource())
230
-                                    .getTextField();
231
-                        } else if (e.getSource() instanceof JTextField) {
232
-                            source = (JTextField) e.getSource();
233
-                        } else {
234
-                            throw new IllegalArgumentException(
235
-                                            "Event is not from known source.");
236
-                        }
237
-                        if (source.isEditable()) {
238
-                            new LoggingSwingWorker<Object, Void>(eventBus) {
223
+                UIUtilities.invokeLater(() -> {
224
+                    final JTextField source;
225
+                    if (e.getSource() instanceof SwingInputField) {
226
+                        source = ((SwingInputField) e.getSource())
227
+                                .getTextField();
228
+                    } else if (e.getSource() instanceof JTextField) {
229
+                        source = (JTextField) e.getSource();
230
+                    } else {
231
+                        throw new IllegalArgumentException(
232
+                                        "Event is not from known source.");
233
+                    }
234
+                    if (source.isEditable()) {
235
+                        new LoggingSwingWorker<Object, Void>(eventBus) {
239 236
 
240
-                                @Override
241
-                                protected Object doInBackground() {
242
-                                    enterPressed(line);
243
-                                    return null;
244
-                                }
245
-                            }.execute();
246
-                        }
237
+                            @Override
238
+                            protected Object doInBackground() {
239
+                                enterPressed(line);
240
+                                return null;
241
+                            }
242
+                        }.execute();
247 243
                     }
248 244
                 });
249 245
             }

+ 7
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/components/statusbar/InviteLabel.java 查看文件

@@ -129,17 +129,13 @@ public class InviteLabel extends StatusbarPopupPanel<JLabel>
129 129
      * Updates the invite label for the currently active server.
130 130
      */
131 131
     private void update() {
132
-        UIUtilities.invokeLater(new Runnable() {
133
-
134
-            @Override
135
-            public void run() {
136
-                if (activeConnection == null || activeConnection.getInvites().isEmpty()) {
137
-                    setVisible(false);
138
-                    closeDialog();
139
-                } else {
140
-                    refreshDialog();
141
-                    setVisible(true);
142
-                }
132
+        UIUtilities.invokeLater(() -> {
133
+            if (activeConnection == null || activeConnection.getInvites().isEmpty()) {
134
+                setVisible(false);
135
+                closeDialog();
136
+            } else {
137
+                refreshDialog();
138
+                setVisible(true);
143 139
             }
144 140
         });
145 141
     }

+ 9
- 15
ui_swing/src/com/dmdirc/addons/ui_swing/components/statusbar/StatusbarPanel.java 查看文件

@@ -102,14 +102,11 @@ public abstract class StatusbarPanel<T extends JComponent> extends JPanel
102 102
      * Closes and reopens the dialog to update information and border positions.
103 103
      */
104 104
     public final void refreshDialog() {
105
-        UIUtilities.invokeLater(new Runnable() {
106
-            @Override
107
-            public void run() {
108
-                synchronized (StatusbarPanel.this) {
109
-                    if (dialog != null) {
110
-                        closeDialog();
111
-                        openDialog();
112
-                    }
105
+        UIUtilities.invokeLater(() -> {
106
+            synchronized (this) {
107
+                if (dialog != null) {
108
+                    closeDialog();
109
+                    openDialog();
113 110
                 }
114 111
             }
115 112
         });
@@ -119,7 +116,7 @@ public abstract class StatusbarPanel<T extends JComponent> extends JPanel
119 116
      * Opens the information dialog.
120 117
      */
121 118
     protected void openDialog() {
122
-        synchronized (StatusbarPanel.this) {
119
+        synchronized (this) {
123 120
             if (dialog == null) {
124 121
                 setBackground(getPopupBackground());
125 122
                 setForeground(getPopupForeground());
@@ -134,7 +131,7 @@ public abstract class StatusbarPanel<T extends JComponent> extends JPanel
134 131
      * Closes the information dialog.
135 132
      */
136 133
     protected void closeDialog() {
137
-        synchronized (StatusbarPanel.this) {
134
+        synchronized (this) {
138 135
             if (dialog != null) {
139 136
                 setBackground(null);
140 137
                 setForeground(null);
@@ -152,11 +149,8 @@ public abstract class StatusbarPanel<T extends JComponent> extends JPanel
152 149
      * @return is the dialog open
153 150
      */
154 151
     protected final boolean isDialogOpen() {
155
-        synchronized (StatusbarPanel.this) {
156
-            if (dialog != null) {
157
-                return dialog.isVisible();
158
-            }
159
-            return false;
152
+        synchronized (this) {
153
+            return dialog != null && dialog.isVisible();
160 154
         }
161 155
     }
162 156
 

+ 9
- 25
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/error/ErrorTableModel.java 查看文件

@@ -45,13 +45,13 @@ public final class ErrorTableModel extends AbstractTableModel implements ErrorLi
45 45
     /** Data list. */
46 46
     private final List<ProgramError> errors;
47 47
     /** Are we ready? */
48
-    private boolean ready = false;
48
+    private boolean ready;
49 49
 
50 50
     /**
51 51
      * Creates a new instance of ErrorTableModel.
52 52
      */
53 53
     public ErrorTableModel() {
54
-        this.errors = Collections.synchronizedList(new ArrayList<ProgramError>());
54
+        this.errors = Collections.synchronizedList(new ArrayList<>());
55 55
     }
56 56
 
57 57
     public void load(final ErrorManager errorManager) {
@@ -236,37 +236,21 @@ public final class ErrorTableModel extends AbstractTableModel implements ErrorLi
236 236
 
237 237
     @Override
238 238
     public void errorAdded(final ProgramError error) {
239
-        UIUtilities.invokeLater(new Runnable() {
240
-
241
-            @Override
242
-            public void run() {
243
-                addRow(error);
244
-            }
245
-        });
239
+        UIUtilities.invokeLater(() -> addRow(error));
246 240
     }
247 241
 
248 242
     @Override
249 243
     public void errorDeleted(final ProgramError error) {
250
-        UIUtilities.invokeLater(new Runnable() {
251
-
252
-            @Override
253
-            public void run() {
254
-                removeRow(error);
255
-            }
256
-        });
244
+        UIUtilities.invokeLater(() -> removeRow(error));
257 245
     }
258 246
 
259 247
     @Override
260 248
     public void errorStatusChanged(final ProgramError error) {
261
-        UIUtilities.invokeLater(new Runnable() {
262
-
263
-            @Override
264
-            public void run() {
265
-                synchronized (errors) {
266
-                    final int errorRow = indexOf(error);
267
-                    if (errorRow != -1 && errorRow < getRowCount()) {
268
-                        fireTableRowsUpdated(errorRow, errorRow);
269
-                    }
249
+        UIUtilities.invokeLater(() -> {
250
+            synchronized (errors) {
251
+                final int errorRow = indexOf(error);
252
+                if (errorRow != -1 && errorRow < getRowCount()) {
253
+                    fireTableRowsUpdated(errorRow, errorRow);
270 254
                 }
271 255
             }
272 256
         });

+ 21
- 30
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java 查看文件

@@ -33,7 +33,7 @@ import com.dmdirc.addons.ui_swing.components.text.TextLabel;
33 33
 import com.dmdirc.config.prefs.PreferencesCategory;
34 34
 import com.dmdirc.ui.IconManager;
35 35
 
36
-import java.awt.Component;
36
+import java.util.Arrays;
37 37
 import java.util.Collections;
38 38
 import java.util.HashMap;
39 39
 import java.util.Map;
@@ -166,25 +166,20 @@ public class CategoryPanel extends JPanel {
166 166
                 //Hack around mig bug
167 167
                 panel.invalidate();
168 168
                 panel.validate();
169
-                for (final Component component : panel.getComponents()) {
170
-                    if (component instanceof JPanel) {
171
-                        component.invalidate();
172
-                        component.validate();
173
-                    }
174
-                }
169
+                Arrays.stream(panel.getComponents()).filter(c -> c instanceof JPanel)
170
+                        .forEach(c -> {
171
+                            c.invalidate();
172
+                            c.validate();
173
+                        });
175 174
                 //And for good measure, hack the crap out of it some more :(
176
-                SwingUtilities.invokeLater(new Runnable() {
177
-                    @Override
178
-                    public void run() {
179
-                        panel.invalidate();
180
-                        panel.validate();
181
-                        for (final Component component : panel.getComponents()) {
182
-                            if (component instanceof JPanel) {
183
-                                component.invalidate();
184
-                                component.validate();
185
-                            }
186
-                        }
187
-                    }
175
+                SwingUtilities.invokeLater(() -> {
176
+                    panel.invalidate();
177
+                    panel.validate();
178
+                    Arrays.stream(panel.getComponents()).filter(c -> c instanceof JPanel)
179
+                            .forEach(c -> {
180
+                                c.invalidate();
181
+                                c.validate();
182
+                            });
188 183
                 });
189 184
                 if (category == null) {
190 185
                     title.setText("Preferences");
@@ -234,17 +229,13 @@ public class CategoryPanel extends JPanel {
234 229
      * @param message Message to display
235 230
      */
236 231
     public void setError(final String message) {
237
-        UIUtilities.invokeLater(new Runnable() {
238
-
239
-            @Override
240
-            public void run() {
241
-                final JPanel panel = new JPanel(new MigLayout("fillx"));
242
-                panel.add(new TextLabel("An error has occurred loading the "
243
-                        + "preferences dialog, an error has been raised: "),
244
-                        "wrap");
245
-                panel.add(new TextLabel(message));
246
-                scrollPane.setViewportView(panel);
247
-            }
232
+        UIUtilities.invokeLater(() -> {
233
+            final JPanel panel = new JPanel(new MigLayout("fillx"));
234
+            panel.add(new TextLabel("An error has occurred loading the "
235
+                    + "preferences dialog, an error has been raised: "),
236
+                    "wrap");
237
+            panel.add(new TextLabel(message));
238
+            scrollPane.setViewportView(panel);
248 239
         });
249 240
     }
250 241
 

+ 9
- 12
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/SwingPreferencesDialog.java 查看文件

@@ -198,20 +198,17 @@ public final class SwingPreferencesDialog extends StandardDialog implements
198 198
      * Adds the categories from the preferences manager, clearing existing categories first.
199 199
      */
200 200
     private void addCategories(final List<PreferencesCategory> categories) {
201
-        UIUtilities.invokeLater(new Runnable() {
202
-            @Override
203
-            public void run() {
204
-                tabList.removeListSelectionListener(SwingPreferencesDialog.this);
205
-                for (PreferencesCategory category : categories) {
206
-                    if (!category.isInline()) {
207
-                        ((DefaultListModel<PreferencesCategory>) tabList.getModel()).addElement(
208
-                                category);
209
-                    }
210
-                    addCategories(category.getSubcats());
201
+        UIUtilities.invokeLater(() -> {
202
+            tabList.removeListSelectionListener(this);
203
+            for (PreferencesCategory category : categories) {
204
+                if (!category.isInline()) {
205
+                    ((DefaultListModel<PreferencesCategory>) tabList.getModel()).addElement(
206
+                            category);
211 207
                 }
212
-                tabList.addListSelectionListener(SwingPreferencesDialog.this);
213
-                tabList.setSelectedIndex(0);
208
+                addCategories(category.getSubcats());
214 209
             }
210
+            tabList.addListSelectionListener(this);
211
+            tabList.setSelectedIndex(0);
215 212
         });
216 213
         mainPanel.setWaiting(false);
217 214
     }

+ 8
- 12
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/updater/SwingUpdaterDialog.java 查看文件

@@ -216,20 +216,16 @@ public class SwingUpdaterDialog extends StandardDialog implements
216 216
     @Override
217 217
     public void updateManagerStatusChanged(final UpdateManager manager,
218 218
             final UpdateManagerStatus status) {
219
-        UIUtilities.invokeLater(new Runnable() {
219
+        UIUtilities.invokeLater(() -> {
220
+            getOkButton().setEnabled(status != UpdateManagerStatus.WORKING);
220 221
 
221
-            @Override
222
-            public void run() {
223
-                getOkButton().setEnabled(status != UpdateManagerStatus.WORKING);
224
-
225
-                if (status == UpdateManagerStatus.IDLE_RESTART_NEEDED) {
226
-                    if (isVisible()) {
227
-                        restartDialogProvider.displayOrRequestFocus();
228
-                    }
229
-                    dispose();
230
-                } else {
231
-                    getCancelButton().setVisible(true);
222
+            if (status == UpdateManagerStatus.IDLE_RESTART_NEEDED) {
223
+                if (isVisible()) {
224
+                    restartDialogProvider.displayOrRequestFocus();
232 225
                 }
226
+                dispose();
227
+            } else {
228
+                getCancelButton().setVisible(true);
233 229
             }
234 230
         });
235 231
     }

+ 1
- 6
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/tree/Tree.java 查看文件

@@ -134,12 +134,7 @@ public class Tree extends JTree implements MouseMotionListener,
134 134
      * @param path Path
135 135
      */
136 136
     public void setTreePath(final TreePath path) {
137
-        UIUtilities.invokeLater(new Runnable() {
138
-            @Override
139
-            public void run() {
140
-                setSelectionPath(path);
141
-            }
142
-        });
137
+        UIUtilities.invokeLater(() -> setSelectionPath(path));
143 138
     }
144 139
 
145 140
     /**

+ 54
- 69
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java 查看文件

@@ -128,21 +128,18 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
128 128
         this.swingEventBus = swingEventBus;
129 129
         this.iconManager = iconManager;
130 130
 
131
-        UIUtilities.invokeLater(new Runnable() {
132
-            @Override
133
-            public void run() {
134
-                model = new TreeViewModel(config, new TreeViewNode(null, null));
135
-                tree = new Tree(TreeFrameManager.this, model, swingEventBus, globalConfig, domain);
136
-                tree.setCellRenderer(
137
-                        new TreeViewTreeCellRenderer(config, colourManager, TreeFrameManager.this));
138
-                tree.setVisible(true);
139
-
140
-                config.addChangeListener("treeview", TreeFrameManager.this);
141
-                config.addChangeListener("ui", "sortrootwindows", TreeFrameManager.this);
142
-                config.addChangeListener("ui", "sortchildwindows", TreeFrameManager.this);
143
-                config.addChangeListener("ui", "backgroundcolour", TreeFrameManager.this);
144
-                config.addChangeListener("ui", "foregroundcolour", TreeFrameManager.this);
145
-            }
131
+        UIUtilities.invokeLater(() -> {
132
+            model = new TreeViewModel(config, new TreeViewNode(null, null));
133
+            tree = new Tree(this, model, swingEventBus, globalConfig, domain);
134
+            tree.setCellRenderer(
135
+                    new TreeViewTreeCellRenderer(config, colourManager, this));
136
+            tree.setVisible(true);
137
+
138
+            config.addChangeListener("treeview", this);
139
+            config.addChangeListener("ui", "sortrootwindows", this);
140
+            config.addChangeListener("ui", "sortchildwindows", this);
141
+            config.addChangeListener("ui", "backgroundcolour", this);
142
+            config.addChangeListener("ui", "foregroundcolour", this);
146 143
         });
147 144
     }
148 145
 
@@ -158,27 +155,23 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
158 155
 
159 156
     @Override
160 157
     public void setParent(final JComponent parent) {
161
-        SwingUtilities.invokeLater(new Runnable() {
162
-
163
-            @Override
164
-            public void run() {
165
-                final JScrollPane scrollPane = new JScrollPane(tree);
166
-                scrollPane.setAutoscrolls(true);
167
-                scrollPane.setHorizontalScrollBarPolicy(
168
-                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
169
-
170
-                parent.setVisible(false);
171
-                parent.setLayout(new MigLayout("ins 0, fill"));
172
-                parent.add(scrollPane, "grow");
173
-                parent.setFocusable(false);
174
-                parent.setVisible(true);
175
-
176
-                setColours();
177
-
178
-                eventBus.subscribe(TreeFrameManager.this);
179
-                swingEventBus.subscribe(TreeFrameManager.this);
180
-                redoTreeView();
181
-            }
158
+        SwingUtilities.invokeLater(() -> {
159
+            final JScrollPane scrollPane = new JScrollPane(tree);
160
+            scrollPane.setAutoscrolls(true);
161
+            scrollPane.setHorizontalScrollBarPolicy(
162
+                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
163
+
164
+            parent.setVisible(false);
165
+            parent.setLayout(new MigLayout("ins 0, fill"));
166
+            parent.add(scrollPane, "grow");
167
+            parent.setFocusable(false);
168
+            parent.setVisible(true);
169
+
170
+            setColours();
171
+
172
+            eventBus.subscribe(this);
173
+            swingEventBus.subscribe(this);
174
+            redoTreeView();
182 175
         });
183 176
     }
184 177
 
@@ -308,30 +301,26 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
308 301
      * Starts the tree from scratch taking into account new sort orders.
309 302
      */
310 303
     private void redoTreeView() {
311
-        UIUtilities.invokeLater(new Runnable() {
312
-
313
-            @Override
314
-            public void run() {
315
-                ((DefaultTreeModel) tree.getModel()).setRoot(null);
316
-                ((DefaultTreeModel) tree.getModel()).setRoot(new TreeViewNode(null, null));
317
-                if (scroller != null) {
318
-                    scroller.unregister();
319
-                }
320
-                scroller = new TreeTreeScroller(swingEventBus, tree);
321
-
322
-                for (FrameContainer window : windowManager.getRootWindows()) {
323
-                    addWindow(null, windowFactory.getSwingWindow(window));
324
-                    final Collection<FrameContainer> childWindows = window.getChildren();
325
-                    for (FrameContainer childWindow : childWindows) {
326
-                        addWindow(nodes.get(windowFactory.getSwingWindow(window)),
327
-                                windowFactory.getSwingWindow(childWindow));
328
-                    }
304
+        UIUtilities.invokeLater(() -> {
305
+            ((DefaultTreeModel) tree.getModel()).setRoot(null);
306
+            ((DefaultTreeModel) tree.getModel()).setRoot(new TreeViewNode(null, null));
307
+            if (scroller != null) {
308
+                scroller.unregister();
309
+            }
310
+            scroller = new TreeTreeScroller(swingEventBus, tree);
311
+
312
+            for (FrameContainer window : windowManager.getRootWindows()) {
313
+                addWindow(null, windowFactory.getSwingWindow(window));
314
+                final Collection<FrameContainer> childWindows = window.getChildren();
315
+                for (FrameContainer childWindow : childWindows) {
316
+                    addWindow(nodes.get(windowFactory.getSwingWindow(window)),
317
+                            windowFactory.getSwingWindow(childWindow));
329 318
                 }
319
+            }
330 320
 
331
-                if (activeFrameManager.getActiveFrame() != null) {
332
-                    selectionChanged(new SwingWindowSelectedEvent(
333
-                            Optional.ofNullable(activeFrameManager.getActiveFrame())));
334
-                }
321
+            if (activeFrameManager.getActiveFrame() != null) {
322
+                selectionChanged(new SwingWindowSelectedEvent(
323
+                        Optional.ofNullable(activeFrameManager.getActiveFrame())));
335 324
             }
336 325
         });
337 326
     }
@@ -339,17 +328,13 @@ public class TreeFrameManager implements FrameManager, Serializable, ConfigChang
339 328
     @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
340 329
     public void selectionChanged(final SwingWindowSelectedEvent event) {
341 330
         if (event.getWindow().isPresent()) {
342
-            UIUtilities.invokeLater(new Runnable() {
343
-
344
-                @Override
345
-                public void run() {
346
-                    final TreeNode[] treePath = ((DefaultTreeModel) tree.getModel())
347
-                            .getPathToRoot(nodes.get(event.getWindow().get()));
348
-                    if (treePath != null && treePath.length > 0) {
349
-                        final TreePath path = new TreePath(treePath);
350
-                        tree.setTreePath(path);
351
-                        tree.scrollPathToVisible(path);
352
-                    }
331
+            UIUtilities.invokeLater(() -> {
332
+                final TreeNode[] treePath = ((DefaultTreeModel) tree.getModel())
333
+                        .getPathToRoot(nodes.get(event.getWindow().get()));
334
+                if (treePath != null && treePath.length > 0) {
335
+                    final TreePath path = new TreePath(treePath);
336
+                    tree.setTreePath(path);
337
+                    tree.scrollPathToVisible(path);
353 338
                 }
354 339
             });
355 340
         }

+ 7
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuScroller.java 查看文件

@@ -82,17 +82,13 @@ public class WindowMenuScroller implements ConfigChangeListener {
82 82
 
83 83
     @Override
84 84
     public void configChanged(final String domain, final String key) {
85
-        UIUtilities.invokeLater(new Runnable() {
86
-
87
-            @Override
88
-            public void run() {
89
-                scroller.dispose();
90
-                scroller = new MenuScroller(menu,
91
-                        config.getOptionInt(configDomain, "windowMenuItems"),
92
-                        config.getOptionInt(configDomain, "windowMenuScrollInterval"),
93
-                        fixedCount, 0);
94
-                scroller.setShowSeperators(false);
95
-            }
85
+        UIUtilities.invokeLater(() -> {
86
+            scroller.dispose();
87
+            scroller = new MenuScroller(menu,
88
+                    config.getOptionInt(configDomain, "windowMenuItems"),
89
+                    config.getOptionInt(configDomain, "windowMenuScrollInterval"),
90
+                    fixedCount, 0);
91
+            scroller.setShowSeperators(false);
96 92
         });
97 93
     }
98 94
 

+ 30
- 60
ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPane.java 查看文件

@@ -399,13 +399,7 @@ public final class TextPane extends JComponent implements MouseWheelListener,
399 399
 
400 400
     /** Clears the TextPane. */
401 401
     public void clear() {
402
-        UIUtilities.invokeLater(new Runnable() {
403
-            /** {@inheritDoc}. */
404
-            @Override
405
-            public void run() {
406
-                document.clear();
407
-            }
408
-        });
402
+        UIUtilities.invokeLater(document::clear);
409 403
     }
410 404
 
411 405
     /** Clears the selection. */
@@ -435,56 +429,44 @@ public final class TextPane extends JComponent implements MouseWheelListener,
435 429
 
436 430
     @Override
437 431
     public void trimmed(final int newSize, final int numTrimmed) {
438
-        UIUtilities.invokeLater(new Runnable() {
439
-            /** {@inheritDoc}. */
440
-            @Override
441
-            public void run() {
442
-                lastSeenLine -= numTrimmed;
443
-                final LinePosition selectedRange = getSelectedRange();
444
-                selectedRange.setStartLine(selectedRange.getStartLine() - numTrimmed);
445
-                selectedRange.setEndLine(selectedRange.getEndLine() - numTrimmed);
446
-                if (selectedRange.getStartLine() < 0) {
447
-                    selectedRange.setStartLine(0);
448
-                }
449
-                if (selectedRange.getEndLine() < 0) {
450
-                    selectedRange.setEndLine(0);
451
-                }
452
-                setSelectedText(selectedRange);
453
-                if (scrollModel.getValue() == scrollModel.getMaximum()) {
454
-                    setRangeProperties(newSize, newSize);
455
-                } else {
456
-                    setRangeProperties(newSize, scrollModel.getValue() - numTrimmed);
457
-                }
432
+        UIUtilities.invokeLater(() -> {
433
+            lastSeenLine -= numTrimmed;
434
+            final LinePosition selectedRange = getSelectedRange();
435
+            selectedRange.setStartLine(selectedRange.getStartLine() - numTrimmed);
436
+            selectedRange.setEndLine(selectedRange.getEndLine() - numTrimmed);
437
+            if (selectedRange.getStartLine() < 0) {
438
+                selectedRange.setStartLine(0);
439
+            }
440
+            if (selectedRange.getEndLine() < 0) {
441
+                selectedRange.setEndLine(0);
442
+            }
443
+            setSelectedText(selectedRange);
444
+            if (scrollModel.getValue() == scrollModel.getMaximum()) {
445
+                setRangeProperties(newSize, newSize);
446
+            } else {
447
+                setRangeProperties(newSize, scrollModel.getValue() - numTrimmed);
458 448
             }
459 449
         });
460 450
     }
461 451
 
462 452
     @Override
463 453
     public void cleared() {
464
-        UIUtilities.invokeLater(new Runnable() {
465
-            /** {@inheritDoc}. */
466
-            @Override
467
-            public void run() {
468
-                scrollModel.setMaximum(0);
469
-                scrollModel.setValue(0);
470
-                canvas.recalc();
471
-            }
454
+        UIUtilities.invokeLater(() -> {
455
+            scrollModel.setMaximum(0);
456
+            scrollModel.setValue(0);
457
+            canvas.recalc();
472 458
         });
473 459
     }
474 460
 
475 461
     @Override
476 462
     public void linesAdded(final int line, final int length, final int size) {
477
-        UIUtilities.invokeLater(new Runnable() {
478
-            /** {@inheritDoc}. */
479
-            @Override
480
-            public void run() {
481
-                if (scrollModel.getValue() == scrollModel.getMaximum()) {
482
-                    setRangeProperties(size, size);
483
-                } else {
484
-                    setRangeProperties(size, scrollModel.getValue());
485
-                    if (showNotification) {
486
-                        newLineIndicator.setVisible(true);
487
-                    }
463
+        UIUtilities.invokeLater(() -> {
464
+            if (scrollModel.getValue() == scrollModel.getMaximum()) {
465
+                setRangeProperties(size, size);
466
+            } else {
467
+                setRangeProperties(size, scrollModel.getValue());
468
+                if (showNotification) {
469
+                    newLineIndicator.setVisible(true);
488 470
                 }
489 471
             }
490 472
         });
@@ -492,13 +474,7 @@ public final class TextPane extends JComponent implements MouseWheelListener,
492 474
 
493 475
     @Override
494 476
     public void repaintNeeded() {
495
-        UIUtilities.invokeLater(new Runnable() {
496
-            /** {@inheritDoc}. */
497
-            @Override
498
-            public void run() {
499
-                canvas.recalc();
500
-            }
501
-        });
477
+        UIUtilities.invokeLater(canvas::recalc);
502 478
     }
503 479
 
504 480
     /**
@@ -542,13 +518,7 @@ public final class TextPane extends JComponent implements MouseWheelListener,
542 518
         showNotification = frame.getContainer().getConfigManager()
543 519
                 .getOptionBool(configDomain, "textpanelinenotification");
544 520
         if (!showNotification) {
545
-            UIUtilities.invokeLater(new Runnable() {
546
-                /** {@inheritDoc}. */
547
-                @Override
548
-                public void run() {
549
-                    newLineIndicator.setVisible(false);
550
-                }
551
-            });
521
+            UIUtilities.invokeLater(() -> newLineIndicator.setVisible(false));
552 522
         }
553 523
     }
554 524
 

+ 1
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/textpane/TextPaneCanvas.java 查看文件

@@ -149,13 +149,7 @@ class TextPaneCanvas extends JPanel implements MouseInputListener,
149 149
      */
150 150
     private void updateCachedSettings() {
151 151
         quickCopy = manager.getOptionBool("ui", "quickCopy");
152
-        UIUtilities.invokeLater(new Runnable() {
153
-
154
-            @Override
155
-            public void run() {
156
-                recalc();
157
-            }
158
-        });
152
+        UIUtilities.invokeLater(this::recalc);
159 153
     }
160 154
 
161 155
     private void paintOntoGraphics(final Graphics2D g) {

+ 1
- 7
windowstatus/src/com/dmdirc/addons/windowstatus/WindowStatusPanel.java 查看文件

@@ -52,13 +52,7 @@ public class WindowStatusPanel extends JPanel implements StatusBarComponent {
52 52
      * @param text New text
53 53
      */
54 54
     public void setText(final String text) {
55
-        UIUtilities.invokeLater(new Runnable() {
56
-
57
-            @Override
58
-            public void run() {
59
-                label.setText(Styliser.stipControlCodes(text));
60
-            }
61
-        });
55
+        UIUtilities.invokeLater(() -> label.setText(Styliser.stipControlCodes(text)));
62 56
     }
63 57
 
64 58
 }

Loading…
取消
儲存