Ignore:
Timestamp:
2009-07-27T18:36:17+02:00 (15 years ago)
Author:
Gubaer
Message:

partial fix for #3109: window order generally messed up?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r1811 r1860  
    2828import org.openstreetmap.josm.actions.AboutAction;
    2929import org.openstreetmap.josm.gui.ExtendedDialog;
     30import org.openstreetmap.josm.gui.OptionPaneUtil;
    3031import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    3132import org.xml.sax.SAXException;
     
    4950
    5051        @Override protected void finish() {
    51             if (errors.length() > 0)
    52                 JOptionPane.showMessageDialog(Main.parent, tr("There were problems with the following plugins:\n\n {0}",errors));
    53             else
    54                 JOptionPane.showMessageDialog(Main.parent, trn("{0} Plugin successfully downloaded. Please restart JOSM.", "{0} Plugins successfully downloaded. Please restart JOSM.", count, count));
     52            if (errors.length() > 0) {
     53                OptionPaneUtil.showMessageDialog(
     54                        Main.parent,
     55                        tr("There were problems with the following plugins:\n\n {0}",errors),
     56                        tr("Error"),
     57                        JOptionPane.ERROR_MESSAGE
     58                );
     59            } else {
     60                OptionPaneUtil.showMessageDialog(
     61                        Main.parent,
     62                        trn("{0} Plugin successfully downloaded. Please restart JOSM.", "{0} Plugins successfully downloaded. Please restart JOSM.", count, count),
     63                        tr("Information"),
     64                        JOptionPane.INFORMATION_MESSAGE
     65                );
     66            }
    5567        }
    5668
    5769        @Override protected void realRun() throws SAXException, IOException {
    5870            File pluginDir = Main.pref.getPluginsDirFile();
    59             if (!pluginDir.exists())
     71            if (!pluginDir.exists()) {
    6072                pluginDir.mkdirs();
     73            }
    6174            progressMonitor.setTicksCount(toUpdate.size());
    6275            for (PluginInformation d : toUpdate) {
     
    6477                progressMonitor.worked(1);
    6578                File pluginFile = new File(pluginDir, d.name + ".jar.new");
    66                 if(download(d, pluginFile))
     79                if(download(d, pluginFile)) {
    6780                    count++;
    68                 else
     81                } else
    6982                {
    7083                    errors += d.name + "\n";
     
    88101        int count = 0;
    89102        for (String site : getSites()) {
    90         /* TODO: remove old site files (everything except .jar) */
     103            /* TODO: remove old site files (everything except .jar) */
    91104            try {
    92105                BufferedReader r = new BufferedReader(new InputStreamReader(new URL(site).openStream(), "utf-8"));
    93106                new File(Main.pref.getPreferencesDir()+"plugins").mkdir();
    94107                BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
    95                 new FileOutputStream(new File(Main.pref.getPluginsDirFile(),
    96                 count + "-site-" + site.replaceAll("[/:\\\\ <>|]", "_") + ".txt")), "utf-8"));
    97                 for (String line = r.readLine(); line != null; line = r.readLine())
     108                        new FileOutputStream(new File(Main.pref.getPluginsDirFile(),
     109                                count + "-site-" + site.replaceAll("[/:\\\\ <>|]", "_") + ".txt")), "utf-8"));
     110                for (String line = r.readLine(); line != null; line = r.readLine()) {
    98111                    out.append(line+"\n");
     112                }
    99113                r.close();
    100114                out.close();
     
    110124        {
    111125            int answer = new ExtendedDialog(Main.parent,
    112                         tr("Skip download"),
    113                         tr("JOSM version {0} required for plugin {1}.", pd.mainversion, pd.name),
    114                         new String[] {tr("Download Plugin"), tr("Skip Download")},
    115                         new String[] {"download.png", "cancel.png"}).getValue();
     126                    tr("Skip download"),
     127                    tr("JOSM version {0} required for plugin {1}.", pd.mainversion, pd.name),
     128                    new String[] {tr("Download Plugin"), tr("Skip Download")},
     129                    new String[] {"download.png", "cancel.png"}).getValue();
    116130            if (answer != 1)
    117131                return false;
     
    122136            OutputStream out = new FileOutputStream(file);
    123137            byte[] buffer = new byte[8192];
    124             for (int read = in.read(buffer); read != -1; read = in.read(buffer))
     138            for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
    125139                out.write(buffer, 0, read);
     140            }
    126141            out.close();
    127142            in.close();
Note: See TracChangeset for help on using the changeset viewer.