Example usage for javafx.scene.control TablePosition getColumn

List of usage examples for javafx.scene.control TablePosition getColumn

Introduction

In this page you can find the example usage for javafx.scene.control TablePosition getColumn.

Prototype

@Override
public int getColumn() 

Source Link

Document

The column index that this TablePosition represents in the TableView.

Usage

From source file:com.github.drbookings.ui.controller.MainController.java

private void deleteSelected() {
    final ObservableList<TablePosition> selectedItems = tableView.getSelectionModel().getSelectedCells();
    if (logger.isDebugEnabled()) {
        logger.debug("Delete " + selectedItems);
    }/*w  w  w. j a  v  a  2  s . c o  m*/
    for (final TablePosition<DateBean, ?> tp : selectedItems) {
        final int c = tp.getColumn();
        final int r = tp.getRow();
        final TableColumn<DateBean, ?> tableColumn = tp.getTableColumn();
        final Object cellData = tableColumn.getCellData(r);
        if (logger.isDebugEnabled()) {
            logger.debug("Delete in column " + c + ", " + cellData);
        }
        if (cellData instanceof DateBean) {
            final DateBean db = (DateBean) cellData;
            if (db.getRooms().isEmpty()) {

            } else {
                final RoomBean rb = db.getRoom("" + c);
                if (rb.isEmpty()) {
                    continue;
                }
                final BookingBean booking = rb.getFilteredBookingEntries().get(0).getElement();
                if (logger.isDebugEnabled()) {
                    logger.debug("Deleting " + booking);
                }
                manager.removeBooking(booking);
            }
        }
    }
}

From source file:com.github.drbookings.ui.controller.MainController.java

private ListChangeListener<TablePosition> getCellSelectionListener() {
    return change -> {
        final List<RoomBean> cells = new ArrayList<>();
        final List<DateBean> dates = new ArrayList<>();
        for (final TablePosition tp : change.getList()) {
            final int r = tp.getRow();
            final int c = tp.getColumn();
            final Object cell = tp.getTableColumn().getCellData(r);
            if (cell instanceof DateBean) {
                final RoomBean room = ((DateBean) cell).getRoom("" + c);
                if (room != null) {
                    cells.add(room);//w w  w .jav  a  2s. c  o m
                }
                dates.add((DateBean) cell);
            }
        }
        RoomBeanSelectionManager.getInstance().setSelection(cells);
        DateBeanSelectionManager.getInstance().setSelection(dates);
    };
}