Ignore:
Timestamp:
2017-08-24T15:54:00+02:00 (2 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/io
Files:
6 edited

Legend:

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

    r12620 r12634  
    1414import java.util.HashMap;
    1515import java.util.Map;
     16import java.util.concurrent.Executors;
    1617
    17 import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.data.validation.OsmValidator;
    1919import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
     
    2424import org.openstreetmap.josm.tools.CheckParameterUtil;
    2525import org.openstreetmap.josm.tools.Logging;
     26import org.openstreetmap.josm.tools.Utils;
    2627
    2728/**
     
    140141                    if (style != null) {
    141142                        Logging.info("Map style "+style.getDisplayString()+" has been modified. Reloading style...");
    142                         Main.worker.submit(new MapPaintStyleLoader(Collections.singleton(style)));
     143                        Executors.newSingleThreadExecutor(Utils.newThreadFactory("mapstyle-reload-%d", Thread.NORM_PRIORITY)).submit(
     144                                new MapPaintStyleLoader(Collections.singleton(style)));
    143145                    } else if (rule != null) {
    144146                        Logging.info("Validator rule "+rule.getDisplayString()+" has been modified. Reloading rule...");
  • trunk/src/org/openstreetmap/josm/io/OsmConnection.java

    r12620 r12634  
    121121            }
    122122            final Runnable authTask = new FutureTask<>(() -> {
    123                 // Concerning Utils.newDirectExecutor: Main.worker cannot be used since this connection is already
    124                 // executed via Main.worker. The OAuth connections would block otherwise.
     123                // Concerning Utils.newDirectExecutor: Main worker cannot be used since this connection is already
     124                // executed via main worker. The OAuth connections would block otherwise.
    125125                final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard(
    126126                        Main.parent, apiUrl.toExternalForm(), Utils.newDirectExecutor());
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r12630 r12634  
    145145                        Future<?> future = osmTask.download(newLayer, new Bounds(minlat, minlon, maxlat, maxlon),
    146146                                null /* let the task manage the progress monitor */);
    147                         Main.worker.submit(new PostDownloadHandler(osmTask, future));
     147                        MainApplication.worker.submit(new PostDownloadHandler(osmTask, future));
    148148                    }
    149149                }
     
    196196            try {
    197197                final SearchCompiler.Match search = SearchCompiler.compile(args.get("search"));
    198                 Main.worker.submit(() -> {
     198                MainApplication.worker.submit(() -> {
    199199                    final DataSet ds = Main.getLayerManager().getEditDataSet();
    200200                    final Collection<OsmPrimitive> filteredPrimitives = SubclassFilteredCollection.filter(ds.allPrimitives(), search);
     
    214214        // add changeset tags after download if necessary
    215215        if (args.containsKey("changeset_comment") || args.containsKey("changeset_source")) {
    216             Main.worker.submit(() -> {
     216            MainApplication.worker.submit(() -> {
    217217                if (Main.getLayerManager().getEditDataSet() != null) {
    218218                    if (args.containsKey("changeset_comment")) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadDataHandler.java

    r9990 r12634  
    77import java.nio.charset.StandardCharsets;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
    1110import org.openstreetmap.josm.data.osm.DataSet;
     11import org.openstreetmap.josm.gui.MainApplication;
    1212import org.openstreetmap.josm.io.IllegalDataException;
    1313import org.openstreetmap.josm.io.OsmReader;
     
    4040    @Override
    4141    protected void handleRequest() throws RequestHandlerErrorException {
    42         Main.worker.submit(new LoadDataTask(isLoadInNewLayer(), dataSet, args.get("layer_name")));
     42        MainApplication.worker.submit(new LoadDataTask(isLoadInNewLayer(), dataSet, args.get("layer_name")));
    4343    }
    4444
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java

    r12620 r12634  
    1414import org.openstreetmap.josm.data.osm.PrimitiveId;
    1515import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     16import org.openstreetmap.josm.gui.MainApplication;
    1617import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask;
    1718import org.openstreetmap.josm.gui.util.GuiHelper;
     
    6869            final DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask(
    6970                    newLayer, ps, referrers, relationMembers, args.get("layer_name"), null);
    70             Main.worker.submit(task);
    71             Main.worker.submit(() -> {
     71            MainApplication.worker.submit(task);
     72            MainApplication.worker.submit(() -> {
    7273                final List<PrimitiveId> downloaded = task.getDownloadedId();
    7374                final DataSet ds = Main.getLayerManager().getEditDataSet();
  • trunk/src/org/openstreetmap/josm/io/session/SessionImporter.java

    r8404 r12634  
    77import java.io.IOException;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1110import org.openstreetmap.josm.actions.SessionLoadAction.Loader;
     11import org.openstreetmap.josm.gui.MainApplication;
    1212import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1313import org.openstreetmap.josm.io.FileImporter;
     
    3737    public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
    3838        boolean zip = Utils.hasExtension(file, "joz");
    39         Main.worker.submit(new Loader(file, zip));
     39        MainApplication.worker.submit(new Loader(file, zip));
    4040    }
    4141}
Note: See TracChangeset for help on using the changeset viewer.