List of usage examples for javafx.scene.control CheckBoxTreeItem setSelected
public final void setSelected(boolean value)
From source file:caillou.company.clonemanager.gui.customComponent.excludeTree.ExcludeTreeController.java
public void initialiseRootDirectory() { DirectoryLazyCheckableTreeItem rootValue = this.factoryDirectoryCheckableTreeItem .createItem(this.getModel().getPath()); final CheckBoxTreeItem<DirectoryLazyCheckableTreeItem> rootItem = new CheckBoxTreeItem<>(rootValue); rootItem.setSelected(true); this.buildTreeLazily(rootItem, 3); treeView.setRoot(rootItem);// ww w . jav a2s. c om treeView.prefWidthProperty().bind(this.rootId.widthProperty().subtract(10)); treeView.prefHeightProperty().bind(this.rootId.heightProperty().subtract(10)); treeView.setCellFactory(CheckBoxTreeCell.<DirectoryLazyCheckableTreeItem>forTreeView()); }
From source file:caillou.company.clonemanager.gui.customComponent.excludeTree.ExcludeTreeController.java
public void buildTreeLazily(final CheckBoxTreeItem<DirectoryLazyCheckableTreeItem> currentItem, int nbPass) { if (nbPass == 0) { return;/*from ww w . ja va 2s . c om*/ } boolean lazyChilds = nbPass > 2; DirectoryLazyCheckableTreeItem currentItemValue = currentItem.getValue(); final ExcludeTreeController excludeControllerInstance = this; File currentDirectory = new File(currentItemValue.getAbsolutePath()); if (!currentDirectory.canRead()) { return; } currentItemValue.setLoaded(lazyChilds); currentItem.getChildren().clear(); for (File subFile : currentDirectory.listFiles(directoryFilter)) { DirectoryLazyCheckableTreeItem childrenDirectoryLazyCheckableTreeItem = this.factoryDirectoryCheckableTreeItem .createItem(subFile.getAbsolutePath()); CheckBoxTreeItem<DirectoryLazyCheckableTreeItem> children = new CheckBoxTreeItem<>( childrenDirectoryLazyCheckableTreeItem); children.setSelected(!this.getModel().isExcludedByUser(subFile.toPath())); final ExcludeModel excludeModel = this.getModel(); final File tmpFile = subFile; children.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { excludeModel.removeExclusionByUser(tmpFile.toPath()); } else { excludeModel.addExclusionByUser(tmpFile.toPath()); } } }); this.buildTreeLazily(children, nbPass - 1); currentItem.getChildren().add(children); } if (nbPass == 2) { currentItem.expandedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { excludeControllerInstance.buildTreeLazily(currentItem, 3); currentItem.expandedProperty().removeListener(this); } }); } }
From source file:UI.MainStageController.java
/** * <h1>Changes the selection of every treeitem representating a sample</h1> * <p>//from w w w. j a v a 2 s .c o m * <p>Note: </p>May not be used for selection by metadata because it changes every treeitem * independent of any characteristics of the represented samples * </p> * @param isDeselectAll Boolean whether every treeitem should be selected or deselected */ private void changeSelectionForSamples(boolean isDeselectAll) { if (treeViewFiles.getRoot() != null && !treeViewFiles.getRoot().getChildren().isEmpty()) { for (int i = 0; i < treeViewFiles.getRoot().getChildren().size(); i++) { //Replaces the found tree item with a CheckBoxTreeItem -> Actually the found tree item //is already a CheckBoxTreeItem but the TreeView does not now anythin from its CellFactory //at this point. TreeItem<String> foundTreeItem = treeViewFiles.getRoot().getChildren().get(i); CheckBoxTreeItem<String> checkBoxTreeItemRepresentation = (CheckBoxTreeItem<String>) foundTreeItem; checkBoxTreeItemRepresentation.setSelected(!isDeselectAll); treeViewFiles.getRoot().getChildren().set(i, checkBoxTreeItemRepresentation); } } }