Changeset 1138 in josm for trunk


Ignore:
Timestamp:
2008-12-15T17:14:52+01:00 (15 years ago)
Author:
stoecker
Message:

close bug #1841

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

Legend:

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

    r1120 r1138  
    249249                if (info.early != early)
    250250                    continue;
    251                 if (info.mainversion != null && info.mainversion.compareTo(AboutAction.version) > 0) {
    252                     JOptionPane.showMessageDialog(Main.parent, tr("Plugin requires JOSM update: {0}.", pluginName));
    253                     continue;
     251                if (info.mainversion != null) {
     252                    int requiredJOSMVersion = 0;
     253                    try {
     254                        requiredJOSMVersion = Integer.parseInt(info.mainversion);
     255                    } catch(NumberFormatException e) {
     256                        e.printStackTrace();
     257                    }
     258                    if (requiredJOSMVersion > AboutAction.getVersionNumber()) {
     259                        JOptionPane.showMessageDialog(Main.parent, tr("Plugin requires JOSM update: {0}.", pluginName));
     260                        continue;
     261                    }
    254262                }
    255263                if (!p.containsKey(info.stage))
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r1084 r1138  
    1313import java.io.InputStream;
    1414import java.io.InputStreamReader;
     15import java.net.MalformedURLException;
    1516import java.net.URL;
    1617import java.util.Map.Entry;
     
    4445 * @author imi
    4546 */
     47/**
     48 * @author Stephan
     49 *
     50 */
    4651public class AboutAction extends JosmAction {
    4752
    48         public static final String version;
     53        private static final String version;
    4954
    5055        private final static JTextArea revision;
    5156        private static String time;
    5257
    53         static {
    54                 URL u = Main.class.getResource("/REVISION");
    55                 if(u == null) u = Main.class.getResource("/META-INF/MANIFEST.MF");
     58    static {
     59        URL u = Main.class.getResource("/REVISION");
     60        if(u == null) {
     61            try {
     62                u = new URL("jar:" + Main.class.getProtectionDomain().getCodeSource().getLocation().toString()
     63                        + "!/META-INF/MANIFEST.MF");
     64            } catch (MalformedURLException e) {
     65                e.printStackTrace();
     66            }
     67        }
    5668                revision = loadFile(u);
    5769
    58                 Pattern versionPattern = Pattern.compile(".*?(?:Revision|Main-Version): ([0-9]*).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
     70                Pattern versionPattern = Pattern.compile(".*?(?:Revision|Main-Version): ([0-9]*(?: SVN)?).*", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
    5971                Matcher match = versionPattern.matcher(revision.getText());
    6072                version = match.matches() ? match.group(1) : tr("UNKNOWN");
     
    6577        }
    6678
    67         static public String getVersion() {
     79        /**
     80         * Return string describing version.
     81         * Note that the strinc contains the version number plus an optional suffix of " SVN" to indicate an unofficial development build.
     82         * @return version string
     83         */
     84        static public String getVersionString() {
    6885                return version;
    6986        }
    7087
     88    /**
     89     * Return the number part of the version string.
     90     * @return integer part of version number or Integer.MAX_VALUE if not available
     91     */
     92    public static int getVersionNumber() {
     93        int myVersion=Integer.MAX_VALUE;
     94        try {
     95            myVersion = Integer.parseInt(version.split(" ")[0]);
     96        } catch (NumberFormatException e) {
     97            e.printStackTrace();
     98        }
     99        return myVersion;
     100    }
     101       
     102    /**
     103     * check whether the version is a development build out of SVN.
     104     * @return true if it is a SVN unofficial build
     105     */
     106    public static boolean isDevelopmentVersion() {
     107        return version.endsWith(" SVN");
     108    }
     109       
    71110        public AboutAction() {
    72111                super(tr("About"), "about", tr("Display the about screen."), Shortcut.registerShortcut("system:about", tr("About"), KeyEvent.VK_F1, Shortcut.GROUP_DIRECT, Shortcut.SHIFT_DEFAULT), true);
  • trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java

    r1130 r1138  
    4848    public AddNodeAction() {
    4949        super(tr("Add Node"), "addnode", tr("Add a node by entering latitude and longitude."),
    50                         Shortcut.registerShortcut("addnode", tr("Edit: {0}", tr("Add Node")), KeyEvent.VK_D, Shortcut.GROUP_MENU), true);
     50                Shortcut.registerShortcut("addnode", tr("Edit: {0}", tr("Add Node")), KeyEvent.VK_D, Shortcut.GROUP_EDIT,
     51                Shortcut.SHIFT_DEFAULT), true);
    5152    }
    5253
  • trunk/src/org/openstreetmap/josm/actions/ToggleGPXLinesAction.java

    r1084 r1138  
    1414        public ToggleGPXLinesAction() {
    1515                super(tr("Toggle GPX Lines"), "gps-lines", tr("Toggles the global setting ''{0}''.", tr("Draw lines between raw gps points.")),
    16                 Shortcut.registerShortcut("view:gpxlines", tr("View: {0}", tr("Toggle GPX Lines")), KeyEvent.VK_X, Shortcut.GROUP_MENU), true);
     16                Shortcut.registerShortcut("view:gpxlines", tr("View: {0}", tr("Toggle GPX Lines")), KeyEvent.VK_X, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), true);
    1717        }
    1818
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r1016 r1138  
    5757            }
    5858
    59             int myVersion;
    60             try {
    61                 myVersion = Integer.parseInt(AboutAction.getVersion());
    62             } catch (NumberFormatException e) {
    63                 myVersion = 0;
    64             }
     59            int myVersion = AboutAction.getVersionNumber();
    6560
    6661            Pattern commentPattern = Pattern.compile("\\<p\\>\\s*\\/\\*[^\\*]*\\*\\/\\s*\\<\\/p\\>", Pattern.CASE_INSENSITIVE|Pattern.DOTALL|Pattern.MULTILINE);
  • trunk/src/org/openstreetmap/josm/gui/SplashScreen.java

    r1093 r1138  
    7373
    7474                // Add the version number
    75                 JLabel version = new JLabel(tr("Version {0}", AboutAction.version));
     75                JLabel version = new JLabel(tr("Version {0}", AboutAction.getVersionString()));
    7676                gbc.gridy = 1;
    7777                gbc.insets = new Insets(0, 0, 0, 0);
Note: See TracChangeset for help on using the changeset viewer.