[jboss-svn-commits] JBL Code SVN: r7462 - in labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable: . model
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Nov 8 07:48:30 EST 2006
Author: stevearoonie
Date: 2006-11-08 07:48:25 -0500 (Wed, 08 Nov 2006)
New Revision: 7462
Modified:
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java
labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java
Log:
add merge row
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java 2006-11-08 11:56:06 UTC (rev 7461)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java 2006-11-08 12:48:25 UTC (rev 7462)
@@ -36,7 +36,7 @@
public class EditableDTGrid extends Composite {
private static final int START_DATA_ROW = 1;
-
+
private DecisionTable dt;
private FlexTable table = new FlexTable();
@@ -44,7 +44,7 @@
private int currentRow;
private int currentCol;
-
+
private Cell currentCell;
private FlexCellFormatter cellFormatter = table.getFlexCellFormatter();
@@ -113,39 +113,40 @@
}
protected void setCurrentCell(int row, int column) {
- System.out.println("row: " + row + ", col: " + column);
- if (column > 0 && column <= numCols() && row >= START_DATA_ROW
- && (row != currentRow || column != currentCol)) {
+ if (column > 0 && column <= numCols() && row >= START_DATA_ROW) {
Cell selectedCell = dt.getRow(row - 1).getCell(column - 1);
- int col = selectedCell.getColumnIndex() + 1;
- System.out.println("cell: " + selectedCell);
+ if (selectedCell != currentCell) {
+ int col = selectedCell.getColumnIndex() + 1;
- if (currentRow >= START_DATA_ROW) {
- TextBox text = (TextBox) table
- .getWidget(currentRow, currentCol);
- newCell(currentRow, currentCol, text.getText());
- }
- if (currentRow != row) {
- if (currentRow > START_DATA_ROW) {
- cellFormatter.setStyleName(currentRow, 0,
- "dt-editor-CountColumn");
+ if (currentRow >= START_DATA_ROW) {
+ TextBox text = (TextBox) table.getWidget(currentRow,
+ currentCol);
+ newCell(currentRow, currentCol, text.getText());
}
- cellFormatter.setStyleName(row, 0,
- "dt-editor-CountColumn-selected");
- }
- if (currentCol != col) {
- if (currentCol > 0) {
- cellFormatter.setStyleName(0, currentCell.getColumnIndex() + 1,
- "dt-editor-DescriptionCell");
+ if (currentCell == null || currentRow != row) {
+ if (currentCell != null) {
+ cellFormatter.setStyleName(currentRow, 0,
+ "dt-editor-CountColumn");
+ }
+ cellFormatter.setStyleName(row, 0,
+ "dt-editor-CountColumn-selected");
}
- cellFormatter.setStyleName(0, col,
- "dt-editor-DescriptionCell-selected");
+ if (currentCell == null || (currentCell.getColumnIndex() + 1) != col) {
+ if (currentCell != null) {
+ cellFormatter.setStyleName(0, currentCell
+ .getColumnIndex() + 1,
+ "dt-editor-DescriptionCell");
+ }
+ cellFormatter.setStyleName(0, col,
+ "dt-editor-DescriptionCell-selected");
+ }
+ cellFormatter.setStyleName(row, column,
+ "dt-editor-Cell-selected");
+ currentRow = row;
+ currentCol = column;
+ currentCell = selectedCell;
+ editColumn(row, column);
}
- cellFormatter.setStyleName(row, column, "dt-editor-Cell-selected");
- currentRow = row;
- currentCol = column;
- currentCell = selectedCell;
- editColumn(row, column);
}
}
@@ -153,7 +154,7 @@
Row row = dt.getHeaderRow();
// for the count column
cellFormatter.setStyleName(0, 0, "dt-editor-DescriptionCell");
-
+
table.setText(0, 0, "");
cellFormatter.setStyleName(0, 0, "dt-editor-CountColumn");
@@ -161,7 +162,7 @@
Column column = (Column) it.next();
newHeaderCell(row.getCell(column));
}
-
+
}
/**
@@ -173,7 +174,7 @@
*/
private void populateDataGrid() {
int i = 1;
- for (Iterator it = dt.getRows().iterator(); it.hasNext();i++) {
+ for (Iterator it = dt.getRows().iterator(); it.hasNext(); i++) {
Row row = (Row) it.next();
table.setText(i, 0, Integer.toString(i));
cellFormatter.setStyleName(i, 0, "dt-editor-CountColumn");
@@ -181,7 +182,7 @@
Column column = (Column) it2.next();
newCell(row.getCell(column));
}
-
+
}
}
@@ -202,7 +203,7 @@
cellFormatter.setColSpan(rowIndex, columnIndex, cell.getColspan());
cellFormatter.setRowSpan(rowIndex, columnIndex, cell.getRowspan());
}
-
+
private void newCell(int row, int column, String text) {
table.setText(row, column, text);
cellFormatter.setStyleName(row, column, "dt-editor-Cell");
@@ -211,7 +212,7 @@
public void mergeCol() {
if (currentCell != null) {
dt.mergeCol(currentCell);
-// if (currentRow >= START_DATA_ROW && currentCol > 0) {
+ // if (currentRow >= START_DATA_ROW && currentCol > 0) {
int currentSpan = cellFormatter.getColSpan(currentRow, currentCol);
if (currentCol + currentSpan <= numCols()) {
int nextSpan = cellFormatter.getColSpan(currentRow,
@@ -232,12 +233,14 @@
}
public void mergeRow() {
- if (currentRow >= START_DATA_ROW && currentCol > 0) {
+ if (currentCell != null) {
+ // if (currentRow >= START_DATA_ROW && currentCol > 0) {
mergeRow(currentRow, currentCol);
}
}
private void mergeRow(int row, int col) {
+ dt.mergeRow(currentCell);
int currentSpan = cellFormatter.getRowSpan(row, col);
if (row + currentSpan <= numRows) {
int nextSpan = cellFormatter.getRowSpan(row + currentSpan, col);
@@ -447,5 +450,4 @@
return 6;
}
-
}
Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java 2006-11-08 11:56:06 UTC (rev 7461)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/model/DecisionTable.java 2006-11-08 12:48:25 UTC (rev 7462)
@@ -59,11 +59,7 @@
public void mergeCol(Cell currentCell) {
Row row = currentCell.getRow();
- System.err.println("currentCell.getColumnIndex(): "
- + currentCell.getColumnIndex());
int currentColspan = currentCell.getColspan();
- System.err.println("currentCell.getColspan(): "
- + currentColspan);
int nextCellColumnIndex = currentCell.getColumnIndex() + currentColspan;
Column nextColumn = (Column) columns.get(nextCellColumnIndex);
Cell nextCell = row.getCell(nextColumn);
@@ -71,4 +67,15 @@
row.removeColumn(nextColumn);
nextColumn.removeCell(nextCell);
}
+
+ public void mergeRow(Cell currentCell) {
+ Column column = currentCell.getColumn();
+ int currentRowspan = currentCell.getRowspan();
+ int nextCellRowIndex = currentCell.getRowIndex() + currentRowspan;
+ Row nextRow = (Row) rows.get(nextCellRowIndex);
+ Cell nextCell = nextRow.getCell(column);
+ currentCell.setRowspan(currentRowspan + nextCell.getRowspan());
+ nextRow.removeColumn(column);
+ column.removeCell(nextCell);
+ }
}
More information about the jboss-svn-commits
mailing list