Package org.openstreetmap.josm.plugins

Examples of org.openstreetmap.josm.plugins.PluginDownloadTask


        // create a task for downloading plugins if the user has activated, yet not downloaded,
        // new plugins
        //
        final PluginPreference preference = getPluginPreference();
        final List<PluginInformation> toDownload = preference.getPluginsScheduledForUpdateOrDownload();
        final PluginDownloadTask task;
        if (toDownload != null && ! toDownload.isEmpty()) {
            task = new PluginDownloadTask(this, toDownload, tr("Download plugins"));
        } else {
            task = null;
        }

        // this is the task which will run *after* the plugins are downloaded
        //
        final Runnable continuation = new Runnable() {
            @Override
            public void run() {
                boolean requiresRestart = false;
                if (task != null && !task.isCanceled()) {
                    if (!task.getDownloadedPlugins().isEmpty()) {
                        requiresRestart = true;
                    }
                }

                for (PreferenceSetting setting : settingsInitialized) {
                    if (setting.ok()) {
                        requiresRestart = true;
                    }
                }

                // build the messages. We only display one message, including the status
                // information from the plugin download task and - if necessary - a hint
                // to restart JOSM
                //
                StringBuilder sb = new StringBuilder();
                sb.append("<html>");
                if (task != null && !task.isCanceled()) {
                    sb.append(PluginPreference.buildDownloadSummary(task));
                }
                if (requiresRestart) {
                    sb.append(tr("You have to restart JOSM for some settings to take effect."));
                    sb.append("<br/><br/>");
                    sb.append(tr("Would you like to restart now?"));
                }
                sb.append("</html>");

                // display the message, if necessary
                //
                if (requiresRestart) {
                    final ButtonSpec [] options = RestartAction.getButtonSpecs();
                    if (0 == HelpAwareOptionPane.showOptionDialog(
                            Main.parent,
                            sb.toString(),
                            tr("Restart"),
                            JOptionPane.INFORMATION_MESSAGE,
                            null, /* no special icon */
                            options,
                            options[0],
                            null /* no special help */
                            )) {
                        Main.main.menu.restart.actionPerformed(null);
                    }
                } else if (task != null && !task.isCanceled()) {
                    JOptionPane.showMessageDialog(
                            Main.parent,
                            sb.toString(),
                            tr("Warning"),
                            JOptionPane.WARNING_MESSAGE
View Full Code Here


        @Override
        public void actionPerformed(ActionEvent e) {
            final List<PluginInformation> toUpdate = model.getSelectedPlugins();
            // the async task for downloading plugins
            final PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(
                    pnlPluginPreferences,
                    toUpdate,
                    tr("Update plugins")
                    );
            // the async task for downloading plugin information
            final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(Main.pref.getPluginSites());

            // to be run asynchronously after the plugin download
            //
            final Runnable pluginDownloadContinuation = new Runnable() {
                @Override
                public void run() {
                    if (pluginDownloadTask.isCanceled())
                        return;
                    notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask);
                    model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins());
                    model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins());
                    GuiHelper.runInEDT(new Runnable() {
                        @Override
                        public void run() {
                            pnlPluginPreferences.refreshView();                        }
                    });
                }
            };

            // to be run asynchronously after the plugin list download
            //
            final Runnable pluginInfoDownloadContinuation = new Runnable() {
                @Override
                public void run() {
                    if (pluginInfoDownloadTask.isCanceled())
                        return;
                    model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins());
                    // select plugins which actually have to be updated
                    //
                    Iterator<PluginInformation> it = toUpdate.iterator();
                    while(it.hasNext()) {
                        PluginInformation pi = it.next();
                        if (!pi.isUpdateRequired()) {
                            it.remove();
                        }
                    }
                    if (toUpdate.isEmpty()) {
                        alertNothingToUpdate();
                        return;
                    }
                    pluginDownloadTask.setPluginsToDownload(toUpdate);
                    Main.worker.submit(pluginDownloadTask);
                    Main.worker.submit(pluginDownloadContinuation);
                }
            };
View Full Code Here

                            if (installList.contains(name)) toInstallPlugins.add(pi);
                            if (removeList.contains(name)) toRemovePlugins.add(pi);
                            if (deleteList.contains(name)) toDeletePlugins.add(pi);
                        }
                        if (!installList.isEmpty()) {
                            PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(Main.parent, toInstallPlugins, tr ("Installing plugins"));
                            Main.worker.submit(pluginDownloadTask);
                        }
                        Collection<String> pls = new ArrayList<>(Main.pref.getCollection("plugins"));
                        for (PluginInformation pi: toInstallPlugins) {
                            if (!pls.contains(pi.name)) {
View Full Code Here

        }

        @Override
        public void run() {
         // Give the user a chance to deactivate the plugin which threw the exception (if it was thrown from a plugin)
            final PluginDownloadTask pluginDownloadTask = PluginHandler.updateOrdisablePluginAfterException(e);

            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    // Then ask for submitting a bug report, for exceptions thrown from a plugin too, unless updated to a new version
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.plugins.PluginDownloadTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.