Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2016-01-27 09:09:25 +0000
committerDirk Fauth2016-01-28 15:29:11 +0000
commit9a28be7f0b23555114259dbfe26892831aa032b7 (patch)
tree5be3fa6dc5b88b19e37a8b1ddc2984defb9e6fb7
parenta61d719c441cc7ac1fc3d16ec19045458749ec2d (diff)
downloadorg.eclipse.nebula.widgets.nattable-9a28be7f0b23555114259dbfe26892831aa032b7.tar.gz
org.eclipse.nebula.widgets.nattable-9a28be7f0b23555114259dbfe26892831aa032b7.tar.xz
org.eclipse.nebula.widgets.nattable-9a28be7f0b23555114259dbfe26892831aa032b7.zip
Bug 486624 - [FillHandle] Open API to allow other difference calculation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=486624 Change-Id: Ib2e80188bf90e20831313b9ac8a2aeff097ca308 Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java
index 2065e5d7..01e9d773 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Dirk Fauth <dirk.fauth@googlemail.com> - Initial API and implementation
- *
+ * Vincent Lorenzo <vincent.lorenzo@cea.fr> - Bug 486624
*****************************************************************************/
package org.eclipse.nebula.widgets.nattable.fillhandle.command;
@@ -190,7 +190,7 @@ public class FillHandlePasteCommandHandler implements ILayerCommandHandler<FillH
Class<?> type = cell.getDataValue() != null ? cell.getDataValue().getClass() : null;
ILayerCell[][] cells = this.clipboard.getCopiedCells();
- int rowDiff = toRow - cell.getRowIndex();
+ int rowDiff = getRowDiff(cell, toRow);
if (cells.length == 1) {
return getCastValue(rowDiff, type);
} else if (type != null) {
@@ -323,7 +323,7 @@ public class FillHandlePasteCommandHandler implements ILayerCommandHandler<FillH
Class<?> type = cell.getDataValue() != null ? cell.getDataValue().getClass() : null;
ILayerCell[][] cells = this.clipboard.getCopiedCells();
- int columnDiff = toColumn - cell.getColumnIndex();
+ int columnDiff = getColumnDiff(cell, toColumn);
int rowArrayIndex = cell.getRowIndex() - this.clipboard.getCopiedCells()[0][0].getRowIndex();
if (cells[rowArrayIndex].length == 1) {
return getCastValue(columnDiff, type);
@@ -452,6 +452,34 @@ public class FillHandlePasteCommandHandler implements ILayerCommandHandler<FillH
return null;
}
+ /**
+ * Calculate the row difference between the cell row index and the row index
+ * of the cell to copy to.
+ *
+ * @param currentCell
+ * The current cell to manage.
+ * @param toRow
+ * The row index of the cell to copy to.
+ * @return The difference as integer.
+ */
+ protected int getRowDiff(final ILayerCell currentCell, final int toRow) {
+ return toRow - currentCell.getRowIndex();
+ }
+
+ /**
+ * Calculate the column difference between the cell column index and the
+ * column index of the cell to copy to.
+ *
+ * @param currentCell
+ * The current cell to manage.
+ * @param toColumn
+ * The column index of the cell to copy to.
+ * @return The difference as integer.
+ */
+ protected int getColumnDiff(final ILayerCell currentCell, final int toColumn) {
+ return toColumn - currentCell.getColumnIndex();
+ }
+
protected Number getCastValue(int diff, Class<?> type) {
if (type != null) {
if (type == Byte.class) {

Back to the top