org.netbeans.api.java.platform.JavaPlatform Java Examples

The following examples show how to use org.netbeans.api.java.platform.JavaPlatform. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JBStopRunnable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String[] createEnvironment() {
    
    JBProperties properties = dm.getProperties();

    JavaPlatform platform = properties.getJavaPlatform();
    FileObject fo = (FileObject) platform.getInstallFolders().iterator().next();
    String javaHome = FileUtil.toFile(fo).getAbsolutePath();
    List<String> envp = new ArrayList<String>(3);
    envp.add("JAVA=" + javaHome + "/bin/java"); // NOI18N
    envp.add("JAVA_HOME=" + javaHome); // NOI18N
    envp.add("JBOSS_HOME=" + properties.getRootDir().getAbsolutePath());    // NOI18N        
    if (Utilities.isWindows()) {
        // the shutdown script should not wait for a key press
        envp.add("NOPAUSE=true"); // NOI18N
    }
    return (String[]) envp.toArray(new String[envp.size()]);
}
 
Example #2
Source File: DefaultClassPathProviderTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testModularSources_SystemModules() throws Exception {
    final FileObject artefact = getSourceFile (FILE_IN_PACKAGE);
    Lookup.getDefault().lookup(MockSLQ.class).register(this.srcRoot, new SpecificationVersion("1.8"));  //NOI18N
    assertEquals("1.8", SourceLevelQuery.getSourceLevel(artefact)); //NOI18N
    ClassPathProvider cpp = new DefaultClassPathProvider ();
    ClassPath cp = cpp.findClassPath(artefact, JavaClassPathConstants.MODULE_BOOT_PATH);
    assertNull ("DefaultClassPathProvider returned not null for MODULE_BOOT_PATH with source level 8",cp);
    cp = cpp.findClassPath(artefact, ClassPath.BOOT);
    assertEquals("DefaultClassPathProvider returned invalid classpath for BOOT with source level 8",
            JavaPlatform.getDefault().getBootstrapLibraries(),
            cp);
    Lookup.getDefault().lookup(MockSLQ.class).register(this.srcRoot, new SpecificationVersion("9"));  //NOI18N
    assertEquals("9", SourceLevelQuery.getSourceLevel(artefact)); //NOI18N
    cpp = new DefaultClassPathProvider ();
    cp = cpp.findClassPath(artefact, JavaClassPathConstants.MODULE_BOOT_PATH);
    assertEquals ("DefaultClassPathProvider returned invalid classpath for MODULE_BOOT_PATH with source level 9",
            j9.getBootstrapLibraries(),
            cp);
    cp = cpp.findClassPath(artefact, ClassPath.BOOT);
    assertEquals("DefaultClassPathProvider returned invalid classpath for BOOT with source level 9",
            j9.getBootstrapLibraries(),
            cp);
}
 
