Java Code Examples for javafx.scene.control.TreeItem#setExpanded()
The following examples show how to use
javafx.scene.control.TreeItem#setExpanded() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeViewSample1.java From marathonv5 with Apache License 2.0 | 6 votes |
public TreeViewSample1() { final TreeItem<String> treeRoot = new TreeItem<String>("Root node"); treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 1"), new TreeItem<String>("Child Node 2"), new TreeItem<String>("Child Node 3"))); treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 4"), new TreeItem<String>("Child Node 5"), new TreeItem<String>("Child Node 6"), new TreeItem<String>("Child Node 7"), new TreeItem<String>("Child Node 8"), new TreeItem<String>("Child Node 9"), new TreeItem<String>("Child Node 10"), new TreeItem<String>("Child Node 11"), new TreeItem<String>("Child Node 12"), new TreeItem<String>("Child Node 13"), new TreeItem<String>("Child Node 14"), new TreeItem<String>("Child Node 15"), new TreeItem<String>("Child Node 16"), new TreeItem<String>("Child Node 17"), new TreeItem<String>("Child Node 18"), new TreeItem<String>("Child Node 19"), new TreeItem<String>("Child Node 20"), new TreeItem<String>("Child Node 21"), new TreeItem<String>("Child Node 22"), new TreeItem<String>("Child Node 23"), new TreeItem<String>("Child Node 24"))); final TreeView treeView = new TreeView(); treeView.setShowRoot(true); treeView.setRoot(treeRoot); treeRoot.setExpanded(true); getChildren().add(treeView); }
Example 2
Source File: FeatureTableFX.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public FeatureTableFX() { // add dummy root TreeItem<ModularFeatureListRow> root = new TreeItem<>(); root.setExpanded(true); this.setRoot(root); this.setShowRoot(false); this.setTableMenuButtonVisible(true); this.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); this.getSelectionModel().setCellSelectionEnabled(true); setTableEditable(true); /*getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { int io = getRoot().getChildren().indexOf(oldValue); int in = getRoot().getChildren().indexOf(newValue); });*/ parameters = MZmineCore.getConfiguration().getModuleParameters(FeatureTableFXModule.class); rowTypesParameter = parameters.getParameter(FeatureTableFXParameters.showRowTypeColumns); featureTypesParameter = parameters .getParameter(FeatureTableFXParameters.showFeatureTypeColumns); rowItems = FXCollections.observableArrayList(); filteredRowItems = new FilteredList<>(rowItems); columnMap = new HashMap<>(); }
Example 3
Source File: ChoiceBoxTreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public ChoiceBoxTreeViewSample() { final TreeItem<String> treeRoot = new TreeItem<String>("Root node"); treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 1"), new TreeItem<String>("Option 2"), new TreeItem<String>("Option 3"))); treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 4"), new TreeItem<String>("Option 5"), new TreeItem<String>("Option 6"))); final TreeView treeView = new TreeView(); treeView.setShowRoot(true); treeView.setRoot(treeRoot); treeRoot.setExpanded(true); treeView.setEditable(true); treeView.setCellFactory(ChoiceBoxTreeCell.forTreeView(items)); getChildren().add(treeView); }
Example 4
Source File: JFXTreeTableCellBehavior.java From JFoenix with Apache License 2.0 | 6 votes |
@Override protected boolean handleDisclosureNode(double x, double y) { final TreeItem<S> treeItem = getControl().getTreeTableRow().getTreeItem(); if (!treeItem.isLeaf()) { final Node disclosureNode = getControl().getTreeTableRow().getDisclosureNode(); if (disclosureNode != null) { if (disclosureNode.getBoundsInParent().contains(x + disclosureNode.getTranslateX(), y)) { if (treeItem != null) { treeItem.setExpanded(!treeItem.isExpanded()); } return true; } } } return false; }
Example 5
Source File: TreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public TreeViewSample() { final TreeItem<String> treeRoot = new TreeItem<String>("Root node"); treeRoot.getChildren().addAll(Arrays.asList( new TreeItem<String>("Child Node 1"), new TreeItem<String>("Child Node 2"), new TreeItem<String>("Child Node 3"))); treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList( new TreeItem<String>("Child Node 4"), new TreeItem<String>("Child Node 5"), new TreeItem<String>("Child Node 6"), new TreeItem<String>("Child Node 7"), new TreeItem<String>("Child Node 8"), new TreeItem<String>("Child Node 9"), new TreeItem<String>("Child Node 10"), new TreeItem<String>("Child Node 11"), new TreeItem<String>("Child Node 12"))); final TreeView treeView = new TreeView(); treeView.setShowRoot(true); treeView.setRoot(treeRoot); treeRoot.setExpanded(true); getChildren().add(treeView); }
Example 6
Source File: ReasonSelectorController.java From OEE-Designer with MIT License | 6 votes |
private void onSelectReason(TreeItem<ReasonNode> oldItem, TreeItem<ReasonNode> newItem) throws Exception { if (newItem == null) { return; } // new attributes selectedReason = newItem.getValue().getReason(); // show the children too Set<Reason> children = selectedReason.getChildren(); List<Reason> sortedChildren = new ArrayList<>(children); Collections.sort(sortedChildren); boolean hasTreeChildren = newItem.getChildren().size() > 0 ? true : false; // check to see if the node's children have been previously shown if (!hasTreeChildren) { newItem.getChildren().clear(); for (Reason child : children) { TreeItem<ReasonNode> entityItem = new TreeItem<>(new ReasonNode(child)); newItem.getChildren().add(entityItem); entityItem.setGraphic(ImageManager.instance().getImageView(Images.REASON)); } } newItem.setExpanded(true); }
Example 7
Source File: TreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public TreeViewSample() { final TreeItem<String> treeRoot = new TreeItem<String>("Root node"); treeRoot.getChildren().addAll(Arrays.asList( new TreeItem<String>("Child Node 1"), new TreeItem<String>("Child Node 2"), new TreeItem<String>("Child Node 3"))); treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList( new TreeItem<String>("Child Node 4"), new TreeItem<String>("Child Node 5"), new TreeItem<String>("Child Node 6"), new TreeItem<String>("Child Node 7"), new TreeItem<String>("Child Node 8"), new TreeItem<String>("Child Node 9"), new TreeItem<String>("Child Node 10"), new TreeItem<String>("Child Node 11"), new TreeItem<String>("Child Node 12"))); final TreeView treeView = new TreeView(); treeView.setShowRoot(true); treeView.setRoot(treeRoot); treeRoot.setExpanded(true); getChildren().add(treeView); }
Example 8
Source File: ListKMLContentsSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 6 votes |
/** * Recursively adds child tree items to the given parent tree item based on its node's child nodes. * * @param parent a parent KML node tree item * @return the original parent, now with the child tree attached to it */ private TreeItem<KmlNode> buildTree(TreeItem<KmlNode> parent) { KmlNode node = parent.getValue(); node.setVisible(true); List<KmlNode> children = new ArrayList<>(); if (parent.getValue() instanceof KmlContainer) { children.addAll(((KmlContainer) node).getChildNodes()); } else if (parent.getValue() instanceof KmlNetworkLink) { children.addAll(((KmlNetworkLink) node).getChildNodes()); } children.forEach(childNode -> { TreeItem<KmlNode> childTreeItem = buildTree(new TreeItem<>(childNode)); parent.getChildren().add(childTreeItem); }); parent.setExpanded(true); // expand all nodes in the tree view return parent; }
Example 9
Source File: CoursesTreeView.java From iliasDownloaderTool with GNU General Public License v2.0 | 5 votes |
public void selectFile(IliasFile selectedDirectory) { collapse(); final TreeItem<IliasTreeNode> linkedTreeItem = getItem(selectedDirectory); linkedTreeItem.setExpanded(true); getSelectionModel().clearSelection(); getSelectionModel().select(linkedTreeItem); scrollTo(getSelectionModel().getSelectedIndex()); }
Example 10
Source File: ResourceView.java From marathonv5 with Apache License 2.0 | 5 votes |
private void expandTreeView(TreeItem<Resource> item) { if (item != null && !item.isLeaf()) { item.setExpanded(true); for (TreeItem<Resource> child : item.getChildren()) { expandTreeView(child); } } }
Example 11
Source File: CoursesTreeView.java From iliasDownloaderTool with GNU General Public License v2.0 | 5 votes |
private void collapse(ObservableList<TreeItem<IliasTreeNode>> items) { for (TreeItem<IliasTreeNode> item : items) { item.setExpanded(false); collapse(item.getChildren()); } dashboard.setStatusText(""); }
Example 12
Source File: MetadataNode.java From sis with Apache License 2.0 | 5 votes |
private void expandNodes(TreeItem<TreeTable.Node> root) { if (root == null || root.isLeaf()) { return; } root.setExpanded(getExpandNode().test(root.getValue())); for (TreeItem<TreeTable.Node> child : root.getChildren()) { expandNodes(child); } }
Example 13
Source File: GeographyCodeSelectorController.java From MyBox with Apache License 2.0 | 5 votes |
protected void addNodes(TreeItem<Text> parent, List<GeographyCode> codes, List<Long> haveChildren) { if (parent == null || codes == null || codes.isEmpty()) { return; } for (GeographyCode code : codes) { long codeid = code.getGcid(); Text codeNode = new Text(code.getName()); codeNode.setOnMouseClicked((MouseEvent event) -> { userController.codeSelected(code); }); codeNode.setUserData(codeid); TreeItem<Text> codeItem = new TreeItem(codeNode); parent.getChildren().add(codeItem); if (!leafCheck.isSelected() || (haveChildren != null && haveChildren.contains(codeid))) { TreeItem<Text> dummyItem = new TreeItem(new Text("Loading")); codeItem.getChildren().add(dummyItem); codeItem.setExpanded(false); codeItem.expandedProperty().addListener( (ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) -> { if (newVal && !codeItem.isLeaf() && !loaded(codeItem)) { nodeTree(codeItem, code); } }); } } }
Example 14
Source File: TreeHelper.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Expand or collapse complete sub tree * * @param node Node from which on to expand * @param expand Expand or collapse? */ public static void setExpanded(final TreeItem<?> node, final boolean expand) { if (node.isLeaf()) return; node.setExpanded(expand); for (TreeItem<?> sub : node.getChildren()) setExpanded(sub, expand); }
Example 15
Source File: DirectoryItem.java From Recaf with MIT License | 4 votes |
/** * Expand all parents to this item. */ public void expandParents() { TreeItem<?> item = this; while ((item = item.getParent()) != null) item.setExpanded(true); }
Example 16
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected int getTreeTableNodeIndex(TreeTableView<?> treeTableView, String path) { String[] tokens = path.substring(1).split("(?<!\\\\)/"); Object rootNode = treeTableView.getRoot(); int start = treeTableView.isShowRoot() ? 1 : 0; List<TreeItem<?>> treePath = new ArrayList<TreeItem<?>>(); treePath.add((TreeItem<?>) rootNode); StringBuilder searchedPath = new StringBuilder(); if (treeTableView.isShowRoot()) { String rootNodeText = unescapeSpecialCharacters(tokens[0]); searchedPath.append("/" + rootNodeText); if (rootNode == null) { throw new RuntimeException("TreeTableView does not have a root node!"); } if (!searchedPath.toString() .equals("/" + getTextForTreeTableNodeObject(treeTableView, treePath.get(treePath.size() - 1)))) { throw new RuntimeException("TreeTableView root node does not match: Expected </" + getTextForTreeTableNodeObject(treeTableView, treePath.get(treePath.size() - 1)) + "> Actual: <" + searchedPath.toString() + ">"); } } for (int i = start; i < tokens.length; i++) { String childText = unescapeSpecialCharacters(tokens[i]); searchedPath.append("/" + childText); boolean matched = false; TreeItem<?> item = treePath.get(treePath.size() - 1); item.setExpanded(true); for (int j = 0; j < item.getChildren().size(); j++) { Object child = item.getChildren().get(j); treePath.add((TreeItem<?>) child); List<TreeItem<?>> childPath = treePath; if (childText.equals(getTextForTreeTableNodeObject(treeTableView, childPath.get(childPath.size() - 1)))) { treePath = childPath; matched = true; break; } } if (!matched) { return -1; } } @SuppressWarnings("rawtypes") TreeItem treeItem = treePath.get(treePath.size() - 1); return treeTableView.getRow(treeItem); }
Example 17
Source File: PhysicalModelController.java From OEE-Designer with MIT License | 4 votes |
@FXML private void onDeleteEntity() { PlantEntity selectedEntity = getSelectedEntity(); if (selectedEntity == null) { AppUtils.showErrorDialog(DesignerLocalizer.instance().getErrorString("no.entity")); return; } // confirm ButtonType type = AppUtils.showConfirmationDialog( DesignerLocalizer.instance().getLangString("confirm.delete", selectedEntity.getName())); if (type.equals(ButtonType.CANCEL)) { return; } try { // delete from db if previously saved PlantEntity parentEntity = selectedEntity.getParent(); if (parentEntity != null) { // remove from parent with orphan removal parentEntity.removeChild(selectedEntity); PersistenceService.instance().save(parentEntity); } else { // cascade delete PersistenceService.instance().delete(selectedEntity); } // remove this entity from the tree TreeItem<EntityNode> selectedEntityItem = tvEntities.getSelectionModel().getSelectedItem(); TreeItem<EntityNode> parentNode = selectedEntityItem.getParent(); parentNode.getChildren().remove(selectedEntityItem); tvEntities.getSelectionModel().clearSelection(); tvEntities.refresh(); parentNode.setExpanded(true); onNewEntity(); } catch (Exception e) { AppUtils.showErrorDialog(e); } }
Example 18
Source File: MonitorController.java From OEE-Designer with MIT License | 4 votes |
private void onSelectEntity(TreeItem<EntityNode> oldItem, TreeItem<EntityNode> newItem) throws Exception { if (newItem == null) { return; } // new attributes PlantEntity selectedEntity = newItem.getValue().getPlantEntity(); if (selectedEntity == null) { // load the entity String name = newItem.getValue().getPlantEntity().getName(); selectedEntity = PersistenceService.instance().fetchPlantEntityByName(name); newItem.getValue().setPlantEntity(selectedEntity); } // show the children too Set<PlantEntity> children = selectedEntity.getChildren(); List<PlantEntity> sortedChildren = new ArrayList<>(children); Collections.sort(sortedChildren); boolean hasTreeChildren = newItem.getChildren().size() > 0 ? true : false; // check to see if the node's children have been previously shown if (!hasTreeChildren) { newItem.getChildren().clear(); for (PlantEntity child : children) { TreeItem<EntityNode> entityItem = new TreeItem<>(new EntityNode(child)); newItem.getChildren().add(entityItem); this.setEntityGraphic(entityItem); } } newItem.setExpanded(true); if (selectedEntity instanceof Equipment) { dashboardController.setupEquipmentLoss((Equipment) selectedEntity); dashboardController.enableRefresh(true); } else { dashboardController.setupEquipmentLoss(null); dashboardController.enableRefresh(false); } dashboardController.onRefresh(); }
Example 19
Source File: TreeMenu.java From SmartCity-ParkingManagement with Apache License 2.0 | 4 votes |
public TreeItem<String> makeBranch(final String title, final TreeItem<String> parent) { final TreeItem<String> $ = new TreeItem<>(title); $.setExpanded(true); parent.getChildren().add($); return $; }
Example 20
Source File: PlanningCenterOnlineImportDialog.java From Quelea with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") protected void processServiceTypeFolder(TreeItem<String> parentItem) throws IOException { String orgName = parser.getPlanningCenterClient().services().api().get().execute().body().get().getName(); List<Folder> folders = parser.getPlanningCenterClient().services().folders().api().get().execute().body().get(); Map<String, TreeItem<String>> treeItemMap = folders.stream() .collect(Collectors.toMap(Folder::getId, f -> new TreeItem<>(f.getName() == null ? orgName : f.getName()))); for (Folder folder : folders) { if (folder.getParent().isPresent()) { Folder parent = folder.getParent().get(); treeItemMap.get(parent.getId()).getChildren().add(treeItemMap.get(folder.getId())); } else { parentItem.getChildren().add(treeItemMap.get(folder.getId())); } treeItemMap.get(folder.getId()).setExpanded(true); } List<ServiceType> serviceTypes = parser.getPlanningCenterClient().services().serviceTypes().api().get().execute().body().get(); for (ServiceType serviceType : serviceTypes) { TreeItem<String> serviceTypeItem = new TreeItem<>(serviceType.getName()); TreeItem<String> serviceTypeParentItem; if (serviceType.getParent() == null) { serviceTypeParentItem = parentItem; } else { serviceTypeParentItem = treeItemMap.get(serviceType.getParent().getId()); } List<Plan> serviceTypePlans = parser.getPlanningCenterClient().services().serviceType(serviceType.getId()).plans().api().get().execute().body().get(); for (Plan plan : serviceTypePlans) { String date = plan.getDates(); if (date.isEmpty() || date.equals("No dates")) { continue; } List<Item> planItems = parser.getPlanningCenterClient().services().serviceType(plan.getServiceType().getId()).plan(plan.getId()).items().api().get().execute().body().get(); TreeItem<String> planItem = new TreeItem<>(date); serviceTypeItem.getChildren().add(planItem); PlanningCenterOnlinePlanDialog planDialog = new PlanningCenterOnlinePlanDialog(PlanningCenterOnlineImportDialog.this, plan, planItems); treeViewItemPlanDialogMap.put(planItem, planDialog); } serviceTypeItem.setExpanded(true); serviceTypeParentItem.getChildren().add(serviceTypeItem); } }