Changeset 19101 in josm
- Timestamp:
- 2024-06-11T23:53:20+02:00 (5 months ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java
r17358 r19101 71 71 Way way = this.ways.get(waypos); 72 72 73 if ( !this.reversed.get(waypos)) {73 if (Boolean.FALSE.equals(this.reversed.get(waypos))) { 74 74 for (int pos = 0; pos < way.getNodesCount() - 1; pos++) { 75 75 ringNodes.add(way.getNode(pos)); … … 212 212 //add cur way to the list 213 213 collectedWays.add(curWay); 214 collectedWaysReverse.add( Boolean.valueOf(curWayReverse));214 collectedWaysReverse.add(curWayReverse); 215 215 216 216 if (nextNode == startNode) { -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java
r16438 r19101 92 92 List<PrimitiveData> bufferCopy, List<PrimitiveData> toSelect) { 93 93 EnumMap<OsmPrimitiveType, Map<Long, Long>> newIds = new EnumMap<>(OsmPrimitiveType.class); 94 newIds.put(OsmPrimitiveType.NODE, new HashMap< Long, Long>());95 newIds.put(OsmPrimitiveType.WAY, new HashMap< Long, Long>());96 newIds.put(OsmPrimitiveType.RELATION, new HashMap< Long, Long>());94 newIds.put(OsmPrimitiveType.NODE, new HashMap<>()); 95 newIds.put(OsmPrimitiveType.WAY, new HashMap<>()); 96 newIds.put(OsmPrimitiveType.RELATION, new HashMap<>()); 97 97 98 98 for (PrimitiveData data : pasteBuffer.getAll()) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r19050 r19101 2 2 package org.openstreetmap.josm.gui.dialogs; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.I18n.trn; … … 94 95 */ 95 96 public class SelectionListDialog extends ToggleDialog { 97 private static final String SELECTION_CASING = marktr("Selection"); 98 private static final String SELECTION = "selection"; 96 99 private JList<OsmPrimitive> lstPrimitives; 97 100 private final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); … … 147 150 */ 148 151 public SelectionListDialog() { 149 super(tr( "Selection"), "selectionlist", tr("Open a selection list window."),152 super(tr(SELECTION_CASING), "selectionlist", tr("Open a selection list window."), 150 153 Shortcut.registerShortcut("subwindow:selection", tr("Windows: {0}", 151 tr( "Selection")), KeyEvent.VK_T, Shortcut.ALT_SHIFT),154 tr(SELECTION_CASING)), KeyEvent.VK_T, Shortcut.ALT_SHIFT), 152 155 150, // default height 153 156 true // default is "show dialog" … … 395 398 putValue(NAME, tr("Zoom to selection")); 396 399 putValue(SHORT_DESCRIPTION, tr("Zoom to selection")); 397 new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);400 new ImageProvider("dialogs/autoscale", SELECTION).getResource().attachImageIcon(this, true); 398 401 updateEnabledState(); 399 402 } … … 434 437 */ 435 438 ZoomToListSelection() { 436 new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);439 new ImageProvider("dialogs/autoscale", SELECTION).getResource().attachImageIcon(this, true); 437 440 updateEnabledState(); 438 441 } … … 464 467 /** 465 468 * The list model for the list of OSM primitives in the current JOSM selection. 466 * 469 * <p> 467 470 * The model also maintains a history of the last {@link SelectionListModel#SELECTION_HISTORY_SIZE} 468 471 * JOSM selection. … … 493 496 */ 494 497 public synchronized String getJOSMSelectionSummary() { 495 if (selection.isEmpty()) return tr( "Selection");498 if (selection.isEmpty()) return tr(SELECTION_CASING); 496 499 int numNodes = 0; 497 500 int numWays = 0; … … 650 653 : OsmPrimitiveComparator.comparingNames())); 651 654 } catch (IllegalArgumentException e) { 652 throw BugReport.intercept(e).put("size", size).put("quick", quick).put( "selection", selection);655 throw BugReport.intercept(e).put("size", size).put("quick", quick).put(SELECTION, selection); 653 656 } 654 657 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/BooleanStyleSettingGui.java
r15293 r19101 3 3 4 4 import java.awt.event.ActionEvent; 5 import java.util. Arrays;5 import java.util.Collections; 6 6 import java.util.Objects; 7 7 … … 40 40 setting.setValue(isSelected()); 41 41 if (!noRepaint) { 42 MainApplication.worker.submit(new MapPaintStyleLoader( Arrays.asList(setting.parentStyle)));42 MainApplication.worker.submit(new MapPaintStyleLoader(Collections.singletonList(setting.parentStyle))); 43 43 } 44 44 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSettingGroupGui.java
r17270 r19101 6 6 import java.awt.event.ActionEvent; 7 7 import java.util.Arrays; 8 import java.util.Collections; 8 9 import java.util.List; 9 10 import java.util.Objects; … … 52 53 public void actionPerformed(ActionEvent e) { 53 54 List<BooleanStyleSettingCheckBoxMenuItem> items = Arrays.stream(submenu.getMenuComponents()) 54 .filter( c -> c instanceof BooleanStyleSettingCheckBoxMenuItem)55 .filter(BooleanStyleSettingCheckBoxMenuItem.class::isInstance) 55 56 .map(c -> (BooleanStyleSettingCheckBoxMenuItem) c) 56 57 .collect(Collectors.toList()); 57 58 final boolean select = items.stream().anyMatch(cbi -> !cbi.isSelected()); 58 59 items.stream().filter(cbi -> select != cbi.isSelected()).forEach(cbi -> cbi.doClickWithoutRepaint(0)); 59 MainApplication.worker.submit(new MapPaintStyleLoader( Arrays.asList(group.parentStyle)));60 MainApplication.worker.submit(new MapPaintStyleLoader(Collections.singletonList(group.parentStyle))); 60 61 } 61 62 }); -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java
r19080 r19101 169 169 /* Is joining an array really that complicated in Java? */ 170 170 private static String[] getDefaultNameTags() { 171 final vartags = new ArrayList<>(Arrays.asList(LanguageInfo.getOSMLocaleCodes("name:")));171 final ArrayList<String> tags = new ArrayList<>(Arrays.asList(LanguageInfo.getOSMLocaleCodes("name:"))); 172 172 tags.addAll(Arrays.asList("name", 173 173 "int_name", -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r19080 r19101 59 59 import javax.swing.KeyStroke; 60 60 import javax.swing.ListSelectionModel; 61 import javax.swing.SwingConstants; 61 62 import javax.swing.UIManager; 62 63 import javax.swing.event.CellEditorListener; … … 112 113 */ 113 114 public abstract class SourceEditor extends JPanel { 115 private static final String DELETE = "delete"; 116 private static final String DIALOGS = "dialogs"; 114 117 115 118 /** the type of source entry **/ … … 219 222 RemoveActiveSourcesAction removeActiveSourcesAction = new RemoveActiveSourcesAction(); 220 223 tblActiveSources.getSelectionModel().addListSelectionListener(removeActiveSourcesAction); 221 tblActiveSources.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");222 tblActiveSources.getActionMap().put( "delete", removeActiveSourcesAction);224 tblActiveSources.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), DELETE); 225 tblActiveSources.getActionMap().put(DELETE, removeActiveSourcesAction); 223 226 224 227 MoveUpDownAction moveUp = null; … … 297 300 gbc.insets = new Insets(0, 0, 0, 6); 298 301 299 JToolBar sideButtonTB = new JToolBar( JToolBar.VERTICAL);302 JToolBar sideButtonTB = new JToolBar(SwingConstants.VERTICAL); 300 303 sideButtonTB.setFloatable(false); 301 304 sideButtonTB.setBorderPainted(false); … … 363 366 RemoveIconPathAction removeIconPathAction = new RemoveIconPathAction(); 364 367 tblIconPaths.getSelectionModel().addListSelectionListener(removeIconPathAction); 365 tblIconPaths.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete");366 tblIconPaths.getActionMap().put( "delete", removeIconPathAction);368 tblIconPaths.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), DELETE); 369 tblIconPaths.getActionMap().put(DELETE, removeIconPathAction); 367 370 368 371 gbc.gridx = 0; … … 721 724 data = IntStream.range(0, data.size()) 722 725 .filter(i -> !idxs.contains(i)) 723 .mapToObj( i -> data.get(i))726 .mapToObj(data::get) 724 727 .collect(Collectors.toList()); 725 728 fireTableDataChanged(); … … 909 912 putValue(NAME, tr("New")); 910 913 putValue(SHORT_DESCRIPTION, getStr(I18nString.NEW_SOURCE_ENTRY_TOOLTIP)); 911 new ImageProvider( "dialogs", "add").getResource().attachImageIcon(this);914 new ImageProvider(DIALOGS, "add").getResource().attachImageIcon(this); 912 915 } 913 916 … … 939 942 putValue(NAME, tr("Remove")); 940 943 putValue(SHORT_DESCRIPTION, getStr(I18nString.REMOVE_SOURCE_TOOLTIP)); 941 new ImageProvider( "dialogs", "delete").getResource().attachImageIcon(this);944 new ImageProvider(DIALOGS, DELETE).getResource().attachImageIcon(this); 942 945 updateEnabledState(); 943 946 } … … 962 965 putValue(NAME, tr("Edit")); 963 966 putValue(SHORT_DESCRIPTION, getStr(I18nString.EDIT_SOURCE_TOOLTIP)); 964 new ImageProvider( "dialogs", "edit").getResource().attachImageIcon(this);967 new ImageProvider(DIALOGS, "edit").getResource().attachImageIcon(this); 965 968 updateEnabledState(); 966 969 } … … 1008 1011 MoveUpDownAction(boolean isDown) { 1009 1012 increment = isDown ? 1 : -1; 1010 new ImageProvider( "dialogs", isDown ? "down" : "up").getResource().attachImageIcon(this, true);1013 new ImageProvider(DIALOGS, isDown ? "down" : "up").getResource().attachImageIcon(this, true); 1011 1014 putValue(SHORT_DESCRIPTION, isDown ? tr("Move the selected entry one row down.") : tr("Move the selected entry one row up.")); 1012 1015 updateEnabledState(); … … 1110 1113 putValue(NAME, tr("Reload")); 1111 1114 putValue(SHORT_DESCRIPTION, tr(getStr(I18nString.RELOAD_ALL_AVAILABLE), url)); 1112 new ImageProvider( "dialogs", "refresh").getResource().attachImageIcon(this);1115 new ImageProvider(DIALOGS, "refresh").getResource().attachImageIcon(this); 1113 1116 this.url = url; 1114 1117 this.sourceProviders = sourceProviders; … … 1252 1255 putValue(NAME, tr("New")); 1253 1256 putValue(SHORT_DESCRIPTION, tr("Add a new icon path")); 1254 new ImageProvider( "dialogs", "add").getResource().attachImageIcon(this);1257 new ImageProvider(DIALOGS, "add").getResource().attachImageIcon(this); 1255 1258 } 1256 1259 … … 1266 1269 putValue(NAME, tr("Remove")); 1267 1270 putValue(SHORT_DESCRIPTION, tr("Remove the selected icon paths")); 1268 new ImageProvider( "dialogs", "delete").getResource().attachImageIcon(this);1271 new ImageProvider(DIALOGS, DELETE).getResource().attachImageIcon(this); 1269 1272 updateEnabledState(); 1270 1273 } … … 1289 1292 putValue(NAME, tr("Edit")); 1290 1293 putValue(SHORT_DESCRIPTION, tr("Edit the selected icon path")); 1291 new ImageProvider( "dialogs", "edit").getResource().attachImageIcon(this);1294 new ImageProvider(DIALOGS, "edit").getResource().attachImageIcon(this); 1292 1295 updateEnabledState(); 1293 1296 } … … 1608 1611 public void setInitialValue(String initialValue) { 1609 1612 this.value = initialValue; 1610 if (initialValue == null) { 1611 this.tfFileName.setText(""); 1612 } else { 1613 this.tfFileName.setText(initialValue); 1614 } 1613 this.tfFileName.setText(Objects.requireNonNullElse(initialValue, "")); 1615 1614 } 1616 1615 -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r19050 r19101 98 98 99 99 private static final String EMPTY_TOOLBAR_MARKER = "<!-empty-!>"; 100 private static final String TOOLBAR = "toolbar"; 101 private static final String DIALOGS = "dialogs"; 100 102 101 103 /** … … 363 365 result.setLength(0); 364 366 365 String val = (String) action.getAction().getValue( "toolbar");367 String val = (String) action.getAction().getValue(TOOLBAR); 366 368 if (val == null) 367 369 return null; … … 395 397 tmp = action.getIcon(); 396 398 if (!tmp.isEmpty()) { 397 result.append(first ? "{" : ",") ;398 result.append("icon=");399 result.append(first ? "{" : ",") 400 .append("icon="); 399 401 escape(tmp); 400 402 first = false; … … 513 515 // remove the button from toolbar preferences 514 516 t.remove(res); 515 Config.getPref().putList( "toolbar", t);517 Config.getPref().putList(TOOLBAR, t); 516 518 MainApplication.getToolbar().refreshToolbarControl(); 517 519 } … … 522 524 public void actionPerformed(ActionEvent e) { 523 525 final PreferenceDialog p = new PreferenceDialog(MainApplication.getMainFrame()); 524 SwingUtilities.invokeLater(() -> p.selectPreferencesTabByName( "toolbar"));526 SwingUtilities.invokeLater(() -> p.selectPreferencesTabByName(TOOLBAR)); 525 527 p.setVisible(true); 526 528 } … … 796 798 */ 797 799 public Settings(DefaultMutableTreeNode rootActionsNode) { 798 super(/* ICON(preferences/) */ "toolbar", tr("Toolbar"), tr("Customize the elements on the toolbar."));800 super(/* ICON(preferences/) */ TOOLBAR, tr("Toolbar"), tr("Customize the elements on the toolbar.")); 799 801 actionsTreeModel = new DefaultTreeModel(rootActionsNode); 800 802 actionsTree = new JTree(actionsTreeModel); … … 805 807 switch (name) { 806 808 case "up": 807 b.setIcon(ImageProvider.get( "dialogs", "up", ImageSizes.LARGEICON));809 b.setIcon(ImageProvider.get(DIALOGS, "up", ImageSizes.LARGEICON)); 808 810 b.setToolTipText(tr("Move the currently selected members up")); 809 811 break; 810 812 case "down": 811 b.setIcon(ImageProvider.get( "dialogs", "down", ImageSizes.LARGEICON));813 b.setIcon(ImageProvider.get(DIALOGS, "down", ImageSizes.LARGEICON)); 812 814 b.setToolTipText(tr("Move the currently selected members down")); 813 815 break; … … 817 819 break; 818 820 case ">": 819 b.setIcon(ImageProvider.get( "dialogs", "delete", ImageSizes.LARGEICON));821 b.setIcon(ImageProvider.get(DIALOGS, "delete", ImageSizes.LARGEICON)); 820 822 b.setToolTipText(tr("Remove")); 821 823 break; … … 1014 1016 t = Collections.singletonList(EMPTY_TOOLBAR_MARKER); 1015 1017 } 1016 Config.getPref().putList( "toolbar", t);1018 Config.getPref().putList(TOOLBAR, t); 1017 1019 MainApplication.getToolbar().refreshToolbarControl(); 1018 1020 return false; … … 1050 1052 Action action = menuItem.getAction(); 1051 1053 userObject = action; 1052 Object tb = action.getValue( "toolbar");1054 Object tb = action.getValue(TOOLBAR); 1053 1055 if (tb == null) { 1054 1056 Logging.info(tr("Toolbar action without name: {0}", … … 1101 1103 1102 1104 public static Collection<String> getToolString() { 1103 Collection<String> toolStr = Config.getPref().getList( "toolbar", Arrays.asList(deftoolbar));1105 Collection<String> toolStr = Config.getPref().getList(TOOLBAR, Arrays.asList(deftoolbar)); 1104 1106 if (Utils.isEmpty(toolStr)) { 1105 1107 toolStr = Arrays.asList(deftoolbar); … … 1141 1143 */ 1142 1144 public Action register(Action action) { 1143 String toolbar = (String) action.getValue( "toolbar");1145 String toolbar = (String) action.getValue(TOOLBAR); 1144 1146 if (toolbar == null) { 1145 1147 Logging.info(tr("Registered toolbar action without name: {0}", … … 1165 1167 */ 1166 1168 public Action unregister(Action action) { 1167 Object toolbar = action.getValue( "toolbar");1169 Object toolbar = action.getValue(TOOLBAR); 1168 1170 if (toolbar instanceof String) { 1169 1171 return regactions.remove(toolbar); … … 1243 1245 } 1244 1246 } 1245 Config.getPref().putList( "toolbar", t);1247 Config.getPref().putList(TOOLBAR, t); 1246 1248 MainApplication.getToolbar().refreshToolbarControl(); 1247 1249 } … … 1273 1275 1274 1276 if (sc == null || paramCode != 0) { 1275 String name = Optional.ofNullable((String) action.getAction().getValue( "toolbar")).orElseGet(action::getDisplayName);1277 String name = Optional.ofNullable((String) action.getAction().getValue(TOOLBAR)).orElseGet(action::getDisplayName); 1276 1278 if (paramCode != 0) { 1277 1279 name = name+paramCode; -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java
r18801 r19101 11 11 import java.awt.GridLayout; 12 12 import java.awt.Toolkit; 13 import java.awt.event.InputEvent; 13 14 import java.awt.event.KeyEvent; 14 15 import java.awt.im.InputContext; … … 56 57 // independent from the keyboard's labelling. But the operation system's locale 57 58 // usually matches the keyboard. This even works with my English Windows and my German keyboard. 58 private static final String SHIFT = KeyEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A,59 KeyEvent.SHIFT_DOWN_MASK).getModifiers());60 private static final String CTRL = KeyEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A,61 KeyEvent.CTRL_DOWN_MASK).getModifiers());62 private static final String ALT = KeyEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A,63 KeyEvent.ALT_DOWN_MASK).getModifiers());64 private static final String META = KeyEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A,65 KeyEvent.META_DOWN_MASK).getModifiers());59 private static final String SHIFT = InputEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A, 60 InputEvent.SHIFT_DOWN_MASK).getModifiers()); 61 private static final String CTRL = InputEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A, 62 InputEvent.CTRL_DOWN_MASK).getModifiers()); 63 private static final String ALT = InputEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A, 64 InputEvent.ALT_DOWN_MASK).getModifiers()); 65 private static final String META = InputEvent.getModifiersExText(KeyStroke.getKeyStroke(KeyEvent.VK_A, 66 InputEvent.META_DOWN_MASK).getModifiers()); 66 67 67 68 // A list of keys to present the user. Sadly this really is a list of keys Java knows about, … … 97 98 int i = field.getInt(null); 98 99 String s = KeyEvent.getKeyText(i); 99 if ( s != null &&!s.isEmpty() && !s.contains(unknown)) {100 list.put( Integer.valueOf(i), s);100 if (!s.isEmpty() && !s.contains(unknown)) { 101 list.put(i, s); 101 102 } 102 103 } catch (IllegalArgumentException | IllegalAccessException e) { … … 107 108 KeyboardUtils.getExtendedKeyCodes(InputContext.getInstance().getLocale()) 108 109 .forEach((key, value) -> list.put(key, value.toString())); 109 list.put( Integer.valueOf(-1), "");110 list.put(-1, ""); 110 111 111 112 // Remove "look-alike" values. See JOSM #22020 comment 2. These override the standard left/right/up/down keys. … … 292 293 panel.cbDefault.setSelected(!sc.isAssignedUser()); 293 294 panel.cbDisable.setSelected(sc.getKeyStroke() == null); 294 panel.cbShift.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.SHIFT_DOWN_MASK) != 0);295 panel.cbCtrl.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.CTRL_DOWN_MASK) != 0);296 panel.cbAlt.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.ALT_DOWN_MASK) != 0);297 panel.cbMeta.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.META_DOWN_MASK) != 0);295 panel.cbShift.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & InputEvent.SHIFT_DOWN_MASK) != 0); 296 panel.cbCtrl.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & InputEvent.CTRL_DOWN_MASK) != 0); 297 panel.cbAlt.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & InputEvent.ALT_DOWN_MASK) != 0); 298 panel.cbMeta.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & InputEvent.META_DOWN_MASK) != 0); 298 299 if (sc.getKeyStroke() != null) { 299 300 panel.tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode())); … … 329 330 } else { 330 331 sc.setAssignedModifier( 331 (panel.cbShift.isSelected() ? KeyEvent.SHIFT_DOWN_MASK : 0) |332 (panel.cbCtrl.isSelected() ? KeyEvent.CTRL_DOWN_MASK : 0) |333 (panel.cbAlt.isSelected() ? KeyEvent.ALT_DOWN_MASK : 0) |334 (panel.cbMeta.isSelected() ? KeyEvent.META_DOWN_MASK : 0)332 (panel.cbShift.isSelected() ? InputEvent.SHIFT_DOWN_MASK : 0) | 333 (panel.cbCtrl.isSelected() ? InputEvent.CTRL_DOWN_MASK : 0) | 334 (panel.cbAlt.isSelected() ? InputEvent.ALT_DOWN_MASK : 0) | 335 (panel.cbMeta.isSelected() ? InputEvent.META_DOWN_MASK : 0) 335 336 ); 336 337 for (Map.Entry<Integer, String> entry : keyList.entrySet()) { -
trunk/src/org/openstreetmap/josm/io/OnlineResource.java
r18014 r19101 36 36 * @return the localized name 37 37 */ 38 public finalString getLocName() {38 public String getLocName() { 39 39 return locName; 40 40 } … … 45 45 * @since 17041 46 46 */ 47 public finalString getOfflineIcon() {47 public String getOfflineIcon() { 48 48 switch (this) { 49 49 case OSM_API: … … 67 67 * @return whether the given URL matches this online resource 68 68 */ 69 public finalboolean matches(String url) {69 public boolean matches(String url) { 70 70 final String baseUrl; 71 71 switch (this) { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r19050 r19101 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.I18n.trn; … … 64 65 */ 65 66 public class OsmApi extends OsmConnection { 67 private static final String CHANGESET_STR = "changeset"; 68 private static final String CHANGESET_SLASH = "changeset/"; 69 private static final String ERROR_MESSAGE = marktr("Changeset ID > 0 expected. Got {0}."); 66 70 67 71 /** … … 465 469 */ 466 470 public void openChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException { 467 CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");471 CheckParameterUtil.ensureParameterNotNull(changeset, CHANGESET_STR); 468 472 try { 469 473 progressMonitor.beginTask(tr("Creating changeset...")); … … 496 500 */ 497 501 public void updateChangeset(Changeset changeset, ProgressMonitor monitor) throws OsmTransferException { 498 CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");502 CheckParameterUtil.ensureParameterNotNull(changeset, CHANGESET_STR); 499 503 if (monitor == null) { 500 504 monitor = NullProgressMonitor.INSTANCE; 501 505 } 502 506 if (changeset.getId() <= 0) 503 throw new IllegalArgumentException(tr( "Changeset ID > 0 expected. Got {0}.", changeset.getId()));507 throw new IllegalArgumentException(tr(ERROR_MESSAGE, changeset.getId())); 504 508 try { 505 509 monitor.beginTask(tr("Updating changeset...")); 506 510 initialize(monitor); 507 511 monitor.setCustomText(tr("Updating changeset {0}...", changeset.getId())); 508 sendPutRequest( "changeset/"+ changeset.getId(), toXml(changeset), monitor);512 sendPutRequest(CHANGESET_SLASH + changeset.getId(), toXml(changeset), monitor); 509 513 } catch (ChangesetClosedException e) { 510 514 e.setSource(ChangesetClosedException.Source.UPDATE_CHANGESET); … … 531 535 */ 532 536 public void closeChangeset(Changeset changeset, ProgressMonitor monitor) throws OsmTransferException { 533 CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");537 CheckParameterUtil.ensureParameterNotNull(changeset, CHANGESET_STR); 534 538 if (monitor == null) { 535 539 monitor = NullProgressMonitor.INSTANCE; 536 540 } 537 541 if (changeset.getId() <= 0) 538 throw new IllegalArgumentException(tr( "Changeset ID > 0 expected. Got {0}.", changeset.getId()));542 throw new IllegalArgumentException(tr(ERROR_MESSAGE, changeset.getId())); 539 543 try { 540 544 monitor.beginTask(tr("Closing changeset...")); 541 545 initialize(monitor); 542 546 // send "\r\n" instead of empty string, so we don't send zero payload - workaround bugs in proxy software 543 sendPutRequest( "changeset/"+ changeset.getId() + "/close", "\r\n", monitor);547 sendPutRequest(CHANGESET_SLASH + changeset.getId() + "/close", "\r\n", monitor); 544 548 } catch (ChangesetClosedException e) { 545 549 e.setSource(ChangesetClosedException.Source.CLOSE_CHANGESET); … … 565 569 throw new IllegalArgumentException(tr("Changeset must be closed in order to add a comment")); 566 570 else if (changeset.getId() <= 0) 567 throw new IllegalArgumentException(tr( "Changeset ID > 0 expected. Got {0}.", changeset.getId()));568 sendRequest("POST", "changeset/"+ changeset.getId() + "/comment?text="+ Utils.encodeUrl(comment),571 throw new IllegalArgumentException(tr(ERROR_MESSAGE, changeset.getId())); 572 sendRequest("POST", CHANGESET_SLASH + changeset.getId() + "/comment?text="+ Utils.encodeUrl(comment), 569 573 null, monitor, "application/x-www-form-urlencoded", true, false); 570 574 } … … 599 603 monitor.indeterminateSubTask( 600 604 trn("Uploading {0} object...", "Uploading {0} objects...", list.size(), list.size())); 601 String diffUploadResponse = sendPostRequest( "changeset/"+ changeset.getId() + "/upload", diffUploadRequest, monitor);605 String diffUploadResponse = sendPostRequest(CHANGESET_SLASH + changeset.getId() + "/upload", diffUploadRequest, monitor); 602 606 603 607 // Process the response from the server … … 893 897 } 894 898 if (changeset.getId() <= 0) 895 throw new IllegalArgumentException(tr( "Changeset ID > 0 expected. Got {0}.", changeset.getId()));899 throw new IllegalArgumentException(tr(ERROR_MESSAGE, changeset.getId())); 896 900 if (!changeset.isOpen()) 897 901 throw new IllegalArgumentException(tr("Open changeset expected. Got closed changeset with id {0}.", changeset.getId())); … … 954 958 .append("/close"); 955 959 if (!encodedMessage.trim().isEmpty()) { 956 urlBuilder.append("?text=") ;957 urlBuilder.append(encodedMessage);960 urlBuilder.append("?text=") 961 .append(encodedMessage); 958 962 } 959 963 … … 975 979 .append("/reopen"); 976 980 if (!encodedMessage.trim().isEmpty()) { 977 urlBuilder.append("?text=") ;978 urlBuilder.append(encodedMessage);981 urlBuilder.append("?text=") 982 .append(encodedMessage); 979 983 } 980 984 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r16960 r19101 9 9 import java.awt.GridBagLayout; 10 10 import java.awt.event.ActionEvent; 11 import java.awt.event.InputEvent; 11 12 import java.awt.event.KeyEvent; 12 13 import java.awt.event.MouseEvent; … … 98 99 int addValue(String val) { 99 100 Integer c = valueCount.get(val); 100 int r = c == null ? 1 : (c .intValue()+1);101 int r = c == null ? 1 : (c + 1); 101 102 valueCount.put(val, r); 102 103 return r; … … 138 139 count[i] = 0; 139 140 String key = tags[i][0]; 140 String value = tags[i][1], oldValue; 141 Boolean b = Boolean.TRUE; 141 String value = tags[i][1]; 142 String oldValue; 143 boolean b = Boolean.TRUE; 142 144 ExistingValues old = new ExistingValues(key); 143 145 for (OsmPrimitive osm : sel) { … … 204 206 // get edit results if the table looses the focus, for example if a user clicks "add tags" 205 207 propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 206 propertyTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK), "shiftenter");208 propertyTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK), "shiftenter"); 207 209 propertyTable.getActionMap().put("shiftenter", new AbstractAction() { 208 210 @Override public void actionPerformed(ActionEvent e) { … … 242 244 TableModel tm = propertyTable.getModel(); 243 245 for (int i = 0; i < tm.getRowCount(); i++) { 244 if (buttonIndex == 1 || (Boolean) tm.getValueAt(i, 0)) {246 if (buttonIndex == 1 || Boolean.TRUE.equals(tm.getValueAt(i, 0))) { 245 247 String key = (String) tm.getValueAt(i, 1); 246 248 Object value = tm.getValueAt(i, 2); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r19050 r19101 90 90 */ 91 91 public final class PluginHandler { 92 private static final String DIALOGS = "dialogs"; 93 private static final String WARNING = marktr("Warning"); 94 private static final String HTML_START = "<html>"; 95 private static final String HTML_END = "</html>"; 96 private static final String UPDATE_PLUGINS = marktr("Update plugins"); 97 private static final String CANCEL = "cancel"; 98 private static final String PLUGINS = "plugins"; 99 private static final String DISABLE_PLUGIN = marktr("Disable plugin"); 100 private static final String PLUGINMANAGER_VERSION_BASED_UPDATE_POLICY = "pluginmanager.version-based-update.policy"; 101 private static final String PLUGINMANAGER_LASTUPDATE = "pluginmanager.lastupdate"; 102 private static final String PLUGINMANAGER_TIME_BASED_UPDATE_POLICY = "pluginmanager.time-based-update.policy"; 92 103 93 104 /** … … 197 208 sorted.putAll(info.attr); 198 209 for (Entry<Object, Object> e : sorted.entrySet()) { 199 b.append(e.getKey()) ;200 b.append(": ");201 b.append(e.getValue());202 b.append('\n');210 b.append(e.getKey()) 211 .append(": ") 212 .append(e.getValue()) 213 .append('\n'); 203 214 } 204 215 return b.toString(); … … 275 286 * List of unmaintained plugins. Not really up-to-date as the vast majority of plugins are not maintained after a few months, sadly... 276 287 */ 277 static final List<String> UNMAINTAINED_PLUGINS = Collections.unmodifiableList(Arrays.asList(288 static final List<String> UNMAINTAINED_PLUGINS = List.of( 278 289 "irsrectify", // See https://josm.openstreetmap.de/changeset/29404/osm/ 279 290 "surveyor2", // See https://josm.openstreetmap.de/changeset/29404/osm/ … … 283 294 "LaneConnector", // See #11468, #11518, https://github.com/TrifanAdrian/LanecConnectorPlugin/issues/1 284 295 "Remove.redundant.points" // See #11468, #11518, https://github.com/bularcasergiu/RemoveRedundantPoints (not even created an issue...) 285 ) );296 ); 286 297 287 298 /** … … 385 396 if (plugins.contains(depr.name)) { 386 397 plugins.remove(depr.name); 387 PreferencesUtils.removeFromList(Config.getPref(), "plugins", depr.name);398 PreferencesUtils.removeFromList(Config.getPref(), PLUGINS, depr.name); 388 399 removedPlugins.add(depr); 389 400 } … … 397 408 parent, 398 409 getRemovedPluginsMessage(removedPlugins), 399 tr( "Warning"),410 tr(WARNING), 400 411 JOptionPane.WARNING_MESSAGE 401 412 ); … … 404 415 static String getRemovedPluginsMessage(Collection<DeprecatedPlugin> removedPlugins) { 405 416 StringBuilder sb = new StringBuilder(32); 406 sb.append( "<html>")417 sb.append(HTML_START) 407 418 .append(trn( 408 419 "The following plugin is no longer necessary and has been deactivated:", … … 417 428 sb.append("</li>"); 418 429 } 419 sb.append("</ul> </html>");430 sb.append("</ul>").append(HTML_END); 420 431 return sb.toString(); 421 432 } … … 437 448 } 438 449 if (confirmDisablePlugin(parent, getUnmaintainedPluginMessage(unmaintained), unmaintained)) { 439 PreferencesUtils.removeFromList(Config.getPref(), "plugins", unmaintained);450 PreferencesUtils.removeFromList(Config.getPref(), PLUGINS, unmaintained); 440 451 plugins.remove(unmaintained); 441 452 } … … 470 481 if (Config.getPref().getInt("pluginmanager.version", 0) < v) { 471 482 message = 472 "<html>"483 HTML_START 473 484 + tr("You updated your JOSM software.<br>" 474 485 + "To prevent problems the plugins should be updated as well.<br><br>" 475 486 + "Update plugins now?" 476 487 ) 477 + "</html>";478 togglePreferenceKey = "pluginmanager.version-based-update.policy";488 + HTML_END; 489 togglePreferenceKey = PLUGINMANAGER_VERSION_BASED_UPDATE_POLICY; 479 490 } else { 480 491 long tim = System.currentTimeMillis(); 481 long last = Config.getPref().getLong( "pluginmanager.lastupdate", 0);492 long last = Config.getPref().getLong(PLUGINMANAGER_LASTUPDATE, 0); 482 493 int maxTime = Config.getPref().getInt("pluginmanager.time-based-update.interval", DEFAULT_TIME_BASED_UPDATE_INTERVAL); 483 494 long d = TimeUnit.MILLISECONDS.toDays(tim - last); 484 495 if ((last <= 0) || (maxTime <= 0)) { 485 Config.getPref().put( "pluginmanager.lastupdate", Long.toString(tim));496 Config.getPref().put(PLUGINMANAGER_LASTUPDATE, Long.toString(tim)); 486 497 } else if (d > maxTime) { 487 498 message = 488 "<html>"499 HTML_START 489 500 + tr("Last plugin update more than {0} days ago.", d) 490 + "</html>";491 togglePreferenceKey = "pluginmanager.time-based-update.policy";501 + HTML_END; 502 togglePreferenceKey = PLUGINMANAGER_TIME_BASED_UPDATE_POLICY; 492 503 } 493 504 } … … 503 514 switch (policy) { 504 515 case "never": 505 if ( "pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) {516 if (PLUGINMANAGER_VERSION_BASED_UPDATE_POLICY.equals(togglePreferenceKey)) { 506 517 Logging.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled.")); 507 } else if ( "pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) {518 } else if (PLUGINMANAGER_TIME_BASED_UPDATE_POLICY.equals(togglePreferenceKey)) { 508 519 Logging.info(tr("Skipping plugin update after elapsed update interval. Automatic update at startup is disabled.")); 509 520 } … … 511 522 512 523 case "always": 513 if ( "pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) {524 if (PLUGINMANAGER_VERSION_BASED_UPDATE_POLICY.equals(togglePreferenceKey)) { 514 525 Logging.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled.")); 515 } else if ( "pluginmanager.time-based-update.policy".equals(togglePreferenceKey)) {526 } else if (PLUGINMANAGER_TIME_BASED_UPDATE_POLICY.equals(togglePreferenceKey)) { 516 527 Logging.info(tr("Running plugin update after elapsed update interval. Automatic update at startup is disabled.")); 517 528 } … … 527 538 ButtonSpec[] options = { 528 539 new ButtonSpec( 529 tr( "Update plugins"),530 new ImageProvider( "dialogs", "refresh"),540 tr(UPDATE_PLUGINS), 541 new ImageProvider(DIALOGS, "refresh"), 531 542 tr("Click to update the activated plugins"), 532 543 null /* no specific help context */ … … 534 545 new ButtonSpec( 535 546 tr("Skip update"), 536 new ImageProvider( "cancel"),547 new ImageProvider(CANCEL), 537 548 tr("Click to skip updating the activated plugins"), 538 549 null /* no specific help context */ … … 543 554 parent, 544 555 pnlMessage, 545 tr( "Update plugins"),556 tr(UPDATE_PLUGINS), 546 557 JOptionPane.WARNING_MESSAGE, 547 558 null, … … 577 588 private static void alertMissingRequiredPlugin(Component parent, String plugin, Set<String> missingRequiredPlugin) { 578 589 StringBuilder sb = new StringBuilder(48); 579 sb.append( "<html>")590 sb.append(HTML_START) 580 591 .append(trn("Plugin {0} requires a plugin which was not found. The missing plugin is:", 581 592 "Plugin {0} requires {1} plugins which were not found. The missing plugins are:", … … 584 595 missingRequiredPlugin.size())) 585 596 .append(Utils.joinAsHtmlUnorderedList(missingRequiredPlugin)) 586 .append( "</html>");597 .append(HTML_END); 587 598 ButtonSpec[] specs = { 588 599 new ButtonSpec( … … 636 647 if (!task.getDownloadedPlugins().isEmpty()) { 637 648 // update plugin list in preferences 638 Set<String> plugins = new HashSet<>(Config.getPref().getList( "plugins"));649 Set<String> plugins = new HashSet<>(Config.getPref().getList(PLUGINS)); 639 650 for (PluginInformation plugin : task.getDownloadedPlugins()) { 640 651 plugins.add(plugin.name); 641 652 } 642 Config.getPref().putList( "plugins", new ArrayList<>(plugins));653 Config.getPref().putList(PLUGINS, new ArrayList<>(plugins)); 643 654 // restart 644 655 RestartAction.restartJOSM(); … … 667 678 final int selected = HelpAwareOptionPane.showOptionDialog( 668 679 parent, 669 "<html>"+ tr("Plugin {0} requires Java version {1}. The current Java version is {2}.<br>"680 HTML_START + tr("Plugin {0} requires Java version {1}. The current Java version is {2}.<br>" 670 681 + "You have to update Java in order to use this plugin.", 671 682 plugin, Integer.toString(requiredVersion), Utils.getJavaVersion() 672 ) + "</html>",673 tr( "Warning"),683 ) + HTML_END, 684 tr(WARNING), 674 685 JOptionPane.WARNING_MESSAGE, 675 686 null, … … 678 689 null 679 690 ); 680 if (selected == 1) { 681 if (Utils.isRunningJavaWebStart()) { 682 OpenBrowser.displayUrl(Config.getPref().get("openwebstart.download.url", "https://openwebstart.com/download/")); 683 } else if (!Utils.isRunningWebStart()) { 684 final String javaUrl = PlatformManager.getPlatform().getJavaUrl(); 685 OpenBrowser.displayUrl(javaUrl); 686 } 691 if (selected == 1 && !Utils.isRunningWebStart()) { 692 final String javaUrl = PlatformManager.getPlatform().getJavaUrl(); 693 OpenBrowser.displayUrl(javaUrl); 687 694 } 688 695 } … … 695 702 plugin, Integer.toString(requiredVersion), Version.getInstance().getVersionString() 696 703 ), 697 tr( "Warning"),704 tr(WARNING), 698 705 JOptionPane.WARNING_MESSAGE, 699 706 null … … 861 868 } 862 869 if (msg != null && confirmDisablePlugin(parent, msg, plugin.name)) { 863 PreferencesUtils.removeFromList(Config.getPref(), "plugins", plugin.name);870 PreferencesUtils.removeFromList(Config.getPref(), PLUGINS, plugin.name); 864 871 } 865 872 } … … 1021 1028 private static void alertMissingPluginInformation(Component parent, Collection<String> plugins) { 1022 1029 StringBuilder sb = new StringBuilder(); 1023 sb.append( "<html>")1030 sb.append(HTML_START) 1024 1031 .append(trn("JOSM could not find information about the following plugin:", 1025 1032 "JOSM could not find information about the following plugins:", … … 1029 1036 "The plugins are not going to be loaded.", 1030 1037 plugins.size())) 1031 .append( "</html>");1038 .append(HTML_END); 1032 1039 HelpAwareOptionPane.showOptionDialog( 1033 1040 parent, 1034 1041 sb.toString(), 1035 tr( "Warning"),1042 tr(WARNING), 1036 1043 JOptionPane.WARNING_MESSAGE, 1037 1044 ht("/Plugin/Loading#MissingPluginInfos") … … 1054 1061 try { 1055 1062 monitor.beginTask(tr("Determining plugins to load...")); 1056 Set<String> plugins = new HashSet<>(Config.getPref().getList( "plugins", new LinkedList<>()));1063 Set<String> plugins = new HashSet<>(Config.getPref().getList(PLUGINS, new LinkedList<>())); 1057 1064 Logging.debug("Plugins list initialized to {0}", plugins); 1058 1065 String systemProp = Utils.getSystemProperty("josm.plugins"); … … 1088 1095 private static void alertFailedPluginUpdate(Component parent, Collection<PluginInformation> plugins) { 1089 1096 StringBuilder sb = new StringBuilder(128); 1090 sb.append( "<html>")1097 sb.append(HTML_START) 1091 1098 .append(trn( 1092 1099 "Updating the following plugin has failed:", … … 1102 1109 "Please open the Preference Dialog after JOSM has started and try to update them manually.", 1103 1110 plugins.size())) 1104 .append( "</html>");1111 .append(HTML_END); 1105 1112 HelpAwareOptionPane.showOptionDialog( 1106 1113 parent, … … 1222 1229 monitor.createSubTaskMonitor(1, false), 1223 1230 pluginsToDownload, 1224 tr( "Update plugins")1231 tr(UPDATE_PLUGINS) 1225 1232 ); 1226 1233 future = MainApplication.worker.submit(pluginDownloadTask); … … 1254 1261 // if all plugins updated, remember the update because it was successful 1255 1262 Config.getPref().putInt("pluginmanager.version", Version.getInstance().getVersion()); 1256 Config.getPref().put( "pluginmanager.lastupdate", Long.toString(System.currentTimeMillis()));1263 Config.getPref().put(PLUGINMANAGER_LASTUPDATE, Long.toString(System.currentTimeMillis())); 1257 1264 } 1258 1265 return plugins; … … 1270 1277 ButtonSpec[] options = { 1271 1278 new ButtonSpec( 1272 tr( "Disable plugin"),1273 new ImageProvider( "dialogs", "delete"),1279 tr(DISABLE_PLUGIN), 1280 new ImageProvider(DIALOGS, "delete"), 1274 1281 tr("Click to delete the plugin ''{0}''", name), 1275 1282 null /* no specific help context */ … … 1277 1284 new ButtonSpec( 1278 1285 tr("Keep plugin"), 1279 new ImageProvider( "cancel"),1286 new ImageProvider(CANCEL), 1280 1287 tr("Click to keep the plugin ''{0}''", name), 1281 1288 null /* no specific help context */ … … 1285 1292 parent, 1286 1293 reason, 1287 tr( "Disable plugin"),1294 tr(DISABLE_PLUGIN), 1288 1295 JOptionPane.WARNING_MESSAGE, 1289 1296 null, … … 1484 1491 new ButtonSpec( 1485 1492 tr("Update plugin"), 1486 new ImageProvider( "dialogs", "refresh"),1493 new ImageProvider(DIALOGS, "refresh"), 1487 1494 tr("Click to update the plugin ''{0}''", plugin.getPluginInformation().name), 1488 1495 null /* no specific help context */ 1489 1496 ), 1490 1497 new ButtonSpec( 1491 tr( "Disable plugin"),1492 new ImageProvider( "dialogs", "delete"),1498 tr(DISABLE_PLUGIN), 1499 new ImageProvider(DIALOGS, "delete"), 1493 1500 tr("Click to disable the plugin ''{0}''", plugin.getPluginInformation().name), 1494 1501 null /* no specific help context */ … … 1496 1503 new ButtonSpec( 1497 1504 tr("Keep plugin"), 1498 new ImageProvider( "cancel"),1505 new ImageProvider(CANCEL), 1499 1506 tr("Click to keep the plugin ''{0}''", plugin.getPluginInformation().name), 1500 1507 null /* no specific help context */ … … 1503 1510 1504 1511 final StringBuilder msg = new StringBuilder(256); 1505 msg.append( "<html>")1512 msg.append(HTML_START) 1506 1513 .append(tr("An unexpected exception occurred that may have come from the ''{0}'' plugin.", 1507 1514 Utils.escapeReservedCharactersHTML(plugin.getPluginInformation().name))) … … 1513 1520 } 1514 1521 msg.append(tr("Try updating to the newest version of this plugin before reporting a bug.")) 1515 .append( "</html>");1522 .append(HTML_END); 1516 1523 1517 1524 try { … … 1519 1526 MainApplication.getMainFrame(), 1520 1527 msg.toString(), 1521 tr( "Update plugins"),1528 tr(UPDATE_PLUGINS), 1522 1529 JOptionPane.QUESTION_MESSAGE, 1523 1530 null, … … 1590 1597 return null; 1591 1598 1592 Set<String> plugins = new HashSet<>(Config.getPref().getList( "plugins"));1599 Set<String> plugins = new HashSet<>(Config.getPref().getList(PLUGINS)); 1593 1600 final PluginInformation pluginInfo = plugin.getPluginInformation(); 1594 1601 if (!plugins.contains(pluginInfo.name)) … … 1605 1612 // deactivate the plugin 1606 1613 plugins.remove(plugin.getPluginInformation().name); 1607 Config.getPref().putList( "plugins", new ArrayList<>(plugins));1614 Config.getPref().putList(PLUGINS, new ArrayList<>(plugins)); 1608 1615 GuiHelper.runInEDTAndWait(() -> JOptionPane.showMessageDialog( 1609 1616 MainApplication.getMainFrame(), … … 1624 1631 */ 1625 1632 public static Collection<String> getBugReportInformation() { 1626 final Collection<String> pl = new TreeSet<>(Config.getPref().getList( "plugins", new LinkedList<>()));1633 final Collection<String> pl = new TreeSet<>(Config.getPref().getList(PLUGINS, new LinkedList<>())); 1627 1634 for (final PluginProxy pp : pluginList) { 1628 1635 PluginInformation pi = pp.getPluginInformation(); -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r12798 r19101 104 104 private int equivMax = 1; 105 105 106 private int[] xvec, yvec; /* Vectors being compared. */ 106 /* Vectors being compared. */ 107 private int[] xvec; 108 private int[] yvec; 107 109 private int[] fdiag; /* Vector, indexed by diagonal, containing 108 110 the X coordinate of the point furthest … … 113 115 along the given diagonal in the backward 114 116 search of the edit matrix. */ 115 private int fdiagoff, bdiagoff; 117 private int fdiagoff; 118 private int bdiagoff; 116 119 private final FileData[] filevec; 117 120 private int cost; … … 120 123 * Find the midpoint of the shortest edit script for a specified 121 124 * portion of the two files. 122 * 125 * <p> 123 126 * We scan from the beginnings of the files, and simultaneously from the ends, 124 127 * doing a breadth-first search through the space of edit-sequence. 125 128 * When the two searches meet, we have found the midpoint of the shortest 126 129 * edit sequence. 127 * 130 * <p> 128 131 * The value returned is the number of the diagonal on which the midpoint lies. 129 132 * The diagonal number equals the number of inserted lines minus the number … … 131 134 * The edit cost is stored into COST; this is the total number of 132 135 * lines inserted or deleted (counting only lines before the midpoint). 133 * 136 * <p> 134 137 * This function assumes that the first lines of the specified portions 135 138 * of the two files do not match, and likewise that the last lines do not 136 139 * match. The caller must trim matching lines from the beginning and end 137 140 * of the portions it is going to specify. 138 * 141 * <p> 139 142 * Note that if we return the "wrong" diagonal value, or if 140 143 * the value of bdiag at that diagonal is "wrong", … … 156 159 final int fmid = xoff - yoff; // Center diagonal of top-down search. 157 160 final int bmid = xlim - ylim; // Center diagonal of bottom-up search. 158 int fmin = fmid, fmax = fmid; // Limits of top-down search. 159 int bmin = bmid, bmax = bmid; // Limits of bottom-up search. 161 // Limits of top-down search. 162 int fmin = fmid; 163 int fmax = fmid; 164 // Limits of bottom-up search. 165 int bmin = bmid; 166 int bmax = bmid; 160 167 // True if southeast corner is on an odd diagonal with respect to the northwest. 161 168 final boolean odd = (fmid - bmid & 1) != 0; … … 212 219 } 213 220 for (d = bmax; d >= bmin; d -= 2) { 214 int x, y, tlo = bd[bdiagoff + d - 1], thi = bd[bdiagoff + d + 1]; 221 int x; 222 int y; 223 final int tlo = bd[bdiagoff + d - 1]; 224 final int thi = bd[bdiagoff + d + 1]; 215 225 216 226 if (tlo < thi) { … … 235 245 * Compare in detail contiguous subsequences of the two files 236 246 * which are known, as a whole, to match each other. 237 * 247 * <p> 238 248 * The results are recorded in the vectors filevec[N].changed_flag, by 239 249 * storing a 1 in the element for each line that is an insertion or deletion. 240 * 250 * <p> 241 251 * The subsequence of file 0 is [XOFF, XLIM) and likewise for file 1. 242 * 252 * <p> 243 253 * Note that XLIM, YLIM are exclusive bounds. 244 254 * All line numbers are origin-0 and discarded lines are not counted. … … 340 350 while (i0 < len0 || i1 < len1) { 341 351 if (changed0[1+i0] || changed1[1+i1]) { 342 int line0 = i0, line1 = i1; 352 int line0 = i0; 353 int line1 = i1; 343 354 344 355 /* Find # lines changed here in each file. */ … … 374 385 while (i0 >= 0 || i1 >= 0) { 375 386 if (changed0[i0] || changed1[i1]) { 376 int line0 = i0, line1 = i1; 387 int line0 = i0; 388 int line1 = i1; 377 389 378 390 /* Find # lines changed here in each file. */ … … 480 492 * DELETED is the number of lines deleted here from file 0. 481 493 * INSERTED is the number of lines inserted here in file 1. 482 * 494 * <p> 483 495 * If DELETED is 0 then LINE0 is the number of the line before 484 496 * which the insertion was done; vice versa for INSERTED and LINE1. … … 539 551 /** 540 552 * Discard lines that have no matches in another file. 541 * 553 * <p> 542 554 * A line which is discarded will not be considered by the actual comparison algorithm; 543 555 * it will be as if that line were not in the file. … … 747 759 h.put(data[i], equivs[i]); 748 760 } else { 749 equivs[i] = ir .intValue();761 equivs[i] = ir; 750 762 } 751 763 } … … 754 766 /** 755 767 * Adjust inserts/deletes of blank lines to join changes as much as possible. 756 * 768 * <p> 757 769 * We do something when a run of changed lines include a blank line at one end and have an excluded blank line at the other. 758 770 * We are free to choose which blank line is included. -
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r18315 r19101 23 23 import com.drew.metadata.exif.ExifDirectoryBase; 24 24 import com.drew.metadata.exif.ExifIFD0Directory; 25 import com.drew.metadata.exif.ExifSubIFDDirectory;26 25 import com.drew.metadata.exif.GpsDirectory; 27 26 import com.drew.metadata.iptc.IptcDirectory; … … 76 75 } 77 76 for (Tag tag : dirIt.getTags()) { 78 if (tag.getTagType() == Exif SubIFDDirectory.TAG_DATETIME_ORIGINAL /* 0x9003 */ &&79 !tag.getDescription().matches("\\[ [0-9]+ .+\\]")) {77 if (tag.getTagType() == ExifDirectoryBase.TAG_DATETIME_ORIGINAL /* 0x9003 */ && 78 !tag.getDescription().matches("\\[\\d+ .+]")) { 80 79 dateTimeOrig = tag.getDescription(); 81 } else if (tag.getTagType() == Exif IFD0Directory.TAG_DATETIME /* 0x0132 */) {80 } else if (tag.getTagType() == ExifDirectoryBase.TAG_DATETIME /* 0x0132 */) { 82 81 dateTime = tag.getDescription(); 83 } else if (tag.getTagType() == Exif SubIFDDirectory.TAG_DATETIME_DIGITIZED /* 0x9004 */) {82 } else if (tag.getTagType() == ExifDirectoryBase.TAG_DATETIME_DIGITIZED /* 0x9004 */) { 84 83 dateTimeDig = tag.getDescription(); 85 } else if (tag.getTagType() == Exif SubIFDDirectory.TAG_SUBSECOND_TIME_ORIGINAL /* 0x9291 */) {84 } else if (tag.getTagType() == ExifDirectoryBase.TAG_SUBSECOND_TIME_ORIGINAL /* 0x9291 */) { 86 85 subSecOrig = tag.getDescription(); 87 } else if (tag.getTagType() == Exif SubIFDDirectory.TAG_SUBSECOND_TIME /* 0x9290 */) {86 } else if (tag.getTagType() == ExifDirectoryBase.TAG_SUBSECOND_TIME /* 0x9290 */) { 88 87 subSec = tag.getDescription(); 89 } else if (tag.getTagType() == Exif SubIFDDirectory.TAG_SUBSECOND_TIME_DIGITIZED /* 0x9292 */) {88 } else if (tag.getTagType() == ExifDirectoryBase.TAG_SUBSECOND_TIME_DIGITIZED /* 0x9292 */) { 90 89 subSecDig = tag.getDescription(); 91 90 } … … 145 144 final Metadata metadata = JpegMetadataReader.readMetadata(filename); 146 145 final Directory dir = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class); 147 return dir == null ? null : dir.getInteger(Exif IFD0Directory.TAG_ORIENTATION);146 return dir == null ? null : dir.getInteger(ExifDirectoryBase.TAG_ORIENTATION); 148 147 } catch (JpegProcessingException | IOException e) { 149 148 Logging.error(e); … … 316 315 if (ele != null) { 317 316 final Integer d = dirGps.getInteger(GpsDirectory.TAG_ALTITUDE_REF); 318 if (d != null && d .intValue()== 1) {317 if (d != null && d == 1) { 319 318 ele *= -1; 320 319 } … … 367 366 /** 368 367 * Returns a Transform that fixes the image orientation. 369 * 368 * <p> 370 369 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated as 1. 371 370 * @param orientation the exif-orientation of the image … … 376 375 public static AffineTransform getRestoreOrientationTransform(final int orientation, final int width, final int height) { 377 376 final int q; 378 final double ax, ay; 377 final double ax; 378 final double ay; 379 379 switch (orientation) { 380 380 case 8: … … 404 404 * Check, if the given orientation switches width and height of the image. 405 405 * E.g. 90 degree rotation 406 * 406 * <p> 407 407 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 408 408 * as 1. … … 416 416 /** 417 417 * Check, if the given orientation requires any correction to the image. 418 * 418 * <p> 419 419 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 420 420 * as 1. -
trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java
r19071 r19101 96 96 } else if (code.matches(".+@.+")) { 97 97 return code.substring(0, 1).toUpperCase(Locale.ENGLISH) 98 + code. substring(1, 2)98 + code.charAt(1) 99 99 + '-' 100 100 + code.substring(3, 4).toUpperCase(Locale.ENGLISH) … … 128 128 /** 129 129 * Replies the locale code used by JOSM for a given locale. 130 * 130 * <p> 131 131 * In most cases JOSM uses the 2-character ISO 639 language code ({@link Locale#getLanguage()} 132 132 * to identify the locale of a localized resource, but in some cases it may use the 133 133 * programmatic name for locales, as replied by {@link Locale#toString()}. 134 * 134 * <p> 135 135 * For unknown country codes and variants this function already does fallback to 136 136 * internally known translations. … … 157 157 * Replies the OSM locale codes for the default locale. 158 158 * 159 * @param prefix a prefix like {@code name:}. 159 160 * @return the OSM locale codes for the default locale 160 161 * @see #getOSMLocaleCodes(String, Locale) … … 167 168 /** 168 169 * Replies the locale codes used by OSM for a given locale. 169 * 170 * <p> 170 171 * In most cases OSM uses the 2-character ISO 639 language code ({@link Locale#getLanguage()} 171 172 * to identify the locale of a localized resource, but in some cases it may use the 172 173 * programmatic name for locales, as replied by {@link Locale#toString()}. 173 * 174 * <p> 174 175 * For unknown country codes and variants this function already does fallback to 175 176 * internally known translations. … … 191 192 return new String[]{prefix+"zh-Hant-TW", prefix+"zh-Hant", prefix+"zh"}; 192 193 default: 193 var r = new ArrayList<String>();194 ArrayList<String> r = new ArrayList<>(); 194 195 for (String s : LanguageInfo.getLanguageCodes(null)) { 195 196 r.add(prefix + s); … … 201 202 /** 202 203 * Replies the locale code used by Java for a given locale. 203 * 204 * <p> 204 205 * In most cases JOSM and Java uses the same codes, but for some exceptions this is needed. 205 206 * … … 219 220 case "id": 220 221 return "in"; 221 } 222 return localeName; 222 default: 223 return localeName; 224 } 223 225 } 224 226 225 227 /** 226 228 * Replies the display string used by JOSM for a given locale. 227 * 229 * <p> 228 230 * In most cases returns text replied by {@link Locale#getDisplayName()}, for some 229 231 * locales an override is used (i.e. when unsupported by Java). … … 245 247 /** 246 248 * Replies the locale used by Java for a given language code. 247 * 249 * <p> 248 250 * Accepts JOSM and Java codes as input. 249 251 * … … 257 259 /** 258 260 * Replies the locale used by Java for a given language code. 259 * 261 * <p> 260 262 * Accepts JOSM, Java and POSIX codes as input. 261 263 * -
trunk/src/org/openstreetmap/josm/tools/ListenerList.java
r19050 r19101 40 40 @Override 41 41 public boolean equals(Object obj) { 42 if (obj != null && obj.getClass() == WeakListener.class) {42 if (obj instanceof WeakListener) { 43 43 return Objects.equals(listener.get(), ((WeakListener<?>) obj).listener.get()); 44 44 } else { … … 72 72 /** 73 73 * Adds a listener. The listener will not prevent the object from being garbage collected. 74 * 74 * <p> 75 75 * This should be used with care. It is better to add good cleanup code. 76 76 * @param listener The listener. … … 79 79 if (ensureNotInList(listener)) { 80 80 // clean the weak listeners, just to be sure... 81 while (weakListeners.remove(new WeakListener<T>(null))) { 82 // continue 83 } 81 WeakListener<T> nullListener = new WeakListener<>(null); 82 weakListeners.removeIf(nullListener::equals); 84 83 weakListeners.add(new WeakListener<>(listener)); 85 84 } -
trunk/src/org/openstreetmap/josm/tools/ListeningCollection.java
r12269 r19101 32 32 public final Iterator<T> iterator() { 33 33 Iterator<T> it = base.iterator(); 34 return new Iterator< T>() {34 return new Iterator<>() { 35 35 private T object; 36 36 -
trunk/src/org/openstreetmap/josm/tools/MultiMap.java
r15870 r19101 14 14 /** 15 15 * MultiMap - maps keys to multiple values. 16 * 16 * <p> 17 17 * Corresponds to Google guava LinkedHashMultimap and Apache Collections MultiValueMap 18 18 * but it is an independent (simple) implementation. … … 59 59 /** 60 60 * Map a key to a value. 61 * 61 * <p> 62 62 * Can be called multiple times with the same key, but different value. 63 63 * @param key key with which the specified value is to be associated … … 70 70 /** 71 71 * Put a key that maps to nothing. (Only if it is not already in the map) 72 * 72 * <p> 73 73 * Afterwards containsKey(key) will return true and get(key) will return 74 74 * an empty Set instead of null. … … 78 78 if (map.containsKey(key)) 79 79 return; 80 map.put(key, new LinkedHashSet< B>());80 map.put(key, new LinkedHashSet<>()); 81 81 } 82 82 83 83 /** 84 84 * Map the key to all the given values. 85 * 85 * <p> 86 86 * Adds to the mappings that are already there. 87 87 * @param key key with which the specified values are to be associated … … 104 104 * Returns the Set associated with the given key. Result is null if 105 105 * nothing has been mapped to this key. 106 * 106 * <p> 107 107 * Modifications of the returned list changes the underling map, 108 108 * but you should better not do that. -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19094 r19101 16 16 import java.io.InputStream; 17 17 import java.io.UnsupportedEncodingException; 18 import java.lang.reflect.Method;19 18 import java.net.MalformedURLException; 20 19 import java.net.URI; … … 102 101 private static final double TO_RADIANS = Math.PI / 180.0; 103 102 104 /**105 * A reference to {@code Map.ofEntries()} available since Java 9106 */107 static final Method mapOfEntries = mapOfEntriesMethod();108 109 private static Method mapOfEntriesMethod() {110 if (getJavaVersion() >= 9) {111 try {112 return Map.class.getMethod("ofEntries", Map.Entry[].class);113 } catch (NoSuchMethodException noSuchMethodException) {114 Logging.trace(noSuchMethodException);115 }116 }117 return null;118 }119 120 103 private Utils() { 121 104 // Hide default constructor for utils classes … … 205 188 * @deprecated since 15718, use {@link String#join} or {@link Collectors#joining} 206 189 */ 207 @Deprecated 190 @Deprecated(since = "15718", forRemoval = true) 208 191 public static String join(String sep, Collection<?> values) { 209 192 CheckParameterUtil.ensureParameterNotNull(sep, "sep"); … … 349 332 */ 350 333 public static boolean deleteFileIfExists(File file) { 351 if (file.exists()) { 352 return deleteFile(file); 353 } else { 354 return true; 355 } 334 return !file.exists() || deleteFile(file); 356 335 } 357 336 … … 590 569 */ 591 570 public static <A, B> Collection<B> transform(final Collection<? extends A> c, final Function<A, B> f) { 592 return new AbstractCollection< B>() {571 return new AbstractCollection<>() { 593 572 594 573 @Override … … 599 578 @Override 600 579 public Iterator<B> iterator() { 601 return new Iterator< B>() {580 return new Iterator<>() { 602 581 603 582 private final Iterator<? extends A> it = c.iterator(); … … 632 611 */ 633 612 public static <A, B> List<B> transform(final List<? extends A> l, final Function<A, B> f) { 634 return new AbstractList< B>() {613 return new AbstractList<>() { 635 614 636 615 @Override … … 657 636 @SuppressWarnings("unchecked") 658 637 public static <T> List<T> toUnmodifiableList(Collection<T> collection) { 659 // Java 9: use List.of(...)660 638 if (isEmpty(collection)) { 661 639 return Collections.emptyList(); … … 663 641 return Collections.singletonList(collection.iterator().next()); 664 642 } else { 665 return (List<T>) Arrays.asList(collection.toArray()); 643 // List.copyOf would also work, but if the original collection is immutable, it just returns the original 644 // collection. 645 return (List<T>) List.of(collection.toArray()); 666 646 } 667 647 } … … 685 665 final Map.Entry<K, V> entry = map.entrySet().iterator().next(); 686 666 return Collections.singletonMap(entry.getKey(), entry.getValue()); 687 } else if (mapOfEntries != null) { 688 try { 689 // Java 9: use Map.ofEntries(...) 690 return (Map<K, V>) mapOfEntries.invoke(null, (Object) map.entrySet().toArray(new Map.Entry[0])); 691 } catch (ReflectiveOperationException toLog) { 692 Logging.trace(toLog); 693 } 694 } 695 return Collections.unmodifiableMap(map); 667 } 668 // Map.copyOf would also work, but if the original map is immutable, it just returns the original map. 669 return Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])); 696 670 } 697 671 … … 849 823 /** 850 824 * Runs an external command and returns the standard output. 851 * 825 * <p> 852 826 * The program is expected to execute fast, as this call waits 10 seconds at most. 853 827 * … … 991 965 sb.append(',').append(cur); 992 966 } else { 993 sb.append('-').append(last) ;994 sb.append(',').append(cur);967 sb.append('-').append(last) 968 .append(',').append(cur); 995 969 cnt = 0; 996 970 } … … 1129 1103 * Fixes URL with illegal characters in the query (and fragment) part by 1130 1104 * percent encoding those characters. 1131 * 1105 * <p> 1132 1106 * special characters like & and # are not encoded 1133 1107 * … … 1531 1505 * @deprecated since 19050 -- use {@link InputStream#readAllBytes()} instead 1532 1506 */ 1533 @Deprecated 1507 @Deprecated(since = "19050", forRemoval = true) 1534 1508 public static byte[] readBytesFromStream(InputStream stream) throws IOException { 1535 1509 if (stream == null) { … … 1644 1618 } else if (val < min) { 1645 1619 return min; 1646 } else if (val > max) { 1647 return max; 1648 } else { 1649 return val; 1650 } 1620 } 1621 return Math.min(val, max); 1651 1622 } 1652 1623 … … 1860 1831 * @return true if JOSM has been started via Oracle Java Web Start 1861 1832 * @since 15740 1862 */ 1833 * @deprecated JOSM no longer supports Oracle Java Webstart since Oracle Java Webstart doesn't support Java 9+. 1834 */ 1835 @Deprecated(since = "19101", forRemoval = true) 1863 1836 public static boolean isRunningJavaWebStart() { 1864 1837 return isRunningWebStart() && isClassFound("com.sun.javaws.Main"); … … 2071 2044 */ 2072 2045 public static Double unitToMeter(String s) throws IllegalArgumentException { 2073 s = s.replace All(" ", "").replaceAll(",", ".");2046 s = s.replace(" ", "").replace(",", "."); 2074 2047 Matcher m = PATTERN_LENGTH.matcher(s); 2075 2048 if (m.matches()) { 2076 Double v = Double.valueOf(m.group(1)); 2077 if ("cm".equals(m.group(2))) 2078 v *= 0.01; 2079 else if ("mm".equals(m.group(2))) 2080 v *= 0.001; 2081 else if ("km".equals(m.group(2))) 2082 v *= 1000.0; 2083 else if ("nmi".equals(m.group(2))) 2084 v *= 1852.0; 2085 else if ("mi".equals(m.group(2))) 2086 v *= 1609.344; 2087 else if ("ft".equals(m.group(2)) || "'".equals(m.group(2))) 2088 v *= 0.3048; 2089 else if ("in".equals(m.group(2)) || "\"".equals(m.group(2))) 2090 v *= 0.0254; 2091 return v; 2049 return Double.parseDouble(m.group(1)) * unitToMeterConversion(m.group(2)); 2092 2050 } else { 2093 2051 m = PATTERN_LENGTH2.matcher(s); … … 2095 2053 /* NOTE: we assume -a'b" means -(a'+b") and not (-a')+b" - because of such issues SI units have been invented 2096 2054 and have been adopted by the majority of the world */ 2097 return (Double. valueOf(m.group(2))*0.3048+Double.valueOf(m.group(4))*0.0254)*(m.group(1).isEmpty() ? 1.0 : -1.0);2055 return (Double.parseDouble(m.group(2))*0.3048+Double.parseDouble(m.group(4))*0.0254)*(m.group(1).isEmpty() ? 1.0 : -1.0); 2098 2056 } 2099 2057 } 2100 2058 throw new IllegalArgumentException("Invalid length value: " + s); 2101 2059 } 2060 2061 /** 2062 * Get the conversion factor for a specified unit to meters 2063 * @param unit The unit to convert to meters 2064 * @return The conversion factor or 1. 2065 * @throws IllegalArgumentException if the unit does not currently have a conversion 2066 */ 2067 private static double unitToMeterConversion(String unit) throws IllegalArgumentException { 2068 if (unit == null) { 2069 return 1; 2070 } 2071 switch (unit) { 2072 case "cm": return 0.01; 2073 case "mm": return 0.001; 2074 case "m": return 1; 2075 case "km": return 1000.0; 2076 case "nmi": return 1852.0; 2077 case "mi": return 1609.344; 2078 case "ft": 2079 case "'": 2080 return 0.3048; 2081 case "in": 2082 case "\"": 2083 return 0.0254; 2084 default: throw new IllegalArgumentException("Invalid length unit: " + unit); 2085 } 2086 } 2102 2087 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java
r17380 r19101 32 32 * @since 10285 33 33 */ 34 @SuppressWarnings("OverrideThrowableToString")35 34 public class ReportedException extends RuntimeException { 36 35 /** … … 168 167 */ 169 168 public boolean isSame(ReportedException e) { 170 if (!getMessage().equals(e.getMessage())) { 171 return false; 172 } 173 174 return hasSameStackTrace(new CauseTraceIterator(), e.getCause()); 169 return getMessage().equals(e.getMessage()) && hasSameStackTrace(new CauseTraceIterator(), e.getCause()); 175 170 } 176 171 … … 192 187 if ((c1 == null) != (c2 == null)) { 193 188 return false; 194 } else if (c1 != null) { 195 return hasSameStackTrace(causeTraceIterator, c2); 196 } else { 197 return true; 198 } 189 } 190 return c1 == null || hasSameStackTrace(causeTraceIterator, c2); 199 191 } 200 192 … … 231 223 string = makeCollectionNice((Collection<?>) value); 232 224 } else if (value.getClass().isArray()) { 233 string = makeCollectionNice( Arrays.asList(value));225 string = makeCollectionNice(Collections.singleton(value)); 234 226 } else { 235 227 string = value.toString(); … … 283 275 */ 284 276 public boolean isOutOfMemory() { 285 return StreamUtils.toStream(CauseTraceIterator::new).anyMatch( t -> t instanceof OutOfMemoryError);277 return StreamUtils.toStream(CauseTraceIterator::new).anyMatch(OutOfMemoryError.class::isInstance); 286 278 } 287 279 … … 293 285 private final class CauseTraceIterator implements Iterator<Throwable> { 294 286 private Throwable current = getCause(); 295 private final Set<Throwable> dejaVu = Collections.newSetFromMap(new IdentityHashMap< Throwable, Boolean>());287 private final Set<Throwable> dejaVu = Collections.newSetFromMap(new IdentityHashMap<>()); 296 288 297 289 @Override -
trunk/src/org/openstreetmap/josm/tools/template_engine/Variable.java
r16488 r19101 62 62 @Override 63 63 public boolean isValid(TemplateEngineDataProvider dataProvider) { 64 if (special && SPECIAL_VALUE_EVERYTHING.equals(variableName)) 65 return true; 66 else 67 return dataProvider.getTemplateValue(variableName, special) != null; 64 return (special && SPECIAL_VALUE_EVERYTHING.equals(variableName)) 65 || dataProvider.getTemplateValue(variableName, special) != null; 68 66 } 69 67 … … 94 92 return false; 95 93 Variable other = (Variable) obj; 96 if (special != other.special) 97 return false; 98 if (variableName == null) { 99 if (other.variableName != null) 100 return false; 101 } else if (!variableName.equals(other.variableName)) 102 return false; 103 return true; 94 return this.special == other.special && Objects.equals(this.variableName, other.variableName); 104 95 } 105 96 }
Note:
See TracChangeset
for help on using the changeset viewer.