Ignore:
Timestamp:
2019-09-29T22:03:18+02:00 (5 years ago)
Author:
donvip
Message:

use lambdas for Runnable

Location:
applications/editors/josm/plugins/geochat/src/geochat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/geochat/src/geochat/ChatPaneManager.java

    r34512 r35160  
    102102        final String nline = line.startsWith("\n") ? line : "\n" + line;
    103103        final JTextPane thepane = chatPanes.get(userName).pane;
    104         GuiHelper.runInEDT(new Runnable() {
    105             @Override
    106             public void run() {
    107                 Document doc = thepane.getDocument();
    108                 try {
    109                     SimpleAttributeSet attrs = null;
    110                     if (messageType != MESSAGE_TYPE_DEFAULT) {
    111                         attrs = new SimpleAttributeSet();
    112                         if (messageType == MESSAGE_TYPE_INFORMATION)
    113                             StyleConstants.setItalic(attrs, true);
    114                         else if (messageType == MESSAGE_TYPE_ATTENTION)
    115                             StyleConstants.setForeground(attrs, COLOR_ATTENTION);
    116                     }
    117                     doc.insertString(doc.getLength(), nline, attrs);
    118                 } catch (BadLocationException ex) {
    119                     Logging.warn(ex);
     104        GuiHelper.runInEDT(() -> {
     105            Document doc = thepane.getDocument();
     106            try {
     107                SimpleAttributeSet attrs = null;
     108                if (messageType != MESSAGE_TYPE_DEFAULT) {
     109                    attrs = new SimpleAttributeSet();
     110                    if (messageType == MESSAGE_TYPE_INFORMATION)
     111                        StyleConstants.setItalic(attrs, true);
     112                    else if (messageType == MESSAGE_TYPE_ATTENTION)
     113                        StyleConstants.setForeground(attrs, COLOR_ATTENTION);
    120114                }
    121                 thepane.setCaretPosition(doc.getLength());
     115                doc.insertString(doc.getLength(), nline, attrs);
     116            } catch (BadLocationException ex) {
     117                Logging.warn(ex);
    122118            }
     119            thepane.setCaretPosition(doc.getLength());
    123120        });
    124121    }
  • applications/editors/josm/plugins/geochat/src/geochat/ChatServerConnection.java

    r34512 r35160  
    116116            return;
    117117        }
    118         new Thread(new Runnable() {
    119             @Override
    120             public void run() {
    121                 try {
    122                     int cnt = 10;
    123                     while (getPosition() == null && cnt-- > 0) {
    124                         Thread.sleep(200);
    125                     }
    126                 } catch (InterruptedException e) {
    127                     Logging.warn(e);
    128                 }
    129                 autoLogin(userName);
    130             }
     118        new Thread(() -> {
     119            try {
     120                int cnt = 10;
     121                while (getPosition() == null && cnt-- > 0) {
     122                    Thread.sleep(200);
     123                }
     124            } catch (InterruptedException e) {
     125                Logging.warn(e);
     126            }
     127            autoLogin(userName);
    131128        }).start();
    132129    }
  • applications/editors/josm/plugins/geochat/src/geochat/GeoChatPanel.java

    r34512 r35160  
    235235            title = title + " (" + comment + ")";
    236236        final String alarm = (alarmLevel <= 0 ? "" : alarmLevel == 1 ? "* " : "!!! ") + title;
    237         GuiHelper.runInEDT(new Runnable() {
    238             @Override
    239             public void run() {
    240                 setTitle(alarm);
    241             }
    242         });
     237        GuiHelper.runInEDT(() -> setTitle(alarm));
    243238    }
    244239
     
    259254        Config.getPref().put("geochat.username", userName);
    260255        if (gcPanel.getComponentCount() == 1) {
    261             GuiHelper.runInEDTAndWait(new Runnable() {
    262                 @Override
    263                 public void run() {
    264                     gcPanel.remove(0);
    265                     gcPanel.add(tabs, BorderLayout.CENTER);
    266                     gcPanel.add(input, BorderLayout.SOUTH);
    267                 }
     256            GuiHelper.runInEDTAndWait(() -> {
     257                gcPanel.remove(0);
     258                gcPanel.add(tabs, BorderLayout.CENTER);
     259                gcPanel.add(input, BorderLayout.SOUTH);
    268260            });
    269261        }
     
    274266    public void notLoggedIn(final String reason) {
    275267        if (reason != null) {
    276             GuiHelper.runInEDT(new Runnable() {
    277                 @Override
    278                 public void run() {
    279                     new Notification(tr("Failed to log in to GeoChat:") + "\n" + reason).show();
    280                 }
    281             });
     268            GuiHelper.runInEDT(() -> new Notification(tr("Failed to log in to GeoChat:") + '\n' + reason).show());
    282269        } else {
    283270            // regular logout
     
    292279    @Override
    293280    public void messageSendFailed(final String reason) {
    294         GuiHelper.runInEDT(new Runnable() {
    295             @Override
    296             public void run() {
    297                 new Notification(tr("Failed to send message:") + "\n" + reason).show();
    298             }
    299         });
     281        GuiHelper.runInEDT(() -> new Notification(tr("Failed to send message:") + '\n' + reason).show());
    300282    }
    301283
  • applications/editors/josm/plugins/geochat/src/geochat/JsonQueryUtil.java

    r34512 r35160  
    9090    public void run() {
    9191        if (EventQueue.isDispatchThread()) {
    92             new Thread(new Runnable() {
    93                 @Override
    94                 public void run() {
    95                     doRealRun();
    96                 }
    97             }).start();
     92            new Thread(this::doRealRun).start();
    9893        } else {
    9994            doRealRun();
Note: See TracChangeset for help on using the changeset viewer.