Ticket #18925: 18925.3.patch
File 18925.3.patch, 5.9 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/plugins/javafx/JavaFxPlugin.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.javafx; 3 import static org.openstreetmap.josm.tools.I18n.tr; 3 4 4 5 import java.io.File; 5 6 import java.io.IOException; … … 14 15 import java.nio.file.StandardCopyOption; 15 16 import java.nio.file.attribute.BasicFileAttributes; 16 17 import java.security.CodeSource; 18 import java.util.Arrays; 19 import java.util.Collections; 17 20 import java.util.Enumeration; 18 21 import java.util.List; 19 22 import java.util.Objects; … … 21 24 import java.util.zip.ZipFile; 22 25 23 26 import org.openstreetmap.josm.data.Preferences; 27 import org.openstreetmap.josm.gui.MainApplication; 24 28 import org.openstreetmap.josm.io.audio.AudioPlayer; 25 29 import org.openstreetmap.josm.plugins.DynamicURLClassLoader; 26 30 import org.openstreetmap.josm.plugins.Plugin; 31 import org.openstreetmap.josm.plugins.PluginHandler; 27 32 import org.openstreetmap.josm.plugins.PluginInformation; 28 33 import org.openstreetmap.josm.plugins.javafx.io.audio.JavaFxMediaPlayer; 29 34 import org.openstreetmap.josm.tools.Logging; 35 import org.openstreetmap.josm.tools.Utils; 30 36 37 31 38 /** 32 39 * OpenJFX plugin brings OpenJFX (JavaFX) to other plugins. 33 40 */ 34 41 abstract class JavaFxPlugin extends Plugin { 35 42 43 Exception e; 36 44 /** 37 45 * Constructs a new {@code OpenJfxPlugin}. 38 46 * @param info plugin info 39 47 * @param ext native libraries extension 40 * @param orderedNativeLibraries native librari res that must be loaded in this order48 * @param orderedNativeLibraries native libraries that must be loaded in this order 41 49 */ 42 50 protected JavaFxPlugin(PluginInformation info, String ext, List<String> orderedNativeLibraries) { 43 51 super(info); 52 boolean isJavaFx = Utils.getSystemProperty("javafx.runtime.version") != null || Arrays.asList("Oracle Corporation").contains(Utils.getSystemProperty("java.vendor")); 53 if (!isJavaFx && Utils.getJavaVersion() >= 10) { 54 extractNativeLibs(ext); 55 loadNativeLibs(ext, orderedNativeLibraries); 56 } else if (!isJavaFx) { 57 Logging.error("JavaFX is not available"); 58 StringBuilder message = new StringBuilder(tr("JavaFX is not available.")); 59 String os = Utils.getSystemProperty("os.name").toLowerCase(); 60 if (Arrays.asList("windows", "mac os").contains(os)) { 61 message.append(tr(" Please install OpenJFX through your package manager.")); 62 } else { 63 message.append(tr(" Please update to Java 11+.")); 64 } 65 if (PluginHandler.confirmDisablePlugin(MainApplication.getMainFrame(), message.toString(), info.getName())) { 66 PluginHandler.removePlugins(Collections.singletonList(info)); 67 } 68 return; 69 } 44 70 AudioPlayer.setSoundPlayerClass(JavaFxMediaPlayer.class); 45 extractNativeLibs(ext);46 loadNativeLibs(ext, orderedNativeLibraries);47 71 } 48 72 49 73 private static void extractNativeLibs(String ext) { -
src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginOsx.java
3 3 4 4 import java.util.Arrays; 5 5 6 import javax.swing.UnsupportedLookAndFeelException; 7 6 8 import org.openstreetmap.josm.plugins.PluginInformation; 7 9 8 10 /** … … 13 15 /** 14 16 * Constructs a new {@code JavaFxPluginOsx}. 15 17 * @param info plugin info 18 * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10) 16 19 */ 17 public JavaFxPluginOsx(PluginInformation info) {20 public JavaFxPluginOsx(PluginInformation info) throws UnsupportedLookAndFeelException { 18 21 super(info, ".dylib", Arrays.asList()); 19 22 } 20 23 } -
src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginUnixoid.java
3 3 4 4 import java.util.Arrays; 5 5 6 import javax.swing.UnsupportedLookAndFeelException; 7 6 8 import org.openstreetmap.josm.plugins.PluginInformation; 7 9 8 10 /** … … 13 15 /** 14 16 * Constructs a new {@code JavaFxPluginUnixoid}. 15 17 * @param info plugin info 18 * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10) 16 19 */ 17 public JavaFxPluginUnixoid(PluginInformation info) {20 public JavaFxPluginUnixoid(PluginInformation info) throws UnsupportedLookAndFeelException { 18 21 super(info, ".so", Arrays.asList()); 19 22 } 20 23 } -
src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginWindows.java
3 3 4 4 import java.util.Arrays; 5 5 6 import javax.swing.UnsupportedLookAndFeelException; 7 6 8 import org.openstreetmap.josm.plugins.PluginInformation; 7 9 8 10 /** … … 13 15 /** 14 16 * Constructs a new {@code JavaFxPluginWindows}. 15 17 * @param info plugin info 18 * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10) 16 19 */ 17 public JavaFxPluginWindows(PluginInformation info) {20 public JavaFxPluginWindows(PluginInformation info) throws UnsupportedLookAndFeelException { 18 21 super(info, ".dll", Arrays.asList("fxplugins.dll")); 19 22 } 20 23 }