use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.
the class CopyDataCommandHandler method assembleCopiedDataStructure.
protected LayerCell[][] assembleCopiedDataStructure() {
final Set<Range> selectedRows = selectionLayer.getSelectedRows();
final int rowOffset = columnHeaderLayer != null ? columnHeaderLayer.getRowCount() : 0;
// Add offset to rows, remember they need to include the column header as a row
final LayerCell[][] copiedCells = new LayerCell[selectionLayer.getSelectedRowCount() + rowOffset][1];
if (columnHeaderLayer != null) {
copiedCells[0] = assembleColumnHeaders(selectionLayer.getSelectedColumns());
}
for (Range range : selectedRows) {
for (int rowPosition = range.start; rowPosition < range.end; rowPosition++) {
copiedCells[(rowPosition - range.start) + rowOffset] = assembleBody(rowPosition);
}
}
return copiedCells;
}
use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.
the class AbstractColumnHideShowLayer method underlyingToLocalColumnPositions.
@Override
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
Collection<Range> localColumnPositionRanges = new ArrayList<Range>();
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
int startColumnPosition = getAdjustedUnderlyingToLocalStartPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start, underlyingColumnPositionRange.end);
int endColumnPosition = getAdjustedUnderlyingToLocalEndPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.end, underlyingColumnPositionRange.start);
// causes strange behaviour in Freeze- and other Layers were returned.
if (startColumnPosition > -1) {
localColumnPositionRanges.add(new Range(startColumnPosition, endColumnPosition));
}
}
return localColumnPositionRanges;
}
use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.
the class ColumnReorderEvent method getColumnDiffs.
public Collection<StructuralDiff> getColumnDiffs() {
Collection<StructuralDiff> columnDiffs = new ArrayList<StructuralDiff>();
Collection<Range> beforeFromColumnPositionRanges = getBeforeFromColumnPositionRanges();
int afterAddColumnPosition = beforeToColumnPosition;
for (Range beforeFromColumnPositionRange : beforeFromColumnPositionRanges) {
if (beforeFromColumnPositionRange.start < beforeToColumnPosition) {
afterAddColumnPosition -= Math.min(beforeFromColumnPositionRange.end, beforeToColumnPosition) - beforeFromColumnPositionRange.start;
} else {
break;
}
}
int cumulativeAddSize = 0;
for (Range beforeFromColumnPositionRange : beforeFromColumnPositionRanges) {
cumulativeAddSize += beforeFromColumnPositionRange.size();
}
int offset = 0;
for (Range beforeFromColumnPositionRange : beforeFromColumnPositionRanges) {
int afterDeleteColumnPosition = beforeFromColumnPositionRange.start - offset;
if (afterAddColumnPosition < afterDeleteColumnPosition) {
afterDeleteColumnPosition += cumulativeAddSize;
}
columnDiffs.add(new StructuralDiff(DiffTypeEnum.DELETE, beforeFromColumnPositionRange, new Range(afterDeleteColumnPosition, afterDeleteColumnPosition)));
offset += beforeFromColumnPositionRange.size();
}
Range beforeAddRange = new Range(beforeToColumnPosition, beforeToColumnPosition);
offset = 0;
for (Range beforeFromColumnPositionRange : beforeFromColumnPositionRanges) {
int size = beforeFromColumnPositionRange.size();
columnDiffs.add(new StructuralDiff(DiffTypeEnum.ADD, beforeAddRange, new Range(afterAddColumnPosition + offset, afterAddColumnPosition + offset + size)));
offset += size;
}
return columnDiffs;
}
use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.
the class ShowColumnPositionsEvent method getColumnDiffs.
public Collection<StructuralDiff> getColumnDiffs() {
Collection<StructuralDiff> columnDiffs = new ArrayList<StructuralDiff>();
int offset = 0;
for (Range range : getColumnPositionRanges()) {
columnDiffs.add(new StructuralDiff(DiffTypeEnum.ADD, new Range(range.start - offset, range.start - offset), range));
offset += range.size();
}
return columnDiffs;
}
use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.
the class ColumnReorderLayer method underlyingToLocalColumnPositions.
@Override
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
List<Integer> reorderedColumnPositions = new ArrayList<Integer>();
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
for (int underlyingColumnPosition = underlyingColumnPositionRange.start; underlyingColumnPosition < underlyingColumnPositionRange.end; underlyingColumnPosition++) {
int localColumnPosition = underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start);
reorderedColumnPositions.add(Integer.valueOf(localColumnPosition));
}
}
Collections.sort(reorderedColumnPositions);
return PositionUtil.getRanges(reorderedColumnPositions);
}
Aggregations