Changeset 10363 in josm for trunk/src/org
- Timestamp:
- 2016-06-12T20:40:45+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r10234 r10363 42 42 /** Values for {@code power} key interpreted as power stations */ 43 43 protected static final Collection<String> POWER_STATION_TAGS = Arrays.asList("station", "sub_station", "substation", "plant", "generator"); 44 /** Values for {@code building} key interpreted as power stations */ 45 protected static final Collection<String> BUILDING_STATION_TAGS = Arrays.asList("transformer_tower"); 44 46 /** Values for {@code power} key interpreted as allowed power items */ 45 47 protected static final Collection<String> POWER_ALLOWED_TAGS = Arrays.asList("switch", "transformer", "busbar", "generator", "switchgear", … … 174 176 */ 175 177 protected static final boolean isPowerStation(OsmPrimitive p) { 176 return isPowerIn(p, POWER_STATION_TAGS) ;178 return isPowerIn(p, POWER_STATION_TAGS) || isBuildingIn(p, BUILDING_STATION_TAGS); 177 179 } 178 180 … … 196 198 197 199 /** 198 * Helper function to check if power tag sis a certain value.200 * Helper function to check if power tag is a certain value. 199 201 * @param p The primitive to be tested 200 202 * @param values List of possible values … … 203 205 private static boolean isPowerIn(OsmPrimitive p, Collection<String> values) { 204 206 String v = p.get("power"); 207 return v != null && values != null && values.contains(v); 208 } 209 210 /** 211 * Helper function to check if building tag is a certain value. 212 * @param p The primitive to be tested 213 * @param values List of possible values 214 * @return {@code true} if power key is set and equal to possible values 215 */ 216 private static boolean isBuildingIn(OsmPrimitive p, Collection<String> values) { 217 String v = p.get("building"); 205 218 return v != null && values != null && values.contains(v); 206 219 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r10300 r10363 43 43 import org.openstreetmap.josm.data.osm.Tag; 44 44 import org.openstreetmap.josm.gui.ExtendedDialog; 45 import org.openstreetmap.josm.gui.MapView;46 45 import org.openstreetmap.josm.gui.Notification; 47 46 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 48 import org.openstreetmap.josm.gui.layer.Layer; 47 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 48 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 49 49 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 50 50 import org.openstreetmap.josm.gui.tagging.presets.items.Key; … … 75 75 * @since 294 76 76 */ 77 public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener, Predicate<OsmPrimitive> {77 public class TaggingPreset extends AbstractAction implements ActiveLayerChangeListener, Predicate<OsmPrimitive> { 78 78 79 79 public static final int DIALOG_ANSWER_APPLY = 1; … … 113 113 */ 114 114 public TaggingPreset() { 115 Ma pView.addLayerChangeListener(this);115 Main.getLayerManager().addActiveLayerChangeListener(this); 116 116 updateEnabledState(); 117 117 } … … 480 480 } 481 481 482 /** 483 * Gets a list of tags that are set by this preset. 484 * @return The list of tags. 485 */ 482 486 public List<Tag> getChangedTags() { 483 487 List<Tag> result = new ArrayList<>(); … … 488 492 } 489 493 494 /** 495 * Create a command to change the given list of tags. 496 * @param sel The primitives to change the tags for 497 * @param changedTags The tags to change 498 * @return A command that changes the tags. 499 */ 490 500 public static Command createCommand(Collection<OsmPrimitive> sel, List<Tag> changedTags) { 491 501 List<Command> cmds = new ArrayList<>(); … … 514 524 515 525 @Override 516 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 517 updateEnabledState(); 518 } 519 520 @Override 521 public void layerAdded(Layer newLayer) { 522 updateEnabledState(); 523 } 524 525 @Override 526 public void layerRemoved(Layer oldLayer) { 526 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 527 527 updateEnabledState(); 528 528 } … … 533 533 } 534 534 535 /** 536 * Determines whether this preset matches the types. 537 * @param t The types that must match 538 * @return <code>true</code> if all types match. 539 */ 535 540 public boolean typeMatches(Collection<TaggingPresetType> t) { 536 541 return t == null || types == null || types.containsAll(t); … … 558 563 */ 559 564 public boolean matches(Collection<TaggingPresetType> t, Map<String, String> tags, boolean onlyShowable) { 560 if ( onlyShowable && !isShowable())565 if ((onlyShowable && !isShowable()) || !typeMatches(t)) { 561 566 return false; 562 else if (!typeMatches(t)) 563 return false; 564 else 567 } else { 565 568 return TaggingPresetItem.matches(data, tags); 569 } 566 570 } 567 571 … … 590 594 } 591 595 596 /** 597 * Gets a string describing this preset that can be used for the toolbar 598 * @return A String that can be passed on to the toolbar 599 * @see ToolbarPreferences#addCustomButton(String, int, boolean) 600 */ 592 601 public String getToolbarString() { 593 602 ToolbarPreferences.ActionParser actionParser = new ToolbarPreferences.ActionParser(null);
Note:
See TracChangeset
for help on using the changeset viewer.