javafx.scene.control.TreeTablePosition Java Examples
The following examples show how to use
javafx.scene.control.TreeTablePosition.
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: EditableTreeTable.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
/** * @return the elements corresponding to the active cell */ public List<E> getSelectedElements() { ObservableList<TreeTablePosition<EditableTreeTableLineItem<Wrapper<E>>, ?>> selectedcells = treetableview .getSelectionModel().getSelectedCells(); if (selectedcells.size() == 1) { TreeTablePosition<EditableTreeTableLineItem<Wrapper<E>>, ?> selectedposition = selectedcells.get(0); TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, ?> tablecolumn = selectedposition.getTableColumn(); if (tablecolumn instanceof EditableTreeTableValueColumn) { @SuppressWarnings({ "unchecked", "rawtypes" }) EditableTreeTableValueColumn<E, ?, ?> tablecolumnparsed = (EditableTreeTableValueColumn) tablecolumn; TreeItem<EditableTreeTableLineItem<Wrapper<E>>> treeitem = selectedposition.getTreeItem(); EditableTreeTableLineItem<Wrapper<E>> rowdata = treeitem.getValue(); ArrayList<Wrapper<E>> filteredvalues = tablecolumnparsed.columngrouping.filterItems(rowdata, tablecolumnparsed.titlekey); ArrayList<E> returnedvalues = new ArrayList<E>(); for (int i = 0; i < filteredvalues.size(); i++) { returnedvalues.add(filteredvalues.get(i).getPayload()); } return returnedvalues; } } return new ArrayList<E>(); }
Example #2
Source File: EditableTreeTable.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
/** * generates a listener to manage * <ul> * <li>on key pressed, edition starts</li> * <li>delete removes content from the cell</li> * </ul> */ private void generateEditionListener() { treetableview.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { KeyCode keyCode = event.getCode(); logger.finest(" > Key event on table " + keyCode); TreeTablePosition< EditableTreeTableLineItem<Wrapper<E>>, ?> focusedcell = treetableview.getFocusModel().getFocusedCell(); if (treetableview.getEditingCell() != null) { logger.finest(" >>Discard event as editing cell active"); } else { if (keyCode == KeyCode.DELETE || keyCode == KeyCode.BACK_SPACE) { logger.finest(" > Delete detected "); TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, ?> column = focusedcell.getTableColumn(); if (column instanceof EditableTreeTableValueColumn) { @SuppressWarnings("unchecked") EditableTreeTableValueColumn< E, ?, ?> parsedcolumn = (EditableTreeTableValueColumn<E, ?, ?>) column; TreeItem<EditableTreeTableLineItem<Wrapper<E>>> treeitem = focusedcell.getTreeItem(); parsedcolumn.clear(treeitem.getValue()); } } if (keyCode.isLetterKey() || keyCode.isDigitKey() || keyCode == KeyCode.DECIMAL || keyCode == KeyCode.SPACE) { logger.finest(" > Detected real content"); treetableview.edit(focusedcell.getRow(), focusedcell.getTableColumn()); } } } }); }
Example #3
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 5 votes |
public String getTreeTableSelection(TreeTableView<?> treeTableView) { TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel(); ObservableList<Integer> selectedIndices = selectionModel.getSelectedIndices(); ObservableList<?> selectedCells = selectionModel.getSelectedCells(); int rowCount = treeTableView.getExpandedItemCount(); int columnCount = treeTableView.getColumns().size(); if (selectedIndices.size() == 0 || selectedCells.size() == 0) { return ""; } else if (!selectionModel.isCellSelectionEnabled() && selectedIndices.size() == treeTableView.getExpandedItemCount() || selectionModel.isCellSelectionEnabled() && selectedCells.size() == rowCount * columnCount) { return "all"; } else if (!selectionModel.isCellSelectionEnabled()) { return getTreeTableRowSelectionText(treeTableView, selectionModel.getSelectedItems()); } else { int[] rows = new int[selectedCells.size()]; int[] columns = new int[selectedCells.size()]; JSONObject cells = new JSONObject(); JSONArray value = new JSONArray(); for (int i = 0; i < selectedCells.size(); i++) { TreeTablePosition<?, ?> cell = (TreeTablePosition<?, ?>) selectedCells.get(i); rows[i] = cell.getRow(); columns[i] = cell.getColumn(); List<String> cellValue = new ArrayList<>(); cellValue.add(getTreeTableNodePath(treeTableView, selectionModel.getModelItem(cell.getRow()))); cellValue.add(getTreeTableColumnName(treeTableView, cell.getColumn())); value.put(cellValue); } cells.put("cells", value); return cells.toString(); } }
Example #4
Source File: RFXTreeTableView.java From marathonv5 with Apache License 2.0 | 5 votes |
public RFXTreeTableView(Node source, JSONOMapConfig omapConfig, Point2D point, IJSONRecorder recorder) { super(source, omapConfig, point, recorder); TreeTableView<?> treeTableView = (TreeTableView<?>) source; if (source == null) { return; } if (treeTableView.getEditingCell() != null) { TreeTablePosition<?, ?> editingCell = treeTableView.getEditingCell(); row = editingCell.getRow(); column = editingCell.getColumn(); } else { if (point != null) { column = getTreeTableColumnAt(treeTableView, point); row = getTreeTableRowAt(treeTableView, point); } else { ObservableList<?> selectedCells = treeTableView.getSelectionModel().getSelectedCells(); for (Object cell : selectedCells) { TreeTablePosition<?, ?> tablePosition = (TreeTablePosition<?, ?>) cell; column = tablePosition.getColumn(); row = tablePosition.getRow(); } } } cellInfo = getTreeTableCellText(treeTableView, row, column); if (row == -1 || column == -1) { row = column = -1; } }
Example #5
Source File: EditableTreeTable.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
/** * @return the tree table view */ public Node getNode() { treetableview = new TreeTableView<EditableTreeTableLineItem<Wrapper<E>>>(); treetableview.setEditable(true); treetableview.getSelectionModel().setCellSelectionEnabled(true); generateTree(); generateRootColumn(); generateEditionListener(); for (int i = 0; i < this.columngroups.size(); i++) { ColumnGroup<E> thiscolumngroup = this.columngroups.get(i); thiscolumngroup.preProcess(payload); List<TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, ?>> columnsforgroup = thiscolumngroup .generateColumns(); logger.finest(" ---- Processing columngroup " + i + ", class = " + thiscolumngroup.getClass().getName() + " columncount=" + (columnsforgroup != null ? columnsforgroup.size() : "null")); if (columnsforgroup != null) for (int j = 0; j < columnsforgroup.size(); j++) { TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, ?> column = columnsforgroup.get(j); logger.finest(" ----> processing column " + j + " inside columngroup, class = " + column.getClass() + ", title = " + column.getText()); treetableview.getColumns().add(column); } } expandall(treetableview.getRoot(), 0); resize(); if (this.defaultisreadonly) treetableview.setEditable(false); treetableview.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (treetableview.isEditable()) { logger.fine("Sink event as editable mode"); } else { if (event.getClickCount() > 1 && (event.getButton().equals(MouseButton.PRIMARY))) { logger.fine(" >>> Proper Event"); if (readonlyactioneventhandler != null) { ObservableList< TreeTablePosition< EditableTreeTableLineItem<Wrapper<E>>, ?>> selectedcells = treetableview.getSelectionModel().getSelectedCells(); if (selectedcells.size() == 1) { TreeTablePosition< EditableTreeTableLineItem<Wrapper<E>>, ?> selectedposition = selectedcells.get(0); TreeTableColumn< EditableTreeTableLineItem<Wrapper<E>>, ?> tablecolumn = selectedposition.getTableColumn(); if (tablecolumn instanceof EditableTreeTableValueColumn) { if (fireonlyifoneitem) { @SuppressWarnings({ "unchecked", "rawtypes" }) EditableTreeTableValueColumn< E, ?, ?> tablecolumnparsed = (EditableTreeTableValueColumn) tablecolumn; TreeItem<EditableTreeTableLineItem<Wrapper<E>>> treeitem = selectedposition .getTreeItem(); EditableTreeTableLineItem<Wrapper<E>> rowdata = treeitem.getValue(); ArrayList<Wrapper<E>> filteredvalues = tablecolumnparsed.columngrouping .filterItems(rowdata, tablecolumnparsed.titlekey); if (filteredvalues.size() == 1) readonlyactioneventhandler.handle(event); } else { readonlyactioneventhandler.handle(event); } } } } } } } }); return treetableview; }
Example #6
Source File: FeatureTableFX.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unchecked") private void editFocusedCell() { TreeTablePosition<ModularFeatureListRow, ?> focusedCell = this.focusModelProperty().get().focusedCellProperty().get(); this.edit(focusedCell.getRow(), focusedCell.getTableColumn()); }