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


Java JavaProjectConstants类代码示例

本文整理汇总了Java中org.netbeans.api.java.project.JavaProjectConstants的典型用法代码示例。如果您正苦于以下问题:Java JavaProjectConstants类的具体用法?Java JavaProjectConstants怎么用?Java JavaProjectConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isOnSourceClasspath

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
public static boolean isOnSourceClasspath(FileObject fo) {
    Project p = FileOwnerQuery.getOwner(fo);
    if (p==null) {
        return false;
    }
    if (OpenProjects.getDefault().isProjectOpen(p)) {
        SourceGroup[] gr = ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (int j = 0; j < gr.length; j++) {
            if (fo==gr[j].getRootFolder()) {
                return true;
            }
            if (FileUtil.isParentOf(gr[j].getRootFolder(), fo)) {
                return true;
            }
        }
        return false;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RefactoringUtil.java

示例2: initCombos

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
private void initCombos() {
        Sources sources = ProjectUtils.getSources(project);
        SourceGroup[] sourceGroupsJava = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        if (sourceGroupsJava == null) {
            throw new IllegalStateException(
                    NbBundle.getMessage(FXMLTemplateWizardIterator.class,
                    "MSG_ConfigureFXMLPanel_SGs_Error")); // NOI18N
        }
        support = new SourceGroupSupport(JavaProjectConstants.SOURCES_TYPE_JAVA);
        support.addSourceGroups(sourceGroupsJava); //must exist

        comboBoxSourceRoot.setModel(new DefaultComboBoxModel(support.getSourceGroups().toArray()));
//        SourceGroupSupport.SourceGroupProxy preselectedGroup = support.getParent().getCurrentSourceGroup();
//        ignoreRootCombo = true;
//        comboBoxSourceRoot.setSelectedItem(preselectedGroup);
//        ignoreRootCombo = false;
//        comboBoxPackage.getEditor().setItem(support.getParent().getCurrentPackageName());
        updatePackages();
        updateText();
        updateResult();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JSEApplicationClassChooser.java

示例3: getJPAVersion

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
/**
 * method check target compile classpath for presence of persitence classes of certain version
 * returns max supported specification
 * @param project
 * @return
 */
public static String getJPAVersion(Project target)
{
    String version=null;
    Sources sources=ProjectUtils.getSources(target);
    SourceGroup groups[]=sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    SourceGroup firstGroup=groups[0];
    FileObject fo=firstGroup.getRootFolder();
    ClassPath compile=ClassPath.getClassPath(fo, ClassPath.COMPILE);
    if(compile.findResource("javax/persistence/criteria/CriteriaUpdate.class")!=null) {
        version=Persistence.VERSION_2_1;
    } else if(compile.findResource("javax/persistence/criteria/JoinType.class")!=null) {
        version=Persistence.VERSION_2_0;
    } else if(compile.findResource("javax/persistence/Entity.class")!=null) {
        version=Persistence.VERSION_1_0;
    }
    return version;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:PersistenceUtils.java

示例4: getSourceRoots

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
private static void getSourceRoots(final Lookup.Provider project, final boolean traverse, Set<Lookup.Provider> projects, Set<FileObject> roots) {
    if (project instanceof Project) {
        final Sources sources = ProjectUtils.getSources((Project)project);

        for (SourceGroup sg : sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
            roots.add(sg.getRootFolder());
        }

        if (traverse) {
            // process possible subprojects
            //mkleint: see subprojectprovider for official contract, maybe classpath should be checked instead? see #210465                
            SubprojectProvider spp = project.getLookup().lookup(SubprojectProvider.class);

            if (spp != null) {
                for (Project p : spp.getSubprojects()) {
                    if (projects.add(p)) {
                        getSourceRoots(p, traverse, projects, roots);
                    }
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ProjectUtilities.java

示例5: getProjectClassPath

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
/**
 * Returns the project classpath including project build paths.
 * Can be used to set classpath for custom classloader.
 * 
 * @param projectFile may not be used in method realization
 * @return List of java.io.File objects representing each entry on the classpath.
 */
@Override
public List<URL> getProjectClassPath(FileObject projectFile) {
    List<URL> projectClassPathEntries = new ArrayList<URL>();
    SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (sgs.length < 1) {
        return projectClassPathEntries;
    }
    FileObject sourceRoot = sgs[0].getRootFolder();
    ClassPathProvider cpProv = project.getLookup().lookup(ClassPathProvider.class);
    ClassPath cp = cpProv.findClassPath(sourceRoot, ClassPath.EXECUTE);
    if(cp == null){
        cp = cpProv.findClassPath(sourceRoot, ClassPath.COMPILE);
    }
    for (ClassPath.Entry cpEntry : cp.entries()) {
        if(cpEntry.isValid()){
            //if project isn't build, there may be number of invalid entries and may be in some other cases
            projectClassPathEntries.add(cpEntry.getURL());
        }
    }

    return projectClassPathEntries;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:PersistenceEnvironmentImpl.java

示例6: getSourceGroups

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
private static SourceGroup[] getSourceGroups(Project project) {
    Sources projectSources = ProjectUtils.getSources(project);
    // first, try to get resources
    SourceGroup[] resources = projectSources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES);
    if (resources.length > 0) {
        return resources;
    }
    // try to create it
    SourceGroup resourcesSourceGroup = SourceGroupModifier.createSourceGroup(
        project, JavaProjectConstants.SOURCES_TYPE_RESOURCES, JavaProjectConstants.SOURCES_HINT_MAIN);
    if (resourcesSourceGroup != null) {
        return new SourceGroup[] {resourcesSourceGroup};
    }
    // fallback to java sources
    return projectSources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PersistenceEnvironmentImpl.java

示例7: getTestParameter

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
private String getTestParameter(FileObject[] activatedFOs, Project project, FileObject testDir) {
    if(activatedFOs.length == 1 && project.getProjectDirectory().equals(activatedFOs[0])) {
        return Utils.RUN_SELENIUM_TESTS_REGEXP;
    }
    String testParameter = "";
    SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    SourceGroup sourceGroup = findGroup(sourceGroups, activatedFOs);
    if (sourceGroup != null) {
        for (FileObject fo : activatedFOs) {
            String relativePath = FileUtil.getRelativePath(sourceGroup.getRootFolder(), fo);
            if (relativePath == null) {
                continue;
            }

            if (!testParameter.isEmpty()) {
                testParameter = testParameter.concat(",");
            }
            testParameter = testParameter + relativePath + "/" + Utils.RUN_SELENIUM_TESTS_REGEXP;
        }
    }
    return testParameter;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Selenium2MavenSupportImpl.java

示例8: getDataFiles

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
public List<FileObject> getDataFiles() {
    List<FileObject> files = new ArrayList<FileObject>();
    
    Sources srcs = ProjectUtils.getSources(project);
    SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    for (int i = 0; i < grps.length; i++) {
        FileObject srcRoot = grps[i].getRootFolder();
        if (srcRoot.getPath().endsWith("test/unit/src")) { // NOI18N
            addFile("test", files); // NOI18N
        } else {
            files.add(srcRoot);
        }
    }
    
    return files;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ModuleOperations.java

示例9: testJARFileIsProduced

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
public void testJARFileIsProduced() throws Exception {
    AntArtifact[] arts = AntArtifactQuery.findArtifactsByType(loadersProject, JavaProjectConstants.ARTIFACT_TYPE_JAR);
    assertEquals("one artifact produced", 1, arts.length);
    assertEquals("correct project", loadersProject, arts[0].getProject());
    assertEquals("correct type", JavaProjectConstants.ARTIFACT_TYPE_JAR, arts[0].getType());
    assertEquals("correct ID", "module", arts[0].getID());
    assertEquals("correct location",
        Collections.singletonList(URI.create("../nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar")),
        Arrays.asList(arts[0].getArtifactLocations()));
    assertEquals("correct script", nbRoot().getFileObject("openide.loaders/build.xml"), arts[0].getScriptFile());
    assertEquals("correct build target", "netbeans", arts[0].getTargetName());
    assertEquals("correct clean target", "clean", arts[0].getCleanTargetName());
    assertEquals("no properties", new Properties(), arts[0].getProperties());
    arts = AntArtifactQuery.findArtifactsByType(javaProjectProject, JavaProjectConstants.ARTIFACT_TYPE_JAR);
    assertEquals("one artifact produced", 1, arts.length);
    assertEquals("correct location",
        Collections.singletonList(URI.create("../nbbuild/netbeans/" + TestBase.CLUSTER_JAVA + "/modules/org-netbeans-modules-java-project.jar")),
        Arrays.asList(arts[0].getArtifactLocations()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AntArtifactProviderImplTest.java

示例10: getClassChooserPanel

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
/**
 * Returns a panel for choosing name and target location of the test
 * class. If the panel already exists, returns the existing panel,
 * otherwise creates a new panel.
 *
 * @return  existing panel or a newly created panel if it did not exist
 */
private WizardDescriptor.Panel<WizardDescriptor> getClassChooserPanel() {
    final Project project = Templates.getProject(wizard);
    if (classChooserPanel == null || project != lastSelectedProject) {
        SourceGroupModifier.createSourceGroup(project, JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_HINT_TEST);
        final JUnitUtils utils = new JUnitUtils(project);
        if (utils.getSourcesToTestsMap(true).isEmpty()) {
            classChooserPanel = new StepProblemMessage(
                    project,
                    NbBundle.getMessage(EmptyTestCaseWizardIterator.class,
                                        "MSG_NoTestSourceGroup"));  //NOI18N
        } else {
            if (classChooserPanel == null) {
                classChooserPanel = new SimpleTestStepLocation();
            }
            ((SimpleTestStepLocation) classChooserPanel).setUp(utils);
        }
    }
    lastSelectedProject = project;
    return classChooserPanel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:SimpleTestCaseWizardIterator.java

示例11: testIncludesExcludes

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
public void testIncludesExcludes() throws Exception {
    SourceGroup g = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)[0];
    assertEquals(sources, g.getRootFolder());
    FileObject objectJava = FileUtil.createData(sources, "java/lang/Object.java");
    FileObject jcJava = FileUtil.createData(sources, "javax/swing/JComponent.java");
    FileObject doc = FileUtil.createData(sources, "javax/swing/doc-files/index.html");
    assertTrue(g.contains(objectJava));
    assertTrue(g.contains(jcJava));
    assertTrue(g.contains(doc));
    Method projectOpened = ProjectOpenedHook.class.getDeclaredMethod("projectOpened");
    projectOpened.setAccessible(true);
    projectOpened.invoke(project.getLookup().lookup(ProjectOpenedHook.class));
    EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    assertEquals("includes/excludes were initialized to defaults", "**", ep.getProperty(ProjectProperties.INCLUDES));
    assertEquals("includes/excludes were initialized to defaults", "", ep.getProperty(ProjectProperties.EXCLUDES));
    ep.setProperty(ProjectProperties.INCLUDES, "javax/swing/");
    ep.setProperty(ProjectProperties.EXCLUDES, "**/doc-files/");
    helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
    pm.saveProject(project);
    assertFalse(g.contains(objectJava));
    assertTrue(g.contains(jcJava));
    assertFalse(g.contains(doc));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:J2SESourcesTest.java

示例12: findProjectImportedModules

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
/**
 * Returns set of modules imported by the project. Adds to the passed collection
 * if not null. Module names from `required' clause will be returned
 * 
 * @param project the project
 * @param in optional; the collection
 * @return original collection or a new one with imported modules added
 */
public static Collection<String> findProjectImportedModules(Project project, Collection<String> in) {
    Collection<String> result = in != null ? in : new HashSet<>();
    if (project == null) {
        return result;
    }
    
    for (SourceGroup sg : org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        if (isNormalRoot(sg)) {
            ClasspathInfo cpi = ClasspathInfo.create(sg.getRootFolder());
            ClassPath mcp = cpi.getClassPath(PathKind.COMPILE);
            
            for (FileObject r : mcp.getRoots()) {
                URL u = URLMapper.findURL(r, URLMapper.INTERNAL);
                String modName = SourceUtils.getModuleName(u);
                if (modName != null) {
                    result.add(modName);
                }
            }
        }
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ShellProjectUtils.java

示例13: isOnSourceClasspath

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
public static boolean isOnSourceClasspath(FileObject fo) {
    Project p = FileOwnerQuery.getOwner(fo);
    if (p==null) return false;
    Project[] opened = OpenProjects.getDefault().getOpenProjects();
    for (int i = 0; i<opened.length; i++) {
        if (p.equals(opened[i]) || opened[i].equals(p)) {
            SourceGroup[] gr = ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            for (int j = 0; j < gr.length; j++) {
                if (fo==gr[j].getRootFolder()) return true;
                if (FileUtil.isParentOf(gr[j].getRootFolder(), fo))
                    return true;
            }
            return false;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RetoucheUtils.java

示例14: getClasspathInfo

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
public ClasspathInfo getClasspathInfo() {
    if (cpi != null) {
        return cpi;
    }
    FileObject fileObject = project.getProjectDirectory();
    SourceGroup[] grp = org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    List<FileObject> roots = new ArrayList<>(grp.length);
    for (SourceGroup sg : grp) {
        roots.add(sg.getRootFolder());
    }
    return cpi = ClasspathInfo.create(
            ClassPath.getClassPath(fileObject, ClassPath.BOOT), // JDK classes
            ClassPath.EMPTY,
            ClassPathSupport.createClassPath(roots.toArray(new FileObject[roots.size()]))
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JShellOptions2.java

示例15: areSourceRootsOwned

import org.netbeans.api.java.project.JavaProjectConstants; //导入依赖的package包/类
/**
 * Checks whether any of Eclipse source roots is already owned by a project.
 * If it is then abort import and tell user to open that project instead.
 * Internal source roots beneath the project directory do not pose this problem, as
 * {@link FileOwnerQuery} should consider the new project to be the default owner of anything
 * underneath it.
 * @param model a model of the project being considered for import
 * @param nbProjectDir the proposed directory to use as the NetBeans {@linkplain Project#getProjectDirectory project directory}
 * @param importProblems problems to append to in case this returns true
 * @return true if the import would be blocked by ownership issues; false normally
 */
public static boolean areSourceRootsOwned(ProjectImportModel model, File nbProjectDir, List<String> importProblems) {
    for (File sourceRootFile : model.getEclipseSourceRootsAsFileArray()) {
        if (sourceRootFile.getAbsolutePath().startsWith(nbProjectDir.getAbsolutePath())) {
            continue;
        }
        FileObject fo = FileUtil.toFileObject(sourceRootFile);
        if (fo == null) { // #148256
            continue;
        }
        Project p = FileOwnerQuery.getOwner(fo);
        if (p != null) {
            for (SourceGroup sg : ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
                if (fo.equals(sg.getRootFolder())) {
                    importProblems.add(NbBundle.getMessage(EclipseProject.class, "MSG_SourceRootOwned", // NOI18N
                            model.getProjectName(), sourceRootFile.getPath(),
                            FileUtil.getFileDisplayName(p.getProjectDirectory())));
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:ProjectFactorySupport.java


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