Search in sources :

Example 81 with CopyDataToClipboardCommand

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

the class FillHandleSeriesTest method testSingleCellIntegerValueDragUp.

@Test
public void testSingleCellIntegerValueDragUp() {
    this.dataProvider.setDataValue(4, 4, Integer.valueOf("1"));
    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, 1, 1, 4));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.UP, this.natTable.getConfigRegistry()));
    assertEquals(Integer.valueOf("-2"), this.selectionLayer.getDataValueByPosition(4, 1));
    assertEquals(Integer.valueOf("-1"), this.selectionLayer.getDataValueByPosition(4, 2));
    assertEquals(Integer.valueOf("0"), this.selectionLayer.getDataValueByPosition(4, 3));
    assertEquals(Integer.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 4));
}
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 82 with CopyDataToClipboardCommand

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

the class FillHandleSeriesTest method testSingleCellLongValueDragDown.

@Test
public void testSingleCellLongValueDragDown() {
    this.dataProvider.setDataValue(4, 4, Long.valueOf("1"));
    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(Long.valueOf("1"), this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals(Long.valueOf("2"), this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals(Long.valueOf("3"), this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals(Long.valueOf("4"), 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)

Example 83 with CopyDataToClipboardCommand

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

the class FormulaFillHandlePasteTest method testFunctionCellDragDown.

@Test
public void testFunctionCellDragDown() {
    this.dataProvider.setDataValue(4, 4, "2");
    this.dataProvider.setDataValue(5, 4, "21");
    this.dataProvider.setDataValue(6, 4, "=E5*F5");
    this.dataProvider.setDataValue(4, 5, "3");
    this.dataProvider.setDataValue(5, 5, "22");
    this.selectionLayer.selectCell(6, 4, false, true);
    testCellStates(new Point(4, 4), new Point(5, 4), new Point(6, 4), new Point(4, 5), new Point(5, 5));
    this.natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
    "\t", // $NON-NLS-1$
    System.getProperty("line.separator"), this.natTable.getConfigRegistry()));
    this.selectionLayer.setFillHandleRegion(new Rectangle(6, 4, 1, 2));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
    assertEquals("2", this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals("21", this.selectionLayer.getDataValueByPosition(5, 4));
    assertEquals(new BigDecimal("42"), this.selectionLayer.getDataValueByPosition(6, 4));
    assertEquals("3", this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals("22", this.selectionLayer.getDataValueByPosition(5, 5));
    assertEquals(new BigDecimal("66"), this.selectionLayer.getDataValueByPosition(6, 5));
    testCellStates(new Point(4, 4), new Point(5, 4), new Point(6, 4), new Point(4, 5), new Point(5, 5), new Point(6, 5));
}
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) Point(org.eclipse.swt.graphics.Point) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 84 with CopyDataToClipboardCommand

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

the class FormulaFillHandlePasteTest method testMultiNumberCellDragDown.

@Test
public void testMultiNumberCellDragDown() {
    this.dataProvider.setDataValue(4, 4, "2");
    this.dataProvider.setDataValue(4, 5, "4");
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(4, 5, false, true);
    testCellStates(new Point(4, 4), new Point(4, 5));
    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("2", this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals("4", this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals("6", this.selectionLayer.getDataValueByPosition(4, 6));
    assertEquals("8", this.selectionLayer.getDataValueByPosition(4, 7));
    testCellStates(new Point(4, 4), new Point(4, 5), new Point(4, 6), new Point(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) Point(org.eclipse.swt.graphics.Point) 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