Example #3
Source File: JavaFxDefaultJavadocImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@NonNull
public Collection<URI> getDefaultJavadoc(@NonNull final JavaPlatform platform) {
    final List<URI> result = new ArrayList<>();
    final JavadocFilter filter = new JavadocFilter();
    for (FileObject installFolder : platform.getInstallFolders()) {
        for (FileObject file : installFolder.getChildren()) {
            final Collection<? extends URI> roots = filter.accept(file);
            result.addAll(roots);
        }
    }
    if (!result.isEmpty()) {
        return Collections.unmodifiableCollection(result);
    }
    final SpecificationVersion spec = platform.getSpecification().getVersion();
    final String uri = OFFICIAL_JAVADOC.get(spec);
    if (uri != null) {
        try {
            return Collections.singletonList(new URI(uri));
        } catch (URISyntaxException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return Collections.<URI>emptyList();
}
 
Example #4
Source File: JavaFxRuntimeInclusion.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns status of the artifact at relative path runtimePath in platform javaPlatform
 * @param javaPlatform the {@link JavaPlatform} where the artifact is to be searched for
 * @param runtimePath relative path to artifact
 * @return status of artifact presence/inclusion in platform
 */
@NonNull
private static Support forRuntime(@NonNull final JavaPlatform javaPlatform, @NonNull final String runtimePath) {
    Parameters.notNull("javaPlatform", javaPlatform);   //NOI18N
    Parameters.notNull("rtPath", runtimePath);   //NOI18N
    for (FileObject installFolder : javaPlatform.getInstallFolders()) {
        final FileObject jfxrtJar = installFolder.getFileObject(runtimePath);
        if (jfxrtJar != null  && jfxrtJar.isData()) {
            final URL jfxrtRoot = FileUtil.getArchiveRoot(jfxrtJar.toURL());
            for (ClassPath.Entry e : javaPlatform.getBootstrapLibraries().entries()) {
                if (jfxrtRoot.equals(e.getURL())) {
                    return Support.INCLUDED;
                }
            }
            return Support.PRESENT;
        }
    }
    return Support.MISSING;
}
 
Example #5
Source File: CtSymArchiveTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testIssue247469() throws IOException {
    final JavaPlatform jp = JavaPlatformManager.getDefault().getDefaultPlatform();
    assertNotNull(jp);
    final ClasspathInfo cpInfo = ClasspathInfo.create(jp.getBootstrapLibraries(), ClassPath.EMPTY, ClassPath.EMPTY);
    assertNotNull(cpInfo);
    final JavaSource js = JavaSource.create(cpInfo);
    js.runUserActionTask(new Task<CompilationController>() {
        @Override
        public void run(final CompilationController cc) throws Exception {
            final PackageElement packageElement = cc.getElements().getPackageElement("java.lang"); // NOI18N
            for (Element elem : packageElement.getEnclosedElements()) {
                if ("ProcessBuilder$1".equals(elem.getSimpleName().toString())) { // NOI18N
                    TypeElement te = (TypeElement) elem;
                    assertEquals(NestingKind.ANONYMOUS, te.getNestingKind());
                    break;
                }
            }
        }
    }, true);
}
 
Example #6
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if JavaFx is present as a module in the platform.
 * @param javaPlatform to check
 * @return returns true if the JavaFx is available as a platform module
 */
public static boolean hasJavaFxModule(@NonNull final JavaPlatform javaPlatform) {
    if (JDK9.compareTo(javaPlatform.getSpecification().getVersion()) > 0) {
        return false;
    }
    for (ClassPath.Entry e : javaPlatform.getBootstrapLibraries().entries()) {
        final URL url = e.getURL();
        if (!MODULE_PROTOCOL.equals(url.getProtocol())) {
            continue;
        }
        if (MODULE_JFX_BASE.equals(getModuleName(url))) {
            return true;
        }
    }
    return false;
}
 
Example #7
Source File: CompletionHandler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public CompletionHandler() {
    JavaPlatformManager platformMan = JavaPlatformManager.getDefault();
    JavaPlatform platform = platformMan.getDefaultPlatform();
    List<URL> docfolder = platform.getJavadocFolders();

    for (URL url : docfolder) {
        LOG.log(Level.FINEST, "JDK Doc path: {0}", url.toString()); // NOI18N
        jdkJavaDocBase = url.toString();
    }

    GroovySettings groovySettings = GroovySettings.getInstance();
    docListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            synchronized (CompletionHandler.this) {
                groovyJavaDocBase = null;
                groovyApiDocBase = null;
            }
        }
    };
    groovySettings.addPropertyChangeListener(WeakListeners.propertyChange(docListener, this));
}
 
Example #8
Source File: ModuleNamesTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
    if (location == StandardLocation.CLASS_OUTPUT) {
        return Collections.emptySet();
    } else if (location == StandardLocation.SYSTEM_MODULES) {
        final ClassPath cp = JavaPlatform.getDefault().getBootstrapLibraries();
        Collection<? extends URL> javaBase = findJavaBase(cp);
        if (javaBase.isEmpty()) {
            javaBase = fakeJavaBase(cp);
        }
        return Collections.singleton(Collections.singleton(new ModLoc(
                StandardLocation.SYSTEM_MODULES,
                "java.base",    //NOI18N
                javaBase)));
    } else {
        return Collections.emptySet();
    }
}
 
