本文整理匯總了Java中org.openide.nodes.Node.isLeaf方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.isLeaf方法的具體用法?Java Node.isLeaf怎麽用?Java Node.isLeaf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.nodes.Node
的用法示例。
在下文中一共展示了Node.isLeaf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getChild
import org.openide.nodes.Node; //導入方法依賴的package包/類
public java.lang.Object getChild(java.lang.Object parent, int index) {
int superCnt = super.getChildCount(parent);
int myCnt = 0;
for (int i = 0; i < superCnt; i++) {
Object origChild = super.getChild(parent, i);
Node n = Visualizer.findNode(origChild);
if (!n.isLeaf()) {
if (myCnt++ == index) {
return origChild;
}
}
}
return null;
}
示例2: getIndexOfChild
import org.openide.nodes.Node; //導入方法依賴的package包/類
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child) {
int superCnt = super.getChildCount(parent);
int myCnt = 0;
for (int i = 0; i < superCnt; i++) {
Object origChild = super.getChild(parent, i);
if (child.equals(origChild)) {
return myCnt;
}
Node n = Visualizer.findNode(origChild);
if (!n.isLeaf()) {
myCnt++;
}
}
return -1;
}
示例3: representationOf
import org.openide.nodes.Node; //導入方法依賴的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(']');
}
}
}
示例4: getPrevRow
import org.openide.nodes.Node; //導入方法依賴的package包/類
private int getPrevRow(int row) {
row = row - 1;
Outline outline = tablePanel.treeView.getOutline();
if(row < 0 || row >= outline.getRowCount()) {
return -1;
}
TreePath path = outline.getOutlineModel().getLayout().getPathForRow(row);
Node node = Visualizer.findNode(path.getLastPathComponent());
if(node.isLeaf()) {
if(node instanceof RevisionNode || node instanceof RevisionNode.FileNode) {
return row;
} else {
return -1;
}
} else {
TreePathSupport support = outline.getOutlineModel().getTreePathSupport();
if(support.isExpanded(path)) {
return getPrevRow(row);
} else {
support.expandPath(path);
return row + node.getChildren().getNodesCount();
}
}
}
示例5: getNextRow
import org.openide.nodes.Node; //導入方法依賴的package包/類
private int getNextRow(int row) {
row = row + 1;
Outline outline = tablePanel.treeView.getOutline();
if(row < 0 || row >= outline.getRowCount()) {
return -1;
}
TreePath path = outline.getOutlineModel().getLayout().getPathForRow(row);
Node node = Visualizer.findNode(path.getLastPathComponent());
if(node.isLeaf()) {
if(node instanceof RevisionNode || node instanceof RevisionNode.FileNode) {
return row;
} else {
return -1;
}
} else {
TreePathSupport support = outline.getOutlineModel().getTreePathSupport();
if(support.isExpanded(path)) {
return getPrevRow(row);
} else {
support.expandPath(path);
return row + 1;
}
}
}
示例6: copyNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
protected Node copyNode (Node node) {
boolean filter = false;
try {
DataObject d = (DataObject) node.getCookie (DataObject.class);
if (d != null) {
InstanceCookie.Of inst = (InstanceCookie.Of)d.getCookie(InstanceCookie.Of.class);
if (inst != null && (inst.instanceOf(Node.class) || inst.instanceOf(Node.Handle.class))) {
// This is just a node, not a real setting. E.g. ModuleNode, LoaderPoolNode. As such,
// it itself should not display any origin information, it would make no sense. However
// its children might have a legitimate DataObject cookie from the SFS.
d = null;
}
}
DataFolder folder = (DataFolder) node.getCookie (DataFolder.class);
FileSystem fs = d == null || folder != null ? null : d.getPrimaryFile ().getFileSystem ();
filter = fs == null ? false : fs.isDefault();
} catch (FileStateInvalidException e) {
// ignore
}
return filter ? new SettingFilterNode (node) :
node.isLeaf() ? node.cloneNode() : new TrivialFilterNode(node);
}
示例7: isRelevantNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public boolean isRelevantNode(Node node) {
if (node == null) {
return false;
} else {
Node parent = node.getParentNode();
return node.isLeaf() && parent != null
&& parent.getParentNode() != null;
}
}
示例8: printTree
import org.openide.nodes.Node; //導入方法依賴的package包/類
private static String printTree(Node n) {
String name = n.getDisplayName();
if (n.isLeaf()) {
return name;
} else {
List<String> kidNames = new ArrayList<String>();
for (Node kid : n.getChildren().getNodes(true)) {
kidNames.add(printTree(kid));
}
return name + kidNames;
}
}
示例9: createChildren
import org.openide.nodes.Node; //導入方法依賴的package包/類
private static Children createChildren(FileObject fo) {
if (fo != null) {
try {
Node n = DataObject.find(fo).getNodeDelegate();
if (!n.isLeaf()) { // using n.cloneNode().getChildren() does not work; someone caches cloneNode??
return new FilterNode.Children(n);
}
} catch (DataObjectNotFoundException x) {
Exceptions.printStackTrace(x);
}
}
return Children.LEAF;
}
示例10: FilteredNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
FilteredNode(Node original, String displayName, Filter filter) {
super(original, original.isLeaf() ? Children.LEAF : new FilteredChildren(original, filter));
if (displayName != null) {
disableDelegation(DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME);
setDisplayName(displayName);
}
}
示例11: getChildCount
import org.openide.nodes.Node; //導入方法依賴的package包/類
public int getChildCount(java.lang.Object parent) {
int superCnt = super.getChildCount(parent);
int myCnt = 0;
for (int i = 0; i < superCnt; i++) {
Node n = Visualizer.findNode(super.getChild(parent, i));
if (!n.isLeaf()) {
myCnt++;
}
}
return myCnt;
}
示例12: initChildren
import org.openide.nodes.Node; //導入方法依賴的package包/類
private void initChildren() {
Node node = getOriginal();
node.addNodeListener(WeakListeners.create(NodeListener.class, this, node));
final boolean leaf = node.isLeaf();
if (!leaf) {
setChildren(children);
}
}
示例13: ActionFilterNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
private ActionFilterNode(Node original, int mode) {
super(original, original.isLeaf() ? Children.LEAF : new ActionFilterChildren(original, mode, null));
this.mode = mode;
}
示例14: initTreeView
import org.openide.nodes.Node; //導入方法依賴的package包/類
/**
* Initializes the tree view.
*/
private void initTreeView() {
treeView = new BeanTreeView() {
{
tree.setCellRenderer(createTreeCellRenderer(tree.getCellRenderer()));
}
@Override
public void expandAll() {
// The original expandAll() doesn't work for us as it doesn't
// seem to wait for the calculation of sub-nodes.
Node root = manager.getRootContext();
expandAll(root);
// The view attempts to scroll to the expanded node
// and it does it with a delay. Hence, simple calls like
// tree.scrollRowToVisible(0) have no effect (are overriden
// later) => the dummy collapse and expansion attempts
// to work around that and keep the root node visible.
collapseNode(root);
expandNode(root);
}
/**
* Expands the whole sub-tree under the specified node.
*
* @param node root node of the sub-tree that should be expanded.
*/
private void expandAll(Node node) {
treeView.expandNode(node);
for (Node subNode : node.getChildren().getNodes(true)) {
if (!subNode.isLeaf()) {
expandAll(subNode);
}
}
}
};
treeView.setAllowedDragActions(DnDConstants.ACTION_NONE);
treeView.setAllowedDropActions(DnDConstants.ACTION_NONE);
treeView.setRootVisible(false);
add(treeView, BorderLayout.CENTER);
}
示例15: SortedNode
import org.openide.nodes.Node; //導入方法依賴的package包/類
public SortedNode (Node original) {
super(original, original.isLeaf() ? Children.LEAF : new SortedChildren(original));
original2filter.put (original, this);
}