javafx.scene.control.TreeItem Java Examples
The following examples show how to use
javafx.scene.control.TreeItem.
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: TestRunner.java From marathonv5 with Apache License 2.0 | 6 votes |
private TestTreeItem findNextFailureInChildren(TestTreeItem parent, boolean findInSibling) { TestTreeItem found = null; for (TreeItem<Test> child : parent.getChildren()) { if (child.isLeaf() && (((TestTreeItem) child).getState() == State.FAILURE || ((TestTreeItem) child).getState() == State.ERROR)) { found = (TestTreeItem) child; break; } else { found = findNextFailureInChildren((TestTreeItem) child, findInSibling); if (found != null) { break; } } } if (found == null && findInSibling) { TestTreeItem sib = (TestTreeItem) parent.nextSibling(); if (isFailure(sib)) { found = sib; } else { if (sib != null) { found = findNextFailureInChildren(sib, true); } } } return found; }
Example #2
Source File: AlarmTreeView.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** For leaf nodes, drag PV name */ private void addDragSupport() { tree_view.setOnDragDetected(event -> { final ObservableList<TreeItem<AlarmTreeItem<?>>> items = tree_view.getSelectionModel().getSelectedItems(); if (items.size() != 1) return; final AlarmTreeItem<?> item = items.get(0).getValue(); if (! (item instanceof AlarmClientLeaf)) return; final Dragboard db = tree_view.startDragAndDrop(TransferMode.COPY); final ClipboardContent content = new ClipboardContent(); content.putString(item.getName()); db.setContent(content); event.consume(); }); }
Example #3
Source File: TreeUtil.java From arma-dialog-creator with MIT License | 6 votes |
/** Checks if the given start TreeItem contains the searching {@link TreeItem} as a descendant. Checks are done recursively. @param startItem where to start searching @param searchingFor TreeItem to look for @return if startItem has the descendant searchingFor */ public static boolean hasDescendant(@NotNull TreeItem<?> startItem, @NotNull TreeItem<?> searchingFor) { if (startItem.equals(searchingFor)) { return true; } if (startItem.getChildren().size() == 0) { return false; } for (TreeItem<?> item : startItem.getChildren()) { boolean contains = hasDescendant(item, searchingFor); if (contains) { return true; } } return false; }
Example #4
Source File: WidgetTree.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Called by selection handler when selected widgets have changed, or on new model * @param widgets Widgets to select in tree */ public void setSelectedWidgets(final List<Widget> widgets) { if (! active.compareAndSet(false, true)) return; try { final MultipleSelectionModel<TreeItem<WidgetOrTab>> selection = tree_view.getSelectionModel(); selection.clearSelection(); for (Widget widget : widgets) selection.select(widget2tree.get(widget)); // If something's selected, show it. // Otherwise leave tree at current position. final int index = selection.getSelectedIndex(); if (index >= 0) tree_view.scrollTo(index); } finally { active.set(false); } }
Example #5
Source File: VirtualAssetEditorDialog.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void processOk() { super.processOk(); final VirtualResourceTree<C> resourceTree = getResourceTree(); final MultipleSelectionModel<TreeItem<VirtualResourceElement<?>>> selectionModel = resourceTree.getSelectionModel(); final TreeItem<VirtualResourceElement<?>> selectedItem = selectionModel.getSelectedItem(); if (selectedItem == null) { hide(); return; } final VirtualResourceElement<?> element = selectedItem.getValue(); final Object object = element.getObject(); final Class<C> type = getObjectsType(); if (type.isInstance(object)) { getConsumer().accept(type.cast(object)); } }
Example #6
Source File: WorkScheduleEditorController.java From OEE-Designer with MIT License | 6 votes |
private void onSelectSchedule(TreeItem<ScheduleNode> oldItem, TreeItem<ScheduleNode> newItem) throws Exception { if (newItem == null) { return; } selectedScheduleItem = newItem; // new attributes WorkSchedule selectedSchedule = getSelectedSchedule(); if (selectedSchedule == null) { return; } displayAttributes(selectedSchedule); }
Example #7
Source File: AstTreeView.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
/** * Focus the given node, handling scrolling if needed. */ @Override public void setFocusNode(final Node node, DataHolder options) { SelectionModel<TreeItem<Node>> selectionModel = getSelectionModel(); if (getRoot() == null || getRoot().getValue() == null) { return; } mapToMyTree(getRoot().getValue(), node, options.getData(CARET_POSITION)) .map(((ASTTreeItem) getRoot())::findItem) .ifPresent(found -> { // don't fire any selection event while itself setting the selected item suppressibleSelectionEvents.suspendWhile(() -> selectionModel.select(found)); }); getFocusModel().focus(selectionModel.getSelectedIndex()); if (!isIndexVisible(selectionModel.getSelectedIndex())) { scrollTo(selectionModel.getSelectedIndex()); } }
Example #8
Source File: OpcDaBrowserController.java From OEE-Designer with MIT License | 6 votes |
private void populateAvailableTags(TreeItem<OpcDaTagTreeBranch> selectedItem) { try { clearTagData(); availableTags.clear(); if (selectedItem != null && selectedItem.isLeaf()) { // fill in the possible tags OpcDaTagTreeBranch selectedNode = selectedItem.getValue(); OpcDaTreeBrowser treeBrowser = getApp().getOpcDaClient().getTreeBrowser(); Collection<OpcDaBrowserLeaf> tags = treeBrowser.getLeaves(selectedNode); availableTags.clear(); for (OpcDaBrowserLeaf tag : tags) { if (!monitoredItemIds.contains(tag.getItemId())) { availableTags.add(tag); } } } lvAvailableTags.refresh(); } catch (Exception e) { AppUtils.showErrorDialog(e); } }
Example #9
Source File: SyncTreeItem.java From PeerWasp with MIT License | 6 votes |
private void handleWhenInProgress(ProgressState eventState) { switch(eventState){ case SUCCESSFUL: for(TreeItem<PathItem> child : getChildren()){ if(child instanceof SyncTreeItem){ SyncTreeItem castedChild = (SyncTreeItem) child; if(castedChild.getProgressState() == ProgressState.IN_PROGRESS){ return; } } } setProgressState(eventState); break; default: //ignore } }
Example #10
Source File: TreeViewFactory.java From ariADDna with Apache License 2.0 | 6 votes |
/** * Generate treeView of file items * TODO: work with VUFS items * * @return tree view */ public TreeView<SimpleTreeElement> getSimple() { TreeView<SimpleTreeElement> tree = new TreeView<>(); TreeItem<SimpleTreeElement> root = new TreeItem<>(new SimpleTreeElement("root", 0)); TreeItem<SimpleTreeElement> outer1 = makeBranch(new SimpleTreeElement("Folder1", 1), root); TreeItem<SimpleTreeElement> outer2 = makeBranch(new SimpleTreeElement("Documents", 2), root); TreeItem<SimpleTreeElement> inner1; TreeItem<SimpleTreeElement> inner2; makeBranch(new SimpleTreeElement("MyFotos", 3), outer1); makeBranch(new SimpleTreeElement("OtherFiles", 4), outer1); makeBranch(new SimpleTreeElement("WorkFiles", 5), root); makeBranch(new SimpleTreeElement("Projects", 6), root); tree.setRoot(root); tree.setPrefWidth(200); setTreeCellFactory(tree); tree.setShowRoot(false); return tree; }
Example #11
Source File: FilesRedundancyResultsController.java From MyBox with Apache License 2.0 | 6 votes |
@FXML public void exceptLastAction() { isSettingValues = true; TreeItem<FileInformation> rootItem = filesTreeView.getRoot(); List<TreeItem<FileInformation>> digests = rootItem.getChildren(); if (digests == null || digests.isEmpty()) { filesTreeView.setRoot(null); return; } rootItem.getValue().setSelected(false); for (TreeItem<FileInformation> digest : digests) { digest.getValue().setSelected(false); List<TreeItem<FileInformation>> files = digest.getChildren(); if (files == null || files.isEmpty()) { continue; } for (int i = 0; i < files.size() - 1; ++i) { files.get(i).getValue().setSelected(true); } files.get(files.size() - 1).getValue().setSelected(false); } filesTreeView.refresh(); isSettingValues = false; checkSelection(); }
Example #12
Source File: RootController.java From BetonQuest-Editor with GNU General Public License v3.0 | 6 votes |
@FXML public void select(MouseEvent event) { try { TreeItem<String> selected = tree.getSelectionModel().getSelectedItem(); if (event.getClickCount() != 2 || selected == null || !selected.isLeaf()) { return; } BetonQuestEditor instance = BetonQuestEditor.getInstance(); PackageSet set = instance.getSet(selected.getParent().getValue()); if (set == null) { return; } QuestPackage pack = set.getPackage(selected.getValue()); if (pack == null) { return; } instance.display(pack); hide(); } catch (Exception e) { ExceptionController.display(e); } }
Example #13
Source File: ModFuncContextMenu.java From erlyberly with GNU General Public License v3.0 | 6 votes |
private void onExportedFunctionTrace(ActionEvent e) { TreeItem<ModFunc> selectedItem = selectedTreeItemProperty().get(); if(selectedItem == null) return; if(selectedItem.getValue() == null) return; if(!selectedItem.getValue().isModule()) selectedItem = selectedItem.getParent(); // get all the functions we may trace HashSet<ModFunc> funcs = new HashSet<ModFunc>(); recurseModFuncItems(selectedItem, funcs); // filter the exported ones HashSet<ModFunc> exported = new HashSet<ModFunc>(); for (ModFunc modFunc : funcs) { if(modFunc.isExported()) { exported.add(modFunc); } } // trace 'em toggleTraceMod(exported); }
Example #14
Source File: FileBrowseService.java From AsciidocFX with Apache License 2.0 | 6 votes |
private void focusFoundItem(TreeItem<Item> searchFoundItem) { if (Objects.nonNull(searchFoundItem)) { TreeView<Item> fileSystemView = controller.getFileSystemView(); threadService.runActionLater(() -> { fileSystemView.getSelectionModel().clearSelection(); int selectedIndex = findIndex(searchFoundItem); fileSystemView.getSelectionModel().select(searchFoundItem); fileSystemView.scrollTo(selectedIndex); TreeItem<Item> parent = searchFoundItem.getParent(); if (Objects.nonNull(parent)) { if (!parent.isExpanded()) { parent.setExpanded(true); } } }, true); } }
Example #15
Source File: RenameAction.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** @param node Node used to position confirmation dialog * @param item Item to rename */ public RenameAction(final Node node, final TreeItem<FileInfo> item) { super(Messages.Rename, ImageCache.getImageView(ImageCache.class, "/icons/name.png")); setOnAction(event -> { final File file = item.getValue().file; final TextInputDialog prompt = new TextInputDialog(file.getName()); prompt.setTitle(getText()); prompt.setHeaderText(Messages.RenameHdr); DialogHelper.positionDialog(prompt, node, 0, 0); final String new_name = prompt.showAndWait().orElse(null); if (new_name == null) return; JobManager.schedule(Messages.RenameJobName + item.getValue(), monitor -> { Files.move(file.toPath(), (new File(file.getParentFile(), new_name)).toPath(), StandardCopyOption.REPLACE_EXISTING); final FileTreeItem parent = (FileTreeItem)item.getParent(); Platform.runLater(() -> parent.forceRefresh()); }); }); }
Example #16
Source File: ProfilerInfoBox.java From chart-fx with Apache License 2.0 | 6 votes |
private ChangeListener<? super DebugLevel> updateSelectedCrumbLevelListener(final TreeItem<VBox> fpsItem, final TreeItem<VBox> cpuItem, final TreeItem<VBox> versionItem) { return (ch, o, n) -> { switch (getDebugLevel()) { case FRAMES_PER_SECOND: setSelectedCrumb(fpsItem); break; case CPU_LOAD: setSelectedCrumb(cpuItem); break; case VERSION: setSelectedCrumb(versionItem); break; case NONE: default: setSelectedCrumb(treeRoot); break; } }; }
Example #17
Source File: AttributeSetMenu.java From MythRedisClient with Apache License 2.0 | 6 votes |
/** * 点击处理方法. * * @param treeView treeView */ @Override protected void setAction(TreeView treeView) { super.setOnAction( (event) -> { TreeItem<Label> item = (TreeItem) treeView.getSelectionModel().getSelectedItem(); String flag = item.getValue().getAccessibleHelp(); if ("link".equals(flag)) { String poolId = item.getValue().getAccessibleText(); ConnectPanel connectPanel = new ConnectPanel(); connectPanel.isNewLink(false); connectPanel.showConnectPanel(poolId); } } ); }
Example #18
Source File: SyncSettingsController.java From ariADDna with Apache License 2.0 | 6 votes |
/** * Native init method. * Create VUFS folders tree view * @param location * @param resources */ @Override public void initialize(URL location, ResourceBundle resources) { //TODO: replace to getting elements from Repository CheckBoxTreeItem<String> root = new CheckBoxTreeItem<>("Root"); root.setExpanded(true); CheckBoxTreeItem<String> folder1 = new CheckBoxTreeItem<>("Folder1"); folder1.getChildren().addAll( new CheckBoxTreeItem<>("MyFoto"), new CheckBoxTreeItem<>("OtherFiles") ); root.getChildren().addAll( folder1, new CheckBoxTreeItem<>("Documents"), new CheckBoxTreeItem<>("WorkFiles"), new CheckBoxTreeItem<>("Projects")); // Create the CheckTreeView with the data final CheckTreeView<String> checkTreeView = new CheckTreeView<>(root); checkTreeView.getCheckModel().getCheckedItems() .addListener((ListChangeListener<TreeItem<String>>) c -> { System.out.println(checkTreeView.getCheckModel().getCheckedItems()); }); checkTreeView.setId("sync-tree-view"); container.getChildren().add(checkTreeView); }
Example #19
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 6 votes |
protected String getPathText(List<TreeItem<?>> treePath) { // We should be getting the *text* from the tree cell. We need to figure // out how to construct // a tree cell for a item that is not visible // Set<Node> nodes = treeView.lookupAll(".tree-cell"); // for (Node node : nodes) { // TreeCell<?> cell = (TreeCell<?>) node; // if (lastPathComponent == cell.getTreeItem()) { // RFXComponent cellComponent = new // RFXComponentFactory(omapConfig).findRawRComponent(node, null, // recorder); // return cellComponent.getText(); // } // } TreeItem<?> lastPathComponent = treePath.get(treePath.size() - 1); return getTreeItemText(lastPathComponent); }
Example #20
Source File: DnDCellFactory.java From milkman with MIT License | 6 votes |
private void dragOver(DragEvent event, TreeCell<Node> treeCell, TreeView<Node> treeView) { if (!event.getDragboard().hasContent(JAVA_FORMAT)) return; TreeItem<Node> thisItem = treeCell.getTreeItem(); // can't drop on itself if (draggedItem == null || thisItem == null || thisItem == draggedItem) return; // ignore if this is the root if (draggedItem.getParent() == null) { clearDropLocation(); return; } event.acceptTransferModes(TransferMode.MOVE); if (!Objects.equals(dropZone, treeCell)) { clearDropLocation(); this.dropZone = treeCell; dropZone.setStyle(DROP_HINT_STYLE); } }
Example #21
Source File: DataSourceTreeViewInit.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
/** * 刷新数据源下的 table * <p> * 对table */ private void refreshDataSource(TreeView<DataItem> treeViewDataSource) { TreeItem<DataItem> dataSourceTreeItem = treeViewDataSource.getSelectionModel().getSelectedItem(); DataSource dataSource = (DataSource) dataSourceTreeItem.getValue(); List<Table> tables = tableService.refreshTables(dataSource); if (!tables.isEmpty()) { ObservableList<TreeItem<DataItem>> children = dataSourceTreeItem.getChildren(); children.remove(0, children.size()); tables.forEach(table -> { TreeItem<DataItem> tableTreeItem = TreeUtils.add2Tree(table, dataSourceTreeItem); tableTreeItem.setGraphic(new ImageView("/image/table.png")); }); } // 关闭右边的 Border 展示 this.rightBorderShowClose(dataSource); }
Example #22
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private String getTreeTableItemText(TreeTableView<?> treeTableView, TreeItem<?> lastPathComponent) { @SuppressWarnings("rawtypes") TreeTableColumn treeTableColumn = treeTableView.getTreeColumn(); if (treeTableColumn == null) { treeTableColumn = treeTableView.getColumns().get(0); } ObservableValue<?> cellObservableValue = treeTableColumn.getCellObservableValue(lastPathComponent); String original = cellObservableValue.getValue().toString(); String itemText = original; int suffixIndex = 0; TreeItem<?> parent = lastPathComponent.getParent(); if (parent == null) return itemText; ObservableList<?> children = parent.getChildren(); for (int i = 0; i < children.indexOf(lastPathComponent); i++) { TreeItem<?> child = (TreeItem<?>) children.get(i); cellObservableValue = treeTableColumn.getCellObservableValue(child); String current = cellObservableValue.getValue().toString(); if (current.equals(original)) { itemText = String.format("%s(%d)", original, ++suffixIndex); } } return itemText; }
Example #23
Source File: ConfigurationUIController.java From jace with GNU General Public License v2.0 | 5 votes |
private void getExpandedNodes(String prefix, TreeItem<ConfigNode> root, Set<String> expanded) { if (root == null) return; root.getChildren().stream().filter((item) -> (item.isExpanded())).forEach((item) -> { String name = prefix+item.toString(); expanded.add(name); getExpandedNodes(name+DELIMITER, item, expanded); }); }
Example #24
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 5 votes |
public String rowToPath(int row) { TreeView<?> treeView = (TreeView<?>) getComponent(); TreeItem<?> treeItem = treeView.getTreeItem(row); if (treeItem == null) { throw new RuntimeException("Trying to create a tree item for row " + row + " which is invalid"); } return getTextForNode(treeView, treeItem); }
Example #25
Source File: TreeHelper.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Expand path from root to given node * * @param node Node to expand */ public static void expandItemPath(final TreeItem<?> node) { TreeItem<?> parent = node.getParent(); while (parent != null) { parent.setExpanded(true); parent = parent.getParent(); } }
Example #26
Source File: WorkScheduleEditorController.java From OEE-Designer with MIT License | 5 votes |
private void displaySchedules() throws Exception { getRootScheduleItem().getChildren().clear(); List<WorkSchedule> schedules = PersistenceService.instance().fetchWorkSchedules(); Collections.sort(schedules); for (WorkSchedule schedule : schedules) { TreeItem<ScheduleNode> scheduleItem = new TreeItem<>(new ScheduleNode(schedule)); resetGraphic(scheduleItem); getRootScheduleItem().getChildren().add(scheduleItem); } tvSchedules.refresh(); }
Example #27
Source File: IconEditorFactory.java From constellation with Apache License 2.0 | 5 votes |
private void addNode(TreeItem<IconNode> item, IconNode node) { if (node.getChildren().length == 0) { return; } for (IconNode childNode : node.getChildren()) { final TreeItem<IconNode> childItem = new TreeItem<>(childNode); item.getChildren().add(childItem); addNode(childItem, childNode); } }
Example #28
Source File: QuestProgress.java From logbook-kai with MIT License | 5 votes |
private TreeItem<String> buildFilterLeaf(FleetCondition condition) { TreeItem<String> item = new TreeItem<>(condition.toString()); setFilterListIcon(item); if (condition.getConditions() != null) { if (condition.getConditions().size() == 1 && !condition.getOperator().startsWith("N")) { item.setValue(condition.getConditions().get(0).toString()); } else { for (FleetCondition subcondition : condition.getConditions()) { item.getChildren().add(this.buildFilterLeaf(subcondition)); } } } return item; }
Example #29
Source File: MaterialSelectorController.java From OEE-Designer with MIT License | 5 votes |
private TreeItem<MaterialNode> getRootMaterialItem() throws Exception { if (tvMaterials.getRoot() == null) { Material rootMaterial = new Material(); rootMaterial.setName(Material.ROOT_MATERIAL_NAME); tvMaterials.setRoot(new TreeItem<>(new MaterialNode(rootMaterial))); } return tvMaterials.getRoot(); }
Example #30
Source File: QuestProgress.java From logbook-kai with MIT License | 5 votes |
void setQuest(AppQuest quest) { this.quest = quest; this.name.setText(quest.getQuest().getTitle() + " 期限:" + quest.getExpire()); this.info.setText(quest.getQuest().getDetail().replaceAll("<br>", "")); this.condition.setRoot(new TreeItem<String>("読み込み中")); this.load(); }