Changeset 3086 in josm for trunk/src


Ignore:
Timestamp:
2010-03-05T13:13:34+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #4665: Plugin Local version lower Offer version

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r3085 r3086  
    313313            sb.append(buildDownloadSummary(task));
    314314            if (!downloaded.isEmpty()) {
    315                 sb.append("Please restart JOSM to activate the downloaded plugins.");
     315                sb.append(tr("Please restart JOSM to activate the downloaded plugins."));
    316316            }
    317317            sb.append("</html>");
     
    333333                    tr("Update plugins")
    334334            );
    335             Runnable r = new Runnable() {
     335
     336            final ReadRemotePluginInformationTask task2 = new ReadRemotePluginInformationTask(Main.pref.getPluginSites());
     337
     338            final Runnable r2 = new Runnable() {
    336339                public void run() {
    337                     if (task.isCanceled())
     340                    if (task2.isCanceled())
    338341                        return;
    339342                    notifyDownloadResults(task);
     
    342345                }
    343346            };
     347
     348            final Runnable r1 = new Runnable() {
     349                public void run() {
     350                    if (task.isCanceled())
     351                        return;
     352                    Main.worker.submit(task2);
     353                    Main.worker.submit(r2);
     354                }
     355            };
     356
    344357            Main.worker.submit(task);
    345             Main.worker.submit(r);
     358            Main.worker.submit(r1);
    346359        }
    347360    }
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r3083 r3086  
    606606     * Updates the plugins in <code>plugins</code>.
    607607     *
     608     * @param parent the parent window for message boxes
    608609     * @param plugins the collection of plugins to update. Must not be null.
    609610     * @param monitor the progress monitor. Defaults to {@see NullProgressMonitor#INSTANCE} if null.
     
    616617        }
    617618        try {
    618             PluginDownloadTask task = new PluginDownloadTask(
    619                     monitor,
     619            monitor.beginTask("");
     620            ExecutorService service = Executors.newSingleThreadExecutor();
     621
     622            // try to download the plugin lists
     623            //
     624            ReadRemotePluginInformationTask task1 = new ReadRemotePluginInformationTask(
     625                    monitor.createSubTaskMonitor(1,false),
     626                    Main.pref.getPluginSites()
     627            );
     628            Future<?> future = service.submit(task1);
     629            try {
     630                future.get();
     631            } catch(ExecutionException e) {
     632                System.out.println(tr("Warning: failed to download plugin information list"));
     633                e.printStackTrace();
     634                // don't abort in case of error, continue with downloading plugins below
     635            } catch(InterruptedException e) {
     636                System.out.println(tr("Warning: failed to download plugin information list"));
     637                e.printStackTrace();
     638                // don't abort in case of error, continue with downloading plugins below
     639            }
     640
     641            // try to update the locally installed plugins
     642            //
     643            PluginDownloadTask task2 = new PluginDownloadTask(
     644                    monitor.createSubTaskMonitor(1,false),
    620645                    plugins,
    621646                    tr("Update plugins")
    622647            );
    623             ExecutorService service = Executors.newSingleThreadExecutor();
    624             Future<?> future = service.submit(task);
     648
     649            future = service.submit(task2);
    625650            try {
    626651                future.get();
    627652            } catch(ExecutionException e) {
    628653                e.printStackTrace();
     654                alertFailedPluginUpdate(parent, plugins);
     655                return;
    629656            } catch(InterruptedException e) {
    630657                e.printStackTrace();
    631             }
    632             if (! task.getFailedPlugins().isEmpty()) {
    633                 alertFailedPluginUpdate(parent, task.getFailedPlugins());
     658                alertFailedPluginUpdate(parent, plugins);
     659                return;
     660            }
     661            // notify user if downloading a locally installed plugin failed
     662            //
     663            if (! task2.getFailedPlugins().isEmpty()) {
     664                alertFailedPluginUpdate(parent, task2.getFailedPlugins());
    634665                return;
    635666            }
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r3084 r3086  
    2828import org.openstreetmap.josm.data.Version;
    2929import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     30import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3031import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    3132import org.openstreetmap.josm.io.OsmTransferException;
     
    4445    private List<PluginInformation> availabePlugins;
    4546
    46     /**
    47      * Creates the task
    48      *
    49      * @param sites the collection of download sites. Defaults to the empty collection if null.
    50      */
    51     public ReadRemotePluginInformationTask(Collection<String> sites) {
    52         super(tr("Download plugin list..."), false /* don't ignore exceptions */);
     47    protected void init(Collection<String> sites){
    5348        this.sites = sites;
    5449        if (sites == null) {
     
    5651        }
    5752        availabePlugins = new LinkedList<PluginInformation>();
    58     }
     53
     54    }
     55    /**
     56     * Creates the task
     57     *
     58     * @param sites the collection of download sites. Defaults to the empty collection if null.
     59     */
     60    public ReadRemotePluginInformationTask(Collection<String> sites) {
     61        super(tr("Download plugin list..."), false /* don't ignore exceptions */);
     62        init(sites);
     63    }
     64
     65    /**
     66     * Creates the task
     67     *
     68     * @param monitor the progress monitor. Defaults to {@see NullProgressMonitor#INSTANCE} if null
     69     * @param sites the collection of download sites. Defaults to the empty collection if null.
     70     */
     71    public ReadRemotePluginInformationTask(ProgressMonitor monitor, Collection<String> sites) {
     72        super(tr("Download plugin list..."), monitor == null ? NullProgressMonitor.INSTANCE: monitor, false /* don't ignore exceptions */);
     73        init(sites);
     74    }
     75
    5976
    6077    @Override
Note: See TracChangeset for help on using the changeset viewer.