Search in sources :

Example 6 with RowHideCommand

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));
}
Also used : RowReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand) RowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) Test(org.junit.Test)

Example 7 with RowHideCommand

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));
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) RowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand)

Example 8 with RowHideCommand

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();
}
Also used : FreezeRowCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand) ShowAllRowsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllRowsCommand) RowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) Test(org.junit.Test)

Example 9 with RowHideCommand

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();
}
Also used : FreezeRowCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand) ShowAllRowsCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllRowsCommand) RowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) Test(org.junit.Test)

Example 10 with RowHideCommand

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));
}
Also used : RowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand) MultiRowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand) Test(org.junit.Test)

Aggregations

RowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand)11 Test (org.junit.Test)10 MultiRowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiRowHideCommand)8 FreezeRowCommand (org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand)4 ShowAllRowsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllRowsCommand)4 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)2 HideRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent)2 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)2 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)2 RowReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)2 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)2 Shell (org.eclipse.swt.widgets.Shell)2 StructuralDiff (org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1