private void populateTree(ProjectProperty project) { requireNonNull(project); final TreeItem<DocumentProperty> root = branch(project); hierarchy.setRoot(root); hierarchy.getSelectionModel().select(root); }
/** * Refreshes the AST and returns the new compilation unit if the parse didn't fail. */ public Optional<Node> refreshAST() { String source = getText(); if (StringUtils.isBlank(source)) { astTreeView.setRoot(null); return Optional.empty(); } Optional<Node> current; try { current = astManager.updateIfChanged(source, auxclasspathClassLoader.getValue()); } catch (ParseAbortedException e) { astViewTitledPane.setTitle("Abstract syntax tree (error)"); return Optional.empty(); } current.ifPresent(this::setUpToDateCompilationUnit); return current; }
private void setUpToDateCompilationUnit(Node node) { parent.invalidateAst(); astViewTitledPane.setTitle("Abstract syntax tree"); ASTTreeItem root = ASTTreeItem.getRoot(node); astTreeView.setRoot(root); }
/** * Invalidates the info being displayed. */ private void invalidateInfo() { metricResultsListView.setItems(FXCollections.emptyObservableList()); xpathAttributesListView.setItems(FXCollections.emptyObservableList()); scopeHierarchyTreeView.setRoot(null); }
private void displayScopes(Node node, boolean focusScopeView) { // current selection TreeItem<Object> previousSelection = scopeHierarchyTreeView.getSelectionModel().getSelectedItem(); ScopeHierarchyTreeItem rootScope = ScopeHierarchyTreeItem.buildAscendantHierarchy(node); scopeHierarchyTreeView.setRoot(rootScope); if (focusScopeView && previousSelection != null) { // Try to find the node that was previously selected and focus it in the new ascendant hierarchy. // Otherwise, when you select a node in the scope tree, since focus of the app is shifted to that // node, the scope hierarchy is reset and you lose the selection - even though obviously the node // you selected is in its own scope hierarchy so it looks buggy. int maxDepth = DesignerIteratorUtil.count(DesignerIteratorUtil.parentIterator(previousSelection, true)); rootScope.tryFindNode(previousSelection.getValue(), maxDepth) .ifPresent(scopeHierarchyTreeView.getSelectionModel()::select); } }
@Override public void initialize(URL location, ResourceBundle resources) { title.setTextFill(Color.web("#45a6fc")); // TODO Use styleClass instead header.setText("Component Explorer"); final RootItem root = new RootItem(speedment); root.getChildren().addAll(components()); tree.setRoot(root); close.setOnAction(newCloseHandler()); }
@Override protected void beforeParentInit() { treeViewWrapper = new TreeViewWrapper<>(astTreeView); astTreeView.setCellFactory(treeView -> new ASTTreeCell(parent)); initializeLanguageSelector(); // languageVersionProperty() must be initialized languageVersionProperty().values() .filterMap(Objects::nonNull, LanguageVersion::getLanguage) .distinct() .subscribe(this::updateSyntaxHighlighter); languageVersionProperty().values() .filter(Objects::nonNull) .map(LanguageVersion::getShortName) .map(lang -> "Source Code (" + lang + ")") .subscribe(editorTitledPane::setTitle); EventStreams.valuesOf(astTreeView.getSelectionModel().selectedItemProperty()) .filterMap(Objects::nonNull, TreeItem::getValue) .subscribe(parent::onNodeItemSelected); codeEditorArea.plainTextChanges() .filter(t -> !t.isIdentity()) .successionEnds(AST_REFRESH_DELAY) // Refresh the AST anytime the text, classloader, or language version changes .or(auxclasspathClassLoader.changes()) .or(languageVersionProperty().changes()) .subscribe(tick -> { // Discard the AST if the language version has changed tick.ifRight(c -> astTreeView.setRoot(null)); Platform.runLater(parent::refreshAST); }); codeEditorArea.setParagraphGraphicFactory(lineNumberFactory()); }
@Override public void initialize(URL url, ResourceBundle rb) { session.setRoot(new TreeItem<String>("Session") { private boolean isFirstTimeChildren = true; @Override public ObservableList getChildren() { if (isFirstTimeChildren) { isFirstTimeChildren = false; // First getChildren() call, so we actually go off and // determine the children of the File contained in this TreeItem. super.getChildren().setAll(buildChildren(this)); } return super.getChildren(); } @Override public boolean isLeaf() { return false; } private ObservableList<TreeItem<String>> buildChildren(TreeItem<String> treeItem) { ObservableList<TreeItem<String>> children = FXCollections.observableArrayList(); children.add(new TreeItem<>(Connections.get().getURL().getHost())); return children; } }); }
private void refreshSubstationDetailView(IdAndName substationIdAndName) { if (substationIdAndName != null && substationIdAndName != LIST_BUSY) { substationDetailedView.setRoot(new TreeItem<>(TREEVIEW_BUSY)); String query = processTemplate(voltageLevelTemplate, ImmutableMap.of("substationId", substationIdAndName.getId())); queryNetwork(query, voltageLevelQueryResultListType, (List<VoltageLevelQueryResult> voltageLevelQueryResults) -> fillSubstationDetailViewWithQueryResults(substationIdAndName, voltageLevelQueryResults), substationDetailsExecutor); } else { substationDetailedView.setRoot(null); } }
private void rebuildTable(Observable o) { if (getSkinnable().getRootDirectories() == null) { this.tree.setRoot(new TreeItem<>()); } else { TreeItem<@NonNull ResourceItem> root = new TreeItem<>(); root.getChildren().setAll( getSkinnable().getRootDirectories().stream() .map((d) -> new DirTreeItem(d)) .collect(Collectors.toList())); this.tree.setRoot(root); } }
private void rebuildTable(Observable o) { if (getSkinnable().getRootDirectories() == null) { this.tree.setRoot(new TreeItem<>()); } else { TreeItem<@NonNull DirItem> root = new TreeItem<>(); root.getChildren().setAll( getSkinnable().getRootDirectories().stream() .map((d) -> new DirTreeItem(d)) .collect(Collectors.toList())); this.tree.setRoot(root); } }
private void rebuildTable(Observable o) { if (getSkinnable().getRootDirectories() == null) { this.tree.setRoot(new TreeItem<>()); } else { TreeItem<@NonNull ResourceItem> root = new TreeItem<>(); root.getChildren().setAll( getSkinnable().getRootDirectories().stream() .map((d) -> new DirTreeItem(d)) .collect(Collectors.toList())); this.tree.setRoot(root); } }
private void rebuildTable(Observable o) { if (getSkinnable().getRootDirectories() == null) { this.tree.setRoot(new TreeItem<>()); } else { TreeItem<@NonNull DirItem> root = new TreeItem<>(); root.getChildren().setAll( getSkinnable().getRootDirectories().stream() .map((d) -> new DirTreeItem(d)) .collect(Collectors.toList())); this.tree.setRoot(root); } }
treeView.setRoot(new TreeItem<DisplayableNode>(null)); treeView.setShowRoot(false); treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<DisplayableNode>>() {
view.setRoot(root); treeCache.put(outline, view);
view.setRoot(root); treeCache.put(outline, view);
private void fillSubstationDetailViewWithQueryResults(IdAndName substationIdAndName, List<VoltageLevelQueryResult> voltageLevelQueryResults) { equipmentTabs.getTabs().clear(); if (voltageLevelQueryResults != null) { TreeItem<EquipmentInfo> substationItem = new TreeItem<>(new EquipmentInfo(substationIdAndName, "SUBSTATION")); substationItem.setExpanded(true); for (VoltageLevelQueryResult voltageLevelQueryResult : voltageLevelQueryResults) { TreeItem<EquipmentInfo> voltageLevelItem = new TreeItem<>(new EquipmentInfo(voltageLevelQueryResult.getIdAndName(), "VOLTAGE_LEVEL")); substationItem.getChildren().add(voltageLevelItem); for (EquipmentInfo equipment : voltageLevelQueryResult.getEquipments()) { Node icon = getSymbol(equipment.getType()); TreeItem<EquipmentInfo> equipmentItem = new TreeItem<>(equipment, icon); voltageLevelItem.getChildren().add(equipmentItem); } voltageLevelItem.setExpanded(true); } substationDetailedView.setRoot(substationItem); } else { substationDetailedView.setRoot(null); } }
public void refresh(List<WorkflowVersion> newItems) { treeView.setShowRoot(false); TreeItem<DisplayWorkflowClassesModel> rootItem = new TreeItem<DisplayWorkflowClassesModel>(); rootItem.getChildren().addAll(groupToTreeItem(newItems)); treeView.setRoot(rootItem); treeView.setCellFactory(new Callback<TreeView<DisplayWorkflowClassesModel>, TreeCell<DisplayWorkflowClassesModel>>() { @Override public TreeCell<DisplayWorkflowClassesModel> call(TreeView<DisplayWorkflowClassesModel> listView) { return new TextFieldTreeCell<DisplayWorkflowClassesModel>(new StringConverter<DisplayWorkflowClassesModel>() { @Override public DisplayWorkflowClassesModel fromString(String string) { return null; } @Override public String toString(DisplayWorkflowClassesModel object) { return object.displayName; } }); } }); rootItem.setExpanded(true); }
treeView.setRoot(dummyRoot); treeView.setShowRoot(false);