Search in sources :

Example 1 with MultiColumnReorderCommand

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

the class ColumnGroupReorderLayer method reorderColumnGroup.

public boolean reorderColumnGroup(int fromColumnPosition, int toColumnPosition) {
    int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition);
    List<Integer> fromColumnPositions = getColumnGroupPositions(fromColumnIndex);
    return underlyingLayer.doCommand(new MultiColumnReorderCommand(this, fromColumnPositions, toColumnPosition));
}
Also used : MultiColumnReorderCommand(net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand)

Example 2 with MultiColumnReorderCommand

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

the class ColumnGroupsCommandHandler method handleGroupColumnsCommand.

public void handleGroupColumnsCommand(String columnGroupName) {
    try {
        List<Integer> selectedPositions = new ArrayList<Integer>();
        int[] fullySelectedColumns = new int[columnIndexesToPositionsMap.size()];
        int count = 0;
        for (Integer columnIndex : columnIndexesToPositionsMap.keySet()) {
            fullySelectedColumns[count++] = columnIndex.intValue();
            selectedPositions.add(columnIndexesToPositionsMap.get(columnIndex));
        }
        model.addColumnsIndexesToGroup(columnGroupName, fullySelectedColumns);
        selectionLayer.doCommand(new MultiColumnReorderCommand(selectionLayer, selectedPositions, selectedPositions.get(0).intValue()));
        selectionLayer.clear();
    } catch (Throwable t) {
    }
    contextLayer.fireLayerEvent(new GroupColumnsEvent(contextLayer));
}
Also used : GroupColumnsEvent(net.sourceforge.nattable.group.event.GroupColumnsEvent) MultiColumnReorderCommand(net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand) ArrayList(java.util.ArrayList)

Example 3 with MultiColumnReorderCommand

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

the class ReorderColumnsAndGroupsCommandHandler method doCommand.

/**
	 * Check if any column belongs to a group. If yes, add all columns in that group.
	 * Assumes that the 'toLocation' is not inside another group
	 */
@Override
protected boolean doCommand(ReorderColumnsAndGroupsCommand command) {
    final ILayer underlyingLayer = columnGroupReorderLayer.getUnderlyingLayer();
    List<String> groupsProcessed = new ArrayList<String>();
    List<Integer> fromColumnPositions = command.getFromColumnPositions();
    List<Integer> fromColumnPositionsWithGroupColumns = new ArrayList<Integer>();
    for (Integer fromColumnPosition : fromColumnPositions) {
        int fromColumnIndex = underlyingLayer.getColumnIndexByPosition(fromColumnPosition.intValue());
        ColumnGroupModel model = columnGroupReorderLayer.getModel();
        if (model.isPartOfAGroup(fromColumnIndex)) {
            String groupName = model.getColumnGroupNameForIndex(fromColumnIndex);
            if (!groupsProcessed.contains(groupName)) {
                groupsProcessed.add(groupName);
                fromColumnPositionsWithGroupColumns.addAll(columnGroupReorderLayer.getColumnGroupPositions(fromColumnIndex));
            }
        } else {
            fromColumnPositionsWithGroupColumns.add(fromColumnPosition);
        }
    }
    return underlyingLayer.doCommand(new MultiColumnReorderCommand(columnGroupReorderLayer, fromColumnPositionsWithGroupColumns, command.getToColumnPosition()));
}
Also used : MultiColumnReorderCommand(net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand) ILayer(net.sourceforge.nattable.layer.ILayer) ArrayList(java.util.ArrayList) ColumnGroupModel(net.sourceforge.nattable.group.ColumnGroupModel)

Example 4 with MultiColumnReorderCommand

use of net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand 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)

Aggregations

MultiColumnReorderCommand (net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand)4 ArrayList (java.util.ArrayList)3 List (java.util.List)1 ILayerCommand (net.sourceforge.nattable.command.ILayerCommand)1 ColumnGroupModel (net.sourceforge.nattable.group.ColumnGroupModel)1 GroupColumnsEvent (net.sourceforge.nattable.group.event.GroupColumnsEvent)1 ILayer (net.sourceforge.nattable.layer.ILayer)1 ColumnReorderCommand (net.sourceforge.nattable.reorder.command.ColumnReorderCommand)1