# HG changeset patch # Parent 918742ebe348643e6dece1cb7f8642913ab3debc #212238 - Platform without FX can be select for use in FX Project Properties diff -r 918742ebe348 java.api.common/apichanges.xml --- a/java.api.common/apichanges.xml Mon Apr 22 14:23:09 2013 +0200 +++ b/java.api.common/apichanges.xml Tue Apr 23 16:22:41 2013 +0200 @@ -107,6 +107,25 @@ + Added PlatformFilter interface. + + + + + +

+ Added interface PlatformFilter to enable filtering out + Java Platforms from UI lists. The primary usecase is to enable + projects that are extensions of SE project to hook into project + UI provided by SE project. More specifically, FX projects need + to hide non-FX platforms in Project Properties panels belonging to SE. +

+
+ + +
+ + Added UI support for JRE profiles. diff -r 918742ebe348 java.api.common/manifest.mf --- a/java.api.common/manifest.mf Mon Apr 22 14:23:09 2013 +0200 +++ b/java.api.common/manifest.mf Tue Apr 23 16:22:41 2013 +0200 @@ -1,4 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.java.api.common/0 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.46 +OpenIDE-Module-Specification-Version: 1.47 diff -r 918742ebe348 java.api.common/src/org/netbeans/modules/java/api/common/ui/PlatformFilter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java.api.common/src/org/netbeans/modules/java/api/common/ui/PlatformFilter.java Tue Apr 23 16:22:41 2013 +0200 @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.modules.java.api.common.ui; + +import org.netbeans.api.java.platform.JavaPlatform; + +/** + * Platform filter is to be used in platform lists (e.g., in combo boxes). + * Projects should be able to register implementation in lookup, to restrict + * lists of platforms to only platforms fulfilling project's needs. This mechanism + * is useful in projects that extend the SE Project and need to hook into the + * underlying SE UI infrastructure. + * + * @author psomol + */ +public interface PlatformFilter { + + /** + * Returns true if platform fulfills whatever condition is implemented + */ + boolean accept(JavaPlatform platform); + +} diff -r 918742ebe348 java.api.common/src/org/netbeans/modules/java/api/common/ui/PlatformUiSupport.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/ui/PlatformUiSupport.java Mon Apr 22 14:23:09 2013 +0200 +++ b/java.api.common/src/org/netbeans/modules/java/api/common/ui/PlatformUiSupport.java Tue Apr 23 16:22:41 2013 +0200 @@ -85,7 +85,7 @@ /** * Support class for {@link JavaPlatform} manipulation in project customizer. - * @author Tomas Zezula, Tomas Mysik + * @author Tomas Zezula, Tomas Mysik, Petr Somol */ public final class PlatformUiSupport { @@ -109,6 +109,19 @@ /** + * Create a {@link ComboBoxModel} of Java platforms. + * The model listens on the {@link JavaPlatformManager} and update its + * state according to the changes. + * @param activePlatform the active project's platform, can be null. + * @param filter project specific filter to filter-out platforms that are not usable in given context + * @return {@link ComboBoxModel}. + */ + public static ComboBoxModel createPlatformComboBoxModel(String activePlatform, Collection filters) { + return new PlatformComboBoxModel(activePlatform, filters); + } + + + /** * Create a {@link ListCellRenderer} for rendering items of the {@link ComboBoxModel} * created by the {@link PlatformUiSupport#createPlatformComboBoxModel(String)} method. * @return {@link ListCellRenderer}. @@ -612,11 +625,17 @@ private String initialPlatform; private PlatformKey selectedPlatform; private boolean inUpdate; + private Collection filters; public PlatformComboBoxModel(String initialPlatform) { + this(initialPlatform, null); + } + + public PlatformComboBoxModel(String initialPlatform, Collection filters) { this.pm = JavaPlatformManager.getDefault(); this.pm.addPropertyChangeListener(WeakListeners.propertyChange(this, this.pm)); this.initialPlatform = initialPlatform; + this.filters = filters; } public int getSize() { @@ -668,7 +687,16 @@ Set orderedNames = new TreeSet(); boolean activeFound = false; for (JavaPlatform platform : platforms) { - if (platform.getInstallFolders().size() > 0) { + boolean accepted = true; + if(filters != null) { + for(PlatformFilter filter : filters) { + if(!filter.accept(platform)) { + accepted = false; + break; + } + } + } + if (accepted && platform.getInstallFolders().size() > 0) { PlatformKey pk = new PlatformKey(platform); orderedNames.add(pk); if (!activeFound && initialPlatform != null) { @@ -684,15 +712,21 @@ } } if (!activeFound) { - if (initialPlatform == null) { - if (selectedPlatform == null || !orderedNames.contains(selectedPlatform)) { - selectedPlatform = new PlatformKey(JavaPlatformManager.getDefault().getDefaultPlatform()); - } + if(orderedNames.isEmpty()) { + LOGGER.warning("PlatformComboBoxModel: All platforms filtered out. Adding default platform although it is not accepted by all PlatformFilters."); // NOI18N + selectedPlatform = new PlatformKey(JavaPlatformManager.getDefault().getDefaultPlatform()); + orderedNames.add(selectedPlatform); } else { - PlatformKey pk = new PlatformKey(initialPlatform); - orderedNames.add(pk); - if (selectedPlatform == null) { - selectedPlatform = pk; + if (initialPlatform == null) { + if (selectedPlatform == null || !orderedNames.contains(selectedPlatform)) { + selectedPlatform = new PlatformKey(JavaPlatformManager.getDefault().getDefaultPlatform()); + } + } else { + PlatformKey pk = new PlatformKey(initialPlatform); + orderedNames.add(pk); + if (selectedPlatform == null) { + selectedPlatform = pk; + } } } } diff -r 918742ebe348 java.api.common/test/unit/src/org/netbeans/modules/java/api/common/ui/PlatformFilterTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java.api.common/test/unit/src/org/netbeans/modules/java/api/common/ui/PlatformFilterTest.java Tue Apr 23 16:22:41 2013 +0200 @@ -0,0 +1,284 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.modules.java.api.common.ui; + +import org.netbeans.modules.java.api.common.ui.PlatformFilter; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.java.platform.JavaPlatform; +import org.netbeans.api.java.platform.Specification; +import org.netbeans.api.project.Project; +import org.netbeans.junit.NbTestCase; +import org.netbeans.modules.java.platform.JavaPlatformProvider; +import org.netbeans.spi.java.classpath.support.ClassPathSupport; +import org.netbeans.spi.project.support.ant.AntBasedTestUtil; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.modules.SpecificationVersion; +import org.openide.util.Lookup; +import org.openide.util.lookup.Lookups; +import org.openide.util.test.MockLookup; + + +public class PlatformFilterTest extends NbTestCase { + + private static final String PRESERVE = "ToBePreserved"; + private static final String FILTEROUT = "ToBeFilteredOut"; + private MockProject prj1; + private MockProject prj2; + private JavaPlatform platform1; + private JavaPlatform platform2; + private JavaPlatform platform3; + + public PlatformFilterTest(final String name) { + super(name); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + platform1 = new TestPlatform("DefaultPlatform" + PRESERVE); + platform2 = new TestPlatform("Platform" + PRESERVE); + platform3 = new TestPlatform("Platform" + FILTEROUT); + MockLookup.setInstances( + AntBasedTestUtil.testAntBasedProjectType(), + new PlatformFilterTest.TestPlatformProvider( + platform1, + platform2, + platform3 + )); + clearWorkDir(); + final FileObject projectDir1 = FileUtil.createFolder( + new File(getWorkDir(),"project1")); //NOI18N + prj1 = new PlatformFilterTest.MockProject(projectDir1); + final FileObject projectDir2 = FileUtil.createFolder( + new File(getWorkDir(),"project2")); //NOI18N + prj2 = new PlatformFilterTest.MockProjectExtended(projectDir2); + } + + public void testMockProject1() { + Collection platforms = prj1.getAvailablePlatforms(); + assertEquals(platforms.size(), 3); + assertTrue(platforms.contains(platform1)); + assertTrue(platforms.contains(platform2)); + assertTrue(platforms.contains(platform3)); + } + + public void testMockProject2() { + Collection platforms = prj2.getAvailablePlatforms(); + assertEquals(platforms.size(), 2); + assertTrue(platforms.contains(platform1)); + assertTrue(platforms.contains(platform2)); + assertFalse(platforms.contains(platform3)); + } + + private static class MockProject implements Project { + + private final FileObject projectDir; + + MockProject(final FileObject projectDir) { + assert projectDir != null; + this.projectDir = projectDir; + } + + public Collection getAvailablePlatforms() { + List result = new ArrayList<>(); + final Collection filters = getLookup().lookupAll(PlatformFilter.class); + JavaPlatform[] platforms = TestPlatformProvider.getDefault().getInstalledPlatforms(); + if(platforms != null) { + for(int i = 0; i < platforms.length; i++) { + boolean accepted = true; + if(filters != null) { + for(PlatformFilter filter : filters) { + if(!filter.accept(platforms[i])) { + accepted = false; + break; + } + } + } + if(accepted) { + result.add(platforms[i]); + } + } + } + return result; + } + + @Override + public FileObject getProjectDirectory() { + return projectDir; + } + + @Override + public Lookup getLookup() { + return Lookups.fixed(this); + } + + } + + private static class MockProjectExtended extends MockProject { + + MockProjectExtended(final FileObject projectDir) { + super(projectDir); + } + + @Override + public Lookup getLookup() { + return Lookups.fixed(this, getFilter()); + } + + private PlatformFilter getFilter() { + return new PlatformFilter() { + @Override + public boolean accept(JavaPlatform platform) { + return !platform.getDisplayName().endsWith(FILTEROUT); + } + }; + } + + } + + + private static class TestPlatformProvider implements JavaPlatformProvider { + + private JavaPlatform[] platforms; + + public static JavaPlatformProvider getDefault() { + return MockLookup.getDefault().lookup(JavaPlatformProvider.class); + } + + public TestPlatformProvider(JavaPlatform... platforms) { + if(platforms.length == 0) { + this.platforms = new JavaPlatform[]{new TestPlatform("DefaultPlatform")}; + } else { + this.platforms = platforms; + } + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + } + + @Override + public JavaPlatform[] getInstalledPlatforms() { + return platforms; + } + + @Override + public JavaPlatform getDefaultPlatform() { + if (platforms.length == 0) { + platforms = new JavaPlatform[]{new TestPlatform("DefaultPlatform")}; + } + return platforms[0]; + } + } + + private static class TestPlatform extends JavaPlatform { + + private String name; + + public TestPlatform(String name) { + this.name = name; + } + + @Override + public FileObject findTool(String toolName) { + return null; + } + + @Override + public String getVendor() { + return "me"; + } + + @Override + public ClassPath getStandardLibraries() { + return ClassPathSupport.createClassPath(new URL[0]); + } + + @Override + public Specification getSpecification() { + return new Specification("j2se", new SpecificationVersion("1.7")); + } + + @Override + public ClassPath getSourceFolders() { + return null; + } + + @Override + public Map getProperties() { + return Collections.singletonMap("platform.ant.name", getDisplayName()); + } + + @Override + public List getJavadocFolders() { + return null; + } + + @Override + public Collection getInstallFolders() { + return null; + } + + @Override + public String getDisplayName() { + return name == null ? "DefaultTestPlatform" : name; + } + + @Override + public ClassPath getBootstrapLibraries() { + return ClassPathSupport.createClassPath(new URL[0]); + } + } +} diff -r 918742ebe348 java.j2seproject/nbproject/project.xml --- a/java.j2seproject/nbproject/project.xml Mon Apr 22 14:23:09 2013 +0200 +++ b/java.j2seproject/nbproject/project.xml Tue Apr 23 16:22:41 2013 +0200 @@ -142,7 +142,7 @@ 0-1 - 1.45 + 1.47 diff -r 918742ebe348 java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java Mon Apr 22 14:23:09 2013 +0200 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java Tue Apr 23 16:22:41 2013 +0200 @@ -58,6 +58,7 @@ import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; @@ -90,6 +91,7 @@ import org.netbeans.modules.java.api.common.classpath.ClassPathSupport; import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.project.ui.ClassPathUiSupport; +import org.netbeans.modules.java.api.common.ui.PlatformFilter; import org.netbeans.modules.java.api.common.project.ui.customizer.ClassPathListCellRenderer; import org.netbeans.modules.java.api.common.project.ui.customizer.SourceRootsUi; import org.netbeans.modules.java.api.common.ui.PlatformUiSupport; @@ -341,7 +343,9 @@ RUN_CLASSPATH_MODEL = ClassPathUiSupport.createListModel(cs.itemsIterator(projectProperties.get(ProjectProperties.RUN_CLASSPATH))); RUN_TEST_CLASSPATH_MODEL = ClassPathUiSupport.createListModel(cs.itemsIterator(projectProperties.get(ProjectProperties.RUN_TEST_CLASSPATH))); ENDORSED_CLASSPATH_MODEL = ClassPathUiSupport.createListModel(cs.itemsIterator(projectProperties.get(ProjectProperties.ENDORSED_CLASSPATH))); - PLATFORM_MODEL = PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM)); + final Collection filters = project.getLookup().lookupAll(PlatformFilter.class); + PLATFORM_MODEL = filters == null ? PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM)) : + PlatformUiSupport.createPlatformComboBoxModel (evaluator.getProperty(JAVA_PLATFORM), filters); PLATFORM_LIST_RENDERER = PlatformUiSupport.createPlatformListCellRenderer(); JAVAC_SOURCE_MODEL = PlatformUiSupport.createSourceLevelComboBoxModel (PLATFORM_MODEL, evaluator.getProperty(JAVAC_SOURCE), evaluator.getProperty(JAVAC_TARGET)); JAVAC_SOURCE_RENDERER = PlatformUiSupport.createSourceLevelListCellRenderer (); diff -r 918742ebe348 javafx2.project/nbproject/project.xml --- a/javafx2.project/nbproject/project.xml Mon Apr 22 14:23:09 2013 +0200 +++ b/javafx2.project/nbproject/project.xml Tue Apr 23 16:22:41 2013 +0200 @@ -73,7 +73,7 @@ 0-1 - 1.24 + 1.47 diff -r 918742ebe348 javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectPlatformFilter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectPlatformFilter.java Tue Apr 23 16:22:41 2013 +0200 @@ -0,0 +1,124 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.modules.javafx2.project; + +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.netbeans.api.java.platform.JavaPlatform; +import org.netbeans.modules.java.api.common.ui.PlatformFilter; +import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator; +import org.netbeans.spi.project.ProjectServiceProvider; +import org.netbeans.spi.project.support.ant.EditableProperties; +import org.netbeans.spi.project.support.ant.PropertyUtils; +import org.openide.util.Lookup; +import org.openide.util.Parameters; + +/** + * + * @author Petr Somol + */ +@ProjectServiceProvider(service=PlatformFilter.class, projectType={"org-netbeans-modules-java-j2seproject"}) // NOI18N +public class JFXProjectPlatformFilter implements PlatformFilter { + + private static final String PLATFORM_ANT_NAME = "platform.ant.name"; // NOI18N + private static final String PLATFORM_PREFIX = "platforms"; // NOI18N + private static final String JAVAFX_SDK_PREFIX = "javafx.sdk.home"; // NOI18N + private static final String JAVAFX_RUNTIME_PREFIX = "javafx.runtime.home"; // NOI18N + + private final J2SEPropertyEvaluator eval; + + public JFXProjectPlatformFilter(Lookup lkp) { + Parameters.notNull("lkp", lkp); //NOI18N + this.eval = lkp.lookup(J2SEPropertyEvaluator.class); + Parameters.notNull("eval", eval); //NOI18N + } + + @Override + public boolean accept(final JavaPlatform platform) { + if(platform != null) { + if(isFXProject(eval)) { + if(isJavaFXEnabled(platform)) { + return true; + } + return false; + } + return true; + } + return false; + } + + /** + * Determines whether given Java Platform supports JavaFX + * (copied from JavaFXPlatformUtils to prevent load on startup) + * + * @param IDE java platform instance + * @return is JavaFX supported + */ + private static boolean isJavaFXEnabled(@NonNull final JavaPlatform platform) { + Parameters.notNull("platform", platform); // NOI18N + String platformName = platform.getProperties().get(PLATFORM_ANT_NAME); + EditableProperties properties = PropertyUtils.getGlobalProperties(); + String sdkPath = properties.get(PLATFORM_PREFIX + '.' + platformName + '.' + JAVAFX_SDK_PREFIX); + String runtimePath = properties.get(PLATFORM_PREFIX + '.' + platformName + '.' + JAVAFX_RUNTIME_PREFIX); + return sdkPath != null && runtimePath != null; + } + + /** + * Checks whether the project represented by its evaluator is a FX project + * + * @param eval + * @return + */ + private static boolean isFXProject(@NonNull final J2SEPropertyEvaluator eval) { + //Don't use JFXProjectProperties.isTrue to prevent JFXProjectProperties from being loaded + //JFXProjectProperties.JAVAFX_ENABLED is inlined by compliler + return isTrue(eval.evaluator().getProperty(JFXProjectProperties.JAVAFX_ENABLED)); + } + + private static boolean isTrue(@NullAllowed final String value) { + return value != null && ( + "true".equalsIgnoreCase(value) || //NOI18N + "yes".equalsIgnoreCase(value) || //NOI18N + "on".equalsIgnoreCase(value)); //NOI18N + } + +} diff -r 918742ebe348 javafx2.project/src/org/netbeans/modules/javafx2/project/api/JavaFXProjectUtils.java --- a/javafx2.project/src/org/netbeans/modules/javafx2/project/api/JavaFXProjectUtils.java Mon Apr 22 14:23:09 2013 +0200 +++ b/javafx2.project/src/org/netbeans/modules/javafx2/project/api/JavaFXProjectUtils.java Tue Apr 23 16:22:41 2013 +0200 @@ -41,11 +41,14 @@ */ package org.netbeans.modules.javafx2.project.api; +import java.util.Arrays; import javax.swing.ComboBoxModel; import javax.swing.ListCellRenderer; import org.netbeans.api.java.platform.JavaPlatform; import org.netbeans.api.project.Project; +import org.netbeans.modules.java.api.common.ui.PlatformFilter; import org.netbeans.modules.java.api.common.ui.PlatformUiSupport; +import org.netbeans.modules.javafx2.platform.api.JavaFXPlatformUtils; import org.netbeans.modules.javafx2.project.J2SEProjectType; import org.netbeans.modules.javafx2.project.JFXProjectUtils; import org.netbeans.modules.javafx2.project.ui.PlatformsComboBoxModel; @@ -53,6 +56,7 @@ /** * * @author Anton Chechel + * @author Petr Somol */ public final class JavaFXProjectUtils { @@ -67,7 +71,13 @@ } public static ComboBoxModel createPlatformComboBoxModel() { - return new PlatformsComboBoxModel(PlatformUiSupport.createPlatformComboBoxModel("default_platform")); // NOI18N + return new PlatformsComboBoxModel(PlatformUiSupport.createPlatformComboBoxModel("default_platform", // NOI18N + Arrays.asList(new PlatformFilter() { + @Override + public boolean accept(JavaPlatform platform) { + return JavaFXPlatformUtils.isJavaFXEnabled(platform); + } + }))); } public static ListCellRenderer createPlatformListCellRenderer() {