下面列出了javafx.scene.control.TreeItem#isExpanded ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void reveal(final TreeItem<ScanCommand> item)
{
// Expand tree up to parent because 'getRow' will
// only find items that are expanded
TreeItem<ScanCommand> parent = item.getParent();
while (parent != null)
{
if (! parent.isExpanded())
parent.setExpanded(true);
parent = parent.getParent();
}
// Scroll to the active command
final int row = getRow(active_item);
if (row >= 0)
{
// Try to show one command above the desired one to get some context
if (row > 1)
scrollTo(row-1);
else
scrollTo(row);
}
}
private void extractDataFromTree(
ArrayList<ObjectInStructure> treedata,
TreeItem<ObjectDataElt> nodetoprocess,
int leveltouse,
String cascadetouse,
int circuitbreaker) {
if (circuitbreaker > CObjectTreeArray.TREE_NAVIGATION_CIRCUITBREAKER)
throw new RuntimeException("Circuit Breaker on too deep recursive structure");
String currentnodecascade = cascadetouse;
int levelforchildren = leveltouse;
if (nodetoprocess.getValue() != null) {
currentnodecascade = (cascadetouse.length() > 0 ? cascadetouse : "1");
boolean leaf = true;
if (nodetoprocess.getChildren().size() > 0)
leaf = false;
treedata.add(new ObjectInStructure(nodetoprocess.getValue(), currentnodecascade, leveltouse, leaf));
levelforchildren++;
}
if (nodetoprocess.isExpanded()) {
Iterator<TreeItem<ObjectDataElt>> childreniterator = nodetoprocess.getChildren().iterator();
int childindex = 0;
while (childreniterator.hasNext()) {
childindex++;
TreeItem<ObjectDataElt> thischild = childreniterator.next();
String childcascade = currentnodecascade + (currentnodecascade.length() > 0 ? "." : "") + childindex;
extractDataFromTree(treedata, thischild, levelforchildren, childcascade, circuitbreaker + 1);
}
}
}
private ObservableList<TreeItem<File>> getLoadedChildren(TreeItem<File> item) {
return (item instanceof FileTreeItem && !item.isExpanded())
? ((FileTreeItem)item).getLoadedChildren()
: item.getChildren();
}