Changeset 14121 in josm
- Timestamp:
- 2018-08-11T17:51:12+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r14120 r14121 11 11 import java.util.Collection; 12 12 import java.util.Collections; 13 import java.util.EnumSet;14 import java.util.HashMap;15 13 import java.util.List; 16 14 import java.util.Map; … … 36 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 37 35 import org.openstreetmap.josm.io.FileWatcher; 36 import org.openstreetmap.josm.io.NetworkManager; 38 37 import org.openstreetmap.josm.io.OnlineResource; 39 38 import org.openstreetmap.josm.spi.preferences.Config; … … 80 79 */ 81 80 public static final FileWatcher fileWatcher = new FileWatcher(); 82 83 private static final Map<String, Throwable> NETWORK_ERRORS = new HashMap<>();84 85 private static final Set<OnlineResource> OFFLINE_RESOURCES = EnumSet.noneOf(OnlineResource.class);86 81 87 82 /** … … 423 418 * @param t The network error 424 419 * @return The previous error associated to the given resource, if any. Can be {@code null} 420 * @deprecated Use {@link NetworkManager#addNetworkError(URL, Throwable)} 425 421 * @since 6642 426 422 */ 423 @Deprecated 427 424 public static Throwable addNetworkError(URL url, Throwable t) { 428 if (url != null && t != null) { 429 Throwable old = addNetworkError(url.toExternalForm(), t); 430 if (old != null) { 431 Logging.warn("Already here "+old); 432 } 433 return old; 434 } 435 return null; 425 return NetworkManager.addNetworkError(url, t); 436 426 } 437 427 … … 443 433 * @param t The network error 444 434 * @return The previous error associated to the given resource, if any. Can be {@code null} 435 * @deprecated Use {@link NetworkManager#addNetworkError(String, Throwable)} 445 436 * @since 6642 446 437 */ 438 @Deprecated 447 439 public static Throwable addNetworkError(String url, Throwable t) { 448 if (url != null && t != null) { 449 return NETWORK_ERRORS.put(url, t); 450 } 451 return null; 440 return NetworkManager.addNetworkError(url, t); 452 441 } 453 442 … … 455 444 * Returns the network errors that occured until now. 456 445 * @return the network errors that occured until now, indexed by URL 446 * @deprecated Use {@link NetworkManager#getNetworkErrors} 457 447 * @since 6639 458 448 */ 449 @Deprecated 459 450 public static Map<String, Throwable> getNetworkErrors() { 460 return new HashMap<>(NETWORK_ERRORS);451 return NetworkManager.getNetworkErrors(); 461 452 } 462 453 463 454 /** 464 455 * Clears the network errors cache. 456 * @deprecated Use {@link NetworkManager#clearNetworkErrors} 465 457 * @since 12011 466 458 */ 459 @Deprecated 467 460 public static void clearNetworkErrors() { 468 N ETWORK_ERRORS.clear();461 NetworkManager.clearNetworkErrors(); 469 462 } 470 463 … … 546 539 * @param r the online resource 547 540 * @return {@code true} if {@code r} is offline and should not be accessed 541 * @deprecated Use {@link NetworkManager#isOffline} 548 542 * @since 7434 549 543 */ 544 @Deprecated 550 545 public static boolean isOffline(OnlineResource r) { 551 return OFFLINE_RESOURCES.contains(r) || OFFLINE_RESOURCES.contains(OnlineResource.ALL);546 return NetworkManager.isOffline(r); 552 547 } 553 548 … … 556 551 * @param r the online resource 557 552 * @return {@code true} if {@code r} was not already offline 553 * @deprecated Use {@link NetworkManager#setOffline} 558 554 * @since 7434 559 555 */ 556 @Deprecated 560 557 public static boolean setOffline(OnlineResource r) { 561 return OFFLINE_RESOURCES.add(r);558 return NetworkManager.setOffline(r); 562 559 } 563 560 … … 566 563 * @param r the online resource 567 564 * @return {@code true} if {@code r} was offline 565 * @deprecated Use {@link NetworkManager#setOnline} 568 566 * @since 8506 569 567 */ 568 @Deprecated 570 569 public static boolean setOnline(OnlineResource r) { 571 return OFFLINE_RESOURCES.remove(r);570 return NetworkManager.setOnline(r); 572 571 } 573 572 … … 575 574 * Replies the set of online resources currently offline. 576 575 * @return the set of online resources currently offline 576 * @deprecated Use {@link NetworkManager#getOfflineResources} 577 577 * @since 7434 578 578 */ 579 @Deprecated 579 580 public static Set<OnlineResource> getOfflineResources() { 580 return EnumSet.copyOf(OFFLINE_RESOURCES);581 return NetworkManager.getOfflineResources(); 581 582 } 582 583 } -
trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java
r13761 r14121 24 24 import org.openstreetmap.josm.gui.io.CloseChangesetTask; 25 25 import org.openstreetmap.josm.io.ChangesetQuery; 26 import org.openstreetmap.josm.io.NetworkManager; 26 27 import org.openstreetmap.josm.io.OnlineResource; 27 28 import org.openstreetmap.josm.io.OsmServerChangesetReader; … … 52 53 ); 53 54 putValue("help", ht("/Action/CloseChangeset")); 54 setEnabled(! Main.isOffline(OnlineResource.OSM_API));55 setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API)); 55 56 56 57 } -
trunk/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java
r13927 r14121 7 7 import java.util.concurrent.Future; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask; 11 10 import org.openstreetmap.josm.actions.downloadtasks.DownloadParams; … … 13 12 import org.openstreetmap.josm.data.Bounds; 14 13 import org.openstreetmap.josm.gui.MainApplication; 14 import org.openstreetmap.josm.io.NetworkManager; 15 15 import org.openstreetmap.josm.io.OnlineResource; 16 16 … … 55 55 protected void updateEnabledState() { 56 56 setEnabled(getLayerManager().getActiveLayer() != null 57 && ! Main.isOffline(OnlineResource.OSM_API));57 && !NetworkManager.isOffline(OnlineResource.OSM_API)); 58 58 } 59 59 } -
trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java
r13927 r14121 7 7 import java.util.concurrent.Future; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 11 10 import org.openstreetmap.josm.actions.downloadtasks.DownloadParams; … … 14 13 import org.openstreetmap.josm.gui.MainApplication; 15 14 import org.openstreetmap.josm.io.BoundingBoxDownloader; 15 import org.openstreetmap.josm.io.NetworkManager; 16 16 import org.openstreetmap.josm.io.OnlineResource; 17 17 … … 43 43 protected void updateEnabledState() { 44 44 setEnabled(getLayerManager().getActiveLayer() != null 45 && ! Main.isOffline(OnlineResource.OSM_API));45 && !NetworkManager.isOffline(OnlineResource.OSM_API)); 46 46 } 47 47 -
trunk/src/org/openstreetmap/josm/actions/HelpAction.java
r11553 r14121 15 15 import org.openstreetmap.josm.gui.help.HelpBrowser; 16 16 import org.openstreetmap.josm.gui.help.HelpUtil; 17 import org.openstreetmap.josm.io.NetworkManager; 17 18 import org.openstreetmap.josm.io.OnlineResource; 18 19 import org.openstreetmap.josm.tools.Shortcut; … … 35 36 shortcut ? Shortcut.registerShortcut("system:help", tr("Help"), KeyEvent.VK_F1, Shortcut.DIRECT) : null, 36 37 true); 37 setEnabled(! Main.isOffline(OnlineResource.JOSM_WEBSITE));38 setEnabled(!NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)); 38 39 } 39 40 -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java
r13926 r14121 13 13 import org.openstreetmap.josm.gui.dialogs.OsmIdSelectionDialog; 14 14 import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager; 15 import org.openstreetmap.josm.io.NetworkManager; 15 16 import org.openstreetmap.josm.io.OnlineResource; 16 17 import org.openstreetmap.josm.tools.Shortcut; … … 67 68 public void setupDialog() { 68 69 super.setupDialog(); 69 buttons.get(0).setEnabled(! Main.isOffline(OnlineResource.OSM_API));70 buttons.get(0).setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API)); 70 71 } 71 72 } -
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r13486 r14121 12 12 import java.util.concurrent.Future; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.actions.downloadtasks.DownloadTaskList; 16 15 import org.openstreetmap.josm.data.DataSource; 17 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 17 import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor; 18 import org.openstreetmap.josm.io.NetworkManager; 19 19 import org.openstreetmap.josm.io.OnlineResource; 20 20 import org.openstreetmap.josm.tools.Shortcut; … … 48 48 protected void updateEnabledState() { 49 49 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 50 setEnabled(editLayer != null && editLayer.isDownloadable() && ! Main.isOffline(OnlineResource.OSM_API));50 setEnabled(editLayer != null && editLayer.isDownloadable() && !NetworkManager.isOffline(OnlineResource.OSM_API)); 51 51 } 52 52 -
trunk/src/org/openstreetmap/josm/actions/UpdateModifiedAction.java
r13559 r14121 9 9 import java.util.Collections; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.DataSet; 13 12 import org.openstreetmap.josm.data.osm.DownloadPolicy; 14 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.io.NetworkManager; 15 15 import org.openstreetmap.josm.io.OnlineResource; 16 16 import org.openstreetmap.josm.tools.Shortcut; … … 49 49 DataSet ds = getLayerManager().getEditDataSet(); 50 50 setEnabled(ds != null && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()) 51 && ! Main.isOffline(OnlineResource.OSM_API));51 && !NetworkManager.isOffline(OnlineResource.OSM_API)); 52 52 } 53 53 -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r13559 r14121 25 25 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 26 26 import org.openstreetmap.josm.io.MultiFetchServerObjectReader; 27 import org.openstreetmap.josm.io.NetworkManager; 27 28 import org.openstreetmap.josm.io.OnlineResource; 28 29 import org.openstreetmap.josm.io.OsmTransferException; … … 125 126 DataSet ds = selection.iterator().next().getDataSet(); 126 127 setEnabled(!ds.isLocked() && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()) 127 && ! Main.isOffline(OnlineResource.OSM_API));128 && !NetworkManager.isOffline(OnlineResource.OSM_API)); 128 129 } 129 130 } -
trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java
r13957 r14121 7 7 import javax.swing.AbstractAction; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.IPrimitiveAction; 11 10 import org.openstreetmap.josm.data.osm.DownloadPolicy; … … 13 12 import org.openstreetmap.josm.data.osm.IRelation; 14 13 import org.openstreetmap.josm.data.osm.OsmData; 14 import org.openstreetmap.josm.io.NetworkManager; 15 15 import org.openstreetmap.josm.io.OnlineResource; 16 16 import org.openstreetmap.josm.tools.SubclassFilteredCollection; … … 57 57 } 58 58 OsmData<?, ?, ?, ?> ds = relations.iterator().next().getDataSet(); 59 return ! Main.isOffline(OnlineResource.OSM_API)59 return !NetworkManager.isOffline(OnlineResource.OSM_API) 60 60 && ds != null && !ds.isLocked() && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()); 61 61 } -
trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java
r13761 r14121 17 17 import org.openstreetmap.josm.gui.MainApplication; 18 18 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 19 import org.openstreetmap.josm.io.NetworkManager; 19 20 import org.openstreetmap.josm.io.OnlineResource; 20 21 import org.openstreetmap.josm.io.OsmApi; … … 33 34 OsmApi api = OsmApi.getOsmApi(); 34 35 try { 35 if ( Main.isOffline(OnlineResource.OSM_API)) {36 if (NetworkManager.isOffline(OnlineResource.OSM_API)) { 36 37 return false; 37 38 } -
trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java
r14095 r14121 6 6 import java.text.MessageFormat; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder; 10 9 import org.openstreetmap.josm.data.osm.User; 11 10 import org.openstreetmap.josm.data.osm.UserInfo; 12 11 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 12 import org.openstreetmap.josm.io.NetworkManager; 13 13 import org.openstreetmap.josm.io.OnlineResource; 14 14 import org.openstreetmap.josm.io.OsmApi; … … 67 67 instance = new UserIdentityManager(); 68 68 if (OsmApi.isUsingOAuth() && OAuthAccessTokenHolder.getInstance().containsAccessToken() && 69 ! Main.isOffline(OnlineResource.OSM_API)) {69 !NetworkManager.isOffline(OnlineResource.OSM_API)) { 70 70 try { 71 71 instance.initFromOAuth(); -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r13888 r14121 32 32 import javax.swing.UIManager; 33 33 34 import org.openstreetmap.josm.Main;35 34 import org.openstreetmap.josm.gui.help.HelpBrowser; 36 35 import org.openstreetmap.josm.gui.help.HelpUtil; … … 38 37 import org.openstreetmap.josm.gui.util.WindowGeometry; 39 38 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 39 import org.openstreetmap.josm.io.NetworkManager; 40 40 import org.openstreetmap.josm.io.OnlineResource; 41 41 import org.openstreetmap.josm.tools.GBC; … … 554 554 putValue(NAME, tr("Help")); 555 555 new ImageProvider("help").getResource().attachImageIcon(this, true); 556 setEnabled(! Main.isOffline(OnlineResource.JOSM_WEBSITE));556 setEnabled(!NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)); 557 557 } 558 558 -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14120 r14121 147 147 import org.openstreetmap.josm.io.FileWatcher; 148 148 import org.openstreetmap.josm.io.MessageNotifier; 149 import org.openstreetmap.josm.io.NetworkManager; 149 150 import org.openstreetmap.josm.io.OnlineResource; 150 151 import org.openstreetmap.josm.io.OsmApi; … … 1310 1311 for (String s : offlineNames.split(",")) { 1311 1312 try { 1312 Main.setOffline(OnlineResource.valueOf(s.toUpperCase(Locale.ENGLISH)));1313 NetworkManager.setOffline(OnlineResource.valueOf(s.toUpperCase(Locale.ENGLISH))); 1313 1314 } catch (IllegalArgumentException e) { 1314 1315 Logging.log(Logging.LEVEL_ERROR, … … 1320 1321 } 1321 1322 } 1322 Set<OnlineResource> offline = Main.getOfflineResources();1323 Set<OnlineResource> offline = NetworkManager.getOfflineResources(); 1323 1324 if (!offline.isEmpty()) { 1324 1325 Logging.warn(trn("JOSM is running in offline mode. This resource will not be available: {0}", … … 1508 1509 1509 1510 private static boolean handleNetworkErrors() { 1510 Map<String, Throwable> networkErrors = Main.getNetworkErrors();1511 Map<String, Throwable> networkErrors = NetworkManager.getNetworkErrors(); 1511 1512 boolean condition = !networkErrors.isEmpty(); 1512 1513 if (condition) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r14119 r14121 33 33 import javax.swing.event.ListSelectionListener; 34 34 35 import org.openstreetmap.josm.Main;36 35 import org.openstreetmap.josm.actions.AbstractInfoAction; 37 36 import org.openstreetmap.josm.actions.downloadtasks.ChangesetHeaderDownloadTask; … … 56 55 import org.openstreetmap.josm.gui.widgets.ListPopupMenu; 57 56 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 57 import org.openstreetmap.josm.io.NetworkManager; 58 58 import org.openstreetmap.josm.io.OnlineResource; 59 59 import org.openstreetmap.josm.spi.preferences.Config; … … 361 361 362 362 protected void updateEnabledState() { 363 setEnabled(getCurrentChangesetList().getSelectedIndices().length > 0 && ! Main.isOffline(OnlineResource.OSM_API));363 setEnabled(getCurrentChangesetList().getSelectedIndices().length > 0 && !NetworkManager.isOffline(OnlineResource.OSM_API)); 364 364 } 365 365 … … 498 498 public static void displayChangesets(final Set<Integer> sel) { 499 499 final Set<Integer> toDownload = new HashSet<>(); 500 if (! Main.isOffline(OnlineResource.OSM_API)) {500 if (!NetworkManager.isOffline(OnlineResource.OSM_API)) { 501 501 ChangesetCache cc = ChangesetCache.getInstance(); 502 502 for (int id: sel) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r12743 r14121 41 41 import javax.swing.event.ListSelectionListener; 42 42 43 import org.openstreetmap.josm.Main;44 43 import org.openstreetmap.josm.actions.downloadtasks.AbstractChangesetDownloadTask; 45 44 import org.openstreetmap.josm.actions.downloadtasks.ChangesetContentDownloadTask; … … 64 63 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 65 64 import org.openstreetmap.josm.io.ChangesetQuery; 65 import org.openstreetmap.josm.io.NetworkManager; 66 66 import org.openstreetmap.josm.io.OnlineResource; 67 67 import org.openstreetmap.josm.tools.ImageProvider; … … 387 387 new ImageProvider("dialogs", "search").getResource().attachImageIcon(this); 388 388 putValue(SHORT_DESCRIPTION, tr("Launch the dialog for querying changesets")); 389 setEnabled(! Main.isOffline(OnlineResource.OSM_API));389 setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API)); 390 390 } 391 391 … … 511 511 512 512 protected void updateEnabledState() { 513 setEnabled(model.hasSelectedChangesets() && ! Main.isOffline(OnlineResource.OSM_API));513 setEnabled(model.hasSelectedChangesets() && !NetworkManager.isOffline(OnlineResource.OSM_API)); 514 514 } 515 515 … … 544 544 545 545 protected void updateEnabledState() { 546 setEnabled(model.hasSelectedChangesets() && ! Main.isOffline(OnlineResource.OSM_API));546 setEnabled(model.hasSelectedChangesets() && !NetworkManager.isOffline(OnlineResource.OSM_API)); 547 547 } 548 548 … … 584 584 585 585 protected void updateEnabledState() { 586 setEnabled(model.hasSelectedChangesets() && ! Main.isOffline(OnlineResource.OSM_API));586 setEnabled(model.hasSelectedChangesets() && !NetworkManager.isOffline(OnlineResource.OSM_API)); 587 587 } 588 588 … … 618 618 new ImageProvider("dialogs/changeset", "downloadchangeset").getResource().attachImageIcon(this); 619 619 putValue(SHORT_DESCRIPTION, tr("Download my changesets from the OSM server (max. 100 changesets)")); 620 setEnabled(! Main.isOffline(OnlineResource.OSM_API));620 setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API)); 621 621 } 622 622 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java
r13434 r14121 29 29 import javax.swing.JToolBar; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.actions.AutoScaleAction; 33 32 import org.openstreetmap.josm.actions.downloadtasks.ChangesetHeaderDownloadTask; … … 45 44 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 46 45 import org.openstreetmap.josm.gui.widgets.JosmTextField; 46 import org.openstreetmap.josm.io.NetworkManager; 47 47 import org.openstreetmap.josm.io.OnlineResource; 48 48 import org.openstreetmap.josm.tools.ImageProvider; … … 331 331 332 332 public void initProperties(Changeset cs) { 333 setEnabled(cs != null && ! Main.isOffline(OnlineResource.OSM_API));333 setEnabled(cs != null && !NetworkManager.isOffline(OnlineResource.OSM_API)); 334 334 } 335 335 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java
r12634 r14121 20 20 import javax.swing.JToolBar; 21 21 22 import org.openstreetmap.josm.Main;23 22 import org.openstreetmap.josm.actions.downloadtasks.ChangesetHeaderDownloadTask; 24 23 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 25 24 import org.openstreetmap.josm.data.osm.Changeset; 26 25 import org.openstreetmap.josm.gui.MainApplication; 26 import org.openstreetmap.josm.io.NetworkManager; 27 27 import org.openstreetmap.josm.io.OnlineResource; 28 28 import org.openstreetmap.josm.tools.ImageProvider; … … 83 83 84 84 public void initProperties(Changeset cs) { 85 setEnabled(cs != null && ! Main.isOffline(OnlineResource.OSM_API));85 setEnabled(cs != null && !NetworkManager.isOffline(OnlineResource.OSM_API)); 86 86 } 87 87 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/SingleChangesetDownloadPanel.java
r12846 r14121 17 17 import javax.swing.event.DocumentListener; 18 18 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.actions.downloadtasks.ChangesetContentDownloadTask; 21 20 import org.openstreetmap.josm.gui.widgets.ChangesetIdTextField; 22 21 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; 22 import org.openstreetmap.josm.io.NetworkManager; 23 23 import org.openstreetmap.josm.io.OnlineResource; 24 24 import org.openstreetmap.josm.spi.preferences.Config; … … 88 88 89 89 @Override 90 public void actionPerformed(ActionEvent arg0) {90 public void actionPerformed(ActionEvent e) { 91 91 if (!isEnabled()) 92 92 return; … … 102 102 103 103 protected void updateEnabledState() { 104 setEnabled(tfChangesetId.readIds() && ! Main.isOffline(OnlineResource.OSM_API));104 setEnabled(tfChangesetId.readIds() && !NetworkManager.isOffline(OnlineResource.OSM_API)); 105 105 } 106 106 107 107 @Override 108 public void changedUpdate(DocumentEvent arg0) {108 public void changedUpdate(DocumentEvent e) { 109 109 updateEnabledState(); 110 110 } 111 111 112 112 @Override 113 public void insertUpdate(DocumentEvent arg0) {113 public void insertUpdate(DocumentEvent e) { 114 114 updateEnabledState(); 115 115 } 116 116 117 117 @Override 118 public void removeUpdate(DocumentEvent arg0) {118 public void removeUpdate(DocumentEvent e) { 119 119 updateEnabledState(); 120 120 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorAction.java
r14030 r14121 12 12 import javax.swing.event.TableModelListener; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.data.osm.DataSet; 16 15 import org.openstreetmap.josm.data.osm.DownloadPolicy; … … 22 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 22 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 23 import org.openstreetmap.josm.io.NetworkManager; 24 24 import org.openstreetmap.josm.io.OnlineResource; 25 25 … … 93 93 return false; 94 94 DataSet ds = editorAccess.getEditor().getRelation().getDataSet(); 95 return ! Main.isOffline(OnlineResource.OSM_API) && ds != null && !ds.isLocked()95 return !NetworkManager.isOffline(OnlineResource.OSM_API) && ds != null && !ds.isLocked() 96 96 && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()); 97 97 } -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r14106 r14121 48 48 import org.openstreetmap.josm.gui.util.GuiHelper; 49 49 import org.openstreetmap.josm.gui.util.WindowGeometry; 50 import org.openstreetmap.josm.io.NetworkManager; 50 51 import org.openstreetmap.josm.io.OnlineResource; 51 52 import org.openstreetmap.josm.plugins.PluginHandler; … … 549 550 new ImageProvider("download").getResource().attachImageIcon(this); 550 551 putValue(SHORT_DESCRIPTION, tr("Click to download the currently selected area")); 551 setEnabled(! Main.isOffline(OnlineResource.OSM_API));552 setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API)); 552 553 } 553 554 -
trunk/src/org/openstreetmap/josm/gui/download/DownloadObjectDialog.java
r13288 r14121 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 15 15 import org.openstreetmap.josm.gui.dialogs.OsmIdSelectionDialog; 16 import org.openstreetmap.josm.io.NetworkManager; 16 17 import org.openstreetmap.josm.io.OnlineResource; 17 18 import org.openstreetmap.josm.spi.preferences.Config; … … 54 55 public void setupDialog() { 55 56 super.setupDialog(); 56 buttons.get(0).setEnabled(! Main.isOffline(OnlineResource.OSM_API));57 buttons.get(0).setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API)); 57 58 } 58 59 -
trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java
r11553 r14121 10 10 import javax.swing.AbstractAction; 11 11 12 import org.openstreetmap.josm. Main;12 import org.openstreetmap.josm.io.NetworkManager; 13 13 import org.openstreetmap.josm.io.OnlineResource; 14 14 import org.openstreetmap.josm.tools.ImageProvider; … … 48 48 new ImageProvider("help").getResource().attachImageIcon(this); 49 49 this.helpTopic = helpTopic; 50 setEnabled(! Main.isOffline(OnlineResource.JOSM_WEBSITE));50 setEnabled(!NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)); 51 51 } 52 52 -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r13130 r14121 91 91 import org.openstreetmap.josm.gui.widgets.JosmTextField; 92 92 import org.openstreetmap.josm.io.CachedFile; 93 import org.openstreetmap.josm.io.NetworkManager; 93 94 import org.openstreetmap.josm.io.OnlineResource; 94 95 import org.openstreetmap.josm.io.OsmTransferException; … … 1155 1156 this.url = url; 1156 1157 this.sourceProviders = sourceProviders; 1157 setEnabled(! Main.isOffline(OnlineResource.JOSM_WEBSITE));1158 setEnabled(!NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)); 1158 1159 } 1159 1160 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java
r14119 r14121 42 42 import org.openstreetmap.josm.gui.tagging.presets.items.Text; 43 43 import org.openstreetmap.josm.io.CachedFile; 44 import org.openstreetmap.josm.io.NetworkManager; 44 45 import org.openstreetmap.josm.io.UTFInputStreamReader; 45 46 import org.openstreetmap.josm.spi.preferences.Config; … … 386 387 Logging.error(source); 387 388 if (source.startsWith("http")) { 388 Main.addNetworkError(source, e);389 NetworkManager.addNetworkError(source, e); 389 390 } 390 391 if (displayErrMsg) { -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r12869 r14121 10 10 import java.util.concurrent.TimeUnit; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.UserIdentityManager; 14 13 import org.openstreetmap.josm.data.osm.UserInfo; … … 100 99 public static void start() { 101 100 int interval = PROP_INTERVAL.get(); 102 if ( Main.isOffline(OnlineResource.OSM_API)) {101 if (NetworkManager.isOffline(OnlineResource.OSM_API)) { 103 102 Logging.info(tr("{0} not available (offline mode)", tr("Message notifier"))); 104 103 } else if (!isRunning() && interval > 0 && isUserEnoughIdentified()) { -
trunk/src/org/openstreetmap/josm/io/OnlineResource.java
r8674 r14121 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import org.openstreetmap.josm.Main;7 5 8 6 /** … … 43 41 */ 44 42 public final void checkOfflineAccess(String downloadString, String resourceString) { 45 if ( Main.isOffline(this) && downloadString.substring(downloadString.indexOf("://"))43 if (NetworkManager.isOffline(this) && downloadString.substring(downloadString.indexOf("://")) 46 44 .startsWith(resourceString.substring(resourceString.indexOf("://")))) { 47 45 throw new OfflineAccessException(tr("Unable to access ''{0}'': {1} not available (offline mode)", downloadString, getLocName())); -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r14119 r14121 25 25 import javax.xml.parsers.ParserConfigurationException; 26 26 27 import org.openstreetmap.josm.Main;28 27 import org.openstreetmap.josm.data.coor.LatLon; 29 28 import org.openstreetmap.josm.data.notes.Note; … … 259 258 } 260 259 if (capabilities == null) { 261 if ( Main.isOffline(OnlineResource.OSM_API)) {260 if (NetworkManager.isOffline(OnlineResource.OSM_API)) { 262 261 Logging.warn(tr("{0} not available (offline mode)", tr("OSM API"))); 263 262 } else { … … 280 279 } catch (OsmTransferException e) { 281 280 initialized = false; 282 Main.addNetworkError(url, Utils.getRootCause(e));281 NetworkManager.addNetworkError(url, Utils.getRootCause(e)); 283 282 throw new OsmApiInitializationException(e); 284 283 } catch (SAXException | IOException | ParserConfigurationException e) { -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r14119 r14121 67 67 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 68 68 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 69 import org.openstreetmap.josm.io.NetworkManager; 69 70 import org.openstreetmap.josm.io.OfflineAccessException; 70 71 import org.openstreetmap.josm.io.OnlineResource; … … 530 531 531 532 private static boolean checkOfflineAccess() { 532 if ( Main.isOffline(OnlineResource.ALL)) {533 if (NetworkManager.isOffline(OnlineResource.ALL)) { 533 534 return false; 534 535 } 535 if ( Main.isOffline(OnlineResource.JOSM_WEBSITE)) {536 if (NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)) { 536 537 for (String updateSite : Main.pref.getPluginSites()) { 537 538 try { -
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r13647 r14121 29 29 import java.util.zip.GZIPInputStream; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.data.Version; 33 32 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 34 33 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 35 34 import org.openstreetmap.josm.io.Compression; 35 import org.openstreetmap.josm.io.NetworkManager; 36 36 import org.openstreetmap.josm.io.ProgressInputStream; 37 37 import org.openstreetmap.josm.io.ProgressOutputStream; … … 162 162 Logging.warn(e); 163 163 //noinspection ThrowableResultOfMethodCallIgnored 164 Main.addNetworkError(url, Utils.getRootCause(e));164 NetworkManager.addNetworkError(url, Utils.getRootCause(e)); 165 165 throw e; 166 166 } -
trunk/test/unit/org/openstreetmap/josm/MainTest.java
r14120 r14121 2 2 package org.openstreetmap.josm; 3 3 4 import static org.junit.Assert.assertEquals;5 4 import static org.junit.Assert.assertFalse; 6 5 import static org.junit.Assert.assertNotNull; 7 6 import static org.junit.Assert.assertTrue; 8 9 import java.net.MalformedURLException;10 import java.net.URL;11 import java.util.Map;12 7 13 8 import org.junit.Rule; … … 16 11 import org.openstreetmap.josm.Main.InitializationTask; 17 12 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; 18 import org.openstreetmap.josm.io.OnlineResource;19 13 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 14 … … 40 34 Main.preConstructorInit(); 41 35 assertNotNull(CoordinateFormatManager.getDefaultFormat()); 42 }43 44 /**45 * Unit test of {@link Main#addNetworkError}, {@link Main#getNetworkErrors} and {@link Main#clearNetworkErrors}.46 * @throws MalformedURLException if any error occurs47 */48 @Test49 public void testNetworkErrors() throws MalformedURLException {50 Main.clearNetworkErrors();51 assertTrue(Main.getNetworkErrors().isEmpty());52 Main.addNetworkError("http://url1", new Exception("exception_1"));53 Main.addNetworkError(new URL("http://url2"), new Exception("exception_2"));54 Map<String, Throwable> errors = Main.getNetworkErrors();55 assertEquals(2, errors.size());56 assertEquals("exception_1", errors.get("http://url1").getMessage());57 assertEquals("exception_2", errors.get("http://url2").getMessage());58 Main.clearNetworkErrors();59 assertTrue(Main.getNetworkErrors().isEmpty());60 }61 62 /**63 * Unit test of {@link Main#setOffline} and {@link Main#getOfflineResources}.64 */65 @Test66 public void testOfflineRessources() {67 Main.setOnline(OnlineResource.ALL);68 assertTrue(Main.getOfflineResources().isEmpty());69 assertFalse(Main.isOffline(OnlineResource.JOSM_WEBSITE));70 Main.setOffline(OnlineResource.JOSM_WEBSITE);71 assertTrue(Main.isOffline(OnlineResource.JOSM_WEBSITE));72 Main.setOnline(OnlineResource.JOSM_WEBSITE);73 assertFalse(Main.isOffline(OnlineResource.JOSM_WEBSITE));74 Main.setOffline(OnlineResource.ALL);75 assertTrue(Main.isOffline(OnlineResource.JOSM_WEBSITE));76 assertTrue(Main.isOffline(OnlineResource.OSM_API));77 Main.setOnline(OnlineResource.ALL);78 36 } 79 37
Note:
See TracChangeset
for help on using the changeset viewer.