Ignore:
Timestamp:
2017-08-24T15:54:00+02:00 (3 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate Main.worker, replace it by gui.MainApplication.worker + code refactoring to make sure only editor packages use it

Location:
trunk/src/org/openstreetmap/josm/data
Files:
1 added
2 edited

Legend:

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

    r12620 r12634  
    235235
    236236    /**
     237     * Constructs a new {@code Preferences}.
     238     */
     239    public Preferences() {
     240        // Default constructor
     241    }
     242
     243    /**
     244     * Constructs a new {@code Preferences} from an existing instance.
     245     * @param pref existing preferences to copy
     246     * @since 12634
     247     */
     248    public Preferences(Preferences pref) {
     249        settingsMap.putAll(pref.settingsMap);
     250        defaultsMap.putAll(pref.defaultsMap);
     251        colornames.putAll(pref.colornames);
     252    }
     253
     254    /**
    237255     * Adds a new preferences listener.
    238256     * @param listener The listener to add
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java

    r12620 r12634  
    1616import java.util.Set;
    1717import java.util.TreeSet;
     18import java.util.concurrent.ExecutorService;
    1819
    1920import org.openstreetmap.josm.Main;
     
    3334public class ImageryLayerInfo {
    3435
     36    /** Unique instance */
    3537    public static final ImageryLayerInfo instance = new ImageryLayerInfo();
    3638    /** List of all usable layers */
     
    6163    }
    6264
     65    /**
     66     * Constructs a new {@code ImageryLayerInfo} from an existing one.
     67     * @param info info to copy
     68     */
    6369    public ImageryLayerInfo(ImageryLayerInfo info) {
    6470        layers.addAll(info.layers);
    6571    }
    6672
     73    /**
     74     * Clear the lists of layers.
     75     */
    6776    public void clear() {
    6877        layers.clear();
     
    8897            Collections.sort(layers);
    8998        }
    90         loadDefaults(false, true, fastFail);
     99        loadDefaults(false, null, fastFail);
    91100    }
    92101
     
    95104     *
    96105     * The data is downloaded from the JOSM website (or loaded from cache).
    97      * Entries marked as "default" are added to the user selection, if not
    98      * already present.
     106     * Entries marked as "default" are added to the user selection, if not already present.
    99107     *
    100108     * @param clearCache if true, clear the cache and start a fresh download.
    101      * @param quiet whether not the loading should be performed using a {@link PleaseWaitRunnable} in the background
     109     * @param worker executor service which will perform the loading. If null, it should be performed using a {@link PleaseWaitRunnable} in the background
    102110     * @param fastFail whether opening HTTP connections should fail fast, see {@link ImageryReader#setFastFail(boolean)}
    103      */
    104     public void loadDefaults(boolean clearCache, boolean quiet, boolean fastFail) {
     111     * @since 12634
     112     */
     113    public void loadDefaults(boolean clearCache, ExecutorService worker, boolean fastFail) {
    105114        final DefaultEntryLoader loader = new DefaultEntryLoader(clearCache, fastFail);
    106         if (quiet) {
     115        if (worker == null) {
    107116            loader.realRun();
    108117            loader.finish();
    109118        } else {
    110             Main.worker.execute(new DefaultEntryLoader(clearCache, fastFail));
     119            worker.execute(loader);
    111120        }
    112121    }
     
    327336    }
    328337
     338    /**
     339     * Add a new imagery entry.
     340     * @param info imagery entry to add
     341     */
    329342    public void add(ImageryInfo info) {
    330343        layers.add(info);
    331344    }
    332345
     346    /**
     347     * Remove an imagery entry.
     348     * @param info imagery entry to remove
     349     */
    333350    public void remove(ImageryInfo info) {
    334351        layers.remove(info);
    335352    }
    336353
     354    /**
     355     * Save the list of imagery entries to preferences.
     356     */
    337357    public void save() {
    338358        List<ImageryPreferenceEntry> entries = new ArrayList<>();
Note: See TracChangeset for help on using the changeset viewer.