[Tynstep-svn] r69 - in trunk/step-web-app: . .settings src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/events src/main/java/com/tyndalehouse/step/web/server/common src/main/java/com/tyndalehouse/step/web/server/db src/main/resources war/css

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Tue Dec 29 12:43:58 MST 2009


Author: ChrisBurrell
Date: 2009-12-29 12:43:58 -0700 (Tue, 29 Dec 2009)
New Revision: 69

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEventDescriptor.java
Modified:
   trunk/step-web-app/.classpath
   trunk/step-web-app/.project
   trunk/step-web-app/.settings/com.google.gwt.eclipse.core.prefs
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/TimelineConstants.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/events/TimelineMouseHandler.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/DbProvider.java
   trunk/step-web-app/src/main/resources/log4j.properties
   trunk/step-web-app/war/css/step.css
Log:
creating hover popup for timeline events

Modified: trunk/step-web-app/.classpath
===================================================================
--- trunk/step-web-app/.classpath	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/.classpath	2009-12-29 19:43:58 UTC (rev 69)
@@ -23,5 +23,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
 	<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER/GWT (2)"/>
 	<classpathentry kind="lib" path="war/WEB-INF/lib/gwt-servlet.jar"/>
+	<classpathentry kind="con" path="DERBY_CONTAINER"/>
 	<classpathentry kind="output" path="war/WEB-INF/classes"/>
 </classpath>

Modified: trunk/step-web-app/.project
===================================================================
--- trunk/step-web-app/.project	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/.project	2009-12-29 19:43:58 UTC (rev 69)
@@ -25,5 +25,7 @@
 		<nature>org.eclipse.jdt.core.javanature</nature>
 		<nature>com.google.gwt.eclipse.core.gwtNature</nature>
 		<nature>com.google.gdt.eclipse.core.webAppNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.apache.derby.ui.derbyEngine</nature>
 	</natures>
 </projectDescription>

Modified: trunk/step-web-app/.settings/com.google.gwt.eclipse.core.prefs
===================================================================
--- trunk/step-web-app/.settings/com.google.gwt.eclipse.core.prefs	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/.settings/com.google.gwt.eclipse.core.prefs	2009-12-29 19:43:58 UTC (rev 69)
@@ -1,5 +1,5 @@
-#Sun Dec 13 06:17:04 GMT 2009
+#Sat Dec 19 14:28:25 GMT 2009
 eclipse.preferences.version=1
 entryPointModules=
 filesCopiedToWebInfLib=gwt-servlet.jar
-gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy1kcmFmdENvbXBpbGVdXT48L2V4dHJhLWFyZ3M+PHZtLWFyZ3M+PCFbQ0RBVEFbLVhteDUxMm1dXT48L3ZtLWFyZ3M+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\=
+gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+REVUQUlMRUQ8L291dHB1dC1zdHlsZT48ZXh0cmEtYXJncz48IVtDREFUQVstZHJhZnRDb21waWxlXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -311,4 +311,11 @@
 		//also recalculate the times and dates of the events (perhaps this is not always necessary)
 		setupEventSpecificOptions(); // a few extra bits in there, but nothing that takes time
 	}