Example #9
Source File: PlatformsCustomizer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void expandAllNodes (BeanTreeView btv, Node node, ExplorerManager mgr, JavaPlatform platform) {
    btv.expandNode (node);
    Children ch = node.getChildren();
    if ( ch == Children.LEAF ) {
        if (platform != null && platform.equals(node.getLookup().lookup(JavaPlatform.class))) {
            try {
                mgr.setSelectedNodes (new Node[] {node});
            } catch (PropertyVetoException e) {
                //Ignore it
            }
        }
        return;
    }
    Node nodes[] = ch.getNodes( true );
    for ( int i = 0; i < nodes.length; i++ ) {
        expandAllNodes( btv, nodes[i], mgr, platform);
    }

}
 
Example #10
Source File: MIMETypes.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get MIME types based on registered Java platforms.
 * The call returns either a cached set, or queries the platforms.
 * 
 * @return a set of MIME types.
 */
public synchronized Set<String> get() {
    if (allPlatformsMIMETypes != null) {
        return allPlatformsMIMETypes;
    }
    JavaPlatformManager pm = JavaPlatformManager.getDefault();
    if (allPlatformsListener == null) {
        allPlatformsListener = new PropertyChangeListener() {
            @Override public void propertyChange(PropertyChangeEvent evt) {
                synchronized (MIMETypes.this) {
                    allPlatformsMIMETypes = null;
                }
                pcs.firePropertyChange(PROP_MIME_TYPES, null, null);
            }
        };
        pm.addPropertyChangeListener(allPlatformsListener);
    }
    JavaPlatform[] installedPlatforms = pm.getPlatforms(null, new Specification ("j2se", null));   //NOI18N
    Set<String> mTypes = new HashSet<>();
    for (int i = 0; i < installedPlatforms.length; i++) {
        mTypes.addAll(get(installedPlatforms[i]));
    }
    allPlatformsMIMETypes = mTypes;
    return mTypes;
}
 
Example #11
Source File: SettingsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private final JavaPlatform findSelectedJdk(String[] name) {
    if (jdkHomeDataModel == null) {
        name[0] = "";
        return null;
    }
    String jdk = (String) jdkHomeDataModel.getSelectedItem();
    final JavaPlatform def = JavaPlatformManager.getDefault().getDefaultPlatform();
    if (jdk == null || jdk.equals(def.getDisplayName())) {
        name[0] = "";
        return def;
    }
    for (JavaPlatform p : JavaPlatformManager.getDefault().getInstalledPlatforms()) {
        if (jdk.equals(p.getDisplayName())) {
            String antName = p.getProperties().get("platform.ant.name");
            if (antName != null) {
                name[0] = antName;
                return p;
            }
        }
    }
    name[0] = jdk;
    return null;
}
 
Example #12
Source File: PlatformModulesPathImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PathResourceImplementation> createResources() {
    final List<PathResourceImplementation> res = new ArrayList<>();
    JavaPlatform pf = findActivePlatform();
    Arrays.stream(new JavaPlatform[] {findActivePlatform()})
        .flatMap((plat)->plat.getBootstrapLibraries().entries().stream())
        .map((entry) -> entry.getURL())
        .filter((root) -> (PROTOCOL_NBJRT.equals(root.getProtocol())))
        .forEach((root)->{res.add(ClassPathSupport.createResource(root));});
    if(LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "PlatformModulesPath for project {0} and platform {1}", new Object[] {project.getProjectDirectory().getPath(), pf.getDisplayName()});
    }
    if(LOGGER.isLoggable(Level.FINER)) {            
        StringBuilder sb = new StringBuilder();
        Iterator<PathResourceImplementation> it = res.iterator();
        while(it.hasNext()) {
            sb.append(it.next());
            if(it.hasNext()) sb.append("\n");
        }
        LOGGER.log(Level.FINER, sb.toString());
    }
    return res;
}
 
