Changeset 10616 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2016-07-23T21:38:02+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r9876 r10616 34 34 import org.openstreetmap.josm.io.OsmTransferException; 35 35 import org.openstreetmap.josm.io.auth.CredentialsManager; 36 import org.openstreetmap.josm.tools.Utils.Function; 36 37 import org.openstreetmap.josm.tools.date.DateUtils; 37 38 … … 141 142 OsmPrimitive firstRefs = conflict.b.iterator().next(); 142 143 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()); 150 145 String refIdsString = refIds.size() == 1 ? refIds.iterator().next().toString() : refIds.toString(); 151 146 if (conflict.a instanceof Node) { -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r9983 r10616 16 16 import java.util.Arrays; 17 17 import java.util.Collection; 18 import java.util.Comparator;19 18 import java.util.HashMap; 20 19 import java.util.Locale; … … 382 381 Locale[] l = new Locale[v.size()]; 383 382 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())); 390 384 return l; 391 385 } … … 743 737 744 738 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); 751 740 } 752 741 -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r10600 r10616 33 33 import java.util.Arrays; 34 34 import java.util.Collection; 35 import java.util.Comparator;36 35 import java.util.HashMap; 37 36 import java.util.Hashtable; … … 76 75 import org.w3c.dom.NodeList; 77 76 import org.xml.sax.Attributes; 78 import org.xml.sax.EntityResolver;79 77 import org.xml.sax.InputSource; 80 78 import org.xml.sax.SAXException; … … 687 685 * Load the image in a background thread. 688 686 * 689 * This method returns immediately and runs the image request 690 * asynchronously. 687 * This method returns immediately and runs the image request asynchronously. 691 688 * 692 689 * @param callback a callback. It is called, when the image is ready. … … 697 694 public void getInBackground(final ImageCallback callback) { 698 695 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())); 707 697 } else { 708 ImageIcon result = get(); 709 callback.finished(result); 698 callback.finished(get()); 710 699 } 711 700 } … … 714 703 * Load the image in a background thread. 715 704 * 716 * This method returns immediately and runs the image request 717 * asynchronously. 705 * This method returns immediately and runs the image request asynchronously. 718 706 * 719 707 * @param callback a callback. It is called, when the image is ready. … … 725 713 public void getInBackground(final ImageResourceCallback callback) { 726 714 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())); 734 716 } else { 735 717 callback.finished(getResource()); … … 1280 1262 }); 1281 1263 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]))); 1288 1265 1289 1266 CachedFile cf = new CachedFile(base + fn).setDestDir( … … 1508 1485 // Check if the presets have icons for nodes/relations. 1509 1486 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); 1517 1491 }); 1518 1492 presets.addAll(TaggingPresets.getMatchingPresets(primitive)); -
trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java
r9634 r10616 7 7 import java.awt.KeyboardFocusManager; 8 8 import java.awt.event.ActionEvent; 9 import java.awt.event.ActionListener;10 9 import java.awt.event.KeyEvent; 11 10 import java.util.HashMap; … … 63 62 String.valueOf(info.getShortcut()), info.getDescription())); 64 63 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)); 71 65 layers.add(item); 72 66 } … … 79 73 "Repeat " + lastLayer.getDescription())); 80 74 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)); 87 76 layers.add(repeateItem); 88 77 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r10580 r10616 421 421 // Method unused, but kept for translation already done. To reuse during Java 9 migration 422 422 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); 453 450 } 454 451 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r10604 r10616 1374 1374 */ 1375 1375 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(); 1382 1377 } 1383 1378 … … 1620 1615 public static void setObjectsAccessible(final AccessibleObject ... objects) { 1621 1616 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); 1629 1620 } 1621 return null; 1630 1622 }); 1631 1623 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportSender.java
r10404 r10616 132 132 private void failed(String string) { 133 133 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)); 143 141 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); 147 144 }); 148 145 }
Note: See TracChangeset
for help on using the changeset viewer.