Changeset 6443 in josm for trunk/src


Ignore:
Timestamp:
2013-12-06T20:15:43+01:00 (11 years ago)
Author:
Don-vip
Message:

see #8465 - Ask Windows users to update their Sun/Oracle Java 6 version to Oracle Java 7

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

Legend:

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

    r6380 r6443  
    975975            if (version.startsWith("1.6") || version.startsWith("6") ||
    976976                    version.startsWith("1.7") || version.startsWith("7") ||
    977                     version.startsWith("1.8") || version.startsWith("8"))
     977                    version.startsWith("1.8") || version.startsWith("8") ||
     978                    version.startsWith("1.9") || version.startsWith("9"))
    978979                return;
    979980            if (version.startsWith("1.5") || version.startsWith("5")) {
  • trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java

    r6340 r6443  
    272272    public ExtendedDialog showDialog() {
    273273        // Check if the user has set the dialog to not be shown again
    274         if (toggleCheckState(togglePref)) {
     274        if (toggleCheckState()) {
    275275            result = toggleValue;
    276276            return this;
     
    595595     * @return true if dialog should not be shown again
    596596     */
    597     private boolean toggleCheckState(String togglePref) {
     597    public final boolean toggleCheckState() {
    598598        toggleable = togglePref != null && !togglePref.isEmpty();
    599599
    600600        toggleValue = Main.pref.getInteger("message."+togglePref+".value", -1);
    601601        // No identifier given, so return false (= show the dialog)
    602         if(!toggleable || toggleValue == -1)
     602        if (!toggleable || toggleValue == -1)
    603603            return false;
    604         this.togglePref = togglePref;
    605604        // The pref is true, if the dialog should be shown.
    606605        return !(Main.pref.getBoolean("message."+ togglePref, true));
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r6380 r6443  
    66
    77/**
    8  * This interface allows platfrom (operating system) dependent code
     8 * This interface allows platform (operating system) dependent code
    99 * to be bundled into self-contained classes.
    10  *
    11  * For plugin authors:
    12  * To implement your own PlatformHook class, implement this interface,
    13  * then create the class when your plugin is loaded and store it in
    14  * Main.platform. Please not that the two "startup" hooks will be
    15  * called _before_ your plugin is loaded. If you need to hook there,
    16  * split your class into two (one containing only the startup hooks,
    17  * and one with the remainder) and send the startup class, together
    18  * with propper OS detection code (see Main) for inclusion with
    19  * JOSM to the JOSM team.
    20  *
    21  * Also, it might be a good idea to extend PlatformHookUnixoid.
    22  * That class has a more or less neutral behaviour, that should
    23  * work on all platforms supported by J2SE.
    24  *
    25  * Attention: At this time this interface is not to be considered
    26  * complete.
     10 * @since 1023
    2711 */
    2812public interface PlatformHook {
     13   
    2914    /**
    3015      * The preStartupHook will be called extremly early. It is
     
    3217      *
    3318      * Reason: On OSX we need to inform the Swing libraries
    34       * that we want to be integrated with the OS before we setup
    35       * our GUI.
     19      * that we want to be integrated with the OS before we setup our GUI.
    3620      */
    3721    public void preStartupHook();
     
    4832    /**
    4933      * The openURL hook will be used to open an URL in the
    50       * default webbrowser.
     34      * default web browser.
     35     * @param url The URL to open
     36     * @throws IOException if any I/O error occurs
    5137      */
    5238    public void openUrl(String url) throws IOException;
     
    7965      *
    8066      * Tooltips are usually not system dependent, unless the
    81       * JVM is to dumb to provide correct names for all the keys.
     67      * JVM is too dumb to provide correct names for all the keys.
    8268      *
    8369      * Another reason not to use the implementation in the *nix
    84       * hook are LAFs that don't understand HTML, such as the OSX
    85       * LAFs.
     70      * hook are LAFs that don't understand HTML, such as the OSX LAFs.
     71      *
     72     * @param name Tooltip text to display
     73     * @param sc Shortcut associated (to display accelerator between parenthesis)
     74     * @return Full tooltip text (name + accelerator)
    8675      */
    8776    public String makeTooltip(String name, Shortcut sc);
    8877
     78    /**
     79     * Returns the default LAF to be used on this platform to look almost as a native application.
     80     * @return The default native LAF for this platform
     81     */
    8982    public String getDefaultStyle();
    9083
     84    /**
     85     * Determines if the platform allows full-screen.
     86     * @return {@code true} if full screen is allowed, {@code false} otherwise
     87     */
    9188    public boolean canFullscreen();
    9289
     90    /**
     91     * Renames a file.
     92     * @param from Source file
     93     * @param to Target file
     94     * @return {@code true} if the file has been renamed, {@code false} otherwise
     95     */
    9396    public boolean rename(File from, File to);
    9497
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r6380 r6443  
    1515
    1616/**
    17  * @see PlatformHook
     17 * {@code PlatformHook} implementation for Apple Mac OS X systems.
     18 * @since 1023
    1819 */
    1920public class PlatformHookOsx extends PlatformHookUnixoid implements PlatformHook, InvocationHandler {
     21   
    2022    private static PlatformHookOsx ivhandler = new PlatformHookOsx();
    21     @Override
    22     public void preStartupHook(){
     23   
     24    @Override
     25    public void preStartupHook() {
    2326        // This will merge our MenuBar into the system menu.
    2427        // MUST be set before Swing is initialized!
    25         // And will not work when one of the system independet LAFs is used.
     28        // And will not work when one of the system independent LAFs is used.
    2629        // They just insist on painting themselves...
    2730        System.setProperty("apple.laf.useScreenMenuBar", "true");
    2831    }
     32   
    2933    @Override
    3034    public void startupHook() {
     
    4448        }
    4549    }
     50   
    4651    @Override
    4752    public Object invoke (Object proxy, Method method, Object[] args) throws Throwable {
     
    6469        return null;
    6570    }
     71   
    6672    @Override
    6773    public void openUrl(String url) throws IOException {
     
    7177    @Override
    7278    public void initSystemShortcuts() {
    73         // Yeah, it's a long, long list. And people always complain that OSX has no shortcuts.
    7479        Shortcut.registerSystemShortcut("apple-reserved-01", tr("reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK).setAutomatic(); // Show or hide the Spotlight search field (when multiple languages are installed, may rotate through enabled script systems).
    7580        Shortcut.registerSystemShortcut("apple-reserved-02", tr("reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK).setAutomatic(); // Apple reserved.
     
    207212        Shortcut.registerSystemShortcut("view:zoomout", tr("reserved"), KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK); // Zoom out
    208213    }
     214   
    209215    @Override
    210216    public String makeTooltip(String name, Shortcut sc) {
     
    237243
    238244    @Override
    239     public String getDefaultStyle()
    240     {
     245    public String getDefaultStyle() {
    241246        return "javax.swing.plaf.metal.MetalLookAndFeel";
    242247    }
    243248
    244249    @Override
    245     public boolean canFullscreen()
    246     {
     250    public boolean canFullscreen() {
    247251        return false;
    248252    }
    249253
    250     /* (non-Javadoc)
    251      * @see org.openstreetmap.josm.tools.PlatformHookUnixoid#getOSDescription()
    252      */
    253254    @Override
    254255    public String getOSDescription() {
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r6380 r6443  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Dimension;
    67import java.awt.GraphicsEnvironment;
    78import java.awt.event.KeyEvent;
     
    1314import java.util.Arrays;
    1415
     16import javax.swing.JOptionPane;
     17
    1518import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.gui.ExtendedDialog;
    1620
    1721/**
     
    2832
    2933    @Override
    30     public void preStartupHook(){
     34    public void preStartupHook() {
    3135    }
    3236
     
    5660        Shortcut.registerSystemShortcut("system:resetX", tr("reserved"), KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic();
    5761    }
     62   
    5863    /**
    5964     * This should work for all platforms. Yeah, should.
     
    8287
    8388    @Override
    84     public boolean canFullscreen()
    85     {
     89    public boolean canFullscreen() {
    8690        return GraphicsEnvironment.getLocalGraphicsEnvironment()
    8791        .getDefaultScreenDevice().isFullScreenSupported();
     
    8993
    9094    @Override
    91     public boolean rename(File from, File to)
    92     {
     95    public boolean rename(File from, File to) {
    9396        return from.renameTo(to);
    9497    }
     
    263266        }
    264267    }
     268   
     269    protected void askUpdateJava(String version) {
     270        try {
     271            ExtendedDialog ed = new ExtendedDialog(
     272                    Main.parent,
     273                    tr("Outdated Java version"),
     274                    new String[]{tr("Update Java"), tr("Cancel")});
     275            // Check if the dialog has not already been permanently hidden by user
     276            if (!ed.toggleEnable("askUpdateJava7").toggleCheckState()) {
     277                ed.setButtonIcons(new String[]{"java.png", "cancel.png"}).setCancelButton(2);
     278                ed.setMinimumSize(new Dimension(460, 260));
     279                ed.setIcon(JOptionPane.WARNING_MESSAGE);
     280                ed.setContent(tr("You are running version {0} of Java.", "<b>"+version+"</b>")+"<br><br>"+
     281                        "<b>"+tr("This version is no longer supported by {0} since {1} and is not recommended for use.", "Oracle", tr("February 2013"))+"</b><br><br>"+
     282                        "<b>"+tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", "7")+"</b><br><br>"+
     283                        tr("Would you like to update now ?"));
     284   
     285                if (ed.showDialog().getValue() == 1) {
     286                    openUrl("http://www.java.com/download");
     287                }
     288            }
     289        } catch (IOException e) {
     290            Main.warn(e);
     291        }
     292    }
    265293}
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r6380 r6443  
    3232
    3333/**
    34   * see PlatformHook.java
     34  * {@code PlatformHook} implementation for Microsoft Windows systems.
     35  * @since 1023
    3536  */
    3637public class PlatformHookWindows extends PlatformHookUnixoid implements PlatformHook {
     38   
     39    @Override
     40    public void startupHook() {
     41        super.startupHook();
     42        // Invite users to install Oracle Java 7 if they are still with Sun/Oracle Java 6
     43        String vendor = System.getProperty("java.vendor");
     44        String version = System.getProperty("java.version");
     45        if ("Sun Microsystems Inc.".equals(vendor) && version != null && version.startsWith("1.6")) {
     46            askUpdateJava(version);
     47        }
     48    }
     49
    3750    @Override
    3851    public void openUrl(String url) throws IOException {
     
    111124
    112125    @Override
    113     public String getDefaultStyle()
    114     {
     126    public String getDefaultStyle() {
    115127        return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    116128    }
    117129
    118130    @Override
    119     public boolean rename(File from, File to)
    120     {
    121         if(to.exists())
     131    public boolean rename(File from, File to) {
     132        if (to.exists())
    122133            to.delete();
    123134        return from.renameTo(to);
    124135    }
    125136
    126     /* (non-Javadoc)
    127      * @see org.openstreetmap.josm.tools.PlatformHookUnixoid#getOSDescription()
    128      */
    129137    @Override
    130138    public String getOSDescription() {
Note: See TracChangeset for help on using the changeset viewer.