catch up with development
Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/common/item/GridItem.java b/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/common/item/GridItem.java
index bec6544..ab10c21 100644
--- a/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/common/item/GridItem.java
+++ b/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/common/item/GridItem.java
@@ -58,10 +58,14 @@
int columnCount = 0;
int colspan = 0;
for (GridRow row : grid.getRows()) {
+ int rowCellSpan = 0;
int cellSize = row.getCells().size();
for (GridCell cell : row.getCells()) {
- colspan = Math.max(colspan, cell.getColumnspan() - 1);
+ // "cell.getColumnspan() -1" is required cause without a colspan definition as minimum 1 column has to exist.
+ // Therefore columnCount is used as minimum size of column to be created.
+ rowCellSpan = rowCellSpan + (cell.getColumnspan() -1);
}
+ colspan = Math.max(colspan, rowCellSpan);
columnCount = Math.max(columnCount, cellSize);
}
// 'columnCount' times a column and a cell is created in newGridItem(String, int, int) ...
diff --git a/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/validation/ReportDSLValidator.xtend b/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/validation/ReportDSLValidator.xtend
index 7208857..21b0be4 100644
--- a/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/validation/ReportDSLValidator.xtend
+++ b/org.eclipse.osbp.xtext.reportdsl/src/org/eclipse/osbp/xtext/reportdsl/validation/ReportDSLValidator.xtend
@@ -50,6 +50,7 @@
import org.eclipse.osbp.xtext.reportdsl.Text
import org.eclipse.osbp.xtext.reportdsl.Title
import org.eclipse.xtext.validation.Check
+import org.eclipse.osbp.xtext.reportdsl.GridRow
/**
* Custom validation rules.
@@ -269,6 +270,32 @@
}
}
+ @Check
+ def checkGridCellColumnSpan(Grid grid) {
+ var sumColSpan = 0
+ var firstColSpan = 0
+ for (GridRow row: grid.getRows()) {
+ var rowCellSpan = 0
+ var cellSize = row.getCells().size()
+ for (GridCell cell : row.getCells()){
+ rowCellSpan = rowCellSpan + (cell.getColumnspan - 1)
+ }
+ if (rowCellSpan < 0){
+ sumColSpan = cellSize
+ }else{
+ sumColSpan = rowCellSpan + cellSize
+ }
+ if (firstColSpan == 0){
+ firstColSpan = sumColSpan
+ }else if (sumColSpan != firstColSpan){
+ for (GridCell cell : row.getCells()){
+ error('''Sum of all cells's ColumnSpan of this row should be «firstColSpan».''', cell , ReportDSLPackage.Literals.GRID_CELL__COLUMNSPAN)
+ }
+
+ }
+ }
+ }
+
def private boolean checkPageTemplateBelonging(EObject attribute) {
var eObj = attribute.eContainer
while ((eObj!==null) && !(eObj instanceof PageTemplate)){