Ignore:
Timestamp:
2017-09-13T23:24:50+02:00 (2 years ago)
Author:
bastiK
Message:

see #15229 - use Config.getPref() wherever possible

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/GuiSizesHelper.java

    r12682 r12846  
    66import java.awt.Toolkit;
    77
    8 import org.openstreetmap.josm.Main;
     8import org.openstreetmap.josm.spi.preferences.Config;
    99
    1010/**
     
    3232            synchronized (GuiSizesHelper.class) {
    3333                if (screenDPI == -1) {
    34                     float scalePref = (float) Main.pref.getDouble("gui.scale", 1.0);
     34                    float scalePref = (float) Config.getPref().getDouble("gui.scale", 1.0);
    3535                    if (scalePref != 0) {
    3636                        screenDPI = 96f * scalePref;
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r12841 r12846  
    3636import org.openstreetmap.josm.io.UTFInputStreamReader;
    3737import org.openstreetmap.josm.io.auth.DefaultAuthenticator;
     38import org.openstreetmap.josm.spi.preferences.Config;
    3839
    3940/**
     
    4546    private URL url;
    4647    private final String requestMethod;
    47     private int connectTimeout = (int) TimeUnit.SECONDS.toMillis(Main.pref.getInt("socket.timeout.connect", 15));
    48     private int readTimeout = (int) TimeUnit.SECONDS.toMillis(Main.pref.getInt("socket.timeout.read", 30));
     48    private int connectTimeout = (int) TimeUnit.SECONDS.toMillis(Config.getPref().getInt("socket.timeout.connect", 15));
     49    private int readTimeout = (int) TimeUnit.SECONDS.toMillis(Config.getPref().getInt("socket.timeout.read", 30));
    4950    private byte[] requestBody;
    5051    private long ifModifiedSince;
    5152    private final Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    52     private int maxRedirects = Main.pref.getInt("socket.maxredirects", 5);
     53    private int maxRedirects = Config.getPref().getInt("socket.maxredirects", 5);
    5354    private boolean useCache;
    5455    private String reasonForRequest;
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r12841 r12846  
    7272import org.openstreetmap.josm.io.CachedFile;
    7373import org.openstreetmap.josm.plugins.PluginHandler;
     74import org.openstreetmap.josm.spi.preferences.Config;
    7475import org.w3c.dom.Element;
    7576import org.w3c.dom.Node;
     
    122123    public enum ImageSizes {
    123124        /** SMALL_ICON value of an Action */
    124         SMALLICON(Main.pref.getInt("iconsize.smallicon", 16)),
     125        SMALLICON(Config.getPref().getInt("iconsize.smallicon", 16)),
    125126        /** LARGE_ICON_KEY value of an Action */
    126         LARGEICON(Main.pref.getInt("iconsize.largeicon", 24)),
     127        LARGEICON(Config.getPref().getInt("iconsize.largeicon", 24)),
    127128        /** map icon */
    128         MAP(Main.pref.getInt("iconsize.map", 16)),
     129        MAP(Config.getPref().getInt("iconsize.map", 16)),
    129130        /** map icon maximum size */
    130         MAPMAX(Main.pref.getInt("iconsize.mapmax", 48)),
     131        MAPMAX(Config.getPref().getInt("iconsize.mapmax", 48)),
    131132        /** cursor icon size */
    132         CURSOR(Main.pref.getInt("iconsize.cursor", 32)),
     133        CURSOR(Config.getPref().getInt("iconsize.cursor", 32)),
    133134        /** cursor overlay icon size */
    134135        CURSOROVERLAY(CURSOR),
     
    142143         * @since 8323
    143144         */
    144         LAYER(Main.pref.getInt("iconsize.layer", 16)),
     145        LAYER(Config.getPref().getInt("iconsize.layer", 16)),
    145146        /** Toolbar button icon size
    146147         * @since 9253
     
    150151         * @since 9253
    151152         */
    152         SIDEBUTTON(Main.pref.getInt("iconsize.sidebutton", 20)),
     153        SIDEBUTTON(Config.getPref().getInt("iconsize.sidebutton", 20)),
    153154        /** Settings tab icon size
    154155         * @since 9253
    155156         */
    156         SETTINGS_TAB(Main.pref.getInt("iconsize.settingstab", 48)),
     157        SETTINGS_TAB(Config.getPref().getInt("iconsize.settingstab", 48)),
    157158        /**
    158159         * The default image size
    159160         * @since 9705
    160161         */
    161         DEFAULT(Main.pref.getInt("iconsize.default", 24)),
     162        DEFAULT(Config.getPref().getInt("iconsize.default", 24)),
    162163        /**
    163164         * Splash dialog logo size
     
    10181019                "https://wiki.openstreetmap.org/wiki/File:"
    10191020                );
    1020         final Collection<String> baseUrls = Main.pref.getList("image-provider.wiki.urls", defaultBaseUrls);
     1021        final Collection<String> baseUrls = Config.getPref().getList("image-provider.wiki.urls", defaultBaseUrls);
    10211022
    10221023        final String fn = name.substring(name.lastIndexOf('/') + 1);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r12788 r12846  
    1919import java.util.List;
    2020
    21 import org.openstreetmap.josm.Main;
    2221import org.openstreetmap.josm.data.projection.datum.NTV2Proj4DirGridShiftFileSource;
    2322import org.openstreetmap.josm.io.CertificateAmendment.CertAmend;
     23import org.openstreetmap.josm.spi.preferences.Config;
    2424import org.openstreetmap.josm.tools.date.DateUtils;
    2525
     
    314314            String version = Utils.getJavaLatestVersion();
    315315            callback.askUpdateJava(version != null ? version : "latest",
    316                     Main.pref.get("java.update.url", "https://www.java.com/download"),
     316                    Config.getPref().get("java.update.url", "https://www.java.com/download"),
    317317                    DateUtils.getDateFormat(DateFormat.MEDIUM).format(expiration), false);
    318318        }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r12841 r12846  
    2727import org.openstreetmap.josm.Main;
    2828import org.openstreetmap.josm.io.CertificateAmendment.CertAmend;
     29import org.openstreetmap.josm.spi.preferences.Config;
    2930
    3031/**
     
    5152    @Override
    5253    public void openUrl(String url) throws IOException {
    53         for (String program : Main.pref.getList("browser.unix",
     54        for (String program : Config.getPref().getList("browser.unix",
    5455                Arrays.asList("xdg-open", "#DESKTOP#", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"))) {
    5556            try {
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r12776 r12846  
    6969import org.openstreetmap.josm.data.Preferences;
    7070import org.openstreetmap.josm.io.CertificateAmendment.CertAmend;
     71import org.openstreetmap.josm.spi.preferences.Config;
    7172
    7273/**
     
    501502     */
    502503    protected void extendFontconfig(String templateFileName) {
    503         String customFontconfigFile = Main.pref.get("fontconfig.properties", null);
     504        String customFontconfigFile = Config.getPref().get("fontconfig.properties", null);
    504505        if (customFontconfigFile != null) {
    505506            Utils.updateSystemProperty("sun.awt.fontconfig", customFontconfigFile);
    506507            return;
    507508        }
    508         if (!Main.pref.getBoolean("font.extended-unicode", true))
     509        if (!Config.getPref().getBoolean("font.extended-unicode", true))
    509510            return;
    510511
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r12841 r12846  
    2323
    2424import org.openstreetmap.josm.Main;
     25import org.openstreetmap.josm.spi.preferences.Config;
    2526
    2627/**
     
    170171    // create a shortcut object from an string as saved in the preferences
    171172    private Shortcut(String prefString) {
    172         List<String> s = new ArrayList<>(Main.pref.getList(prefString));
     173        List<String> s = new ArrayList<>(Config.getPref().getList(prefString));
    173174        this.shortText = prefString.substring(15);
    174175        this.longText = s.get(0);
     
    182183
    183184    private void saveDefault() {
    184         Main.pref.getList("shortcut.entry."+shortText, Arrays.asList(longText,
     185        Config.getPref().getList("shortcut.entry."+shortText, Arrays.asList(longText,
    185186            String.valueOf(requestedKey), String.valueOf(requestedGroup), String.valueOf(requestedKey),
    186187            String.valueOf(getGroupModifier(requestedGroup)), String.valueOf(true), String.valueOf(false)));
     
    190191    private boolean save() {
    191192        if (isAutomatic() || isReset() || !isAssignedUser()) {
    192             return Main.pref.putList("shortcut.entry."+shortText, null);
     193            return Config.getPref().putList("shortcut.entry."+shortText, null);
    193194        } else {
    194             return Main.pref.putList("shortcut.entry."+shortText, Arrays.asList(longText,
     195            return Config.getPref().putList("shortcut.entry."+shortText, Arrays.asList(longText,
    195196                String.valueOf(requestedKey), String.valueOf(requestedGroup), String.valueOf(assignedKey),
    196197                String.valueOf(assignedModifier), String.valueOf(assignedDefault), String.valueOf(assignedUser)));
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r12841 r12846  
    1212import java.util.regex.Pattern;
    1313
    14 import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.spi.preferences.Config;
    1515
    1616/**
     
    2020
    2121    // properties need JOSM restart to apply, modified rarely enough
    22     private static final int MAX_KEY_LENGTH = Main.pref.getInt("tags.paste.max-key-length", 50);
    23     private static final int MAX_KEY_COUNT = Main.pref.getInt("tags.paste.max-key-count", 30);
    24     private static final String KEY_PATTERN = Main.pref.get("tags.paste.tag-pattern", "[0-9a-zA-Z:_]*");
     22    private static final int MAX_KEY_LENGTH = Config.getPref().getInt("tags.paste.max-key-length", 50);
     23    private static final int MAX_KEY_COUNT = Config.getPref().getInt("tags.paste.max-key-count", 30);
     24    private static final String KEY_PATTERN = Config.getPref().get("tags.paste.tag-pattern", "[0-9a-zA-Z:_]*");
    2525    private static final int MAX_VALUE_LENGTH = 255;
    2626
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r12841 r12846  
    7070
    7171import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    72 import org.openstreetmap.josm.Main;
    7372import org.openstreetmap.josm.io.Compression;
     73import org.openstreetmap.josm.spi.preferences.Config;
    7474import org.w3c.dom.Document;
    7575import org.xml.sax.InputSource;
     
    12461246     */
    12471247    public static ForkJoinPool newForkJoinPool(String pref, final String nameFormat, final int threadPriority) {
    1248         int noThreads = Main.pref.getInt(pref, Runtime.getRuntime().availableProcessors());
     1248        int noThreads = Config.getPref().getInt(pref, Runtime.getRuntime().availableProcessors());
    12491249        return new ForkJoinPool(noThreads, new ForkJoinPool.ForkJoinWorkerThreadFactory() {
    12501250            final AtomicLong count = new AtomicLong(0);
     
    16861686    public static String getJavaLatestVersion() {
    16871687        try {
    1688             return HttpClient.create(
    1689                     new URL(Main.pref.get("java.baseline.version.url", "http://javadl-esd-secure.oracle.com/update/baseline.version")))
     1688            return HttpClient.create(new URL(Config.getPref().get("java.baseline.version.url", "http://javadl-esd-secure.oracle.com/update/baseline.version")))
    16901689                    .connect().fetchContent().split("\n")[0];
    16911690        } catch (IOException e) {
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r9168 r12846  
    77
    88import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.spi.preferences.Config;
    910import org.openstreetmap.josm.tools.LanguageInfo.LocaleType;
    1011
     
    3031     */
    3132    public WikiReader() {
    32         this(Main.pref.get("help.baseurl", Main.getJOSMWebsite()));
     33        this(Config.getPref().get("help.baseurl", Main.getJOSMWebsite()));
    3334    }
    3435
Note: See TracChangeset for help on using the changeset viewer.