本文整理汇总了Java中org.openide.nodes.Children.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Children.getNodes方法的具体用法?Java Children.getNodes怎么用?Java Children.getNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.nodes.Children
的用法示例。
在下文中一共展示了Children.getNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandAllNodes
import org.openide.nodes.Children; //导入方法依赖的package包/类
private static void expandAllNodes (BeanTreeView btv, Node node, ExplorerManager mgr, JavaPlatform platform) {
btv.expandNode (node);
Children ch = node.getChildren();
if ( ch == Children.LEAF ) {
if (platform != null && platform.equals(node.getLookup().lookup(JavaPlatform.class))) {
try {
mgr.setSelectedNodes (new Node[] {node});
} catch (PropertyVetoException e) {
//Ignore it
}
}
return;
}
Node nodes[] = ch.getNodes( true );
for ( int i = 0; i < nodes.length; i++ ) {
expandAllNodes( btv, nodes[i], mgr, platform);
}
}
示例2: representationOf
import org.openide.nodes.Children; //导入方法依赖的package包/类
private static void representationOf(Children c, StringBuilder b) {
boolean first = true;
for (Node n : c.getNodes(true)) {
if (first) {
first = false;
} else {
b.append(", ");
}
b.append(n.getDisplayName());
if (!n.isLeaf()) {
b.append('[');
representationOf(n.getChildren(), b);
b.append(']');
}
}
}
示例3: testChildrenCanGC
import org.openide.nodes.Children; //导入方法依赖的package包/类
public void testChildrenCanGC () throws Exception {
Filter filter = new Filter();
holder = filter;
String pref = getName() + '/';
FileObject bb = FileUtil.createFolder(FileUtil.getConfigRoot(), pref + "/BB");
bb.createData("Ahoj.txt");
bb.createData("Hi.txt");
DataFolder folder = DataFolder.findFolder(bb);
Children ch = folder.createNodeChildren(filter);
LOG.info("children created: " + ch);
Node[] arr = ch.getNodes(true);
LOG.info("nodes obtained" + arr);
assertEquals("Accepts only Ahoj", 1, arr.length);
LOG.info("The one node" + arr[0]);
WeakReference<Children> ref = new WeakReference<Children>(ch);
ch = null;
arr = null;
assertGC("Children can disappear even we hold the filter", ref);
}
示例4: testOrderAttributesAreReflected
import org.openide.nodes.Children; //导入方法依赖的package包/类
public void testOrderAttributesAreReflected() throws Exception {
FileObject root = FileUtil.createFolder(FileUtil.getConfigRoot(), "order");
for (int i = 0; i < 256; i++) {
FileUtil.createData(root, "file" + i + ".txt");
}
FileObject[] arr = root.getChildren();
assertEquals(256, arr.length);
for (int i = 0; i < 256; i++) {
arr[i].setAttribute("position", i ^ 0x6B);
}
DataFolder folder = DataFolder.findFolder (root);
Node n = folder.getNodeDelegate();
Children ch = n.getChildren();
Node[] nodes = ch.getNodes (true);
assertEquals(256, nodes.length);
for (int i = 0; i < 256; i++) {
FileObject fo = nodes[i].getLookup().lookup(FileObject.class);
assertNotNull(i + " Has file object: " + nodes[i], fo);
assertEquals(i + " It is the correct one: ", arr[i ^ 0x6B], fo);
}
}
示例5: expandFirstLevel
import org.openide.nodes.Children; //导入方法依赖的package包/类
private void expandFirstLevel(BeanTreeView btv) {
Node root = manager.getRootContext();
Children ch = root.getChildren();
if ( ch == Children.LEAF ) {
return;
}
Node nodes[] = ch.getNodes(true);
btv.expandNode(root);
for ( int i = 0; i < nodes.length; i++ ) {
btv.expandNode( nodes[i] );
if ( i == 0 ) {
try {
manager.setSelectedNodes( new Node[] { nodes[i] } );
}
catch ( java.beans.PropertyVetoException e ) {
// No selection for some reason
}
}
}
}
示例6: getNodeForElement
import org.openide.nodes.Children; //导入方法依赖的package包/类
public ElementNode getNodeForElement(ElementHandle<Element> eh) {
if (getDescritption().elementHandle != null
&& eh.signatureEquals(getDescritption().elementHandle)) {
return this;
}
Children ch = getChildren();
if (ch instanceof ElementChilren) {
for (Node sub : ch.getNodes()) {
ElementNode result = ((ElementNode) sub).getNodeForElement(eh);
if (result != null) {
return result;
}
}
}
return null;
}
示例7: getTemplateNode
import org.openide.nodes.Children; //导入方法依赖的package包/类
private static Node getTemplateNode(FileObject fo, FileObject rootFO) {
if (rootFO.equals(fo)) {
return getTemplateRootNode();
}
Node parent = getTemplateNode(fo.getParent(), rootFO);
if (parent == null) {
return null;
}
Children ch = parent.getChildren();
for (Node node : ch.getNodes(true)) {
if (fo.equals(node.getLookup().lookup(FileObject.class))) {
return node;
}
}
return null;
}
示例8: testChangeableDataFilterOnNodeDelegate
import org.openide.nodes.Children; //导入方法依赖的package包/类
@RandomlyFails // NB-Core-Build #1049 (in FolderChildrenLazyTest), #1051 (in this)
public void testChangeableDataFilterOnNodeDelegate() throws Exception {
String pref = getName() + "/";
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/A.txt");
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/B.txt");
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/AA.txt");
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/BA.txt");
FileObject bb = FileUtil.getConfigFile(pref + "BB");
Filter filter = new Filter();
DataFolder folder = DataFolder.findFolder (bb);
Node n = folder.getClonedNodeDelegate(filter);
Children ch = n.getChildren();
Node[] arr = ch.getNodes (true);
assertNodes( arr, new String[] { "A.txt", "AA.txt" } );
filter.fire();
arr = ch.getNodes (true);
assertNodes( arr, new String[] { "B.txt", "BA.txt" } );
}
示例9: testChangeableDataFilter
import org.openide.nodes.Children; //导入方法依赖的package包/类
@RandomlyFails // NB-Core-Build #1058 (in FolderChildrenLazyTest)
public void testChangeableDataFilter() throws Exception {
String pref = getName() + "/";
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/A.txt");
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/B.txt");
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/AA.txt");
FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/BA.txt");
FileObject bb = FileUtil.getConfigFile(pref + "/BB");
Filter filter = new Filter();
DataFolder folder = DataFolder.findFolder (bb);
Children ch = folder.createNodeChildren( filter );
Node[] arr = ch.getNodes (true);
assertNodes( arr, new String[] { "A.txt", "AA.txt" } );
filter.fire();
arr = ch.getNodes (true);
assertNodes( arr, new String[] { "B.txt", "BA.txt" } );
}
示例10: getActions
import org.openide.nodes.Children; //导入方法依赖的package包/类
/** Getter for set of actions that should be present in the
* popup menu of this node. This set is used in construction of
* menu returned from getContextMenu and specially when a menu for
* more nodes is constructed.
*
* @return array of system actions that should be in popup menu
*/
@Override
public Action[] getActions ( boolean context ) {
if ( context ) {
return super.getActions( true );
}
else {
Children ch = getChildren();
Node[] nodes = ch.getNodes();
if ( nodes == null )
return new SystemAction[0];
if( nodes.length == 0 || ( nodes[0] != null && ((BiFeatureNode)nodes[0]).getBiFeature() instanceof BiFeature.Descriptor) )
return new SystemAction[0];
return new SystemAction[] {
SystemAction.get (BiIncludeAllAction.class),
SystemAction.get (BiExcludeAllAction.class),
null
};
}
}
示例11: testViewItemChanges
import org.openide.nodes.Children; //导入方法依赖的package包/类
@RandomlyFails // NB-Core-Build #1012
public void testViewItemChanges() throws Exception {
FileObject top = FileUtil.toFileObject(copyFolder(FileUtil.toFile(egdirFO.getFileObject("extsrcroot"))));
FreeformProject extsrcroot_ = (FreeformProject) ProjectManager.getDefault().findProject(top.getFileObject("proj"));
Node root = extsrcroot_.getLookup().lookup(LogicalViewProvider.class).createLogicalView();
Children ch = root.getChildren();
Node[] kids = ch.getNodes(true);
assertEquals("two child nodes", 2, kids.length);
assertEquals("correct code name #1", "../src", kids[0].getName());
assertEquals("correct code name #2", "nbproject/project.xml", kids[1].getName());
TestNL l = new TestNL();
root.addNodeListener(l);
Element data = extsrcroot_.getPrimaryConfigurationData();
Element view = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
assertNotNull("have <view>", view);
Element items = XMLUtil.findElement(view, "items", FreeformProjectType.NS_GENERAL);
assertNotNull("have <items>", items);
Element sourceFolder = XMLUtil.findElement(items, "source-folder", FreeformProjectType.NS_GENERAL);
assertNotNull("have <source-folder>", sourceFolder);
Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
assertNotNull("have <location>", location);
NodeList nl = location.getChildNodes();
assertEquals("one child", 1, nl.getLength());
location.removeChild(nl.item(0));
location.appendChild(location.getOwnerDocument().createTextNode("../src2"));
Element sourceFile = XMLUtil.findElement(items, "source-file", FreeformProjectType.NS_GENERAL);
assertNotNull("have <source-file>", sourceFile);
items.removeChild(sourceFile);
extsrcroot_.putPrimaryConfigurationData(data);
// children keys are updated asynchronously. give them a time
Thread.sleep(500);
assertFalse("got some changes in children", l.probeChanges().isEmpty());
kids = ch.getNodes(true);
assertEquals("one child node", 1, kids.length);
assertEquals("correct code name #1", "../src2", kids[0].getName());
assertEquals("correct display name #1", "External Sources", kids[0].getDisplayName());
assertEquals("correct cookie #1",
DataObject.find(top.getFileObject("src2")),
kids[0].getLookup().lookup(DataObject.class));
}
示例12: findNodeFor
import org.openide.nodes.Children; //导入方法依赖的package包/类
ComponentNode findNodeFor(ComponentInfo ci) {
if (ci.equals(this.ci)) {
return this;
}
Children ch = getChildren();
Node[] subNodes = ch.getNodes();
for (Node n : subNodes) {
ComponentNode cn = (ComponentNode) n;
ComponentNode node = cn.findNodeFor(ci);
if (node != null) {
return node;
}
}
return null;
}
示例13: checkNoLazyNode
import org.openide.nodes.Children; //导入方法依赖的package包/类
static void checkNoLazyNode(Children children) {
for (Node n : children.getNodes()) {
if (n instanceof BadgingNode) {
((BadgingNode)n).replaceProject(null);
}
if (n.getLookup().lookup(LazyProject.class) != null) {
OpenProjectList.LOGGER.warning("LazyProjects remain visible");
}
}
}
示例14: testViewItemBasic
import org.openide.nodes.Children; //导入方法依赖的package包/类
public void testViewItemBasic() throws Exception {
Node root = extsrcroot.getLookup().lookup(LogicalViewProvider.class).createLogicalView();
assertEquals("lookup has project", extsrcroot, root.getLookup().lookup(Project.class));
Children ch = root.getChildren();
Node[] kids = ch.getNodes(true);
assertEquals("two child nodes", 2, kids.length);
// Do not check anything about #1, since it is provided by java/freeform.
assertEquals("correct code name #2", "nbproject/project.xml", kids[1].getName());
assertEquals("correct display name #2", "project.xml", kids[1].getDisplayName());
assertEquals("correct cookie #2",
DataObject.find(egdirFO.getFileObject("extsrcroot/proj/nbproject/project.xml")),
kids[1].getLookup().lookup(DataObject.class));
}
示例15: testViewItemBasic
import org.openide.nodes.Children; //导入方法依赖的package包/类
public void testViewItemBasic() throws Exception {
Node root = lvp.createLogicalView();
Children ch = root.getChildren();
Node[] kids = ch.getNodes(true);
assertEquals("two child nodes", 2, kids.length);
assertEquals("correct code name #1", "../src", kids[0].getName());
assertEquals("correct display name #1", "External Sources", kids[0].getDisplayName());
assertEquals("correct cookie #1",
DataObject.find(egdirFO.getFileObject("extsrcroot/src")),
kids[0].getLookup().lookup(DataObject.class));
Node[] kids2 = kids[0].getChildren().getNodes(true);
assertEquals("one child of ../src", 1, kids2.length);
assertEquals("correct name of #1's kid", "org.foo", kids2[0].getName());
// Do not test node #2; supplied by ant/freeform.
}