Example #13
Source File: JavaUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Search Java SE with provided java home in provided platforms array.
 * <p/>
 * @param javaPlatforms Java SE platforms to search in.
 * @param javaHome      Java SE home to search for.
 * @return Returns Java SE platform {@see JavaPlatform} object matching
 *         provided Java SE home or <code>null</code> if no such
 *         installed platform was found.
 */
public static JavaPlatform findPlatformByJavaHome(
        @NonNull final JavaPlatform[] javaPlatforms,
        @NonNull final File javaHome) {
    // Avoid NPEs and troll developer a bit.
    Parameters.notNull("javaPlatforms", javaPlatforms);
    Parameters.notNull("javaHome", javaHome);
    // Scan all install folders of all onstalled platformsList
    // for Java SE home.
    JavaPlatform javaPlatform = null;
    for (JavaPlatform platform : javaPlatforms) {
        for (FileObject fo : platform.getInstallFolders()) {
            if (javaHome.equals(FileUtil.toFile(fo))) {
                javaPlatform = platform;
                break;
            }
        }
        if (javaPlatform != null) {
            break;
        }
    }
    return javaPlatform;        
}
 
Example #14
Source File: JavaUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Search provided Java SE home in installed platformsList.
 * <p/>
 * @param javaHome Java SE home currently selected.
 * @return Returns Java SE platform {@see JavaPlatform} object matching
 *         provided Java SE home or <code>null</code> if no such
 *         installed platform was found.
 */
public static JavaPlatform findInstalledPlatform(
        @NonNull final File javaHome) {
    // Avoid NPEs and troll developer a bit.
    Parameters.notNull("javaHome", javaHome);
    // Scan all install folders of all onstalled platformsList
    // for Java SE home.
    JavaPlatform[] platforms = getInstalledJavaSEPlatforms();
    JavaPlatform javaPlatform = null;
    for (JavaPlatform platform : platforms) {
        for (FileObject fo : platform.getInstallFolders()) {
            if (javaHome.equals(FileUtil.toFile(fo))) {
                javaPlatform = platform;
                break;
            }
        }
        if (javaPlatform != null) {
            break;
        }
    }
    return javaPlatform;        
}
 
Example #15
Source File: JavaScriptNashornPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void selectPlatform(JavaPlatform platform) {
    int n = platformsComboBox.getItemCount();
    for (int i = 0; i < n; i++) {
        Object obj = platformsComboBox.getItemAt(i);
        JavaPlatform p = PlatformUiSupport.getPlatform(obj);
        if (platform.equals(p)) {
            platformsComboBox.setSelectedIndex(i);
            return ;
        }
    }
}
 
Example #16
Source File: TomcatProperties.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JavaPlatform getJavaPlatform() {
    String currentJvm = ip.getProperty(PROP_JAVA_PLATFORM);
    JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    JavaPlatform[] installedPlatforms = jpm.getPlatforms(null, new Specification("J2SE", null)); // NOI18N
    for (int i = 0; i < installedPlatforms.length; i++) {
        String platformName = (String)installedPlatforms[i].getProperties().get(PLAT_PROP_ANT_NAME);
        if (platformName != null && platformName.equals(currentJvm)) {
            return installedPlatforms[i];
        }
    }
    // return default platform if none was set
    return jpm.getDefaultPlatform();
}
 
Example #17
Source File: JdkConfiguration.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String getPlatformID(JavaPlatform platform) {
    String s = platform.getProperties().get("platform.ant.name"); // NOI18N
    if (s != null) {
        return s;
    } else {
        return PLATFORM_ID_DEFAULT;
    }
}
 
Example #18
Source File: PlatformJavadocForBinaryQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JavadocForBinaryQuery.Result findJavadoc(@NonNull final URL binaryRoot) {
    final Collection<JavaPlatform> candidates = new ArrayDeque<JavaPlatform>();
    for (JavaPlatform jp : JavaPlatformManager.getDefault().getInstalledPlatforms()) {
        for (ClassPath.Entry entry : jp.getBootstrapLibraries().entries()) {
            if (binaryRoot.equals(entry.getURL())) {
                candidates.add(jp);
            }
        }
    }
    return candidates.isEmpty() ? null : new R(candidates);
}
 
