use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class FillHandlePasteCommandHandler method doCommand.
@Override
public boolean doCommand(ILayer targetLayer, FillHandlePasteCommand command) {
if (this.clipboard.getCopiedCells() != null) {
int pasteColumn = -1;
int pasteRow = -1;
int pasteWidth = this.clipboard.getCopiedCells().length;
int pasteHeight = this.clipboard.getCopiedCells()[0].length;
Rectangle handleRegion = this.selectionLayer.getFillHandleRegion();
if (handleRegion != null) {
pasteColumn = handleRegion.x;
pasteRow = handleRegion.y;
pasteWidth = handleRegion.width;
pasteHeight = handleRegion.height;
} else {
PositionCoordinate coord = this.selectionLayer.getSelectionAnchor();
pasteColumn = coord.getColumnPosition();
pasteRow = coord.getRowPosition();
}
int pasteStartColumn = pasteColumn;
int rowStartAdjustment = 0;
if (command.direction == MoveDirectionEnum.UP) {
rowStartAdjustment = pasteHeight % this.clipboard.getCopiedCells().length;
}
int columnStartAdjustment = 0;
if (command.direction == MoveDirectionEnum.LEFT) {
columnStartAdjustment = pasteWidth % this.clipboard.getCopiedCells()[0].length;
}
for (int i = 0; i < pasteHeight; i++) {
ILayerCell[] cells = this.clipboard.getCopiedCells()[(i + rowStartAdjustment) % this.clipboard.getCopiedCells().length];
for (int j = 0; j < pasteWidth; j++) {
ILayerCell cell = cells[(j + columnStartAdjustment) % this.clipboard.getCopiedCells()[0].length];
Object cellValue = getPasteValue(cell, command, pasteColumn, pasteRow);
if (EditUtils.isCellEditable(this.selectionLayer, command.configRegistry, new PositionCoordinate(this.selectionLayer, pasteColumn, pasteRow))) {
this.selectionLayer.doCommand(new UpdateDataCommand(this.selectionLayer, pasteColumn, pasteRow, cellValue));
}
pasteColumn++;
if (pasteColumn >= this.selectionLayer.getColumnCount()) {
break;
}
}
pasteRow++;
pasteColumn = pasteStartColumn;
}
}
return true;
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowHeaderCompositeTest method shouldHandleClearFilterCommand.
@Test
public void shouldHandleClearFilterCommand() throws Exception {
Assert.assertEquals(13, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 1, 2, "ford"));
Assert.assertEquals(1, this.filterList.size());
this.layerUnderTest.doCommand(new ClearFilterCommand(this.layerUnderTest, 1));
Assert.assertEquals(13, this.filterList.size());
this.listener.containsInstanceOf(RowStructuralRefreshEvent.class);
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowDataLayerTest method shouldHandleClearFilterCommand.
@Test
public void shouldHandleClearFilterCommand() throws Exception {
assertEquals(13, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 1, 0, "ford"));
assertEquals(1, this.filterList.size());
this.layerUnderTest.doCommand(new ClearFilterCommand(this.layerUnderTest, 1));
assertEquals(13, this.filterList.size());
this.listener.containsInstanceOf(RowStructuralRefreshEvent.class);
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowDataLayerTest method shouldHandleTheClearAllFiltersCommand.
@Test
public void shouldHandleTheClearAllFiltersCommand() throws Exception {
assertEquals(13, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 1, 0, "ford"));
assertEquals(1, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 0, 0, "XXX"));
assertEquals(0, this.filterList.size());
this.layerUnderTest.doCommand(new ClearAllFiltersCommand());
assertEquals(13, this.filterList.size());
this.listener.containsInstanceOf(RowStructuralRefreshEvent.class);
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowHeaderCompositeTest method shouldHandleTheClearAllFiltersCommand.
@Test
public void shouldHandleTheClearAllFiltersCommand() throws Exception {
Assert.assertEquals(13, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 1, 2, "ford"));
Assert.assertEquals(1, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 0, 2, "XXX"));
Assert.assertEquals(0, this.filterList.size());
this.layerUnderTest.doCommand(new ClearAllFiltersCommand());
Assert.assertEquals(13, this.filterList.size());
this.listener.containsInstanceOf(RowStructuralRefreshEvent.class);
}
Aggregations