method naming: getXofY(X, Y)
diff --git a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataReadAccessor.xtend b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataReadAccessor.xtend
index c871bf9..d806a79 100644
--- a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataReadAccessor.xtend
+++ b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataReadAccessor.xtend
@@ -7,6 +7,6 @@
/**
* @return The data value associated with the cell at the given column and row position.
*/
- def Object getCellDataValue(Layer layer, Serializable columnId, Serializable rowId)
+ def Object getDataValueOfCell(Layer layer, Serializable columnId, Serializable rowId)
}
\ No newline at end of file
diff --git a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataWriteAccessor.xtend b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataWriteAccessor.xtend
index e5907d1..a8292f2 100644
--- a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataWriteAccessor.xtend
+++ b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerDataWriteAccessor.xtend
@@ -7,6 +7,6 @@
/**
* Sets a new value for the data associated with the cell at the given column and row position.
*/
- def void setCellDataValue(Layer layer, Serializable columnId, Serializable rowId, Object newValue)
+ def void setDataValueOfCell(Object newValue, Layer layer, Serializable columnId, Serializable rowId)
}
\ No newline at end of file
diff --git a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/axis/impl/SimpleAxis.xtend b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/axis/impl/SimpleAxis.xtend
index 49a5b14..b2479a2 100644
--- a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/axis/impl/SimpleAxis.xtend
+++ b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/axis/impl/SimpleAxis.xtend
@@ -4,6 +4,8 @@
import java.util.TreeMap
import org.eclipse.nebula.widgets.nattable.core.layer.axis.Axis
+import static extension org.eclipse.nebula.widgets.nattable.core.layer.axis.AxisInvariants.*
+
/**
* A simple Axis implementation.
*/
@@ -11,7 +13,7 @@
int segmentCount
int defaultSegmentSize
- val sizeMap = new TreeMap<Integer, Integer> // segment position -> pixel size
+ val segmentSizeMap = new TreeMap<Integer, Integer> // segment Position -> pixel size
new(int segmentCount, int defaultSegmentSize) {
this.segmentCount = segmentCount
@@ -27,14 +29,14 @@
override getStartPixelOfSegmentPosition(int segmentPosition) {
if (segmentPosition < 0) return -1
else if (segmentPosition == 0) return 0
- else if (sizeMap.empty) return segmentPosition * defaultSegmentSize
+ else if (segmentSizeMap.empty) return segmentPosition * defaultSegmentSize
else {
var numResizedSegments = 0
var resizeAggregate = 0
- for (resizedPosition : sizeMap.subMap(0, segmentPosition).keySet) {
+ for (resizedSegmentPosition : segmentSizeMap.subMap(0, segmentPosition).keySet) {
numResizedSegments = numResizedSegments + 1
- resizeAggregate = resizeAggregate + sizeMap.get(resizedPosition)
+ resizeAggregate = resizeAggregate + segmentSizeMap.get(resizedSegmentPosition)
}
return ((segmentPosition - numResizedSegments) * defaultSegmentSize) + resizeAggregate
@@ -58,10 +60,11 @@
//
- def void setSegmentPixelSize(int segmentPosition, int size) {
+ def void setPixelSizeOfSegmentPosition(int size, int segmentPosition) {
+ if (!containsSegmentPosition(segmentPosition)) throw new IllegalArgumentException('''segment position «segmentPosition» is not contained in this axis''')
if (size < 0) throw new IllegalArgumentException("size must be >= 0")
- sizeMap.put(segmentPosition, size)
+ segmentSizeMap.put(segmentPosition, size)
}
}
\ No newline at end of file
diff --git a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/LayerDataAccessorCell.xtend b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/LayerDataAccessorCell.xtend
index 4e4118b..c9d7112 100644
--- a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/LayerDataAccessorCell.xtend
+++ b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/LayerDataAccessorCell.xtend
@@ -20,7 +20,7 @@
// Cell interface
override getDataValue() {
- layerDataAccessor.getCellDataValue(
+ layerDataAccessor.getDataValueOfCell(
layer,
layer.getColumnIdOfPosition(positionBounds.originPosition.columnPosition),
layer.getRowIdOfPosition(positionBounds.originPosition.rowPosition)
@@ -28,11 +28,11 @@
}
override setDataValue(Object newValue) {
- layerDataAccessor.setCellDataValue(
+ layerDataAccessor.setDataValueOfCell(
+ newValue,
layer,
layer.getColumnIdOfPosition(positionBounds.originPosition.columnPosition),
- layer.getRowIdOfPosition(positionBounds.originPosition.rowPosition),
- newValue
+ layer.getRowIdOfPosition(positionBounds.originPosition.rowPosition)
)
}
diff --git a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/LayerDataAccessorImpl.xtend b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/LayerDataAccessorImpl.xtend
index 288d447..7e4ec35 100644
--- a/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/LayerDataAccessorImpl.xtend
+++ b/NatTable/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/LayerDataAccessorImpl.xtend
@@ -20,12 +20,12 @@
this.layerDataWriteAccessor = layerDataWriteAccessor
}
- override getCellDataValue(Layer layer, Serializable columnId, Serializable rowId) {
- layerDataReadAccessor.getCellDataValue(layer, columnId, rowId)
+ override getDataValueOfCell(Layer layer, Serializable columnId, Serializable rowId) {
+ layerDataReadAccessor.getDataValueOfCell(layer, columnId, rowId)
}
- override setCellDataValue(Layer layer, Serializable columnId, Serializable rowId, Object newValue) {
- layerDataWriteAccessor?.setCellDataValue(layer, columnId, rowId, newValue)
+ override setDataValueOfCell(Object newValue, Layer layer, Serializable columnId, Serializable rowId) {
+ layerDataWriteAccessor?.setDataValueOfCell(newValue, layer, columnId, rowId)
}
}
\ No newline at end of file
diff --git a/NatTable/test/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend b/NatTable/test/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend
index d669077..593445c 100644
--- a/NatTable/test/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend
+++ b/NatTable/test/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend
@@ -49,17 +49,16 @@
static def getSWTNatTable(Shell shell) {
val natTable = new SWTNatTable(shell)
- val bodyHorizontalAxis = new ReorderAxis(
- new SimpleAxis(4, 200) => [ setSegmentPixelSize(0, 100) ]
- ) => [ reorderSegmentPosition(1, 2) ]
-
- val bodyVerticalAxis = new HideShowAxis(
- new SimpleAxis(4, 100) => [ setSegmentPixelSize(2, 200) ]
- ) => [ hideSegmentId(0) ]
-
val bodyLayer = new DummyLayer(
- bodyHorizontalAxis,
- bodyVerticalAxis
+ // Horizontal axis
+ new ReorderAxis(
+ new SimpleAxis(4, 200) => [ setPixelSizeOfSegmentPosition(100, 0) ]
+ ) => [ reorderSegmentPosition(1, 2) ],
+
+ // Vertical axis
+ new HideShowAxis(
+ new SimpleAxis(4, 100) => [ setPixelSizeOfSegmentPosition(200, 2) ]
+ ) => [ hideSegmentId(0) ]
)
// val bodyLayer = new ViewportLayer(new DummyLayer(4, 4, 200, 100), new SWTControlPixelArea(natTable))
// natTable.horizontalBar.addListener(SWT::Selection, [ Event event |