List of usage examples for javafx.scene.control TreeItem getValue
public final T getValue()
From source file:org.sleuthkit.autopsy.timeline.ui.detailview.tree.DescriptionTreeItem.java
@Override String getDisplayText() {/* w w w .j a v a 2 s . co m*/ String text = getValue().getDescription() + " (" + getValue().getSize() + ")"; // NON-NLS TreeItem<TimeLineEvent> parent = getParent(); if (parent != null && parent.getValue() != null && (parent instanceof DescriptionTreeItem)) { //strip off parent description text = StringUtils.substringAfter(text, parent.getValue().getDescription()); } return text; }
From source file:Main.java
@Override public void start(Stage stage) { rootNode.setExpanded(true);/*ww w .ja v a2s . c om*/ for (Employee employee : employees) { TreeItem<String> empLeaf = new TreeItem<>(employee.getName()); boolean found = false; for (TreeItem<String> depNode : rootNode.getChildren()) { if (depNode.getValue().contentEquals(employee.getDepartment())) { depNode.getChildren().add(empLeaf); found = true; break; } } if (!found) { TreeItem<String> depNode = new TreeItem<>(employee.getDepartment()); rootNode.getChildren().add(depNode); depNode.getChildren().add(empLeaf); } } stage.setTitle("Tree View Sample"); VBox box = new VBox(); final Scene scene = new Scene(box, 400, 300); scene.setFill(Color.LIGHTGRAY); TreeView<String> treeView = new TreeView<>(rootNode); treeView.setEditable(true); treeView.setCellFactory((TreeView<String> p) -> new TextFieldTreeCellImpl()); box.getChildren().add(treeView); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { rootNode.setExpanded(true);// w w w . ja va 2s . c o m for (Employee employee : employees) { TreeItem<String> empLeaf = new TreeItem<>(employee.getName()); boolean found = false; for (TreeItem<String> depNode : rootNode.getChildren()) { if (depNode.getValue().contentEquals(employee.getDepartment())) { depNode.getChildren().add(empLeaf); found = true; break; } } if (!found) { TreeItem depNode = new TreeItem(employee.getDepartment()); rootNode.getChildren().add(depNode); depNode.getChildren().add(empLeaf); } } stage.setTitle("Tree View Sample"); VBox box = new VBox(); final Scene scene = new Scene(box, 400, 300); scene.setFill(Color.LIGHTGRAY); TreeView<String> treeView = new TreeView<>(rootNode); treeView.setEditable(true); treeView.setCellFactory((TreeView<String> p) -> new TextFieldTreeCellImpl()); box.getChildren().add(treeView); stage.setScene(scene); stage.show(); }
From source file:musicmetadatak1009705.FolderTreeView.java
public VBox treeStack() throws IOException { VBox vbox = new VBox(); File[] drives = File.listRoots(); ArrayList<File> fileListing; /*for (File dir : drives) { System.out.println(dir.toString()); fileListing = restrictingList(dir); }*///from w w w . ja va 2 s . c om fileListing = restrictingList(new File("D:\\")); ArrayList<TreeItem> treeItems = new ArrayList<>(); for (File dir : drives) { //System.out.println(dir.toString()); treeItems.add(createNode(dir)); } TreeView<File> tree = proxyCreateNode(treeItems); vbox.getChildren().add(tree); tree.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends TreeItem<File>> observable, TreeItem<File> oldValue, TreeItem<File> newValue) -> { System.out.println("Selected Text: " + newValue.getValue()); TreeItem<File> selectedItem = newValue; System.out.println("Selected Text: " + selectedItem.getValue()); try { //FileTreeView fileTreeView = new FileTreeView(); System.out.println("File Tree View Event"); fileTreeView.GetFilesFromFolder((newValue.getValue().toString())); //fileTreeView.SetFileTreeView(); } catch (IOException ex) { System.err.println("Unable to pass fileTreeView Value \nPassed Value: " + selectedItem.getValue().toString() + "\r\nError Message:\r\n" + ex.toString()); Logger.getLogger(FolderTreeView.class.getName()).log(Level.SEVERE, null, ex); } } /* @Override public void changed( ObservableValue<? extends TreeItem<File>> observable, TreeItem<String> old_val, TreeItem<File> new_val) { }*/ ); return vbox; }
From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java
public Branch currentBranchValue() { TreeItem<Branch> item = currentBranch(); return item == null ? null : item.getValue(); }
From source file:ubicrypt.ui.files.FilesController.java
@Override public void initialize(URL url, ResourceBundle resourceBundle) { fxml = substringBefore(substringAfterLast(url.getFile(), "/"), ".fxml"); treeView.setCellFactory(treeView1 -> new TreeCellFactory(treeView1, fileUntracker, null, osUtil, basePath)); localConfig.getLocalFiles().stream().filter(Utils.trackedFile) .forEach(localFile -> addFiles(localFile.getPath().iterator(), basePath, root, localFile)); //remote file events fileEvents.filter(fileEvent -> fileEvent.getLocation() == FileEvent.Location.remote) .subscribe(fileEvent -> { log.debug("file remote event:{}", fileEvent); //update file icon final UbiFile<UbiFile> file = fileEvent.getFile(); Observable.create(fileInSync.call(file)).subscribe(res -> { searchFile(root, file).ifPresent(treeView -> { log.debug("found file item:{}", treeView); final Node graphics = treeView.getValue().getGraphics(); graphics.getStyleClass().clear(); graphics.getStyleClass().add(format("tree-file-saved-%s", res)); });/*from w ww. ja v a 2 s .c o m*/ }); }); //local file events fileEvents.filter(fileEvent -> fileEvent.getLocation() == FileEvent.Location.local).subscribe(fileEvent -> { log.debug("file local event:{}", fileEvent); Optional<TreeItem<ITreeItem>> optfile = searchFile(root, fileEvent.getFile()); if (!optfile.isPresent()) { optfile = localConfig.getLocalFiles().stream().filter(fileEvent.getFile()::equals).findFirst() .map(fe -> addFiles(fileEvent.getFile().getPath().iterator(), basePath, root, fe)); } if (!optfile.isPresent()) { log.debug("file not present:{}", fileEvent.getFile().getPath()); return; } TreeItem<ITreeItem> vfile = optfile.get(); final Node graphics = vfile.getValue().getGraphics(); graphics.getStyleClass().clear(); switch (fileEvent.getType()) { case created: case synched: graphics.getStyleClass().add("tree-file-saved-true"); break; case unsynched: graphics.getStyleClass().add("tree-file-saving"); break; case error: graphics.getStyleClass().add("tree-file-saved-true"); break; case removed: case deleted: removeItem(vfile); break; default: graphics.getStyleClass().add(format("tree-file-saved-%s", true)); } }); //sync-done events appEvents.subscribe(ClassMatcher.newMatcher().on(SyncBeginEvent.class, event -> { log.info("sync begin received"); }).on(SynchDoneEvent.class, event -> { log.debug("synchronization done"); })); }
From source file:caillou.company.clonemanager.gui.customComponent.excludeTree.ExcludeTreeController.java
public void buildTreeLazily(final TreeItem<DirectoryLazyCheckableTreeItem> currentItem, int nbPass) { if (nbPass == 0) { return;/*from www . j a v a 2s. c o m*/ } 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)) { TreeItem<DirectoryLazyCheckableTreeItem> children = new CheckBoxTreeItem<>( this.factoryDirectoryCheckableTreeItem.createItem(subFile.getAbsolutePath())); 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:org.dataconservancy.packaging.gui.presenter.impl.EditPackageContentsPresenterImplTest.java
/** * Helper function for getting a child with a given ID * @param parent the parent TreeItem/*from ww w . java 2s. com*/ * @param id the ID * @return a child with a given ID */ private TreeItem<Node> findChild(TreeItem<Node> parent, URI id) { for (TreeItem<Node> ti : parent.getChildren()) { if (ti.getValue().getIdentifier().equals(id)) { parent.setExpanded(true); return ti; } } return null; }
From source file:edu.mit.lib.handbag.Controller.java
private void transmitBag() { try {/*from ww w . j a v a2s .c om*/ URI destUri = new URL(workflowChoiceBox.getValue().getDestinationUrl()).toURI(); String pkgFormat = workflowChoiceBox.getValue().getPackageFormat(); boolean localDest = destUri.getScheme().startsWith("file"); Path destDir = Paths.get(destUri); Filler filler = localDest ? new Filler(destDir.resolve(bagName)) : new Filler(); // add payload files for (TreeItem ti : payloadTreeView.getRoot().getChildren()) { PathRef pr = (PathRef) ti.getValue(); if (pr.getRelPath().length() > 0) { filler.payload(pr.getRelPath() + pr.getPath().getFileName(), pr.getPath()); } else { filler.payload(pr.getPath()); } } // add metadata (currently only bag-info properties supported) for (PropertySheet.Item mdItem : metadataPropertySheet.getItems()) { MetadataItem item = (MetadataItem) mdItem; if (item.getValue() != null && item.getValue().length() > 0) { filler.metadata(item.getRealName(), item.getValue()); } } if (localDest) { filler.toPackage(pkgFormat); } else { // send to URL - TODO } reset(true); } catch (IOException | URISyntaxException exp) { } }
From source file:sonicScream.controllers.CategoryTabController.java
public void revertSound() { TreeItem<String> selectedNode = (TreeItem<String>) CategoryTabTreeView.getSelectionModel() .getSelectedItem();// w w w . ja va2s . co m if (!selectedNode.isLeaf()) { return; //Shouldn't even be possible, but just in case } //We use this later to find the correct node to select after a reversion. int nodeParentIndex = selectedNode.getParent().getParent().getChildren().indexOf(selectedNode.getParent()); Script activeScript = (Script) CategoryTabComboBox.getValue(); //get the index of the selected node relative to its parent. int selectedWaveIndex = selectedNode.getParent().getChildren().indexOf(selectedNode); VPKFileService vpkService = (VPKFileService) ServiceLocator.getService(VPKFileService.class); Script vpkScript = new Script(vpkService.getVPKEntry(activeScript.getVPKPath()), _category); List<TreeItem<String>> vpkWaves = TreeUtils.getWaveStrings(vpkScript.getRootNode()).orElse(null); if (vpkWaves != null && vpkWaves.size() > selectedWaveIndex) { TreeItem<String> selectedNodeInRoot = TreeUtils.getWaveStrings(activeScript.getRootNode()).get() .get(selectedWaveIndex); TreeItem<String> selectedNodeInVPKRoot = vpkWaves.get(selectedWaveIndex); String vpkNodeString = StringUtils.normalizeSpace((selectedNodeInVPKRoot.getValue())); selectedNodeInRoot.setValue(vpkNodeString); selectedNode.setValue(StringParsing.rootSoundToSimpleSound(vpkNodeString)); } //if the index does NOT exist, remove the index from the root node, and //then do all the updating else { TreeItem<String> selectedNodeInRoot = TreeUtils.getWaveStrings(activeScript.getRootNode()).get() .get(selectedWaveIndex); selectedNodeInRoot.getParent().getChildren().remove(selectedNodeInRoot); selectedNode.getParent().getChildren().remove(selectedNode); //TODO: Delete the parent if it no longer has any children. } }