blob: 03ef0d3a9c9ec3327fe5e5db8f2d7cc948a116f5 [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.layer.event;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import org.eclipse.statet.ecommons.waltable.coordinate.LRange;
import org.eclipse.statet.ecommons.waltable.coordinate.LRectangle;
import org.eclipse.statet.ecommons.waltable.layer.ILayer;
/**
* @see ColumnStructuralChangeEvent
*/
public abstract class RowStructuralChangeEvent extends RowVisualChangeEvent implements IStructuralChangeEvent {
public RowStructuralChangeEvent(final ILayer layer, final LRange...rowPositionRanges) {
this(layer, Arrays.asList(rowPositionRanges));
}
public RowStructuralChangeEvent(final ILayer layer, final Collection<LRange> rowPositionRanges) {
super(layer, rowPositionRanges);
}
protected RowStructuralChangeEvent(final RowStructuralChangeEvent event) {
super(event);
}
@Override
public Collection<LRectangle> getChangedPositionRectangles() {
final Collection<LRectangle> changedPositionRectangles= new ArrayList<>();
final long columnCount= getLayer().getColumnCount();
final long rowCount= getLayer().getRowCount();
for (final LRange lRange : getRowPositionRanges()) {
changedPositionRectangles.add(new LRectangle(0, lRange.start, columnCount, rowCount - lRange.start));
}
return changedPositionRectangles;
}
@Override
public boolean isHorizontalStructureChanged() {
return false;
}
@Override
public Collection<StructuralDiff> getColumnDiffs() {
return null;
}
@Override
public boolean isVerticalStructureChanged() {
return true;
}
}