blob: 9ca1100b8fa4b2dbd0319de2797930651c6c0e6a [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2012, 2021 Original NatTable authors and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Original NatTable authors and others - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.ecommons.waltable.resize;
import org.eclipse.statet.ecommons.waltable.command.AbstractLayerCommandHandler;
import org.eclipse.statet.ecommons.waltable.coordinate.ILValueIterator;
import org.eclipse.statet.ecommons.waltable.coordinate.LRangeList.ValueIterator;
import org.eclipse.statet.ecommons.waltable.layer.DataLayer;
public class MultiColumnResizeCommandHandler extends AbstractLayerCommandHandler<MultiColumnResizeCommand> {
private final DataLayer dataLayer;
public MultiColumnResizeCommandHandler(final DataLayer dataLayer) {
this.dataLayer= dataLayer;
}
@Override
public Class<MultiColumnResizeCommand> getCommandClass() {
return MultiColumnResizeCommand.class;
}
@Override
protected boolean doCommand(final MultiColumnResizeCommand command) {
for (final ILValueIterator columnIter= new ValueIterator(command.getPositions()); columnIter.hasNext(); ) {
final long columnPosition= columnIter.nextValue();
this.dataLayer.setColumnWidthByPosition(columnPosition, command.getColumnWidth(columnPosition));
}
return true;
}
}