blob: da6ecd51e343d2369959e132c83af9cc155f1cb5 [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.selection;
import static org.eclipse.statet.ecommons.waltable.coordinate.Orientation.HORIZONTAL;
import static org.eclipse.statet.ecommons.waltable.selection.SelectionLayer.NO_SELECTION;
import java.util.Collection;
import org.eclipse.statet.ecommons.waltable.coordinate.LRange;
import org.eclipse.statet.ecommons.waltable.coordinate.LRangeList;
import org.eclipse.statet.ecommons.waltable.layer.ILayer;
import org.eclipse.statet.ecommons.waltable.layer.event.ColumnVisualChangeEvent;
public class ColumnSelectionEvent extends ColumnVisualChangeEvent implements ISelectionEvent {
private final SelectionLayer selectionLayer;
private long columnPositionToReveal;
public ColumnSelectionEvent(final SelectionLayer selectionLayer,
final long columnPosition, final boolean revealColumn) {
this(selectionLayer, new LRangeList(columnPosition),
(revealColumn) ? columnPosition : NO_SELECTION );
}
public ColumnSelectionEvent(final SelectionLayer selectionLayer,
final Collection<LRange> columnPositions, final long columnPositionToReveal) {
super(selectionLayer, columnPositions);
this.selectionLayer= selectionLayer;
this.columnPositionToReveal= columnPositionToReveal;
}
protected ColumnSelectionEvent(final ColumnSelectionEvent event) {
super(event);
this.selectionLayer= event.selectionLayer;
this.columnPositionToReveal= event.columnPositionToReveal;
}
@Override
public ColumnSelectionEvent cloneEvent() {
return new ColumnSelectionEvent(this);
}
@Override
public SelectionLayer getSelectionLayer() {
return this.selectionLayer;
}
public long getColumnPositionToReveal() {
return this.columnPositionToReveal;
}
@Override
public boolean convertToLocal(final ILayer localLayer) {
if (this.columnPositionToReveal != NO_SELECTION) {
this.columnPositionToReveal= localLayer.getDim(HORIZONTAL).underlyingToLocalPosition(
getLayer().getDim(HORIZONTAL), this.columnPositionToReveal );
}
return super.convertToLocal(localLayer);
}
}