Search in sources :

Example 6 with Range

use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.

the class RowStructuralChangeEvent method getChangedPositionRectangles.

@Override
public Collection<Rectangle> getChangedPositionRectangles() {
    Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>();
    int columnCount = getLayer().getColumnCount();
    int rowCount = getLayer().getRowCount();
    for (Range range : getRowPositionRanges()) {
        changedPositionRectangles.add(new Rectangle(0, range.start, columnCount, rowCount - range.start));
    }
    return changedPositionRectangles;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(org.eclipse.swt.graphics.Rectangle) Range(net.sourceforge.nattable.coordinate.Range)

Example 7 with Range

use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.

the class SelectionModel method getSelectedRowCount.

public int getSelectedRowCount() {
    Set<Range> selectedRows = getSelectedRows();
    int count = 0;
    for (Range range : selectedRows) {
        count += range.end - range.start;
    }
    return count;
}
Also used : Range(net.sourceforge.nattable.coordinate.Range)

Example 8 with Range

use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.

the class SelectRowCommandHandler method selectRowWithCtrlKey.

private Range selectRowWithCtrlKey(int columnPosition, int rowPosition) {
    Rectangle selectedRowRectangle = new Rectangle(0, rowPosition, selectionLayer.getColumnCount(), 1);
    if (selectionLayer.isRowFullySelected(rowPosition)) {
        selectionLayer.clearSelection(selectedRowRectangle);
        if (selectionLayer.lastSelectedRegion != null && selectionLayer.lastSelectedRegion.equals(selectedRowRectangle)) {
            selectionLayer.lastSelectedRegion = null;
        }
    } else {
        // Preserve last selected region
        if (selectionLayer.lastSelectedRegion != null) {
            selectionLayer.selectionModel.addSelection(new Rectangle(selectionLayer.lastSelectedRegion.x, selectionLayer.lastSelectedRegion.y, selectionLayer.lastSelectedRegion.width, selectionLayer.lastSelectedRegion.height));
        }
        selectionLayer.selectRegion(0, rowPosition, selectionLayer.getColumnCount(), 1);
        selectionLayer.moveSelectionAnchor(columnPosition, rowPosition);
    }
    return new Range(rowPosition, rowPosition + 1);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Range(net.sourceforge.nattable.coordinate.Range)

Example 9 with Range

use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.

the class SelectRowCommandHandler method internalSelectRow.

private Set<Range> internalSelectRow(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) {
    Set<Range> changedRowRanges = new HashSet<Range>();
    if (noShiftOrControl(withShiftMask, withControlMask)) {
        changedRowRanges.addAll(selectionLayer.getSelectedRows());
        selectionLayer.clear();
        selectionLayer.selectCell(0, rowPosition, withShiftMask, withControlMask);
        selectionLayer.selectRegion(0, rowPosition, selectionLayer.getColumnCount(), 1);
        selectionLayer.moveSelectionAnchor(columnPosition, rowPosition);
        changedRowRanges.add(new Range(rowPosition, rowPosition + 1));
    } else if (bothShiftAndControl(withShiftMask, withControlMask)) {
        changedRowRanges.add(selectRowWithShiftKey(rowPosition));
    } else if (isShiftOnly(withShiftMask, withControlMask)) {
        changedRowRanges.add(selectRowWithShiftKey(rowPosition));
    } else if (isControlOnly(withShiftMask, withControlMask)) {
        changedRowRanges.add(selectRowWithCtrlKey(columnPosition, rowPosition));
    }
    selectionLayer.lastSelectedCell.columnPosition = selectionLayer.getColumnCount() - 1;
    selectionLayer.lastSelectedCell.rowPosition = rowPosition;
    return changedRowRanges;
}
Also used : Range(net.sourceforge.nattable.coordinate.Range) HashSet(java.util.HashSet)

Example 10 with Range

use of net.sourceforge.nattable.coordinate.Range in project translationstudio8 by heartsome.

the class ViewportLayer method processColumnSelection.

private void processColumnSelection(ColumnSelectionEvent selectionEvent) {
    for (Range columnPositionRange : selectionEvent.getColumnPositionRanges()) {
        moveColumnPositionIntoViewport(columnPositionRange.end - 1, false);
        adjustHorizontalScrollBar();
    }
}
Also used : Range(net.sourceforge.nattable.coordinate.Range)

Aggregations

Range (net.sourceforge.nattable.coordinate.Range)25 ArrayList (java.util.ArrayList)12 HashSet (java.util.HashSet)6 Rectangle (org.eclipse.swt.graphics.Rectangle)6 StructuralDiff (net.sourceforge.nattable.layer.event.StructuralDiff)5 Serializable (java.io.Serializable)2 PositionCoordinate (net.sourceforge.nattable.coordinate.PositionCoordinate)2 LinkedList (java.util.LinkedList)1 LayerCell (net.sourceforge.nattable.layer.cell.LayerCell)1 RowSelectionEvent (net.sourceforge.nattable.selection.event.RowSelectionEvent)1