Search in sources :

Example 76 with CopyDataToClipboardCommand

use of org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand in project nebula.widgets.nattable by eclipse.

the class FillHandleSeriesTest method testMultiCellIntegerValueDragRight.

@Test
public void testMultiCellIntegerValueDragRight() {
    // column 4 simple series
    this.dataProvider.setDataValue(4, 4, Integer.valueOf("1"));
    this.dataProvider.setDataValue(5, 4, Integer.valueOf("2"));
    this.dataProvider.setDataValue(6, 4, Integer.valueOf("3"));
    // column 5 calculated series
    this.dataProvider.setDataValue(4, 5, Integer.valueOf("2"));
    this.dataProvider.setDataValue(5, 5, Integer.valueOf("4"));
    this.dataProvider.setDataValue(6, 5, Integer.valueOf("6"));
    // column 6 incontiguous
    this.dataProvider.setDataValue(4, 6, Integer.valueOf("1"));
    this.dataProvider.setDataValue(5, 6, Integer.valueOf("2"));
    this.dataProvider.setDataValue(6, 6, Integer.valueOf("4"));
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(6, 6, true, false);
    this.natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
    "\t", // $NON-NLS-1$
    System.getProperty("line.separator"), this.natTable.getConfigRegistry()));
    this.selectionLayer.setFillHandleRegion(new Rectangle(4, 4, 6, 3));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.RIGHT, this.natTable.getConfigRegistry()));
    // simple series
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(5, 4));
    assertEquals(Integer.valueOf("3"), this.selectionLayer.getDataValueByPosition(6, 4));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(7, 4));
    assertEquals(Integer.valueOf("5"), this.selectionLayer.getDataValueByPosition(8, 4));
    assertEquals(Integer.valueOf("6"), this.selectionLayer.getDataValueByPosition(9, 4));
    // series with 2 difference
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(5, 5));
    assertEquals(Integer.valueOf("6"), this.selectionLayer.getDataValueByPosition(6, 5));
    assertEquals(Integer.valueOf("8"), this.selectionLayer.getDataValueByPosition(7, 5));
    assertEquals(Integer.valueOf("10"), this.selectionLayer.getDataValueByPosition(8, 5));
    assertEquals(Integer.valueOf("12"), this.selectionLayer.getDataValueByPosition(9, 5));
    // as there is no common diff value in the cells we simply perform a
    // copy operation
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(5, 6));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(6, 6));
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(7, 6));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(8, 6));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(9, 6));
}
Also used : FillHandlePasteCommand(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand) CopyDataToClipboardCommand(org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 77 with CopyDataToClipboardCommand

use of org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand in project nebula.widgets.nattable by eclipse.

the class FillHandleSeriesTest method testMultiCellSameDiffLongValueDragDown.

@Test
public void testMultiCellSameDiffLongValueDragDown() {
    this.dataProvider.setDataValue(4, 4, Long.valueOf("1"));
    this.dataProvider.setDataValue(4, 5, Long.valueOf("3"));
    this.dataProvider.setDataValue(4, 6, Long.valueOf("5"));
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(4, 5, false, true);
    this.selectionLayer.selectCell(4, 6, false, true);
    this.natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
    "\t", // $NON-NLS-1$
    System.getProperty("line.separator"), this.natTable.getConfigRegistry()));
    this.selectionLayer.setFillHandleRegion(new Rectangle(4, 4, 1, 6));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
    assertEquals(Long.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals(Long.valueOf("3"), this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals(Long.valueOf("5"), this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals(Long.valueOf("7"), this.selectionLayer.getDataValueByPosition(4, 7));
    assertEquals(Long.valueOf("9"), this.selectionLayer.getDataValueByPosition(4, 8));
    assertEquals(Long.valueOf("11"), this.selectionLayer.getDataValueByPosition(4, 9));
}
Also used : FillHandlePasteCommand(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand) CopyDataToClipboardCommand(org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 78 with CopyDataToClipboardCommand

use of org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand in project nebula.widgets.nattable by eclipse.

the class FillHandleSeriesTest method testMultiCellIntegerValueDragDown.

@Test
public void testMultiCellIntegerValueDragDown() {
    // column 4 simple series
    this.dataProvider.setDataValue(4, 4, Integer.valueOf("1"));
    this.dataProvider.setDataValue(4, 5, Integer.valueOf("2"));
    this.dataProvider.setDataValue(4, 6, Integer.valueOf("3"));
    // column 5 calculated series
    this.dataProvider.setDataValue(5, 4, Integer.valueOf("2"));
    this.dataProvider.setDataValue(5, 5, Integer.valueOf("4"));
    this.dataProvider.setDataValue(5, 6, Integer.valueOf("6"));
    // column 6 incontiguous
    this.dataProvider.setDataValue(6, 4, Integer.valueOf("1"));
    this.dataProvider.setDataValue(6, 5, Integer.valueOf("2"));
    this.dataProvider.setDataValue(6, 6, Integer.valueOf("4"));
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(6, 6, true, false);
    this.natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
    "\t", // $NON-NLS-1$
    System.getProperty("line.separator"), this.natTable.getConfigRegistry()));
    this.selectionLayer.setFillHandleRegion(new Rectangle(4, 4, 3, 6));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
    // simple series
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals(Integer.valueOf("3"), this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(4, 7));
    assertEquals(Integer.valueOf("5"), this.selectionLayer.getDataValueByPosition(4, 8));
    assertEquals(Integer.valueOf("6"), this.selectionLayer.getDataValueByPosition(4, 9));
    // series with 2 difference
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(5, 4));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(5, 5));
    assertEquals(Integer.valueOf("6"), this.selectionLayer.getDataValueByPosition(5, 6));
    assertEquals(Integer.valueOf("8"), this.selectionLayer.getDataValueByPosition(5, 7));
    assertEquals(Integer.valueOf("10"), this.selectionLayer.getDataValueByPosition(5, 8));
    assertEquals(Integer.valueOf("12"), this.selectionLayer.getDataValueByPosition(5, 9));
    // as there is no common diff value in the cells we simply perform a
    // copy operation
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(6, 4));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(6, 5));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(6, 6));
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(6, 7));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(6, 8));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(6, 9));
}
Also used : FillHandlePasteCommand(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand) CopyDataToClipboardCommand(org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 79 with CopyDataToClipboardCommand

use of org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand in project nebula.widgets.nattable by eclipse.

the class FillHandleSeriesTest method testMultiCellDifferentIntegerValueDragDown.

@Test
public void testMultiCellDifferentIntegerValueDragDown() {
    this.dataProvider.setDataValue(4, 4, Integer.valueOf("1"));
    this.dataProvider.setDataValue(4, 5, Integer.valueOf("2"));
    this.dataProvider.setDataValue(4, 6, Integer.valueOf("4"));
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(4, 5, false, true);
    this.selectionLayer.selectCell(4, 6, false, true);
    this.natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
    "\t", // $NON-NLS-1$
    System.getProperty("line.separator"), this.natTable.getConfigRegistry()));
    this.selectionLayer.setFillHandleRegion(new Rectangle(4, 4, 1, 6));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
    // as there is no common diff value in the cells we simply perform a
    // copy operation
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 7));
    assertEquals(Integer.valueOf("2"), this.selectionLayer.getDataValueByPosition(4, 8));
    assertEquals(Integer.valueOf("4"), this.selectionLayer.getDataValueByPosition(4, 9));
}
Also used : FillHandlePasteCommand(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand) CopyDataToClipboardCommand(org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 80 with CopyDataToClipboardCommand

use of org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand in project nebula.widgets.nattable by eclipse.

the class FillHandleSeriesTest method testSingleCellBigIntegerValueDragDown.

@Test
public void testSingleCellBigIntegerValueDragDown() {
    this.dataProvider.setDataValue(4, 4, BigInteger.valueOf(100));
    this.selectionLayer.setSelectedCell(4, 4);
    this.natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
    "\t", // $NON-NLS-1$
    System.getProperty("line.separator"), this.natTable.getConfigRegistry()));
    this.selectionLayer.setFillHandleRegion(new Rectangle(4, 4, 1, 4));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
    assertEquals(BigInteger.valueOf(100), this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals(BigInteger.valueOf(101), this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals(BigInteger.valueOf(102), this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals(BigInteger.valueOf(103), this.selectionLayer.getDataValueByPosition(4, 7));
}
Also used : FillHandlePasteCommand(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand) CopyDataToClipboardCommand(org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Aggregations

CopyDataToClipboardCommand (org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand)84 FillHandlePasteCommand (org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand)83 Rectangle (org.eclipse.swt.graphics.Rectangle)82 Test (org.junit.Test)82 Point (org.eclipse.swt.graphics.Point)34 Date (java.util.Date)6 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 CopyDataCommandHandler (org.eclipse.nebula.widgets.nattable.copy.command.CopyDataCommandHandler)1 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)1 DefaultBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider)1 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)1 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)1 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)1 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)1 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)1 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)1 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)1 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)1