Example #19
Source File: JavaUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Search for first available installed folder in Java SE platform.
 * <p/>
 * @param platform Java SE platform to search for first available
 *                 installed folder.
 * @return First available installed folder or <code>null</code> if no such
 *         folder exists.
 */
public static String getJavaHome(JavaPlatform platform) {
    String javaHome = null;
    Iterator<FileObject> platformIterator
            = platform.getInstallFolders().iterator();
    if (platformIterator.hasNext()) {
        FileObject javaHomeFO = platformIterator.next();
        if (javaHomeFO != null) {
            javaHome = FileUtil.toFile(javaHomeFO).getAbsolutePath();
        }
    }
    return javaHome;
}
 
Example #20
Source File: PlatformSourceForBinaryQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static boolean contains(
    @NonNull final JavaPlatform platform,
    @NonNull final URL artifact) {
    for (ClassPath.Entry entry : platform.getBootstrapLibraries().entries()) {
        if (entry.getURL().equals (artifact)) {
            return true;
        }
    }
    return false;
}
 
Example #21
Source File: PlatformSourceForBinaryQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to locate the source root for given classpath root.
 * @param binaryRoot the URL of a classpath root (platform supports file and jar protocol)
 * @return FileObject[], never returns null
 */
@Override
public SourceForBinaryQueryImplementation2.Result findSourceRoots2(URL binaryRoot) {
    SourceForBinaryQueryImplementation2.Result res = this.cache.get (binaryRoot);
    if (res != null) {
        return res;
    }
    final JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    final Collection<JavaPlatform> candidates = new ArrayDeque<>();
    for (JavaPlatform platform : jpm.getInstalledPlatforms()) {
        if (contains(platform, binaryRoot)) {
            candidates.add(platform);
        }
    }
    if (!candidates.isEmpty()) {
        res = new Result(
            jpm,
            binaryRoot,
            candidates);
        this.cache.put (binaryRoot, res);
        return res;
    }
    String binaryRootS = binaryRoot.toExternalForm();
    if (binaryRootS.startsWith(JAR_FILE)) {
        if (binaryRootS.endsWith(RTJAR_PATH)) {
            //Unregistered platform
            String srcZipS = binaryRootS.substring(4,binaryRootS.length() - RTJAR_PATH.length()) + SRC_ZIP;
            try {
                URL srcZip = FileUtil.getArchiveRoot(new URL(srcZipS));
                FileObject fo = URLMapper.findFileObject(srcZip);
                if (fo != null) {
                    return new UnregisteredPlatformResult (fo);
                }
            } catch (MalformedURLException mue) {
                Exceptions.printStackTrace(mue);
            }
        }
    }
    return null;
}
 
Example #22
Source File: JBProperties.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JavaPlatform getJavaPlatform() {
    String currentJvm = ip.getProperty(PROP_JAVA_PLATFORM);
    JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    JavaPlatform[] installedPlatforms = jpm.getPlatforms(null, new Specification("J2SE", null)); // NOI18N
    for (int i = 0; i < installedPlatforms.length; i++) {
        String platformName = (String)installedPlatforms[i].getProperties().get(PLAT_PROP_ANT_NAME);
        if (platformName != null && platformName.equals(currentJvm)) {
            return installedPlatforms[i];
        }
    }
    // return default platform if none was set
    return jpm.getDefaultPlatform();
}
 
Example #23
Source File: MavenCommandLineExecutor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isEventSpyCompatible(final BeanRunConfig clonedConfig) {
    // EventSpy cannot work on jdk < 7
    if (clonedConfig.getProject() != null) {
        ActiveJ2SEPlatformProvider javaprov = clonedConfig.getProject().getLookup().lookup(ActiveJ2SEPlatformProvider.class);
        JavaPlatform platform = javaprov.getJavaPlatform();
        return (platform.getSpecification().getVersion().compareTo(VER17) >= 0);
    } else {
        return true;
    }
}
 
