Search in sources :

Example 1 with ILayerCommand

use of net.sourceforge.nattable.command.ILayerCommand in project translationstudio8 by heartsome.

the class ChooseColumnsFromCategoriesCommandHandler method itemsMoved.

/**
	 * Moves the columns up or down by firing commands on the dialog.<br/>
	 *
	 * Individual columns are moved using the {@link ColumnReorderCommand}<br/>
	 * Contiguously selected columns are moved using the {@link MultiColumnReorderCommand}<br/>
	 */
public void itemsMoved(MoveDirectionEnum direction, List<Integer> selectedPositions) {
    List<List<Integer>> fromPositions = PositionUtil.getGroupedByContiguous(selectedPositions);
    List<Integer> toPositions = getDestinationPositions(direction, fromPositions);
    for (int i = 0; i < fromPositions.size(); i++) {
        boolean multipleColumnsMoved = fromPositions.get(i).size() > 1;
        ILayerCommand command = null;
        if (!multipleColumnsMoved) {
            int fromPosition = fromPositions.get(i).get(0).intValue();
            int toPosition = toPositions.get(i);
            command = new ColumnReorderCommand(columnHideShowLayer, fromPosition, toPosition);
        } else if (multipleColumnsMoved) {
            command = new MultiColumnReorderCommand(columnHideShowLayer, fromPositions.get(i), toPositions.get(i));
        }
        columnHideShowLayer.doCommand(command);
    }
    refreshDialog();
}
Also used : MultiColumnReorderCommand(net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand) ArrayList(java.util.ArrayList) List(java.util.List) MultiColumnReorderCommand(net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand) ColumnReorderCommand(net.sourceforge.nattable.reorder.command.ColumnReorderCommand) ILayerCommand(net.sourceforge.nattable.command.ILayerCommand)

Example 2 with ILayerCommand

use of net.sourceforge.nattable.command.ILayerCommand in project translationstudio8 by heartsome.

the class DimensionallyDependentLayer method doCommand.

// Commands
@Override
public boolean doCommand(ILayerCommand command) {
    // Invoke command handler(s) on the Dimensionally dependent layer
    ILayerCommand clonedCommand = command.cloneCommand();
    if (super.doCommand(command)) {
        return true;
    }
    clonedCommand = command.cloneCommand();
    if (horizontalLayerDependency.doCommand(clonedCommand)) {
        return true;
    }
    clonedCommand = command.cloneCommand();
    if (verticalLayerDependency.doCommand(clonedCommand)) {
        return true;
    }
    return baseLayer.doCommand(command);
}
Also used : ILayerCommand(net.sourceforge.nattable.command.ILayerCommand)

Aggregations

ILayerCommand (net.sourceforge.nattable.command.ILayerCommand)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ColumnReorderCommand (net.sourceforge.nattable.reorder.command.ColumnReorderCommand)1 MultiColumnReorderCommand (net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand)1