本文整理汇总了Java中org.netbeans.spi.project.SubprojectProvider类的典型用法代码示例。如果您正苦于以下问题:Java SubprojectProvider类的具体用法?Java SubprojectProvider怎么用?Java SubprojectProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubprojectProvider类属于org.netbeans.spi.project包,在下文中一共展示了SubprojectProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testChangeListener
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testChangeListener() throws Exception {
SuiteProject s = generateSuite("suite");
SubprojectProvider spp = s.getLookup().lookup(SubprojectProvider.class);
SPPChangeListener l = new SPPChangeListener();
spp.addChangeListener(l);
NbModuleProject module1 = generateSuiteComponent(s, "module1");
assertTrue("change was noticed", l.changed);
assertEquals("suite has one submodule", 1, spp.getSubprojects().size());
l.changed = false;
SuiteUtils.removeModuleFromSuite(module1);
assertTrue("change was noticed", l.changed);
l.changed = false;
assertEquals("suite doesn't have any submodules", 0, spp.getSubprojects().size());
spp.removeChangeListener(l);
generateSuiteComponent(s, "module2");
assertFalse("change was noticed", l.changed);
assertEquals("suite has one submodule", 1, spp.getSubprojects().size());
}
示例2: testAddModule
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testAddModule() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
NbModuleProject module1 = generateStandaloneModule("module1");
SuiteProvider suiteProvider = module1.getLookup().lookup(SuiteProvider.class);
assertNull("module1 is standalone module - doesn't have valid SuiteProvider", suiteProvider);
SuiteUtils.addModule(suite1, module1);
SubprojectProvider spp = SuitePropertiesTest.getSubProjectProvider(suite1);
assertEquals("one module suite component", 1, spp.getSubprojects().size());
suiteProvider = module1.getLookup().lookup(SuiteProvider.class);
assertNotNull("module1 became suite component - has valid SuiteProvider", suiteProvider.getSuiteDirectory());
NbModuleProject module2 = generateStandaloneModule("module2");
NbModuleProject module3 = generateStandaloneModule("module3");
SuiteUtils.addModule(suite1, module2);
SuiteUtils.addModule(suite1, module3);
assertEquals("three module suite components", 3, spp.getSubprojects().size());
}
示例3: testRemoveModuleFromSuiteWithDependencies
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testRemoveModuleFromSuiteWithDependencies() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
NbModuleProject module1 = TestBase.generateSuiteComponent(suite1, "module1");
NbModuleProject module2 = TestBase.generateSuiteComponent(suite1, "module2");
SubprojectProvider spp = SuitePropertiesTest.getSubProjectProvider(suite1);
assertEquals("two suite components", 2, spp.getSubprojects().size());
ApisupportAntUtils.addDependency(module2, module1.getCodeNameBase(), null, null, true, null);
ProjectManager.getDefault().saveProject(module2);
ProjectXMLManager pxm2 = new ProjectXMLManager(module2);
assertEquals("one dependency", 1, pxm2.getDirectDependencies().size());
SuiteUtils.removeModuleFromSuiteWithDependencies(module1);
spp = SuitePropertiesTest.getSubProjectProvider(suite1);
assertEquals("one suite component", 1, spp.getSubprojects().size());
SuiteProvider suiteProvider = module1.getLookup().lookup(SuiteProvider.class);
assertNull("module1 became standalone module - doesn't have a SuiteProvider", suiteProvider);
pxm2 = new ProjectXMLManager(module2);
assertEquals("dependency was removed", 0, pxm2.getDirectDependencies().size());
}
示例4: testAddTwoModulesWithTheSameCNB_62819
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testAddTwoModulesWithTheSameCNB_62819() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
NbModuleProject module1a = generateStandaloneModule("module1");
File otherDir = new File(getWorkDir(), "otherDir");
otherDir.mkdir();
NbModuleProject module1b = TestBase.generateStandaloneModule(otherDir, "module1");
SuiteUtils.addModule(suite1, module1a);
SuiteUtils.addModule(suite1, module1b);
SubprojectProvider spp = SuitePropertiesTest.getSubProjectProvider(suite1);
assertEquals("cannot add two suite components with the same cnb", 1, spp.getSubprojects().size());
SuiteProvider suiteProvider = module1a.getLookup().lookup(SuiteProvider.class);
assertNotNull("module1a became suite component - has valid SuiteProvider", suiteProvider.getSuiteDirectory());
suiteProvider = module1b.getLookup().lookup(SuiteProvider.class);
assertNull("module1b remains standalone - has no SuiteProvider", suiteProvider);
}
示例5: testGeneratingOfUniqAntProperty_62819
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testGeneratingOfUniqAntProperty_62819() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
NbModuleProject module1 = generateStandaloneModule("module1");
NbModuleProject module2 = generateStandaloneModule("module2");
SuiteUtils.addModule(suite1, module1);
FileObject propsFO = suite1.getProjectDirectory().getFileObject("nbproject/project.properties");
EditableProperties props = Util.loadProperties(propsFO);
assertEquals("modules property", "${project.org.example.module1}", props.getProperty("modules"));
assertEquals("module1 property", "../module1", props.getProperty("project.org.example.module1"));
// user is free to do this, although in more sensible way
assertEquals("module1 project removed (sanity check)", "../module1", props.remove("project.org.example.module1"));
props.setProperty("modules", "${project.org.example.module2}");
props.setProperty("project.org.example.module2", "../module1");
Util.storeProperties(propsFO, props);
SuiteUtils.addModule(suite1, module2);
SubprojectProvider spp = SuitePropertiesTest.getSubProjectProvider(suite1);
assertEquals("one module suite component", 2, spp.getSubprojects().size());
SuiteProvider suiteProvider = module1.getLookup().lookup(SuiteProvider.class);
assertNotNull("module1 became suite component - has valid SuiteProvider", suiteProvider.getSuiteDirectory());
suiteProvider = module2.getLookup().lookup(SuiteProvider.class);
assertNotNull("module2 became suite component - has valid SuiteProvider", suiteProvider.getSuiteDirectory());
}
示例6: testRemoveAllSubModules
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testRemoveAllSubModules() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
TestBase.generateSuiteComponent(suite1, "module1a");
TestBase.generateSuiteComponent(suite1, "module1b");
SuiteProperties suite1Props = getSuiteProperties(suite1);
SuiteSubModulesListModel model = suite1Props.getModulesListModel();
assertNotNull(model);
// simulate removing all items from the list
JList moduleList = new JList(model);
moduleList.setSelectedIndices(new int[] {0, model.getSize() - 1});
model.removeModules(Arrays.asList(moduleList.getSelectedValues()));
assertEquals("no subModule should be left", 0, model.getSize());
saveProperties(suite1Props);
SubprojectProvider spp = getSubProjectProvider(suite1);
assertEquals("no module should be left", 0, spp.getSubprojects().size());
}
示例7: testAddModule
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testAddModule() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
TestBase.generateSuiteComponent(suite1, "module1");
SubprojectProvider spp = getSubProjectProvider(suite1);
SuiteProperties suiteProps = getSuiteProperties(suite1);
SuiteSubModulesListModel model = suiteProps.getModulesListModel();
assertEquals("one module suite component", 1, model.getSize());
NbModuleProject module2ToAdd = generateStandaloneModule("module2");
NbModuleProject module3ToAdd = generateStandaloneModule("module3");
assertNull(module2ToAdd.getLookup().lookup(SuiteProvider.class));
model.addModule(module2ToAdd);
model.addModule(module3ToAdd);
saveProperties(suiteProps);
SuiteProvider suiteProvider = module2ToAdd.getLookup().lookup(SuiteProvider.class);
assertNotNull(suiteProvider);
assertNotNull(suiteProvider.getSuiteDirectory());
suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
assertNotNull(suiteProvider.getSuiteDirectory());
assertEquals("three module suite components", 3, suiteProps.getModulesListModel().getSize());
}
示例8: testRemoveOneSubModule
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testRemoveOneSubModule() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
NbModuleProject module1a = TestBase.generateSuiteComponent(suite1, "module1a");
TestBase.generateSuiteComponent(suite1, "module1b");
SuiteProperties suite1Props = getSuiteProperties(suite1);
SuiteSubModulesListModel model = suite1Props.getModulesListModel();
assertNotNull(model);
// simulate removing first item from the list
JList moduleList = new JList(model);
moduleList.setSelectedIndex(0);
model.removeModules(Arrays.asList(moduleList.getSelectedValues()));
assertEquals("one subModule should left", 1, model.getSize());
saveProperties(suite1Props);
SubprojectProvider spp = getSubProjectProvider(suite1);
assertEquals("one module should be left", 1, spp.getSubprojects().size());
NbModuleProject project = (NbModuleProject) spp.getSubprojects().toArray()[0];
assertEquals("module1b should be the one", "org.example.module1b", project.getCodeNameBase());
assertSame("module1b module is still suite component module", NbModuleType.SUITE_COMPONENT, project.getModuleType());
// assert that the remove module (module1a) is standalone
assertSame("module1a module is standalone module now", NbModuleType.STANDALONE, module1a.getModuleType());
}
示例9: testRemovingSecondModuleFromThree_63307
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testRemovingSecondModuleFromThree_63307() throws Exception {
SuiteProject suite1 = generateSuite("suite1");
TestBase.generateSuiteComponent(suite1, "module1");
NbModuleProject module2 = TestBase.generateSuiteComponent(suite1, "module2");
TestBase.generateSuiteComponent(suite1, "module3");
SubprojectProvider spp = getSubProjectProvider(suite1);
SuiteProperties suiteProps = getSuiteProperties(suite1);
SuiteSubModulesListModel model = suiteProps.getModulesListModel();
assertEquals("three module suite components", 3, model.getSize());
model.removeModules(Arrays.asList(new Object[] { module2 }));
saveProperties(suiteProps);
suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
assertEquals("two module suite components", 2, suiteProps.getModulesListModel().getSize());
}
示例10: 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;
}
示例11: 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);
}
}
}
}
}
示例12: enable
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
@Override protected boolean enable(Node[] activatedNodes) {
if ( activatedNodes == null || activatedNodes.length == 0 ) {
return false; // No nodes no closing
}
// Find out whether openAllProjectsItem nodes have project in lookup
boolean someSubprojects = false; // And have some subprojects;
for( int i = 0; i < activatedNodes.length; i++ ) {
Project p = activatedNodes[i].getLookup().lookup(Project.class);
if ( p == null ) {
return false;
}
else {
SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
if ( spp != null //#97534 be satisfied with presence of the provider in lookup - && !spp.getSubprojects().isEmpty()
) {
someSubprojects = true;
}
}
}
return someSubprojects;
}
示例13: 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;
}
}
示例14: 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);
}
}
}
}
}
示例15: testProjectModules
import org.netbeans.spi.project.SubprojectProvider; //导入依赖的package包/类
public void testProjectModules() throws Exception {
TestFileUtils.writeFile(d, "pom.xml",
"<project xmlns='http://maven.apache.org/POM/4.0.0'>" +
"<modelVersion>4.0.0</modelVersion>" +
"<groupId>grp</groupId>" +
"<artifactId>p1</artifactId>" +
"<version>0</version>" +
"<packaging>pom</packaging>" +
"<modules>" +
"<module>sub</module>" +
"</modules>" +
"</project>");
TestFileUtils.writeFile(d, "sub/pom.xml",
"<project xmlns='http://maven.apache.org/POM/4.0.0'>" +
"<modelVersion>4.0.0</modelVersion>" +
"<groupId>grp</groupId>" +
"<artifactId>p2</artifactId>" +
"<version>0</version>" +
"</project>");
Project p1 = ProjectManager.getDefault().findProject(d);
Project p2 = ProjectManager.getDefault().findProject(d.getFileObject("sub"));
assertEquals(Collections.singleton(p2), p1.getLookup().lookup(SubprojectProvider.class).getSubprojects());
}