Changeset 14144 in josm


Ignore:
Timestamp:
2018-08-12T14:45:46+02:00 (6 years ago)
Author:
Don-vip
Message:

see #15229 - code refactoring - add PlatformHook.getPossiblePreferenceDirs()

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r14138 r14144  
    281281        addPossibleResourceDir(locations, getSystemEnv("JOSM_RESOURCES"));
    282282        addPossibleResourceDir(locations, getSystemProperty("josm.resources"));
    283         if (PlatformManager.isPlatformWindows()) {
    284             String appdata = getSystemEnv("APPDATA");
    285             if (appdata != null && getSystemEnv("ALLUSERSPROFILE") != null
    286                     && appdata.lastIndexOf(File.separator) != -1) {
    287                 appdata = appdata.substring(appdata.lastIndexOf(File.separator));
    288                 locations.add(new File(new File(getSystemEnv("ALLUSERSPROFILE"),
    289                         appdata), "JOSM").getPath());
    290             }
    291         } else {
    292             locations.add("/usr/local/share/josm/");
    293             locations.add("/usr/local/lib/josm/");
    294             locations.add("/usr/share/josm/");
    295             locations.add("/usr/lib/josm/");
    296         }
     283        locations.addAll(PlatformManager.getPlatform().getPossiblePreferenceDirs());
    297284        return locations;
    298285    }
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r14120 r14144  
    1818import java.util.stream.Collectors;
    1919
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.command.AddCommand;
    2221import org.openstreetmap.josm.command.ChangeCommand;
     
    10461045     *
    10471046     * @param nodes the list of nodes representing the polygon
    1048      * @param projection the projection to use for the calculation, {@code null} defaults to {@link Main#getProjection()}
     1047     * @param projection the projection to use for the calculation, {@code null} defaults to {@link ProjectionRegistry#getProjection()}
    10491048     * @return area and perimeter
    10501049     * @since 13638 (signature)
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r13691 r14144  
    1616import java.security.cert.X509Certificate;
    1717import java.text.DateFormat;
     18import java.util.Collection;
     19import java.util.Collections;
    1820import java.util.Date;
    1921import java.util.List;
     
    369371        return file;
    370372    }
     373
     374    /**
     375     * Returns a set of possible platform specific directories where resources could be stored.
     376     * @return A set of possible platform specific directories where resources could be stored.
     377     * @since 14144
     378     */
     379    default Collection<String> getPossiblePreferenceDirs() {
     380        return Collections.emptyList();
     381    }
    371382}
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r13695 r14144  
    2424import java.security.cert.X509Certificate;
    2525import java.util.Arrays;
     26import java.util.Collection;
     27import java.util.HashSet;
    2628import java.util.Locale;
     29import java.util.Set;
    2730import java.util.concurrent.ExecutionException;
    2831
     
    419422        return null;
    420423    }
     424
     425    @Override
     426    public Collection<String> getPossiblePreferenceDirs() {
     427        Set<String> locations = new HashSet<>();
     428        locations.add("/usr/local/share/josm/");
     429        locations.add("/usr/local/lib/josm/");
     430        locations.add("/usr/share/josm/");
     431        locations.add("/usr/lib/josm/");
     432        return locations;
     433    }
    421434}
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r13791 r14144  
    6565import java.util.Collection;
    6666import java.util.Enumeration;
     67import java.util.HashSet;
    6768import java.util.List;
    6869import java.util.Locale;
    6970import java.util.Properties;
     71import java.util.Set;
    7072import java.util.concurrent.ExecutionException;
    7173import java.util.concurrent.TimeUnit;
     
    781783        return file;
    782784    }
     785
     786    @Override
     787    public Collection<String> getPossiblePreferenceDirs() {
     788        Set<String> locations = new HashSet<>();
     789        String appdata = getSystemEnv("APPDATA");
     790        if (appdata != null && getSystemEnv("ALLUSERSPROFILE") != null
     791                && appdata.lastIndexOf(File.separator) != -1) {
     792            appdata = appdata.substring(appdata.lastIndexOf(File.separator));
     793            locations.add(new File(new File(getSystemEnv("ALLUSERSPROFILE"), appdata), "JOSM").getPath());
     794        }
     795        return locations;
     796    }
    783797}
Note: See TracChangeset for help on using the changeset viewer.