Search in sources :

Example 6 with ILayerCommand

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

the class GridLayerTest method doCommandInvokesBodyFirst.

@Test
public void doCommandInvokesBodyFirst() throws Exception {
    DummyCommandHandler bodyCommandHandler = new DummyCommandHandler(true);
    DummyCommandHandler columnHeaderCommandHandler = new DummyCommandHandler(true);
    DummyCommandHandler rowHeaderCommandHandler = new DummyCommandHandler(true);
    DummyCommandHandler cornerCommandHandler = new DummyCommandHandler(true);
    this.bodyDataLayer.registerCommandHandler(bodyCommandHandler);
    this.columnHeaderDataLayer.registerCommandHandler(columnHeaderCommandHandler);
    this.rowHeaderDataLayer.registerCommandHandler(rowHeaderCommandHandler);
    this.cornerDataLayer.registerCommandHandler(cornerCommandHandler);
    final ILayerCommand command = new LayerCommandFixture();
    this.gridLayerUnderTest.doCommand(command);
    Assert.assertTrue(bodyCommandHandler.isCommandCaught());
    Assert.assertFalse(columnHeaderCommandHandler.isCommandCaught());
    Assert.assertFalse(rowHeaderCommandHandler.isCommandCaught());
    Assert.assertFalse(cornerCommandHandler.isCommandCaught());
}
Also used : LayerCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture) ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand) Test(org.junit.Test)

Example 7 with ILayerCommand

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

the class GridLayerTest method doCommandInvokesOtherLayers.

@Test
public void doCommandInvokesOtherLayers() throws Exception {
    DummyCommandHandler bodyCommandHandler = new DummyCommandHandler(false);
    DummyCommandHandler columnHeaderCommandHandler = new DummyCommandHandler(false);
    DummyCommandHandler rowHeaderCommandHandler = new DummyCommandHandler(false);
    DummyCommandHandler cornerCommandHandler = new DummyCommandHandler(true);
    this.bodyDataLayer.registerCommandHandler(bodyCommandHandler);
    this.columnHeaderDataLayer.registerCommandHandler(columnHeaderCommandHandler);
    this.rowHeaderDataLayer.registerCommandHandler(rowHeaderCommandHandler);
    this.cornerDataLayer.registerCommandHandler(cornerCommandHandler);
    final ILayerCommand command = new LayerCommandFixture();
    this.gridLayerUnderTest.doCommand(command);
    Assert.assertFalse(bodyCommandHandler.isCommandCaught());
    Assert.assertFalse(columnHeaderCommandHandler.isCommandCaught());
    Assert.assertFalse(rowHeaderCommandHandler.isCommandCaught());
    Assert.assertTrue(cornerCommandHandler.isCommandCaught());
}
Also used : LayerCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture) ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand) Test(org.junit.Test)

Example 8 with ILayerCommand

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

the class HideColumnCommandTest method testHideColumnCommand.

@Test
public void testHideColumnCommand() {
    int columnPosition = 2;
    ILayerCommand hideColumnCommand = new MultiColumnHideCommand(this.columnHideShowLayer, columnPosition);
    Assert.assertEquals(5, this.columnHideShowLayer.getColumnCount());
    this.columnHideShowLayer.doCommand(hideColumnCommand);
    Assert.assertEquals(4, this.columnHideShowLayer.getColumnCount());
    Assert.assertEquals(0, this.columnHideShowLayer.getColumnIndexByPosition(0));
    Assert.assertEquals(1, this.columnHideShowLayer.getColumnIndexByPosition(1));
    Assert.assertEquals(3, this.columnHideShowLayer.getColumnIndexByPosition(2));
    Assert.assertEquals(4, this.columnHideShowLayer.getColumnIndexByPosition(3));
}
Also used : ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand) Test(org.junit.Test)

Example 9 with ILayerCommand

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

the class HideRowCommandTest method testHideRowCommand.

@Test
public void testHideRowCommand() {
    int rowPosition = 2;
    ILayerCommand hideRowCommand = new MultiRowHideCommand(this.rowHideShowLayer, rowPosition);
    Assert.assertEquals(7, this.rowHideShowLayer.getRowCount());
    this.rowHideShowLayer.doCommand(hideRowCommand);
    Assert.assertEquals(6, this.rowHideShowLayer.getRowCount());
    Assert.assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
    Assert.assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
    Assert.assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(2));
    Assert.assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(3));
    Assert.assertEquals(5, this.rowHideShowLayer.getRowIndexByPosition(4));
    Assert.assertEquals(6, this.rowHideShowLayer.getRowIndexByPosition(5));
}
Also used : ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand) Test(org.junit.Test)

Example 10 with ILayerCommand

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

the class DimensionallyDependentIndexLayer method doCommand.

// Commands
@Override
public boolean doCommand(ILayerCommand command) {
    // Invoke command handler(s) on the Dimensionally dependent layer
    ILayerCommand clonedCommand = command.cloneCommand();
    if (super.doCommand(command)) {
        return true;
    }
    clonedCommand = command.cloneCommand();
    if (this.horizontalLayerDependency.doCommand(clonedCommand)) {
        return true;
    }
    clonedCommand = command.cloneCommand();
    if (this.verticalLayerDependency.doCommand(clonedCommand)) {
        return true;
    }
    return false;
}
Also used : ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand)

Aggregations

ILayerCommand (org.eclipse.nebula.widgets.nattable.command.ILayerCommand)11 Test (org.junit.Test)6 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 LayerCommandFixture (org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AbstractRegionCommand (org.eclipse.nebula.widgets.nattable.command.AbstractRegionCommand)1 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)1 ClearAllSelectionsCommand (org.eclipse.nebula.widgets.nattable.selection.command.ClearAllSelectionsCommand)1 Point (org.eclipse.swt.graphics.Point)1