Search in sources :

Example 1 with FillHandlePasteCommand

use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.

the class FillHandlePasteTest method testSingleCellDragOneUpRight.

@Test
public void testSingleCellDragOneUpRight() {
    this.dataProvider.setDataValue(4, 4, "Simpson");
    this.selectionLayer.setSelectedCell(4, 4);
    testCellStates(new Point(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, 3, 2, 2));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, MoveDirectionEnum.UP, this.natTable.getConfigRegistry()));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 3));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(5, 3));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(5, 4));
    testCellStates(new Point(4, 3), new Point(5, 3), new Point(4, 4), new Point(5, 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) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 2 with FillHandlePasteCommand

use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.

the class FillHandlePasteTest method testMultiCellDragOneLeft.

@Test
public void testMultiCellDragOneLeft() {
    this.dataProvider.setDataValue(3, 4, "Homer");
    this.dataProvider.setDataValue(4, 4, "Simpson");
    this.dataProvider.setDataValue(3, 5, "Ned");
    this.dataProvider.setDataValue(4, 5, "Flanders");
    this.selectionLayer.selectCell(3, 4, false, true);
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(3, 5, false, true);
    this.selectionLayer.selectCell(4, 5, false, true);
    testCellStates(new Point(3, 4), new Point(4, 4), new Point(3, 5), 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(2, 4, 3, 2));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, MoveDirectionEnum.LEFT, this.natTable.getConfigRegistry()));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(2, 4));
    assertEquals("Homer", this.selectionLayer.getDataValueByPosition(3, 4));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals("Flanders", this.selectionLayer.getDataValueByPosition(2, 5));
    assertEquals("Ned", this.selectionLayer.getDataValueByPosition(3, 5));
    assertEquals("Flanders", this.selectionLayer.getDataValueByPosition(4, 5));
    testCellStates(new Point(2, 4), new Point(3, 4), new Point(4, 4), new Point(2, 5), new Point(3, 5), new Point(4, 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) Test(org.junit.Test)

Example 3 with FillHandlePasteCommand

use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.

the class FillHandlePasteTest method testSingleCellDragUpLeft.

@Test
public void testSingleCellDragUpLeft() {
    this.dataProvider.setDataValue(4, 4, "Simpson");
    this.selectionLayer.setSelectedCell(4, 4);
    testCellStates(new Point(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(3, 3, 2, 2));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, MoveDirectionEnum.LEFT, this.natTable.getConfigRegistry()));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(3, 3));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 3));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(3, 4));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 4));
    testCellStates(new Point(3, 3), new Point(4, 3), new Point(3, 4), new Point(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) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 4 with FillHandlePasteCommand

use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.

the class FillHandlePasteTest method testMultiHorizontalCellDragDown.

@Test
public void testMultiHorizontalCellDragDown() {
    this.dataProvider.setDataValue(3, 4, "Homer");
    this.dataProvider.setDataValue(4, 4, "Simpson");
    this.selectionLayer.selectCell(3, 4, false, true);
    this.selectionLayer.selectCell(4, 4, false, true);
    testCellStates(new Point(3, 4), new Point(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(3, 4, 2, 3));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
    assertEquals("Homer", this.selectionLayer.getDataValueByPosition(3, 4));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals("Homer", this.selectionLayer.getDataValueByPosition(3, 5));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals("Homer", this.selectionLayer.getDataValueByPosition(3, 6));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 6));
    testCellStates(new Point(3, 4), new Point(4, 4), new Point(3, 5), new Point(4, 5), new Point(3, 6), new Point(4, 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) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 5 with FillHandlePasteCommand

use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.

the class FillHandlePasteTest method testMultiCellDragOneRight.

@Test
public void testMultiCellDragOneRight() {
    this.dataProvider.setDataValue(3, 4, "Homer");
    this.dataProvider.setDataValue(4, 4, "Simpson");
    this.dataProvider.setDataValue(3, 5, "Ned");
    this.dataProvider.setDataValue(4, 5, "Flanders");
    this.selectionLayer.selectCell(3, 4, false, true);
    this.selectionLayer.selectCell(4, 4, false, true);
    this.selectionLayer.selectCell(3, 5, false, true);
    this.selectionLayer.selectCell(4, 5, false, true);
    testCellStates(new Point(3, 4), new Point(4, 4), new Point(3, 5), 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(3, 4, 3, 2));
    this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, MoveDirectionEnum.RIGHT, this.natTable.getConfigRegistry()));
    assertEquals("Homer", this.selectionLayer.getDataValueByPosition(3, 4));
    assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 4));
    assertEquals("Homer", this.selectionLayer.getDataValueByPosition(5, 4));
    assertEquals("Ned", this.selectionLayer.getDataValueByPosition(3, 5));
    assertEquals("Flanders", this.selectionLayer.getDataValueByPosition(4, 5));
    assertEquals("Ned", this.selectionLayer.getDataValueByPosition(5, 5));
    testCellStates(new Point(3, 4), new Point(4, 4), new Point(5, 4), new Point(3, 5), new Point(4, 5), new Point(5, 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) Test(org.junit.Test)

Aggregations

FillHandlePasteCommand (org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand)84 CopyDataToClipboardCommand (org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand)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 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 MenuAdapter (org.eclipse.swt.events.MenuAdapter)1 MenuEvent (org.eclipse.swt.events.MenuEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1