Search in sources :

Example 1 with ColumnGroupModel

use of net.sourceforge.nattable.group.ColumnGroupModel in project translationstudio8 by heartsome.

the class ColumnGroupExpandCollapseCommandHandler method doCommand.

@Override
protected boolean doCommand(ColumnGroupExpandCollapseCommand command) {
    int columnIndex = columnGroupExpandCollapseLayer.getColumnIndexByPosition(command.getColumnPosition());
    ColumnGroupModel model = columnGroupExpandCollapseLayer.getModel();
    boolean wasCollapsed = model.isCollapsed(columnIndex);
    ColumnGroup columnGroup = model.toggleColumnGroupExpandCollapse(columnIndex);
    List<Integer> columnPositions = new ArrayList<Integer>(columnGroup.getMembers());
    columnPositions.remove(0);
    ILayerEvent event;
    if (wasCollapsed) {
        event = new ShowColumnPositionsEvent(columnGroupExpandCollapseLayer, columnPositions);
    } else {
        event = new HideColumnPositionsEvent(columnGroupExpandCollapseLayer, columnPositions);
    }
    columnGroupExpandCollapseLayer.fireLayerEvent(event);
    return true;
}
Also used : ILayerEvent(net.sourceforge.nattable.layer.event.ILayerEvent) HideColumnPositionsEvent(net.sourceforge.nattable.hideshow.event.HideColumnPositionsEvent) ArrayList(java.util.ArrayList) ColumnGroup(net.sourceforge.nattable.group.ColumnGroupModel.ColumnGroup) ColumnGroupModel(net.sourceforge.nattable.group.ColumnGroupModel) ShowColumnPositionsEvent(net.sourceforge.nattable.hideshow.event.ShowColumnPositionsEvent)

Example 2 with ColumnGroupModel

use of net.sourceforge.nattable.group.ColumnGroupModel in project translationstudio8 by heartsome.

the class GroupMultiColumnReorderCommandHandler method doCommand.

@Override
protected boolean doCommand(MultiColumnReorderCommand command) {
    int toColumnPosition = command.getToColumnPosition();
    ILayer underlyingLayer = columnGroupReorderLayer.getUnderlyingLayer();
    int toColumnIndex = underlyingLayer.getColumnIndexByPosition(toColumnPosition);
    List<Integer> fromColumnPositions = command.getFromColumnPositions();
    ColumnGroupModel model = columnGroupReorderLayer.getModel();
    if (updateModel(underlyingLayer, toColumnIndex, fromColumnPositions, model)) {
        return underlyingLayer.doCommand(command);
    } else {
        return false;
    }
}
Also used : ILayer(net.sourceforge.nattable.layer.ILayer) ColumnGroupModel(net.sourceforge.nattable.group.ColumnGroupModel)

Example 3 with ColumnGroupModel

use of net.sourceforge.nattable.group.ColumnGroupModel 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)

Aggregations

ColumnGroupModel (net.sourceforge.nattable.group.ColumnGroupModel)3 ArrayList (java.util.ArrayList)2 ILayer (net.sourceforge.nattable.layer.ILayer)2 ColumnGroup (net.sourceforge.nattable.group.ColumnGroupModel.ColumnGroup)1 HideColumnPositionsEvent (net.sourceforge.nattable.hideshow.event.HideColumnPositionsEvent)1 ShowColumnPositionsEvent (net.sourceforge.nattable.hideshow.event.ShowColumnPositionsEvent)1 ILayerEvent (net.sourceforge.nattable.layer.event.ILayerEvent)1 MultiColumnReorderCommand (net.sourceforge.nattable.reorder.command.MultiColumnReorderCommand)1