changeset 44:5db587ba4b0f CellTable

background and border color of CellTable for selection and hover
author Sebastian Kruse <skruse@mpiwg-berlin.mpg.de>
date Fri, 07 Dec 2012 18:57:02 +0100
parents fad6fb60a2db
children 169bf48359e2
files src/econnect/wp3_3/client/core/DataObject.java src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java
diffstat 2 files changed, 48 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/econnect/wp3_3/client/core/DataObject.java	Fri Dec 07 16:04:27 2012 +0100
+++ b/src/econnect/wp3_3/client/core/DataObject.java	Fri Dec 07 18:57:02 2012 +0100
@@ -135,6 +135,15 @@
 		this.setHover(hover);
 	}-*/;
 
+	/**
+     * Getter for the hover status of the DataObject
+     *
+     * @param hover boolean value is true, if the object is hovered
+    */
+	public final native boolean getHover()  /*-{
+		return (this.hoverSelect == true);
+	}-*/;
+
     /**
      * Setter for the selection of the DataObject
      *
--- a/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java	Fri Dec 07 16:04:27 2012 +0100
+++ b/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java	Fri Dec 07 18:57:02 2012 +0100
@@ -18,7 +18,11 @@
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
 import com.google.gwt.user.client.ui.TextBox;
 import com.google.gwt.view.client.ListDataProvider;
+import com.google.gwt.view.client.Range;
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.NodeList;
+import com.google.gwt.dom.client.Style.BorderStyle;
+import com.google.gwt.dom.client.TableCellElement;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.MouseOutEvent;
@@ -335,9 +339,12 @@
 		//if the dataProvider already exists, refresh the
 		//displayed data
 		if (this.dataProvider != null) {
+			
+			//refresh data
 			this.dataProvider.refresh();
-		
 			this.elementsTable.setRowCount(this.actualObjectSet.size());
+
+			this.updateView(false);
 		}
 		
 		if (dataSetWasEmpty)
@@ -429,7 +436,7 @@
 				currentDataObject.setPercentage(0);
 		}
 		
-		setActualObjectSet();
+		updateView(false);
 	}
 	
     /**
@@ -442,15 +449,37 @@
 			showSelected.removeStyleName("selectedView");
 			this.viewAll = 0;		
 		}
-		/*
-		for( int i=0; i<this.displayedObjects.length; i++ ){
-			for( int j=0; j<this.displayedObjects[i].length; j++ ){
-				if( this.displayedObjects[i][j] != null && this.displayedObjects[i][j].getStatus() ){
-					updateCell(i,j);
-				}
+		
+		//redraw colors of elements (selected/unselected)
+	    int start = this.elementsTable.getVisibleRange().getStart();
+	    for (int i=0; i<this.elementsTable.getPageSize(); i++) {
+	    	
+	    	if ((start+i) >= dataProvider.getList().size())
+	    		break;
+	    	
+	    	DataObject object = dataProvider.getList().get(start+i);
+	    	
+			boolean selected = object.isSelected();
+			if (hover)
+				selected = object.getHover();
+
+			double percentage = (new Double(object.getPercentage()).doubleValue());
+			String borderColor = StiCore.getBorderColor(this.index,selected);
+			String cellColor = StiCore.getCellColor(this.index,percentage);
+
+			//TODO: das RowElement ist ein TR. Das hat kein Border, weswegen es
+			//auch keine Farbe bekommt. Erst einmal allen sub-Elementen die
+			// border-Color geben. Das sollte verbessert werden.
+			
+			NodeList<TableCellElement> cells = this.elementsTable.getRowElement(i).getCells();
+			
+			for (int cellIndex=0; cellIndex < cells.getLength(); cellIndex++){
+				cells.getItem(cellIndex).getStyle().setBorderColor(borderColor);
 			}
-		}
-		*/
+			
+			this.elementsTable.getRowElement(i).getStyle().setBorderColor(borderColor);
+			this.elementsTable.getRowElement(i).getStyle().setBackgroundColor(cellColor);
+	    }
 	}
 
 	public String getTermIdentifier() {