Search in sources :

Example 36 with ClientAreaResizeCommand

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

the class ResizeColumnHideShowLayerTest method testHideShowPercentageSizedColumns.

// test hide with percentage sized columns (not fixed values)
@Test
public void testHideShowPercentageSizedColumns() {
    this.bodyDataLayer.setColumnPercentageSizing(true);
    ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
    cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
    this.hideShowLayer.doCommand(cmd);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.hideColumnPositions(2);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.showAllColumns();
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 37 with ClientAreaResizeCommand

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

the class ResizeColumnHideShowLayerTest method testHideShowFixedPercentageSizedColumns.

// test hide with all percentage with fixed percentage values
@Test
public void testHideShowFixedPercentageSizedColumns() {
    this.bodyDataLayer.setColumnWidthPercentageByPosition(0, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(1, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(2, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(3, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(4, 40);
    ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
    cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
    this.hideShowLayer.doCommand(cmd);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(240, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.hideColumnPositions(1, 2);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(129, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(129, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(342, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.showAllColumns();
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(240, this.hideShowLayer.getColumnWidthByPosition(4));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 38 with ClientAreaResizeCommand

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

the class ResizeColumnHideShowLayerTest method testHideShowPercentageSizedColumnsAndDefaultMinWidth.

@Test
public void testHideShowPercentageSizedColumnsAndDefaultMinWidth() {
    this.bodyDataLayer.setColumnPercentageSizing(true);
    this.bodyDataLayer.setDefaultMinColumnWidth(10);
    ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
    cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
    this.hideShowLayer.doCommand(cmd);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.hideColumnPositions(2);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(150, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.showAllColumns();
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(120, this.hideShowLayer.getColumnWidthByPosition(4));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 39 with ClientAreaResizeCommand

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

the class ResizeColumnHideShowLayerTest method testHideShowDefaultColumnWithPercentageLastColumn.

// test hide with mixed sized where last column
// should take remaining space
@Test
public void testHideShowDefaultColumnWithPercentageLastColumn() {
    // the last column should take the remaining space
    this.bodyDataLayer.setColumnPercentageSizing(4, true);
    ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
    cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
    this.hideShowLayer.doCommand(cmd);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.hideColumnPositions(1);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(300, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.showAllColumns();
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(200, this.hideShowLayer.getColumnWidthByPosition(4));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 40 with ClientAreaResizeCommand

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

the class ResizeColumnHideShowLayerTest method testHideResizeShowSpecificColumn.

@Test
public void testHideResizeShowSpecificColumn() {
    // change width of the column that gets hidden
    this.bodyDataLayer.setColumnWidthByPosition(1, 50);
    // the last column should take the remaining space
    this.bodyDataLayer.setColumnPercentageSizing(4, true);
    ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
    cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
    this.hideShowLayer.doCommand(cmd);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(250, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.hideColumnPositions(1);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(300, this.hideShowLayer.getColumnWidthByPosition(4));
    // resize a column
    this.bodyDataLayer.setColumnWidthByPosition(0, 50);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(350, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.showAllColumns();
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(300, this.hideShowLayer.getColumnWidthByPosition(4));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Aggregations

ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)48 Rectangle (org.eclipse.swt.graphics.Rectangle)46 Test (org.junit.Test)31 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)17 Shell (org.eclipse.swt.widgets.Shell)17 Before (org.junit.Before)9 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)4 Properties (java.util.Properties)3 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)3 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)3 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)3 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)2 RowResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 StructuralRefreshCommand (org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand)1 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)1 CellEditorCreatedEvent (org.eclipse.nebula.widgets.nattable.edit.CellEditorCreatedEvent)1