Changeset 3417 in josm


Ignore:
Timestamp:
2010-08-05T15:29:36+02:00 (14 years ago)
Author:
bastiK
Message:

Added message box if JOSM starts with Java 5. The following classes need to be Java 5 compatible for this message box to show up: JOSM, MainApplication, I18n.

File:
1 edited

Legend:

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

    r3410 r3417  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 //Licence: GPL
    32package org.openstreetmap.josm.gui;
    43
     
    65
    76import java.awt.EventQueue;
     7import java.awt.GridBagConstraints;
     8import java.awt.GridBagLayout;
    89import java.awt.Toolkit;
    910import java.awt.event.WindowAdapter;
     
    2324
    2425import javax.swing.JFrame;
     26import javax.swing.JLabel;
     27import javax.swing.JOptionPane;
     28import javax.swing.JPanel;
     29import javax.swing.JTextArea;
    2530
    2631import org.openstreetmap.josm.Main;
     
    134139    public static void main(final String[] argArray) {
    135140        I18n.init();
     141        checkJava6();
    136142
    137143        Policy.setPolicy(new Policy() {
     
    277283     */
    278284    public static void removeObsoletePreferences() {
     285
    279286        String[] obsolete = {
    280287                "proxy.anonymous", // 01/2010 - not needed anymore. Can be removed mid 2010
     
    288295        }
    289296    }
     297
     298    private static void checkJava6() {
     299        String version = System.getProperty("java.version");
     300        if (version != null) {
     301            if (version.startsWith("1.6") || version.startsWith("6"))
     302                return;
     303            if (version.startsWith("1.5") || version.startsWith("5")) {
     304                JLabel ho = new JLabel("<html>"+
     305                    tr("<h2>JOSM requires Java version 6.</h2>"+
     306                        "Detected Java version: {0}.<br>"+
     307                        "You can <ul><li>update your Java (JRE) or</li>"+
     308                        "<li>use an earlier (Java 5 compatible) version of JOSM.</li></ul>"+
     309                        "More Info:", version)+"</html>");
     310                JTextArea link = new JTextArea("http://josm.openstreetmap.de/wiki/Help/SystemRequirements");
     311                link.setEditable(false);
     312                link.setBackground(panel.getBackground());
     313                JPanel panel = new JPanel(new GridBagLayout());
     314                GridBagConstraints gbc = new GridBagConstraints();
     315                gbc.gridwidth = GridBagConstraints.REMAINDER;
     316                gbc.anchor = GridBagConstraints.WEST;
     317                gbc.weightx = 1.0;
     318                panel.add(ho, gbc);
     319                panel.add(link, gbc);
     320                final String EXIT = tr("Exit JOSM");
     321                final String CONTINUE = tr("Continue, try anyway");
     322                int ret = JOptionPane.showOptionDialog(null, panel, tr("Error"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] {EXIT, CONTINUE}, EXIT);
     323                if (ret == 0) {
     324                    System.exit(0);
     325                }
     326                return;
     327            }
     328        }
     329        System.err.println("Error: Could not recognize Java Version: "+version);
     330    }
    290331}
Note: See TracChangeset for help on using the changeset viewer.