+	
+	/** returns the event div that is shown on the screen
+	 * @return the eventDiv
+	 */
+	public Element getEventDiv() {
+		return eventDiv;
+	}
 }

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEventDescriptor.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEventDescriptor.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEventDescriptor.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -0,0 +1,77 @@
+package com.tyndalehouse.step.web.client.toolkit.timeline;
+
+import java.util.HashMap;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.extjs.gxt.ui.client.core.El;
+import com.google.gwt.event.dom.client.MouseEvent;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.tyndalehouse.step.web.client.toolkit.timeline.components.TimelineConstants;
+
+/**
+ * There is only one timeline descriptor for the timeline module.
+ * This shows some content driven from the TimeEvent bean
+ * @author cjburrell
+ *
+ */
+public class TimeEventDescriptor {
+	/**
+	 * Singleton-like pattern keyed on timeline object
+	 */
+	private static HashMap<Timeline, TimeEventDescriptor> descriptors = new HashMap<Timeline, TimeEventDescriptor>();
+	private Element div;
+	private El divWrapper;
+	
+	/**
+	 * private constructor initialising the descriptor
+	 */
+	private TimeEventDescriptor(Timeline timeline) {
+		div = DOM.createDiv();
+		divWrapper = new El(div);
+		
+		divWrapper.setStyleName("step-timeline-time-event-descriptor");
+		divWrapper.setDisplayed(false);
+		
+		//append to timeline component
+		timeline.getElement().appendChild(div);
+	}
+	
+	/**
+	 * No need to synchronise here, since javascript is single threaded
+	 * @param te TimeEvent is used to find the timeline div if need is to initialise
+	 * Could pass in timeline, but not need here...
+	 */
+	private static TimeEventDescriptor instance(Timeline tl) {
+		if(!descriptors.containsKey(tl)) {
+			descriptors.put(tl, new TimeEventDescriptor(tl));			
+		}
+		return descriptors.get(tl);
+	}
+	
+	/**
+	 * Given a timed event, this shows the description in a div
+	 * @param te
+	 */
+	public static void show(Timeline tl, TimeEvent te, MouseEvent me) {
+		El divWrapper = instance(tl).getDivWrapper();
+		divWrapper.setInnerHtml(te.getId() + " - " + te.getDescription());
+		divWrapper.setDisplayed(true);
+		Log.debug("x: " + me.getX());
+		Log.debug("y: " + me.getY());
+
+		divWrapper.setLeft(tl.getAbsoluteLeft() + me.getX());
+		divWrapper.setTop(tl.getAbsoluteTop() + me.getY() - TimelineConstants.SPACE_BELOW_POPUP);
+	}
+	
+	public static void hide(Timeline tl) {
+		instance(tl).getDivWrapper().setDisplayed(false);
+	}
+
+	/**
+	 * @return the divWrapper
+	 */
+	public El getDivWrapper() {
+		return divWrapper;
+	}
+}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -7,9 +7,12 @@
 
 import com.allen_sauer.gwt.log.client.Log;
 import com.extjs.gxt.ui.client.core.El;
+import com.google.gwt.dom.client.EventTarget;
 import com.google.gwt.event.dom.client.MouseDownEvent;
+import com.google.gwt.event.dom.client.MouseEvent;
 import com.google.gwt.event.dom.client.MouseMoveEvent;
 import com.google.gwt.event.dom.client.MouseOutEvent;
+import com.google.gwt.event.dom.client.MouseOverEvent;
 import com.google.gwt.event.dom.client.MouseUpEvent;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
@@ -66,6 +69,7 @@
 		addDomHandler(tmh, MouseUpEvent.getType());
 		addDomHandler(tmh, MouseDownEvent.getType());
 		addDomHandler(tmh, MouseOutEvent.getType());
+		addDomHandler(tmh, MouseOverEvent.getType());
 	}
 
 	private native static void disableSelection(Element e) /*-{
@@ -77,6 +81,36 @@
 	public void handle(MouseOutEvent event) {
 		downStatus = false;
 	}
+	
+	/**
+	 * An awful lot of events are going to fired and captured and discarded
+	 * and one wonders if this is really the best way to do it
+	 * @param me
+	 */
+	public void handleMouseOverTimeEvent(MouseEvent e) {
+		EventTarget et = e.getNativeEvent().getEventTarget();
+		Element targetElement = et.cast();
+		
+		//find out if moved over event:
+		//Log.debug("Scanning " + timebands.size() + " timebands");
+		for(TimeBand band : timebands) {
+			//Log.debug("Scanning " + band.getEvents().size());
+			for(TimeEvent te : band.getEvents().values()) {
+				if(te.getEventDiv().isOrHasChild(targetElement)) {
+					//Log.debug("Found event:" + te.getId() + " " + te.getDescription());
+					TimeEventDescriptor.show(this, te, e);
+					return;
+				}
+			}
+		}
+		
+		//if no events found, then hide description:
+		TimeEventDescriptor.hide(this);
+	}
+	
+	public void handle(MouseOverEvent e) {
+		handleMouseOverTimeEvent(e);
+	}
 
 	public void handle(MouseMoveEvent e) {
 		if(timebands.size() != 0) {
@@ -103,6 +137,8 @@
 				// needs to be passed back to the server...
 				//TODO: this needs to  be fired also in the case of window resizing events
 				fireTimelineScrollEvent();
+			} else {
+				handleMouseOverTimeEvent(e);
 			}
 		} 
 		//ignore if no timebands, as it is not fully rendered

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/TimelineConstants.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/TimelineConstants.java	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/TimelineConstants.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -17,5 +17,10 @@
 	public static final int POINT_IN_TIME_WIDTH_SPACE = 15;
 	public static final int TAPE_TRACK_HEIGHT = 20 + 1;
 	public static final int EVENT_MIN_WIDTH = 2;
