本文整理汇总了Java中org.netbeans.spi.project.SubprojectProvider.getSubprojects方法的典型用法代码示例。如果您正苦于以下问题:Java SubprojectProvider.getSubprojects方法的具体用法?Java SubprojectProvider.getSubprojects怎么用?Java SubprojectProvider.getSubprojects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.spi.project.SubprojectProvider
的用法示例。
在下文中一共展示了SubprojectProvider.getSubprojects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCP
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private ClassPath createCP(Project prj, HashSet<Project> parents) {
parents.add(prj);
List<ClassPath> list = new ArrayList<ClassPath>();
ProjectSourcesClassPathProvider cpp = prj.getLookup().lookup(ProjectSourcesClassPathProvider.class);
ClassPath[] cp = cpp.getProjectClassPaths(ClassPath.EXECUTE);
list.addAll(Arrays.asList(cp));
//for pom packaging projects subprojects/modules matter
//TODO for application project it's DependencyProjectProvider, for pom project (run-ide?) it's containerprojectprovider
SubprojectProvider spp = prj.getLookup().lookup(SubprojectProvider.class);
if (spp != null) {
for (Project sub : spp.getSubprojects()) {
if (parents.contains(sub)) {
continue;
}
ClassPath c = createCP(sub, parents);
if (c != null) {
list.add(c);
}
}
}
if (list.size() > 0) {
return ClassPathSupport.createProxyClassPath(list.toArray(new ClassPath[list.size()]));
}
return null;
}
示例2: visitSubprojects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private static void visitSubprojects(Project p, Set<Project> projects, boolean main, ProgressHandle h, int[] startEnd) {
if ((main || !ProjectConvertors.isConvertorProject(p)) && projects.add(p)) {
if (h != null) {
h.progress(progressMessage(p), Math.min(++startEnd[0], startEnd[1]));
}
ProjectContainerProvider pcp = p.getLookup().lookup(ProjectContainerProvider.class);
if (pcp != null) {
ProjectContainerProvider.Result res = pcp.getContainedProjects();
projects.addAll(res.getProjects());
if (!res.isRecursive()) {
visitSubprojects(p, projects, false, h, startEnd);
}
} else {
//fallback to semi-deprecated subprojectprovider
SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
if (spp != null) {
for (Project p2 : spp.getSubprojects()) {
visitSubprojects(p2, projects, false, h, startEnd);
}
}
}
}
}
示例3: getSubProjects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private void getSubProjects() {
try {
if(activatedNodes != null) {
for( int i = 0; i < activatedNodes.length; i++ ) {
Project p = activatedNodes[i].getLookup().lookup(Project.class);
if ( p != null ) {
ProjectContainerProvider pcp = p.getLookup().lookup(ProjectContainerProvider.class);
if (pcp != null) {
subProjects = pcp.getContainedProjects().getProjects();
} else {
SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
if(spp != null) {
subProjects = spp.getSubprojects();
}
}
}
}
}
} finally {
initialized = true;
}
}
示例4: getSourceRoots
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private static void getSourceRoots(final Project project, final boolean traverse, Set<Project> projects, Set<FileObject> roots) {
final Sources sources = ProjectUtils.getSources(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, 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);
}
}
}
}
}
示例5: updateWithDependencies
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private void updateWithDependencies(Node[] nodes) {
Set<Project> projectsToUpdate = new HashSet<Project>(nodes.length * 2);
for (Node node : nodes) {
if (!SvnUtils.isVersionedProject(node, true)) {
continue;
}
Project project = (Project) node.getLookup().lookup(Project.class);
projectsToUpdate.add(project);
//mkleint: see subprojectprovider for official contract, see #210465
// do we care if all or just the direct subprojects are included?
SubprojectProvider deps = (SubprojectProvider) project.getLookup().lookup(SubprojectProvider.class);
if(deps != null) {
Set<? extends Project> children = deps.getSubprojects();
for (Project child : children) {
if (SvnUtils.isVersionedProject(child, true)) {
projectsToUpdate.add(child);
}
}
}
}
Context context = SvnUtils.getProjectsContext(projectsToUpdate.toArray(new Project[projectsToUpdate.size()]));
UpdateAction.performUpdate(context, getContextDisplayName(nodes));
}
示例6: addSubprojects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
/**
* Gets all subprojects recursively
* @param p project to scan
* @param result all subprojects
* @param cache temporary cache of projects
*/
public static void addSubprojects(Project p, Set<Project> result, Map<Project, Set<? extends Project>> cache) {
// original in ProjectUI API
Set<? extends Project> subprojects = cache.get(p);
if (subprojects == null) {
// p's subprojects have not yet been searched
SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
if (spp != null) {
subprojects = spp.getSubprojects();
} else {
subprojects = Collections.emptySet();
}
cache.put(p, subprojects);
for (Project sp : subprojects) {
result.add(sp);
addSubprojects(sp, result, cache);
}
}
}
示例7: testSubprojectProviderImpl
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
/**
* Check that the {@link SubprojectProvider} implementation behaves correctly.
* @throws Exception in case of unexpected failures
*/
public void testSubprojectProviderImpl() throws Exception {
AntArtifact art = sisterh.createSimpleAntArtifact("jar", "build.jar", sisterh.getStandardPropertyEvaluator(), "dojar", "clean");
assertNotNull("added a ref to proj2.dojar", r.addReference(art, art.getArtifactLocations()[0]));
art = sisterh.createSimpleAntArtifact("javadoc", "build.javadoc", sisterh.getStandardPropertyEvaluator(), "dojavadoc", "clean");
assertNotNull("added a ref to proj2.dojavadoc", r.addReference(art, art.getArtifactLocations()[0]));
art = seph.createSimpleAntArtifact("jar", "build.jar", seph.getStandardPropertyEvaluator(), "dojar", "clean");
assertNotNull("added a ref to proj3.dojar", r.addReference(art, art.getArtifactLocations()[0]));
SubprojectProvider sp = r.createSubprojectProvider();
Set<? extends Project> subprojs = sp.getSubprojects();
assertEquals("two subprojects", 2, subprojs.size());
Project[] subprojsA = subprojs.toArray(new Project[2]);
Project proj2, proj3;
if (ProjectUtils.getInformation(subprojsA[0]).getName().equals("proj2")) {
proj2 = subprojsA[0];
proj3 = subprojsA[1];
} else {
proj2 = subprojsA[1];
proj3 = subprojsA[0];
}
assertEquals("proj2 was found correctly", pm.findProject(sisterprojdir), proj2);
assertEquals("proj3 was found correctly", pm.findProject(sepprojdir), proj3);
}
示例8: isSubProjectOf
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private static boolean isSubProjectOf(Project p, Project op,
Map<Project, Set<? extends Project>> subProjects, // cache of sub-projects
Set<Project> allSubProjects) { // all inspected sub-projects
Set<? extends Project> sps = subProjects.get(op);
if (sps == null) {
//mkleint: see subprojectprovider for official contract, see #210465
SubprojectProvider spp = op.getLookup().lookup(SubprojectProvider.class);
if (spp == null) {
return false;
}
sps = spp.getSubprojects();
subProjects.put(op, sps);
}
for (Project sp : sps) {
if (allSubProjects.contains(sp)) {
continue;
}
allSubProjects.add(sp);
if (p.equals(sp) || isSubProjectOf(p, sp, subProjects, allSubProjects)) {
return true;
}
}
return false;
}
示例9: getSourceRoots
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的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);
}
}
}
}
}
}
示例10: getSrcDir
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
/** Get source dir with tests.
* @return null if source dir was not located
*/
public URL getSrcDir() throws IOException {
String nborgPath = getNetBeansOrgPath();
if (nborgPath != null) {
return Utilities.toURI(new File(getNBRoot(),nborgPath)).toURL();
}
File prjDir = getTestDistRoot();
if (prjDir == null)
return null;
// find parent when dir was not created
while(!prjDir.exists()) {
prjDir = prjDir.getParentFile();
if (prjDir == null) {
// parent doesn't exist
return null;
}
}
Project prj = FileOwnerQuery.getOwner(FileUtil.toFileObject(prjDir));
if (prj != null && prj.getLookup().lookup(SuiteProject.class) != null) {
SubprojectProvider subprojects = prj.getLookup().lookup(SubprojectProvider.class);
if (subprojects != null) {
for (Project p : subprojects.getSubprojects()) {
if (p instanceof NbModuleProject) {
NbModuleProject nbm = (NbModuleProject) p;
if (nbm != null && nbm.getCodeNameBase().equals(getCodeNameBase())) {
FileObject file = nbm.getTestSourceDirectory(testType);
if (file != null) {
return file.toURL();
}
}
}
}
}
}
return null;
}
示例11: checkSubprojects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
private void checkSubprojects(Project project, String... subprojectNames) throws Exception {
SubprojectProvider spp = project.getLookup().lookup(SubprojectProvider.class);
assertNotNull("have SPP in " + project, spp);
SortedSet<String> actual = new TreeSet<String>();
for (Project sp : spp.getSubprojects()) {
actual.add(ProjectUtils.getInformation(sp).getName());
}
assertEquals("correct subprojects for " + project, new TreeSet<String>(Arrays.asList(subprojectNames)).toString(), actual.toString());
}
示例12: getSubProjects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
/**
* Returns direct subprojects
* @param p parent project
* @return collection of direct subprojects
*/
public static Set<? extends Project> getSubProjects (Project p) {
Set<? extends Project> subprojects = null;
SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
if (spp != null) {
subprojects = spp.getSubprojects();
} else {
subprojects = Collections.emptySet();
}
return subprojects;
}
示例13: fetchSubprojects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
public static void fetchSubprojects(final Project project, final Set<Project> projects) {
// process possible subprojects
//mkleint: see subprojectprovider for official contract, see #210465
SubprojectProvider spp = project.getLookup().lookup(SubprojectProvider.class);
if (spp != null) {
for (Project p : spp.getSubprojects()) {
if (projects.add(p)) {
fetchSubprojects(p, projects);
}
}
}
}
示例14: processSubprojects
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
public void processSubprojects(Project project) throws IOException {
SubprojectProvider subs = project.getLookup().lookup(SubprojectProvider.class);
if (subs != null) {
Set<? extends Project> subProjects = subs.getSubprojects();
for (Project p : subProjects) {
processProject(p);
}
}
}
示例15: deleteProject
import org.netbeans.spi.project.SubprojectProvider; //导入方法依赖的package包/类
static void deleteProject(final SuiteProject project, UserInputHandler handler) {
String displayName = getDisplayName(project);
FileObject projectFolder = project.getProjectDirectory();
LOG.log(Level.FINE, "delete started: {0}", displayName);
final List<FileObject> metadataFiles = ProjectOperations.getMetadataFiles(project);
final List<FileObject> dataFiles = ProjectOperations.getDataFiles(project);
final List<FileObject> allFiles = new ArrayList<FileObject>();
allFiles.addAll(metadataFiles);
allFiles.addAll(dataFiles);
for (Iterator<FileObject> i = allFiles.iterator(); i.hasNext(); ) {
FileObject f = i.next();
if (!FileUtil.isParentOf(projectFolder, f)) {
if (projectFolder.equals(f)) {
// sources == project directory
continue;
}
i.remove();
}
}
final SubprojectProvider suiteProvider = project.getLookup().lookup(SubprojectProvider.class);
final Set<Project> subProjects = (Set<Project>) suiteProvider.getSubprojects();
final Set<NbModuleProject> subModules = new HashSet<NbModuleProject>();
for(Project prjIter:subProjects) {
NbModuleProject nbModulePrj = prjIter.getLookup().lookup(NbModuleProject.class);
if(nbModulePrj != null) {
subModules.add(nbModulePrj);
}
}
final Map<NbModuleProject,List<FileObject>> subModulesDataFiles = getSubModulesDataFiles(subModules);
final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(DefaultSuiteProjectOperationsImplementation.class, "LBL_Delete_Project_Caption"));
final DefaultSuiteProjectDeletePanel deletePanel = new DefaultSuiteProjectDeletePanel(handle, displayName, FileUtil.getFileDisplayName(projectFolder), !subModulesDataFiles.isEmpty(), !subModules.isEmpty());
String caption = NbBundle.getMessage(DefaultSuiteProjectOperationsImplementation.class, "LBL_Delete_Project_Caption");
handler.showConfirmationDialog(deletePanel, project, caption, "Yes_Button", "No_Button", true, new Executor() { // NOI18N
public @Override void execute() throws Exception {
deletePanel.addProgressBar();
close(project);
Map<NbModuleProject,List<FileObject>> subModulesAllFiles = null;
Map<NbModuleProject,List<FileObject>> subModulesMetadataFiles = null;
if(deletePanel.isDeleteModules()) {
for(NbModuleProject modulePrjIter:subModules) {
close(modulePrjIter);
}
subModulesAllFiles = new HashMap<NbModuleProject, List<FileObject>>();
subModulesAllFiles.putAll(subModulesDataFiles);
subModulesMetadataFiles = getSubModulesMetadataFiles(subModules, subModulesAllFiles);
}
if (deletePanel.isDeleteSources()) {
performDelete(project, allFiles, subModulesAllFiles, handle);
} else {
performDelete(project, metadataFiles, subModulesMetadataFiles, handle);
}
deletePanel.removeProgressBar();
}
});
LOG.log(Level.FINE, "delete done: {0}", displayName);
}