Changeset 16598 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-06-11T11:32:23+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r16597 r16598 116 116 import org.openstreetmap.josm.tools.Logging; 117 117 import org.openstreetmap.josm.tools.Shortcut; 118 import org.openstreetmap.josm.tools.TaginfoRegionalInstance; 118 119 import org.openstreetmap.josm.tools.Territories; 119 120 import org.openstreetmap.josm.tools.Utils; … … 197 198 private final TaginfoAction tagHistoryAction = taginfoAction.toTagHistoryAction(); 198 199 private final Collection<TaginfoAction> taginfoNationalActions = new ArrayList<>(); 200 private transient int taginfoNationalHash; 199 201 private final PasteValueAction pasteValueAction = new PasteValueAction(); 200 202 private final CopyValueAction copyValueAction = new CopyValueAction( … … 371 373 372 374 private void setupTaginfoNationalActions(Collection<? extends IPrimitive> newSel) { 375 if (newSel.isEmpty()) { 376 return; 377 } 378 final LatLon center = newSel.iterator().next().getBBox().getCenter(); 379 List<TaginfoRegionalInstance> regionalInstances = Territories.getRegionalTaginfoUrls(center); 380 int newHashCode = regionalInstances.hashCode(); 381 if (newHashCode == taginfoNationalHash) { 382 // taginfoNationalActions are still valid 383 return; 384 } 385 taginfoNationalHash = newHashCode; 373 386 destroyTaginfoNationalActions(); 374 if (!newSel.isEmpty()) { 375 final LatLon center = newSel.iterator().next().getBBox().getCenter(); 376 Territories.getRegionalTaginfoUrls(center).stream() 377 .map(taginfo -> taginfoAction.withTaginfoUrl(tr("Go to Taginfo ({0})", taginfo.toString()), taginfo.getUrl()) 378 ).forEach(taginfoNationalActions::add); 379 taginfoNationalActions.stream().map(membershipMenu::add).forEach(membershipMenuTagInfoNatItems::add); 380 taginfoNationalActions.stream().map(tagMenu::add).forEach(tagMenuTagInfoNatItems::add); 381 } 387 regionalInstances.stream() 388 .map(taginfo -> taginfoAction.withTaginfoUrl(tr("Go to Taginfo ({0})", taginfo.toString()), taginfo.getUrl())) 389 .forEach(taginfoNationalActions::add); 390 taginfoNationalActions.stream().map(membershipMenu::add).forEach(membershipMenuTagInfoNatItems::add); 391 taginfoNationalActions.stream().map(tagMenu::add).forEach(tagMenuTagInfoNatItems::add); 382 392 } 383 393
Note:
See TracChangeset
for help on using the changeset viewer.