Changeset 15371 in josm


Ignore:
Timestamp:
2019-09-24T17:50:54+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #18160 - Ask layers for source, don't hardcode source for layer types (patch by taylor.smock)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r15121 r15371  
    2929import java.util.List;
    3030import java.util.Set;
    31 import java.util.TreeSet;
    3231import java.util.concurrent.CopyOnWriteArrayList;
    3332import java.util.concurrent.atomic.AtomicBoolean;
     33import java.util.stream.Collectors;
    3434
    3535import javax.swing.AbstractButton;
     
    5151import org.openstreetmap.josm.gui.autofilter.AutoFilterManager;
    5252import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler;
    53 import org.openstreetmap.josm.gui.layer.GpxLayer;
    54 import org.openstreetmap.josm.gui.layer.ImageryLayer;
    5553import org.openstreetmap.josm.gui.layer.Layer;
    5654import org.openstreetmap.josm.gui.layer.LayerManager;
     
    6765import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener;
    6866import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    69 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    7067import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
    7168import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     
    819816     */
    820817    public String getLayerInformationForSourceTag() {
    821         final Set<String> layerInfo = new TreeSet<>();
    822         if (!layerManager.getLayersOfType(GpxLayer.class).isEmpty()) {
    823             // no i18n for international values
    824             layerInfo.add("survey");
    825         }
    826         for (final GeoImageLayer i : layerManager.getLayersOfType(GeoImageLayer.class)) {
    827             if (i.isVisible()) {
    828                 layerInfo.add(i.getName());
    829             }
    830         }
    831         for (final ImageryLayer i : layerManager.getLayersOfType(ImageryLayer.class)) {
    832             if (i.isVisible()) {
    833                 layerInfo.add(i.getInfo().getSourceName());
    834             }
    835         }
     818        final Set<String> layerInfo = layerManager.getVisibleLayersInZOrder().stream()
     819                .filter(layer -> layer.getChangesetSourceTag() != null && !layer.getChangesetSourceTag().trim().isEmpty())
     820                .map(layer -> layer.getChangesetSourceTag().trim()).distinct().collect(Collectors.toSet());
    836821        return Utils.join("; ", layerInfo);
    837822    }
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r14338 r15371  
    474474        this.isExpertMode = isExpert;
    475475    }
     476
     477    @Override
     478    public String getChangesetSourceTag() {
     479        // no i18n for international values
     480        return "survey";
     481    }
    476482}
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r14757 r15371  
    355355        return getClass().getSimpleName() + " [info=" + info + ']';
    356356    }
     357
     358    @Override
     359    public String getChangesetSourceTag() {
     360        return getInfo().getSourceName();
     361    }
    357362}
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r14153 r15371  
    675675    }
    676676
     677    /**
     678     * Get the source for the layer
     679     * @return The string for the changeset source tag or {@code null}
     680     * @since 15371
     681     */
     682    public String getChangesetSourceTag() {
     683        return null;
     684    }
     685
    677686    @Override
    678687    public String toString() {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r15333 r15371  
    10111011        updateBufferAndRepaint();
    10121012    }
     1013
     1014    @Override
     1015    public String getChangesetSourceTag() {
     1016        return getName();
     1017    }
    10131018}
Note: See TracChangeset for help on using the changeset viewer.