/******************************************************************************* * Copyright (c) 2012 BestSolution.at and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Tom Schindl - initial API and implementation *******************************************************************************/ package at.bestsolution.efxclipse.tooling.pde.core; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.launching.environments.IExecutionEnvironment; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.service.resolver.ImportPackageSpecification; import org.eclipse.pde.core.IClasspathContributor; import at.bestsolution.efxclipse.tooling.jdt.core.internal.BuildPathSupport; @SuppressWarnings("restriction") public class JavaFXClassPathExtender implements IClasspathContributor { @Override public List getHostBundleContributions(BundleDescription desc) { for( String e : desc.getExecutionEnvironments() ) { IExecutionEnvironment env = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(e); IPath[] paths = null; if( env.getDefaultVM() != null ) { paths = BuildPathSupport.getFxJarPath(env.getDefaultVM()); } if( paths == null || paths[0] == null && ! paths[0].toFile().exists() ) { for( IVMInstall i : env.getCompatibleVMs() ) { paths = BuildPathSupport.getFxJarPath(i); if( paths != null && paths[0] != null && paths[0].toFile().exists() ) { break; } } } if( paths != null && paths[0] != null && paths[0].toFile().exists() ) { List l = new ArrayList(); for( ImportPackageSpecification i : desc.getImportPackages() ) { if( i.getName().startsWith("javafx") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),false)); } else if( i.getName().startsWith("com.sun.browser") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.deploy") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.glass") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.javafx") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.media") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.openpisces") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.prism") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.scenario") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.t2k") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("com.sun.webpane") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } else if( i.getName().startsWith("netscape.javascript") ) { l.add(new Rule(new Path(i.getName().replace('.', '/')+"/*"),true)); } } return Collections.singletonList(new Contribution(paths[0], paths[1] == null || !paths[1].toFile().exists() ? BuildPathSupport.WEB_JAVADOC_LOCATION : paths[1].toFile().toURI().toString(), null, null, l.toArray(new Rule[0]))); } } return Collections.emptyList(); } @Override public List getReferencedBundleContributions( BundleDescription desc) { return Collections.emptyList(); } }