Changeset 10616 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-07-23T21:38:02+02:00 (8 years ago)
Author:
Don-vip
Message:

see #11390 - sonar - squid:S1604 - Java 8: Anonymous inner classes containing only one method should become lambdas

Location:
trunk/src/org/openstreetmap/josm
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java

    r10611 r10616  
    576576    private void requestFocusToDefaultButton() {
    577577        if (defaultButton != null) {
    578             GuiHelper.runInEDT(() -> defaultButton.requestFocusInWindow());
     578            GuiHelper.runInEDT(defaultButton::requestFocusInWindow);
    579579        }
    580580    }
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r10611 r10616  
    500500            final Popup staticPopup = popup;
    501501            popup = null;
    502             EventQueue.invokeLater(() -> staticPopup.hide());
     502            EventQueue.invokeLater(staticPopup::hide);
    503503        }
    504504
     
    520520            } else {
    521521                // There is no old popup
    522                 EventQueue.invokeLater(() -> staticPopup.show());
     522                EventQueue.invokeLater(staticPopup::show);
    523523            }
    524524            this.popupLabels = lbls;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java

    r10611 r10616  
    420420                    refreshView(r);
    421421                }
    422                 SwingUtilities.invokeLater(() -> Main.map.repaint());
     422                SwingUtilities.invokeLater(Main.map::repaint);
    423423            } catch (OsmTransferException e) {
    424424                if (canceled) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r10611 r10616  
    122122        // just trigger a repaint - the display name of the relation members may have changed
    123123        Collection<RelationMember> sel = getSelectedMembers();
    124         GuiHelper.runInEDT(() -> fireTableDataChanged());
     124        GuiHelper.runInEDT(this::fireTableDataChanged);
    125125        setSelectedMembers(sel);
    126126    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java

    r10611 r10616  
    167167                // FIXME: this is necessary because there are dialogs listening
    168168                // for DataChangeEvents which manipulate Swing components on this thread.
    169                 SwingUtilities.invokeLater(() -> getLayer().onPostDownloadFromServer());
     169                SwingUtilities.invokeLater(getLayer()::onPostDownloadFromServer);
    170170
    171171                if (visitor.getConflicts().isEmpty())
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java

    r10611 r10616  
    138138        final Set<PrimitiveId> errs = mainTask.getMissingPrimitives();
    139139        if (errs != null && !errs.isEmpty())
    140             GuiHelper.runInEDTAndWait(() -> reportProblemDialog(errs,
     140            GuiHelper.runInEDTAndWait(reportProblemDialog(errs,
    141141                    trn("Object could not be downloaded", "Some objects could not be downloaded", errs.size()),
    142142                    trn("One object could not be downloaded.<br>",
     
    148148                    tr("missing objects:"),
    149149                    JOptionPane.ERROR_MESSAGE
    150                     ).showDialog());
     150                    )::showDialog);
    151151
    152152        // Warm about deleted primitives
     
    160160        }
    161161        if (!del.isEmpty())
    162             GuiHelper.runInEDTAndWait(() -> reportProblemDialog(del,
     162            GuiHelper.runInEDTAndWait(reportProblemDialog(del,
    163163                    trn("Object deleted", "Objects deleted", del.size()),
    164164                    trn(
     
    169169                    null,
    170170                    JOptionPane.WARNING_MESSAGE
    171             ).showDialog());
     171            )::showDialog);
    172172    }
    173173
  • trunk/src/org/openstreetmap/josm/io/NMEAImporter.java

    r10615 r10616  
    7575           .append("</html>");
    7676        if (success) {
    77             SwingUtilities.invokeLater(() -> new Notification(
     77            SwingUtilities.invokeLater(new Notification(
    7878                    "<h3>" + tr("NMEA import success:") + "</h3>" + msg.toString())
    7979                    .setIcon(JOptionPane.INFORMATION_MESSAGE)
    80                     .show());
     80                    ::show);
    8181        } else {
    8282            HelpAwareOptionPane.showMessageDialogInEDT(
  • trunk/src/org/openstreetmap/josm/plugins/Plugin.java

    r9645 r10616  
    146146        File pluginJar = new File(pluginDir, info.name + ".jar");
    147147        final URL pluginJarUrl = Utils.fileToURL(pluginJar);
    148         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
    149               @Override
    150               public ClassLoader run() {
    151                   return new URLClassLoader(new URL[] {pluginJarUrl}, Main.class.getClassLoader());
    152               }
    153         });
     148        return AccessController.doPrivileged((PrivilegedAction<ClassLoader>)
     149                () -> new URLClassLoader(new URL[] {pluginJarUrl}, Main.class.getClassLoader()));
    154150    }
    155151}
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10493 r10616  
    2424import java.util.Collection;
    2525import java.util.Collections;
    26 import java.util.Comparator;
    2726import java.util.HashMap;
    2827import java.util.HashSet;
     
    3534import java.util.Set;
    3635import java.util.TreeSet;
    37 import java.util.concurrent.Callable;
    3836import java.util.concurrent.ExecutionException;
    3937import java.util.concurrent.FutureTask;
     
    534532
    535533        // Continuation
    536         Main.worker.submit(new Runnable() {
    537             @Override
    538             public void run() {
    539                 // Build list of plugins to download
    540                 Set<PluginInformation> toDownload = new HashSet<>(pluginInfoDownloadTask.getAvailablePlugins());
    541                 for (Iterator<PluginInformation> it = toDownload.iterator(); it.hasNext();) {
    542                     PluginInformation info = it.next();
    543                     if (!missingRequiredPlugin.contains(info.getName())) {
    544                         it.remove();
     534        Main.worker.submit(() -> {
     535            // Build list of plugins to download
     536            Set<PluginInformation> toDownload = new HashSet<>(pluginInfoDownloadTask.getAvailablePlugins());
     537            for (Iterator<PluginInformation> it = toDownload.iterator(); it.hasNext();) {
     538                PluginInformation info = it.next();
     539                if (!missingRequiredPlugin.contains(info.getName())) {
     540                    it.remove();
     541                }
     542            }
     543            // Check if something has still to be downloaded
     544            if (!toDownload.isEmpty()) {
     545                // download plugins
     546                final PluginDownloadTask task = new PluginDownloadTask(parent, toDownload, tr("Download plugins"));
     547                Main.worker.submit(task);
     548                Main.worker.submit(() -> {
     549                    // restart if some plugins have been downloaded
     550                    if (!task.getDownloadedPlugins().isEmpty()) {
     551                        // update plugin list in preferences
     552                        Set<String> plugins = new HashSet<>(Main.pref.getCollection("plugins"));
     553                        for (PluginInformation plugin : task.getDownloadedPlugins()) {
     554                            plugins.add(plugin.name);
     555                        }
     556                        Main.pref.putCollection("plugins", plugins);
     557                        // restart
     558                        new RestartAction().actionPerformed(null);
     559                    } else {
     560                        Main.warn("No plugin downloaded, restart canceled");
    545561                    }
    546                 }
    547                 // Check if something has still to be downloaded
    548                 if (!toDownload.isEmpty()) {
    549                     // download plugins
    550                     final PluginDownloadTask task = new PluginDownloadTask(parent, toDownload, tr("Download plugins"));
    551                     Main.worker.submit(task);
    552                     Main.worker.submit(new Runnable() {
    553                         @Override
    554                         public void run() {
    555                             // restart if some plugins have been downloaded
    556                             if (!task.getDownloadedPlugins().isEmpty()) {
    557                                 // update plugin list in preferences
    558                                 Set<String> plugins = new HashSet<>(Main.pref.getCollection("plugins"));
    559                                 for (PluginInformation plugin : task.getDownloadedPlugins()) {
    560                                     plugins.add(plugin.name);
    561                                 }
    562                                 Main.pref.putCollection("plugins", plugins);
    563                                 // restart
    564                                 new RestartAction().actionPerformed(null);
    565                             } else {
    566                                 Main.warn("No plugin downloaded, restart canceled");
    567                             }
    568                         }
    569                     });
    570                 } else {
    571                     Main.warn("No plugin to download, operation canceled");
    572                 }
     562                });
     563            } else {
     564                Main.warn("No plugin to download, operation canceled");
    573565            }
    574566        });
     
    665657    public static synchronized DynamicURLClassLoader getPluginClassLoader() {
    666658        if (pluginClassLoader == null) {
    667             pluginClassLoader = AccessController.doPrivileged(new PrivilegedAction<DynamicURLClassLoader>() {
    668                 @Override
    669                 public DynamicURLClassLoader run() {
    670                     return new DynamicURLClassLoader(new URL[0], Main.class.getClassLoader());
    671                 }
    672             });
     659            pluginClassLoader = AccessController.doPrivileged((PrivilegedAction<DynamicURLClassLoader>)
     660                    () -> new DynamicURLClassLoader(new URL[0], Main.class.getClassLoader()));
    673661            sources.add(0, pluginClassLoader);
    674662        }
     
    760748            Collections.sort(
    761749                    toLoad,
    762                     new Comparator<PluginInformation>() {
    763                         @Override
    764                         public int compare(PluginInformation o1, PluginInformation o2) {
    765                             if (o1.stage < o2.stage) return -1;
    766                             if (o1.stage == o2.stage) return 0;
    767                             return 1;
    768                         }
     750                    (o1, o2) -> {
     751                        if (o1.stage < o2.stage) return -1;
     752                        if (o1.stage == o2.stage) return 0;
     753                        return 1;
    769754                    }
    770755            );
     
    11731158            return;
    11741159
    1175         final File[] files = pluginDir.listFiles(new FilenameFilter() {
    1176             @Override
    1177             public boolean accept(File dir, String name) {
    1178                 return name.endsWith(".jar.new");
    1179             }
    1180         });
     1160        final File[] files = pluginDir.listFiles((FilenameFilter) (dir, name) -> name.endsWith(".jar.new"));
    11811161        if (files == null)
    11821162            return;
     
    11981178            } catch (IOException e) {
    11991179                if (dowarn) {
    1200                     Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}",
     1180                    Main.warn(e, tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. {2}",
    12011181                            plugin.toString(), updatedPlugin.toString(), e.getLocalizedMessage()));
    12021182                }
     
    13091289
    13101290        try {
    1311             FutureTask<Integer> task = new FutureTask<>(new Callable<Integer>() {
    1312                 @Override
    1313                 public Integer call() {
    1314                     return HelpAwareOptionPane.showOptionDialog(
    1315                             Main.parent,
    1316                             msg.toString(),
    1317                             tr("Update plugins"),
    1318                             JOptionPane.QUESTION_MESSAGE,
    1319                             null,
    1320                             options,
    1321                             options[0],
    1322                             ht("/ErrorMessages#ErrorInPlugin")
    1323                     );
    1324                 }
    1325             });
     1291            FutureTask<Integer> task = new FutureTask<>(() -> HelpAwareOptionPane.showOptionDialog(
     1292                    Main.parent,
     1293                    msg.toString(),
     1294                    tr("Update plugins"),
     1295                    JOptionPane.QUESTION_MESSAGE,
     1296                    null,
     1297                    options,
     1298                    options[0],
     1299                    ht("/ErrorMessages#ErrorInPlugin")
     1300            ));
    13261301            GuiHelper.runInEDT(task);
    13271302            return task.get();
     
    13941369            plugins.remove(plugin.getPluginInformation().name);
    13951370            Main.pref.putCollection("plugins", plugins);
    1396             GuiHelper.runInEDTAndWait(new Runnable() {
    1397                 @Override
    1398                 public void run() {
    1399                     JOptionPane.showMessageDialog(
    1400                             Main.parent,
    1401                             tr("The plugin has been removed from the configuration. Please restart JOSM to unload the plugin."),
    1402                             tr("Information"),
    1403                             JOptionPane.INFORMATION_MESSAGE
    1404                     );
    1405                 }
    1406             });
     1371            GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog(
     1372                    Main.parent,
     1373                    tr("The plugin has been removed from the configuration. Please restart JOSM to unload the plugin."),
     1374                    tr("Information"),
     1375                    JOptionPane.INFORMATION_MESSAGE
     1376            ));
    14071377            return null;
    14081378        default:
  • trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java

    r10173 r10616  
    4747    }
    4848
     49    /**
     50     * Constructs a new {@code ReadLocalPluginInformationTask}.
     51     * @param monitor progress monitor
     52     */
    4953    public ReadLocalPluginInformationTask(ProgressMonitor monitor) {
    5054        super(tr("Reading local plugin information.."), monitor, false);
     
    7781
    7882    private static File[] listFiles(File pluginsDirectory, final String regex) {
    79         return pluginsDirectory.listFiles(
    80                 new FilenameFilter() {
    81                     @Override
    82                     public boolean accept(File dir, String name) {
    83                         return name.matches(regex);
    84                     }
    85                 }
    86         );
     83        return pluginsDirectory.listFiles((FilenameFilter) (dir, name) -> name.matches(regex));
    8784    }
    8885
     
    108105    protected void scanPluginFiles(ProgressMonitor monitor, File pluginsDirectory) {
    109106        File[] pluginFiles = pluginsDirectory.listFiles(
    110                 new FilenameFilter() {
    111                     @Override
    112                     public boolean accept(File dir, String name) {
    113                         return name.endsWith(".jar") || name.endsWith(".jar.new");
    114                     }
    115                 }
     107                (FilenameFilter) (dir, name) -> name.endsWith(".jar") || name.endsWith(".jar.new")
    116108        );
    117109        if (pluginFiles == null || pluginFiles.length == 0)
     
    131123                }
    132124            } catch (PluginException e) {
    133                 Main.warn("PluginException: "+e.getMessage());
     125                Main.warn(e, "PluginException: ");
    134126                Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname));
    135127            }
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r10173 r10616  
    200200    private static void displayErrorMessage(final ProgressMonitor monitor, final String msg, final String details, final String title,
    201201            final String firstMessage) {
    202         GuiHelper.runInEDTAndWait(new Runnable() {
    203             @Override public void run() {
    204                 JPanel panel = new JPanel(new GridBagLayout());
    205                 panel.add(new JLabel(firstMessage), GBC.eol().insets(0, 0, 0, 10));
    206                 StringBuilder b = new StringBuilder();
    207                 for (String part : msg.split("(?<=\\G.{200})")) {
    208                     b.append(part).append('\n');
    209                 }
    210                 panel.add(new JLabel("<html><body width=\"500\"><b>"+b.toString().trim()+"</b></body></html>"), GBC.eol().insets(0, 0, 0, 10));
    211                 if (details != null && !details.isEmpty()) {
    212                     panel.add(new JLabel(tr("Details:")), GBC.eol().insets(0, 0, 0, 10));
    213                     JosmTextArea area = new JosmTextArea(details);
    214                     area.setEditable(false);
    215                     area.setLineWrap(true);
    216                     area.setWrapStyleWord(true);
    217                     JScrollPane scrollPane = new JScrollPane(area);
    218                     scrollPane.setPreferredSize(new Dimension(500, 300));
    219                     panel.add(scrollPane, GBC.eol().fill());
    220                 }
    221                 JOptionPane.showMessageDialog(monitor.getWindowParent(), panel, title, JOptionPane.ERROR_MESSAGE);
    222             }
     202        GuiHelper.runInEDTAndWait(() -> {
     203            JPanel panel = new JPanel(new GridBagLayout());
     204            panel.add(new JLabel(firstMessage), GBC.eol().insets(0, 0, 0, 10));
     205            StringBuilder b = new StringBuilder();
     206            for (String part : msg.split("(?<=\\G.{200})")) {
     207                b.append(part).append('\n');
     208            }
     209            panel.add(new JLabel("<html><body width=\"500\"><b>"+b.toString().trim()+"</b></body></html>"), GBC.eol().insets(0, 0, 0, 10));
     210            if (details != null && !details.isEmpty()) {
     211                panel.add(new JLabel(tr("Details:")), GBC.eol().insets(0, 0, 0, 10));
     212                JosmTextArea area = new JosmTextArea(details);
     213                area.setEditable(false);
     214                area.setLineWrap(true);
     215                area.setWrapStyleWord(true);
     216                JScrollPane scrollPane = new JScrollPane(area);
     217                scrollPane.setPreferredSize(new Dimension(500, 300));
     218                panel.add(scrollPane, GBC.eol().fill());
     219            }
     220            JOptionPane.showMessageDialog(monitor.getWindowParent(), panel, title, JOptionPane.ERROR_MESSAGE);
    223221        });
    224222    }
     
    296294        for (String location : PluginInformation.getPluginLocations()) {
    297295            File[] f = new File(location).listFiles(
    298                     new FilenameFilter() {
    299                         @Override
    300                         public boolean accept(File dir, String name) {
    301                             return name.matches("^([0-9]+-)?site.*\\.txt$") ||
    302                             name.matches("^([0-9]+-)?site.*-icons\\.zip$");
    303                         }
    304                     }
     296                    (FilenameFilter) (dir, name) -> name.matches("^([0-9]+-)?site.*\\.txt$") ||
     297                                                    name.matches("^([0-9]+-)?site.*-icons\\.zip$")
    305298            );
    306299            if (f != null && f.length > 0) {
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r9876 r10616  
    3434import org.openstreetmap.josm.io.OsmTransferException;
    3535import org.openstreetmap.josm.io.auth.CredentialsManager;
     36import org.openstreetmap.josm.tools.Utils.Function;
    3637import org.openstreetmap.josm.tools.date.DateUtils;
    3738
     
    141142            OsmPrimitive firstRefs = conflict.b.iterator().next();
    142143            String objId = Long.toString(conflict.a.getId());
    143             Collection<Long> refIds = Utils.transform(conflict.b, new Utils.Function<OsmPrimitive, Long>() {
    144 
    145                 @Override
    146                 public Long apply(OsmPrimitive x) {
    147                     return x.getId();
    148                 }
    149             });
     144            Collection<Long> refIds = Utils.transform(conflict.b, (Function<OsmPrimitive, Long>) x -> x.getId());
    150145            String refIdsString = refIds.size() == 1 ? refIds.iterator().next().toString() : refIds.toString();
    151146            if (conflict.a instanceof Node) {
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r9983 r10616  
    1616import java.util.Arrays;
    1717import java.util.Collection;
    18 import java.util.Comparator;
    1918import java.util.HashMap;
    2019import java.util.Locale;
     
    382381        Locale[] l = new Locale[v.size()];
    383382        l = v.toArray(l);
    384         Arrays.sort(l, new Comparator<Locale>() {
    385             @Override
    386             public int compare(Locale o1, Locale o2) {
    387                 return o1.toString().compareTo(o2.toString());
    388             }
    389         });
     383        Arrays.sort(l, (o1, o2) -> o1.toString().compareTo(o2.toString()));
    390384        return l;
    391385    }
     
    743737
    744738    public static TranslationAdapter getTranslationAdapter() {
    745         return new TranslationAdapter() {
    746             @Override
    747             public String tr(String text, Object... objects) {
    748                 return I18n.tr(text, objects);
    749             }
    750         };
     739        return (text, objects) -> I18n.tr(text, objects);
    751740    }
    752741
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r10600 r10616  
    3333import java.util.Arrays;
    3434import java.util.Collection;
    35 import java.util.Comparator;
    3635import java.util.HashMap;
    3736import java.util.Hashtable;
     
    7675import org.w3c.dom.NodeList;
    7776import org.xml.sax.Attributes;
    78 import org.xml.sax.EntityResolver;
    7977import org.xml.sax.InputSource;
    8078import org.xml.sax.SAXException;
     
    687685     * Load the image in a background thread.
    688686     *
    689      * This method returns immediately and runs the image request
    690      * asynchronously.
     687     * This method returns immediately and runs the image request asynchronously.
    691688     *
    692689     * @param callback a callback. It is called, when the image is ready.
     
    697694    public void getInBackground(final ImageCallback callback) {
    698695        if (name.startsWith(HTTP_PROTOCOL) || name.startsWith(WIKI_PROTOCOL)) {
    699             Runnable fetch = new Runnable() {
    700                 @Override
    701                 public void run() {
    702                     ImageIcon result = get();
    703                     callback.finished(result);
    704                 }
    705             };
    706             IMAGE_FETCHER.submit(fetch);
     696            IMAGE_FETCHER.submit(() -> callback.finished(get()));
    707697        } else {
    708             ImageIcon result = get();
    709             callback.finished(result);
     698            callback.finished(get());
    710699        }
    711700    }
     
    714703     * Load the image in a background thread.
    715704     *
    716      * This method returns immediately and runs the image request
    717      * asynchronously.
     705     * This method returns immediately and runs the image request asynchronously.
    718706     *
    719707     * @param callback a callback. It is called, when the image is ready.
     
    725713    public void getInBackground(final ImageResourceCallback callback) {
    726714        if (name.startsWith(HTTP_PROTOCOL) || name.startsWith(WIKI_PROTOCOL)) {
    727             Runnable fetch = new Runnable() {
    728                 @Override
    729                 public void run() {
    730                     callback.finished(getResource());
    731                 }
    732             };
    733             IMAGE_FETCHER.submit(fetch);
     715            IMAGE_FETCHER.submit(() -> callback.finished(getResource()));
    734716        } else {
    735717            callback.finished(getResource());
     
    12801262            });
    12811263
    1282             parser.setEntityResolver(new EntityResolver() {
    1283                 @Override
    1284                 public InputSource resolveEntity(String publicId, String systemId) {
    1285                     return new InputSource(new ByteArrayInputStream(new byte[0]));
    1286                 }
    1287             });
     1264            parser.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(new byte[0])));
    12881265
    12891266            CachedFile cf = new CachedFile(base + fn).setDestDir(
     
    15081485        // Check if the presets have icons for nodes/relations.
    15091486        if (!OsmPrimitiveType.WAY.equals(primitive.getType())) {
    1510             final Collection<TaggingPreset> presets = new TreeSet<>(new Comparator<TaggingPreset>() {
    1511                 @Override
    1512                 public int compare(TaggingPreset o1, TaggingPreset o2) {
    1513                     final int o1TypesSize = o1.types == null || o1.types.isEmpty() ? Integer.MAX_VALUE : o1.types.size();
    1514                     final int o2TypesSize = o2.types == null || o2.types.isEmpty() ? Integer.MAX_VALUE : o2.types.size();
    1515                     return Integer.compare(o1TypesSize, o2TypesSize);
    1516                 }
     1487            final Collection<TaggingPreset> presets = new TreeSet<>((o1, o2) -> {
     1488                final int o1TypesSize = o1.types == null || o1.types.isEmpty() ? Integer.MAX_VALUE : o1.types.size();
     1489                final int o2TypesSize = o2.types == null || o2.types.isEmpty() ? Integer.MAX_VALUE : o2.types.size();
     1490                return Integer.compare(o1TypesSize, o2TypesSize);
    15171491            });
    15181492            presets.addAll(TaggingPresets.getMatchingPresets(primitive));
  • trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java

    r9634 r10616  
    77import java.awt.KeyboardFocusManager;
    88import java.awt.event.ActionEvent;
    9 import java.awt.event.ActionListener;
    109import java.awt.event.KeyEvent;
    1110import java.util.HashMap;
     
    6362                        String.valueOf(info.getShortcut()), info.getDescription()));
    6463                item.setMnemonic(info.getShortcut());
    65                 item.addActionListener(new ActionListener() {
    66                     @Override
    67                     public void actionPerformed(ActionEvent e) {
    68                         action.action.executeMultikeyAction(info.getIndex(), false);
    69                     }
    70                 });
     64                item.addActionListener(e -> action.action.executeMultikeyAction(info.getIndex(), false));
    7165                layers.add(item);
    7266            }
     
    7973                            "Repeat " + lastLayer.getDescription()));
    8074                    repeateItem.setMnemonic(action.shortcut.getKeyStroke().getKeyCode());
    81                     repeateItem.addActionListener(new ActionListener() {
    82                         @Override
    83                         public void actionPerformed(ActionEvent e) {
    84                             action.action.executeMultikeyAction(-1, true);
    85                         }
    86                     });
     75                    repeateItem.addActionListener(e -> action.action.executeMultikeyAction(-1, true));
    8776                    layers.add(repeateItem);
    8877                }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r10580 r10616  
    421421    // Method unused, but kept for translation already done. To reuse during Java 9 migration
    422422    protected void askUpdateJava(final String version, final String url) {
    423         GuiHelper.runInEDTAndWait(new Runnable() {
    424             @Override
    425             public void run() {
    426                 ExtendedDialog ed = new ExtendedDialog(
    427                         Main.parent,
    428                         tr("Outdated Java version"),
    429                         new String[]{tr("OK"), tr("Update Java"), tr("Cancel")});
    430                 // Check if the dialog has not already been permanently hidden by user
    431                 if (!ed.toggleEnable("askUpdateJava9").toggleCheckState()) {
    432                     ed.setButtonIcons(new String[]{"ok", "java", "cancel"}).setCancelButton(3);
    433                     ed.setMinimumSize(new Dimension(480, 300));
    434                     ed.setIcon(JOptionPane.WARNING_MESSAGE);
    435                     StringBuilder content = new StringBuilder(tr("You are running version {0} of Java.", "<b>"+version+"</b>"))
    436                             .append("<br><br>");
    437                     if ("Sun Microsystems Inc.".equals(System.getProperty("java.vendor")) && !isOpenJDK()) {
    438                         content.append("<b>").append(tr("This version is no longer supported by {0} since {1} and is not recommended for use.",
    439                                 "Oracle", tr("April 2015"))).append("</b><br><br>"); // TODO: change date once Java 8 EOL is announced
    440                     }
    441                     content.append("<b>")
    442                            .append(tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", "8"))
    443                            .append("</b><br><br>")
    444                            .append(tr("Would you like to update now ?"));
    445                     ed.setContent(content.toString());
    446 
    447                     if (ed.showDialog().getValue() == 2) {
    448                         try {
    449                             openUrl(url);
    450                         } catch (IOException e) {
    451                             Main.warn(e);
    452                         }
     423        GuiHelper.runInEDTAndWait(() -> {
     424            ExtendedDialog ed = new ExtendedDialog(
     425                    Main.parent,
     426                    tr("Outdated Java version"),
     427                    new String[]{tr("OK"), tr("Update Java"), tr("Cancel")});
     428            // Check if the dialog has not already been permanently hidden by user
     429            if (!ed.toggleEnable("askUpdateJava9").toggleCheckState()) {
     430                ed.setButtonIcons(new String[]{"ok", "java", "cancel"}).setCancelButton(3);
     431                ed.setMinimumSize(new Dimension(480, 300));
     432                ed.setIcon(JOptionPane.WARNING_MESSAGE);
     433                StringBuilder content = new StringBuilder(tr("You are running version {0} of Java.", "<b>"+version+"</b>"))
     434                        .append("<br><br>");
     435                if ("Sun Microsystems Inc.".equals(System.getProperty("java.vendor")) && !isOpenJDK()) {
     436                    content.append("<b>").append(tr("This version is no longer supported by {0} since {1} and is not recommended for use.",
     437                            "Oracle", tr("April 2015"))).append("</b><br><br>"); // TODO: change date once Java 8 EOL is announced
     438                }
     439                content.append("<b>")
     440                       .append(tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", "8"))
     441                       .append("</b><br><br>")
     442                       .append(tr("Would you like to update now ?"));
     443                ed.setContent(content.toString());
     444
     445                if (ed.showDialog().getValue() == 2) {
     446                    try {
     447                        openUrl(url);
     448                    } catch (IOException e) {
     449                        Main.warn(e);
    453450                    }
    454451                }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r10604 r10616  
    13741374     */
    13751375    public static Executor newDirectExecutor() {
    1376         return new Executor() {
    1377             @Override
    1378             public void execute(Runnable command) {
    1379                 command.run();
    1380             }
    1381         };
     1376        return command -> command.run();
    13821377    }
    13831378
     
    16201615    public static void setObjectsAccessible(final AccessibleObject ... objects) {
    16211616        if (objects != null && objects.length > 0) {
    1622             AccessController.doPrivileged(new PrivilegedAction<Object>() {
    1623                 @Override
    1624                 public Object run() {
    1625                     for (AccessibleObject o : objects) {
    1626                         o.setAccessible(true);
    1627                     }
    1628                     return null;
     1617            AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
     1618                for (AccessibleObject o : objects) {
     1619                    o.setAccessible(true);
    16291620                }
     1621                return null;
    16301622            });
    16311623        }
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportSender.java

    r10404 r10616  
    132132    private void failed(String string) {
    133133        errorMessage = string;
    134         SwingUtilities.invokeLater(new Runnable() {
    135             @Override
    136             public void run() {
    137                 JPanel errorPanel = new JPanel(new GridBagLayout());
    138                 errorPanel.add(new JMultilineLabel(
    139                         tr("Opening the bug report failed. Please report manually using this website:")),
    140                         GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    141                 errorPanel.add(new UrlLabel(Main.getJOSMWebsite() + "/newticket", 2), GBC.eop().insets(8, 0, 0, 0));
    142                 errorPanel.add(new DebugTextDisplay(statusText));
     134        SwingUtilities.invokeLater(() -> {
     135            JPanel errorPanel = new JPanel(new GridBagLayout());
     136            errorPanel.add(new JMultilineLabel(
     137                    tr("Opening the bug report failed. Please report manually using this website:")),
     138                    GBC.eol().fill(GridBagConstraints.HORIZONTAL));
     139            errorPanel.add(new UrlLabel(Main.getJOSMWebsite() + "/newticket", 2), GBC.eop().insets(8, 0, 0, 0));
     140            errorPanel.add(new DebugTextDisplay(statusText));
    143141
    144                 JOptionPane.showMessageDialog(Main.parent, errorPanel, tr("You have encountered a bug in JOSM"),
    145                         JOptionPane.ERROR_MESSAGE);
    146             }
     142            JOptionPane.showMessageDialog(Main.parent, errorPanel, tr("You have encountered a bug in JOSM"),
     143                    JOptionPane.ERROR_MESSAGE);
    147144        });
    148145    }
Note: See TracChangeset for help on using the changeset viewer.