- Timestamp:
- 2017-08-24T15:54:00+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 90 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r12633 r12634 59 59 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 60 60 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 61 import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;62 61 import org.openstreetmap.josm.gui.util.GuiHelper; 63 62 import org.openstreetmap.josm.gui.util.RedirectInputMap; … … 123 122 /** 124 123 * The worker thread slave. This is for executing all long and intensive 125 * calculations. The executed runnables are guaranteed to be executed separately 126 * and sequential. 127 */ 128 public static final ExecutorService worker = new ProgressMonitorExecutor("main-worker-%d", Thread.NORM_PRIORITY); 124 * calculations. The executed runnables are guaranteed to be executed separately and sequential. 125 * @deprecated use {@link MainApplication#worker} instead 126 */ 127 @Deprecated 128 public static final ExecutorService worker = MainApplication.worker; 129 129 130 130 /** … … 855 855 protected void shutdown() { 856 856 if (!GraphicsEnvironment.isHeadless()) { 857 worker.shutdown();858 857 ImageProvider.shutdown(false); 859 858 JCSCacheManager.shutdown(); … … 867 866 } 868 867 if (!GraphicsEnvironment.isHeadless()) { 869 worker.shutdownNow();870 868 ImageProvider.shutdown(true); 871 869 } -
trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java
r12581 r12634 19 19 import org.openstreetmap.josm.data.osm.UserInfo; 20 20 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 22 23 import org.openstreetmap.josm.gui.io.CloseChangesetDialog; … … 57 58 @Override 58 59 public void actionPerformed(ActionEvent e) { 59 Main .worker.submit(new DownloadOpenChangesetsTask());60 MainApplication.worker.submit(new DownloadOpenChangesetsTask()); 60 61 } 61 62 … … 80 81 Collection<Changeset> changesetsToClose = dialog.getSelectedChangesets(); 81 82 CloseChangesetTask closeChangesetTask = new CloseChangesetTask(changesetsToClose); 82 Main .worker.submit(closeChangesetTask);83 MainApplication.worker.submit(closeChangesetTask); 83 84 } 84 85 -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r12630 r12634 161 161 if (multipolygonRelation != null) { 162 162 if (!multipolygonRelation.isNew() && multipolygonRelation.isIncomplete()) { 163 Main .worker.submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), Main.getLayerManager().getEditLayer()));163 MainApplication.worker.submit(new DownloadRelationTask(Collections.singleton(multipolygonRelation), Main.getLayerManager().getEditLayer())); 164 164 } else if (multipolygonRelation.hasIncompleteMembers()) { 165 Main .worker.submit(new DownloadRelationMemberTask(multipolygonRelation,165 MainApplication.worker.submit(new DownloadRelationMemberTask(multipolygonRelation, 166 166 DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(Collections.singleton(multipolygonRelation)), 167 167 Main.getLayerManager().getEditLayer())); … … 169 169 } 170 170 // create/update multipolygon relation 171 Main .worker.submit(new CreateUpdateMultipolygonTask(selectedWays, multipolygonRelation));171 MainApplication.worker.submit(new CreateUpdateMultipolygonTask(selectedWays, multipolygonRelation)); 172 172 } 173 173 -
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r12630 r12634 83 83 task.setZoomAfterDownload(zoom && !dialog.isDownloadGpxData() && !dialog.isDownloadNotes()); 84 84 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null); 85 Main .worker.submit(new PostDownloadHandler(task, future));85 MainApplication.worker.submit(new PostDownloadHandler(task, future)); 86 86 if (zoom) { 87 87 tasks.add(new Pair<>(task, future)); … … 93 93 task.setZoomAfterDownload(zoom && !dialog.isDownloadOsmData() && !dialog.isDownloadNotes()); 94 94 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null); 95 Main .worker.submit(new PostDownloadHandler(task, future));95 MainApplication.worker.submit(new PostDownloadHandler(task, future)); 96 96 if (zoom) { 97 97 tasks.add(new Pair<>(task, future)); … … 103 103 task.setZoomAfterDownload(zoom && !dialog.isDownloadOsmData() && !dialog.isDownloadGpxData()); 104 104 Future<?> future = task.download(false, area, null); 105 Main .worker.submit(new PostDownloadHandler(task, future));105 MainApplication.worker.submit(new PostDownloadHandler(task, future)); 106 106 if (zoom) { 107 107 tasks.add(new Pair<>(task, future)); … … 110 110 111 111 if (zoom && tasks.size() > 1) { 112 Main .worker.submit(() -> {112 MainApplication.worker.submit(() -> { 113 113 ProjectionBounds bounds = null; 114 114 // Wait for completion of download jobs -
trunk/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java
r12630 r12634 48 48 task.setZoomAfterDownload(false); 49 49 Future<?> future = task.download(false, bounds, null); 50 Main .worker.submit(new PostDownloadHandler(task, future));50 MainApplication.worker.submit(new PostDownloadHandler(task, future)); 51 51 } 52 52 -
trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java
r12630 r12634 36 36 task.setZoomAfterDownload(false); 37 37 Future<?> future = task.download(bounds); 38 Main .worker.submit(new PostDownloadHandler(task, future));38 MainApplication.worker.submit(new PostDownloadHandler(task, future)); 39 39 } 40 40 -
trunk/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java
r11031 r12634 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.osm.PrimitiveId; 13 import org.openstreetmap.josm.gui.MainApplication; 13 14 import org.openstreetmap.josm.gui.download.DownloadObjectDialog; 14 15 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; … … 54 55 final DownloadPrimitivesWithReferrersTask task = 55 56 new DownloadPrimitivesWithReferrersTask(newLayer, ids, downloadReferrers, full, null, null); 56 Main .worker.submit(task);57 Main .worker.submit(() -> {57 MainApplication.worker.submit(task); 58 MainApplication.worker.submit(() -> { 58 59 final List<PrimitiveId> downloaded = task.getDownloadedId(); 59 60 if (downloaded != null) { -
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r10413 r12634 12 12 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 15 16 import org.openstreetmap.josm.tools.Shortcut; … … 45 46 if (children == null || children.isEmpty()) 46 47 return; 47 Main .worker.submit(new DownloadReferrersTask(targetLayer, children));48 MainApplication.worker.submit(new DownloadReferrersTask(targetLayer, children)); 48 49 } 49 50 -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r12620 r12634 18 18 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 19 19 import org.openstreetmap.josm.data.osm.event.SelectionEventManager; 20 import org.openstreetmap.josm.gui.MainApplication; 20 21 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 21 22 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; … … 273 274 274 275 protected static void waitFuture(final Future<?> future, final PleaseWaitProgressMonitor monitor) { 275 Main .worker.submit(() -> {276 MainApplication.worker.submit(() -> { 276 277 try { 277 278 future.get(); -
trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java
r12620 r12634 13 13 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 16 17 import org.openstreetmap.josm.gui.layer.Layer; … … 52 53 return null; 53 54 final Object actionName = getValue(NAME); 54 return Main .worker.submit(() -> {55 return MainApplication.worker.submit(() -> { 55 56 final long start = System.currentTimeMillis(); 56 57 boolean layerMerged = false; -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r12630 r12634 76 76 OpenFileTask task = new OpenFileTask(Arrays.asList(files), fc.getFileFilter()); 77 77 task.setRecordHistory(true); 78 Main .worker.submit(task);78 MainApplication.worker.submit(task); 79 79 } 80 80 … … 105 105 OpenFileTask task = new OpenFileTask(fileList, null); 106 106 task.setRecordHistory(recordHistory); 107 return Main .worker.submit(task);107 return MainApplication.worker.submit(task); 108 108 } 109 109 -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r12620 r12634 41 41 import org.openstreetmap.josm.gui.ExtendedDialog; 42 42 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 43 import org.openstreetmap.josm.gui.MainApplication; 43 44 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 44 45 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; … … 233 234 for (final DownloadTask task : tasks) { 234 235 try { 235 result.add(Main .worker.submit(new PostDownloadHandler(task, task.loadUrl(newLayer, url, monitor))));236 result.add(MainApplication.worker.submit(new PostDownloadHandler(task, task.loadUrl(newLayer, url, monitor)))); 236 237 } catch (IllegalArgumentException e) { 237 238 Logging.error(e); -
trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java
r12609 r12634 36 36 import org.openstreetmap.josm.data.preferences.BooleanProperty; 37 37 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.download.DownloadDialog; 39 40 import org.openstreetmap.josm.gui.download.OverpassQueryList; … … 118 119 new OverpassDownloadReader(area, OverpassServerPreference.getOverpassServer(), overpassQuery), 119 120 dialog.isNewLayerRequired(), area, null); 120 Main .worker.submit(new PostDownloadHandler(task, future, errorReporter));121 MainApplication.worker.submit(new PostDownloadHandler(task, future, errorReporter)); 121 122 } 122 123 -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r12630 r12634 61 61 File file = fc.getSelectedFile(); 62 62 boolean zip = Utils.hasExtension(file, "joz"); 63 Main .worker.submit(new Loader(file, zip));63 MainApplication.worker.submit(new Loader(file, zip)); 64 64 } 65 65 -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r11643 r12634 20 20 import org.openstreetmap.josm.data.osm.PrimitiveId; 21 21 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 22 import org.openstreetmap.josm.gui.MainApplication; 22 23 import org.openstreetmap.josm.gui.io.UpdatePrimitivesTask; 23 24 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 59 60 */ 60 61 public static void updatePrimitives(final Collection<OsmPrimitive> selection) { 61 Main .worker.submit(new UpdatePrimitivesTask(Main.getLayerManager().getEditLayer(), selection));62 MainApplication.worker.submit(new UpdatePrimitivesTask(Main.getLayerManager().getEditLayer(), selection)); 62 63 } 63 64 -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r12630 r12634 246 246 } 247 247 248 Main .worker.execute(248 MainApplication.worker.execute( 249 249 new UploadPrimitivesTask( 250 250 UploadDialog.getUploadDialog().getUploadStrategySpecification(), -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r11385 r12634 26 26 import org.openstreetmap.josm.data.osm.visitor.Visitor; 27 27 import org.openstreetmap.josm.gui.DefaultNameFormatter; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 29 30 import org.openstreetmap.josm.gui.io.UploadSelectionDialog; … … 160 161 // processPostParentChecker() 161 162 // 162 Main .worker.submit(new DeletedParentsChecker(layer, toUpload));163 MainApplication.worker.submit(new DeletedParentsChecker(layer, toUpload)); 163 164 } else { 164 165 processPostParentChecker(layer, toUpload); -
trunk/src/org/openstreetmap/josm/actions/ValidateAction.java
r12630 r12634 91 91 } 92 92 93 Main .worker.submit(new ValidationTask(tests, selection, lastSelection));93 MainApplication.worker.submit(new ValidationTask(tests, selection, lastSelection)); 94 94 } 95 95 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractChangesetDownloadTask.java
r12620 r12634 11 11 import javax.swing.SwingUtilities; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.Bounds; 15 14 import org.openstreetmap.josm.data.osm.Changeset; 16 15 import org.openstreetmap.josm.data.osm.ChangesetCache; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 119 119 * } 120 120 * } 121 * Main .worker.submit(runAfterTask);121 * MainApplication.worker.submit(runAfterTask); 122 122 * </pre> 123 123 * … … 125 125 */ 126 126 public final Future<?> download() { 127 return downloadTaskRunnable != null ? Main .worker.submit(downloadTaskRunnable) : null;127 return downloadTaskRunnable != null ? MainApplication.worker.submit(downloadTaskRunnable) : null; 128 128 } 129 129 130 130 @Override 131 131 public final Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) { 132 return downloadTaskRunnable != null ? Main .worker.submit(downloadTaskRunnable) : null;132 return downloadTaskRunnable != null ? MainApplication.worker.submit(downloadTaskRunnable) : null; 133 133 } 134 134 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r12630 r12634 75 75 // We need submit instead of execute so we can wait for it to finish and get the error 76 76 // message if necessary. If no one calls getErrorMessage() it just behaves like execute. 77 return Main .worker.submit(downloadTask);77 return MainApplication.worker.submit(downloadTask); 78 78 } 79 79 … … 99 99 // We need submit instead of execute so we can wait for it to finish and get the error 100 100 // message if necessary. If no one calls getErrorMessage() it just behaves like execute. 101 return Main .worker.submit(downloadTask);101 return MainApplication.worker.submit(downloadTask); 102 102 103 103 } else if (url.matches(PATTERN_TRACKPOINTS_BBOX)) { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java
r12630 r12634 60 60 final String url = OsmApi.getOsmApi().getBaseUrl() + "notes/" + id; 61 61 downloadTask = new DownloadRawUrlTask(new OsmServerLocationReader(url), progressMonitor); 62 return Main .worker.submit(downloadTask);62 return MainApplication.worker.submit(downloadTask); 63 63 } 64 64 … … 66 66 public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) { 67 67 downloadTask = new DownloadBoundingBoxTask(new BoundingBoxDownloader(downloadArea), progressMonitor); 68 return Main .worker.submit(downloadTask);68 return MainApplication.worker.submit(downloadTask); 69 69 } 70 70 … … 76 76 downloadTask = new DownloadRawUrlTask(new OsmServerLocationReader(url), progressMonitor); 77 77 } 78 return Main .worker.submit(downloadTask);78 return MainApplication.worker.submit(downloadTask); 79 79 } 80 80 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeCompressedTask.java
r10001 r12634 2 2 package org.openstreetmap.josm.actions.downloadtasks; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.util.concurrent.Future; 5 7 6 import static org.openstreetmap.josm.tools.I18n.tr;7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.data.osm.DataSet; 9 import org.openstreetmap.josm.gui.MainApplication; 10 10 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 11 11 import org.openstreetmap.josm.io.OsmServerLocationReader; … … 50 50 // Extract .osc.gz/bz/bz2 filename from URL to set the new layer name 51 51 extractOsmFilename("https?://.*/(.*\\.osc.(gz|bz2?))", url); 52 return Main .worker.submit(downloadTask);52 return MainApplication.worker.submit(downloadTask); 53 53 } 54 54 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java
r12630 r12634 77 77 // Extract .osc filename from URL to set the new layer name 78 78 extractOsmFilename("https?://.*/(.*\\.osc)", url); 79 return Main .worker.submit(downloadTask);79 return MainApplication.worker.submit(downloadTask); 80 80 } 81 81 … … 123 123 if (isCanceled()) return; 124 124 // Let's load all required history 125 Main .worker.submit(new HistoryLoaderAndListener(toLoad));125 MainApplication.worker.submit(new HistoryLoaderAndListener(toLoad)); 126 126 } catch (RejectedExecutionException e) { 127 127 rememberException(e); … … 200 200 // Some primitives still need to be loaded 201 201 // Let's load all required history 202 Main .worker.submit(new HistoryLoaderAndListener(toLoadNext));202 MainApplication.worker.submit(new HistoryLoaderAndListener(toLoadNext)); 203 203 } 204 204 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmCompressedTask.java
r10378 r12634 6 6 import java.util.concurrent.Future; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.data.Bounds; 10 9 import org.openstreetmap.josm.data.osm.DataSet; 10 import org.openstreetmap.josm.gui.MainApplication; 11 11 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 12 12 import org.openstreetmap.josm.io.OsmServerLocationReader; … … 61 61 // Extract .osm.gz/bz/bz2/zip filename from URL to set the new layer name 62 62 extractOsmFilename("https?://.*/(.*\\.osm.(gz|bz2?|zip))", url); 63 return Main .worker.submit(downloadTask);63 return MainApplication.worker.submit(downloadTask); 64 64 } 65 65 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmIdTask.java
r12284 r12634 9 9 import java.util.regex.Pattern; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 13 12 import org.openstreetmap.josm.data.osm.PrimitiveId; 14 13 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; 16 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 40 40 final DownloadPrimitivesWithReferrersTask downloadTask = new DownloadPrimitivesWithReferrersTask( 41 41 newLayer, Collections.singletonList(primitiveId), true, true, null, null); 42 return Main .worker.submit(downloadTask);42 return MainApplication.worker.submit(downloadTask); 43 43 } else { 44 44 throw new IllegalStateException("Failed to parse id from " + url); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r12630 r12634 116 116 * } 117 117 * } 118 * Main .worker.submit(runAfterTask);118 * MainApplication.worker.submit(runAfterTask); 119 119 * </pre> 120 120 * @param reader the reader used to parse OSM data (see {@link OsmServerReader#parseOsm}) … … 134 134 // We need submit instead of execute so we can wait for it to finish and get the error 135 135 // message if necessary. If no one calls getErrorMessage() it just behaves like execute. 136 return Main .worker.submit(downloadTask);136 return MainApplication.worker.submit(downloadTask); 137 137 } 138 138 … … 160 160 // Extract .osm filename from URL to set the new layer name 161 161 extractOsmFilename("https?://.*/(.*\\.osm)", newUrl); 162 return Main .worker.submit(downloadTask);162 return MainApplication.worker.submit(downloadTask); 163 163 } 164 164 … … 287 287 } 288 288 if (!primitivesToUpdate.isEmpty()) { 289 Main .worker.submit(new UpdatePrimitivesTask(layer, primitivesToUpdate));289 MainApplication.worker.submit(new UpdatePrimitivesTask(layer, primitivesToUpdate)); 290 290 } 291 291 layer.onPostDownloadFromServer(); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadSessionTask.java
r12620 r12634 12 12 import org.openstreetmap.josm.actions.SessionLoadAction.Loader; 13 13 import org.openstreetmap.josm.data.Bounds; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 15 16 import org.openstreetmap.josm.tools.HttpClient; … … 47 48 URL u = new URL(url); 48 49 loader = new Loader(HttpClient.create(u).connect().getContent(), u.toURI(), url.endsWith(".joz")); 49 return Main .worker.submit(loader);50 return MainApplication.worker.submit(loader); 50 51 } catch (URISyntaxException | IOException e) { 51 52 Logging.error(e); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTask.java
r9230 r12634 43 43 * } 44 44 * } 45 * Main .worker.submit(runAfterTask);45 * MainApplication.worker.submit(runAfterTask); 46 46 * </pre> 47 47 * -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java
r12620 r12634 29 29 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 30 30 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.Notification; 32 33 import org.openstreetmap.josm.gui.layer.Layer; … … 93 94 } 94 95 }); 95 return Main .worker.submit(new PostDownloadProcessor(osmData));96 return MainApplication.worker.submit(new PostDownloadProcessor(osmData)); 96 97 } 97 98 -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12630 r12634 603 603 // We need to do it like this as otherwise drawAction will see a double 604 604 // click and switch back to SelectMode 605 Main .worker.execute(() -> map.selectDrawTool(true));605 MainApplication.worker.execute(() -> map.selectDrawTool(true)); 606 606 return; 607 607 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
r12630 r12634 35 35 public void actionPerformed(ActionEvent e) { 36 36 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return; 37 Main .worker.submit(new DownloadRelationTask(relations, Main.getLayerManager().getEditLayer()));37 MainApplication.worker.submit(new DownloadRelationTask(relations, Main.getLayerManager().getEditLayer())); 38 38 } 39 39 -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r12630 r12634 51 51 public void actionPerformed(ActionEvent e) { 52 52 if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return; 53 Main .worker.submit(new DownloadRelationMemberTask(53 MainApplication.worker.submit(new DownloadRelationMemberTask( 54 54 relations, 55 55 incompleteMembers, -
trunk/src/org/openstreetmap/josm/actions/upload/UploadNotesTask.java
r12630 r12634 37 37 public void uploadNotes(NoteData noteData, ProgressMonitor progressMonitor) { 38 38 this.noteData = noteData; 39 Main .worker.submit(new UploadTask(tr("Uploading modified notes"), progressMonitor));39 MainApplication.worker.submit(new UploadTask(tr("Uploading modified notes"), progressMonitor)); 40 40 } 41 41 -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r12620 r12634 235 235 236 236 /** 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 /** 237 255 * Adds a new preferences listener. 238 256 * @param listener The listener to add -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r12620 r12634 16 16 import java.util.Set; 17 17 import java.util.TreeSet; 18 import java.util.concurrent.ExecutorService; 18 19 19 20 import org.openstreetmap.josm.Main; … … 33 34 public class ImageryLayerInfo { 34 35 36 /** Unique instance */ 35 37 public static final ImageryLayerInfo instance = new ImageryLayerInfo(); 36 38 /** List of all usable layers */ … … 61 63 } 62 64 65 /** 66 * Constructs a new {@code ImageryLayerInfo} from an existing one. 67 * @param info info to copy 68 */ 63 69 public ImageryLayerInfo(ImageryLayerInfo info) { 64 70 layers.addAll(info.layers); 65 71 } 66 72 73 /** 74 * Clear the lists of layers. 75 */ 67 76 public void clear() { 68 77 layers.clear(); … … 88 97 Collections.sort(layers); 89 98 } 90 loadDefaults(false, true, fastFail);99 loadDefaults(false, null, fastFail); 91 100 } 92 101 … … 95 104 * 96 105 * 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. 99 107 * 100 108 * @param clearCache if true, clear the cache and start a fresh download. 101 * @param quiet whether not the loadingshould be performed using a {@link PleaseWaitRunnable} in the background109 * @param worker executor service which will perform the loading. If null, it should be performed using a {@link PleaseWaitRunnable} in the background 102 110 * @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) { 105 114 final DefaultEntryLoader loader = new DefaultEntryLoader(clearCache, fastFail); 106 if ( quiet) {115 if (worker == null) { 107 116 loader.realRun(); 108 117 loader.finish(); 109 118 } else { 110 Main.worker.execute(new DefaultEntryLoader(clearCache, fastFail));119 worker.execute(loader); 111 120 } 112 121 } … … 327 336 } 328 337 338 /** 339 * Add a new imagery entry. 340 * @param info imagery entry to add 341 */ 329 342 public void add(ImageryInfo info) { 330 343 layers.add(info); 331 344 } 332 345 346 /** 347 * Remove an imagery entry. 348 * @param info imagery entry to remove 349 */ 333 350 public void remove(ImageryInfo info) { 334 351 layers.remove(info); 335 352 } 336 353 354 /** 355 * Save the list of imagery entries to preferences. 356 */ 337 357 public void save() { 338 358 List<ImageryPreferenceEntry> entries = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12633 r12634 7 7 import java.awt.BorderLayout; 8 8 import java.awt.Dimension; 9 import java.awt.GraphicsEnvironment; 9 10 import java.awt.event.KeyEvent; 10 11 import java.io.File; … … 36 37 import java.util.TreeSet; 37 38 import java.util.concurrent.Callable; 39 import java.util.concurrent.ExecutorService; 38 40 import java.util.concurrent.Future; 39 41 import java.util.logging.Level; … … 59 61 import org.openstreetmap.josm.actions.mapmode.DrawAction; 60 62 import org.openstreetmap.josm.actions.search.SearchAction; 61 import org.openstreetmap.josm.data.AutosaveTask;62 63 import org.openstreetmap.josm.data.Bounds; 63 import org.openstreetmap.josm.data.CustomConfigurator;64 64 import org.openstreetmap.josm.data.Version; 65 65 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 68 68 import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor; 69 69 import org.openstreetmap.josm.gui.download.DownloadDialog; 70 import org.openstreetmap.josm.gui.io.CustomConfigurator.XMLCommandProcessor; 71 import org.openstreetmap.josm.gui.layer.AutosaveTask; 70 72 import org.openstreetmap.josm.gui.layer.TMSLayer; 71 73 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; … … 73 75 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder; 74 76 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; 77 import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor; 75 78 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 76 79 import org.openstreetmap.josm.gui.util.GuiHelper; … … 124 127 125 128 /** 129 * The worker thread slave. This is for executing all long and intensive 130 * calculations. The executed runnables are guaranteed to be executed separately and sequential. 131 * @since 12634 (as a replacement to {@code Main.worker}) 132 */ 133 public static final ExecutorService worker = new ProgressMonitorExecutor("main-worker-%d", Thread.NORM_PRIORITY); 134 135 /** 126 136 * Constructs a new {@code MainApplication} without a window. 127 137 */ … … 227 237 @Override 228 238 protected void shutdown() { 239 if (!GraphicsEnvironment.isHeadless()) { 240 worker.shutdown(); 241 } 229 242 if (mainFrame != null) { 230 243 mainFrame.storeState(); … … 234 247 } 235 248 super.shutdown(); 249 if (!GraphicsEnvironment.isHeadless()) { 250 worker.shutdownNow(); 251 } 236 252 } 237 253 … … 456 472 457 473 if (args.hasOption(Option.LOAD_PREFERENCES)) { 458 CustomConfigurator.XMLCommandProcessor config = new CustomConfigurator.XMLCommandProcessor(Main.pref);474 XMLCommandProcessor config = new XMLCommandProcessor(Main.pref); 459 475 for (String i : args.get(Option.LOAD_PREFERENCES)) { 460 476 Logging.info("Reading preferences from " + i); … … 671 687 Future<?> future = task.download(true, b, null); 672 688 // ... and the continuation when the download is finished (this will wait for the download to finish) 673 return Collections.singletonList(Main .worker.submit(new PostDownloadHandler(task, future)));689 return Collections.singletonList(MainApplication.worker.submit(new PostDownloadHandler(task, future))); 674 690 } 675 691 … … 693 709 final Collection<String> selectionArguments = args.get(Option.SELECTION); 694 710 if (!selectionArguments.isEmpty()) { 695 tasks.add(Main .worker.submit(() -> {711 tasks.add(MainApplication.worker.submit(() -> { 696 712 for (String s : selectionArguments) { 697 713 SearchAction.search(s, SearchAction.SearchMode.add); -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/FilePaster.java
r10604 r12634 10 10 import javax.swing.TransferHandler.TransferSupport; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.actions.OpenFileAction; 14 13 import org.openstreetmap.josm.data.coor.EastNorth; 14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 16 … … 35 35 OpenFileAction.OpenFileTask task = new OpenFileAction.OpenFileTask(files, null); 36 36 task.setRecordHistory(true); 37 Main .worker.submit(task);37 MainApplication.worker.submit(task); 38 38 return true; 39 39 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r12620 r12634 44 44 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 45 45 import org.openstreetmap.josm.data.osm.event.SelectionEventManager; 46 import org.openstreetmap.josm.gui.MainApplication; 46 47 import org.openstreetmap.josm.gui.SideButton; 47 48 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager; … … 358 359 return; 359 360 ChangesetHeaderDownloadTask task = new ChangesetHeaderDownloadTask(sel); 360 Main .worker.submit(new PostDownloadHandler(task, task.download()));361 MainApplication.worker.submit(new PostDownloadHandler(task, task.download())); 361 362 } 362 363 … … 393 394 if (sel.isEmpty()) 394 395 return; 395 Main .worker.submit(new CloseChangesetTask(sel));396 MainApplication.worker.submit(new CloseChangesetTask(sel)); 396 397 } 397 398 … … 515 516 } else { 516 517 task = new ChangesetHeaderDownloadTask(toDownload); 517 future = Main .worker.submit(new PostDownloadHandler(task, task.download()));518 future = MainApplication.worker.submit(new PostDownloadHandler(task, task.download())); 518 519 } 519 520 … … 543 544 GuiHelper.runInEDT(() -> launchChangesetManager(sel)); 544 545 }; 545 Main .worker.submit(r);546 MainApplication.worker.submit(r); 546 547 } 547 548 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r12620 r12634 57 57 import org.openstreetmap.josm.actions.PreferencesAction; 58 58 import org.openstreetmap.josm.gui.ExtendedDialog; 59 import org.openstreetmap.josm.gui.MainApplication; 59 60 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 60 61 import org.openstreetmap.josm.gui.SideButton; … … 417 418 final int[] rows = tblStyles.getSelectedRows(); 418 419 MapPaintStyles.reloadStyles(rows); 419 Main .worker.submit(() -> SwingUtilities.invokeLater(() -> {420 MainApplication.worker.submit(() -> SwingUtilities.invokeLater(() -> { 420 421 selectionModel.setValueIsAdjusting(true); 421 422 selectionModel.clearSelection(); … … 461 462 if (fc == null) 462 463 return; 463 Main .worker.submit(new SaveToFileTask(s, fc.getSelectedFile()));464 MainApplication.worker.submit(new SaveToFileTask(s, fc.getSelectedFile())); 464 465 } 465 466 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r12630 r12634 237 237 // 238 238 FixTask fixTask = new FixTask(errorsToFix); 239 Main .worker.submit(fixTask);239 MainApplication.worker.submit(fixTask); 240 240 } 241 241 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r12620 r12634 54 54 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 55 55 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 56 import org.openstreetmap.josm.gui.MainApplication; 56 57 import org.openstreetmap.josm.gui.dialogs.changeset.query.ChangesetQueryDialog; 57 58 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; … … 459 460 @Override 460 461 public void actionPerformed(ActionEvent e) { 461 Main .worker.submit(new CloseChangesetTask(model.getSelectedChangesets()));462 MainApplication.worker.submit(new CloseChangesetTask(model.getSelectedChangesets())); 462 463 } 463 464 … … 568 569 if (!GraphicsEnvironment.isHeadless()) { 569 570 actDownloadSelectedContent.actionPerformed(e); 570 Main .worker.submit(() -> {571 MainApplication.worker.submit(() -> { 571 572 final List<PrimitiveId> primitiveIds = model.getSelectedChangesets().stream() 572 573 .map(Changeset::getContent) … … 754 755 */ 755 756 public void runDownloadTask(final AbstractChangesetDownloadTask task) { 756 Main .worker.submit(new PostDownloadHandler(task, task.download()));757 Main .worker.submit(() -> {757 MainApplication.worker.submit(new PostDownloadHandler(task, task.download())); 758 MainApplication.worker.submit(() -> { 758 759 if (task.isCanceled() || task.isFailed()) 759 760 return; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
r11848 r12634 43 43 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 44 44 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 45 import org.openstreetmap.josm.gui.MainApplication; 45 46 import org.openstreetmap.josm.gui.help.HelpUtil; 46 47 import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager; … … 268 269 task.add(p); 269 270 } 270 Main .worker.submit(task);271 } 272 273 Main .worker.submit(new ShowHistoryTask(primitives));271 MainApplication.worker.submit(task); 272 } 273 274 MainApplication.worker.submit(new ShowHistoryTask(primitives)); 274 275 } 275 276 … … 304 305 final List<PrimitiveId> primitiveIds = model.getSelectedPrimitives().stream().map(HistoryOsmPrimitive::getPrimitiveId) 305 306 .collect(Collectors.toList()); 306 Main .worker.submit(new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null));307 MainApplication.worker.submit(new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null)); 307 308 } 308 309 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java
r12494 r12634 36 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; 37 37 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 38 import org.openstreetmap.josm.gui.MainApplication; 38 39 import org.openstreetmap.josm.gui.help.HelpUtil; 39 40 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; … … 316 317 Collections.singleton(currentChangeset.getId()) 317 318 ); 318 Main .worker.submit(new PostDownloadHandler(task, task.download()));319 MainApplication.worker.submit(new PostDownloadHandler(task, task.download())); 319 320 } 320 321 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java
r10611 r12634 24 24 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 25 25 import org.openstreetmap.josm.data.osm.Changeset; 26 import org.openstreetmap.josm.gui.MainApplication; 26 27 import org.openstreetmap.josm.io.OnlineResource; 27 28 import org.openstreetmap.josm.tools.ImageProvider; … … 78 79 true /* include discussion */ 79 80 ); 80 Main .worker.submit(new PostDownloadHandler(task, task.download()));81 MainApplication.worker.submit(new PostDownloadHandler(task, task.download())); 81 82 } 82 83 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r12630 r12634 1172 1172 } 1173 1173 1174 Main .worker.execute(() -> displayHelp(uris));1174 MainApplication.worker.execute(() -> displayHelp(uris)); 1175 1175 } catch (URISyntaxException e1) { 1176 1176 Logging.error(e1); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r12630 r12634 227 227 228 228 public void run() { 229 Main .worker.submit(new DownloadAllChildrenTask(getParentDialog(), (Relation) model.getRoot()));229 MainApplication.worker.submit(new DownloadAllChildrenTask(getParentDialog(), (Relation) model.getRoot())); 230 230 } 231 231 … … 264 264 relations.add((Relation) aSelection.getLastPathComponent()); 265 265 } 266 Main .worker.submit(new DownloadRelationSetTask(getParentDialog(), relations));266 MainApplication.worker.submit(new DownloadRelationSetTask(getParentDialog(), relations)); 267 267 } 268 268 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r12620 r12634 48 48 * 49 49 * // start the task 50 * Main .worker.submit(task);50 * MainApplication.worker.submit(task); 51 51 * </pre> 52 52 * -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java
r10611 r12634 22 22 import javax.swing.event.ListSelectionListener; 23 23 24 import org.openstreetmap.josm.Main;25 24 import org.openstreetmap.josm.data.osm.Relation; 25 import org.openstreetmap.josm.gui.MainApplication; 26 26 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 27 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 115 115 model.populate(task.getParents()); 116 116 }); 117 Main .worker.submit(task);117 MainApplication.worker.submit(task); 118 118 } 119 119 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java
r12620 r12634 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 21 21 import org.openstreetmap.josm.data.osm.Relation; 22 import org.openstreetmap.josm.gui.MainApplication; 22 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 23 24 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; … … 95 96 return; 96 97 // launch the download task 97 Main .worker.submit(new RelationLoader(getParentDialog(), parent, path));98 MainApplication.worker.submit(new RelationLoader(getParentDialog(), parent, path)); 98 99 } 99 100 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DownloadIncompleteMembersAction.java
r9665 r12634 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MainApplication; 11 12 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 13 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 12 14 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; 13 15 import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel; 14 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;15 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 17 import org.openstreetmap.josm.io.OnlineResource; … … 48 49 if (!isEnabled()) 49 50 return; 50 Main .worker.submit(new DownloadRelationMemberTask(51 MainApplication.worker.submit(new DownloadRelationMemberTask( 51 52 editor.getRelation(), 52 53 memberTableModel.getIncompleteMemberPrimitives(), -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DownloadSelectedIncompleteMembersAction.java
r9991 r12634 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.gui.MainApplication; 10 11 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 11 12 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; … … 43 44 if (!isEnabled()) 44 45 return; 45 Main .worker.submit(new DownloadRelationMemberTask(46 MainApplication.worker.submit(new DownloadRelationMemberTask( 46 47 editor.getRelation(), 47 48 memberTableModel.getSelectedIncompleteMemberPrimitives(), -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
r12620 r12634 33 33 import org.openstreetmap.josm.data.projection.Projections; 34 34 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 35 import org.openstreetmap.josm.gui.MainApplication; 35 36 import org.openstreetmap.josm.gui.MapViewState; 36 37 import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager; … … 334 335 final ChangesetQueryTask task = new ChangesetQueryTask(this, query); 335 336 ChangesetCacheManager.getInstance().runDownloadTask(task); 336 Main .worker.submit(() -> {337 MainApplication.worker.submit(() -> { 337 338 if (task.isCanceled() || task.isFailed()) 338 339 return; -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r12620 r12634 47 47 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 48 48 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 49 import org.openstreetmap.josm.gui.MainApplication; 49 50 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 50 51 import org.openstreetmap.josm.gui.util.GuiHelper; … … 190 191 Main.pref.putCollection(HISTORY_KEY, cbSearchExpression.getHistory()); 191 192 NameQueryTask task = new NameQueryTask(cbSearchExpression.getText()); 192 Main .worker.submit(task);193 MainApplication.worker.submit(task); 193 194 } 194 195 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java
r11659 r12634 23 23 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 24 24 import org.openstreetmap.josm.data.osm.history.HistoryDataSetListener; 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 26 27 import org.openstreetmap.josm.gui.help.HelpUtil; … … 182 183 HistoryLoadTask task = new HistoryLoadTask(); 183 184 task.add(browser.getHistory()); 184 Main .worker.submit(task);185 MainApplication.worker.submit(task); 185 186 } 186 187 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r11746 r12634 23 23 import org.openstreetmap.josm.data.osm.history.History; 24 24 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 26 27 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; … … 213 214 task.add(p); 214 215 } 215 Main .worker.submit(task);216 MainApplication.worker.submit(task); 216 217 } 217 218 … … 229 230 } 230 231 }; 231 Main .worker.submit(r);232 MainApplication.worker.submit(r); 232 233 } 233 234 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java
r11553 r12634 43 43 * .add(aHistoryItem); 44 44 * 45 * Main .worker.execute(task);45 * MainApplication.worker.execute(task); 46 46 * </pre> 47 47 */ -
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r11519 r12634 29 29 import org.openstreetmap.josm.data.osm.history.History; 30 30 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 33 import org.openstreetmap.josm.gui.util.AdjustmentSynchronizer; … … 302 303 public void run() { 303 304 if (HistoryDataSet.getInstance().getHistory(primitiveId) == null) { 304 Main .worker.submit(new HistoryLoadTask().add(primitiveId));305 MainApplication.worker.submit(new HistoryLoadTask().add(primitiveId)); 305 306 } 306 Main .worker.submit(() -> {307 MainApplication.worker.submit(() -> { 307 308 final History h = HistoryDataSet.getInstance().getHistory(primitiveId); 308 309 if (h == null) -
trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java
r12620 r12634 26 26 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 27 27 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 29 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 92 93 throw new IllegalStateException( 93 94 tr("Failed to update primitive with id {0} because current edit layer does not include such a primitive", id)); 94 Main .worker.execute(new UpdatePrimitivesTask(layer, Collections.singleton(p)));95 MainApplication.worker.execute(new UpdatePrimitivesTask(layer, Collections.singleton(p))); 95 96 } 96 97 -
trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java
r10378 r12634 26 26 import org.openstreetmap.josm.data.osm.Changeset; 27 27 import org.openstreetmap.josm.data.osm.ChangesetCache; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 29 30 import org.openstreetmap.josm.gui.widgets.JosmComboBox; … … 299 300 @Override 300 301 public void actionPerformed(ActionEvent e) { 301 DownloadOpenChangesetsTask task = new DownloadOpenChangesetsTask(ChangesetManagementPanel.this); 302 Main.worker.submit(task); 302 MainApplication.worker.submit(new DownloadOpenChangesetsTask(ChangesetManagementPanel.this)); 303 303 } 304 304 } … … 319 319 Changeset cs = (Changeset) cbOpenChangesets.getSelectedItem(); 320 320 if (cs == null) return; 321 CloseChangesetTask task = new CloseChangesetTask(Collections.singletonList(cs)); 322 Main.worker.submit(task); 321 MainApplication.worker.submit(new CloseChangesetTask(Collections.singletonList(cs))); 323 322 } 324 323 -
trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
r12633 r12634 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. data;2 package org.openstreetmap.josm.gui.io; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 18 18 import java.util.HashMap; 19 19 import java.util.HashSet; 20 import java.util.Iterator;21 20 import java.util.List; 22 21 import java.util.Locale; 23 22 import java.util.Map; 24 import java.util.Map.Entry;25 23 import java.util.Set; 26 import java.util.TreeMap;27 24 import java.util.regex.Matcher; 28 25 import java.util.regex.Pattern; … … 45 42 46 43 import org.openstreetmap.josm.Main; 47 import org.openstreetmap.josm.data. preferences.ListListSetting;48 import org.openstreetmap.josm.data. preferences.ListSetting;49 import org.openstreetmap.josm.data. preferences.MapListSetting;44 import org.openstreetmap.josm.data.Preferences; 45 import org.openstreetmap.josm.data.PreferencesUtils; 46 import org.openstreetmap.josm.data.Version; 50 47 import org.openstreetmap.josm.data.preferences.Setting; 51 import org.openstreetmap.josm.data.preferences.StringSetting; 52 import org.openstreetmap.josm.gui.io.DownloadFileTask; 48 import org.openstreetmap.josm.gui.MainApplication; 53 49 import org.openstreetmap.josm.plugins.PluginDownloadTask; 54 50 import org.openstreetmap.josm.plugins.PluginInformation; … … 188 184 DownloadFileTask downloadFileTask = new DownloadFileTask(Main.parent, address, fOut, mkdir, unzip); 189 185 190 Main .worker.submit(downloadFileTask);186 MainApplication.worker.submit(downloadFileTask); 191 187 log("Info: downloading file from %s to %s in background ", parentDir, fOut.getAbsolutePath()); 192 188 if (unzip) log("and unpacking it"); else log(""); … … 394 390 PluginDownloadTask pluginDownloadTask = 395 391 new PluginDownloadTask(Main.parent, toInstallPlugins, tr("Installing plugins")); 396 Main .worker.submit(pluginDownloadTask);392 MainApplication.worker.submit(pluginDownloadTask); 397 393 } 398 394 Collection<String> pls = new ArrayList<>(Main.pref.getCollection("plugins")); … … 413 409 } 414 410 }; 415 Main .worker.submit(task);416 Main .worker.submit(r);411 MainApplication.worker.submit(task); 412 MainApplication.worker.submit(r); 417 413 } 418 414 … … 429 425 } 430 426 return dir; 431 }432 433 public static Preferences clonePreferences(Preferences pref) {434 Preferences tmp = new Preferences();435 tmp.settingsMap.putAll(pref.settingsMap);436 tmp.defaultsMap.putAll(pref.defaultsMap);437 tmp.colornames.putAll(pref.colornames);438 439 return tmp;440 427 } 441 428 … … 759 746 } 760 747 } 761 762 /**763 * Helper class to do specific Preferences operation - appending, replacing,764 * deletion by key and by value765 * Also contains functions that convert preferences object to JavaScript object and back766 */767 public static final class PreferencesUtils {768 769 private PreferencesUtils() {770 // Hide implicit public constructor for utility class771 }772 773 private static void replacePreferences(Preferences fragment, Preferences mainpref) {774 for (Entry<String, Setting<?>> entry: fragment.settingsMap.entrySet()) {775 mainpref.putSetting(entry.getKey(), entry.getValue());776 }777 }778 779 private static void appendPreferences(Preferences fragment, Preferences mainpref) {780 for (Entry<String, Setting<?>> entry: fragment.settingsMap.entrySet()) {781 String key = entry.getKey();782 if (entry.getValue() instanceof StringSetting) {783 mainpref.putSetting(key, entry.getValue());784 } else if (entry.getValue() instanceof ListSetting) {785 ListSetting lSetting = (ListSetting) entry.getValue();786 Collection<String> newItems = getCollection(mainpref, key, true);787 if (newItems == null) continue;788 for (String item : lSetting.getValue()) {789 // add nonexisting elements to then list790 if (!newItems.contains(item)) {791 newItems.add(item);792 }793 }794 mainpref.putCollection(key, newItems);795 } else if (entry.getValue() instanceof ListListSetting) {796 ListListSetting llSetting = (ListListSetting) entry.getValue();797 Collection<Collection<String>> newLists = getArray(mainpref, key, true);798 if (newLists == null) continue;799 800 for (Collection<String> list : llSetting.getValue()) {801 // add nonexisting list (equals comparison for lists is used implicitly)802 if (!newLists.contains(list)) {803 newLists.add(list);804 }805 }806 mainpref.putArray(key, newLists);807 } else if (entry.getValue() instanceof MapListSetting) {808 MapListSetting mlSetting = (MapListSetting) entry.getValue();809 List<Map<String, String>> newMaps = getListOfStructs(mainpref, key, true);810 if (newMaps == null) continue;811 812 // get existing properties as list of maps813 814 for (Map<String, String> map : mlSetting.getValue()) {815 // add nonexisting map (equals comparison for maps is used implicitly)816 if (!newMaps.contains(map)) {817 newMaps.add(map);818 }819 }820 mainpref.putListOfStructs(entry.getKey(), newMaps);821 }822 }823 }824 825 /**826 * Delete items from {@code mainpref} collections that match items from {@code fragment} collections.827 * @param fragment preferences828 * @param mainpref main preferences829 */830 private static void deletePreferenceValues(Preferences fragment, Preferences mainpref) {831 832 for (Entry<String, Setting<?>> entry : fragment.settingsMap.entrySet()) {833 String key = entry.getKey();834 if (entry.getValue() instanceof StringSetting) {835 StringSetting sSetting = (StringSetting) entry.getValue();836 // if mentioned value found, delete it837 if (sSetting.equals(mainpref.settingsMap.get(key))) {838 mainpref.put(key, null);839 }840 } else if (entry.getValue() instanceof ListSetting) {841 ListSetting lSetting = (ListSetting) entry.getValue();842 Collection<String> newItems = getCollection(mainpref, key, true);843 if (newItems == null) continue;844 845 // remove mentioned items from collection846 for (String item : lSetting.getValue()) {847 log("Deleting preferences: from list %s: %s\n", key, item);848 newItems.remove(item);849 }850 mainpref.putCollection(entry.getKey(), newItems);851 } else if (entry.getValue() instanceof ListListSetting) {852 ListListSetting llSetting = (ListListSetting) entry.getValue();853 Collection<Collection<String>> newLists = getArray(mainpref, key, true);854 if (newLists == null) continue;855 856 // if items are found in one of lists, remove that list!857 Iterator<Collection<String>> listIterator = newLists.iterator();858 while (listIterator.hasNext()) {859 Collection<String> list = listIterator.next();860 for (Collection<String> removeList : llSetting.getValue()) {861 if (list.containsAll(removeList)) {862 // remove current list, because it matches search criteria863 log("Deleting preferences: list from lists %s: %s\n", key, list);864 listIterator.remove();865 }866 }867 }868 869 mainpref.putArray(key, newLists);870 } else if (entry.getValue() instanceof MapListSetting) {871 MapListSetting mlSetting = (MapListSetting) entry.getValue();872 List<Map<String, String>> newMaps = getListOfStructs(mainpref, key, true);873 if (newMaps == null) continue;874 875 Iterator<Map<String, String>> mapIterator = newMaps.iterator();876 while (mapIterator.hasNext()) {877 Map<String, String> map = mapIterator.next();878 for (Map<String, String> removeMap : mlSetting.getValue()) {879 if (map.entrySet().containsAll(removeMap.entrySet())) {880 // the map contain all mentioned key-value pair, so it should be deleted from "maps"881 log("Deleting preferences: deleting map from maps %s: %s\n", key, map);882 mapIterator.remove();883 }884 }885 }886 mainpref.putListOfStructs(entry.getKey(), newMaps);887 }888 }889 }890 891 private static void deletePreferenceKeyByPattern(String pattern, Preferences pref) {892 Map<String, Setting<?>> allSettings = pref.getAllSettings();893 for (Entry<String, Setting<?>> entry : allSettings.entrySet()) {894 String key = entry.getKey();895 if (key.matches(pattern)) {896 log("Deleting preferences: deleting key from preferences: " + key);897 pref.putSetting(key, null);898 }899 }900 }901 902 private static void deletePreferenceKey(String key, Preferences pref) {903 Map<String, Setting<?>> allSettings = pref.getAllSettings();904 if (allSettings.containsKey(key)) {905 log("Deleting preferences: deleting key from preferences: " + key);906 pref.putSetting(key, null);907 }908 }909 910 private static Collection<String> getCollection(Preferences mainpref, String key, boolean warnUnknownDefault) {911 ListSetting existing = Utils.cast(mainpref.settingsMap.get(key), ListSetting.class);912 ListSetting defaults = Utils.cast(mainpref.defaultsMap.get(key), ListSetting.class);913 if (existing == null && defaults == null) {914 if (warnUnknownDefault) defaultUnknownWarning(key);915 return null;916 }917 if (existing != null)918 return new ArrayList<>(existing.getValue());919 else920 return defaults.getValue() == null ? null : new ArrayList<>(defaults.getValue());921 }922 923 private static Collection<Collection<String>> getArray(Preferences mainpref, String key, boolean warnUnknownDefault) {924 ListListSetting existing = Utils.cast(mainpref.settingsMap.get(key), ListListSetting.class);925 ListListSetting defaults = Utils.cast(mainpref.defaultsMap.get(key), ListListSetting.class);926 927 if (existing == null && defaults == null) {928 if (warnUnknownDefault) defaultUnknownWarning(key);929 return null;930 }931 if (existing != null)932 return new ArrayList<>(existing.getValue());933 else934 return defaults.getValue() == null ? null : new ArrayList<>(defaults.getValue());935 }936 937 private static List<Map<String, String>> getListOfStructs(Preferences mainpref, String key, boolean warnUnknownDefault) {938 MapListSetting existing = Utils.cast(mainpref.settingsMap.get(key), MapListSetting.class);939 MapListSetting defaults = Utils.cast(mainpref.settingsMap.get(key), MapListSetting.class);940 941 if (existing == null && defaults == null) {942 if (warnUnknownDefault) defaultUnknownWarning(key);943 return null;944 }945 946 if (existing != null)947 return new ArrayList<>(existing.getValue());948 else949 return defaults.getValue() == null ? null : new ArrayList<>(defaults.getValue());950 }951 952 private static void defaultUnknownWarning(String key) {953 log("Warning: Unknown default value of %s , skipped\n", key);954 JOptionPane.showMessageDialog(955 Main.parent,956 tr("<html>Settings file asks to append preferences to <b>{0}</b>,<br/> "+957 "but its default value is unknown at this moment.<br/> " +958 "Please activate corresponding function manually and retry importing.", key),959 tr("Warning"),960 JOptionPane.WARNING_MESSAGE);961 }962 963 private static void showPrefs(Preferences tmpPref) {964 Logging.info("properties: " + tmpPref.settingsMap);965 }966 967 private static void modifyPreferencesByScript(ScriptEngine engine, Preferences tmpPref, String js) throws ScriptException {968 loadPrefsToJS(engine, tmpPref, "API.pref", true);969 engine.eval(js);970 readPrefsFromJS(engine, tmpPref, "API.pref");971 }972 973 /**974 * Convert JavaScript preferences object to preferences data structures975 * @param engine - JS engine to put object976 * @param tmpPref - preferences to fill from JS977 * @param varInJS - JS variable name, where preferences are stored978 * @throws ScriptException if the evaluation fails979 */980 public static void readPrefsFromJS(ScriptEngine engine, Preferences tmpPref, String varInJS) throws ScriptException {981 String finish =982 "stringMap = new java.util.TreeMap ;"+983 "listMap = new java.util.TreeMap ;"+984 "listlistMap = new java.util.TreeMap ;"+985 "listmapMap = new java.util.TreeMap ;"+986 "for (key in "+varInJS+") {"+987 " val = "+varInJS+"[key];"+988 " type = typeof val == 'string' ? 'string' : val.type;"+989 " if (type == 'string') {"+990 " stringMap.put(key, val);"+991 " } else if (type == 'list') {"+992 " l = new java.util.ArrayList;"+993 " for (i=0; i<val.length; i++) {"+994 " l.add(java.lang.String.valueOf(val[i]));"+995 " }"+996 " listMap.put(key, l);"+997 " } else if (type == 'listlist') {"+998 " l = new java.util.ArrayList;"+999 " for (i=0; i<val.length; i++) {"+1000 " list=val[i];"+1001 " jlist=new java.util.ArrayList;"+1002 " for (j=0; j<list.length; j++) {"+1003 " jlist.add(java.lang.String.valueOf(list[j]));"+1004 " }"+1005 " l.add(jlist);"+1006 " }"+1007 " listlistMap.put(key, l);"+1008 " } else if (type == 'listmap') {"+1009 " l = new java.util.ArrayList;"+1010 " for (i=0; i<val.length; i++) {"+1011 " map=val[i];"+1012 " jmap=new java.util.TreeMap;"+1013 " for (var key2 in map) {"+1014 " jmap.put(key2,java.lang.String.valueOf(map[key2]));"+1015 " }"+1016 " l.add(jmap);"+1017 " }"+1018 " listmapMap.put(key, l);"+1019 " } else {" +1020 " org.openstreetmap.josm.data.CustomConfigurator.log('Unknown type:'+val.type+ '- use list, listlist or listmap'); }"+1021 " }";1022 engine.eval(finish);1023 1024 @SuppressWarnings("unchecked")1025 Map<String, String> stringMap = (Map<String, String>) engine.get("stringMap");1026 @SuppressWarnings("unchecked")1027 Map<String, List<String>> listMap = (Map<String, List<String>>) engine.get("listMap");1028 @SuppressWarnings("unchecked")1029 Map<String, List<Collection<String>>> listlistMap = (Map<String, List<Collection<String>>>) engine.get("listlistMap");1030 @SuppressWarnings("unchecked")1031 Map<String, List<Map<String, String>>> listmapMap = (Map<String, List<Map<String, String>>>) engine.get("listmapMap");1032 1033 tmpPref.settingsMap.clear();1034 1035 Map<String, Setting<?>> tmp = new HashMap<>();1036 for (Entry<String, String> e : stringMap.entrySet()) {1037 tmp.put(e.getKey(), new StringSetting(e.getValue()));1038 }1039 for (Entry<String, List<String>> e : listMap.entrySet()) {1040 tmp.put(e.getKey(), new ListSetting(e.getValue()));1041 }1042 1043 for (Entry<String, List<Collection<String>>> e : listlistMap.entrySet()) {1044 @SuppressWarnings({ "unchecked", "rawtypes" })1045 List<List<String>> value = (List) e.getValue();1046 tmp.put(e.getKey(), new ListListSetting(value));1047 }1048 for (Entry<String, List<Map<String, String>>> e : listmapMap.entrySet()) {1049 tmp.put(e.getKey(), new MapListSetting(e.getValue()));1050 }1051 for (Entry<String, Setting<?>> e : tmp.entrySet()) {1052 if (e.getValue().equals(tmpPref.defaultsMap.get(e.getKey()))) continue;1053 tmpPref.settingsMap.put(e.getKey(), e.getValue());1054 }1055 }1056 1057 /**1058 * Convert preferences data structures to JavaScript object1059 * @param engine - JS engine to put object1060 * @param tmpPref - preferences to convert1061 * @param whereToPutInJS - variable name to store preferences in JS1062 * @param includeDefaults - include known default values to JS objects1063 * @throws ScriptException if the evaluation fails1064 */1065 public static void loadPrefsToJS(ScriptEngine engine, Preferences tmpPref, String whereToPutInJS, boolean includeDefaults)1066 throws ScriptException {1067 Map<String, String> stringMap = new TreeMap<>();1068 Map<String, List<String>> listMap = new TreeMap<>();1069 Map<String, List<List<String>>> listlistMap = new TreeMap<>();1070 Map<String, List<Map<String, String>>> listmapMap = new TreeMap<>();1071 1072 if (includeDefaults) {1073 for (Map.Entry<String, Setting<?>> e: tmpPref.defaultsMap.entrySet()) {1074 Setting<?> setting = e.getValue();1075 if (setting instanceof StringSetting) {1076 stringMap.put(e.getKey(), ((StringSetting) setting).getValue());1077 } else if (setting instanceof ListSetting) {1078 listMap.put(e.getKey(), ((ListSetting) setting).getValue());1079 } else if (setting instanceof ListListSetting) {1080 listlistMap.put(e.getKey(), ((ListListSetting) setting).getValue());1081 } else if (setting instanceof MapListSetting) {1082 listmapMap.put(e.getKey(), ((MapListSetting) setting).getValue());1083 }1084 }1085 }1086 tmpPref.settingsMap.entrySet().removeIf(e -> e.getValue().getValue() == null);1087 1088 for (Map.Entry<String, Setting<?>> e: tmpPref.settingsMap.entrySet()) {1089 Setting<?> setting = e.getValue();1090 if (setting instanceof StringSetting) {1091 stringMap.put(e.getKey(), ((StringSetting) setting).getValue());1092 } else if (setting instanceof ListSetting) {1093 listMap.put(e.getKey(), ((ListSetting) setting).getValue());1094 } else if (setting instanceof ListListSetting) {1095 listlistMap.put(e.getKey(), ((ListListSetting) setting).getValue());1096 } else if (setting instanceof MapListSetting) {1097 listmapMap.put(e.getKey(), ((MapListSetting) setting).getValue());1098 }1099 }1100 1101 engine.put("stringMap", stringMap);1102 engine.put("listMap", listMap);1103 engine.put("listlistMap", listlistMap);1104 engine.put("listmapMap", listmapMap);1105 1106 String init =1107 "function getJSList( javaList ) {"+1108 " var jsList; var i; "+1109 " if (javaList == null) return null;"+1110 "jsList = [];"+1111 " for (i = 0; i < javaList.size(); i++) {"+1112 " jsList.push(String(list.get(i)));"+1113 " }"+1114 "return jsList;"+1115 "}"+1116 "function getJSMap( javaMap ) {"+1117 " var jsMap; var it; var e; "+1118 " if (javaMap == null) return null;"+1119 " jsMap = {};"+1120 " for (it = javaMap.entrySet().iterator(); it.hasNext();) {"+1121 " e = it.next();"+1122 " jsMap[ String(e.getKey()) ] = String(e.getValue()); "+1123 " }"+1124 " return jsMap;"+1125 "}"+1126 "for (it = stringMap.entrySet().iterator(); it.hasNext();) {"+1127 " e = it.next();"+1128 whereToPutInJS+"[String(e.getKey())] = String(e.getValue());"+1129 "}\n"+1130 "for (it = listMap.entrySet().iterator(); it.hasNext();) {"+1131 " e = it.next();"+1132 " list = e.getValue();"+1133 " jslist = getJSList(list);"+1134 " jslist.type = 'list';"+1135 whereToPutInJS+"[String(e.getKey())] = jslist;"+1136 "}\n"+1137 "for (it = listlistMap.entrySet().iterator(); it.hasNext(); ) {"+1138 " e = it.next();"+1139 " listlist = e.getValue();"+1140 " jslistlist = [];"+1141 " for (it2 = listlist.iterator(); it2.hasNext(); ) {"+1142 " list = it2.next(); "+1143 " jslistlist.push(getJSList(list));"+1144 " }"+1145 " jslistlist.type = 'listlist';"+1146 whereToPutInJS+"[String(e.getKey())] = jslistlist;"+1147 "}\n"+1148 "for (it = listmapMap.entrySet().iterator(); it.hasNext();) {"+1149 " e = it.next();"+1150 " listmap = e.getValue();"+1151 " jslistmap = [];"+1152 " for (it2 = listmap.iterator(); it2.hasNext();) {"+1153 " map = it2.next();"+1154 " jslistmap.push(getJSMap(map));"+1155 " }"+1156 " jslistmap.type = 'listmap';"+1157 whereToPutInJS+"[String(e.getKey())] = jslistmap;"+1158 "}\n";1159 1160 // Execute conversion script1161 engine.eval(init);1162 }1163 }1164 748 } -
trunk/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java
r11366 r12634 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.actions.OpenFileAction.OpenFileTask; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.tools.ImageProvider; 22 23 … … 85 86 OpenFileTask task = new OpenFileTask(Collections.singletonList(new File(file)), null); 86 87 task.setRecordHistory(true); 87 Main .worker.submit(task);88 MainApplication.worker.submit(task); 88 89 } 89 90 } -
trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
r12633 r12634 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. data;2 package org.openstreetmap.josm.gui.layer; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; … … 37 37 import org.openstreetmap.josm.data.preferences.BooleanProperty; 38 38 import org.openstreetmap.josm.data.preferences.IntegerProperty; 39 import org.openstreetmap.josm.gui.MainApplication; 39 40 import org.openstreetmap.josm.gui.Notification; 40 41 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; … … 42 43 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 43 44 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 44 import org.openstreetmap.josm.gui.layer.OsmDataLayer;45 45 import org.openstreetmap.josm.gui.util.GuiHelper; 46 46 import org.openstreetmap.josm.io.OsmExporter; … … 371 371 List<File> files = getUnsavedLayersFiles(); 372 372 final OpenFileTask openFileTsk = new OpenFileTask(files, null, tr("Restoring files")); 373 final Future<?> openFilesFuture = Main .worker.submit(openFileTsk);374 return Main .worker.submit(() -> {373 final Future<?> openFilesFuture = MainApplication.worker.submit(openFileTsk); 374 return MainApplication.worker.submit(() -> { 375 375 try { 376 376 // Wait for opened tasks to be generated. -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r12630 r12634 316 316 317 317 public static void create(Collection<File> files, GpxLayer gpxLayer) { 318 Main .worker.execute(new Loader(files, gpxLayer));318 MainApplication.worker.execute(new Loader(files, gpxLayer)); 319 319 } 320 320 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java
r12167 r12634 8 8 import java.awt.geom.Rectangle2D; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.actions.DownloadAlongAction; 12 11 import org.openstreetmap.josm.data.coor.LatLon; … … 15 14 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 16 15 import org.openstreetmap.josm.data.gpx.WayPoint; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 18 import org.openstreetmap.josm.gui.help.HelpUtil; … … 197 197 PleaseWaitRunnable task = createTask(); 198 198 if (task != null) { 199 Main .worker.submit(task);199 MainApplication.worker.submit(task); 200 200 } 201 201 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java
r12620 r12634 21 21 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 22 22 import org.openstreetmap.josm.data.gpx.WayPoint; 23 import org.openstreetmap.josm.gui.MainApplication; 23 24 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 25 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; … … 109 110 PrecacheWmsTask task = createTask(); 110 111 if (task != null) { 111 Main .worker.execute(task);112 MainApplication.worker.execute(task); 112 113 } 113 114 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r12620 r12634 22 22 import org.openstreetmap.josm.data.osm.Node; 23 23 import org.openstreetmap.josm.data.osm.Tag; 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 25 26 import org.openstreetmap.josm.gui.layer.Layer; … … 349 350 toReload.add(data.get(i)); 350 351 } 351 Main .worker.submit(new MapPaintStyleLoader(toReload));352 MainApplication.worker.submit(new MapPaintStyleLoader(toReload)); 352 353 } 353 354 -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSetting.java
r12620 r12634 11 11 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.gui.MainApplication; 13 14 import org.openstreetmap.josm.tools.Logging; 14 15 … … 70 71 public void actionPerformed(ActionEvent e) { 71 72 setValue(item.isSelected()); 72 Main .worker.submit(new MapPaintStyles.MapPaintStyleLoader(Arrays.asList(parentStyle)));73 MainApplication.worker.submit(new MapPaintStyles.MapPaintStyleLoader(Arrays.asList(parentStyle))); 73 74 } 74 75 }; -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r10791 r12634 36 36 37 37 import org.openstreetmap.josm.Main; 38 import org.openstreetmap.josm.data.CustomConfigurator;39 38 import org.openstreetmap.josm.data.Preferences; 40 39 import org.openstreetmap.josm.data.oauth.OAuthParameters; … … 306 305 public void initFromPreferences() { 307 306 // Copy current JOSM preferences to update API url with the one used in this wizard 308 Preferences copyPref = CustomConfigurator.clonePreferences(Main.pref);307 Preferences copyPref = new Preferences(Main.pref); 309 308 copyPref.put("osm-server.url", apiUrl); 310 309 pnlFullyAutomaticAuthorisationUI.initFromPreferences(copyPref); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r12620 r12634 35 35 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 36 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 37 import org.openstreetmap.josm.gui.MainApplication; 37 38 import org.openstreetmap.josm.gui.preferences.advanced.AdvancedPreference; 38 39 import org.openstreetmap.josm.gui.preferences.audio.AudioPreference; … … 418 419 // if we have to launch a plugin download task we do it asynchronously, followed 419 420 // by the remaining "save preferences" activites run on the Swing EDT. 420 Main .worker.submit(task);421 Main .worker.submit(() -> SwingUtilities.invokeLater(continuation));421 MainApplication.worker.submit(task); 422 MainApplication.worker.submit(() -> SwingUtilities.invokeLater(continuation)); 422 423 } else { 423 424 // no need for asynchronous activities. Simply run the remaining "save preference" -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r12620 r12634 79 79 import org.openstreetmap.josm.gui.ExtendedDialog; 80 80 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 81 import org.openstreetmap.josm.gui.MainApplication; 81 82 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 82 83 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; … … 533 534 */ 534 535 protected void reloadAvailableSources(String url, List<SourceProvider> sourceProviders) { 535 Main .worker.submit(new SourceLoader(url, sourceProviders));536 MainApplication.worker.submit(new SourceLoader(url, sourceProviders)); 536 537 } 537 538 -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r12620 r12634 38 38 import org.openstreetmap.josm.Main; 39 39 import org.openstreetmap.josm.actions.DiskAccessAction; 40 import org.openstreetmap.josm.data.CustomConfigurator;41 40 import org.openstreetmap.josm.data.Preferences; 42 41 import org.openstreetmap.josm.data.preferences.Setting; 43 42 import org.openstreetmap.josm.data.preferences.StringSetting; 44 43 import org.openstreetmap.josm.gui.dialogs.LogShowDialog; 44 import org.openstreetmap.josm.gui.io.CustomConfigurator; 45 45 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 46 46 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; … … 258 258 return; 259 259 260 Preferences tmpPrefs = CustomConfigurator.clonePreferences(Main.pref);260 Preferences tmpPrefs = new Preferences(Main.pref); 261 261 262 262 StringBuilder log = new StringBuilder(); … … 408 408 @Override 409 409 public void actionPerformed(ActionEvent ae) { 410 Preferences tmpPrefs = CustomConfigurator.clonePreferences(Main.pref);410 Preferences tmpPrefs = new Preferences(Main.pref); 411 411 CustomConfigurator.readXML(file, tmpPrefs); 412 412 readPreferences(tmpPrefs); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java
r9845 r12634 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.actions.DiskAccessAction; 21 import org.openstreetmap.josm.data.CustomConfigurator;22 21 import org.openstreetmap.josm.data.Preferences; 23 22 import org.openstreetmap.josm.data.preferences.Setting; 23 import org.openstreetmap.josm.gui.io.CustomConfigurator; 24 24 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 25 25 import org.openstreetmap.josm.tools.Utils; -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheContentsPanel.java
r12620 r12634 27 27 import org.apache.commons.jcs.engine.stats.behavior.IStatElement; 28 28 import org.apache.commons.jcs.engine.stats.behavior.IStats; 29 import org.openstreetmap.josm.Main;30 29 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 30 import org.openstreetmap.josm.gui.MainApplication; 31 31 import org.openstreetmap.josm.gui.layer.TMSLayer; 32 32 import org.openstreetmap.josm.gui.layer.WMSLayer; … … 51 51 public CacheContentsPanel() { 52 52 super(new GridBagLayout()); 53 Main .worker.submit(() -> {53 MainApplication.worker.submit(() -> { 54 54 addToPanel(TMSLayer.getCache(), "TMS"); 55 55 addToPanel(WMSLayer.getCache(), "WMS"); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r12620 r12634 61 61 import org.openstreetmap.josm.data.imagery.Shape; 62 62 import org.openstreetmap.josm.data.preferences.ColorProperty; 63 import org.openstreetmap.josm.gui.MainApplication; 63 64 import org.openstreetmap.josm.gui.download.DownloadDialog; 64 65 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; … … 657 658 @Override 658 659 public void actionPerformed(ActionEvent evt) { 659 layerInfo.loadDefaults(true, false, false);660 layerInfo.loadDefaults(true, MainApplication.worker, false); 660 661 defaultModel.fireTableDataChanged(); 661 662 defaultTable.getSelectionModel().clearSelection(); -
trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java
r10611 r12634 15 15 import javax.swing.JSeparator; 16 16 17 import org.openstreetmap.josm.data.AutosaveTask;18 17 import org.openstreetmap.josm.data.preferences.BooleanProperty; 18 import org.openstreetmap.josm.gui.layer.AutosaveTask; 19 19 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 20 20 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r12620 r12634 47 47 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 48 48 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 49 import org.openstreetmap.josm.gui.MainApplication; 49 50 import org.openstreetmap.josm.gui.help.HelpUtil; 50 51 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; … … 328 329 } 329 330 }; 330 Main .worker.submit(task);331 Main .worker.submit(r);331 MainApplication.worker.submit(task); 332 MainApplication.worker.submit(r); 332 333 } 333 334 … … 362 363 } 363 364 }; 364 Main .worker.submit(task);365 Main .worker.submit(continuation);365 MainApplication.worker.submit(task); 366 MainApplication.worker.submit(continuation); 366 367 } 367 368 } … … 436 437 } 437 438 pluginDownloadTask.setPluginsToDownload(toUpdate); 438 Main .worker.submit(pluginDownloadTask);439 Main .worker.submit(pluginDownloadContinuation);439 MainApplication.worker.submit(pluginDownloadTask); 440 MainApplication.worker.submit(pluginDownloadContinuation); 440 441 }; 441 442 442 Main .worker.submit(pluginInfoDownloadTask);443 Main .worker.submit(pluginInfoDownloadContinuation);443 MainApplication.worker.submit(pluginInfoDownloadTask); 444 MainApplication.worker.submit(pluginInfoDownloadContinuation); 444 445 } 445 446 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
r12620 r12634 26 26 import org.openstreetmap.josm.data.oauth.OAuthParameters; 27 27 import org.openstreetmap.josm.data.oauth.OAuthToken; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.oauth.AdvancedOAuthPropertiesPanel; 29 30 import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard; … … 315 316 OAuthAuthenticationPreferencesPanel.this, 316 317 apiUrl, 317 Main .worker);318 MainApplication.worker); 318 319 try { 319 320 wizard.showDialog(); … … 364 365 token 365 366 ); 366 Main .worker.submit(task);367 MainApplication.worker.submit(task); 367 368 } 368 369 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r12620 r12634 29 29 import org.openstreetmap.josm.Main; 30 30 import org.openstreetmap.josm.data.preferences.CollectionProperty; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.help.HelpUtil; 32 33 import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator; … … 186 187 final String url = getStrippedApiUrl(); 187 188 final ApiUrlTestTask task = new ApiUrlTestTask(OsmApiUrlInputPanel.this, url); 188 Main .worker.submit(task);189 MainApplication.worker.submit(task); 189 190 Runnable r = () -> { 190 191 if (task.isCanceled()) … … 203 204 SwingUtilities.invokeLater(r1); 204 205 }; 205 Main .worker.submit(r);206 MainApplication.worker.submit(r); 206 207 } 207 208 -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r12620 r12634 50 50 import org.openstreetmap.josm.data.preferences.StrokeProperty; 51 51 import org.openstreetmap.josm.gui.ExtendedDialog; 52 import org.openstreetmap.josm.gui.MainApplication; 52 53 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 53 54 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 93 94 */ 94 95 public static void executeByMainWorkerInEDT(final Runnable task) { 95 Main .worker.submit(() -> runInEDTAndWait(task));96 MainApplication.worker.submit(() -> runInEDTAndWait(task)); 96 97 } 97 98 -
trunk/src/org/openstreetmap/josm/io/FileWatcher.java
r12620 r12634 14 14 import java.util.HashMap; 15 15 import java.util.Map; 16 import java.util.concurrent.Executors; 16 17 17 import org.openstreetmap.josm.Main;18 18 import org.openstreetmap.josm.data.validation.OsmValidator; 19 19 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; … … 24 24 import org.openstreetmap.josm.tools.CheckParameterUtil; 25 25 import org.openstreetmap.josm.tools.Logging; 26 import org.openstreetmap.josm.tools.Utils; 26 27 27 28 /** … … 140 141 if (style != null) { 141 142 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))); 143 145 } else if (rule != null) { 144 146 Logging.info("Validator rule "+rule.getDisplayString()+" has been modified. Reloading rule..."); -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r12620 r12634 121 121 } 122 122 final Runnable authTask = new FutureTask<>(() -> { 123 // Concerning Utils.newDirectExecutor: Main .worker cannot be used since this connection is already124 // 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. 125 125 final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard( 126 126 Main.parent, apiUrl.toExternalForm(), Utils.newDirectExecutor()); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r12630 r12634 145 145 Future<?> future = osmTask.download(newLayer, new Bounds(minlat, minlon, maxlat, maxlon), 146 146 null /* let the task manage the progress monitor */); 147 Main .worker.submit(new PostDownloadHandler(osmTask, future));147 MainApplication.worker.submit(new PostDownloadHandler(osmTask, future)); 148 148 } 149 149 } … … 196 196 try { 197 197 final SearchCompiler.Match search = SearchCompiler.compile(args.get("search")); 198 Main .worker.submit(() -> {198 MainApplication.worker.submit(() -> { 199 199 final DataSet ds = Main.getLayerManager().getEditDataSet(); 200 200 final Collection<OsmPrimitive> filteredPrimitives = SubclassFilteredCollection.filter(ds.allPrimitives(), search); … … 214 214 // add changeset tags after download if necessary 215 215 if (args.containsKey("changeset_comment") || args.containsKey("changeset_source")) { 216 Main .worker.submit(() -> {216 MainApplication.worker.submit(() -> { 217 217 if (Main.getLayerManager().getEditDataSet() != null) { 218 218 if (args.containsKey("changeset_comment")) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadDataHandler.java
r9990 r12634 7 7 import java.nio.charset.StandardCharsets; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 11 10 import org.openstreetmap.josm.data.osm.DataSet; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.io.IllegalDataException; 13 13 import org.openstreetmap.josm.io.OsmReader; … … 40 40 @Override 41 41 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"))); 43 43 } 44 44 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java
r12620 r12634 14 14 import org.openstreetmap.josm.data.osm.PrimitiveId; 15 15 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 16 import org.openstreetmap.josm.gui.MainApplication; 16 17 import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask; 17 18 import org.openstreetmap.josm.gui.util.GuiHelper; … … 68 69 final DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask( 69 70 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(() -> { 72 73 final List<PrimitiveId> downloaded = task.getDownloadedId(); 73 74 final DataSet ds = Main.getLayerManager().getEditDataSet(); -
trunk/src/org/openstreetmap/josm/io/session/SessionImporter.java
r8404 r12634 7 7 import java.io.IOException; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.ExtensionFileFilter; 11 10 import org.openstreetmap.josm.actions.SessionLoadAction.Loader; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 13 13 import org.openstreetmap.josm.io.FileImporter; … … 37 37 public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { 38 38 boolean zip = Utils.hasExtension(file, "joz"); 39 Main .worker.submit(new Loader(file, zip));39 MainApplication.worker.submit(new Loader(file, zip)); 40 40 } 41 41 } -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r12627 r12634 57 57 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 58 58 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 59 import org.openstreetmap.josm.gui.MainApplication; 59 60 import org.openstreetmap.josm.gui.download.DownloadSelection; 60 61 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; … … 590 591 final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask( 591 592 Main.pref.getOnlinePluginSites()); 592 Main .worker.submit(pluginInfoDownloadTask);593 MainApplication.worker.submit(pluginInfoDownloadTask); 593 594 594 595 // Continuation 595 Main .worker.submit(() -> {596 MainApplication.worker.submit(() -> { 596 597 // Build list of plugins to download 597 598 Set<PluginInformation> toDownload = new HashSet<>(pluginInfoDownloadTask.getAvailablePlugins()); … … 601 602 // download plugins 602 603 final PluginDownloadTask task = new PluginDownloadTask(parent, toDownload, tr("Download plugins")); 603 Main .worker.submit(task);604 Main .worker.submit(() -> {604 MainApplication.worker.submit(task); 605 MainApplication.worker.submit(() -> { 605 606 // restart if some plugins have been downloaded 606 607 if (!task.getDownloadedPlugins().isEmpty()) { -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r12620 r12634 17 17 import java.util.Collections; 18 18 import java.util.List; 19 import java.util.concurrent.Executors; 19 20 20 21 import javax.swing.UIManager; … … 148 149 Object oFiles = args[0].getClass().getMethod("getFiles").invoke(args[0]); 149 150 if (oFiles instanceof List) { 150 Main.worker.submit(new OpenFileTask((List<File>) oFiles, null) { 151 Executors.newSingleThreadExecutor(Utils.newThreadFactory("openFiles-%d", Thread.NORM_PRIORITY)).submit( 152 new OpenFileTask((List<File>) oFiles, null) { 151 153 @Override 152 154 protected void realRun() throws SAXException, IOException, OsmTransferException { -
trunk/test/unit/org/openstreetmap/josm/MainTest.java
r12633 r12634 21 21 import org.openstreetmap.josm.Main.InitializationTask; 22 22 import org.openstreetmap.josm.actions.AboutAction; 23 import org.openstreetmap.josm.gui.DownloadParamType;24 23 import org.openstreetmap.josm.gui.MapFrameListener; 25 24 import org.openstreetmap.josm.io.OnlineResource; … … 40 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 41 40 public JOSMTestRules test = new JOSMTestRules().platform().https().devAPI().main().projection(); 42 43 /**44 * Unit test of {@link DownloadParamType#paramType} method.45 */46 @Test47 public void testParamType() {48 assertEquals(DownloadParamType.bounds, DownloadParamType.paramType("48.000,16.000,48.001,16.001"));49 assertEquals(DownloadParamType.fileName, DownloadParamType.paramType("data.osm"));50 assertEquals(DownloadParamType.fileUrl, DownloadParamType.paramType("file:///home/foo/data.osm"));51 assertEquals(DownloadParamType.fileUrl, DownloadParamType.paramType("file://C:\\Users\\foo\\data.osm"));52 assertEquals(DownloadParamType.httpUrl, DownloadParamType.paramType("http://somewhere.com/data.osm"));53 assertEquals(DownloadParamType.httpUrl, DownloadParamType.paramType("https://somewhere.com/data.osm"));54 }55 41 56 42 /** -
trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
r12633 r12634 47 47 @Rule 48 48 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 49 public JOSMTestRules test = new JOSMTestRules(). platform().main();49 public JOSMTestRules test = new JOSMTestRules().main().https().devAPI().timeout(20000); 50 50 51 51 @SuppressFBWarnings(value = "DM_DEFAULT_ENCODING") … … 85 85 public void testShowHelp() throws Exception { 86 86 testShow("--help", MainApplication.getHelp().trim()); 87 } 88 89 /** 90 * Unit test of {@link DownloadParamType#paramType} method. 91 */ 92 @Test 93 public void testParamType() { 94 assertEquals(DownloadParamType.bounds, DownloadParamType.paramType("48.000,16.000,48.001,16.001")); 95 assertEquals(DownloadParamType.fileName, DownloadParamType.paramType("data.osm")); 96 assertEquals(DownloadParamType.fileUrl, DownloadParamType.paramType("file:///home/foo/data.osm")); 97 assertEquals(DownloadParamType.fileUrl, DownloadParamType.paramType("file://C:\\Users\\foo\\data.osm")); 98 assertEquals(DownloadParamType.httpUrl, DownloadParamType.paramType("http://somewhere.com/data.osm")); 99 assertEquals(DownloadParamType.httpUrl, DownloadParamType.paramType("https://somewhere.com/data.osm")); 87 100 } 88 101 -
trunk/test/unit/org/openstreetmap/josm/gui/io/CustomConfiguratorTest.java
r12633 r12634 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. data;2 package org.openstreetmap.josm.gui.io; 3 3 4 4 import static org.junit.Assert.assertEquals; … … 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.TestUtils; 20 import org.openstreetmap.josm.data.CustomConfigurator.PreferencesUtils; 20 import org.openstreetmap.josm.data.Preferences; 21 import org.openstreetmap.josm.data.PreferencesUtils; 22 import org.openstreetmap.josm.gui.io.CustomConfigurator; 21 23 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 24 import org.openstreetmap.josm.tools.Utils; -
trunk/test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java
r12633 r12634 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. data;2 package org.openstreetmap.josm.gui.layer; 3 3 4 4 import static org.junit.Assert.assertEquals; … … 23 23 import org.junit.Test; 24 24 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.data.AutosaveTask.AutosaveLayerInfo;26 25 import org.openstreetmap.josm.data.coor.LatLon; 27 26 import org.openstreetmap.josm.data.osm.DataSet; 28 27 import org.openstreetmap.josm.data.osm.Node; 28 import org.openstreetmap.josm.gui.layer.AutosaveTask; 29 29 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 30 import org.openstreetmap.josm.gui.layer.AutosaveTask.AutosaveLayerInfo; 30 31 import org.openstreetmap.josm.testutils.JOSMTestRules; 31 32 -
trunk/test/unit/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUITest.java
r10989 r12634 6 6 import org.junit.Rule; 7 7 import org.junit.Test; 8 import org.openstreetmap.josm. Main;8 import org.openstreetmap.josm.gui.MainApplication; 9 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 10 … … 28 28 @Test 29 29 public void testFullyAutomaticAuthorizationUI() { 30 assertNotNull(new FullyAutomaticAuthorizationUI("", Main .worker));30 assertNotNull(new FullyAutomaticAuthorizationUI("", MainApplication.worker)); 31 31 } 32 32 } -
trunk/test/unit/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUITest.java
r10989 r12634 6 6 import org.junit.Rule; 7 7 import org.junit.Test; 8 import org.openstreetmap.josm. Main;8 import org.openstreetmap.josm.gui.MainApplication; 9 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 10 … … 28 28 @Test 29 29 public void testManualAuthorizationUI() { 30 assertNotNull(new ManualAuthorizationUI("", Main .worker));30 assertNotNull(new ManualAuthorizationUI("", MainApplication.worker)); 31 31 } 32 32 } -
trunk/test/unit/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUITest.java
r10989 r12634 6 6 import org.junit.Rule; 7 7 import org.junit.Test; 8 import org.openstreetmap.josm. Main;8 import org.openstreetmap.josm.gui.MainApplication; 9 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 10 … … 28 28 @Test 29 29 public void testSemiAutomaticAuthorizationUI() { 30 assertNotNull(new SemiAutomaticAuthorizationUI("", Main .worker));30 assertNotNull(new SemiAutomaticAuthorizationUI("", MainApplication.worker)); 31 31 } 32 32 }
Note:
See TracChangeset
for help on using the changeset viewer.