Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2017-01-20 08:49:00 +0000
committerTom Schindl2017-01-20 08:49:00 +0000
commit0031013386ef0b842af23fba7a37f06a7a3001ec (patch)
tree39b9a5ab0330dd4d17c7ef460a5db5a5481172e7 /bundles/tooling
parent6bb0065325a04f86d4b719d638739448fe4cd6ef (diff)
downloadorg.eclipse.efxclipse-0031013386ef0b842af23fba7a37f06a7a3001ec.tar.gz
org.eclipse.efxclipse-0031013386ef0b842af23fba7a37f06a7a3001ec.tar.xz
org.eclipse.efxclipse-0031013386ef0b842af23fba7a37f06a7a3001ec.zip
Bug 510650 - Add support for JavaFX development with Java9
Diffstat (limited to 'bundles/tooling')
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java74
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/JavaFXClasspathContainerInitializer.java39
2 files changed, 60 insertions, 53 deletions
diff --git a/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java b/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java
index a4fe12b7f..18e3e760b 100755
--- a/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java
+++ b/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java
@@ -19,6 +19,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.core.log.LoggerCreator;
+import org.eclipse.fx.ide.jdt.core.FXVersion;
+import org.eclipse.fx.ide.jdt.core.FXVersionUtil;
import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -32,17 +34,17 @@ import org.eclipse.jdt.launching.LibraryLocation;
public class BuildPathSupport {
public static final String WEB_JAVADOC_LOCATION = "http://docs.oracle.com/javase/8/javafx/api/";
-
+
private static final Logger LOGGER = LoggerCreator.createLogger(BuildPathSupport.class);
-
+
public static IClasspathEntry getJavaFXLibraryEntry(IJavaProject project) {
IPath[] paths = getFxJarPath(project);
if( paths != null ) {
-
+
IPath jarLocationPath = paths[0];
IPath javadocLocation = paths[1];
IPath fxSource = paths[3];
-
+
IClasspathAttribute[] attributes;
IAccessRule[] accessRules= { };
if (javadocLocation == null || !javadocLocation.toFile().exists()) {
@@ -50,27 +52,31 @@ public class BuildPathSupport {
} else {
attributes= new IClasspathAttribute[] { JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toFile().toURI().toString()) };
}
-
+
if( jarLocationPath.toFile().exists() ) {
- return JavaCore.newLibraryEntry(jarLocationPath, fxSource, null, accessRules, attributes, false);
- }
+ return JavaCore.newLibraryEntry(jarLocationPath, fxSource, null, accessRules, attributes, false);
+ }
}
-
+
return null;
}
-
+
public static IPath[] getFxJarPath(IJavaProject project) {
IPath jarLocationPath = null;
IPath javadocLocation = null;
IPath antJarLocationPath = null;
IPath sourceLocationPath = null;
-
+
try {
IVMInstall i = JavaRuntime.getVMInstall(project);
if( i == null ) {
i = JavaRuntime.getDefaultVMInstall();
}
- return getFxJarPath(i);
+
+ if( FXVersionUtil.getFxVersion(i) != FXVersion.FX9 ) {
+ return getFxJarPath(i);
+ }
+ return null;
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -78,8 +84,8 @@ public class BuildPathSupport {
return new IPath[] { jarLocationPath, javadocLocation, antJarLocationPath, sourceLocationPath };
}
-
-
+
+
public static IPath[] getSwtFxJarPath(IVMInstall i) {
File installDir = i.getInstallLocation();
IPath[] checkPaths = {
@@ -87,13 +93,13 @@ public class BuildPathSupport {
new Path(installDir.getAbsolutePath()).append("jre").append("lib").append("jfxswt.jar"),
new Path(installDir.getAbsolutePath()).append("lib").append("jfxswt.jar") // JRE
};
-
+
IPath jarLocationPath = null;
IPath javadocLocation = null;
IPath sourceLocationPath = null;
-
+
jarLocationPath = checkPaths[0];
-
+
if( ! jarLocationPath.toFile().exists() ) {
for( IPath p : checkPaths ) {
if( p.toFile().exists() ) {
@@ -102,48 +108,48 @@ public class BuildPathSupport {
}
}
}
-
+
if( jarLocationPath.toFile().exists() ) {
sourceLocationPath = new Path(installDir.getAbsolutePath()).append("javafx-src.zip");
-
+
return new IPath[] { jarLocationPath, javadocLocation, sourceLocationPath };
}
-
+
return null;
}
-
+
public static IPath[] getFxJarPath(IVMInstall i) {
for( LibraryLocation l : JavaRuntime.getLibraryLocations(i) ) {
if( "jfxrt.jar".equals(l.getSystemLibraryPath().lastSegment()) ) {
return null;
}
}
-
+
IPath jarLocationPath = null;
IPath javadocLocation = null;
IPath antJarLocationPath = null;
IPath sourceLocationPath = null;
-
+
File installDir = i.getInstallLocation();
-
+
IPath[] checkPaths = {
// Java 7
new Path(installDir.getAbsolutePath()).append("jre").append("lib").append("jfxrt.jar"),
new Path(installDir.getAbsolutePath()).append("lib").append("jfxrt.jar") // JRE
-
+
};
-
+
jarLocationPath = checkPaths[0];
-
+
if( ! jarLocationPath.toFile().exists() ) {
for( IPath p : checkPaths ) {
if( p.toFile().exists() ) {
jarLocationPath = p;
break;
}
- }
+ }
}
-
+
if( ! jarLocationPath.toFile().exists() ) {
LOGGER.error("Unable to detect JavaFX jar for JRE " + i.getName());
LOGGER.error(" JRE: " + installDir.getAbsolutePath());
@@ -151,10 +157,10 @@ public class BuildPathSupport {
for( IPath p : checkPaths ) {
LOGGER.error(" " + p.toFile().getAbsolutePath());
}
-
+
return null;
}
-
+
javadocLocation = new Path(installDir.getParentFile().getAbsolutePath()).append("docs").append("api"); //TODO Not shipped yet
if( ! javadocLocation.toFile().exists() ) {
IPath p = new Path(System.getProperty("user.home")).append("javafx-api-"+ i.getName()).append("docs").append("api");
@@ -162,15 +168,15 @@ public class BuildPathSupport {
javadocLocation = p;
}
}
-
+
antJarLocationPath = new Path(installDir.getParent()).append("lib").append("ant-javafx.jar");
-
+
sourceLocationPath = new Path(installDir.getAbsolutePath()).append("javafx-src.zip");
-
+
if( ! sourceLocationPath.toFile().exists() ) {
sourceLocationPath = null;
}
-
+
return new IPath[] { jarLocationPath, javadocLocation, antJarLocationPath, sourceLocationPath };
}
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/JavaFXClasspathContainerInitializer.java b/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/JavaFXClasspathContainerInitializer.java
index 17221b285..623f1b1af 100755
--- a/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/JavaFXClasspathContainerInitializer.java
+++ b/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/JavaFXClasspathContainerInitializer.java
@@ -65,7 +65,7 @@ public class JavaFXClasspathContainerInitializer extends ClasspathContainerIniti
}
}
-
+
public static IClasspathEntry getCssExtClasspathEntry(IJavaProject project) {
try {
return getCssExtClasspathEntry(JavaRuntime.getVMInstall(project));
@@ -74,15 +74,16 @@ public class JavaFXClasspathContainerInitializer extends ClasspathContainerIniti
}
return null;
}
-
+
private static IClasspathEntry getCssExtClasspathEntry(IVMInstall i) {
switch (FXVersionUtil.getFxVersion(i)) {
case FX2: return getBundleAsEntryByName(JavaFXCore.CSSEXT_FX2_BUNDLE_NAME);
case FX8: return getBundleAsEntryByName(JavaFXCore.CSSEXT_FX8_BUNDLE_NAME);
+ case FX9: return getBundleAsEntryByName(JavaFXCore.CSSEXT_FX8_BUNDLE_NAME); //TODO Have there been changes in 9?
}
return null;
}
-
+
private static IClasspathEntry getBundleAsEntryByName(String name) {
try {
final Bundle bundle = Platform.getBundle(name);
@@ -100,33 +101,33 @@ public class JavaFXClasspathContainerInitializer extends ClasspathContainerIniti
return null;
}
}
-
+
@Override
public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) {
return true;
}
-
+
@Override
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
System.err.println("requestUpdate " + containerSuggestion);
-
+
if (isValidJUnitContainerPath(containerPath)) {
final JavaFXContainer container = getNewContainer(containerPath, project);
JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
}
}
-
-
+
+
@Override
public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
if (isValidJUnitContainerPath(containerPath)) {
final JavaFXContainer container = getNewContainer(containerPath, project);
JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
}
-
+
// register update hook
IElementChangedListener listener = new IElementChangedListener() {
-
+
@Override
public void elementChanged(ElementChangedEvent event) {
if (event.getDelta().getKind() == IJavaElementDelta.CHANGED && (event.getDelta().getFlags() & IJavaElementDelta.F_CHILDREN) == IJavaElementDelta.F_CHILDREN) {
@@ -143,34 +144,34 @@ public class JavaFXClasspathContainerInitializer extends ClasspathContainerIniti
e.printStackTrace();
}
}
-
+
}
}
-
-
+
+
}
}
};
JavaCore.addElementChangedListener(listener);
// TODO remove listener
-
+
}
-
-
+
+
private static JavaFXContainer getNewContainer(IPath containerPath, IJavaProject project) {
final IClasspathEntry jfxLibEntry = BuildPathSupport.getJavaFXLibraryEntry(project);
final IClasspathEntry cssExtEntry = getCssExtClasspathEntry(project);
-
+
final List<IClasspathEntry> entries = new ArrayList<>();
if (jfxLibEntry != null) {
entries.add(jfxLibEntry);
}
-
+
if (cssExtEntry != null) {
entries.add(cssExtEntry);
}
-
+
return new JavaFXContainer(containerPath, entries.toArray(new IClasspathEntry[0]));
}

Back to the top