use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayer method reorderColumnGroup.
/**
* @param fromColumnPosition
* The column position of a column in the column group that
* should be reordered.
* @param toColumnPosition
* The column position to which a column group should be
* reordered to.
* @return <code>true</code> if the reorder command was executed and
* consumed successfully
*/
public boolean reorderColumnGroup(int fromColumnPosition, int toColumnPosition) {
int fromColumnIndex = this.underlyingLayer.getColumnIndexByPosition(fromColumnPosition);
List<Integer> fromColumnPositions = getColumnGroupPositions(fromColumnIndex);
return this.underlyingLayer.doCommand(new MultiColumnReorderCommand(this, fromColumnPositions, toColumnPosition));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
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 = this.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 = this.columnGroupReorderLayer.getModel();
if (model.isPartOfAGroup(fromColumnIndex)) {
String groupName = model.getColumnGroupByIndex(fromColumnIndex).getName();
if (!groupsProcessed.contains(groupName)) {
groupsProcessed.add(groupName);
fromColumnPositionsWithGroupColumns.addAll(this.columnGroupReorderLayer.getColumnGroupPositions(fromColumnIndex));
}
} else {
fromColumnPositionsWithGroupColumns.add(fromColumnPosition);
}
}
return underlyingLayer.doCommand(new MultiColumnReorderCommand(this.columnGroupReorderLayer, fromColumnPositionsWithGroupColumns, command.getToColumnPosition(), command.isReorderToLeftEdge()));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandler method handleGroupColumnsCommand.
public void handleGroupColumnsCommand(String columnGroupName) {
try {
List<Integer> selectedPositions = new ArrayList<Integer>(this.columnIndexesToPositionsMap.size());
int[] fullySelectedColumns = new int[this.columnIndexesToPositionsMap.size()];
int count = 0;
for (Integer columnIndex : this.columnIndexesToPositionsMap.keySet()) {
fullySelectedColumns[count++] = columnIndex.intValue();
selectedPositions.add(this.columnIndexesToPositionsMap.get(columnIndex));
}
this.model.addColumnsIndexesToGroup(columnGroupName, fullySelectedColumns);
this.selectionLayer.doCommand(new MultiColumnReorderCommand(this.selectionLayer, selectedPositions, selectedPositions.get(0)));
this.selectionLayer.clear();
} catch (Throwable t) {
}
this.contextLayer.fireLayerEvent(new GroupColumnsEvent(this.contextLayer));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayer method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
if (command instanceof SelectCellCommand && command.convertToTargetLayer(this)) {
// perform selection of level on level header click
SelectCellCommand selection = (SelectCellCommand) command;
if (isLevelHeaderColumn(selection.getColumnPosition())) {
ILayerCell clickedCell = getCellByPosition(selection.getColumnPosition(), selection.getRowPosition());
// calculate number of header columns to the right
int levelHeaderCount = 0;
for (int i = this.levelHeaderPositions.length - 1; i >= 0; i--) {
if (this.levelHeaderPositions[i] >= selection.getColumnPosition()) {
levelHeaderCount++;
}
}
SelectRegionCommand selectRegion = new SelectRegionCommand(this, clickedCell.getColumnPosition() + 1, clickedCell.getOriginRowPosition(), getColumnCount() - levelHeaderCount - (clickedCell.getColumnPosition()), clickedCell.getRowSpan(), selection.isShiftMask(), selection.isControlMask());
this.underlyingLayer.doCommand(selectRegion);
return true;
}
} else if (command instanceof ConfigureScalingCommand) {
this.dpiConverter = ((ConfigureScalingCommand) command).getHorizontalDpiConverter();
} else if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) {
ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command;
Rectangle possibleArea = clientAreaResizeCommand.getScrollable().getClientArea();
// remove the tree level header width from the client area to
// ensure that the percentage calculation is correct
possibleArea.width = possibleArea.width - (this.levelHeaderPositions.length * getScaledLevelHeaderWidth());
clientAreaResizeCommand.setCalcArea(possibleArea);
} else if (command instanceof ColumnReorderCommand) {
ColumnReorderCommand crCommand = ((ColumnReorderCommand) command);
if (!isValidTargetColumnPosition(crCommand.getFromColumnPosition(), crCommand.getToColumnPosition())) {
// command without doing anything
return true;
}
if (isLevelHeaderColumn(crCommand.getToColumnPosition())) {
// tree level header
return super.doCommand(new ColumnReorderCommand(this, crCommand.getFromColumnPosition(), crCommand.getToColumnPosition() + 1));
}
} else if (command instanceof MultiColumnReorderCommand) {
MultiColumnReorderCommand crCommand = ((MultiColumnReorderCommand) command);
for (int fromColumnPosition : crCommand.getFromColumnPositions()) {
if (!isValidTargetColumnPosition(fromColumnPosition, crCommand.getToColumnPosition())) {
// command would be skipped
return true;
}
}
if (isLevelHeaderColumn(crCommand.getToColumnPosition())) {
// tree level header
return super.doCommand(new MultiColumnReorderCommand(this, crCommand.getFromColumnPositions(), crCommand.getToColumnPosition() + 1));
}
}
return super.doCommand(command);
}
Aggregations