Java Code Examples for javafx.scene.control.TableView#getSelectionModel()
The following examples show how to use
javafx.scene.control.TableView#getSelectionModel() .
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: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 7 votes |
@SuppressWarnings("unchecked") public void selectCells(TableView<?> tableView, String value) { @SuppressWarnings("rawtypes") TableViewSelectionModel selectionModel = tableView.getSelectionModel(); selectionModel.clearSelection(); JSONObject cells = new JSONObject(value); JSONArray object = (JSONArray) cells.get("cells"); for (int i = 0; i < object.length(); i++) { JSONArray jsonArray = object.getJSONArray(i); int rowIndex = Integer.parseInt(jsonArray.getString(0)); int columnIndex = getColumnIndex(jsonArray.getString(1)); @SuppressWarnings("rawtypes") TableColumn column = tableView.getColumns().get(columnIndex); if (getVisibleCellAt(tableView, rowIndex, columnIndex) == null) { tableView.scrollTo(rowIndex); tableView.scrollToColumn(column); } selectionModel.select(rowIndex, column); } }
Example 2
Source File: JavaFXTableViewElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public boolean marathon_select(String value) { TableView<?> tableView = (TableView<?>) node; TableViewSelectionModel<?> selectionModel = tableView.getSelectionModel(); if ("".equals(value)) { selectionModel.clearSelection(); return true; } else if (value.equals("all")) { int rowSize = tableView.getItems().size(); for (int i = 0; i < rowSize; i++) { selectionModel.select(i); } return true; } else if (selectionModel.isCellSelectionEnabled()) { selectCells(tableView, value); return true; } else { int[] selectedRows = getSelectedRows(value); selectionModel.clearSelection(); for (int rowIndex : selectedRows) { if (getVisibleCellAt(tableView, rowIndex, tableView.getColumns().size() - 1) == null) { tableView.scrollTo(rowIndex); } selectionModel.select(rowIndex); } return true; } }
Example 3
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 4 votes |
public String getSelection(TableView<?> tableView) { TableViewSelectionModel<?> selectionModel = tableView.getSelectionModel(); if (!selectionModel.isCellSelectionEnabled()) { ObservableList<Integer> selectedIndices = selectionModel.getSelectedIndices(); if (tableView.getItems().size() == selectedIndices.size()) { return "all"; } if (selectedIndices.size() == 0) { return ""; } return getRowSelectionText(selectedIndices); } @SuppressWarnings("rawtypes") ObservableList<TablePosition> selectedCells = selectionModel.getSelectedCells(); int[] rows = new int[selectedCells.size()]; int[] columns = new int[selectedCells.size()]; int rowCount = tableView.getItems().size(); int columnCount = tableView.getColumns().size(); if (selectedCells.size() == rowCount * columnCount) { return "all"; } if (selectedCells.size() == 0) { return ""; } JSONObject cells = new JSONObject(); JSONArray value = new JSONArray(); for (int i = 0; i < selectedCells.size(); i++) { TablePosition<?, ?> cell = selectedCells.get(i); rows[i] = cell.getRow(); columns[i] = cell.getColumn(); List<String> cellValue = new ArrayList<>(); cellValue.add(cell.getRow() + ""); cellValue.add(getColumnName(tableView, cell.getColumn())); value.put(cellValue); } cells.put("cells", value); return cells.toString(); }
Example 4
Source File: LazyLoadingBehavior.java From dolphin-platform with Apache License 2.0 | 4 votes |
public LazyLoadingBehavior(TableView<T> tableView) { this(tableView, tableView.itemsProperty(), tableView.getSelectionModel()); }