Ignore:
Timestamp:
2014-08-20T03:07:15+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #8885 (see #4614) - add offline mode with new command line argument --offline which can take one of several of these values (comma separated):

  • josm_website: to disable all accesses to JOSM website (when not cached, disables Getting Started page, help, plugin list, styles, imagery, presets, rules)
  • osm_api: to disable all accesses to OSM API (disables download, upload, changeset queries, history, user message notification)
  • all: alias to disable all values. Currently equivalent to "josm_website,osm_api"

Plus improved javadoc, fixed EDT violations, and fixed a bug with HTTP redirection sent without "Location" header

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r7021 r7434  
    5050import org.openstreetmap.josm.gui.widgets.JosmTextField;
    5151import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
     52import org.openstreetmap.josm.io.OfflineAccessException;
     53import org.openstreetmap.josm.io.OnlineResource;
    5254import org.openstreetmap.josm.plugins.PluginDownloadTask;
    5355import org.openstreetmap.josm.plugins.PluginInformation;
     
    114116        return sb.toString();
    115117    }
    116    
     118
    117119    /**
    118120     * Notifies user about result of a finished plugin download task.
     
    313315    }
    314316
     317    private static Collection<String> getOnlinePluginSites() {
     318        Collection<String> pluginSites = new ArrayList<>(Main.pref.getPluginSites());
     319        for (Iterator<String> it = pluginSites.iterator(); it.hasNext();) {
     320            try {
     321                OnlineResource.JOSM_WEBSITE.checkOfflineAccess(it.next(), Main.getJOSMWebsite());
     322            } catch (OfflineAccessException ex) {
     323                Main.warn(ex.getMessage());
     324                it.remove();
     325            }
     326        }
     327        return pluginSites;
     328    }
     329
    315330    /**
    316331     * The action for downloading the list of available plugins
    317      *
    318332     */
    319333    class DownloadAvailablePluginsAction extends AbstractAction {
     
    327341        @Override
    328342        public void actionPerformed(ActionEvent e) {
    329             final ReadRemotePluginInformationTask task = new ReadRemotePluginInformationTask(Main.pref.getPluginSites());
     343            Collection<String> pluginSites = getOnlinePluginSites();
     344            if (pluginSites.isEmpty()) {
     345                return;
     346            }
     347            final ReadRemotePluginInformationTask task = new ReadRemotePluginInformationTask(pluginSites);
    330348            Runnable continuation = new Runnable() {
    331349                @Override
     
    345363            Main.worker.submit(continuation);
    346364        }
    347     }
    348 
    349     /**
    350      * The action for downloading the list of available plugins
    351      *
     365
     366    }
     367
     368    /**
     369     * The action for updating the list of selected plugins
    352370     */
    353371    class UpdateSelectedPluginsAction extends AbstractAction {
     
    387405                    );
    388406            // the async task for downloading plugin information
    389             final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(Main.pref.getPluginSites());
     407            final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(getOnlinePluginSites());
    390408
    391409            // to be run asynchronously after the plugin download
Note: See TracChangeset for help on using the changeset viewer.