Changeset 14128 in josm for trunk


Ignore:
Timestamp:
2018-08-11T19:19:44+02:00 (6 years ago)
Author:
Don-vip
Message:

see #15229 - deprecate Main.fileWatcher

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

Legend:

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

    r14125 r14128  
    7777    /**
    7878     * The file watcher service.
    79      */
    80     public static final FileWatcher fileWatcher = new FileWatcher();
     79     * @deprecated Use {@link FileWatcher#getDefaultInstance}
     80     */
     81    @Deprecated
     82    public static final FileWatcher fileWatcher = FileWatcher.getDefaultInstance();
    8183
    8284    /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r13810 r14128  
    2929import java.util.regex.Pattern;
    3030
    31 import org.openstreetmap.josm.Main;
    3231import org.openstreetmap.josm.command.ChangePropertyCommand;
    3332import org.openstreetmap.josm.command.ChangePropertyKeyCommand;
     
    6261import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.TokenMgrError;
    6362import org.openstreetmap.josm.io.CachedFile;
     63import org.openstreetmap.josm.io.FileWatcher;
    6464import org.openstreetmap.josm.io.IllegalDataException;
    6565import org.openstreetmap.josm.io.UTFInputStreamReader;
     
    762762                addMapCSS(i);
    763763                if (Config.getPref().getBoolean("validator.auto_reload_local_rules", true) && source.isLocal()) {
    764                     Main.fileWatcher.registerSource(source);
     764                    FileWatcher.getDefaultInstance().registerSource(source);
    765765                }
    766766            } catch (IOException | IllegalStateException | IllegalArgumentException ex) {
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r14125 r14128  
    410410    protected List<InitializationTask> beforeInitializationTasks() {
    411411        return Arrays.asList(
    412             new InitializationTask(tr("Starting file watcher"), fileWatcher::start),
     412            new InitializationTask(tr("Starting file watcher"), FileWatcher.getDefaultInstance()::start),
    413413            new InitializationTask(tr("Executing platform startup hook"), () -> platform.startupHook(MainApplication::askUpdateJava)),
    414414            new InitializationTask(tr("Building main menu"), this::initializeMainWindow),
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r13845 r14128  
    1515import javax.swing.SwingUtilities;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.data.coor.LatLon;
    1918import org.openstreetmap.josm.data.osm.DataSet;
     
    2726import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    2827import org.openstreetmap.josm.io.CachedFile;
     28import org.openstreetmap.josm.io.FileWatcher;
    2929import org.openstreetmap.josm.spi.preferences.Config;
    3030import org.openstreetmap.josm.tools.ImageProvider;
     
    327327        if (Config.getPref().getBoolean("mappaint.auto_reload_local_styles", true) && source.isLocal()) {
    328328            try {
    329                 Main.fileWatcher.registerSource(source);
     329                FileWatcher.getDefaultInstance().registerSource(source);
    330330            } catch (IOException | IllegalStateException | IllegalArgumentException e) {
    331331                Logging.error(e);
  • trunk/src/org/openstreetmap/josm/io/FileWatcher.java

    r13173 r14128  
    3434    private static final Map<SourceType, Consumer<SourceEntry>> loaderMap = new EnumMap<>(SourceType.class);
    3535    private final Map<Path, SourceEntry> sourceMap = new HashMap<>();
     36
     37    private static class InstanceHolder {
     38        static final FileWatcher INSTANCE = new FileWatcher();
     39    }
     40
     41    /**
     42     * Returns the default instance.
     43     * @return the default instance
     44     * @since 14128
     45     */
     46    public static FileWatcher getDefaultInstance() {
     47        return InstanceHolder.INSTANCE;
     48    }
    3649
    3750    /**
Note: See TracChangeset for help on using the changeset viewer.