Chris Smith преди 9 години
родител
ревизия
d3e8a5c965

+ 57
- 69
dcc/src/com/dmdirc/addons/dcc/DCCCommand.java Целия файл

@@ -42,18 +42,17 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
42 42
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
43 43
 import com.dmdirc.interfaces.CommandController;
44 44
 import com.dmdirc.interfaces.Connection;
45
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
46 45
 import com.dmdirc.parser.interfaces.Parser;
47 46
 import com.dmdirc.ui.WindowManager;
48 47
 import com.dmdirc.ui.input.AdditionalTabTargets;
49 48
 import com.dmdirc.ui.input.TabCompleterFactory;
50 49
 import com.dmdirc.ui.input.TabCompletionType;
51 50
 import com.dmdirc.ui.messages.ColourManagerFactory;
51
+import com.dmdirc.ui.messages.sink.MessageSinkManager;
52 52
 import com.dmdirc.util.URLBuilder;
53 53
 
54 54
 import java.awt.Window;
55 55
 import java.io.File;
56
-import java.util.concurrent.Callable;
57 56
 
58 57
 import javax.annotation.Nonnull;
59 58
 import javax.inject.Inject;
@@ -131,20 +130,16 @@ public class DCCCommand extends Command implements IntelligentCommand {
131 130
             if (parser.isValidChannelName(target)
132 131
                     || parser.getStringConverter().equalsIgnoreCase(target,
133 132
                             myNickname)) {
134
-                new Thread(new Runnable() {
135
-
136
-                    @Override
137
-                    public void run() {
138
-                        if (parser.getStringConverter().equalsIgnoreCase(target,
139
-                                myNickname)) {
140
-                            JOptionPane.showMessageDialog(null,
141
-                                    "You can't DCC yourself.", "DCC Error",
142
-                                    JOptionPane.ERROR_MESSAGE);
143
-                        } else {
144
-                            JOptionPane.showMessageDialog(null,
145
-                                    "You can't DCC a channel.", "DCC Error",
146
-                                    JOptionPane.ERROR_MESSAGE);
147
-                        }
133
+                new Thread(() -> {
134
+                    if (parser.getStringConverter().equalsIgnoreCase(target,
135
+                            myNickname)) {
136
+                        JOptionPane.showMessageDialog(null,
137
+                                "You can't DCC yourself.", "DCC Error",
138
+                                JOptionPane.ERROR_MESSAGE);
139
+                    } else {
140
+                        JOptionPane.showMessageDialog(null,
141
+                                "You can't DCC a channel.", "DCC Error",
142
+                                JOptionPane.ERROR_MESSAGE);
148 143
                     }
149 144
                 }, "DCC-Error-Message").start();
150 145
                 return;
@@ -220,76 +215,69 @@ public class DCCCommand extends Command implements IntelligentCommand {
220 215
             final Connection connection, final boolean isSilent, final String filename) {
221 216
         // New thread to ask the user what file to send
222 217
         final File givenFile = new File(filename);
223
-        final File selectedFile = UIUtilities.invokeAndWait(new Callable<File>() {
224
-            @Override
225
-            public File call() {
226
-                final JFileChooser jc = givenFile.exists()
227
-                        ? KFileChooser.getFileChooser(origin.getConfigManager(),
228
-                                myPlugin, givenFile)
229
-                        : KFileChooser.getFileChooser(origin.getConfigManager(),
230
-                                myPlugin);
231
-                final int result = showFileChooser(givenFile, target, jc);
218
+        final File selectedFile = UIUtilities.invokeAndWait(() -> {
219
+            final JFileChooser jc = givenFile.exists()
220
+                    ? KFileChooser.getFileChooser(origin.getConfigManager(),
221
+                            myPlugin, givenFile)
222
+                    : KFileChooser.getFileChooser(origin.getConfigManager(),
223
+                            myPlugin);
224
+            final int result = showFileChooser(givenFile, target, jc);
232 225
 
233
-                if (result != JFileChooser.APPROVE_OPTION
234
-                        || !handleInvalidItems(jc)) {
235
-                    return null;
236
-                }
237
-                return jc.getSelectedFile();
226
+            if (result != JFileChooser.APPROVE_OPTION
227
+                    || !handleInvalidItems(jc)) {
228
+                return null;
238 229
             }
230
+            return jc.getSelectedFile();
239 231
         });
240 232
         if (selectedFile == null) {
241 233
             return;
242 234
         }
243
-        new Thread(new Runnable() {
244
-
245
-            @Override
246
-            public void run() {
247
-                final DCCTransfer send = new DCCTransfer(origin
248
-                        .getConfigManager().getOptionInt(myPlugin.getDomain(),
249
-                                "send.blocksize"));
250
-                send.setTurbo(origin.getConfigManager().getOptionBool(
251
-                        myPlugin.getDomain(), "send.forceturbo"));
252
-                send.setType(DCCTransfer.TransferType.SEND);
235
+        new Thread(() -> {
236
+            final DCCTransfer send = new DCCTransfer(origin
237
+                    .getConfigManager().getOptionInt(myPlugin.getDomain(),
238
+                            "send.blocksize"));
239
+            send.setTurbo(origin.getConfigManager().getOptionBool(
240
+                    myPlugin.getDomain(), "send.forceturbo"));
241
+            send.setType(DCCTransfer.TransferType.SEND);
253 242
 
254
-                eventBus.publish(new DccSendRequestEvent(connection, target, selectedFile.
255
-                        getAbsolutePath()));
243
+            eventBus.publish(new DccSendRequestEvent(connection, target, selectedFile.
244
+                    getAbsolutePath()));
256 245
 
257
-                sendLine(origin, isSilent, FORMAT_OUTPUT,
258
-                        "Starting DCC Send with: " + target);
246
+            sendLine(origin, isSilent, FORMAT_OUTPUT,
247
+                    "Starting DCC Send with: " + target);
259 248
 
260
-                send.setFileName(selectedFile.getAbsolutePath());
261
-                send.setFileSize(selectedFile.length());
249
+            send.setFileName(selectedFile.getAbsolutePath());
250
+            send.setFileSize(selectedFile.length());
262 251
 
263
-                if (origin.getConfigManager().getOptionBool(
264
-                        myPlugin.getDomain(), "send.reverse")) {
265
-                    final Parser parser = connection.getParser();
252
+            if (origin.getConfigManager().getOptionBool(
253
+                    myPlugin.getDomain(), "send.reverse")) {
254
+                final Parser parser = connection.getParser();
255
+                final TransferContainer container = new TransferContainer(myPlugin, send,
256
+                        origin.getConfigManager(), colourManagerFactory, "Send: " + target,
257
+                        target, connection, urlBuilder, eventBus);
258
+                windowManager.addWindow(myPlugin.getContainer(), container);
259
+                parser.sendCTCP(target, "DCC", "SEND \""
260
+                        + selectedFile.getName() + "\" "
261
+                        + DCC.ipToLong(myPlugin.getListenIP(parser))
262
+                        + " 0 " + send.getFileSize() + " "
263
+                        + send.makeToken()
264
+                        + (send.isTurbo() ? " T" : ""));
265
+            } else {
266
+                final Parser parser = connection.getParser();
267
+                if (myPlugin.listen(send)) {
266 268
                     final TransferContainer container = new TransferContainer(myPlugin, send,
267
-                            origin.getConfigManager(), colourManagerFactory, "Send: " + target,
268
-                            target, connection, urlBuilder, eventBus);
269
+                            origin.getConfigManager(), colourManagerFactory, "*Send: "
270
+                            + target, target, connection, urlBuilder, eventBus);
269 271
                     windowManager.addWindow(myPlugin.getContainer(), container);
270 272
                     parser.sendCTCP(target, "DCC", "SEND \""
271 273
                             + selectedFile.getName() + "\" "
272 274
                             + DCC.ipToLong(myPlugin.getListenIP(parser))
273
-                            + " 0 " + send.getFileSize() + " "
274
-                            + send.makeToken()
275
+                            + " " + send.getPort() + " " + send.getFileSize()
275 276
                             + (send.isTurbo() ? " T" : ""));
276 277
                 } else {
277
-                    final Parser parser = connection.getParser();
278
-                    if (myPlugin.listen(send)) {
279
-                        final TransferContainer container = new TransferContainer(myPlugin, send,
280
-                                origin.getConfigManager(), colourManagerFactory, "*Send: "
281
-                                + target, target, connection, urlBuilder, eventBus);
282
-                        windowManager.addWindow(myPlugin.getContainer(), container);
283
-                        parser.sendCTCP(target, "DCC", "SEND \""
284
-                                + selectedFile.getName() + "\" "
285
-                                + DCC.ipToLong(myPlugin.getListenIP(parser))
286
-                                + " " + send.getPort() + " " + send.getFileSize()
287
-                                + (send.isTurbo() ? " T" : ""));
288
-                    } else {
289
-                        sendLine(origin, isSilent, "DCCSendError",
290
-                                "Unable to start dcc send with " + target
291
-                                + " - unable to create listen socket");
292
-                    }
278
+                    sendLine(origin, isSilent, "DCCSendError",
279
+                            "Unable to start dcc send with " + target
280
+                            + " - unable to create listen socket");
293 281
                 }
294 282
             }
295 283
         }, "openFileThread").start();

+ 52
- 56
dcc/src/com/dmdirc/addons/dcc/DCCManager.java Целия файл

@@ -205,68 +205,64 @@ public class DCCManager {
205 205
     public void saveFile(final String nickname, final DCCTransfer send,
206 206
             final Parser parser, final boolean reverse, final String token) {
207 207
         // New thread to ask the user where to save in to stop us locking the UI
208
-        new Thread(new Runnable() {
209
-
210
-            @Override
211
-            public void run() {
212
-                final JFileChooser jc = KFileChooser.getFileChooser(config,
213
-                        DCCManager.this,
214
-                        config.getOption(getDomain(), "receive.savelocation"));
215
-                final int result;
216
-                if (config.getOptionBool(getDomain(), "receive.autoaccept")) {
217
-                    result = JFileChooser.APPROVE_OPTION;
218
-                } else {
219
-                    result = showFileChooser(send, jc);
220
-                }
221
-                if (result != JFileChooser.APPROVE_OPTION) {
222
-                    return;
223
-                }
224
-                send.setFileName(jc.getSelectedFile().getPath());
225
-                if (!handleExists(send, jc, nickname, parser, reverse, token)) {
226
-                    return;
227
-                }
228
-                final boolean resume = handleResume(jc);
229
-                if (reverse && !token.isEmpty()) {
230
-                    final TransferContainer container = new TransferContainer(DCCManager.this, send,
231
-                            config, colourManagerFactory, "*Receive: " + nickname, nickname, null,
232
-                            urlBuilder, eventBus);
233
-                    windowManager.addWindow(getContainer(), container);
234
-                    send.setToken(token);
235
-                    if (resume) {
236
-                        if (config.getOptionBool(getDomain(),
237
-                                "receive.reverse.sendtoken")) {
238
-                            parser.sendCTCP(nickname, "DCC", "RESUME "
239
-                                    + send.getShortFileName() + " 0 "
240
-                                    + jc.getSelectedFile().length() + " "
241
-                                    + token);
242
-                        } else {
243
-                            parser.sendCTCP(nickname, "DCC", "RESUME "
244
-                                    + send.getShortFileName() + " 0 "
245
-                                    + jc.getSelectedFile().length());
246
-                        }
208
+        new Thread(() -> {
209
+            final JFileChooser jc = KFileChooser.getFileChooser(config,
210
+                    DCCManager.this,
211
+                    config.getOption(getDomain(), "receive.savelocation"));
212
+            final int result;
213
+            if (config.getOptionBool(getDomain(), "receive.autoaccept")) {
214
+                result = JFileChooser.APPROVE_OPTION;
215
+            } else {
216
+                result = showFileChooser(send, jc);
217
+            }
218
+            if (result != JFileChooser.APPROVE_OPTION) {
219
+                return;
220
+            }
221
+            send.setFileName(jc.getSelectedFile().getPath());
222
+            if (!handleExists(send, jc, nickname, parser, reverse, token)) {
223
+                return;
224
+            }
225
+            final boolean resume = handleResume(jc);
226
+            if (reverse && !token.isEmpty()) {
227
+                final TransferContainer container1 = new TransferContainer(DCCManager.this, send,
228
+                        config, colourManagerFactory, "*Receive: " + nickname, nickname, null,
229
+                        urlBuilder, eventBus);
230
+                windowManager.addWindow(getContainer(), container1);
231
+                send.setToken(token);
232
+                if (resume) {
233
+                    if (config.getOptionBool(getDomain(),
234
+                            "receive.reverse.sendtoken")) {
235
+                        parser.sendCTCP(nickname, "DCC", "RESUME "
236
+                                + send.getShortFileName() + " 0 "
237
+                                + jc.getSelectedFile().length() + " "
238
+                                + token);
247 239
                     } else {
248
-                        if (listen(send)) {
249
-                            parser.sendCTCP(nickname, "DCC", "SEND "
250
-                                    + send.getShortFileName() + " "
251
-                                    + DCC.ipToLong(getListenIP(parser))
252
-                                    + " " + send.getPort() + " "
253
-                                    + send.getFileSize() + " " + token);
254
-                        }
240
+                        parser.sendCTCP(nickname, "DCC", "RESUME "
241
+                                + send.getShortFileName() + " 0 "
242
+                                + jc.getSelectedFile().length());
255 243
                     }
256 244
                 } else {
257
-                    final TransferContainer container = new TransferContainer(DCCManager.this, send,
258
-                            config, colourManagerFactory, "Receive: " + nickname, nickname, null,
259
-                            urlBuilder, eventBus);
260
-                    windowManager.addWindow(getContainer(), container);
261
-                    if (resume) {
262
-                        parser.sendCTCP(nickname, "DCC", "RESUME "
245
+                    if (listen(send)) {
246
+                        parser.sendCTCP(nickname, "DCC", "SEND "
263 247
                                 + send.getShortFileName() + " "
264
-                                + send.getPort() + " "
265
-                                + jc.getSelectedFile().length());
266
-                    } else {
267
-                        send.connect();
248
+                                + DCC.ipToLong(getListenIP(parser))
249
+                                + " " + send.getPort() + " "
250
+                                + send.getFileSize() + " " + token);
268 251
                     }
269 252
                 }
253
+            } else {
254
+                final TransferContainer container1 = new TransferContainer(DCCManager.this, send,
255
+                        config, colourManagerFactory, "Receive: " + nickname, nickname, null,
256
+                        urlBuilder, eventBus);
257
+                windowManager.addWindow(getContainer(), container1);
258
+                if (resume) {
259
+                    parser.sendCTCP(nickname, "DCC", "RESUME "
260
+                            + send.getShortFileName() + " "
261
+                            + send.getPort() + " "
262
+                            + jc.getSelectedFile().length());
263
+                } else {
264
+                    send.connect();
265
+                }
270 266
             }
271 267
         }, "saveFileThread: " + send.getShortFileName()).start();
272 268
     }

+ 4
- 8
dcc/src/com/dmdirc/addons/dcc/TransferContainer.java Целия файл

@@ -313,14 +313,10 @@ public class TransferContainer extends FrameContainer implements
313 313
             //that this send is for.
314 314
             if (connection.getParser().getStringConverter().equalsIgnoreCase(
315 315
                     otherNickname, myNickname)) {
316
-                final Thread errorThread = new Thread(new Runnable() {
317
-
318
-                    @Override
319
-                    public void run() {
320
-                        JOptionPane.showMessageDialog(null,
321
-                                "You can't DCC yourself.", "DCC Error",
322
-                                JOptionPane.ERROR_MESSAGE);
323
-                    }
316
+                final Thread errorThread = new Thread(() -> {
317
+                    JOptionPane.showMessageDialog(null,
318
+                            "You can't DCC yourself.", "DCC Error",
319
+                            JOptionPane.ERROR_MESSAGE);
324 320
                 }, "DCC-Error-Message");
325 321
                 errorThread.start();
326 322
             } else {

+ 3
- 10
nickcolours/src/com/dmdirc/addons/nickcolours/NickColourPlugin.java Целия файл

@@ -35,7 +35,6 @@ import com.dmdirc.ui.IconManager;
35 35
 import com.dmdirc.ui.messages.ColourManager;
36 36
 
37 37
 import java.awt.Window;
38
-import java.util.concurrent.Callable;
39 38
 
40 39
 import dagger.ObjectGraph;
41 40
 
@@ -92,15 +91,9 @@ public class NickColourPlugin extends BasePlugin {
92 91
         final PreferencesCategory colours = new PluginPreferencesCategory(
93 92
                 pluginInfo, "Colours",
94 93
                 "Set colours for specific nicknames.", UIUtilities.invokeAndWait(
95
-                        new Callable<NickColourPanel>() {
96
-
97
-                            @Override
98
-                            public NickColourPanel call() {
99
-                                return new NickColourPanel(mainWindow, iconManager, colourManager,
100
-                                        manager.getIdentity(), manager.getConfigManager(),
101
-                                        pluginInfo.getDomain());
102
-                            }
103
-                        }));
94
+                () -> new NickColourPanel(mainWindow, iconManager, colourManager,
95
+                        manager.getIdentity(), manager.getConfigManager(),
96
+                        pluginInfo.getDomain())));
104 97
 
105 98
         general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
106 99
                 "ui", "shownickcoloursintext", "Show colours in text area",

+ 8
- 11
nma/src/com/dmdirc/addons/nma/NotifyMyAndroidCommand.java Целия файл

@@ -82,17 +82,14 @@ public class NotifyMyAndroidCommand extends Command {
82 82
                 origin.getConfigManager().getOption(configDomain, "apikey"),
83 83
                 origin.getConfigManager().getOption(configDomain, "application"));
84 84
 
85
-        new Thread(new Runnable() {
86
-            @Override
87
-            public void run() {
88
-                try {
89
-                    client.notify(parts[0], parts[1]);
90
-                    sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Notification sent");
91
-                } catch (IOException ex) {
92
-                    LOG.info("Exception when trying to notify NMA", ex);
93
-                    sendLine(origin, args.isSilent(), FORMAT_ERROR, "Unable to send: " + ex.
94
-                            getMessage());
95
-                }
85
+        new Thread(() -> {
86
+            try {
87
+                client.notify(parts[0], parts[1]);
88
+                sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Notification sent");
89
+            } catch (IOException ex) {
90
+                LOG.info("Exception when trying to notify NMA", ex);
91
+                sendLine(origin, args.isSilent(), FORMAT_ERROR, "Unable to send: " + ex.
92
+                        getMessage());
96 93
             }
97 94
         }, "NMA Thread").start();
98 95
     }

+ 3
- 11
notifications/src/com/dmdirc/addons/notifications/NotificationsPlugin.java Целия файл

@@ -29,8 +29,6 @@ import com.dmdirc.config.prefs.PreferencesDialogModel;
29 29
 import com.dmdirc.plugins.PluginInfo;
30 30
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
31 31
 
32
-import java.util.concurrent.Callable;
33
-
34 32
 import dagger.ObjectGraph;
35 33
 
36 34
 /**
@@ -76,15 +74,9 @@ public class NotificationsPlugin extends BaseCommandPlugin {
76 74
     @Override
77 75
     public void showConfig(final PreferencesDialogModel manager) {
78 76
         final NotificationConfig configPanel = UIUtilities.invokeAndWait(
79
-                new Callable<NotificationConfig>() {
80
-
81
-                    @Override
82
-                    public NotificationConfig call() {
83
-                        return new NotificationConfig(manager.getIdentity(), pluginInfo.getDomain(),
84
-                                manager.getConfigManager().getOptionList(pluginInfo.getDomain(),
85
-                                        "methodOrder"));
86
-                    }
87
-                });
77
+                () -> new NotificationConfig(manager.getIdentity(), pluginInfo.getDomain(),
78
+                        manager.getConfigManager().getOptionList(pluginInfo.getDomain(),
79
+                                "methodOrder")));
88 80
 
89 81
         final PreferencesCategory category = new PluginPreferencesCategory(
90 82
                 pluginInfo, "Notifications", "", "category-notifications",

+ 6
- 14
nowplaying/src/com/dmdirc/addons/nowplaying/ConfigPanel.java Целия файл

@@ -163,20 +163,12 @@ public class ConfigPanel extends JPanel implements PreferencesInterface, KeyList
163 163
         }
164 164
 
165 165
         final String text = manager.doSubstitution(
166
-                UIUtilities.invokeAndWait(new Callable<String>() {
167
-                    @Override
168
-                    public String call() {
169
-                        return textfield.getText();
170
-                    }
171
-                }), source);
172
-        SwingUtilities.invokeLater(new Runnable() {
173
-            @Override
174
-            public void run() {
175
-                preview.setText("Preview:\n" + text);
176
-                preview.repaint();
177
-                previewPanel.revalidate();
178
-                revalidate();
179
-            }
166
+                UIUtilities.invokeAndWait((Callable<String>) textfield::getText), source);
167
+        SwingUtilities.invokeLater(() -> {
168
+            preview.setText("Preview:\n" + text);
169
+            preview.repaint();
170
+            previewPanel.revalidate();
171
+            revalidate();
180 172
         });
181 173
     }
182 174
 

+ 3
- 10
nowplaying/src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java Целия файл

@@ -29,8 +29,6 @@ import com.dmdirc.config.prefs.PreferencesDialogModel;
29 29
 import com.dmdirc.plugins.PluginInfo;
30 30
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
31 31
 
32
-import java.util.concurrent.Callable;
33
-
34 32
 import dagger.ObjectGraph;
35 33
 
36 34
 /**
@@ -78,14 +76,9 @@ public class NowPlayingPlugin extends BaseCommandPlugin {
78 76
     @Override
79 77
     public void showConfig(final PreferencesDialogModel manager) {
80 78
         final ConfigPanel configPanel = UIUtilities.invokeAndWait(
81
-                new Callable<ConfigPanel>() {
82
-                    @Override
83
-                    public ConfigPanel call() {
84
-                        return new ConfigPanel(nowplayingmanager, manager.getConfigManager(),
85
-                                manager.getIdentity(), domain,
86
-                                nowplayingmanager.getSettings());
87
-                    }
88
-                });
79
+                () -> new ConfigPanel(nowplayingmanager, manager.getConfigManager(),
80
+                        manager.getIdentity(), domain,
81
+                        nowplayingmanager.getSettings()));
89 82
 
90 83
         final PreferencesCategory category = new PluginPreferencesCategory(
91 84
                 pluginInfo, "Now Playing",

+ 9
- 13
nowplaying/src/com/dmdirc/addons/nowplaying/NowPlayingSubsitutionPanel.java Целия файл

@@ -28,6 +28,7 @@ import com.dmdirc.addons.ui_swing.components.substitutions.SubstitutionsPanel;
28 28
 
29 29
 import java.util.ArrayList;
30 30
 import java.util.List;
31
+import java.util.stream.Collectors;
31 32
 
32 33
 import javax.swing.SwingUtilities;
33 34
 
@@ -59,21 +60,16 @@ public class NowPlayingSubsitutionPanel extends SubstitutionsPanel<List<String>>
59 60
 
60 61
     @Override
61 62
     public void setType(final List<String> type) {
62
-        SwingUtilities.invokeLater(new Runnable() {
63
+        SwingUtilities.invokeLater(() -> {
64
+            substitutions = new ArrayList<>();
63 65
 
64
-            @Override
65
-            public void run() {
66
-                substitutions = new ArrayList<>();
67
-
68
-                if (type != null) {
69
-                    for (String sub : type) {
70
-                        substitutions.add(new SubstitutionLabel(new Substitution(sub,
71
-                                sub)));
72
-                    }
73
-                }
74
-
75
-                layoutComponents();
66
+            if (type != null) {
67
+                substitutions.addAll(type.stream()
68
+                        .map(sub -> new SubstitutionLabel(new Substitution(sub, sub)))
69
+                        .collect(Collectors.toList()));
76 70
             }
71
+
72
+            layoutComponents();
77 73
         });
78 74
     }
79 75
 

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