Search in sources :

Example 1 with SelectRowsCommand

use of net.sourceforge.nattable.selection.command.SelectRowsCommand in project translationstudio8 by heartsome.

the class RowSelectionProvider method setSelection.

@SuppressWarnings("unchecked")
public void setSelection(ISelection selection) {
    if (selectionLayer != null && selection instanceof IStructuredSelection) {
        selectionLayer.clear();
        List<Integer> rowIndexs = ((IStructuredSelection) selection).toList();
        Set<Integer> rowPositions = new HashSet<Integer>();
        for (Integer rowIndex : rowIndexs) {
            int rowPosition = selectionLayer.getRowPositionByIndex(rowIndex);
            rowPositions.add(Integer.valueOf(rowPosition));
        }
        selectionLayer.doCommand(new SelectRowsCommand(selectionLayer, 0, ObjectUtils.asIntArray(rowPositions), false, true));
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HashSet(java.util.HashSet) SelectRowsCommand(net.sourceforge.nattable.selection.command.SelectRowsCommand)

Example 2 with SelectRowsCommand

use of net.sourceforge.nattable.selection.command.SelectRowsCommand in project translationstudio8 by heartsome.

the class RowSelectionProvider method setSelection.

@SuppressWarnings("unchecked")
public void setSelection(ISelection selection) {
    if (selectionLayer != null && selection instanceof IStructuredSelection) {
        selectionLayer.clear();
        List<T> rowObjects = ((IStructuredSelection) selection).toList();
        Set<Integer> rowPositions = new HashSet<Integer>();
        for (T rowObject : rowObjects) {
            int rowIndex = rowDataProvider.indexOfRowObject(rowObject);
            int rowPosition = selectionLayer.getRowPositionByIndex(rowIndex);
            rowPositions.add(Integer.valueOf(rowPosition));
        }
        selectionLayer.doCommand(new SelectRowsCommand(selectionLayer, 0, ObjectUtils.asIntArray(rowPositions), false, true));
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HashSet(java.util.HashSet) SelectRowsCommand(net.sourceforge.nattable.selection.command.SelectRowsCommand)

Example 3 with SelectRowsCommand

use of net.sourceforge.nattable.selection.command.SelectRowsCommand in project translationstudio8 by heartsome.

the class SelectRowAction method run.

@Override
public void run(NatTable natTable, MouseEvent event) {
    super.run(natTable, event);
    natTable.doCommand(new SelectRowsCommand(natTable, getGridColumnPosition(), getGridRowPosition(), isWithShiftMask(), isWithControlMask()));
}
Also used : SelectRowsCommand(net.sourceforge.nattable.selection.command.SelectRowsCommand)

Example 4 with SelectRowsCommand

use of net.sourceforge.nattable.selection.command.SelectRowsCommand in project translationstudio8 by heartsome.

the class ViewportSelectRowCommandHandler method doCommand.

@Override
protected boolean doCommand(ViewportSelectRowCommand command) {
    IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer();
    int scrollableColumnPosition = viewportLayer.getOriginColumnPosition();
    int scrollableRowPosition = viewportLayer.localToUnderlyingRowPosition(command.getRowPosition());
    scrollableLayer.doCommand(new SelectRowsCommand(scrollableLayer, scrollableColumnPosition, new int[] { scrollableRowPosition }, command.isWithShiftMask(), command.isWithControlMask()));
    return true;
}
Also used : IUniqueIndexLayer(net.sourceforge.nattable.layer.IUniqueIndexLayer) SelectRowsCommand(net.sourceforge.nattable.selection.command.SelectRowsCommand)

Aggregations

SelectRowsCommand (net.sourceforge.nattable.selection.command.SelectRowsCommand)4 HashSet (java.util.HashSet)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IUniqueIndexLayer (net.sourceforge.nattable.layer.IUniqueIndexLayer)1