当前位置: 首页>>代码示例>>Java>>正文


Java JavaPlatformManager.getDefault方法代码示例

本文整理汇总了Java中org.netbeans.api.java.platform.JavaPlatformManager.getDefault方法的典型用法代码示例。如果您正苦于以下问题:Java JavaPlatformManager.getDefault方法的具体用法?Java JavaPlatformManager.getDefault怎么用?Java JavaPlatformManager.getDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.api.java.platform.JavaPlatformManager的用法示例。


在下文中一共展示了JavaPlatformManager.getDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActivePlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
@CheckForNull
private JavaPlatform getActivePlatform() {
    final String activePlatformId = this.eval.getProperty(platformProp);
    final JavaPlatformManager pm = JavaPlatformManager.getDefault();
    if (activePlatformId == null) {
        return pm.getDefaultPlatform();
    }
    final JavaPlatform[] installedPlatforms = pm.getPlatforms(
            null,
            new Specification(platformType, null));
    for (JavaPlatform javaPlatform : installedPlatforms) {
        final String antName = javaPlatform.getProperties().get(PLAT_PROP_ANT_NAME);
        if (activePlatformId.equals(antName)) {
            return javaPlatform;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProjectProblemsProviders.java

示例2: getActivePlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
/**
 * Returns the active platform used by the project or null if the active
 * project platform is broken.
 * @param activePlatformId the name of platform used by Ant script or null
 * for default platform.
 * @return active {@link JavaPlatform} or null if the project's platform
 * is broken
 */
public static JavaPlatform getActivePlatform(final String activePlatformId) {
    final JavaPlatformManager pm = JavaPlatformManager.getDefault();
    if (activePlatformId == null) {
        return pm.getDefaultPlatform();
    } else {
        JavaPlatform[] installedPlatforms = pm.getPlatforms(null, new Specification(CommonProjectUtils.J2SE_PLATFORM_TYPE, null)); //NOI18N
        for (int i = 0; i < installedPlatforms.length; i++) {
            String antName = installedPlatforms[i].getProperties().get("platform.ant.name"); //NOI18N
            if (antName != null && antName.equals(activePlatformId)) {
                return installedPlatforms[i];
            }
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:AbstractBootPathImpl.java

示例3: getActivePlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
public static JavaPlatform getActivePlatform(final String activePlatformId) {
    final JavaPlatformManager pm = JavaPlatformManager.getDefault();
    if (activePlatformId == null) {
        return pm.getDefaultPlatform();
    } else {
        JavaPlatform[] installedPlatforms = pm.getInstalledPlatforms();
        for (JavaPlatform p : installedPlatforms) {
            String name = p.getSpecification().getName();
            String antName = p.getProperties().get("platform.ant.name"); // NOI18N
            if (name != null && name.equals("j2se") && antName != null && antName.equals(activePlatformId)) { // NOI18N
                return p;
            }
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:OutputUtils.java

示例4: getActivePlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
/**
 * Returns the active platform used by the project or null if the active
 * project platform is broken.
 * @param activePlatformId the name of platform used by Ant script or null
 * for default platform.
 * @param platformType the type of {@link JavaPlatform}
 * @return active {@link JavaPlatform} or null if the project's platform
 * is broken
 * @since 1.59
 */
@CheckForNull
public static JavaPlatform getActivePlatform(
    @NullAllowed final String activePlatformId,
    @NullAllowed String platformType) {
    if (platformType == null) {
        platformType = J2SE_PLATFORM_TYPE;
    }
    final JavaPlatformManager pm = JavaPlatformManager.getDefault();
    if (activePlatformId == null) {
        final JavaPlatform candidate = pm.getDefaultPlatform();
        return candidate == null || !platformType.equals(candidate.getSpecification().getName()) ?
            null :
            candidate;
    }
    JavaPlatform[] installedPlatforms = pm.getPlatforms(null, new Specification(platformType, null)); //NOI18N
    for (JavaPlatform javaPlatform : installedPlatforms) {
        String antName = javaPlatform.getProperties().get("platform.ant.name"); //NOI18N
        if (antName != null && antName.equals(activePlatformId)) {
            return javaPlatform;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:CommonProjectUtils.java

示例5: getPreferredPlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
/**
 * Returns a preferred {@link JavaPlatform} for a new project.
 * @param platformType the platform type as specified by {@link Specification#getName()}
 * @return the preferred {@link JavaPlatform}
 */
@CheckForNull
public static JavaPlatform getPreferredPlatform(@NonNull final String platformType) {
    Parameters.notNull("platformType", platformType);   //NOI18N
    final String platformId = NbPreferences.forModule(PreferredProjectPlatform.class).get(
            MessageFormat.format(PREFERRED_PLATFORM, platformType),
            null);
    final JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    if (platformId != null) {
        for (JavaPlatform jp : jpm.getInstalledPlatforms()) {
            if (platformId.equals(jp.getProperties().get(PLATFORM_ANT_NAME)) &&
                platformType.equals(jp.getSpecification().getName()) &&
                jp.isValid()) {
                return jp;
            }
        }
    }
    final JavaPlatform defaultPlatform = jpm.getDefaultPlatform();
    return platformType.equals(defaultPlatform.getSpecification().getName())?
           defaultPlatform:
           null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PreferredProjectPlatform.java

示例6: PlatformsModel

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
PlatformsModel(
        @NonNull final String requiredPlatformId,
        @NullAllowed final String platformType) {
    Parameters.notNull("requiredPlatformId", requiredPlatformId);   //NOI18N
    this.requiredPlatformId = requiredPlatformId;
    this.platformType = platformType;
    this.broken = new BrokenPlatform(requiredPlatformId);
    this.pm = JavaPlatformManager.getDefault();
    this.pm.addPropertyChangeListener(WeakListeners.propertyChange(this, this.pm));
    init();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FixPlatform.java

示例7: testAvailablePlatforms

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
public void testAvailablePlatforms() {
    
    JavaPlatformManager platMan = JavaPlatformManager.getDefault();
    JavaPlatform platforms[] = platMan.getInstalledPlatforms();
    String[] platNames = new String[platforms.length];
    for (int i = 0; i < platforms.length; i++) {
        System.out.println("Display Name: " + platforms[i].getDisplayName());
        platNames[i] = platforms[i].getDisplayName();
    }
    // there should be test if all added platforms are really added in IDE
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PlatformsTest.java

示例8: findSourceRoots2

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:PlatformSourceForBinaryQuery.java

示例9: getDefJavaPlatBCP

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
private Set<URL> getDefJavaPlatBCP() {
    synchronized (djpbcp) {
        if (djpbcp.isEmpty()) {
            JavaPlatformManager mngr = JavaPlatformManager.getDefault();
            JavaPlatform jp = mngr.getDefaultPlatform();
            ClassPath cp = jp.getBootstrapLibraries();
            for (ClassPath.Entry ent : cp.entries()) {
                djpbcp.add(ent.getURL());
            }
        }
        return Collections.unmodifiableSet(djpbcp);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:EndorsedClassPathImpl.java

示例10: createUniversalCPInfo

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
public synchronized ClasspathInfo createUniversalCPInfo() {
    Reference<ClasspathInfo> r = cached;
    if (r != null) {
        ClasspathInfo c = r.get();
        if (c != null) {
            return c;
        }
    }
    JavaPlatform select = JavaPlatform.getDefault();
    final JavaPlatformManager man = JavaPlatformManager.getDefault();
    if (select.getSpecification().getVersion() != null) {
        for (JavaPlatform p : JavaPlatformManager.getDefault().getInstalledPlatforms()) {
            if (!"j2se".equals(p.getSpecification().getName()) || p.getSpecification().getVersion() == null) continue;
            if (p.getSpecification().getVersion().compareTo(select.getSpecification().getVersion()) > 0) {
                select = p;
            }
        }
    }
    final ClasspathInfo result = ClasspathInfo.create(select.getBootstrapLibraries(), ClassPath.EMPTY, ClassPath.EMPTY);
    if (cached != null) {
            this.cached = new WeakReference<>(result);
    }
    if (weakL == null) {
        man.addPropertyChangeListener(weakL = WeakListeners.propertyChange(this, man));
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:Utilities.java

示例11: PlatformProvider

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
public PlatformProvider (
        @NonNull final Project project,
        @NonNull final PropertyEvaluator evaluator,
        @NonNull final Pair<Pair<String,String>, ClassPath> boot) {
    this.project = project;
    this.evaluator = evaluator;
    this.boot = boot;
    final JavaPlatformManager jps = JavaPlatformManager.getDefault();
    jps.addPropertyChangeListener(WeakListeners.propertyChange(this, jps));
    this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this,evaluator));
    if (this.boot.second() != null) {
        this.boot.second().addPropertyChangeListener(WeakListeners.propertyChange(this, this.boot.second()));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:PlatformNode.java

示例12: findActivePlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
private JavaPlatform findActivePlatform() {
    if (platformManager == null) {
        platformManager = JavaPlatformManager.getDefault();
        platformManager.addPropertyChangeListener(WeakListeners.propertyChange(this, platformManager));
    }
    activePlatformName = evaluator.getProperty(PLATFORM_ACTIVE);
    JavaPlatform activePlatform = CommonProjectUtils.getActivePlatform(activePlatformName, platformType);
    if (activePlatform != null) {
        isActivePlatformValid = true;
    } else {
        activePlatform = createPerProjectPlatform();
        isActivePlatformValid = false;
    }
    return activePlatform;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:BootClassPathImplementation.java

示例13: PlatformModulePath

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
PlatformModulePath(
        @NonNull final PropertyEvaluator eval,
        @NonNull final String platformType) {
    Parameters.notNull("evel", eval);   //NOI18N
    Parameters.notNull("platformType", platformType);   //NOI18N
    this.eval = eval;
    this.platformType = platformType;
    this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval));
    final JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    jpm.addPropertyChangeListener(WeakListeners.propertyChange(this, jpm));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ModuleClassPaths.java

示例14: initListeners

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
private void initListeners() {
    if (listens.compareAndSet(false, true)) {
        final JavaPlatformManager jpm = JavaPlatformManager.getDefault();
        jpm.addPropertyChangeListener(WeakListeners.propertyChange(
            this,
            jpm));
        J2SEProject j2sePrj = project.getLookup().lookup(J2SEProject.class);
        if (j2sePrj != null) {
            j2sePrj.evaluator().addPropertyChangeListener(this);
        } else {
            LOG.log(
               Level.WARNING,
               "No property evaluator provider in project {0}({1})", //NOI18N
               new Object[]{
                   ProjectUtils.getInformation(project).getDisplayName(),
                   FileUtil.getFileDisplayName(project.getProjectDirectory())
               });
        }

        final FileObject projectFolder = project.getProjectDirectory();
        if (projectFolder != null) {
            final File projectDir = FileUtil.toFile(projectFolder);
            if (projectDir != null) {
                final File cfgDir = new File(projectDir, CFG_PATH);   //NOI18N
                FileUtil.addFileChangeListener(this, cfgDir);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:RuntimePlatformProblemsProvider.java

示例15: NashornPlatform

import org.netbeans.api.java.platform.JavaPlatformManager; //导入方法依赖的package包/类
private NashornPlatform() {
    JavaPlatformManager jpm = JavaPlatformManager.getDefault();
    platformListener = new PlatformManagerListener();
    jpm.addPropertyChangeListener(WeakListeners.propertyChange(platformListener, jpm));
    Settings.getPreferences().addPreferenceChangeListener(
            WeakListeners.create(PreferenceChangeListener.class, platformListener, Settings.getPreferences()));
    nashornPlatform = getNashornPlatform(jpm);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:NashornPlatform.java


注:本文中的org.netbeans.api.java.platform.JavaPlatformManager.getDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。