changeset 52:cde4a01e9fa8 CellTable

mouse events (over/out/click) for table rows
author Sebastian Kruse <skruse@mpiwg-berlin.mpg.de>
date Mon, 10 Dec 2012 17:02:59 +0100
parents 5d401f5c6433
children 0a3dca94458c
files src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java
diffstat 1 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java	Mon Dec 10 17:02:15 2012 +0100
+++ b/src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java	Mon Dec 10 17:02:59 2012 +0100
@@ -17,6 +17,8 @@
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
 import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.view.client.CellPreviewEvent;
+import com.google.gwt.view.client.CellPreviewEvent.Handler;
 import com.google.gwt.view.client.ListDataProvider;
 import com.google.gwt.view.client.Range;
 import com.google.gwt.core.client.GWT;
@@ -301,6 +303,52 @@
 	    
 	    dataProvider.setList(this.actualObjectSet);
 	    
+	    this.elementsTable.addCellPreviewHandler(new Handler<DataObject>()
+	    	    {
+	    	        //@Override
+	    	        public void onCellPreview(
+	    	            CellPreviewEvent<DataObject> event)
+	    	        {
+	    	        	boolean wasChanged = false;
+	    	        	
+	    	            if ("mouseover".equals(event.getNativeEvent().getType())) {
+	    	            	DataObject hoveredObject = event.getValue();
+	    	            	
+	    	            	if (!hoveredObject.getHover()){
+	    	            		hoveredObject.setHover(true);
+
+	    	            		wasChanged = true;
+	    	            	}
+	    	            }
+	    	            else if ("mouseout".equals(event.getNativeEvent().getType())) {
+	    	            	DataObject hoveredObject = event.getValue();
+	    	            	
+	    	            	if (hoveredObject.getHover()){
+	    	            		hoveredObject.setHover(false);
+		    	            	
+	    	            		wasChanged = true;
+	    	            	}
+	    	            }
+	    	            else if ("click".equals(event.getNativeEvent().getType())) {
+	    	            	DataObject clickedObject = event.getValue();
+	    	            	
+	    	            	if (clickedObject.getPercentage() > 0){
+	    	            		clickedObject.setPercentage(0);
+
+	    	            	} else {
+	    	            		clickedObject.setPercentage(1);
+	    	            	}
+	    	            	
+	    	            	wasChanged = true;
+	    	            }
+	    	            
+	    	            if (wasChanged) {
+	    	            	updateView(true);
+	    	            	core.updateTimeAndMap();
+	    	            }
+	    	        }
+	    	    });
+	    
 	    this.setWidget(1, 0, this.elementsTable);
 	    
 		Grid tableControls = new Grid(1,5);