本文整理汇总了Java中javafx.scene.control.TreeItem类的典型用法代码示例。如果您正苦于以下问题:Java TreeItem类的具体用法?Java TreeItem怎么用?Java TreeItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeItem类属于javafx.scene.control包,在下文中一共展示了TreeItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTreeView
import javafx.scene.control.TreeItem; //导入依赖的package包/类
public TreeView<Concept> getTreeView() {
if (treeView == null) {
TreeCellFactory cellFactory = new TreeCellFactory(conceptService);
treeView = new TreeView<>();
treeView.getStyleClass().add("concepttree-treeview");
treeView.setEditable(false);
treeView.setCellFactory(tv -> cellFactory.build());
treeView.setContextMenu(getContextMenu());
conceptService.findRoot()
.thenApply(root -> {
Platform.runLater(() -> {
TreeItem<Concept> rootItem = buildTreeItem(root, null);
treeView.setRoot(rootItem);
});
return null;
});
}
return treeView;
}
示例2: changed
import javafx.scene.control.TreeItem; //导入依赖的package包/类
@Override public void changed(ObservableValue<? extends TreeItem<Object>> observable, TreeItem<Object> oldValue,
TreeItem<Object> newValue) {
if (newValue == null) {
okButton.setDisable(true);
documentArea.setText("");
argumentPane.getChildren().clear();
return;
}
TreeItem<Object> item = tree.getSelectionModel().getSelectedItem();
String doc = "";
boolean disable = true;
functionItem = item;
Object value = item.getValue();
if (value instanceof Module) {
doc = ((Module) value).getDocumentation();
} else {
doc = ((Function) value).getDocumentation();
disable = false;
}
okButton.setDisable(disable);
documentArea.setText(doc);
argumentPane.getChildren().clear();
if (item.isLeaf()) {
addArguments(item);
}
}
示例3: testBranches
import javafx.scene.control.TreeItem; //导入依赖的package包/类
@Test
public void testBranches() {
table.getEntry("branch/entry").setString("x");
NetworkTableInstance.getDefault().waitForEntryListenerQueue(-1.0);
waitForFxEvents();
ObservableList<TreeItem<NetworkTableSourceEntry>> children = root.getChildren();
assertEquals(1, children.size(), "There should be 1 first-level child");
assertEquals(1, children.get(0).getChildren().size(), "There should be 1 second-level child");
final TreeItem<NetworkTableSourceEntry> branch = children.get(0);
final TreeItem<NetworkTableSourceEntry> leaf = branch.getChildren().get(0);
assertThat(branch, hasKey("/branch"));
assertThat(branch, hasDisplayString(""));
assertThat("Branch should not be a leaf", branch, not(isLeaf()));
assertThat("Branch should be expanded", branch, isExpanded());
assertThat(leaf, hasKey("/branch/entry"));
assertThat(leaf, hasSimpleKey("entry"));
assertThat(leaf, hasDisplayString("x"));
assertThat(leaf, isLeaf());
}
示例4: expanderListener
import javafx.scene.control.TreeItem; //导入依赖的package包/类
public ChangeListener<Boolean> expanderListener() {
return (observable, oldValue, newValue) -> {
BooleanProperty bb = (BooleanProperty) observable;
TreeItem t = (TreeItem) bb.getBean();
CustomIcons customIcons = new CustomIcons();
t.setGraphic(new ImageView(newValue ? customIcons.getFolderExpandImage() : customIcons.getFolderCollapseImage()));
if (newValue) {
scheduleHighlight();
}
};
}
示例5: initTreeView
import javafx.scene.control.TreeItem; //导入依赖的package包/类
private void initTreeView() {
parentTreeView.setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
@Override public TreeCell<File> call(TreeView<File> param) {
return new ParentFileCell();
}
});
parentTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newVlaue) -> {
TreeItem<File> selectedItem = parentTreeView.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
newFolderButton.setDisable(false);
fileNameBox.setEditable(true);
File selectedFile = selectedItem.getValue();
fillUpChildren(selectedFile);
} else {
fileNameBox.setEditable(false);
newFolderButton.setDisable(true);
childrenListView.getItems().clear();
}
});
File root = fileChooserInfo.getRoot();
TreeItem<File> rootItem = new TreeItem<>(root);
parentTreeView.setRoot(rootItem);
rootItem.setExpanded(true);
parentTreeView.getSelectionModel().select(0);
populateChildren(root, rootItem);
}
示例6: getCollections
import javafx.scene.control.TreeItem; //导入依赖的package包/类
List<TreeItem<String>> getCollections() {
Set<String> mapNames = dbStore.getMapNames();
List<TreeItem<String>> treeItems = new ArrayList<>();
mapNames.stream().filter(this::isCollection)
.forEachOrdered(name -> {
TreeItem<String> collectionItem = new TreeItem<>(name, getIcon("collection.png"));
if (!name.contains(META_MAP_NAME)) {
TreeItem<String> indicesItem = new TreeItem<>("Indices");
indicesItem.getChildren().addAll(getIndices(mapNames, name));
TreeItem<String> metaItem = new TreeItem<>("Metadata");
metaItem.getChildren().add(getMeta(mapNames, name));
collectionItem.getChildren().add(indicesItem);
collectionItem.getChildren().add(metaItem);
}
treeItems.add(collectionItem);
});
return treeItems;
}
示例7: notifyRemoved
import javafx.scene.control.TreeItem; //导入依赖的package包/类
/**
* Notify about removed a spatial.
*
* @param spatial the spatial.
*/
public void notifyRemoved(@NotNull final Spatial spatial) {
spatial.depthFirstTraversal(child -> {
final SceneLayer layer = SceneLayer.getLayer(child);
if (layer == SceneLayer.NO_LAYER) return;
final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);
if (newLayerItem != null && treeItem != null) {
newLayerItem.getChildren().remove(treeItem);
}
}, Spatial.DFSMode.POST_ORDER);
}
示例8: updateCompGeom
import javafx.scene.control.TreeItem; //导入依赖的package包/类
public void updateCompGeom(Map<String, String> map) throws Exception {
compGeomContainer.getChildren().clear();
String groupName = "";
TreeItem<DesignVariableGroup> group = null;
for (String key : map.keySet()) {
String[] names = key.split(":");
if (names.length == 3) {
if (!groupName.equals(names[1])) {
groupName = names[1];
group = new TreeItem<>(new DesignVariableGroup(groupName));
compGeomContainer.getChildren().add(group);
}
if (group != null) addDesignVariable(compGeomContainer, group, names[2], names[0], "0", "", true);
}
}
}
示例9: getGlobalIndexOf
import javafx.scene.control.TreeItem; //导入依赖的package包/类
private int getGlobalIndexOf(TreeItem<String> fileNode)
{
TreeItem<String> root = projectTreeDisplay.getRoot();
ObservableList<TreeItem<String>> projectNodes = root.getChildren();
int index = 0;
for (TreeItem<String> node : projectNodes)
{
if (node.equals(fileNode))
return index;
index++;
for (TreeItem<String> child : node.getChildren())
{
if (child.equals(fileNode))
return index;
index++;
}
}
throw new IllegalArgumentException(fileNode.getValue() + " not found in tree");
}
示例10: notifyAdded
import javafx.scene.control.TreeItem; //导入依赖的package包/类
/**
* Notify about added a spatial.
*
* @param spatial the spatial.
*/
public void notifyAdded(@NotNull final Spatial spatial) {
spatial.depthFirstTraversal(child -> {
final SceneLayer layer = SceneLayer.getLayer(child);
if (layer == SceneLayer.NO_LAYER) return;
final TreeItem<TreeNode<?>> newLayerItem = findItemForValue(getTreeView(), layer);
final TreeItem<TreeNode<?>> treeItem = findItemForValue(getTreeView(), child);
if (newLayerItem != null && treeItem == null) {
final TreeNode<?> objectNode = FACTORY_REGISTRY.createFor(child);
newLayerItem.getChildren().add(new TreeItem<>(objectNode));
}
}, Spatial.DFSMode.POST_ORDER);
}
示例11: CollatedTreeItem
import javafx.scene.control.TreeItem; //导入依赖的package包/类
public CollatedTreeItem() {
children = FXCollections.observableArrayList();
filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
@Override public boolean test(TreeItem<T> t) {
return filter.test(t.getValue());
}
});
sortedChildren = new SortedList<>(filteredChildren);
ObservableList<TreeItem<T>> original = super.getChildren();
sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
@Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
while (c.next()) {
original.removeAll(c.getRemoved());
original.addAll(c.getFrom(), c.getAddedSubList());
}
}
});
}
示例12: setCollation
import javafx.scene.control.TreeItem; //导入依赖的package包/类
public void setCollation() {
if (comparator == null) {
sortedChildren.setComparator(null);
} else {
sortedChildren.setComparator((o1, o2) -> comparator.compare(o1.getValue(), o2.getValue()));
}
if (filter == null) {
filteredChildren.setPredicate(null);
} else {
filteredChildren.setPredicate(new Predicate<TreeItem<T>>() {
@Override public boolean test(TreeItem<T> t) {
return filter.test(t.getValue());
}
});
}
}
示例13: populateSectionsTree
import javafx.scene.control.TreeItem; //导入依赖的package包/类
/**
* Fills sections treeview with passed in sectionsList
*
* @param sectionsList
*/
private void populateSectionsTree( Set<OptionSection> sectionsList )
{
for ( OptionSection section : sectionsList )
{
//TODO this feels disgusting. Fix this
if ( !section.getFullPath().contains(".") )
{
TreeItem<String> sectionItem = new TreeItem<>(section.getName());
if ( section.size() > 0 )
sectionItem.getChildren().addAll(getSectionChildren(section));
sections.getRoot().getChildren().add(sectionItem);
}
}
}
示例14: onNextFailure
import javafx.scene.control.TreeItem; //导入依赖的package包/类
public void onNextFailure() {
if (testTree.getRoot() == null) {
return;
}
TreeItem<Test> item = testTree.getSelectionModel().getSelectedItem();
TestTreeItem nextFailure = null;
if (item != null) {
if (item.isLeaf()) {
nextFailure = findNextFailureInSiblings((TestTreeItem) item);
} else {
nextFailure = findNextFailureInChildren((TestTreeItem) item, true);
}
} else {
nextFailure = findNextFailureInChildren((TestTreeItem) testTree.getRoot(), false);
}
if (nextFailure == null) {
return;
}
isExpandNeeded(nextFailure);
int failureIndex = testTree.getRow(nextFailure);
testTree.getSelectionModel().clearAndSelect(failureIndex);
testTree.scrollTo(failureIndex);
}
示例15: findNextFailureInChildren
import javafx.scene.control.TreeItem; //导入依赖的package包/类
private TestTreeItem findNextFailureInChildren(TestTreeItem parent, boolean findInSibling) {
TestTreeItem found = null;
for (TreeItem<Test> child : parent.getChildren()) {
if (child.isLeaf()
&& (((TestTreeItem) child).getState() == State.FAILURE || ((TestTreeItem) child).getState() == State.ERROR)) {
found = (TestTreeItem) child;
break;
} else {
found = findNextFailureInChildren((TestTreeItem) child, findInSibling);
if (found != null) {
break;
}
}
}
if (found == null && findInSibling) {
TestTreeItem sib = (TestTreeItem) parent.nextSibling();
if (isFailure(sib)) {
found = sib;
} else {
if (sib != null) {
found = findNextFailureInChildren(sib, true);
}
}
}
return found;
}