Ignore:
Timestamp:
2017-09-11T20:43:41+02:00 (7 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/gui
Files:
5 edited

Legend:

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

    r12821 r12825  
    8888import org.openstreetmap.josm.data.osm.UserInfo;
    8989import org.openstreetmap.josm.data.osm.search.SearchMode;
     90import org.openstreetmap.josm.data.preferences.sources.SourceType;
    9091import org.openstreetmap.josm.data.projection.ProjectionCLI;
    9192import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileSource;
     
    9394import org.openstreetmap.josm.data.projection.datum.NTV2Proj4DirGridShiftFileSource;
    9495import org.openstreetmap.josm.data.validation.OsmValidator;
     96import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    9597import org.openstreetmap.josm.gui.ProgramArguments.Option;
    9698import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor;
     
    110112import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    111113import org.openstreetmap.josm.gui.layer.TMSLayer;
     114import org.openstreetmap.josm.gui.mappaint.loader.MapPaintStyleLoader;
    112115import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
    113116import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     
    126129import org.openstreetmap.josm.io.CertificateAmendment;
    127130import org.openstreetmap.josm.io.DefaultProxySelector;
     131import org.openstreetmap.josm.io.FileWatcher;
    128132import org.openstreetmap.josm.io.MessageNotifier;
    129133import org.openstreetmap.josm.io.OnlineResource;
     
    10941098        MessageNotifier.setNotifierCallback(MainApplication::notifyNewMessages);
    10951099        DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback);
     1100        FileWatcher.registerLoader(SourceType.MAP_PAINT_STYLE, MapPaintStyleLoader::reloadStyle);
     1101        FileWatcher.registerLoader(SourceType.TAGCHECKER_RULE, MapCSSTagChecker::reloadRule);
    10961102        OsmUrlToBounds.setMapSizeSupplier(() -> {
    10971103            if (isDisplayingMapView()) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r12651 r12825  
    301301        if (Main.pref.getBoolean("mappaint.auto_reload_local_styles", true) && source.isLocal()) {
    302302            try {
    303                 Main.fileWatcher.registerStyleSource(source);
     303                Main.fileWatcher.registerSource(source);
    304304            } catch (IOException | IllegalStateException | IllegalArgumentException e) {
    305305                Logging.error(e);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java

    r12649 r12825  
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2323import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
     24import org.openstreetmap.josm.data.preferences.sources.SourceType;
    2425import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    2526import org.openstreetmap.josm.io.CachedFile;
     
    7071     */
    7172    public StyleSource(String url, String name, String title) {
    72         super(url, name, title, true);
     73        super(SourceType.MAP_PAINT_STYLE, url, name, title, true);
    7374    }
    7475
  • trunk/src/org/openstreetmap/josm/gui/mappaint/loader/MapPaintStyleLoader.java

    r12651 r12825  
    66import java.util.ArrayList;
    77import java.util.Collection;
     8import java.util.Collections;
    89import java.util.List;
    910
     11import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
    1012import org.openstreetmap.josm.gui.MainApplication;
    1113import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    6769        MainApplication.worker.submit(new MapPaintStyleLoader(toReload));
    6870    }
     71
     72    /**
     73     * Reload style.
     74     * @param style {@link StyleSource} to reload
     75     * @throws IllegalArgumentException if {@code style} is not a {@code StyleSource} instance
     76     * @since 12825
     77     */
     78    public static void reloadStyle(SourceEntry style) {
     79        if (style instanceof StyleSource) {
     80            MainApplication.worker.submit(new MapPaintStyleLoader(Collections.singleton((StyleSource) style)));
     81        } else {
     82            throw new IllegalArgumentException(style + " is not a StyleSource");
     83        }
     84    }
    6985}
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r12649 r12825  
    741741            if (sources == null) return;
    742742            for (ExtendedSourceEntry info: sources) {
    743                 data.add(new SourceEntry(info.url, info.name, info.getDisplayName(), true));
     743                data.add(new SourceEntry(info.type, info.url, info.name, info.getDisplayName(), true));
    744744            }
    745745            fireTableDataChanged();
     
    969969                    active = editEntryDialog.active();
    970970                }
    971                 final SourceEntry entry = new SourceEntry(
     971                final SourceEntry entry = new SourceEntry(sourceType,
    972972                        editEntryDialog.getURL(),
    973973                        null, editEntryDialog.getTitle(), active);
     
    15091509                        Matcher m = Pattern.compile("^(.+);(.+)$").matcher(line);
    15101510                        if (m.matches()) {
    1511                             last = new ExtendedSourceEntry(m.group(1), m.group(2));
     1511                            last = new ExtendedSourceEntry(sourceType, m.group(1), m.group(2));
    15121512                            sources.add(last);
    15131513                        } else {
Note: See TracChangeset for help on using the changeset viewer.