use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.
the class FormulaFillHandlePasteTest method testFullFunctionCellDragDown.
@Test
public void testFullFunctionCellDragDown() {
this.dataProvider.setDataValue(4, 4, "2");
this.dataProvider.setDataValue(5, 4, "21");
this.dataProvider.setDataValue(6, 4, "=E5*F5");
assertEquals(new BigDecimal("42"), this.formulaDataProvider.getDataValue(6, 4));
this.selectionLayer.selectCell(4, 4, false, true);
this.selectionLayer.selectCell(5, 4, false, true);
this.selectionLayer.selectCell(6, 4, false, true);
testCellStates(new Point(4, 4), new Point(5, 4), new Point(6, 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, 3, 3));
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));
assertEquals("4", this.selectionLayer.getDataValueByPosition(4, 6));
assertEquals("23", this.selectionLayer.getDataValueByPosition(5, 6));
assertEquals(new BigDecimal("92"), this.selectionLayer.getDataValueByPosition(6, 6));
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), new Point(4, 6), new Point(5, 6), new Point(6, 6));
}
use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.
the class FormulaFillHandlePasteTest method testSingleCellDragOneDown.
@Test
public void testSingleCellDragOneDown() {
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, 4, 1, 2));
this.natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, MoveDirectionEnum.DOWN, this.natTable.getConfigRegistry()));
assertEquals("Simpson", this.selectionLayer.getDataValueByPosition(4, 5));
testCellStates(new Point(4, 4), new Point(4, 5));
}
use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.
the class FillHandleDragMode method openMenu.
/**
* Opens a menu that enables a user to select whether values should simply
* be copied or if a series should be filled.
*
* @param natTable
* The NatTable instance on which the operation is performed.
*/
protected void openMenu(final NatTable natTable) {
// lazily create the menu
if (this.menu == null || this.menu.isDisposed()) {
this.menu = new Menu(natTable);
MenuItem copyItem = new MenuItem(this.menu, SWT.PUSH);
// $NON-NLS-1$
copyItem.setText(Messages.getLocalizedMessage("%FillHandleDragMode.menu.item.copy"));
copyItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, FillHandleDragMode.this.direction, natTable.getConfigRegistry()));
}
});
MenuItem seriesItem = new MenuItem(this.menu, SWT.PUSH);
// $NON-NLS-1$
seriesItem.setText(Messages.getLocalizedMessage("%FillHandleDragMode.menu.item.series"));
seriesItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.SERIES, FillHandleDragMode.this.direction, natTable.getConfigRegistry()));
}
});
// add a menu listener to reset the fill state when the menu is
// closed
this.menu.addMenuListener(new MenuAdapter() {
@Override
public void menuHidden(MenuEvent e) {
// perform the reset operation asynchronously because on
// several OS the hide event is processed BEFORE the
// selection event
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
reset(natTable);
}
});
}
});
// add the dispose listener for disposing the menu
natTable.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
FillHandleDragMode.this.menu.dispose();
}
});
}
this.menu.setVisible(true);
}
use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.
the class FillHandleDragMode method mouseUp.
@Override
public void mouseUp(final NatTable natTable, MouseEvent event) {
// Cancel any active viewport drag
super.mouseUp(natTable, event);
if (natTable.doCommand(new CopyDataToClipboardCommand(// $NON-NLS-1$
"\t", // $NON-NLS-1$
System.getProperty("line.separator"), natTable.getConfigRegistry()))) {
if (this.clipboard != null) {
if (showMenu(natTable)) {
openMenu(natTable);
} else {
natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, this.direction, natTable.getConfigRegistry()));
reset(natTable);
}
} else {
natTable.doCommand(new FillHandlePasteCommand(FillHandleOperation.COPY, this.direction, natTable.getConfigRegistry()));
reset(natTable);
}
} else {
reset(natTable);
}
}
use of org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommand in project nebula.widgets.nattable by eclipse.
the class FillHandlePasteTest method testMultiCellDragOneDown.
@Test
public void testMultiCellDragOneDown() {
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, 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("Ned", this.selectionLayer.getDataValueByPosition(3, 5));
assertEquals("Flanders", 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));
}
Aggregations