Ignore:
Timestamp:
2017-09-11T20:43:41+02:00 (2 years ago)
Author:
Don-vip
Message:

see #15229 - see #15182 - make FileWatcher generic so it has no more dependence on MapCSS

Location:
trunk/src/org/openstreetmap/josm/data/preferences/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/ExtendedSourceEntry.java

    r12649 r12825  
    2828    /**
    2929     * Constructs a new {@code ExtendedSourceEntry}.
     30     * @param type type of source entry
    3031     * @param simpleFileName file name used for display
    3132     * @param url URL that {@link org.openstreetmap.josm.io.CachedFile} understands
     33     * @since 12825
    3234     */
    33     public ExtendedSourceEntry(String simpleFileName, String url) {
    34         super(url, null, null, true);
     35    public ExtendedSourceEntry(SourceType type, String simpleFileName, String url) {
     36        super(type, url, null, null, true);
    3537        this.simpleFileName = simpleFileName;
    3638    }
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java

    r12649 r12825  
    3030     */
    3131    public MapPaintPrefHelper() {
    32         super("mappaint.style.entries");
     32        super("mappaint.style.entries", SourceType.MAP_PAINT_STYLE);
    3333    }
    3434
     
    8080    @Override
    8181    public Collection<ExtendedSourceEntry> getDefault() {
    82         ExtendedSourceEntry defJosmMapcss = new ExtendedSourceEntry("elemstyles.mapcss", "resource://styles/standard/elemstyles.mapcss");
     82        ExtendedSourceEntry defJosmMapcss = new ExtendedSourceEntry(type, "elemstyles.mapcss", "resource://styles/standard/elemstyles.mapcss");
    8383        defJosmMapcss.active = true;
    8484        defJosmMapcss.name = "standard";
    8585        defJosmMapcss.title = tr("JOSM default (MapCSS)");
    8686        defJosmMapcss.description = tr("Internal style to be used as base for runtime switchable overlay styles");
    87         ExtendedSourceEntry defPL2 = new ExtendedSourceEntry("potlatch2.mapcss", "resource://styles/standard/potlatch2.mapcss");
     87        ExtendedSourceEntry defPL2 = new ExtendedSourceEntry(type, "potlatch2.mapcss", "resource://styles/standard/potlatch2.mapcss");
    8888        defPL2.active = false;
    8989        defPL2.name = "standard";
     
    108108    @Override
    109109    public SourceEntry deserialize(Map<String, String> s) {
    110         return new SourceEntry(s.get("url"), s.get("ptoken"), s.get("title"), Boolean.parseBoolean(s.get("active")));
     110        return new SourceEntry(type, s.get("url"), s.get("ptoken"), s.get("title"), Boolean.parseBoolean(s.get("active")));
    111111    }
    112112}
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/PresetPrefHelper.java

    r12649 r12825  
    2424     */
    2525    public PresetPrefHelper() {
    26         super("taggingpreset.entries");
     26        super("taggingpreset.entries", SourceType.TAGGING_PRESET);
    2727    }
    2828
    2929    @Override
    3030    public Collection<ExtendedSourceEntry> getDefault() {
    31         ExtendedSourceEntry i = new ExtendedSourceEntry("defaultpresets.xml", "resource://data/defaultpresets.xml");
     31        ExtendedSourceEntry i = new ExtendedSourceEntry(type, "defaultpresets.xml", "resource://data/defaultpresets.xml");
    3232        i.title = tr("Internal Preset");
    3333        i.description = tr("The default preset for JOSM");
     
    4545    @Override
    4646    public SourceEntry deserialize(Map<String, String> s) {
    47         return new SourceEntry(s.get("url"), null, s.get("title"), true);
     47        return new SourceEntry(type, s.get("url"), null, s.get("title"), true);
    4848    }
    4949}
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/SourceEntry.java

    r12649 r12825  
    1919
    2020    /**
     21     * The type of source entry.
     22     * @since 12825
     23     **/
     24    public final SourceType type;
     25
     26    /**
    2127     *  A URL can be anything that CachedFile understands, i.e.
    2228     *  a local file, http://, or a file from the current jar
     
    5864    /**
    5965     * Constructs a new {@code SourceEntry}.
     66     * @param type type of source entry
    6067     * @param url URL that {@link org.openstreetmap.josm.io.CachedFile} understands
    6168     * @param isZip if url is a zip file and the resource is inside the zip file
     
    7077     * @see #title
    7178     * @see #active
    72      */
    73     public SourceEntry(String url, boolean isZip, String zipEntryPath, String name, String title, boolean active) {
     79     * @since 12825
     80     */
     81    public SourceEntry(SourceType type, String url, boolean isZip, String zipEntryPath, String name, String title, boolean active) {
     82        this.type = type;
    7483        this.url = url;
    7584        this.isZip = isZip;
     
    8291    /**
    8392     * Constructs a new {@code SourceEntry}.
     93     * @param type type of source entry
    8494     * @param url URL that {@link org.openstreetmap.josm.io.CachedFile} understands
    8595     * @param name Source name
     
    90100     * @see #title
    91101     * @see #active
    92      */
    93     public SourceEntry(String url, String name, String title, boolean active) {
    94         this(url, false, null, name, title, active);
     102     * @since 12825
     103     */
     104    public SourceEntry(SourceType type, String url, String name, String title, boolean active) {
     105        this(type, url, false, null, name, title, active);
    95106    }
    96107
     
    100111     */
    101112    public SourceEntry(SourceEntry e) {
     113        this.type = e.type;
    102114        this.url = e.url;
    103115        this.isZip = e.isZip;
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/SourcePrefHelper.java

    r12649 r12825  
    1919
    2020    private final String pref;
     21    protected final SourceType type;
    2122
    2223    /**
    2324     * Constructs a new {@code SourcePrefHelper} for the given preference key.
    2425     * @param pref The preference key
     26     * @param type The source type
     27     * @since 12825
    2528     */
    26     public SourcePrefHelper(String pref) {
     29    public SourcePrefHelper(String pref, SourceType type) {
    2730        this.pref = pref;
     31        this.type = type;
    2832    }
    2933
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/ValidatorPrefHelper.java

    r12649 r12825  
    5555     */
    5656    public ValidatorPrefHelper() {
    57         super(MapCSSTagChecker.ENTRIES_PREF_KEY);
     57        super(MapCSSTagChecker.ENTRIES_PREF_KEY, SourceType.TAGCHECKER_RULE);
    5858    }
    5959
     
    8080    }
    8181
    82     private static void addDefault(List<ExtendedSourceEntry> defaults, String filename, String title, String description) {
    83         ExtendedSourceEntry i = new ExtendedSourceEntry(filename+".mapcss", "resource://data/validator/"+filename+".mapcss");
     82    private void addDefault(List<ExtendedSourceEntry> defaults, String filename, String title, String description) {
     83        ExtendedSourceEntry i = new ExtendedSourceEntry(type, filename+".mapcss", "resource://data/validator/"+filename+".mapcss");
    8484        i.title = title;
    8585        i.description = description;
     
    9898    @Override
    9999    public SourceEntry deserialize(Map<String, String> s) {
    100         return new SourceEntry(s.get("url"), null, s.get("title"), Boolean.parseBoolean(s.get("active")));
     100        return new SourceEntry(type, s.get("url"), null, s.get("title"), Boolean.parseBoolean(s.get("active")));
    101101    }
    102102}
Note: See TracChangeset for help on using the changeset viewer.