Example #24
Source File: ShellProjectUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static boolean isModularJDK(JavaPlatform pl) {
    if (pl != null) {
        Specification plSpec = pl.getSpecification();
        SpecificationVersion jvmversion = plSpec.getVersion();
        if (jvmversion.compareTo(new SpecificationVersion("9")) >= 0) {
            return true;
        }
    }
    return false;
}
 
Example #25
Source File: PlatformNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasJavadoc() {
    JavaPlatform platform = platformProvider.getPlatform();
    if (platform == null) {
        return false;
    }
    URL[] javadocRoots = getJavadocRoots(platform);
    return javadocRoots.length > 0;
}
 
Example #26
Source File: MavenFileLocator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ClassPath getProjectClasspath(Project p) {
    ClassPath result;
    ClassPathProvider cpp = p.getLookup().lookup(ClassPathProvider.class);
    Set<FileObject> roots = new HashSet<FileObject>();
    Sources sources = ProjectUtils.getSources(p);
    if (sources != null) {
        SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (SourceGroup group : groups) {
            roots.add(group.getRootFolder());
        }
    }

    Set<ClassPath> setCP = new HashSet<ClassPath>();
    if (cpp != null) {
        for (FileObject file : roots) {
            ClassPath path = cpp.findClassPath(file, ClassPath.COMPILE);
            setCP.add(path);
        }
    }

    for (ClassPath cp : setCP) {
        FileObject[] rootsCP = cp.getRoots();
        for (FileObject fo : rootsCP) {
            FileObject[] aaa = SourceForBinaryQuery.findSourceRoots(fo.toURL()).getRoots();
            roots.addAll(Arrays.asList(aaa));
        }
    }
    JavaPlatform platform = p.getLookup().lookup(ActiveJ2SEPlatformProvider.class).getJavaPlatform();

    if (platform != null) {
        roots.addAll(Arrays.asList(platform.getSourceFolders().getRoots()));
    }
    result = ClassPathSupport.createClassPath(roots.toArray(new FileObject[roots.size()]));
    return result;
}
 
Example #27
Source File: MIMETypes.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Set<String> get(Project prj) {
    JavaPlatform jp = getProjectPlatform(prj);
    if (jp == null) {
        return Collections.emptySet();
    }
    return get(jp);
}
 
Example #28
Source File: J2SEProjectPlatformTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    proj = new File(getWorkDir(), "proj");  //NOI18N
    proj.mkdirs();
    final File dp = new File(getWorkDir(), "dp");   //NOI18N
    final File op = new File(getWorkDir(), "op");   //NOI18N
    MockJavaPlatformProvider pp = MockJavaPlatformProvider.getInstance();
    pp.setPlatforms(new JavaPlatform[] {
        new MockJavaPlatform("default_platform", FileUtil.createFolder(dp)),   //NOI18N
        new MockJavaPlatform("other_platform", FileUtil.createFolder(op))      //NOI18N
    });
    MockLookup.setLayersAndInstances(pp);
}
 
Example #29
Source File: PlatformNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void showJavadoc() {
    JavaPlatform platform = platformProvider.getPlatform();
    if (platform != null) {
        URL[] javadocRoots = getJavadocRoots(platform);
        URL pageURL = ShowJavadocAction.findJavadoc("overview-summary.html",javadocRoots);
        if (pageURL == null) {
            pageURL = ShowJavadocAction.findJavadoc("index.html",javadocRoots);
        }
        ShowJavadocAction.showJavaDoc(pageURL, platform.getDisplayName());
    }
}
 
Example #30
Source File: ModuleClassPaths.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NonNull
private Stream<JavaPlatform> getPlatforms() {
    final String platformName = eval.getProperty(ProjectProperties.PLATFORM_ACTIVE);
    return platformName != null && !platformName.isEmpty() ?
            Arrays.stream(JavaPlatformManager.getDefault().getInstalledPlatforms())
                .filter((plat)->
                    platformName.equals(plat.getProperties().get(PLATFORM_ANT_NAME)) &&
                    platformType.equals(plat.getSpecification().getName())) :
            Stream.empty();
}