Java 类javafx.scene.control.TreeTablePosition 实例源码

项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
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();
    }
}
项目:marathonv5    文件:RFXTreeTableView.java   
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;
    }
}
项目:openjfx-8u-dev-tests    文件:TreeTableViewWrap.java   
@Property(SELECTED_CELLS_PROP_NAME)
public List<Point> getSelectedCells() {
    return new GetAction<java.util.List<Point>>() {
        @Override
        public void run(Object... parameters) throws Exception {
            java.util.List<Point> res = new ArrayList<Point>();
            for (TreeTablePosition tp : (java.util.List<TreeTablePosition>) getControl().getSelectionModel().getSelectedCells()) {
                res.add(new Point(tp.getColumn(), tp.getRow()));
            }
            setResult(res);
        }
    }.dispatch(getEnvironment());
}