Changeset 10363 in josm for trunk/src/org


Ignore:
Timestamp:
2016-06-12T20:40:45+02:00 (8 years ago)
Author:
stoecker
Message:

gsoc-core - patch by Michael Zangl - fix #12955 - remove deprecation usage

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  
    4242    /** Values for {@code power} key interpreted as power stations */
    4343    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");
    4446    /** Values for {@code power} key interpreted as allowed power items */
    4547    protected static final Collection<String> POWER_ALLOWED_TAGS = Arrays.asList("switch", "transformer", "busbar", "generator", "switchgear",
     
    174176     */
    175177    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);
    177179    }
    178180
     
    196198
    197199    /**
    198      * Helper function to check if power tags is a certain value.
     200     * Helper function to check if power tag is a certain value.
    199201     * @param p The primitive to be tested
    200202     * @param values List of possible values
     
    203205    private static boolean isPowerIn(OsmPrimitive p, Collection<String> values) {
    204206        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");
    205218        return v != null && values != null && values.contains(v);
    206219    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r10300 r10363  
    4343import org.openstreetmap.josm.data.osm.Tag;
    4444import org.openstreetmap.josm.gui.ExtendedDialog;
    45 import org.openstreetmap.josm.gui.MapView;
    4645import org.openstreetmap.josm.gui.Notification;
    4746import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
    48 import org.openstreetmap.josm.gui.layer.Layer;
     47import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     48import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    4949import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
    5050import org.openstreetmap.josm.gui.tagging.presets.items.Key;
     
    7575 * @since 294
    7676 */
    77 public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener, Predicate<OsmPrimitive> {
     77public class TaggingPreset extends AbstractAction implements ActiveLayerChangeListener, Predicate<OsmPrimitive> {
    7878
    7979    public static final int DIALOG_ANSWER_APPLY = 1;
     
    113113     */
    114114    public TaggingPreset() {
    115         MapView.addLayerChangeListener(this);
     115        Main.getLayerManager().addActiveLayerChangeListener(this);
    116116        updateEnabledState();
    117117    }
     
    480480    }
    481481
     482    /**
     483     * Gets a list of tags that are set by this preset.
     484     * @return The list of tags.
     485     */
    482486    public List<Tag> getChangedTags() {
    483487        List<Tag> result = new ArrayList<>();
     
    488492    }
    489493
     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     */
    490500    public static Command createCommand(Collection<OsmPrimitive> sel, List<Tag> changedTags) {
    491501        List<Command> cmds = new ArrayList<>();
     
    514524
    515525    @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) {
    527527        updateEnabledState();
    528528    }
     
    533533    }
    534534
     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     */
    535540    public boolean typeMatches(Collection<TaggingPresetType> t) {
    536541        return t == null || types == null || types.containsAll(t);
     
    558563     */
    559564    public boolean matches(Collection<TaggingPresetType> t, Map<String, String> tags, boolean onlyShowable) {
    560         if (onlyShowable && !isShowable())
     565        if ((onlyShowable && !isShowable()) || !typeMatches(t)) {
    561566            return false;
    562         else if (!typeMatches(t))
    563             return false;
    564         else
     567        } else {
    565568            return TaggingPresetItem.matches(data, tags);
     569        }
    566570    }
    567571
     
    590594    }
    591595
     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     */
    592601    public String getToolbarString() {
    593602        ToolbarPreferences.ActionParser actionParser = new ToolbarPreferences.ActionParser(null);
Note: See TracChangeset for help on using the changeset viewer.