use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.
the class ResizingVisibleReorderedColumnsTest method changeShouldIncludeAllColumns.
@Test
public void changeShouldIncludeAllColumns() {
// Reorder columns again, should now be 3, 0, 1, 2, 4
this.reorderLayer.reorderColumnPosition(3, 0);
// Resize first column
this.dataLayer.setColumnWidthByPosition(3, 200);
// The changed position rectangle should now be the entire grid
Rectangle expectedRectangle = new Rectangle(0, 0, 5, 7);
Collection<Rectangle> actualRectangles = ((ColumnResizeEvent) this.layerListener.getReceivedEvent(ColumnResizeEvent.class)).getChangedPositionRectangles();
Assert.assertEquals(expectedRectangle, actualRectangles);
}
use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.
the class DataLayer method setColumnWidthPercentageByPosition.
public void setColumnWidthPercentageByPosition(int columnPosition, int width) {
this.columnWidthConfig.setPercentage(columnPosition, width);
fireLayerEvent(new ColumnResizeEvent(this, columnPosition));
}
use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.
the class ResizeColumnHideShowLayer method showAllColumns.
@Override
public void showAllColumns() {
// On show we expect that all visible columns share the free
// space. To avoid that only the adjacent column is decreased, we
// disable fixColumnPercentageValuesOnResize in any case and restore it
// afterwards
boolean fix = this.bodyDataLayer.isFixColumnPercentageValuesOnResize();
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(false);
for (Map.Entry<Integer, ColumnSizeInfo> entry : this.hiddenColumns.entrySet()) {
Integer index = entry.getKey();
ColumnSizeInfo info = entry.getValue();
// first make the column resizable
this.bodyDataLayer.setColumnPositionResizable(index, true);
// set the previous configured min width
if (info.configuredMinWidth < 0) {
this.bodyDataLayer.resetMinColumnWidth(index, false);
} else {
this.bodyDataLayer.setMinColumnWidth(index, info.configuredMinWidth);
}
// set the previous configured width
if (info.configuredPercentage && info.configuredPercentageValue >= 0) {
this.bodyDataLayer.setColumnWidthPercentageByPosition(index, info.configuredPercentageValue);
} else if (!info.configuredPercentage && info.configuredSize >= 0) {
this.bodyDataLayer.setColumnWidthByPosition(index, info.configuredSize, false);
} else {
this.bodyDataLayer.resetColumnWidth(index, false);
}
// set the configured resizable value
this.bodyDataLayer.setColumnPositionResizable(index, info.configuredResizable);
}
List<Range> ranges = PositionUtil.getRanges(this.hiddenColumns.keySet());
this.hiddenColumns.clear();
// reset the fixColumnPercentageValuesOnResize flag
this.bodyDataLayer.setFixColumnPercentageValuesOnResize(fix);
// fire events
for (Range range : ranges) {
this.bodyDataLayer.fireLayerEvent(new ColumnResizeEvent(this.bodyDataLayer, range));
}
}
use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.
the class ResizeEventPropagationTest method shouldReturnARectangleStartingFromResizedColumnToEndOfGrid.
@Test
public void shouldReturnARectangleStartingFromResizedColumnToEndOfGrid() {
// Mimics resizing the second column
this.layerListener = new LayerListenerFixture();
this.dataLayer.addLayerListener(this.layerListener);
this.dataLayer.setColumnWidthByPosition(2, 200);
// This is the propagated event
ColumnResizeEvent columnResizeEvent = (ColumnResizeEvent) this.layerListener.getReceivedEvents().get(0);
Collection<Rectangle> actualRectangles = columnResizeEvent.getChangedPositionRectangles();
// The affected region should have the following size
Rectangle expectedRectangle = new Rectangle(2, 0, 3, 7);
Assert.assertEquals(expectedRectangle, actualRectangles.iterator().next());
}
use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.
the class ResizingVisibleReorderedColumnsTest method changeShouldIncludeLastColumn.
@Test
public void changeShouldIncludeLastColumn() {
// Reorder columns should now be 0, 2, 3, 4, 1
this.reorderLayer.reorderColumnPosition(1, 4);
// Resize last column
this.dataLayer.setColumnWidthByPosition(1, 200);
// The changed position rectangle should just have one column, and the
// column position should be the last column (4)
Rectangle expectedRectangle = new Rectangle(4, 0, 1, 7);
Collection<Rectangle> actualRectangles = ((ColumnResizeEvent) this.layerListener.getReceivedEvent(ColumnResizeEvent.class)).getChangedPositionRectangles();
Assert.assertEquals(expectedRectangle, actualRectangles.iterator().next());
}
Aggregations