use of org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method testReorderHide.
@Test
public void testReorderHide() {
testInit();
// reorder to inverse order: 4 3 2 1 0
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 0));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 1));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 2));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 3));
// hide row at position 2: 0 1 3 4
this.natTable.doCommand(new RowHideCommand(this.viewportLayer, 2));
assertEquals(4, this.viewportLayer.getRowCount());
assertEquals(4, this.viewportLayer.getRowIndexByPosition(0));
assertEquals(3, this.viewportLayer.getRowIndexByPosition(1));
assertEquals(1, this.viewportLayer.getRowIndexByPosition(2));
assertEquals(0, this.viewportLayer.getRowIndexByPosition(3));
assertEquals(-1, this.viewportLayer.getRowIndexByPosition(4));
assertEquals("five", this.viewportLayer.getDataValueByPosition(0, 0));
assertEquals("four", this.viewportLayer.getDataValueByPosition(0, 1));
assertEquals("two", this.viewportLayer.getDataValueByPosition(0, 2));
assertEquals("one", this.viewportLayer.getDataValueByPosition(0, 3));
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand in project nebula.widgets.nattable by eclipse.
the class MenuItemProviders method hideRowMenuItemProvider.
/**
* Will create and return the {@link IMenuItemProvider} that adds the action
* for executing the {@link RowHideCommand} to a popup menu. This command is
* intended to hide the current selected row immediately.
* <p>
* The {@link MenuItem} will be shown with the given menu label.
*
* @param menuLabel
* The text that will be showed for the generated
* {@link MenuItem}
* @return The {@link IMenuItemProvider} for the {@link MenuItem} that
* executes the {@link RowHideCommand}.
*/
public static IMenuItemProvider hideRowMenuItemProvider(final String menuLabel) {
return new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
menuItem.setText(Messages.getLocalizedMessage(menuLabel));
// $NON-NLS-1$
menuItem.setImage(GUIHelper.getImage("hide_row"));
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int rowPosition = getNatEventData(event).getRowPosition();
natTable.doCommand(new RowHideCommand(natTable, rowPosition));
}
});
}
};
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerHideShowTest method testFreezeHideShowRowViewportRegionEdge.
@Test
public void testFreezeHideShowRowViewportRegionEdge() {
// freeze
this.compositeFreezeLayer.doCommand(new FreezeRowCommand(this.compositeFreezeLayer, 1));
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(2, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(3, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
// hide
this.compositeFreezeLayer.doCommand(new RowHideCommand(this.compositeFreezeLayer, 2));
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(2, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(2, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
// show again
this.compositeFreezeLayer.doCommand(new ShowAllRowsCommand());
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(2, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(3, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
reset();
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerHideShowTest method testFreezeHideShowRowFrozenRegionEdge.
@Test
public void testFreezeHideShowRowFrozenRegionEdge() {
// freeze
this.compositeFreezeLayer.doCommand(new FreezeRowCommand(this.compositeFreezeLayer, 1));
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(2, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(3, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(40, this.viewportLayer.getMinimumOrigin().getY());
// hide
this.compositeFreezeLayer.doCommand(new RowHideCommand(this.compositeFreezeLayer, 1));
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(1, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(0, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(3, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(1, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(20, this.viewportLayer.getMinimumOrigin().getY());
// show again - since edge is shown again the frozen region is not
// extended
this.compositeFreezeLayer.doCommand(new ShowAllRowsCommand());
assertEquals(0, this.freezeLayer.getColumnCount());
assertEquals(1, this.freezeLayer.getRowCount());
assertEquals(-1, this.freezeLayer.getBottomRightPosition().columnPosition);
assertEquals(0, this.freezeLayer.getBottomRightPosition().rowPosition);
assertEquals(5, this.viewportLayer.getColumnCount());
assertEquals(4, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getMinimumOriginColumnPosition());
assertEquals(1, this.viewportLayer.getMinimumOriginRowPosition());
assertEquals(0, this.viewportLayer.getMinimumOrigin().getX());
assertEquals(20, this.viewportLayer.getMinimumOrigin().getY());
reset();
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method testHideShow.
@Test
public void testHideShow() {
testInit();
// hide row at position 2: 0 1 3 4
this.natTable.doCommand(new RowHideCommand(this.viewportLayer, 2));
assertEquals(4, this.viewportLayer.getRowCount());
assertEquals(0, this.viewportLayer.getRowIndexByPosition(0));
assertEquals(1, this.viewportLayer.getRowIndexByPosition(1));
assertEquals(3, this.viewportLayer.getRowIndexByPosition(2));
assertEquals(4, this.viewportLayer.getRowIndexByPosition(3));
assertEquals(-1, this.viewportLayer.getRowIndexByPosition(4));
assertEquals("one", this.viewportLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.viewportLayer.getDataValueByPosition(0, 1));
assertEquals("four", this.viewportLayer.getDataValueByPosition(0, 2));
assertEquals("five", this.viewportLayer.getDataValueByPosition(0, 3));
}
Aggregations