Changeset 1073 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2008-11-09T22:10:39+01:00 (15 years ago)
Author:
stoecker
Message:

added some plugin checks

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

Legend:

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

    r1062 r1073  
    3333import javax.swing.UIManager;
    3434
     35import org.openstreetmap.josm.actions.AboutAction;
    3536import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
    3637import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
     
    247248                                if (info.early != early)
    248249                                        continue;
     250                                if (info.mainversion != null && info.mainversion.compareTo(AboutAction.version) < 0)
     251                                {
     252                                        JOptionPane.showMessageDialog(Main.parent, tr("Plugin requires JOSM update: {0}.", pluginName));
     253                                        continue;
     254                                }
    249255                                if (!p.containsKey(info.stage))
    250256                                        p.put(info.stage, new LinkedList<PluginInformation>());
     
    255261                                else
    256262                                        JOptionPane.showMessageDialog(Main.parent, tr("Plugin not found: {0}.", pluginName));
     263                        }
     264                }
     265
     266                if(!early)
     267                {
     268                        long tim = System.currentTimeMillis();
     269                        long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
     270                        Integer maxTime = Main.pref.getInteger("pluginmanager.warntime", 30*24*60*60);
     271                        if(last <= 0)
     272                        {
     273                                Main.pref.put("pluginmanager.lastupdate",Long.toString(tim));
     274                        }
     275                        else if(tim - last >= maxTime*1000*24*60*60)
     276                        {
     277                                long d = (tim - last)/(24*60*60*1000);
     278                                JOptionPane.showMessageDialog(Main.parent, tr("Last plugin update more than {0} days ago.", d));
    257279                        }
    258280                }
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r1066 r1073  
    5252
    5353        static {
    54                 revision = loadFile(Main.class.getResource("/REVISION"));
     54                URL u = Main.class.getResource("/REVISION");
     55                if(u == null) u = Main.class.getResource("/META-INF/MANIFEST.MF");
     56                revision = loadFile(u);
    5557
    56                 Pattern versionPattern = Pattern.compile(".*?Revision: ([0-9]*).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
     58                Pattern versionPattern = Pattern.compile(".*?(?:Revision|Main-Version): ([0-9]*).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
    5759                Matcher match = versionPattern.matcher(revision.getText());
    5860                version = match.matches() ? match.group(1) : tr("UNKNOWN");
    5961
    60                 Pattern timePattern = Pattern.compile(".*?Last Changed Date: ([^\n]*).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
     62                Pattern timePattern = Pattern.compile(".*?(?:Last Changed Date|Main-Date): ([^\n]*).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
    6163                match = timePattern.matcher(revision.getText());
    6264                time = match.matches() ? match.group(1) : tr("UNKNOWN");
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r1065 r1073  
    388388        }
    389389
     390        synchronized public long getLong(String key, long def) {
     391                putDefault(key, Long.toString(def));
     392                String v = get(key);
     393                if(null == v)
     394                        return def;
     395
     396                try {
     397                        return Long.parseLong(v);
     398                } catch(NumberFormatException e) {
     399                        // fall out
     400                }
     401                return def;
     402        }
     403
    390404        synchronized public double getDouble(String key, double def) {
    391405                putDefault(key, Double.toString(def));
     
    408422                        /* handle old comma separated stuff - remove in future */
    409423                        if(s.indexOf(',') >= 0)
     424                                return Arrays.asList(s.split(","));
     425                        /* handle space separated stuff - remove in future */
     426                        else if(s.indexOf(' ') >= 0)
    410427                                return Arrays.asList(s.split(","));
    411428                        else
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java

    r794 r1073  
    3535                pane.add(cancel, GBC.eol().anchor(GBC.CENTER));
    3636                setContentPane(pane);
    37                 setSize(400,100);
     37                setSize(Main.pref.getInteger("progressdialog.size",400),100);
    3838                setLocationRelativeTo(Main.parent);
    3939        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java

    r1053 r1073  
    198198        private void update() {
    199199                // refresh description
    200                 PluginDownloader.downloadDescription();
     200                int num = PluginDownloader.downloadDescription();
     201                Boolean done = false;
    201202                refreshPluginPanel(gui);
    202203
     
    205206                for (PluginProxy proxy : Main.plugins) {
    206207                        PluginDescription description = findDescription(proxy.info.name);
    207                         if (description != null && (description.version == null || description.version.equals("")) ? (proxy.info.version != null && proxy.info.version.equals("")) : !description.version.equals(proxy.info.version)) {
     208                        if (description != null && (description.version == null || description.version.equals(""))
     209                        ? (proxy.info.version != null && proxy.info.version.equals("")) : !description.version.equals(proxy.info.version)) {
    208210                                toUpdate.add(description);
    209211                                toUpdateStr.append(description.name+"\n");
     
    212214                if (toUpdate.isEmpty()) {
    213215                        JOptionPane.showMessageDialog(Main.parent, tr("All installed plugins are up to date."));
    214                         return;
    215                 }
    216                 int answer = JOptionPane.showConfirmDialog(Main.parent, tr("Update the following plugins:\n\n{0}", toUpdateStr.toString()), tr("Update"), JOptionPane.OK_CANCEL_OPTION);
    217                 if (answer != JOptionPane.OK_OPTION)
    218                         return;
    219                 PluginDownloader.update(toUpdate);
     216                        done = true;
     217                }
     218                else
     219                {
     220                        int answer = JOptionPane.showConfirmDialog(Main.parent, tr("Update the following plugins:\n\n{0}",
     221                        toUpdateStr.toString()), tr("Update"), JOptionPane.OK_CANCEL_OPTION);
     222                        if (answer == JOptionPane.OK_OPTION)
     223                        {
     224                                PluginDownloader.update(toUpdate);
     225                                done = true;
     226                        }
     227                }
     228                if(done && num >= 1)
     229                        Main.pref.put("pluginmanager.lastupdate", Long.toString(System.currentTimeMillis()));
    220230        }
    221231
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java

    r1017 r1073  
    2020import java.net.MalformedURLException;
    2121import java.net.URL;
     22import java.util.Arrays;
    2223import java.util.Collection;
    2324import java.util.regex.Matcher;
     
    7172        private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td>([^<]*)</td><td>([^<].*)</td><td>(.*)");
    7273
     74        private final static String[] pluginSites = {"http://josm.openstreetmap.de/wiki/Plugins"};
     75
     76        public static Collection<String> getSites() {
     77                return Main.pref.getCollection("pluginmanager.sites", Arrays.asList(pluginSites));
     78        }
     79
    7380        public static int downloadDescription() {
    7481                int count = 0;
     
    94101                return count;
    95102        }
    96 
    97         public static String[] getSites() {
    98             return Main.pref.get("pluginmanager.sites", "http://josm.openstreetmap.de/wiki/Plugins").split(" ");
    99     }
    100103
    101104        private static CharSequence readXml(BufferedReader r) throws IOException {
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r873 r1073  
    3232        public final File file;
    3333        public final String name;
     34        public final String mainversion;
    3435        public final String className;
    3536        public final String description;
     
    8182                                stage = stageStr == null ? 50 : Integer.parseInt(stageStr);
    8283                                version = attr.getValue("Plugin-Version");
     84                                mainversion = attr.getValue("Plugin-Mainversion");
    8385                                author = attr.getValue("Author");
    8486
     
    101103                                // resource-only plugin
    102104                                className = null;
     105                                mainversion = null;
    103106                                description = tr("unknown");
    104107                                early = false;
Note: See TracChangeset for help on using the changeset viewer.