Search in sources :

Example 1 with IEditableRule

use of net.sourceforge.nattable.config.IEditableRule in project translationstudio8 by heartsome.

the class EditUtils method allCellsEditable.

public static boolean allCellsEditable(SelectionLayer selectionLayer, IConfigRegistry configRegistry) {
    PositionCoordinate[] selectedCells = selectionLayer.getSelectedCells();
    for (PositionCoordinate cell : selectedCells) {
        LabelStack labelStack = selectionLayer.getConfigLabelsByPosition(cell.columnPosition, cell.rowPosition);
        IEditableRule editableRule = configRegistry.getConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, labelStack.getLabels());
        int columnIndex = selectionLayer.getColumnIndexByPosition(cell.columnPosition);
        int rowIndex = selectionLayer.getRowIndexByPosition(cell.rowPosition);
        if (!editableRule.isEditable(columnIndex, rowIndex)) {
            return false;
        }
    }
    return true;
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack) IEditableRule(net.sourceforge.nattable.config.IEditableRule) PositionCoordinate(net.sourceforge.nattable.coordinate.PositionCoordinate)

Example 2 with IEditableRule

use of net.sourceforge.nattable.config.IEditableRule in project translationstudio8 by heartsome.

the class TickUpdateCommandHandler method updateSingleCell.

private void updateSingleCell(TickUpdateCommand command, PositionCoordinate selectedPosition) {
    LayerCell cell = selectionLayer.getCellByPosition(selectedPosition.columnPosition, selectedPosition.rowPosition);
    IEditableRule editableRule = command.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, DisplayMode.EDIT, cell.getConfigLabels().getLabels());
    if (editableRule.isEditable(selectedPosition.columnPosition, selectedPosition.rowPosition)) {
        selectionLayer.doCommand(new UpdateDataCommand(selectionLayer, selectedPosition.columnPosition, selectedPosition.rowPosition, getNewCellValue(command, cell)));
    }
}
Also used : IEditableRule(net.sourceforge.nattable.config.IEditableRule) LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) UpdateDataCommand(net.sourceforge.nattable.edit.command.UpdateDataCommand)

Aggregations

IEditableRule (net.sourceforge.nattable.config.IEditableRule)2 PositionCoordinate (net.sourceforge.nattable.coordinate.PositionCoordinate)1 UpdateDataCommand (net.sourceforge.nattable.edit.command.UpdateDataCommand)1 LabelStack (net.sourceforge.nattable.layer.LabelStack)1 LayerCell (net.sourceforge.nattable.layer.cell.LayerCell)1