use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.
the class RowReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderRightCase.
@SuppressWarnings("boxing")
@Test
public /**
* Index 2 3 0 1 ... 20
* --------------------
* Position 0 1 2 3 ... 20
*/
void returnsCorrectPositionRectangleForMultiColumnReorderRightCase() {
RowReorderLayer reorderLayer = new RowReorderLayer(new BaseDataLayerFixture(20, 20));
// Build expected cell positions to redraw
final Set<Rectangle> expectedPositions = new HashSet<Rectangle>();
expectedPositions.add(new Rectangle(0, 0, 20, 20));
reorderLayer.addLayerListener(new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
RowReorderEvent multiReorder = (RowReorderEvent) event;
assertTrue(multiReorder.getChangedPositionRectangles().containsAll(expectedPositions));
}
});
// Reorder from beginning of grid
List<Integer> fromRowPositions = Arrays.asList(new Integer[] { 0, 1 });
reorderLayer.reorderMultipleRowPositions(fromRowPositions, 2);
// Reorder to middle of grid
expectedPositions.clear();
expectedPositions.add(new Rectangle(0, 5, 20, 15));
fromRowPositions = Arrays.asList(new Integer[] { 5, 6, 7, 8 });
reorderLayer.reorderMultipleRowPositions(fromRowPositions, 10);
// Reorder to end of grid
expectedPositions.clear();
expectedPositions.add(new Rectangle(0, 10, 20, 10));
fromRowPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
reorderLayer.reorderMultipleRowPositions(fromRowPositions, 19);
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.
the class ViewportLayerTest method settingViewportColumnOriginFiresEvent.
@Test
public void settingViewportColumnOriginFiresEvent() throws Exception {
this.viewportLayer.addLayerListener(this.layerListener);
this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(2));
ILayerEvent event = this.layerListener.getReceivedEvents().get(0);
assertTrue(event instanceof IVisualChangeEvent);
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.
the class ViewportLayerTest method testMoveColumnPositionIntoViewportFiresEvent.
/*
* Scrolling Events fired when origin changes
*/
@Test
public void testMoveColumnPositionIntoViewportFiresEvent() throws Exception {
this.viewportLayer.addLayerListener(this.layerListener);
this.viewportLayer.moveColumnPositionIntoViewport(4);
ILayerEvent event = this.layerListener.getReceivedEvents().get(0);
assertTrue(event instanceof IVisualChangeEvent);
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.
the class RowGroupExpandCollapseCommandHandler method doCommand.
@Override
protected boolean doCommand(RowGroupExpandCollapseCommand command) {
int rowIndex = this.rowGroupExpandCollapseLayer.getRowIndexByPosition(command.getRowPosition());
IRowGroupModel<T> model = this.rowGroupExpandCollapseLayer.getModel();
IRowGroup<T> group = RowGroupUtils.getTopMostParentGroup(RowGroupUtils.getRowGroupForRowIndex(model, rowIndex));
// further operation ...
if (group == null || !group.isCollapseable()) {
return true;
}
boolean wasCollapsed = group.isCollapsed();
if (wasCollapsed) {
group.expand();
} else {
group.collapse();
}
List<Integer> rowIndexes = new ArrayList<Integer>(RowGroupUtils.getRowIndexesInGroup(model, rowIndex));
List<Integer> rowPositions = RowGroupUtils.getRowPositionsInGroup(this.rowGroupExpandCollapseLayer, rowIndexes);
ILayerEvent event;
if (wasCollapsed) {
event = new ShowRowPositionsEvent(this.rowGroupExpandCollapseLayer, rowPositions);
} else {
event = new HideRowPositionsEvent(this.rowGroupExpandCollapseLayer, rowPositions);
}
this.rowGroupExpandCollapseLayer.fireLayerEvent(event);
return true;
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent in project nebula.widgets.nattable by eclipse.
the class ColumnGroupExpandCollapseCommandHandler method doCommand.
@Override
protected boolean doCommand(ColumnGroupExpandCollapseCommand command) {
int columnIndex = this.columnGroupExpandCollapseLayer.getColumnIndexByPosition(command.getColumnPosition());
ColumnGroupModel model = this.columnGroupExpandCollapseLayer.getModel(command.getRowPosition());
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
// further operation ...
if (columnGroup == null || !columnGroup.isCollapseable()) {
return true;
}
List<Integer> columnIndexes = new ArrayList<Integer>(columnGroup.getMembers());
columnIndexes.removeAll(columnGroup.getStaticColumnIndexes());
boolean wasCollapsed = columnGroup.isCollapsed();
if (wasCollapsed) {
// we need to cleanup the column position list before we toggle
// because the columns are hidden before the toggle and will be
// visible afterwards
cleanupColumnIndexes(columnIndexes);
}
columnGroup.toggleCollapsed();
if (!wasCollapsed) {
// we need to cleanup the column position list after we toggle
// because the columns are hidden now
cleanupColumnIndexes(columnIndexes);
}
ILayerEvent event;
if (wasCollapsed) {
event = new ShowColumnPositionsEvent(this.columnGroupExpandCollapseLayer, columnIndexes);
} else {
event = new HideColumnPositionsEvent(this.columnGroupExpandCollapseLayer, columnIndexes);
}
this.columnGroupExpandCollapseLayer.fireLayerEvent(event);
return true;
}
Aggregations