Search in sources :

Example 1 with RowResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent in project nebula.widgets.nattable by eclipse.

the class ResizeEventPropagationTest method shouldReturnARectangleStartingFromResizedRowToEndOfGrid.

@Test
public void shouldReturnARectangleStartingFromResizedRowToEndOfGrid() {
    // Mimics resizing the third row
    this.layerListener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(this.layerListener);
    this.dataLayer.setRowHeightByPosition(3, 100);
    // This is the propagated event
    RowResizeEvent rowResizeEvent = (RowResizeEvent) this.layerListener.getReceivedEvents().get(0);
    Collection<Rectangle> actualRectangles = rowResizeEvent.getChangedPositionRectangles();
    // The affected region should have the following size
    Rectangle expectedRectangle = new Rectangle(0, 3, 5, 4);
    Assert.assertEquals(expectedRectangle, actualRectangles.iterator().next());
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) RowResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent) Test(org.junit.Test)

Example 2 with RowResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent in project nebula.widgets.nattable by eclipse.

the class DataLayer method setRowHeightPercentageByPosition.

/**
 * Set the height of the row at the given position to the given percentage
 * value.
 *
 * @param rowPosition
 *            The position of the row to change.
 * @param height
 *            The percentage value to set.
 *
 * @since 1.6
 */
public void setRowHeightPercentageByPosition(int rowPosition, double height) {
    this.rowHeightConfig.setPercentage(rowPosition, height);
    fireLayerEvent(new RowResizeEvent(this, rowPosition));
}
Also used : RowResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent)

Example 3 with RowResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent in project nebula.widgets.nattable by eclipse.

the class DataLayer method setRowHeightPercentageByPosition.

public void setRowHeightPercentageByPosition(int rowPosition, int height) {
    this.rowHeightConfig.setPercentage(rowPosition, height);
    fireLayerEvent(new RowResizeEvent(this, rowPosition));
}
Also used : RowResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent)

Example 4 with RowResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent in project nebula.widgets.nattable by eclipse.

the class MultiRowResizeCommandHandler method doCommand.

@Override
protected boolean doCommand(MultiRowResizeCommand command) {
    Collection<Integer> rowPositions = command.getRowPositions();
    for (int rowPosition : rowPositions) {
        int newRowHeight = command.downScaleValue() ? this.dataLayer.downScaleRowHeight(command.getRowHeight(rowPosition)) : command.getRowHeight(rowPosition);
        this.dataLayer.setRowHeightByPosition(rowPosition, newRowHeight, false);
    }
    List<Range> ranges = PositionUtil.getRanges(rowPositions);
    for (Range range : ranges) {
        this.dataLayer.fireLayerEvent(new RowResizeEvent(this.dataLayer, range));
    }
    return true;
}
Also used : RowResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range)

Aggregations

RowResizeEvent (org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEvent)4 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)1 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Test (org.junit.Test)1