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


Java Sources.getSourceGroups方法代码示例

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


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

示例1: initCombos

import org.netbeans.api.project.Sources; //导入方法依赖的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

示例2: getClasspath

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
@Override
public List<URL> getClasspath() {
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sgs = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    List<URL> list = new ArrayList<URL>();
    for (SourceGroup sg : sgs) {
        try {
            ClassPath cp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE);
            if (cp != null) {
                for (FileObject fob : cp.getRoots()) {
                    URL[] urls = UnitTestForSourceQuery.findSources(fob);
                    if (urls.length == 0) {
                        BinaryForSourceQuery.Result result = BinaryForSourceQuery.findBinaryRoots(fob.getURL());
                        list.addAll(Arrays.asList(result.getRoots()));
                    }
                }
            }
        } catch (FileStateInvalidException fsiex) {
            FormUtils.LOGGER.log(Level.INFO, fsiex.getMessage(), fsiex);
        }
    }
    return list;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ClassSourceResolver.java

示例3: enable

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
protected boolean enable(Node[] node) {
    if (node.length == 0) {
        return false;
    }
    DataObject dobj = (DataObject) node[0].getLookup().lookup(DataObject.class);
    if (dobj == null) {
        return false;
    }
    FileObject fo = dobj.getPrimaryFile();
    Project project = FileOwnerQuery.getOwner(fo);
    if(project == null)
        return false;
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] srcGrps = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (srcGrps == null || srcGrps.length == 0) {
        return false;
    } else {
        return true;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:GenerateDOMScannerAction.java

示例4: getRootFilesForProjectNodes

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
private Set<VCSFileProxy> getRootFilesForProjectNodes (Node[] nodes) {
    Set<VCSFileProxy> rootFiles = new HashSet<VCSFileProxy>(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
        Node node = nodes[i];
        Project project =  node.getLookup().lookup(Project.class);
        if (project != null) {
            Sources sources = ProjectUtils.getSources(project);
            SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
            for (int j = 0; j < sourceGroups.length; j++) {
                SourceGroup sourceGroup = sourceGroups[j];
                FileObject srcRootFo = sourceGroup.getRootFolder();
                VCSFileProxy rootFile = VCSFileProxy.createFileProxy(srcRootFo);
                if (rootFile == null) {
                    continue;
                }
                rootFiles.add(rootFile);
            }
            continue;
        }
    }
    return rootFiles;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ProjectMenuItem.java

示例5: findFile

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
private static @CheckForNull FileObject findFile(FileObject manifest, String path) {
    Project prj = FileOwnerQuery.getOwner(manifest);
    if (prj == null) {
        return null;
    }
    Sources srcs = ProjectUtils.getSources(prj);
    SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (grps.length == 0)   // #143157: there needn't to be source group (yet)
        return null;
    ClassPath cp = ClassPath.getClassPath(grps[0].getRootFolder(), ClassPath.SOURCE);
    if (cp == null) {
        return null;
    }
    path = path.trim();
    return cp.findResource(path);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ManifestHyperlinkProvider.java

示例6: createDefaultProjectSearchInfo

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
/**
 * Create default search info for a project.
 */
static SearchInfo createDefaultProjectSearchInfo(Project project) {
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(
            Sources.TYPE_GENERIC);

    FileObject base = project.getProjectDirectory();
    List<FileObject> roots = new ArrayList<FileObject>();
    if (base != null) {
        roots.add(base);
    }
    for (SourceGroup sg : sourceGroups) {
        FileObject dir = sg.getRootFolder();
        if (dir != null && (base == null || !isUnderBase(base, dir))) {
            roots.add(dir);
        }
    }
    FileObject[] rootArray = new FileObject[roots.size()];
    for (int i = 0; i < roots.size(); i++) {
        rootArray[i] = roots.get(i);
    }
    SubTreeSearchOptions stso =
            project.getLookup().lookup(SubTreeSearchOptions.class);
    if (stso == null) {
        return SearchInfoUtils.createSearchInfoForRoots(rootArray);
    } else {
        return SearchInfoUtils.createSearchInfoForRoots(rootArray, false,
                SearchInfoHelper.subTreeFilters(stso));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:AbstractProjectSearchScope.java

示例7: checkValidity

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
private void checkValidity() {
    Object sel = comProject.getModel().getSelectedItem();
    if (sel == EMPTY) {
        setError(getMessage("MSG_NoProjectSelected"));
        return;
    }
    Sources srcs = ProjectUtils.getSources((Project) sel); // #63247: don't use lookup directly
    if (srcs.getSourceGroups(Sources.TYPE_GENERIC).length > 1) {
        setError(getMessage("MSG_NoExternalRoots"));
        return;
    }
    markValid();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:SelectProjectPanel.java

示例8: getJavaSourceGroups

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
public static SourceGroup[] getJavaSourceGroups(PUDataObject dObj) throws java.io.IOException {
    Project proj = FileOwnerQuery.getOwner(dObj.getPrimaryFile());
    if (proj == null) {
        return new SourceGroup[]{};
    }
    Sources sources = ProjectUtils.getSources(proj);
    SourceGroup[] toRet = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES);
    if (toRet != null && toRet.length != 0) {
        return toRet;
    }
    return sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Util.java

示例9: isValid

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
@Override
public boolean isValid() {
    // XXX add the following checks
    // p.getName = valid NmToken
    // p.getName not already in module
    if (wizardDescriptor == null) {
        return true;
    }
    
    Sources sources=ProjectUtils.getSources(project);
    SourceGroup groups[]=sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if(groups == null || groups.length == 0) {
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE,
                NbBundle.getMessage(EntityWizardDescriptor.class,"ERR_JavaSourceGroup")); //NOI18N
        return false;
    }
    
    
    if (SourceLevelChecker.isSourceLevel14orLower(project)) {
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE,
                NbBundle.getMessage(EntityWizardDescriptor.class, "ERR_NeedProperSourceLevel")); // NOI18N
        return false;
    }
    if (p.getPrimaryKeyClassName().trim().equals("")) { //NOI18N
        wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(EntityWizardDescriptor.class,"ERR_PrimaryKeyNotEmpty")); //NOI18N
        return false;
    }
    
    wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, " "); //NOI18N
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:EntityWizardDescriptor.java

示例10: getSourceGroups

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
private SourceGroup[] getSourceGroups() {
    Sources srcs = project.getLookup().lookup(Sources.class);
    if (srcs == null) {
        throw new IllegalStateException("need Sources instance in lookup"); //NOI18N
    }
    return  srcs.getSourceGroups(test ? MavenSourcesImpl.TYPE_TEST_OTHER  
                                                       : MavenSourcesImpl.TYPE_OTHER);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:OthersRootChildren.java

示例11: findPackageName

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
private static String findPackageName(Project project, FileObject fo) {
    Sources srcs = ProjectUtils.getSources(project);
    SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    for (int i = 0; i < grps.length; i++) {
        if (FileUtil.isParentOf(grps[i].getRootFolder(), fo) && grps[i].contains(fo)) {
            return FileUtil.getRelativePath(grps[i].getRootFolder(), fo);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:NbMoveRefactoringPlugin.java

示例12: testSources

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
public void testSources() throws Exception {
    Sources s = ProjectUtils.getSources(simple);
    SourceGroup[] groups = s.getSourceGroups(Sources.TYPE_GENERIC);
    assertEquals("one generic group", 1, groups.length);
    assertEquals("right root folder", simple.getProjectDirectory(), groups[0].getRootFolder());
    assertEquals("right display name", "Simple Freeform Project", groups[0].getDisplayName());
    groups = s.getSourceGroups("java");
    assertEquals("two Java groups", 2, groups.length);
    assertEquals("right root folder #1", simple.getProjectDirectory().getFileObject("src"), groups[0].getRootFolder());
    assertEquals("right display name #1", "Main Sources", groups[0].getDisplayName());
    assertEquals("right root folder #2", simple.getProjectDirectory().getFileObject("antsrc"), groups[1].getRootFolder());
    assertEquals("right display name #2", "Ant Task Sources", groups[1].getDisplayName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:FreeformSourcesTest.java

示例13: getSourceRoot

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
private static FileObject getSourceRoot(Project prj) {
    Sources sources = ProjectUtils.getSources(prj);
    if (sources != null) {
        SourceGroup[] srcGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        if (srcGroups != null && srcGroups.length>0) {
            return srcGroups[0].getRootFolder();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProjectHelper.java

示例14: testSourceRootChanges

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
public void testSourceRootChanges() throws Exception {
    FileObject top = FileUtil.toFileObject(copyFolder(FileUtil.toFile(egdirFO.getFileObject("extsrcroot"))));
    FreeformProject extsrcroot_ = (FreeformProject) ProjectManager.getDefault().findProject(top.getFileObject("proj"));
    Sources s = ProjectUtils.getSources(extsrcroot_);
    SourceGroup[] groups = s.getSourceGroups("java");
    assertEquals("one Java group", 1, groups.length);
    assertEquals("right root folder", top.getFileObject("src"), groups[0].getRootFolder());
    TestCL l = new TestCL();
    s.addChangeListener(l);
    Element data = extsrcroot_.getPrimaryConfigurationData();
    Element folders = XMLUtil.findElement(data, "folders", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <folders>", folders);
    List<Element> sourceFolders = XMLUtil.findSubElements(folders);
    assertEquals("have 2 <source-folder>s", 2, sourceFolders.size());
    Element sourceFolder = sourceFolders.get(1);
    Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
    assertNotNull("have <location>", location);
    NodeList nl = location.getChildNodes();
    assertEquals("one child (text)", 1, nl.getLength());
    location.removeChild(nl.item(0));
    location.appendChild(location.getOwnerDocument().createTextNode("../src2"));
    extsrcroot_.putPrimaryConfigurationData(data);
    assertEquals("got a change in Sources", 1, l.changeCount());
    groups = s.getSourceGroups("java");
    assertEquals("one Java group", 1, groups.length);
    assertEquals("right root folder", top.getFileObject("src2"), groups[0].getRootFolder());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:FreeformSourcesTest.java

示例15: isValidRoot

import org.netbeans.api.project.Sources; //导入方法依赖的package包/类
public static boolean isValidRoot (File file, File[] relatedRoots, File projectFolder) {
    Project p;
    if ((p = FileOwnerQuery.getOwner(Utilities.toURI(file)))!=null
        && !file.getAbsolutePath().startsWith(projectFolder.getAbsolutePath()+File.separatorChar)) {
        final Sources sources = p.getLookup().lookup(Sources.class);
        if (sources == null) {
            return false;
        }
        final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
        final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length];
        System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length);
        System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length);
        final FileObject projectDirectory = p.getProjectDirectory();
        final FileObject fileObject = FileUtil.toFileObject(file);
        if (projectDirectory == null || fileObject == null) {
            return false;
        }
        for (int i = 0; i< groups.length; i++) {
            final FileObject sgRoot = groups[i].getRootFolder();
            if (fileObject.equals(sgRoot)) {
                return false;
            }
            if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) {
                return false;
            }
        }
        return true;
    }
    else if (contains (file, relatedRoots)) {
        return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:FolderList.java


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