Ticket #18925: 18925.patch

File 18925.patch, 5.4 KB (added by taylor.smock, 3 months ago)

Initial patch

  • src/org/openstreetmap/josm/plugins/javafx/JavaFxPlugin.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.javafx;
     3import static org.openstreetmap.josm.tools.I18n.tr;
    34
    45import java.io.File;
    56import java.io.IOException;
     
    1415import java.nio.file.StandardCopyOption;
    1516import java.nio.file.attribute.BasicFileAttributes;
    1617import java.security.CodeSource;
     18import java.util.Arrays;
    1719import java.util.Enumeration;
    1820import java.util.List;
    1921import java.util.Objects;
     
    2022import java.util.zip.ZipEntry;
    2123import java.util.zip.ZipFile;
    2224
     25import javax.swing.UnsupportedLookAndFeelException;
     26
    2327import org.openstreetmap.josm.data.Preferences;
    2428import org.openstreetmap.josm.io.audio.AudioPlayer;
    2529import org.openstreetmap.josm.plugins.DynamicURLClassLoader;
     
    2731import org.openstreetmap.josm.plugins.PluginInformation;
    2832import org.openstreetmap.josm.plugins.javafx.io.audio.JavaFxMediaPlayer;
    2933import org.openstreetmap.josm.tools.Logging;
     34import org.openstreetmap.josm.tools.Utils;
    3035
     36
    3137/**
    3238 * OpenJFX plugin brings OpenJFX (JavaFX) to other plugins.
    3339 */
    3440abstract class JavaFxPlugin extends Plugin {
    3541
     42    Exception e;
    3643    /**
    3744     * Constructs a new {@code OpenJfxPlugin}.
    3845     * @param info plugin info
    3946     * @param ext native libraries extension
    4047     * @param orderedNativeLibraries native librarires that must be loaded in this order
     48     * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10)
    4149     */
    42     protected JavaFxPlugin(PluginInformation info, String ext, List<String> orderedNativeLibraries) {
     50    protected JavaFxPlugin(PluginInformation info, String ext, List<String> orderedNativeLibraries) throws UnsupportedLookAndFeelException {
    4351        super(info);
    44         AudioPlayer.setSoundPlayerClass(JavaFxMediaPlayer.class);
    45         extractNativeLibs(ext);
    46         loadNativeLibs(ext, orderedNativeLibraries);
     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            AudioPlayer.setSoundPlayerClass(JavaFxMediaPlayer.class);
     55        }
     56        if (!isJavaFx && Utils.getJavaVersion() >= 10) {
     57            extractNativeLibs(ext);
     58            loadNativeLibs(ext, orderedNativeLibraries);
     59        } else if (!isJavaFx) {
     60            throw new UnsupportedLookAndFeelException(tr("JavaFX is not available"));
     61        }
    4762    }
    4863
    4964    private static void extractNativeLibs(String ext) {
  • src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginOsx.java

     
    33
    44import java.util.Arrays;
    55
     6import javax.swing.UnsupportedLookAndFeelException;
     7
    68import org.openstreetmap.josm.plugins.PluginInformation;
    79
    810/**
     
    1315    /**
    1416     * Constructs a new {@code JavaFxPluginOsx}.
    1517     * @param info plugin info
     18     * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10)
    1619     */
    17     public JavaFxPluginOsx(PluginInformation info) {
     20    public JavaFxPluginOsx(PluginInformation info) throws UnsupportedLookAndFeelException {
    1821        super(info, ".dylib", Arrays.asList());
    1922    }
    2023}
  • src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginUnixoid.java

     
    33
    44import java.util.Arrays;
    55
     6import javax.swing.UnsupportedLookAndFeelException;
     7
    68import org.openstreetmap.josm.plugins.PluginInformation;
    79
    810/**
     
    1315    /**
    1416     * Constructs a new {@code JavaFxPluginUnixoid}.
    1517     * @param info plugin info
     18     * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10)
    1619     */
    17     public JavaFxPluginUnixoid(PluginInformation info) {
     20    public JavaFxPluginUnixoid(PluginInformation info) throws UnsupportedLookAndFeelException {
    1821        super(info, ".so", Arrays.asList());
    1922    }
    2023}
  • src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginWindows.java

     
    33
    44import java.util.Arrays;
    55
     6import javax.swing.UnsupportedLookAndFeelException;
     7
    68import org.openstreetmap.josm.plugins.PluginInformation;
    79
    810/**
     
    1315    /**
    1416     * Constructs a new {@code JavaFxPluginWindows}.
    1517     * @param info plugin info
     18     * @throws UnsupportedLookAndFeelException if JavaFX is not available (< Java 10)
    1619     */
    17     public JavaFxPluginWindows(PluginInformation info) {
     20    public JavaFxPluginWindows(PluginInformation info) throws UnsupportedLookAndFeelException {
    1821        super(info, ".dll", Arrays.asList("fxplugins.dll"));
    1922    }
    2023}