Changeset 282 in josm for src/org/openstreetmap/josm


Ignore:
Timestamp:
2007-07-08T00:32:06+02:00 (17 years ago)
Author:
imi
Message:
  • fixed exception when download link of plugins doesn't work
Location:
src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r277 r282  
    6161        private Box pluginPanel = Box.createVerticalBox();
    6262        private JPanel plugin;
     63        private PreferenceDialog gui;
    6364
    6465        public void addGui(final PreferenceDialog gui) {
     66                this.gui = gui;
    6567                plugin = gui.createPreferenceTab("plugin", tr("Plugins"), tr("Configure available Plugins."));
    6668                JScrollPane pluginPane = new JScrollPane(pluginPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     
    123125                                public void actionPerformed(ActionEvent e) {
    124126                                        pluginMap.put(plugin, pluginCheck.isSelected());
    125                                         gui.requiresRestart = true;
    126127                                }
    127128                        });
     
    189190                        else
    190191                                for (PluginDescription pd : toDownload)
    191                                         PluginDownloader.downloadPlugin(pd);
     192                                        if (!PluginDownloader.downloadPlugin(pd))
     193                                                pluginMap.put(pd, false);
     194                                               
    192195                }
    193196
    194197                String plugins = "";
    195                 for (Entry<PluginDescription, Boolean> entry : pluginMap.entrySet()) {
    196                         if (entry.getValue()) {
     198                for (Entry<PluginDescription, Boolean> entry : pluginMap.entrySet())
     199                        if (entry.getValue())
    197200                                plugins += entry.getKey().name + ",";
    198                                 if (PluginInformation.findPlugin(entry.getKey().name) == null)
    199                                         toDownload.add(entry.getKey());
    200                         }
    201                 }
    202201                if (plugins.endsWith(","))
    203202                        plugins = plugins.substring(0, plugins.length()-1);
    204                 Main.pref.put("plugins", plugins);
     203               
     204                String oldPlugins = Main.pref.get("plugins");
     205                if (!plugins.equals(oldPlugins)) {
     206                        Main.pref.put("plugins", plugins);
     207                        gui.requiresRestart = true;
     208                }
    205209        }
    206210}
  • src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r277 r282  
    7575    }
    7676
    77         public static void downloadPlugin(PluginDescription pd) {
     77        public static boolean downloadPlugin(PluginDescription pd) {
    7878                File file = new File(Main.pref.getPreferencesDir()+"plugins/"+pd.name+".jar");
    7979            try {
     
    8585                out.close();
    8686                in.close();
     87                try {
     88                    PluginInformation.findPlugin(pd.name);
     89                    return true;
     90            } catch (Exception e) {
     91                    e.printStackTrace();
     92                    JOptionPane.showMessageDialog(Main.parent, tr("The plugin {0} seem to be broken or could not be downloaded automatically.", pd.name));
     93            }
    8794        } catch (Exception e) {
    88                 if (file.exists())
    89                         file.delete();
    9095                JOptionPane.showMessageDialog(Main.parent, tr("Could not download plugin: {0} from {1}", pd.name, pd.resource));
    9196        }
     97        if (file.exists())
     98                file.delete();
     99        return false;
    92100    }
    93101}
Note: See TracChangeset for help on using the changeset viewer.