Search in sources :

Example 1 with SortColumnCommand

use of org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand in project nebula.widgets.nattable by eclipse.

the class SortColumnAction method run.

@Override
public void run(NatTable natTable, MouseEvent event) {
    int columnPosition = ((NatEventData) event.data).getColumnPosition();
    natTable.doCommand(new SortColumnCommand(natTable, columnPosition, this.accumulate));
}
Also used : SortColumnCommand(org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData)

Example 2 with SortColumnCommand

use of org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand in project nebula.widgets.nattable by eclipse.

the class RowSelectionIntegrationTest method shouldPreserveRowSelectionOnSort.

@Test
public void shouldPreserveRowSelectionOnSort() throws Exception {
    assertEquals(0, this.selectionLayer.getFullySelectedRowPositions().length);
    // Unsorted order - Ford motor at top
    assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 1).toString());
    assertEquals("A Alphabet Co.", this.nattable.getDataValueByPosition(2, 2).toString());
    assertEquals("C General Electric Co", this.nattable.getDataValueByPosition(2, 3).toString());
    // Select 'Ford Motor'
    this.nattable.doCommand(new SelectRowsCommand(this.nattable, 1, 1, false, false));
    assertEquals("B Ford Motor", getSelected().getSecurity_description());
    // Sort
    this.nattable.doCommand(new SortColumnCommand(this.nattable, 2, false));
    // Sorted order - Alphabet co. at top
    assertEquals("A Alphabet Co.", this.nattable.getDataValueByPosition(2, 1).toString());
    assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 2).toString());
    assertEquals("C General Electric Co", this.nattable.getDataValueByPosition(2, 3).toString());
    // Ford motor still selected
    assertEquals("B Ford Motor", getSelected().getSecurity_description());
}
Also used : SortColumnCommand(org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Aggregations

SortColumnCommand (org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand)2 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)1 NatEventData (org.eclipse.nebula.widgets.nattable.ui.NatEventData)1 Test (org.junit.Test)1