[jboss-svn-commits] JBL Code SVN: r7264 - in labs/jbossrules/trunk/drools-jbrms: . src/main/java/org/drools/brms/client/decisiontable src/main/java/org/drools/brms/public

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 1 06:51:14 EST 2006


Author: stevearoonie
Date: 2006-11-01 06:51:03 -0500 (Wed, 01 Nov 2006)
New Revision: 7264

Removed:
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeDialog.java
Modified:
   labs/jbossrules/trunk/drools-jbrms/
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java
   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/InsertAction.java
   labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css
Log:
move actions out to toolbar for DT editor


Property changes on: labs/jbossrules/trunk/drools-jbrms
___________________________________________________________________
Name: svn:ignore
   + repository
target
tomcat
www


Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java	2006-11-01 11:42:23 UTC (rev 7263)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/DeleteAction.java	2006-11-01 11:51:03 UTC (rev 7264)
@@ -29,7 +29,7 @@
     public DeleteAction(final int currentRow, final RowClickListener clickListener) {
         row = currentRow;
         delete = new Image("images/clear_item.gif");
-        delete.setTitle( "Delete this row" );
+        delete.setTitle( "Delete row " + row );
         delete.addClickListener( new ClickListener() {
 			public void onClick(final Widget w) {
 				clickListener.onClick(w, row);
@@ -43,6 +43,7 @@
     
     public void setRow(final int row) {
     	this.row = row;
+    	delete.setTitle("Delete row " + row);
     }
     
     public int getRow() {

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-01 11:42:23 UTC (rev 7263)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/EditableDTGrid.java	2006-11-01 11:51:03 UTC (rev 7264)
@@ -1,10 +1,13 @@
 package org.drools.brms.client.decisiontable;
 
+import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.FlexTable;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.SourcesTableEvents;
+import com.google.gwt.user.client.ui.TableListener;
 import com.google.gwt.user.client.ui.TextBox;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
@@ -27,20 +30,31 @@
 public class EditableDTGrid extends Composite {
 
 	private static final int START_DATA_ROW = 1;
-	
-	private static final int EDIT_COLUMN_OFFSET = 1;
+
+	private static final int EDIT_COLUMN_OFFSET = 2;
+
 	private static final int INSERT_COLUMN_OFFSET = EDIT_COLUMN_OFFSET + 1;
+
 	private static final int DELETE_COLUMN_OFFSET = INSERT_COLUMN_OFFSET + 1;
-	private static final int SHUFFLE_UP_COLUMN_OFFSET = DELETE_COLUMN_OFFSET + 1;
-	private static final int SHUFFLE_DOWN_COLUMN_OFFSET = SHUFFLE_UP_COLUMN_OFFSET + 1;
-	private static final int MERGE_COLUMN_OFFSET = SHUFFLE_DOWN_COLUMN_OFFSET + 1;
 
+	// private static final int SHUFFLE_UP_COLUMN_OFFSET = DELETE_COLUMN_OFFSET
+	// + 1;
+	//
+	// private static final int SHUFFLE_DOWN_COLUMN_OFFSET =
+	// SHUFFLE_UP_COLUMN_OFFSET + 1;
+
+	// private static final int MERGE_COLUMN_OFFSET = SHUFFLE_DOWN_COLUMN_OFFSET
+	// + 1;
+
 	private FlexTable table = new FlexTable();
 
+	private int currentRow;
+
+	private int currentCol;
+
 	private FlexCellFormatter cellFormatter = table.getFlexCellFormatter();
 
 	public EditableDTGrid(String dtName) {
-
 		// for if I switch to a Grid
 		// table.resizeColumns( numCols() + 1 );
 		// table.resizeRows( numRows() );
@@ -54,11 +68,20 @@
 		header.add(new Image("images/decision_table.gif"));
 		header.add(title);
 
+		Toolbar toolbar = new Toolbar(this);
+
 		vert.add(header);
+		vert.add(toolbar);
 		vert.add(table);
 
 		table.setStyleName("dt-editor-Grid");
+		table.addTableListener(new TableListener() {
 
+			public void onCellClicked(SourcesTableEvents ste, int row, int col) {
+				setCurrentCell(row, col);
+			}
+		});
+
 		// set up the header
 		populateHeader();
 
@@ -72,6 +95,36 @@
 		initWidget(vert);
 	}
 
+	protected void setCurrentCell(int row, int col) {
+
+		if (col > 0 && col <= numCols() && row > 0 && (row != currentRow || col != currentCol)) {
+			if (currentRow > 0) {
+				cellFormatter.setStyleName(currentRow, currentCol,
+						"dt-editor-Cell");
+			}
+			if (currentRow != row) {
+				if (currentRow > 0) {
+					cellFormatter.setStyleName(currentRow, 0,
+							"dt-editor-CountColumn");
+				}
+				cellFormatter.setStyleName(row, 0,
+						"dt-editor-CountColumn-selected");
+			}
+			if (currentCol != col) {
+				if (currentCol > 0) {
+					cellFormatter.setStyleName(0, currentCol,
+							"dt-editor-DescriptionCell");
+				}
+				cellFormatter.setStyleName(0, col,
+						"dt-editor-DescriptionCell-selected");
+			}
+			cellFormatter.setStyleName(row, col, "dt-editor-Cell-selected");
+			currentRow = row;
+			currentCol = col;
+			editColumn(row, col);
+		}
+	}
+
 	private void populateHeader() {
 
 		// for the count column
@@ -83,6 +136,75 @@
 		}
 	}
 
+	// private class DTCell extends Composite {
+	// private HorizontalPanel panel = new HorizontalPanel();
+	//
+	// private Image merge;
+	//
+	// private Label content;
+	//
+	// private MergeListener mergeListener;
+	//
+	// private SplitListener splitListener;
+	//
+	// DTCell(String value, final MergeListener mergeListener,
+	// final SplitListener splitListener) {
+	// this.mergeListener = mergeListener;
+	// this.splitListener = splitListener;
+	// content = new Label(value);
+	// merge = new Image("images/refresh.gif");
+	// merge.setTitle("Merge cells in this row");
+	// merge.addClickListener(new ClickListener() {
+	//
+	// public void onClick(Widget w) {
+	// MyPopup popup = new MyPopup(mergeListener, splitListener);
+	// popup.setPopupPosition(w.getAbsoluteLeft(), w
+	// .getAbsoluteTop() + 20);
+	// popup.show();
+	// }
+	// });
+	// panel.add(content);
+	// panel.add(merge);
+	// initWidget(panel);
+	// }
+	//
+	// public void setColumn(int col) {
+	// mergeListener.setColumn(col);
+	// splitListener.setColumn(col);
+	// }
+	//
+	// public void setRow(int row) {
+	// mergeListener.setRow(row);
+	// splitListener.setRow(row);
+	// }
+	// }
+
+	// private static class MyPopup extends PopupPanel {
+	//
+	// public MyPopup(ClickListener mergeListener, ClickListener splitListener)
+	// {
+	// // PopupPanel's constructor takes 'auto-hide' as its boolean
+	// // parameter.
+	// // If this is set, the panel closes itself automatically when the
+	// // user
+	// // clicks outside of it.
+	// super(true);
+	//
+	// // PopupPanel is a SimplePanel, so you have to set it's widget
+	// // property to
+	// // whatever you want its contents to be.
+	// HorizontalPanel panel = new HorizontalPanel();
+	// Image mergeLeft = new Image("images/shuffle_up.gif");
+	// mergeLeft.addClickListener(mergeListener);
+	// Image mergeRight = new Image("images/shuffle_down.gif");
+	// mergeRight.addClickListener(splitListener);
+	// panel.add(mergeLeft);
+	// panel.add(mergeRight);
+	// panel.setBorderWidth(1);
+	// setWidget(panel);
+	// }
+	// }
+
 	/**
 	 * This populates the "data" part of the decision table (not the header
 	 * bits). It starts at the row offset.
@@ -103,104 +225,167 @@
 			table.setText(row, 0, Integer.toString(rowCount));
 			cellFormatter.setStyleName(row, 0, "dt-editor-CountColumn");
 			for (; column < numCols() + 1; column++) {
-				table.setText(row, column, "boo " + column);
+				// table.setText(row, column, "boo " + column);
+				String text = "boo " + column;
+				newCell(row, column, text);
 				cellFormatter.setStyleName(row, column, "dt-editor-Cell");
 			}
 
 			final int currentRow = row;
 
-			addActions(currentRow, false);
+			addActions(column, currentRow, false);
 		}
 	}
 
-	private void addActions(final int currentRow, boolean newRow) {
+	private void newCell(int row, int column, String text) {
+		table.setText(row, column, text);
+		// table.setWidget(row, column, new DTCell(text,
+		// new MergeListener(row, column), new SplitListener(row,
+		// column)));
+	}
+
+	// private class MergeListener implements ClickListener {
+	//
+	// private int row;
+	//
+	// private int col;
+	//
+	// MergeListener(int row, int col) {
+	// this.row = row;
+	// this.col = col;
+	// }
+	//
+	// public void onClick(Widget w) {
+	// mergeCell(row, col);
+	// }
+	//
+	// public void setColumn(int col) {
+	// this.col = col;
+	//			
+	// }
+	//
+	// public void setRow(int row) {
+	// this.row = row;
+	// }
+	//
+	// }
+	//
+	// private class SplitListener implements ClickListener {
+	//
+	// private int row;
+	//
+	// private int col;
+	//
+	// SplitListener(int row, int col) {
+	// this.row = row;
+	// this.col = col;
+	// }
+	//
+	// public void onClick(Widget w) {
+	// splitCell(row, col);
+	// }
+	//
+	// public void setColumn(int col) {
+	// this.col = col;
+	//			
+	// }
+	//
+	// public void setRow(int row) {
+	// this.row = row;
+	// }
+	//
+	// }
+
+	private void addActions(final int startCol, final int currentRow,
+			boolean newRow) {
 		// the action magic
-		addEditActions(currentRow, newRow);
+		addEditActions(startCol, currentRow, newRow);
 
-		addInsertAction(currentRow);
-		addDeleteAction(currentRow);
-		addShuffleUpAction(currentRow);
-		addShuffleDownAction(currentRow);
-		addMergeAction(currentRow);
+		// addInsertAction(startCol, currentRow);
+		// addDeleteAction(startCol, currentRow);
+		// addShuffleUpAction(startCol, currentRow);
+		// addShuffleDownAction(startCol, currentRow);
+		// addMergeAction(currentRow);
 	}
 
-	private void addShuffleDownAction(final int currentRow) {
-		final ShuffleAction shuffleDownAction;
-		if (currentRow == numRows()) {
-			shuffleDownAction = new ShuffleAction();
-		} else {
-		shuffleDownAction = new ShuffleDownAction(
-				currentRow, new RowClickListener() {
-					public void onClick(Widget w, int row) {
-						shuffleDown(row);
-					}
-				});
+	public void mergeCell(int row, int col) {
+		int currentSpan = cellFormatter.getColSpan(row, col);
+		if (col + currentSpan <= numCols()) {
+			int nextSpan = cellFormatter.getColSpan(row, col + 1);
+			table.removeCell(row, col + 1);
+			cellFormatter.setColSpan(row, col, currentSpan + nextSpan);
 		}
-		table.setWidget(currentRow, numCols() + SHUFFLE_DOWN_COLUMN_OFFSET, shuffleDownAction);
 	}
 
-	private void addShuffleUpAction(final int currentRow) {
-		final ShuffleAction shuffleUpAction;
-		if (currentRow == START_DATA_ROW) {
-			shuffleUpAction = new ShuffleAction();
-		} else {
-
-			shuffleUpAction = new ShuffleUpAction(currentRow,
-					new RowClickListener() {
-						public void onClick(Widget w, int row) {
-							shuffleUp(row);
-						}
-					});
+	public void splitCell(int row, int col) {
+		int currentSpan = cellFormatter.getColSpan(row, col);
+		if (currentSpan > 1) {
+			cellFormatter.setColSpan(row, col++, currentSpan - 1);
+			table.insertCell(row, col);
+			newCell(row, col, "");
+			cellFormatter.setStyleName(row, col, "dt-editor-Cell");
 		}
-		table.setWidget(currentRow, numCols() + SHUFFLE_UP_COLUMN_OFFSET, shuffleUpAction);
 	}
 
-	private void addDeleteAction(final int currentRow) {
-		final DeleteAction deleteAction = new DeleteAction(currentRow,
-				new RowClickListener() {
-					public void onClick(Widget w, int row) {
-						deleteRow(row);
-					}
-				});
-		table.setWidget(currentRow, numCols() + DELETE_COLUMN_OFFSET, deleteAction);
-	}
+	// private void addShuffleDownAction(final int numCols, final int
+	// currentRow) {
+	// final ShuffleAction shuffleDownAction;
+	// if (currentRow == numRows()) {
+	// shuffleDownAction = new ShuffleAction();
+	// } else {
+	// shuffleDownAction = new ShuffleDownAction(currentRow,
+	// new RowClickListener() {
+	// public void onClick(Widget w, int row) {
+	// shuffleDown(row);
+	// }
+	// });
+	// }
+	// table.setWidget(currentRow, numCols + SHUFFLE_DOWN_COLUMN_OFFSET,
+	// shuffleDownAction);
+	// }
 
-	private void addMergeAction(final int currentRow) {
-		final MergeAction mergeAction = new MergeAction(currentRow,
-				new RowClickListener() {
-			public void onClick(Widget w, int row) {
-				showMergeRowDialog(row);
-			}
-		});
-		table.setWidget(currentRow, numCols() + MERGE_COLUMN_OFFSET, mergeAction);
-	}
-	
-	protected void showMergeRowDialog(int row) {
-		MergeDialog dialog = new MergeDialog(this, row);
-		dialog.setPopupPosition(200, 200);
-		dialog.show();		
-	}
-	
-	private void addInsertAction(final int currentRow) {
-		final InsertAction insertAction = new InsertAction(currentRow,
-				new RowClickListener() {
-					public void onClick(Widget w, int row) {
-						insertRow(row);
-					}
-				});
-		table.setWidget(currentRow, numCols() + INSERT_COLUMN_OFFSET, insertAction);
-	}
+	// private void addShuffleUpAction(final int numCols, final int currentRow)
+	// {
+	// final ShuffleAction shuffleUpAction;
+	// if (currentRow == START_DATA_ROW) {
+	// shuffleUpAction = new ShuffleAction();
+	// } else {
+	//
+	// shuffleUpAction = new ShuffleUpAction(currentRow,
+	// new RowClickListener() {
+	// public void onClick(Widget w, int row) {
+	// shuffleUp(row);
+	// }
+	// });
+	// }
+	// table.setWidget(currentRow, numCols + SHUFFLE_UP_COLUMN_OFFSET,
+	// shuffleUpAction);
+	// }
 
-	protected void merge(int row, String startCol, String endCol) {
-		int startColumn = Integer.parseInt(startCol);
-		int endColumn = Integer.parseInt(endCol) + 1;
-		cellFormatter.setColSpan(row, startColumn, endColumn - startColumn);
-		for (int i = startColumn + 1; i < endColumn; i++) {
-			table.removeCell(row, i);
-		}
-	}
+	// private void addDeleteAction(final int numCols, final int currentRow) {
+	// final DeleteAction deleteAction = new DeleteAction(currentRow,
+	// new RowClickListener() {
+	// public void onClick(Widget w, int row) {
+	// deleteRow(row);
+	// }
+	// });
+	// table.setWidget(currentRow, numCols + DELETE_COLUMN_OFFSET,
+	// deleteAction);
+	// }
 
-	private void addEditActions(final int currentRow, boolean newRow) {
+	// private void addInsertAction(final int numCols, final int currentRow) {
+	// final InsertAction insertAction = new InsertAction(currentRow,
+	// new RowClickListener() {
+	// public void onClick(Widget w, int row) {
+	// insertRow(row);
+	// }
+	// });
+	// table.setWidget(currentRow, numCols + INSERT_COLUMN_OFFSET,
+	// insertAction);
+	// }
+
+	private void addEditActions(final int numCols, final int currentRow,
+			boolean newRow) {
 		final EditActions actions = new EditActions(currentRow,
 				new RowClickListener() {
 					public void onClick(Widget w, int row) {
@@ -213,7 +398,7 @@
 				});
 		if (newRow)
 			actions.makeEditable();
-		table.setWidget(currentRow, numCols() + EDIT_COLUMN_OFFSET, actions);
+		table.setWidget(currentRow, numCols + EDIT_COLUMN_OFFSET, actions);
 	}
 
 	/**
@@ -230,50 +415,63 @@
 
 	/**
 	 * Shuffle the given row up one
+	 * 
 	 * @param row
 	 */
-	private void shuffleUp(int row) {
-		//create a new row above the given row
-		//remember that insertRow will insert above the given row
-		//so this is two above the original row
-		int newRow = addNewRow(row - 1);
-		
-		copyRow(row + 1, newRow);
-		addActions(newRow, false);
-		
-		//remove the original row
-		table.removeRow(row + 1);
-		
-		//if the original row was the second row then we need to add a shuffle up
-		//widget to the new second row (originally the first row)
-		if (row == START_DATA_ROW + 1) {
-			addShuffleUpAction(row);
-		}
-		//if the original row was the last row we need to remove the shuffle down
-		//widget from the new last row
-		if (row == numRows()) {
-			removeShuffleDown();
-		}
-		renumberRow(row - 1);
-		renumberRow(row);
+	void moveUp() {
+		// create a new row above the given row
+		// remember that insertRow will insert above the given row
+		// so this is two above the original row
+		int newRow = addNewRow(currentRow - 1);
 
+		int lastCol = copyRow(currentRow + 1, newRow);
+		addActions(lastCol, newRow, false);
+
+		// remove the original row
+		table.removeRow(currentRow + 1);
+
+		// if the original row was the second row then we need to add a shuffle
+		// up
+		// widget to the new second row (originally the first row)
+		// if (currentRow == START_DATA_ROW + 1) {
+		// addShuffleUpAction(lastCol, currentRow);
+		// }
+		// if the original row was the last row we need to remove the shuffle
+		// down
+		// widget from the new last row
+		// if (currentRow == numRows()) {
+		// removeShuffleDown();
+		// }
+		// renumberRow(currentRow - 1);
+		renumberRow(currentRow);
+		currentRow = -1;
+		setCurrentCell(newRow, currentCol);
+
 	}
 
 	/**
 	 * Copy the data from the source row to the target row
+	 * 
 	 * @param sourceRow
 	 * @param targetRow
 	 */
-	private void copyRow(int sourceRow, int targetRow) {
-		//TODO handle editable rows
+	private int copyRow(int sourceRow, int targetRow) {
+		// TODO handle editable rows
 		int column = 1;
-		for (; column < numCols() + 1; column++) {
-			table.setText(targetRow, column, table.getText(sourceRow, column));
-			cellFormatter.setStyleName(targetRow, column, "dt-editor-Cell");
+		int colIndex = 1;
+		while (column <= numCols()) {
+			newCell(targetRow, colIndex, table.getText(sourceRow, colIndex));
+			cellFormatter.setStyleName(targetRow, colIndex, "dt-editor-Cell");
+			int colSpan = cellFormatter.getColSpan(sourceRow, colIndex);
+			column = column + colSpan;
+			cellFormatter.setColSpan(targetRow, colIndex++, colSpan);
 		}
+		return colIndex;
 	}
+
 	/**
 	 * Add a new row and set the row number
+	 * 
 	 * @param row
 	 * @return
 	 */
@@ -286,41 +484,50 @@
 
 	/**
 	 * Shuffle the given row down one
+	 * 
 	 * @param row
 	 */
-	private void shuffleDown(int row) {
-		//create a new row below the given row
-		//remember that insertRow will insert above the given row
-		//so this is two below the original row
-		int newRow = addNewRow(row + 2);
-		
-		copyRow(row, newRow);
-		//remove row before adding action widgets so that the row number
-		//is correct (otherwise the shuffle down button may not be displayed
-		table.removeRow(row);
-		addActions(newRow - 1, false);
-		//if the original row was the first row we need to remove the shuffle up
-		//widget from the new first row
-		if (row == START_DATA_ROW) {
-			removeShuffleUp();
-		}
-		//if the original row was the second last row then we need to add a shuffle down
-		//widget to the new second last row (originally the last row)
-		if (row == numRows() - 1) {
-			addShuffleDownAction(row);
-		}
-		renumberRow(row);
-		renumberRow(row + 1);
+	void moveDown() {
+		// create a new row below the given row
+		// remember that insertRow will insert above the given row
+		// so this is two below the original row
+		int newRow = addNewRow(currentRow + 2);
 
-	}
+		int lastCol = copyRow(currentRow, newRow);
+		// remove row before adding action widgets so that the row number
+		// is correct (otherwise the shuffle down button may not be displayed
+		table.removeRow(currentRow);
+		addActions(lastCol, newRow - 1, false);
+		// if the original row was the first row we need to remove the shuffle
+		// up
+		// widget from the new first row
+		// if (row == START_DATA_ROW) {
+		// removeShuffleUp();
+		// }
+		// if the original row was the second last row then we need to add a
+		// shuffle down
+		// widget to the new second last row (originally the last row)
+		// if (row == numRows() - 1) {
+		// addShuffleDownAction(lastCol, row);
+		// }
+		System.err.println("currentRow: " + currentRow);
+		renumberRow(currentRow);
+		renumberRow(currentRow + 1);
+		currentRow = -1;
+		setCurrentCell(newRow - 1, currentCol);
 
-	private void removeShuffleUp() {
-		table.setWidget(START_DATA_ROW, numCols() + SHUFFLE_UP_COLUMN_OFFSET, new ShuffleAction());
 	}
-	private void removeShuffleDown() {
-		table.setWidget(numRows(), numCols() + SHUFFLE_DOWN_COLUMN_OFFSET, new ShuffleAction());
-	}
 
+	// private void removeShuffleUp() {
+	// table.setWidget(START_DATA_ROW, numCols() + SHUFFLE_UP_COLUMN_OFFSET,
+	// new ShuffleAction());
+	// }
+	//
+	// private void removeShuffleDown() {
+	// table.setWidget(numRows(), numCols() + SHUFFLE_DOWN_COLUMN_OFFSET,
+	// new ShuffleAction());
+	// }
+
 	/**
 	 * Delete the specified row
 	 * 
@@ -344,47 +551,58 @@
 			renumberRow(r);
 		}
 	}
+
 	/**
 	 * Renumber the given row and change the row the actions will act on
+	 * 
 	 * @param row
 	 */
 	private void renumberRow(int row) {
 		table.setText(row, 0, Integer.toString(row));
-		int lastColumn = numCols();
-		EditActions editActions = (EditActions) table.getWidget(row,
-				lastColumn + EDIT_COLUMN_OFFSET);
-		editActions.setRow(row);
-		InsertAction insertAction = (InsertAction) table.getWidget(row,
-				lastColumn + INSERT_COLUMN_OFFSET);
-		insertAction.setRow(row);
-		DeleteAction deleteAction = (DeleteAction) table.getWidget(row,
-				lastColumn + DELETE_COLUMN_OFFSET);
-		deleteAction.setRow(row);
-		ShuffleAction shuffleUpAction = (ShuffleAction) table.getWidget(row,
-				lastColumn + SHUFFLE_UP_COLUMN_OFFSET);
-		shuffleUpAction.setRow(row);
-		ShuffleAction shuffleDownAction = (ShuffleAction) table.getWidget(
-				row, lastColumn + SHUFFLE_DOWN_COLUMN_OFFSET);
-		shuffleDownAction.setRow(row);
+		// for (int i = 1; i < numCols(); i++) {
+		// DTCell cell = (DTCell) table.getWidget(row, i);
+		// cell.setRow(row);
+		// }
+		// int lastColumn = numCols();
+		// System.err.println("lastColumn: " + lastColumn);
+		// System.err.println("row: " + row);
+		// System.err.println("table.getHTML(row, lastColumn): "
+		// + table.getHTML(row, lastColumn + EDIT_COLUMN_OFFSET));
+		// EditActions editActions = (EditActions) table.getWidget(row,
+		// lastColumn
+		// + EDIT_COLUMN_OFFSET);
+		// editActions.setRow(row);
+		// InsertAction insertAction = (InsertAction) table.getWidget(row,
+		// lastColumn + INSERT_COLUMN_OFFSET);
+		// insertAction.setRow(row);
+		// DeleteAction deleteAction = (DeleteAction) table.getWidget(row,
+		// lastColumn + DELETE_COLUMN_OFFSET);
+		// deleteAction.setRow(row);
+		// ShuffleAction shuffleUpAction = (ShuffleAction) table.getWidget(row,
+		// lastColumn + SHUFFLE_UP_COLUMN_OFFSET);
+		// shuffleUpAction.setRow(row);
+		// ShuffleAction shuffleDownAction = (ShuffleAction)
+		// table.getWidget(row,
+		// lastColumn + SHUFFLE_DOWN_COLUMN_OFFSET);
+		// shuffleDownAction.setRow(row);
 	}
 
 	/**
 	 * Add a new row after the specified row
-	 * 
-	 * @param row
-	 *            the row to insert after
 	 */
-	private void insertRow(int row) {
-		numRows++;
-		int newRow = addNewRow(row + 1);
-		int column = 1;
-		for (; column < numCols() + 1; column++) {
-			table.setText(newRow, column, "new " + cellId++);
-			cellFormatter.setStyleName(newRow, column, "dt-editor-Cell");
+	void insertRow() {
+		if (currentRow >= START_DATA_ROW) {
+			numRows++;
+			int newRow = addNewRow(currentRow + 1);
+			int column = 1;
+			for (; column < numCols() + 1; column++) {
+				table.setText(newRow, column, "new " + cellId++);
+				cellFormatter.setStyleName(newRow, column, "dt-editor-Cell");
+			}
+			addActions(column, newRow, true);
+			editRow(newRow);
+			reorderRows(newRow);
 		}
-		addActions(newRow, true);
-		editRow(newRow);
-		reorderRows(newRow);
 	}
 
 	/**
@@ -393,7 +611,7 @@
 	private void updateRow(int row) {
 		for (int column = 1; column < numCols() + 1; column++) {
 			TextBox text = (TextBox) table.getWidget(row, column);
-			table.setText(row, column, text.getText());
+			newCell(row, column, text.getText());
 		}
 	}
 
@@ -404,16 +622,20 @@
 	 */
 	private void editRow(int row) {
 		for (int column = 1; column < numCols() + 1; column++) {
-			String text = table.getText(row, column);
-			TextBox box = new TextBox();
-			box.setText(text);
-			box.setStyleName("dsl-field-TextBox");
-			box.setVisibleLength(3);
-			table.setWidget(row, column, box);
-
+			editColumn(row, column);
 		}
 	}
 
+	private void editColumn(int row, int column) {
+		String text = table.getText(row, column);
+		TextBox box = new TextBox();
+		box.setText(text);
+		box.setStyleName("dsl-field-TextBox");
+		//box.setVisibleLength(3);
+		table.setWidget(row, column, box);
+		box.setFocus(true);
+	}
+
 	private int numCols() {
 		return 6;
 	}

Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java	2006-11-01 11:42:23 UTC (rev 7263)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/InsertAction.java	2006-11-01 11:51:03 UTC (rev 7264)
@@ -29,7 +29,7 @@
     public InsertAction(final int currentRow, final RowClickListener clickListener) {
         row = currentRow;
         insert = new Image("images/new_item.gif");
-        insert.setTitle( "Insert row after this row" );
+        insert.setTitle( "Insert row after row " + row );
         insert.addClickListener( new ClickListener() {
 			public void onClick(final Widget w) {
 				clickListener.onClick(w, row);
@@ -43,6 +43,8 @@
     
     public void setRow(final int row) {
     	this.row = row;
+    	insert.setTitle( "Insert row after row " + row );
+    	
     }
     
     public int getRow() {

Deleted: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeDialog.java	2006-11-01 11:42:23 UTC (rev 7263)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/client/decisiontable/MergeDialog.java	2006-11-01 11:51:03 UTC (rev 7264)
@@ -1,58 +0,0 @@
-package org.drools.brms.client.decisiontable;
-
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-/**
- * Dialog to handle merging cells
- * @author Steven Williams
- *
- */
-class MergeDialog extends DialogBox {
-	MergeDialog(final EditableDTGrid dt, final int row) {
-		setText("Merge cells");
-		VerticalPanel form = new VerticalPanel();
-		form.setSpacing(4);
-		Grid grid = new Grid(2, 2);
-		grid.setCellSpacing(4);
-		grid.setWidget(0, 0, new Label("Start column"));
-		final TextBox startColumn = new TextBox();
-		grid.setWidget(0, 1, startColumn);
-		grid.setWidget(1, 0, new Label("End column"));
-		final TextBox endColumn = new TextBox();
-		grid.setWidget(1, 1, endColumn);
-		form.add(grid);
-		Button okay = new Button("OK");
-		okay.addClickListener(new ClickListener() {
-
-			public void onClick(Widget arg0) {
-				dt.merge(row, startColumn.getText(), endColumn.getText());
-				hide();
-			}
-			
-		});
-		Button cancel = new Button("Cancel");
-		cancel.addClickListener(new ClickListener() {
-			
-			public void onClick(Widget arg0) {
-				hide();
-			}
-			
-		});
-		form.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
-		HorizontalPanel buttons = new HorizontalPanel();
-		buttons.setSpacing(4);
-		buttons.add(okay);
-		buttons.add(cancel);
-		form.add(buttons);
-		setWidget(form);
-		
-	}
-}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css
===================================================================
--- labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css	2006-11-01 11:42:23 UTC (rev 7263)
+++ labs/jbossrules/trunk/drools-jbrms/src/main/java/org/drools/brms/public/JBRMS.css	2006-11-01 11:51:03 UTC (rev 7264)
@@ -293,26 +293,52 @@
   padding: 2px;
 }
 
+.dt-editor-Toolbar {
+  background-color: white;
+  border: 1px solid #87B3FF; 
+  padding: 2px;
+}
+
+.dt-editor-Cell-selected {
+  background-color: white;
+  border: 2px solid #87B3FF; 
+  font-size: smaller;
+  padding: 2px;
+}
+
 .dt-editor-DescriptionCell {
   background-color: #FDFCDC;
   font-size: smaller;
   padding: 3px;
 }
 
+.dt-editor-DescriptionCell-selected {
+  background-color: #87B3FF;
+  color : #FFFFFF;
+  font-size: smaller;
+  padding: 3px;
+}
+
 .dt-editor-CountColumn {
   background-color: #FDFCDC;
   font-size: smaller;
   padding: 3px;
 }
+.dt-editor-CountColumn-selected {
+  background-color: #87B3FF;
+  color : #FFFFFF;
+  font-size: smaller;
+  padding: 3px;
+}
 
-
 .dt-editor-Title {
   font-size: larger;
 }
 
 .dsl-field-TextBox {
-  border: 1px solid #87B3FF;
+  border: none;
   padding: 0px;	
+  width: 100%;
 }
 
 .rule-viewer-Documentation {




More information about the jboss-svn-commits mailing list