Changeset 6443 in josm for trunk/src/org
- Timestamp:
- 2013-12-06T20:15:43+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r6380 r6443 975 975 if (version.startsWith("1.6") || version.startsWith("6") || 976 976 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")) 978 979 return; 979 980 if (version.startsWith("1.5") || version.startsWith("5")) { -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r6340 r6443 272 272 public ExtendedDialog showDialog() { 273 273 // Check if the user has set the dialog to not be shown again 274 if (toggleCheckState( togglePref)) {274 if (toggleCheckState()) { 275 275 result = toggleValue; 276 276 return this; … … 595 595 * @return true if dialog should not be shown again 596 596 */ 597 p rivate boolean toggleCheckState(String togglePref) {597 public final boolean toggleCheckState() { 598 598 toggleable = togglePref != null && !togglePref.isEmpty(); 599 599 600 600 toggleValue = Main.pref.getInteger("message."+togglePref+".value", -1); 601 601 // No identifier given, so return false (= show the dialog) 602 if (!toggleable || toggleValue == -1)602 if (!toggleable || toggleValue == -1) 603 603 return false; 604 this.togglePref = togglePref;605 604 // The pref is true, if the dialog should be shown. 606 605 return !(Main.pref.getBoolean("message."+ togglePref, true)); -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r6380 r6443 6 6 7 7 /** 8 * This interface allows platf rom (operating system) dependent code8 * This interface allows platform (operating system) dependent code 9 9 * 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 27 11 */ 28 12 public interface PlatformHook { 13 29 14 /** 30 15 * The preStartupHook will be called extremly early. It is … … 32 17 * 33 18 * 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. 36 20 */ 37 21 public void preStartupHook(); … … 48 32 /** 49 33 * 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 51 37 */ 52 38 public void openUrl(String url) throws IOException; … … 79 65 * 80 66 * 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. 82 68 * 83 69 * 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) 86 75 */ 87 76 public String makeTooltip(String name, Shortcut sc); 88 77 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 */ 89 82 public String getDefaultStyle(); 90 83 84 /** 85 * Determines if the platform allows full-screen. 86 * @return {@code true} if full screen is allowed, {@code false} otherwise 87 */ 91 88 public boolean canFullscreen(); 92 89 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 */ 93 96 public boolean rename(File from, File to); 94 97 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r6380 r6443 15 15 16 16 /** 17 * @see PlatformHook 17 * {@code PlatformHook} implementation for Apple Mac OS X systems. 18 * @since 1023 18 19 */ 19 20 public class PlatformHookOsx extends PlatformHookUnixoid implements PlatformHook, InvocationHandler { 21 20 22 private static PlatformHookOsx ivhandler = new PlatformHookOsx(); 21 @Override 22 public void preStartupHook(){ 23 24 @Override 25 public void preStartupHook() { 23 26 // This will merge our MenuBar into the system menu. 24 27 // MUST be set before Swing is initialized! 25 // And will not work when one of the system independe t LAFs is used.28 // And will not work when one of the system independent LAFs is used. 26 29 // They just insist on painting themselves... 27 30 System.setProperty("apple.laf.useScreenMenuBar", "true"); 28 31 } 32 29 33 @Override 30 34 public void startupHook() { … … 44 48 } 45 49 } 50 46 51 @Override 47 52 public Object invoke (Object proxy, Method method, Object[] args) throws Throwable { … … 64 69 return null; 65 70 } 71 66 72 @Override 67 73 public void openUrl(String url) throws IOException { … … 71 77 @Override 72 78 public void initSystemShortcuts() { 73 // Yeah, it's a long, long list. And people always complain that OSX has no shortcuts.74 79 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). 75 80 Shortcut.registerSystemShortcut("apple-reserved-02", tr("reserved"), KeyEvent.VK_SPACE, KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK).setAutomatic(); // Apple reserved. … … 207 212 Shortcut.registerSystemShortcut("view:zoomout", tr("reserved"), KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK); // Zoom out 208 213 } 214 209 215 @Override 210 216 public String makeTooltip(String name, Shortcut sc) { … … 237 243 238 244 @Override 239 public String getDefaultStyle() 240 { 245 public String getDefaultStyle() { 241 246 return "javax.swing.plaf.metal.MetalLookAndFeel"; 242 247 } 243 248 244 249 @Override 245 public boolean canFullscreen() 246 { 250 public boolean canFullscreen() { 247 251 return false; 248 252 } 249 253 250 /* (non-Javadoc)251 * @see org.openstreetmap.josm.tools.PlatformHookUnixoid#getOSDescription()252 */253 254 @Override 254 255 public String getOSDescription() { -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r6380 r6443 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Dimension; 6 7 import java.awt.GraphicsEnvironment; 7 8 import java.awt.event.KeyEvent; … … 13 14 import java.util.Arrays; 14 15 16 import javax.swing.JOptionPane; 17 15 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.gui.ExtendedDialog; 16 20 17 21 /** … … 28 32 29 33 @Override 30 public void preStartupHook() {34 public void preStartupHook() { 31 35 } 32 36 … … 56 60 Shortcut.registerSystemShortcut("system:resetX", tr("reserved"), KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic(); 57 61 } 62 58 63 /** 59 64 * This should work for all platforms. Yeah, should. … … 82 87 83 88 @Override 84 public boolean canFullscreen() 85 { 89 public boolean canFullscreen() { 86 90 return GraphicsEnvironment.getLocalGraphicsEnvironment() 87 91 .getDefaultScreenDevice().isFullScreenSupported(); … … 89 93 90 94 @Override 91 public boolean rename(File from, File to) 92 { 95 public boolean rename(File from, File to) { 93 96 return from.renameTo(to); 94 97 } … … 263 266 } 264 267 } 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 } 265 293 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r6380 r6443 32 32 33 33 /** 34 * see PlatformHook.java 34 * {@code PlatformHook} implementation for Microsoft Windows systems. 35 * @since 1023 35 36 */ 36 37 public 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 37 50 @Override 38 51 public void openUrl(String url) throws IOException { … … 111 124 112 125 @Override 113 public String getDefaultStyle() 114 { 126 public String getDefaultStyle() { 115 127 return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; 116 128 } 117 129 118 130 @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()) 122 133 to.delete(); 123 134 return from.renameTo(to); 124 135 } 125 136 126 /* (non-Javadoc)127 * @see org.openstreetmap.josm.tools.PlatformHookUnixoid#getOSDescription()128 */129 137 @Override 130 138 public String getOSDescription() {
Note:
See TracChangeset
for help on using the changeset viewer.