List of usage examples for javafx.scene.control TreeItem expandedProperty
public final BooleanProperty expandedProperty()
From source file:eu.fthevenet.binjr.sources.jrds.adapters.JrdsDataAdapter.java
private void attachNode(TreeItem<TimeSeriesBinding<Double>> tree, String id, Map<String, JsonJrdsItem> nodes) throws DataAdapterException { JsonJrdsItem n = nodes.get(id);/* w w w. j av a 2 s. c o m*/ String currentPath = normalizeId(n.id); TreeItem<TimeSeriesBinding<Double>> newBranch = new TreeItem<>( bindingFactory.of(tree.getValue().getTreeHierarchy(), n.name, currentPath, this)); if (JRDS_FILTER.equals(n.type)) { // add a dummy node so that the branch can be expanded newBranch.getChildren().add(new TreeItem<>(null)); // add a listener that will get the treeview filtered according to the selected filter/tag newBranch.expandedProperty().addListener(new FilteredViewListener(n, newBranch)); } else { if (n.children != null) { for (JsonJrdsItem.JsonTreeRef ref : n.children) { attachNode(newBranch, ref._reference, nodes); } } else { // add a dummy node so that the branch can be expanded newBranch.getChildren().add(new TreeItem<>(null)); // add a listener so that bindings for individual datastore are added lazily to avoid // dozens of individual call to "graphdesc" when the tree is built. newBranch.expandedProperty().addListener(new GraphDescListener(currentPath, newBranch, tree)); } } tree.getChildren().add(newBranch); }
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 ww w .j av 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:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java
/** * Recursive helper method to load projects from configuration files. *///w ww. j a va 2 s . co m private void loadProjectsRecursivelyFromXMLFiles(final TreeItem<FXICCWrapper> root, List<InformationalConfigurationContent> availableProjectConfigurations) { int count = 0; String path = Roddy.getApplicationProperty(RunMode.UI, RoddyUIController.APP_PROPERTY_LAST_OPEN_PROJECT_PATH, ""); for (InformationalConfigurationContent icc : availableProjectConfigurations) { FXICCWrapper fpw = new FXICCWrapper(icc, count++); TreeItem<FXICCWrapper> newItem = new TreeItem<>(fpw); root.getChildren().add(newItem); try { Map<String, String> analyses = fpw.getAnalyses(); for (String analysisID : analyses.keySet()) { FXICCWrapper fpwAnalysis = new FXICCWrapper(icc, analysisID, count++); newItem.getChildren().add(new TreeItem<>(fpwAnalysis)); } loadProjectsRecursivelyFromXMLFiles(newItem, icc.getSubContent()); } catch (Exception e) { e.printStackTrace(); } } //Add an expand listener to the topmost nodes if (root.getValue() != null) { for (final TreeItem<FXICCWrapper> treeItem : root.getChildren()) { treeItem.setExpanded(true); } return; } for (final TreeItem<FXICCWrapper> treeItem : root.getChildren()) { treeItem.expandedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean newValue) { if (!newValue) return; //Upon expand close all other nodes. for (TreeItem<FXICCWrapper> sister : root.getChildren()) { if (treeItem == sister) { Roddy.setApplicationProperty(RunMode.UI, RoddyUIController.APP_PROPERTY_LAST_OPEN_PROJECT_PATH, treeItem.getValue().getID()); } else { sister.setExpanded(false); } } } }); if (treeItem.getValue().getID().equals(path)) treeItem.setExpanded(true); } }
From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java
public void reload(JEVisClass jclass) { if (jclass != null) { TreeItem newItem = buildItem(jclass); newItem.expandedProperty().setValue(false); newItem.expandedProperty().setValue(true); }//from w w w .j a v a 2 s . co m }