use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.
the class NatExporter method setClientAreaToMaximum.
/**
* Increase the client area so it can include the whole {@link ILayer}.
*
* @param layer
* The {@link ILayer} for which the client area should be
* maximized.
*
* @since 1.5
*/
protected void setClientAreaToMaximum(ILayer layer) {
final Rectangle maxClientArea = new Rectangle(0, 0, layer.getWidth(), layer.getHeight());
layer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return maxClientArea;
}
});
layer.doCommand(new PrintEntireGridCommand());
}
use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerTest method testFreezeSelectionInMiddle.
@Test
public void testFreezeSelectionInMiddle() {
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 300, 120);
}
});
this.selectionLayer.setSelectedCell(2, 2);
this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(1));
this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(1));
this.compositeFreezeLayer.doCommand(new FreezeSelectionCommand());
TestLayer expectedLayer = new TestLayer(3, 3, "1:0;100 | 2:0;100 | 3:1;100", "1:0;40 | 2:0;40 | 3:1;40", "B1~:FROZEN_REGION | C1~:FROZEN_ROW_REGION | D1~:FROZEN_ROW_REGION \n" + "B2~:FROZEN_COLUMN_REGION | C2~SELECT:selectionAnchor,NONFROZEN_REGION | D2~:NONFROZEN_REGION \n" + "B3~:FROZEN_COLUMN_REGION | C3~:NONFROZEN_REGION | D3~:NONFROZEN_REGION \n");
LayerAssert.assertLayerEquals(expectedLayer, this.compositeFreezeLayer);
}
use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerTest method setup.
@Before
public void setup() {
TestLayer dataLayer = new TestLayer(4, 4, "0:0;100 | 1:1;100 | 2:2;100 | 3:3;100", "0:0;40 | 1:1;40 | 2:2;40 | 3:3;40", "A0 | B0 | C0 | D0 \n" + "A1 | B1 | C1 | D1 \n" + "A2 | B2 | C2 | D2 \n" + "A3 | B3 | C3 | D3 \n");
this.reorderLayer = new ColumnReorderLayer(dataLayer);
this.hideShowLayer = new ColumnHideShowLayer(this.reorderLayer);
this.selectionLayer = new SelectionLayer(this.hideShowLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
this.freezeLayer = new FreezeLayer(this.selectionLayer);
this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, this.viewportLayer, this.selectionLayer);
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 400, 160);
}
});
this.compositeFreezeLayer.doCommand(new InitializeClientAreaCommandFixture());
}
use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.
the class FreezeHandlerTest method testFreezeColumnResize.
@Test
public void testFreezeColumnResize() {
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 1500, 400);
}
});
// Fire this command so that the viewport can be initialized
this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 2));
assertEquals(3, this.freezeLayer.getColumnCount());
assertEquals(7, this.viewportLayer.getColumnCount());
assertEquals(300, this.viewportLayer.getOrigin().getX());
this.compositeFreezeLayer.doCommand(new ColumnResizeCommand(this.freezeLayer, 2, 200));
assertEquals(3, this.freezeLayer.getColumnCount());
assertEquals(7, this.viewportLayer.getColumnCount());
assertEquals(400, this.viewportLayer.getOrigin().getX());
}
use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.
the class FreezeHandlerTest method testFreezeAllColumnsResize.
@Test
public void testFreezeAllColumnsResize() {
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 1500, 400);
}
});
// Fire this command so that the viewport can be initialized
this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 9));
assertEquals(10, this.freezeLayer.getColumnCount());
assertEquals(0, this.viewportLayer.getColumnCount());
assertEquals(1000, this.viewportLayer.getOrigin().getX());
this.compositeFreezeLayer.doCommand(new ColumnResizeCommand(this.freezeLayer, 2, 200));
assertEquals(10, this.freezeLayer.getColumnCount());
assertEquals(0, this.viewportLayer.getColumnCount());
assertEquals(1100, this.viewportLayer.getOrigin().getX());
}
Aggregations