List of usage examples for javafx.scene.control TreeItem getValue
public final T getValue()
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private void setSelectedMissingStatus(final boolean status) { for (TreeItem<TMAEntry> item : table.getSelectionModel().getSelectedItems()) { item.getValue().setMissing(status); }/*from ww w . j a va 2 s. c o m*/ // Refresh the table data if necessary if (skipMissingCoresProperty.get()) { table.getSelectionModel().clearSelection(); refreshTableData(); } else table.refresh(); }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
/** * Recursively search for a TreeItem, based upon the TMAEntry it represents. * /*from w w w . j a v a 2 s.c o m*/ * @param item * @param entry * @return */ private TreeItem<TMAEntry> getItem(final TreeItem<TMAEntry> item, final TMAEntry entry) { if (item == null) return null; if (item.getValue() == entry) return item; for (TreeItem<TMAEntry> item2 : item.getChildren()) { TreeItem<TMAEntry> found = getItem(item2, entry); if (found != null) return found; } return null; }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane createSidePane() { BorderPane pane = new BorderPane(); TabPane tabPane = new TabPane(); kmDisplay = new KaplanMeierDisplay(null, null, null, null); BorderPane paneKaplanMeier = new BorderPane(); paneKaplanMeier.setCenter(kmDisplay.getView()); paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10)); // comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty()); comboMainMeasurement.setMaxWidth(Double.MAX_VALUE); comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc.")); GridPane kmTop = new GridPane(); kmTop.add(new Label("Score"), 0, 0); kmTop.add(comboMainMeasurement, 1, 0); kmTop.add(new Label("Survival type"), 0, 1); kmTop.add(comboSurvival, 1, 1);//from w w w . java 2s.c om comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)")); comboSurvival.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS); GridPane.setHgrow(comboSurvival, Priority.ALWAYS); kmTop.setHgap(5); paneKaplanMeier.setTop(kmTop); // kmDisplay.setOrientation(Orientation.VERTICAL); histogramDisplay = new HistogramDisplay(model, false); comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshCombo(); histogramDisplay.showHistogram(n); updateSurvivalCurves(); }); comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshHistogram(); scatterPane.updateChart(); updateSurvivalCurves(); }); comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { updateSurvivalCurves(); }); // Create a Tab for showing images BorderPane paneImages = new BorderPane(); CheckBox cbShowOverlay = new CheckBox("Show overlay"); imageAvailability.addListener((c, v, n) -> { if (n == ImageAvailability.OVERLAY_ONLY) cbShowOverlay.setSelected(true); else if (n == ImageAvailability.IMAGE_ONLY) cbShowOverlay.setSelected(false); cbShowOverlay.setDisable(n != ImageAvailability.BOTH); }); ListView<TMAEntry> listImages = new ListView<>(); listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache)); listImages.widthProperty().addListener((v, o, n) -> listImages.refresh()); listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;"); table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> { List<TMAEntry> entries = new ArrayList<>(); for (TreeItem<TMAEntry> item : e.getList()) { if (item.getChildren().isEmpty()) { if (item.getValue().hasImage() || item.getValue().hasOverlay()) entries.add(item.getValue()); } else { for (TreeItem<TMAEntry> item2 : item.getChildren()) { if (item2.getValue().hasImage() || item2.getValue().hasOverlay()) entries.add(item2.getValue()); } } listImages.getItems().setAll(entries); } }); cbShowOverlay.setAlignment(Pos.CENTER); cbShowOverlay.setMaxWidth(Double.MAX_VALUE); cbShowOverlay.setPadding(new Insets(5, 5, 5, 5)); cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh()); paneImages.setCenter(listImages); paneImages.setTop(cbShowOverlay); // Determine visibility based upon whether there are any images to show // Tab tabImages = new Tab("Images", paneImages); ScrollPane scrollPane = new ScrollPane(paneKaplanMeier); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); Tab tabSurvival = new Tab("Survival", scrollPane); tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()), // tabImages, new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()), tabSurvival); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); // if (imageAvailability.get() != ImageAvailability.NONE) // tabPane.getTabs().add(1, tabImages); // // imageAvailability.addListener((c, v, n) -> { // if (n == ImageAvailability.NONE) // tabPane.getTabs().remove(tabImages); // else if (!tabPane.getTabs().contains(tabImages)) // tabPane.getTabs().add(1, tabImages); // }); // tabSurvival.visibleProperty().bind( // Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns) // ); pane.setCenter(tabPane); pane.setMinWidth(350); return pane; }
From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java
/** * Recursive helper method to load projects from configuration files. *///from ww w. j ava 2s .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.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
@Override public void expandNode(final Object node) { scrollNodeToVisible(node);//from www .ja v a 2s. c om Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("expandNode", //$NON-NLS-1$ new Callable<Object>() { @Override public Object call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; TreeTableView<?> treeTable = getTree(); List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>() .getInstancesOf(treeTable, TreeTableCell.class); for (TreeTableCell<?, ?> treeTableCell : cells) { // Nullchecks because of the virtual flow cells // are created which might not be associated // with a row or an item TreeTableRow<?> ttRow = treeTableCell.getTreeTableRow(); if (ttRow == null) { continue; } TreeItem<?> checkItem = ttRow.getTreeItem(); if (checkItem == null) { continue; } if (item != null && checkItem.equals(item) && !item.isExpanded()) { return treeTableCell.getTreeTableRow().getDisclosureNode(); } } return null; } }); if (result != null) { getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1)); } EventThreadQueuerJavaFXImpl.invokeAndWait("expandNodeCheckIfExpanded", //$NON-NLS-1$ new Callable<Void>() { @Override public Void call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (!getTree().isDisabled() && !item.isExpanded()) { log.warn("Expand node fallback used for: " //$NON-NLS-1$ + item.getValue()); item.setExpanded(true); } return null; } }); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
@Override public void collapseNode(final Object node) { scrollNodeToVisible(node);/*ww w .j a v a 2 s . c om*/ Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNode", //$NON-NLS-1$ new Callable<Object>() { @Override public Object call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; TreeTableView<?> treeTable = getTree(); List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>() .getInstancesOf(treeTable, TreeTableCell.class); for (TreeTableCell<?, ?> treeTableCell : cells) { // Nullchecks because of the virtual flow cells // are created which might not be associated // with a row or an item TreeTableRow<?> ttRow = treeTableCell.getTreeTableRow(); if (ttRow == null) { continue; } TreeItem<?> checkItem = ttRow.getTreeItem(); if (checkItem == null) { continue; } if (item != null && checkItem.equals(item) && item.isExpanded()) { return treeTableCell.getTreeTableRow().getDisclosureNode(); } } return null; } }); if (result != null) { getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1)); } EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNodeCheckIfExpanded", //$NON-NLS-1$ new Callable<Void>() { @Override public Void call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (!getTree().isDisabled() && item.isExpanded()) { log.warn("Expand node fallback used for: " //$NON-NLS-1$ + item.getValue()); item.setExpanded(true); } return null; } }); }
From source file:musicmetadatak1009705.FolderTreeView.java
private TreeItem<File> createNode(final File f) { return new TreeItem<File>(f) { private boolean isLeaf; private boolean isFirstTimeChildren = true; private boolean isFirstTimeLeaf = true; @Override// w w w. j ava 2 s. c o m public ObservableList<TreeItem<File>> getChildren() { if (isFirstTimeChildren) { isFirstTimeChildren = false; super.getChildren().setAll(buildChildren(this)); } return super.getChildren(); } @Override public boolean isLeaf() { if (isFirstTimeLeaf) { isFirstTimeLeaf = false; File f = (File) getValue(); isLeaf = f.isFile(); } return isLeaf; } private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) { File f = TreeItem.getValue(); if (f == null) { return FXCollections.emptyObservableList(); } if (f.isFile()) { return FXCollections.emptyObservableList(); } File[] files = f.listFiles(); if (files != null) { ObservableList<TreeItem<File>> children = FXCollections.observableArrayList(); for (File childFile : files) { //System.out.println("Adding " + childFile.getAbsolutePath()); if (childFile.isDirectory()) { children.add(createNode(childFile)); } } return children; } return FXCollections.emptyObservableList(); } }; }
From source file:jduagui.Controller.java
private TreeItem<File> createNode(final File f) { return new TreeItem<File>(f) { private boolean isLeaf; private boolean isFirstTimeChildren = true; private boolean isFirstTimeLeaf = true; @Override/*from w w w. j a v a 2 s . c o m*/ public ObservableList<TreeItem<File>> getChildren() { if (isFirstTimeChildren) { isFirstTimeChildren = false; super.getChildren().setAll(buildChildren(this)); } return super.getChildren(); } @Override public boolean isLeaf() { if (isFirstTimeLeaf) { isFirstTimeLeaf = false; File f = (File) getValue(); isLeaf = f.isFile(); } return isLeaf; } private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) { File f = TreeItem.getValue(); if (f != null && f.isDirectory() && (!f.getAbsolutePath().equals("/proc/"))) { File[] files = f.listFiles(); if (files != null) { ObservableList<TreeItem<File>> children = FXCollections.observableArrayList(); for (File childFile : files) { children.add(createNode(childFile)); } return children; } } return FXCollections.emptyObservableList(); } }; }