+	
+	/**
+	 * space between the popup and the mouse
+	 */
+	public static final int SPACE_BELOW_POPUP = 20;
 
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/events/TimelineMouseHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/events/TimelineMouseHandler.java	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/events/TimelineMouseHandler.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -6,11 +6,17 @@
 import com.google.gwt.event.dom.client.MouseMoveHandler;
 import com.google.gwt.event.dom.client.MouseOutEvent;
 import com.google.gwt.event.dom.client.MouseOutHandler;
+import com.google.gwt.event.dom.client.MouseOverEvent;
+import com.google.gwt.event.dom.client.MouseOverHandler;
 import com.google.gwt.event.dom.client.MouseUpEvent;
 import com.google.gwt.event.dom.client.MouseUpHandler;
 import com.tyndalehouse.step.web.client.toolkit.timeline.Timeline;
 
-public class TimelineMouseHandler implements MouseMoveHandler, MouseUpHandler, MouseDownHandler, MouseOutHandler {
+public class TimelineMouseHandler implements 	MouseMoveHandler, 
+											 	MouseUpHandler, 
+											 	MouseDownHandler, 
+											 	MouseOutHandler, 
+											 	MouseOverHandler {
 	private final Timeline timeline;
 
 	public TimelineMouseHandler(Timeline timeline) {
@@ -36,4 +42,10 @@
 	public void onMouseMove(MouseMoveEvent event) {
 		timeline.handle(event);		
 	}
+
+	@Override
+	public void onMouseOver(MouseOverEvent event) {
+		timeline.handle(event);
+		
+	}
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -2,7 +2,6 @@
 
 import java.io.IOException;
 import java.net.URL;
-import java.util.Enumeration;
 import java.util.Properties;
 
 public class ConfigProvider {

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/DbProvider.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/DbProvider.java	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/DbProvider.java	2009-12-29 19:43:58 UTC (rev 69)
@@ -4,8 +4,6 @@
 import java.sql.DriverManager;
 import java.sql.SQLException;
 
-import org.apache.derby.client.am.SqlException;
-
 import com.tyndalehouse.step.web.server.common.ConfigNotLoadedException;
 import com.tyndalehouse.step.web.server.common.ConfigProvider;
 

Modified: trunk/step-web-app/src/main/resources/log4j.properties
===================================================================
--- trunk/step-web-app/src/main/resources/log4j.properties	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/src/main/resources/log4j.properties	2009-12-29 19:43:58 UTC (rev 69)
@@ -10,7 +10,7 @@
 
 # messages on second appender
 log4j.appender.A2=org.apache.log4j.RollingFileAppender
-log4j.appender.A2.File=/home/chrisburrell/public_html/step-server.log
+log4j.appender.A2.File=../logs/step-server.log
 log4j.appender.A2.MaxFileSize=100KB
 log4j.appender.A2.MaxBackupIndex=1
 log4j.appender.A2.layout=org.apache.log4j.PatternLayout

Modified: trunk/step-web-app/war/css/step.css
===================================================================
--- trunk/step-web-app/war/css/step.css	2009-12-19 14:09:04 UTC (rev 68)
+++ trunk/step-web-app/war/css/step.css	2009-12-29 19:43:58 UTC (rev 69)
@@ -133,5 +133,12 @@
 }
 
 .step-timeline-control {
-	z-index: 1000;
+	z-index: 120;
+}
+
+.step-timeline-time-event-descriptor {
+	position: absolute;
+	border: 1px dashed blue;
+	background-color: white;
+	z-index: 130;
 }
\ No newline at end of file




More information about the Tynstep-svn mailing list