本文整理了Java中javafx.scene.control.TreeView.getSelectionModel()
方法的一些代码示例,展示了TreeView.getSelectionModel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeView.getSelectionModel()
方法的具体详情如下:
包路径:javafx.scene.control.TreeView
类名称:TreeView
方法名:getSelectionModel
暂无
代码示例来源:origin: speedment/speedment
private void populateTree(ProjectProperty project) {
requireNonNull(project);
final TreeItem<DocumentProperty> root = branch(project);
hierarchy.setRoot(root);
hierarchy.getSelectionModel().select(root);
}
代码示例来源:origin: pmd/pmd
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);
}
}
代码示例来源:origin: speedment/speedment
private void prepareTree(ProjectProperty project) {
requireNonNull(project);
events.notify(new ProjectLoaded(project));
Bindings.bindContent(ui.getSelectedTreeItems(), hierarchy.getSelectionModel().getSelectedItems());
hierarchy.setCellFactory(view -> new DocumentPropertyCell(projectTreeComponent));
hierarchy.getSelectionModel().setSelectionMode(SINGLE);
populateTree(project);
}
代码示例来源:origin: pmd/pmd
private void focusNodeInTreeView(Node node) {
SelectionModel<TreeItem<Node>> selectionModel = astTreeView.getSelectionModel();
// node is different from the old one
if (selectedTreeItem == null && node != null
|| selectedTreeItem != null && !Objects.equals(node, selectedTreeItem.getValue())) {
ASTTreeItem found = ((ASTTreeItem) astTreeView.getRoot()).findItem(node);
if (found != null) {
selectionModel.select(found);
}
highlightFocusNodeParents(selectedTreeItem, found);
selectedTreeItem = found;
astTreeView.getFocusModel().focus(selectionModel.getSelectedIndex());
if (!treeViewWrapper.isIndexVisible(selectionModel.getSelectedIndex())) {
astTreeView.scrollTo(selectionModel.getSelectedIndex());
}
}
}
代码示例来源:origin: pmd/pmd
@Override
protected void updateItem(Node item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
return;
} else {
setText(item.toString() + (item.getImage() == null ? "" : " \"" + item.getImage() + "\""));
setContextMenu(buildContextMenu(item));
}
// Reclicking the selected node in the ast will scroll back to the node in the editor
this.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
if (t.getButton() == MouseButton.PRIMARY
&& getTreeView().getSelectionModel().getSelectedItem().getValue() == item) {
controller.onNodeItemSelected(item);
t.consume();
}
});
}
代码示例来源:origin: pmd/pmd
@Override
protected void beforeParentInit() {
xpathAttributesListView.setPlaceholder(new Label("No available attributes"));
EventStreams.valuesOf(scopeHierarchyTreeView.getSelectionModel().selectedItemProperty())
.filter(Objects::nonNull)
.map(TreeItem::getValue)
.filterMap(o -> o instanceof NameDeclaration, o -> (NameDeclaration) o)
.filter(nd -> !Objects.equals(nd.getNode(), selectedNode))
.subscribe(declaration -> Platform.runLater(() -> parent.onNodeItemSelected(declaration.getNode(), true)));
scopeHierarchyTreeView.setCellFactory(view -> new ScopeHierarchyTreeCell());
hideCommonAttributesProperty()
.values()
.distinct()
.subscribe(show -> displayAttributes(selectedNode));
}
代码示例来源:origin: jfoenixadmin/JFoenix
setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
setFitToHeight(true);
treeView.getSelectionModel().selectedItemProperty().addListener(observable -> {
TreeItem selectedItem = treeView.getSelectionModel().getSelectedItem();
TreeItem temp = selectedItem;
int level = treeView.getTreeItemLevel(temp) - (treeView.isShowRoot() ? 0 : 1);
代码示例来源:origin: pmd/pmd
@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());
}
代码示例来源:origin: org.copper-engine/copper-monitoring-client
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (newValue != null) {
TreeItem<DisplayWorkflowClassesModel> item = search(workflowView.getRoot(), newValue);
if (item != null) {
workflowView.getSelectionModel().select(item);
} else {
workflowView.getSelectionModel().clearSelection();
}
}
if (newValue == null) {
workflowView.getSelectionModel().clearSelection();
}
}
});
代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls
private void handleSelectionChange(Observable o) {
this.selectedItems.setAll(this.tree.getSelectionModel()
.getSelectedItems().stream().map(t -> t.getValue())
.collect(Collectors.toList()));
}
代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls
private void handleSelectionChange(Observable o) {
this.selectedItems.setAll(this.tree.getSelectionModel()
.getSelectedItems().stream().map(t -> t.getValue())
.collect(Collectors.toList()));
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
private void handleSelectionChange(Observable o) {
this.selectedItems.setAll(this.tree.getSelectionModel()
.getSelectedItems().stream().map(t -> t.getValue())
.collect(Collectors.toList()));
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls
private void handleSelectionChange(Observable o) {
this.selectedItems.setAll(this.tree.getSelectionModel()
.getSelectedItems().stream().map(t -> t.getValue())
.collect(Collectors.toList()));
}
代码示例来源:origin: com.powsybl/powsybl-gse-afs-ext-base
private ContingencyTreeCell() {
contingencyTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
setOnDragOver(this::onDragOver);
setOnDragDropped(this::onDragDropped);
}
代码示例来源:origin: com.powsybl/powsybl-gse-network-explorer
private void onDragDetected(MouseEvent event) {
Dragboard db = substationDetailedView.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
List<EquipmentInfo> listInfo = substationDetailedView.getSelectionModel().getSelectedItems().stream().map(TreeItem :: getValue).collect(Collectors.toList());
content.put(EquipmentInfo.DATA_FORMAT, listInfo);
db.setContent(content);
event.consume();
}
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
/**
* @{inheritedDoc}
*/
@Override
public synchronized <T extends GenericEvent> void handle(T e) {
super.handle(e);
if (e.isA(CoreEvent.TreePopulatedFromTemplateEvent)) {
LazyTreeItem item = (LazyTreeItem) treeView.getSelectionModel().getSelectedItem();
item.reloadChildren();
} else if (e.isA(CoreEvent.TreeFolderCreatedEvent)) {
LazyTreeItem item = (LazyTreeItem) treeView.getSelectionModel().getSelectedItem();
item.reloadChildren();
}
}
代码示例来源:origin: nl.cloudfarming.client/calendar-api
@Override
public void handle(ActionEvent t) {
TreeItem<CalendarNode> selectedItem = nodeList.getTreeView().getSelectionModel().getSelectedItem();
if (selectedItem != null) {
CalendarNode calendarNode = selectedItem.getValue();
chart.removeNode(calendarNode);
}
}
});
代码示例来源:origin: com.powsybl/powsybl-gse-afs-ext-base
private void onKeyPressed(KeyEvent e) {
if (e.getCode() == KeyCode.DELETE) {
showRemoveAlert();
} else if (e.getCode() == KeyCode.F2) {
TreeItem<Object> item = contingencyTree.getSelectionModel().getSelectedItem();
if (item.getValue() instanceof Contingency) {
rename();
}
}
}
代码示例来源:origin: org.copper-engine/copper-monitoring-client
@Override
public void handle(ActionEvent event) {
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent content = new ClipboardContent();
content.putString(treeView.getSelectionModel().getSelectedItem().getValue().displayName);
clipboard.setContent(content);
}
});
代码示例来源:origin: com.powsybl/powsybl-gse-afs-ext-base
private void rename() {
TreeItem<Object> item = contingencyTree.getSelectionModel().getSelectedItem();
Contingency contingency = (Contingency) item.getValue();
TextInputDialog dialog = new TextInputDialog(contingency.getId());
dialog.setTitle(RESOURCE_BUNDLE.getString("RenameContingency"));
dialog.setHeaderText(null);
dialog.setGraphic(null);
dialog.setContentText(RESOURCE_BUNDLE.getString("Name"));
TextField inputField = dialog.getEditor();
BooleanBinding isInvalid = Bindings.createBooleanBinding(() -> inputField.getText().equals(contingency.getId()) || inputField.getText().isEmpty(),
inputField.textProperty());
dialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty().bind(isInvalid);
Optional<String> result = dialog.showAndWait();
result.ifPresent(newName -> {
contingency.setId(newName);
contingencyTree.refresh();
saved.set(false);
});
}
内容来源于网络,如有侵权,请联系作者删除!