private void setupTreeItem(TreeItem<Board> parentTreeItem, Board board) { TreeItem<Board> treeItem = new TreeItem<Board>(board); parentTreeItem.getChildren().add(treeItem); if (board.hasChildren()) { for (Board childBoard : board.getChildren()) { setupTreeItem(treeItem, childBoard); } } }
/** * TreeViewで板を選択する。 * * <p>仮実装で二階層まで対応 * * @param board */ public void setSelection(Board board) { TreeItem<Board> root = boardTreeView.getRoot(); for (TreeItem<Board> boardItem1 : root.getChildren()) { for (TreeItem<Board> boardItem2 : boardItem1.getChildren()) { if (boardItem2.getValue() != null && boardItem2.getValue().getId() != null && boardItem2.getValue().getId().equals(board.getId())) { boardTreeView.getSelectionModel().select(boardItem2); } } } }