Changeset 34623 in osm
- Timestamp:
- 2018-09-09T22:03:36+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/openjfx
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openjfx/.classpath
r34602 r34623 4 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> 5 5 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 6 <classpathentry exported="true" kind="lib" path="lib/javafx-base-11-ea+2 3-win.jar" sourcepath="lib/javafx-base-11-ea+23-sources.jar">6 <classpathentry exported="true" kind="lib" path="lib/javafx-base-11-ea+25-win.jar" sourcepath="lib/javafx-base-11-ea+25-sources.jar"> 7 7 <attributes> 8 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-base-11-ea+2 3-javadoc.jar!/"/>8 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-base-11-ea+25-javadoc.jar!/"/> 9 9 </attributes> 10 10 </classpathentry> 11 <classpathentry exported="true" kind="lib" path="lib/javafx-controls-11-ea+2 3-win.jar" sourcepath="lib/javafx-controls-11-ea+23-sources.jar">11 <classpathentry exported="true" kind="lib" path="lib/javafx-controls-11-ea+25-win.jar" sourcepath="lib/javafx-controls-11-ea+25-sources.jar"> 12 12 <attributes> 13 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-controls-11-ea+2 3-javadoc.jar!/"/>13 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-controls-11-ea+25-javadoc.jar!/"/> 14 14 </attributes> 15 15 </classpathentry> 16 <classpathentry exported="true" kind="lib" path="lib/javafx-fxml-11-ea+2 3-win.jar" sourcepath="lib/javafx-fxml-11-ea+23-sources.jar">16 <classpathentry exported="true" kind="lib" path="lib/javafx-fxml-11-ea+25-win.jar" sourcepath="lib/javafx-fxml-11-ea+25-sources.jar"> 17 17 <attributes> 18 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-fxml-11-ea+2 3-javadoc.jar!/"/>18 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-fxml-11-ea+25-javadoc.jar!/"/> 19 19 </attributes> 20 20 </classpathentry> 21 <classpathentry exported="true" kind="lib" path="lib/javafx-graphics-11-ea+2 3-win.jar" sourcepath="lib/javafx-graphics-11-ea+23-sources.jar">21 <classpathentry exported="true" kind="lib" path="lib/javafx-graphics-11-ea+25-win.jar" sourcepath="lib/javafx-graphics-11-ea+25-sources.jar"> 22 22 <attributes> 23 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-graphics-11-ea+2 3-javadoc.jar!/"/>23 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-graphics-11-ea+25-javadoc.jar!/"/> 24 24 </attributes> 25 25 </classpathentry> 26 <classpathentry exported="true" kind="lib" path="lib/javafx-media-11-ea+2 3-win.jar" sourcepath="lib/javafx-media-11-ea+23-sources.jar">26 <classpathentry exported="true" kind="lib" path="lib/javafx-media-11-ea+25-win.jar" sourcepath="lib/javafx-media-11-ea+25-sources.jar"> 27 27 <attributes> 28 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-media-11-ea+2 3-javadoc.jar!/"/>28 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-media-11-ea+25-javadoc.jar!/"/> 29 29 </attributes> 30 30 </classpathentry> 31 <classpathentry exported="true" kind="lib" path="lib/javafx-swing-11-ea+2 3-win.jar" sourcepath="lib/javafx-swing-11-ea+23-sources.jar">31 <classpathentry exported="true" kind="lib" path="lib/javafx-swing-11-ea+25-win.jar" sourcepath="lib/javafx-swing-11-ea+25-sources.jar"> 32 32 <attributes> 33 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-swing-11-ea+2 3-javadoc.jar!/"/>33 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-swing-11-ea+25-javadoc.jar!/"/> 34 34 </attributes> 35 35 </classpathentry> 36 <classpathentry exported="true" kind="lib" path="lib/javafx-web-11-ea+2 3-win.jar" sourcepath="lib/javafx-web-11-ea+23-sources.jar">36 <classpathentry exported="true" kind="lib" path="lib/javafx-web-11-ea+25-win.jar" sourcepath="lib/javafx-web-11-ea+25-sources.jar"> 37 37 <attributes> 38 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-web-11-ea+2 3-javadoc.jar!/"/>38 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-openjfx/lib/javafx-web-11-ea+25-javadoc.jar!/"/> 39 39 </attributes> 40 40 </classpathentry> -
applications/editors/josm/plugins/openjfx/README
r34602 r34623 1 1 README 2 2 ====== 3 This plugin provides the openjfx library for JOSM plugins.3 This plugin provides the openjfx (JavaFX) library for JOSM plugins. 4 4 * Licensed under GPL v3 (see LICENSE) -
applications/editors/josm/plugins/openjfx/build.xml
r34604 r34623 4 4 <property name="commit.message" value="Commit message"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="14 183"/>6 <property name="plugin.main.version" value="14234"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). … … 10 10 --> 11 11 <property name="plugin.author" value="Don-vip"/> 12 <property name="plugin.class" value="org.openstreetmap.josm.plugins. jaxb.OpenJfxPlugin"/>12 <property name="plugin.class" value="org.openstreetmap.josm.plugins.openjfx.OpenJfxPlugin"/> 13 13 <property name="plugin.description" value="Provides the OpenJFX (JavaFX) library for JOSM core and other JOSM plugins. Provides additional features such as MP3 audio playback."/> 14 14 <property name="plugin.minimum.java.version" value="11"/> … … 25 25 <!-- include fetch_dependencies task --> 26 26 </target> 27 28 <!-- Override build-jar target to speed up merging from 16 minutes to 7 minutes --> 29 <target name="build-jar"> 30 <echo>Building commong jar...</echo> 31 <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="MANIFEST" manifestencoding="UTF-8" duplicate="preserve" level="9"> 32 <restrict> 33 <not><or> 34 <name name="META-INF/maven/*"/> 35 <name name="META-INF/DEPENDENCIES"/> 36 <name name="META-INF/LICENSE"/> 37 <name name="META-INF/NOTICE"/> 38 <name name="META-INF/*.RSA"/> 39 <name name="META-INF/*.SF"/> 40 <name name="module-info.class"/> 41 </or></not> 42 <archives> 43 <zips> 44 <fileset dir="${plugin.lib.dir}" includes="*-linux.jar"/> 45 </zips> 46 </archives> 47 </restrict> 48 </jar> 49 <echo>Adding macOS artifacts...</echo> 50 <jar destfile="${plugin.jar}" update="true" duplicate="preserve" level="9"> 51 <restrict> 52 <or> 53 <name name="*.dylib"/> 54 <name name="com/sun/glass/events/mac/**"/> 55 <name name="com/sun/glass/ui/mac/**"/> 56 <name name="com/sun/media/jfxmediaimpl/platform/osx/**"/> 57 <name name="com/sun/prism/es2/**"/> 58 </or> 59 <archives> 60 <zips> 61 <fileset dir="${plugin.lib.dir}" includes="*-mac.jar"/> 62 </zips> 63 </archives> 64 </restrict> 65 </jar> 66 <echo>Adding Windows artifacts...</echo> 67 <jar destfile="${plugin.jar}" update="true" duplicate="preserve" level="9"> 68 <restrict> 69 <or> 70 <name name="*.dll"/> 71 <name name="com/sun/glass/ui/win/**"/> 72 <name name="com/sun/prism/d3d/**"/> 73 <name name="com/sun/scenario/effect/impl/hw/d3d/**"/> 74 </or> 75 <archives> 76 <zips> 77 <fileset dir="${plugin.lib.dir}" includes="*-win.jar"/> 78 </zips> 79 </archives> 80 </restrict> 81 </jar> 82 </target> 27 83 </project> -
applications/editors/josm/plugins/openjfx/ivy.xml
r34602 r34623 5 5 </configurations> 6 6 <dependencies> 7 <dependency org="org.openjfx" name="javafx-swing" rev="11-ea+2 3">7 <dependency org="org.openjfx" name="javafx-swing" rev="11-ea+25"> 8 8 <artifact name="javafx-swing" type="jar" m:classifier="linux"/> 9 9 <artifact name="javafx-swing" type="jar" m:classifier="mac"/> … … 12 12 <artifact name="javafx-swing" type="jar" m:classifier="javadoc"/> 13 13 </dependency> 14 <dependency org="org.openjfx" name="javafx-fxml" rev="11-ea+2 3">14 <dependency org="org.openjfx" name="javafx-fxml" rev="11-ea+25"> 15 15 <artifact name="javafx-fxml" type="jar" m:classifier="linux"/> 16 16 <artifact name="javafx-fxml" type="jar" m:classifier="mac"/> … … 19 19 <artifact name="javafx-fxml" type="jar" m:classifier="javadoc"/> 20 20 </dependency> 21 <dependency org="org.openjfx" name="javafx-web" rev="11-ea+2 3">21 <dependency org="org.openjfx" name="javafx-web" rev="11-ea+25"> 22 22 <artifact name="javafx-web" type="jar" m:classifier="linux"/> 23 23 <artifact name="javafx-web" type="jar" m:classifier="mac"/> … … 26 26 <artifact name="javafx-web" type="jar" m:classifier="javadoc"/> 27 27 </dependency> 28 <dependency org="org.openjfx" name="javafx-media" rev="11-ea+2 3">28 <dependency org="org.openjfx" name="javafx-media" rev="11-ea+25"> 29 29 <artifact name="javafx-media" type="jar" m:classifier="linux"/> 30 30 <artifact name="javafx-media" type="jar" m:classifier="mac"/> … … 33 33 <artifact name="javafx-media" type="jar" m:classifier="javadoc"/> 34 34 </dependency> 35 <dependency org="org.openjfx" name="javafx-controls" rev="11-ea+2 3">35 <dependency org="org.openjfx" name="javafx-controls" rev="11-ea+25"> 36 36 <artifact name="javafx-controls" type="jar" m:classifier="linux"/> 37 37 <artifact name="javafx-controls" type="jar" m:classifier="mac"/> … … 40 40 <artifact name="javafx-controls" type="jar" m:classifier="javadoc"/> 41 41 </dependency> 42 <dependency org="org.openjfx" name="javafx-base" rev="11-ea+2 3">42 <dependency org="org.openjfx" name="javafx-base" rev="11-ea+25"> 43 43 <artifact name="javafx-base" type="jar" m:classifier="linux"/> 44 44 <artifact name="javafx-base" type="jar" m:classifier="mac"/> … … 47 47 <artifact name="javafx-base" type="jar" m:classifier="javadoc"/> 48 48 </dependency> 49 <dependency org="org.openjfx" name="javafx-graphics" rev="11-ea+2 3">49 <dependency org="org.openjfx" name="javafx-graphics" rev="11-ea+25"> 50 50 <artifact name="javafx-graphics" type="jar" m:classifier="linux"/> 51 51 <artifact name="javafx-graphics" type="jar" m:classifier="mac"/> -
applications/editors/josm/plugins/openjfx/src/org/openstreetmap/josm/plugins/openjfx/OpenJfxPlugin.java
r34603 r34623 2 2 package org.openstreetmap.josm.plugins.openjfx; 3 3 4 import java.io.File; 5 import java.io.IOException; 6 import java.io.InputStream; 7 import java.net.URISyntaxException; 8 import java.nio.charset.StandardCharsets; 9 import java.nio.file.FileVisitResult; 10 import java.nio.file.Files; 11 import java.nio.file.Path; 12 import java.nio.file.Paths; 13 import java.nio.file.SimpleFileVisitor; 14 import java.nio.file.StandardCopyOption; 15 import java.nio.file.attribute.BasicFileAttributes; 16 import java.security.CodeSource; 17 import java.util.Enumeration; 18 import java.util.Objects; 19 import java.util.zip.ZipEntry; 20 import java.util.zip.ZipFile; 21 22 import org.openstreetmap.josm.data.Preferences; 4 23 import org.openstreetmap.josm.io.audio.AudioPlayer; 24 import org.openstreetmap.josm.plugins.DynamicURLClassLoader; 5 25 import org.openstreetmap.josm.plugins.Plugin; 6 26 import org.openstreetmap.josm.plugins.PluginInformation; 7 27 import org.openstreetmap.josm.plugins.openjfx.io.audio.JavaFxMediaPlayer; 28 import org.openstreetmap.josm.tools.Logging; 29 import org.openstreetmap.josm.tools.PlatformManager; 8 30 9 31 /** 10 * JAXBplugin brings OpenJFX (JavaFX) to other plugins.32 * OpenJFX plugin brings OpenJFX (JavaFX) to other plugins. 11 33 */ 12 34 public class OpenJfxPlugin extends Plugin { … … 19 41 super(info); 20 42 AudioPlayer.setSoundPlayerClass(JavaFxMediaPlayer.class); 43 String ext = null; 44 if (PlatformManager.isPlatformWindows()) { 45 ext = ".dll"; 46 } else if (PlatformManager.isPlatformUnixoid()) { 47 ext = ".so"; 48 } else if (PlatformManager.isPlatformOsx()) { 49 ext = ".dylib"; 50 } 51 extractNativeLibs(ext); 52 loadNativeLibs(ext); 53 } 54 55 private static void extractNativeLibs(String ext) { 56 CodeSource src = OpenJfxPlugin.class.getProtectionDomain().getCodeSource(); 57 if (src != null) { 58 try (ZipFile zf = new ZipFile(Paths.get(src.getLocation().toURI()).toFile(), StandardCharsets.UTF_8)) { 59 Path dir = getNativeDir(); 60 Enumeration<? extends ZipEntry> es = zf.entries(); 61 while (es.hasMoreElements()) { 62 ZipEntry ze = es.nextElement(); 63 String name = ze.getName(); 64 if (name.endsWith(ext) || name.endsWith(".jar")) { 65 Path targetPath = dir.resolve(name); 66 File targetFile = targetPath.toFile(); 67 if (!targetFile.exists() || targetFile.lastModified() < ze.getTime()) { 68 try (InputStream is = zf.getInputStream(ze)) { 69 Logging.debug("Extracting " + targetPath); 70 Files.copy(is, targetPath, StandardCopyOption.REPLACE_EXISTING); 71 } 72 } 73 } 74 } 75 } catch (IOException | URISyntaxException e) { 76 Logging.error(e); 77 } 78 } else { 79 Logging.error("Unable to locate openjfx jar file"); 80 } 81 } 82 83 private static Path getNativeDir() throws IOException { 84 return Files.createDirectories(new File(Preferences.main().getPluginsDirectory(), "openjfx").toPath()); 85 } 86 87 private static class LibVisitor extends SimpleFileVisitor<Path> { 88 private final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); 89 private final String ext; 90 91 public LibVisitor(String ext) { 92 this.ext = Objects.requireNonNull(ext); 93 } 94 95 @Override 96 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { 97 if (ccl instanceof DynamicURLClassLoader) { 98 if (file.endsWith(ext)) { 99 Logging.debug("Loading " + file); 100 System.load(file.toAbsolutePath().toString()); 101 } else if (file.endsWith(".jar")) { 102 Logging.debug("Loading " + file); 103 ((DynamicURLClassLoader) ccl).addURL(file.toUri().toURL()); 104 } 105 } else { 106 Logging.error("Unexpected context class loader: " + ccl); 107 return FileVisitResult.TERMINATE; 108 } 109 return FileVisitResult.CONTINUE; 110 } 111 } 112 113 private void loadNativeLibs(String ext) { 114 try { 115 Files.walkFileTree(getNativeDir(), new LibVisitor(ext)); 116 } catch (IOException e) { 117 Logging.error(e); 118 } 21 119 } 22 120 }
Note:
See TracChangeset
for help on using the changeset viewer.