[Tynstep-svn] r79 - in trunk/step-web-app/src/main/java/com/tyndalehouse/step/web: client/eventhandler client/gin client/presenter client/toolkit/timeline client/toolkit/timeline/components client/toolkit/timeline/exceptions client/toolkit/timeline/helpers client/view server/common server/db server/guice server/handler shared shared/beans shared/command shared/result shared/timeline

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Tue Feb 9 14:43:00 MST 2010


Author: ChrisBurrell
Date: 2010-02-09 14:43:00 -0700 (Tue, 09 Feb 2010)
New Revision: 79

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/timeline/
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/timeline/Unit.java
Removed:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/Unit.java
   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/RefDataDbCommand.java
Modified:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/eventhandler/TimelineScrollEventHandler.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/gin/StepClientModule.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/TimelinePresenter.java
   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/TimeEventDescriptor.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeScale.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeband.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/exceptions/IncapableOfCalculatingRequestWindowException.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/helpers/TimeConversionUtil.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.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/guice/LogProvider.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/beans/TimelineBean.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/command/GetEventsForDateRangeCommand.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetTimelineOriginForScriptureResult.java
Log:
committing latest source code

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/eventhandler/TimelineScrollEventHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/eventhandler/TimelineScrollEventHandler.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/eventhandler/TimelineScrollEventHandler.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -3,6 +3,6 @@
 import com.google.gwt.event.shared.EventHandler;
 import com.tyndalehouse.step.web.client.event.TimelineScrollEvent;
 
-public interface TimelineScrollEventHandler  extends EventHandler {
+public interface TimelineScrollEventHandler extends EventHandler {
 	public void onScroll(TimelineScrollEvent event);
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/gin/StepClientModule.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/gin/StepClientModule.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/gin/StepClientModule.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -14,6 +14,7 @@
 import com.tyndalehouse.step.web.client.presenter.ScriptureSelectorPresenter;
 import com.tyndalehouse.step.web.client.presenter.StepModulePresenter;
 import com.tyndalehouse.step.web.client.presenter.StepPresenter;
+import com.tyndalehouse.step.web.client.presenter.TimebandListPresenter;
 import com.tyndalehouse.step.web.client.presenter.TimelinePresenter;
 import com.tyndalehouse.step.web.client.service.eventbus.StepEventBus;
 import com.tyndalehouse.step.web.client.view.HistoryModuleView;
@@ -21,6 +22,7 @@
 import com.tyndalehouse.step.web.client.view.ScriptureSelectorView;
 import com.tyndalehouse.step.web.client.view.ScriptureView;
 import com.tyndalehouse.step.web.client.view.StepView;
+import com.tyndalehouse.step.web.client.view.TimebandListView;
 import com.tyndalehouse.step.web.client.view.TimelineView;
 
 public class StepClientModule  extends AbstractPresenterModule {
@@ -51,6 +53,9 @@
 		
 		bind(TimelinePresenter.class);
 		bind(TimelinePresenter.Display.class).to(TimelineView.class); //.in(Singleton.class);
+		bind(TimebandListPresenter.Display.class).to(TimebandListView.class); //.in(Singleton.class);
+		
+		//		
 //		bind(ITimeLineRender.class).to(TimelineRenderer.class);
 		
 		bind(HistoryModulePresenter.class);

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/TimelinePresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/TimelinePresenter.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/TimelinePresenter.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -16,13 +16,13 @@
 import com.google.gwt.event.dom.client.HasClickHandlers;
 import com.google.inject.Inject;
 import com.tyndalehouse.step.web.client.event.ScriptureChangeEvent;
+import com.tyndalehouse.step.web.client.event.TimebandListUpdateRequiredEvent;
 import com.tyndalehouse.step.web.client.event.TimelineScrollEvent;
 import com.tyndalehouse.step.web.client.eventhandler.ScriptureChangeEventHandler;
 import com.tyndalehouse.step.web.client.eventhandler.TimelineScrollEventHandler;
 import com.tyndalehouse.step.web.client.toolkit.timeline.Timeband;
 import com.tyndalehouse.step.web.client.toolkit.timeline.TimeEvent;
 import com.tyndalehouse.step.web.client.toolkit.timeline.Timeline;
-import com.tyndalehouse.step.web.client.toolkit.timeline.components.Unit;
 import com.tyndalehouse.step.web.client.toolkit.timeline.exceptions.TimeBandNotFoundException;
 import com.tyndalehouse.step.web.shared.beans.TimeBandVisibleDate;
 import com.tyndalehouse.step.web.shared.beans.TimelineBean;
@@ -33,6 +33,7 @@
 import com.tyndalehouse.step.web.shared.result.GetEventsForDateRangeResult;
 import com.tyndalehouse.step.web.shared.result.GetTimelineOriginForScriptureResult;
 import com.tyndalehouse.step.web.shared.result.GetTimelineUISetupResult;
+import com.tyndalehouse.step.web.shared.timeline.Unit;
 
 public class TimelinePresenter extends WidgetPresenter<TimelinePresenter.Display> {
 	private final DispatchAsync dispatcher;
@@ -44,7 +45,7 @@
 
 		bind();
 	}
-
+	
 	public interface Display extends WidgetDisplay {
 		Timeline getTimeline();
 
@@ -96,6 +97,7 @@
 								Log.error("An error occurred while tyring to get events for the timeline", e);
 							}
 
+							//TODO: push this down in to timeline component?
 							@Override
 							protected void handleSuccess(GetEventsForDateRangeResult resultingEvents) {
 								Log.debug("Request for events came back succesfully!");
@@ -130,6 +132,8 @@
 										Log.error("Timeband " + tbvd.getTimebandId() + " cannot be found.");
 									}
 								}
+								
+								eventBus.fireEvent(new TimebandListUpdateRequiredEvent(tl.getCurrentBandStats()));
 							}
 						});
 			}
@@ -174,7 +178,8 @@
 									//be shown.
 								} else {
 									Timeline tl = display.getTimeline();
-									tl.repaint(value.getOriginDate());
+									tl.repaint(value.getOriginDate(), value.getSuggestedTimeScale(), value.getTimebandId());
+									//don't fire event to update list here, events haven't been requested yet!
 								}
 							}
 					
@@ -222,10 +227,9 @@
 		for (TimelineBean tb : setupData.getTimelines()) {
 			Timeband band = new Timeband(timeline, tb.getTimelineId(), tb.getTimelineDescription());
 
-			// TODO: change the scale dynamically
 			band.setPixelsPerUnit(100);
-			//band.setHeight(400);
-			band.setUnit(Unit.valueOf(tb.getUnit()));
+			Log.debug("Unit of band is: " + tb.getUnit());			
+			band.setOriginalUnit(Unit.valueOf(tb.getUnit()));
 
 			// set the date to the middle of the band: TODO: again something
 			// that needs changing.
@@ -234,8 +238,8 @@
 			band.setCurrentDateX(32000);
 			timeline.addBand(band);
 		}
-
-		timeline.fireTimelineScrollEvent();
+//		timeline.fireTimelineScrollEvent();
+//		timeline.initialise();
 	}
 
 	@Override

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	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -82,7 +82,6 @@
 			// then it's a point in time
 			eventType = TimelineConstants.POINT_IN_TIME_EVENT;
 		} else {
-			//TODO: calculate width here
 			eventType = TimelineConstants.DURATION;
 			durationWidth = Math.max(TimelineConstants.EVENT_MIN_WIDTH,
 					TimeConversionUtil.timeToPixel(maxDate.longValue(), currentTimeband) - leftPixelPosition);

Modified: 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	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEventDescriptor.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -2,7 +2,6 @@
 
 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;

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeScale.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeScale.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeScale.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -5,8 +5,8 @@
 import com.extjs.gxt.ui.client.core.El;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
-import com.tyndalehouse.step.web.client.toolkit.timeline.components.Unit;
 import com.tyndalehouse.step.web.client.toolkit.timeline.helpers.TimeConversionUtil;
+import com.tyndalehouse.step.web.shared.timeline.Unit;
 
 public class TimeScale {
 	private boolean isRendered = false;
@@ -52,7 +52,6 @@
 		long visibleLeft = band.getMinVisibleDate();
 		long visibleRight = band.getMaxVisibleDate();
 				
-		// TODO: change this at some point
 		Unit unit = band.getUnit();
 
 		//We do not want to generate all the time scale segments, 

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeband.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeband.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeband.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -13,11 +13,11 @@
 import com.google.gwt.user.client.ui.Widget;
 import com.tyndalehouse.step.web.client.toolkit.timeline.components.TimebandRequestWindow;
 import com.tyndalehouse.step.web.client.toolkit.timeline.components.TimelineConstants;
-import com.tyndalehouse.step.web.client.toolkit.timeline.components.Unit;
 import com.tyndalehouse.step.web.client.toolkit.timeline.exceptions.CannotDeleteEventException;
 import com.tyndalehouse.step.web.client.toolkit.timeline.exceptions.IncapableOfCalculatingRequestWindowException;
 import com.tyndalehouse.step.web.client.toolkit.timeline.helpers.TimeConversionUtil;
 import com.tyndalehouse.step.web.shared.beans.TimeBandVisibleDate;
+import com.tyndalehouse.step.web.shared.timeline.Unit;
 
 /**
  * The TimeBand object represents a section of the timeline that contains the
@@ -105,11 +105,6 @@
 	 */
 	private TimeScale timescale;
 
-	/**
-	 * this is the autohide option, which should hide the timeband if no events
-	 * are displayed
-	 */
-	private boolean autoHide = true;
 
 	/**
 	 * when this is set to true, then we can use the request window object to
@@ -150,8 +145,14 @@
 	 */
 	private List<TapeTrack> tapeTracks;
 
-	private boolean needsResizing = false;
 
+	private Element timebandLabel;
+
+	private Unit originalUnit = null;
+
+	private boolean isUserInterested;
+
+
 	/**
 	 * To create a new timeband on the timeline
 	 * 
@@ -188,20 +189,12 @@
 		// need to check the event isn't already in our list:
 		if (!events.containsKey(event.getId())) {
 			events.put(event.getId(), event);
-
-			if (isVisible()) {
-				// Log.debug("Request to paint event triggered");
 				addEventToTapeTrack(event);
-			} else if (autoHide) {
-				// well the band is not visible, so if the event is in the
-				// visible section, then paint it
+				
 				if (isEventInVisibleSection(event)) {
 					Log.debug("Adding event to hidden band: " + event.getDescription());
-					El el = new El(timebandContainer);
-					el.setDisplayed(true);
 					addEventToTapeTrack(event);
 				}
-			}
 			// otherwise, autoHide is set to false, so leave hidden
 		}
 	}
@@ -238,10 +231,7 @@
 	private TapeTrack addNewTapeTrack() {
 		TapeTrack t = new TapeTrack();
 		tapeTracks.add(t);
-		t.paint(this);
-		
-		needsResizing = true;
-		
+		t.paint(this);		
 		return t;
 	}
 
@@ -309,9 +299,16 @@
 			}
 			timescale.paint();
 		}
-
+		
 		drawEvents();
 		
+		if(isUserInterested) {
+			//after adding events, call the resizing function. 
+			//It decides whether or not the band needs resizing, so no overhead
+			resizeBand();
+		} else {
+			hideFromUser();
+		}
 	}
 
 	/**
@@ -324,20 +321,15 @@
 		for (TimeEvent te : events.values()) {
 			addEventToTapeTrack(te);
 		}
-		
-		//after adding events, call the resizing function. 
-		//It decides whether or not the band needs resizing, so no overhead
-		resizeBand();
 	}
 
 	/**
 	 * Resizes bands dependant on how many bands are present.
 	 */
 	public void resizeBand() {
-		if(needsResizing) {
+		if(isUserInterested) {
 			// resize the timeband to take account of the number of timetracks
 			new El(timebandContainer).setHeight(tapeTracks.size() * TimelineConstants.TAPE_TRACK_HEIGHT);
-			needsResizing = false;
 		}
 	}
 
@@ -349,9 +341,9 @@
 		El gxtBandDiv = new El(bandDiv);
 
 		// set display options, ie. auto hide
-		if (autoHide && !hasVisibleEvents()) {
-			el.setDisplayed(false);
-		}
+//		if (autoHide && !hasVisibleEvents()) {
+//			el.setDisplayed(false);
+//		}
 
 		parent.getTimelineContainer().appendChild(timebandContainer);
 		timebandContainer.appendChild(bandDiv);
@@ -363,11 +355,13 @@
 	}
 
 	private void addLabelToBand() {
-		Element timebandLabel = DOM.createDiv();
+		timebandLabel = DOM.createDiv();
 		El gxtTimebandLabel = new El(timebandLabel);
 		gxtTimebandLabel.setStyleName("step-timeband-label", true);
+		gxtTimebandLabel.setLeft(getElement().getScrollLeft());
 		timebandLabel.setInnerText(description + "(" + id + ")");
 		timebandContainer.appendChild(timebandLabel);
+
 	}
 
 	/**
@@ -443,6 +437,7 @@
 		// so we want to scroll half
 		double pixelFactor = (double) pixelsPerUnit / (double) defaultPixelsPerUnit;
 		this.timebandContainer.setScrollLeft((int) (mouseDownScrollLeft + ((previousClientX - newClientX) * (unitFactor * pixelFactor))));
+		displayTimebandLabel();
 	}
 
 	/**
@@ -486,8 +481,7 @@
 			return new TimeBandVisibleDate(id, minVisibleDate, maxVisibleDate);
 		} else {
 			// return only the portion that has changed (probably only one pixel
-			// worth)! TODO later: ensure
-			// we send requests when they are actually worth sending
+			// worth)!
 			// -------|--------$------|-----$--------------------
 			// mvd mrd Mvd Mrd
 			long minReceivedDate = requestWindow.getMinDate();
@@ -503,16 +497,15 @@
 				return new TimeBandVisibleDate(id, minVisibleDate, maxVisibleDate);
 			} else if (shiftedLeft) {
 				// window could potentially have jumped, so there may be a gap
-				// between maxVisibleDate and min, so take
-				// check for gap first, and then decide
-				// TODO: check here
+				// between maxVisibleDate and min, so take so check that first:
 				if (maxVisibleDate < minReceivedDate) {
 					// we have issues here, as we're either going to have to
-					// remember about all the already painted stuff
-					// or we're going to have to clear down the band first.
-					// TODO: at the moment we reset, but ideally, remember
-					// what's been painted or clear down band.
+					// remember about all the already painted stuff. this would potentially be troublesome
+					// as with units and zooming, we're going to have to eventually repaint huge amounts of stuff
+					// so reset to 0
 					requestWindow = null;
+
+					//TODO: investigate whether we want to clear the band down!
 					return new TimeBandVisibleDate(id, minVisibleDate, maxVisibleDate);
 				} else {
 					// the max is greater than the minimum so we return
@@ -537,8 +530,7 @@
 					}
 				}
 			} else {
-				// TODO: add the proper debug information to the exception
-				throw new IncapableOfCalculatingRequestWindowException("Unable to calculate request window. It was shifted neither left, nor right");
+				throw new IncapableOfCalculatingRequestWindowException(minVisibleDate, maxVisibleDate, minReceivedDate, maxReceivedDate);
 			}
 		}
 	}
@@ -581,13 +573,19 @@
 	 * Gets the band to scroll to the current date
 	 */
 	public void scrollToCurrentDate() {
-		new El(timebandContainer).setScrollLeft((int) currentDateX);
-		// Log.debug("Scroll left is " + timebandContainer.getScrollLeft());
-		// Log.debug("Scroll left is " + new
-		// El(timebandContainer).getScrollLeft());
+		Log.debug("Client width /2 : " + (timebandContainer.getClientWidth() / 2));
+		new El(timebandContainer).setScrollLeft((int) currentDateX - (timebandContainer.getClientWidth() / 2));
+		displayTimebandLabel();
 	}
 
 	/**
+	 * Displays the timeband label on the timeband, with the description of it
+	 */
+	private void displayTimebandLabel() {
+		new El(timebandLabel).setLeft(getElement().getScrollLeft());
+	}
+
+	/**
 	 * Resets the timeband and redraws it
 	 */
 	public void redrawEmptyBand() {
@@ -596,6 +594,15 @@
 	}
 
 	/**
+	 * Hides by setting the height of the band to 0
+	 */
+	public void hideFromUser() {
+		//set height to 0 by default, and we'll add something later TODO: to see which bands have got events...
+		new El(timebandContainer).setHeight(0);		
+	}
+	
+	
+	/**
 	 * Does not delete the events but redraws everything else.
 	 */
 	public void redrawBand() {
@@ -840,4 +847,47 @@
 	public int getSizeTapeTracks() {
 		return tapeTracks.size();
 	}
+
+	public void resetOriginalUnit() {
+		setUnit(originalUnit);
+	}
+
+	public void setOriginalUnit(Unit unit) {
+		if(originalUnit == null) {
+			originalUnit = unit;
+		} else {
+			Log.warn("Original unit is already set. Please use resetOriginalUnit instead");
+		}
+		resetOriginalUnit();
+	}
+
+	/**
+	 * @return the isUserInterested
+	 */
+	public boolean isUserInterested() {
+		return isUserInterested;
+	}
+
+	/**
+	 * true if the band is targetted from user input
+	 * @param isKeyBand a key band that the user wants to see
+	 */
+	public void registerUserInterest(boolean isUserInterested) {
+		this.isUserInterested = isUserInterested;
+	}
+
+	/**
+	 * Could this be optimized by organising the events in time order, 
+	 * and on scroll recording which events have popped off?
+	 * @return
+	 */
+	public int getNumberOfVisibleEvents() {
+		int count = 0;
+		for(TimeEvent te : events.values()) {
+			if(isEventInVisibleSection(te)) {
+				count++;
+			}
+		}
+		return count;
+	}
 }

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	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -17,16 +17,28 @@
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.Widget;
+import com.tyndalehouse.step.web.client.event.TimebandListUpdateRequiredEvent;
 import com.tyndalehouse.step.web.client.event.TimelineScrollEvent;
+import com.tyndalehouse.step.web.client.event.UserInterestInBandEvent;
+import com.tyndalehouse.step.web.client.eventhandler.UserInterestInBandEventHandler;
 import com.tyndalehouse.step.web.client.toolkit.timeline.components.TimelineConstants;
-import com.tyndalehouse.step.web.client.toolkit.timeline.components.Unit;
 import com.tyndalehouse.step.web.client.toolkit.timeline.events.TimelineMouseHandler;
 import com.tyndalehouse.step.web.client.toolkit.timeline.exceptions.IncapableOfCalculatingRequestWindowException;
 import com.tyndalehouse.step.web.client.toolkit.timeline.exceptions.TimeBandNotFoundException;
 import com.tyndalehouse.step.web.client.toolkit.timeline.exceptions.UnknownFiredElement;
+import com.tyndalehouse.step.web.client.toolkit.timeline.helpers.CurrentBandStats;
 import com.tyndalehouse.step.web.shared.beans.TimeBandVisibleDate;
+import com.tyndalehouse.step.web.shared.timeline.Unit;
 
 /**
+ * FEATURE: Add uncertain times from database as dotted events/bands
+ * FEATURE: Add red line down the middle as current Sync line that tells user where bands are sunk
+ * FEATURE: Proper descriptions appearing in hover popups
+ * FEATURE: Add support for timetagging, history links, so that user can copy and paste url
+ * BUG: Fix obvious units that are wrong
+ * BUG: Timeline doesn't render properly when stuff is cached
+ * 
+ * 
  * div .step-timeline (step-grab step-letgo) | | - div .step-timeline-container
  * | | - div .step-timeband-container | | - div .step-timeband | | - div .
  * step-scale-band
@@ -59,18 +71,35 @@
 		setElement(timelineDiv);
 
 		paint();
-		addMouseHandlers();
+		addEventHandlers(eventBus);
 		disableSelection(getElement());		
 	}
 
 	// TODO: investigate pushing the handlers in to the handler!!!
-	private void addMouseHandlers() {
+	private void addEventHandlers(EventBus eventBus) {
 		TimelineMouseHandler tmh = new TimelineMouseHandler(this);
 		addDomHandler(tmh, MouseMoveEvent.getType());
 		addDomHandler(tmh, MouseUpEvent.getType());
 		addDomHandler(tmh, MouseDownEvent.getType());
 		addDomHandler(tmh, MouseOutEvent.getType());
 		addDomHandler(tmh, MouseOverEvent.getType());
+
+		eventBus.addHandler(UserInterestInBandEvent.TYPE, new UserInterestInBandEventHandler() {
+
+			@Override
+			public void onUserInterestedInBand(UserInterestInBandEvent userInterestInBandEvent) {
+				try {
+					Timeband band = getBand(userInterestInBandEvent.getBandId());
+					band.registerUserInterest(userInterestInBandEvent.isOfInterest());
+					band.paint();
+				} catch (TimeBandNotFoundException e) {
+					Log.warn("The user request a band that no longer exists.");
+				}
+			}
+		});
+		
+		//TODO: add window handler
+		
 	}
 
 	private native static void disableSelection(Element e) /*-{
@@ -128,7 +157,6 @@
 	
 	public void handle(MouseMoveEvent e) {
 		if(timebands.size() != 0) {
-			// TODO: customize as a property?
 			Timeband firedBand;
 			try {
 				firedBand = getFiredBand(e);
@@ -144,11 +172,9 @@
 				// mouse is down so move the scroll bars on each timeband
 				// for each timeband, scroll a certain amount... This amount though
 				// is relative to the scales
-				// assume timeband 0 is the default
 				// at the same time we want to add some new scroll visible event to
 				// allow service layer to update
 				// the events shown if necessary on each timeband
-	
 				for (Timeband tb : timebands) {
 					tb.setScrollLeft(clientX, e.getClientX(), unit, pixelsPerUnit);
 					//Log.debug("About to scroll: " + (clientX - e.getClientX()));
@@ -185,12 +211,8 @@
 							//we are only repainting the timescale
 				
 				TimeBandVisibleDate tvd = tb.getOustandingTimebandPeriod();
-				//Log.debug("firing scroll " + tb.getDescription() + " " + tvd.getMinDate() + "," + tvd.getMaxDate());
-				if(!tvd.isNoRequest()) {
-					tse.addTimebandVisibleDate(tvd);
-				} else {
-//					Log.debug("Ignoring timeband request as already have the data");
-				}		
+				Log.debug("firing scroll " + tb.getDescription() + " " + tvd.getMinDate() + "," + tvd.getMaxDate());
+				tse.addTimebandVisibleDate(tvd);
 			} catch (IncapableOfCalculatingRequestWindowException e) {
 				Log.error("Incapable of calculating request window", e);
 			}
@@ -200,7 +222,10 @@
 		if(tse.getTimebandVisibleDates().size() != 0) {
 			eventBus.fireEvent(tse);
 		} else {
-			//Log.debug("Event not fired, no need for it");
+			//this is fired after the scroll has got the events, 
+			//but in this case we're not event firing
+			//the event, so should update the stats, since the visible view has changed
+			eventBus.fireEvent(new TimebandListUpdateRequiredEvent(getCurrentBandStats()));
 		}
 	}
 
@@ -339,17 +364,60 @@
 			tb.zoomOut();
 		}		
 	}
-
-	public void repaint(Long originDate) {
+	
+	public void repaint(final Long originDate, final Unit unit, final int timebandId) {
 		//remove all the timebands from the timeline widget
+		//TODO: HERE all we want to do is set the corect timeband with that unit, not all of them, right?
+		//what if we have several timebands in the origin, is that possible?
+		//events on different timebands with the same scripture references
+		
+		
+		//TODO: set other timbands back to their original scales
+		
 		for(Timeband band : timebands) {
-			band.setCurrentDate(originDate); //one of the events in Jesus' life
-			//TODO: parameterize this depending on the length of the band
-			band.setCurrentDateX(32000);
+			setUserInterestOnBand(band, timebandId, unit);
+			band.setCurrentDate(originDate); 
+			band.setCurrentDateX(TimelineConstants.TIMELINE_WIDTH + timelineDiv.getClientWidth() / 2);
 			band.scrollToCurrentDate();
 			band.redrawEmptyBand();
 		}
 
 		fireTimelineScrollEvent();	
 	}
+
+	/** 
+	 * if the band corresponds to the correct timeband id, then set unit,
+	 * otherwise revert back to the original state...
+	 * @param band band
+	 * @param timebandId timebandId
+	 * @param unit unit
+	 */
+	private void setUserInterestOnBand(Timeband band, int timebandId, Unit unit) {
+		if(band.getId() == timebandId) {
+			band.setUnit(unit);
+			band.registerUserInterest(true);
+		} else {
+			band.resetOriginalUnit();
+			band.registerUserInterest(false);
+		}
+	}
+
+	public List<Timeband> getBands() {
+		return timebands;
+	}
+
+	public List<CurrentBandStats> getCurrentBandStats() {
+		List<CurrentBandStats> stats = new ArrayList<CurrentBandStats>();
+		for(Timeband band : timebands) {
+			
+			CurrentBandStats bandStats = new CurrentBandStats(
+					band.getId(), band.getDescription(),
+					band.getEvents().size(),
+					band.getNumberOfVisibleEvents(), band.isUserInterested());
+			stats.add(bandStats);
+		}
+
+		return stats;
+	}
+
 }

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	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/TimelineConstants.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -22,5 +22,11 @@
 	 * space between the popup and the mouse
 	 */
 	public static final int SPACE_BELOW_POPUP = 20;
+	
+	/**
+	 * total width of timeline width, hardcoded at the moment
+	 */
+	//TODO: parameterize this depending on the length of the band
+	public static final int TIMELINE_WIDTH = 32000;
 
 }

Deleted: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/Unit.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/Unit.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/Unit.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -1,42 +0,0 @@
-package com.tyndalehouse.step.web.client.toolkit.timeline.components;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-
-public enum Unit {
-	SECOND(1000L),
-	MINUTE(60L * 1000L),
-	HOUR(3600L * 1000L),
-	DAY(24L * 3600L * 1000L, "dd MMM yyyy G"),
-	MONTH((365L * 24 * 3600 * 1000L)/12, "MMM yyyy G"),
-	YEAR(365L * 24 * 3600 * 1000L, "yyyy G"),
-	DECADE(10L * 365L * 24 * 3600 * 1000L, "yyyy G"),
-	CENTURY(10L * 10L * 365L * 24 * 3600 * 1000L, "yyyy G"),
-	MILLENIUM(10L * 10L * 10L * 365L * 24 * 3600 * 1000L, "yyyy G");
-
-	private final long milliseconds;
-	private final DateTimeFormat format;
-	
-	/**
-	 * @return the format
-	 */
-	public DateTimeFormat getFormat() {
-		return format;
-	}
-
-	Unit(long milliseconds) {
-		this(milliseconds, "dd MMM YYYY G");
-	}
-	
-	Unit(long milliseconds, String format) {
-		this.format = DateTimeFormat.getFormat(format);
-		this.milliseconds = milliseconds;
-	}
-	
-	/**
-	 * @return the valueInMilliseconds
-	 */
-	public long getMilliseconds() {
-		return milliseconds;
-	}
-	
-}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/exceptions/IncapableOfCalculatingRequestWindowException.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/exceptions/IncapableOfCalculatingRequestWindowException.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/exceptions/IncapableOfCalculatingRequestWindowException.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -16,10 +16,15 @@
 	private static final long serialVersionUID = 1866493907904681758L;
 
 	/**
-	 * Default message constructor
-	 * @param message message to explain why this is not possible
+	 * The client is unable to calculate which bit to request from the server
+	 * @param minVisibleDate the minimum visible date from the client
+	 * @param maxVisibleDate the maximum visible date from the client
+	 * @param minReceivedDate the minimum date the client has ever seen
+	 * @param maxReceivedDate the maximum date the client has ever seen
 	 */
-	public IncapableOfCalculatingRequestWindowException(final String message) {
-		super(message);
+	public IncapableOfCalculatingRequestWindowException(long minVisibleDate, long maxVisibleDate, long minReceivedDate, long maxReceivedDate) {
+		super("Unable to calculate request window for: " 
+				+ minReceivedDate + " / " + maxReceivedDate + 
+				". Visible section is: " + minVisibleDate + " / " + maxVisibleDate);
 	}
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/helpers/TimeConversionUtil.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/helpers/TimeConversionUtil.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/helpers/TimeConversionUtil.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -4,12 +4,9 @@
 
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.tyndalehouse.step.web.client.toolkit.timeline.Timeband;
-import com.tyndalehouse.step.web.client.toolkit.timeline.components.Unit;
+import com.tyndalehouse.step.web.shared.timeline.Unit;
 
 public class TimeConversionUtil {
-	//TODO: make these parameterizable?
-	private final static DateTimeFormat year = DateTimeFormat.getFormat("yyyy G");
-	
 	/**
 	 * This takes a pixel position and returns the equivalent time
 	 * @param pixelPosition the pixel position that we are trying to convert
@@ -53,19 +50,19 @@
 		return (int) pixelValueOnBand;
 	}
 
-	public static String formatPixelToTime(final long pixelPosition, Timeband timeband) {
-		return formatTime(pixelToTime(pixelPosition, timeband));
+	public static String formatPixelToTime(final long pixelPosition, final Timeband timeband) {
+		return formatTime(pixelToTime(pixelPosition, timeband), timeband);
 	}
 	
 	/**
-	 * formats the given time for the moment as yyyy G
+	 * formats the given time using the unit described in the timeband
 	 * @param eventDate date to be formatted 
 	 * @return the string representation of the date
 	 */
-	public static String formatTime(final long eventDate) {
-		//TODO: change for multiple formats when need be
-		//use the year one for now
+	public static String formatTime(final long eventDate, final Timeband timeband) {
 		Date date = new Date(eventDate);
-		return year.format(date);
+		String formatForBand = timeband.getUnit().getFormat();
+		DateTimeFormat format = DateTimeFormat.getFormat(formatForBand);
+		return format.format(date);
 	}
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -10,6 +10,7 @@
 import com.tyndalehouse.step.web.client.presenter.ScripturePresenter;
 import com.tyndalehouse.step.web.client.toolkit.HasSource;
 import com.tyndalehouse.step.web.client.toolkit.SourceListBox;
+import com.tyndalehouse.step.web.client.view.widgets.ScriptureWord;
 
 public class ScriptureView extends Composite implements ScripturePresenter.Display {
 
@@ -30,6 +31,13 @@
 		//TODO : Localise this here.
 		scriptureHTML = new HTML("Please lookup a reference");
 		vp.add(scriptureHTML);
+
+		//TODO why the view is not getting set properly???
+		for(int ii = 0; ii < 5; ii++) {
+			ScriptureWord sw = new ScriptureWord();
+			vp.add(sw.asWidget());
+		}
+		
 	}	
 
 	@Override

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -12,6 +12,7 @@
 import com.tyndalehouse.step.web.client.presenter.ScriptureSelectorPresenter;
 import com.tyndalehouse.step.web.client.presenter.StepModulePresenter;
 import com.tyndalehouse.step.web.client.presenter.StepPresenter;
+import com.tyndalehouse.step.web.client.presenter.TimebandListPresenter;
 import com.tyndalehouse.step.web.client.presenter.TimelinePresenter;
 
 public class StepView extends Composite implements StepPresenter.Display {
@@ -28,7 +29,7 @@
 			ScriptureSelectorPresenter.Display scriptureSelector,
 			ScripturePresenter scripture, ScripturePresenter scripture2,
 			ModuleSelectorPresenter moduleSelector, StepModulePresenter<? extends StepModulePresenter.Display> module,
-			TimelinePresenter timelinePresenter) {
+			TimelinePresenter timelinePresenter, TimebandListPresenter timebandListPresenter) {
 
 		
 		FlowPanel flow = new FlowPanel();
@@ -36,24 +37,6 @@
 		dp = new DockPanel();
 		flow.add(dp);
 		initWidget(flow);
-
-		/**
-		//get the main element and add the three different div layouts.
-//		Element main = this.asWidget().getElement(); 
-//		Element top = DOM.createDiv();
-//		top.setId("top");
-//		
-//		Element middle = DOM.createDiv();
-//		middle.setId("middle");
-//
-//		Element bottom= DOM.createDiv();
-//		bottom.setId("bottom");
-//		main.appendChild(top);
-//		main.appendChild(middle);
-//		main.appendChild(bottom);
-//		
-//		top.appendChild(scriptureSelector.asWidget().getElement());
-		*/
 		
 		HorizontalPanel northPanel = new HorizontalPanel();
 		
@@ -74,6 +57,9 @@
 		
 		dp.add(module.getDisplay().asWidget(), DockPanel.CENTER);
 		flow.add(timelinePresenter.getDisplay().asWidget());
+		
+		//for the moment, adding it to the flow
+		dp.add(timebandListPresenter.getDisplay().asWidget(), DockPanel.SOUTH);
 	}
 
 	

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	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -39,7 +39,11 @@
 	}
 
 
-	private String readProperty(String name) {
+	private String readProperty(final String name) {
 		return p.getProperty(name);
 	}
+
+	public static int getInt(final String paramName) throws ConfigNotLoadedException {
+		return Integer.parseInt(get(paramName));
+	}
 }

Deleted: 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	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/DbProvider.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -1,44 +0,0 @@
-package com.tyndalehouse.step.web.server.db;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import com.tyndalehouse.step.web.server.common.ConfigNotLoadedException;
-import com.tyndalehouse.step.web.server.common.ConfigProvider;
-
-//TODO: all this is in java 6, so we should somehow be able to add it to classpath
-//without shipping jar file
-//TODO: ensure that we put shared libraries somewhere else...
-//TODO: do something about styles, checkstyle, etc.
-//TODO: make a connection pool so that we can reuse
-//db connections and gain performance
-public class DbProvider {
-	private DbProvider() {
-	}
-
-	public static Connection getConnection() throws SQLException {
-		try {
-			String driver = ConfigProvider.get("db.driver");
-			String connectionUrl = ConfigProvider.get("connection.string");
-			Class.forName(driver);
-			return DriverManager.getConnection(connectionUrl);
-		} catch (ClassNotFoundException e) {
-			//TODO: lookup GUICE and see about providers to log with our loggers
-			e.printStackTrace();
-			throw new SQLException(e);
-		} catch (ConfigNotLoadedException e1) {
-			e1.printStackTrace();
-			throw new SQLException(e1);
-		} catch(Throwable t) {
-			t.printStackTrace();
-			throw new SQLException(t);
-		}
-	}
-
-	public static void finaliseConnection(Connection connection) throws SQLException {
-		if(connection != null && !connection.isClosed()) {
-			connection.close();
-		}
-	}
-}

Deleted: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/RefDataDbCommand.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/RefDataDbCommand.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/db/RefDataDbCommand.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -1,46 +0,0 @@
-package com.tyndalehouse.step.web.server.db;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.apache.commons.logging.Log;
-
-import com.google.inject.Inject;
-
-public class RefDataDbCommand {
-	
-	private final Log logger;
-
-	@Inject
-	public RefDataDbCommand(Log logger) {
-		this.logger = logger;
-		
-	}
-	
-	public ResultSet select(final String refId) {
-		Connection connection = null;
-		try {
-			connection = DbProvider.getConnection();
-			Statement statement = connection.createStatement();
-			//	do select
-			
-			//TODO: get a sql framework to generate those queries
-			//TODO: prevent SQL Injection attack
-	        ResultSet rs = 
-	        	statement.executeQuery("SELECT ref_key, ref_text" +
-	        			"FROM refdata where bible_ref = '" + refId + "'");
-			return rs;
-		} catch (SQLException e) {
-			logger.error("A SQL exception has occurred", e);
-		} finally {
-			try {
-				DbProvider.finaliseConnection(connection);
-			} catch (SQLException e) {
-				logger.error("A SQL exception has occurred", e);
-			}
-		}
-		return null;
-	}
-}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -7,9 +7,22 @@
 
 @Singleton
 public class LogProvider implements Provider<Log>{
-
+	//enforce singleton to allow static methods to get to the same log
+	private static Log logger = new Log4JLogger("step.jetty");
+	
+	/**
+	 * The instantiated log to be returned
+	 */
 	public Log get() {
-		return new Log4JLogger("StepWebLogger");
+		return logger;
 	}
 
+	/**
+	 * The static equivalent of the above, so that static contexts
+	 * can log as well
+	 * @return
+	 */
+	public static Log getLogger() {
+		return logger;
+	}
 }
\ No newline at end of file

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -5,7 +5,8 @@
 import org.apache.commons.logging.Log;
 
 import com.google.inject.Singleton;
-import com.tyndalehouse.step.web.server.db.RefDataDbCommand;
+import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
+import com.tyndalehouse.step.web.server.db.framework.StepQueryRunnerImpl;
 import com.tyndalehouse.step.web.server.handler.GetAvailableBibleVersionsHandler;
 import com.tyndalehouse.step.web.server.handler.GetBibleBooksHandler;
 import com.tyndalehouse.step.web.server.handler.GetCurrentBibleTextHandler;
@@ -29,7 +30,6 @@
 		bindHandler(GetTimelineOriginForScriptureHandler.class);
 
 		bind(Log.class).toProvider(LogProvider.class).in(Singleton.class);
-		bind(RefDataDbCommand.class).in(Singleton.class);
-	
+		bind(StepQueryRunner.class).to(StepQueryRunnerImpl.class).in(Singleton.class);
 	}
 }
\ No newline at end of file

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -1,9 +1,5 @@
 package com.tyndalehouse.step.web.server.handler;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -15,138 +11,77 @@
 import org.apache.commons.logging.Log;
 
 import com.google.inject.Inject;
-import com.tyndalehouse.step.web.server.db.DbProvider;
+import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
+import com.tyndalehouse.step.web.server.db.framework.UnableToRunQueryException;
+import com.tyndalehouse.step.web.server.db.timeline.TimeBandVisibleDateProcessor;
 import com.tyndalehouse.step.web.shared.beans.TimeBandVisibleDate;
 import com.tyndalehouse.step.web.shared.beans.TimelineEventBean;
 import com.tyndalehouse.step.web.shared.command.GetEventsForDateRangeCommand;
 import com.tyndalehouse.step.web.shared.result.GetEventsForDateRangeResult;
 
-public class GetEventsForDateRangeHandler implements
-		ActionHandler<GetEventsForDateRangeCommand, GetEventsForDateRangeResult> {
+public class GetEventsForDateRangeHandler implements ActionHandler<GetEventsForDateRangeCommand, GetEventsForDateRangeResult> {
 	private final Log logger;
-	
+	private final StepQueryRunner queryRunner;
 
 	@Inject
-	public GetEventsForDateRangeHandler(Log logger) {
+	public GetEventsForDateRangeHandler(Log logger, StepQueryRunner queryRunner) {
 		this.logger = logger;
+		this.queryRunner = queryRunner;
 	}
 
 	@Override
-	//TODO: build a proper sql statement to query all time bands in one go
-	//TODO: this needs to change to take into account the three different types of date precision but for now,
-	//let's get something working
-	public GetEventsForDateRangeResult execute(
-			GetEventsForDateRangeCommand event, ExecutionContext arg1)
-			throws ActionException {
-
-		Connection conn = null;
-		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy G");
-		
-		//TODO: do some cleaning up for DB code...
+	// TODO: this needs to change to take into account the three different types
+	// of date precision but for now,
+	// let's get something working
+	public GetEventsForDateRangeResult execute(GetEventsForDateRangeCommand event, ExecutionContext arg1) throws ActionException {
+		GetEventsForDateRangeResult result = new GetEventsForDateRangeResult();
+		List<TimeBandVisibleDate> timebands = event.getVisbleDates();
 		try {
-			conn = DbProvider.getConnection();
-			List<TimeBandVisibleDate> timebands = event.getVisbleDates();
-			
-			//so say, we're looking at 1AD - 7AD, what we really want to show, is at least all
-			//those events that are between 1AD and 7AD, so the date of the event if it's a point in time
-			//is going to be between 1 and 7
-			//if it's a duration, then we want the starting point to be before our end point
-			//and the end point of the event to be 
-			StringBuilder sql = new StringBuilder();
-			sql.append("select event_id, from_date, to_date, from_precision, to_precision, name, " +
-					"timeband_id, importance_id, " +
-					"certainty, event_type_id from step.event " +
-					"where (from_date between ? and ?" +
-					"   or to_date between ? and ?" +
-					"   or (from_date < ? and to_date > ?)) ");
-			if(!event.isShowDuration()) { 
-				sql.append(" and to_date is null ");
+			for (TimeBandVisibleDate tvd : timebands) {
+				List<TimelineEventBean> events;
+				events = queryRunner.run(new TimeBandVisibleDateProcessor(tvd.getMinDate(), tvd.getMaxDate(), tvd.getTimebandId()));
+				result.getEvents().addAll(events);
 			}
-			
-			sql.append(" and timeband_id = ? ");
-			sql.append(" order by from_date ");
-			PreparedStatement ps = conn.prepareStatement(sql.toString());
-			
-			GetEventsForDateRangeResult result = new GetEventsForDateRangeResult();
-			
-			for(TimeBandVisibleDate tbvd : timebands) {
-				logger.debug(String.format("Executing request for: %s - %s", 
-						sdf.format(new Date(tbvd.getMinDate())), 
-								sdf.format(new Date(tbvd.getMaxDate()))));
-				logger.debug(tbvd.getTimebandId());
-				ps.setLong(1, tbvd.getMinDate());
-				ps.setLong(2, tbvd.getMaxDate());
-				ps.setLong(3, tbvd.getMinDate());
-				ps.setLong(4, tbvd.getMaxDate());
-				ps.setLong(5, tbvd.getMinDate());
-				ps.setLong(6, tbvd.getMaxDate());
-				ps.setInt(7, tbvd.getTimebandId());
-				
-				ResultSet rs = ps.executeQuery();
-				addEventToResult(result, rs);
-			}
-
-			logger.debug(String.format("Returning %d events to the client", result.getEvents().size()));
-			return result;			
-		} catch (SQLException e) {
-			logger.error(e);
+		} catch (UnableToRunQueryException e) {
+			logger.error("An error occured while trying to retrieve new events from the datbase", e);
 			throw new ActionException(e);
-		} finally {
-			try {
-				DbProvider.finaliseConnection(conn);
-			} catch (SQLException e) {
-				logger.error("An error occured while trying to tear down the connection", e);
-			}
 		}
+
+		logEventsRetrieved(result.getEvents());
+		return result;
 	}
 
-	private void addEventToResult(GetEventsForDateRangeResult result, ResultSet rs) throws SQLException {
-		//TODO: parse the event in some object, as opposed to just fields like that!
-		//in particular the precision type
+	/**
+	 * Logs which events have been retrieved in trace mode
+	 * @param events events to be traced
+	 */
+	private void logEventsRetrieved(List<TimelineEventBean> events) {
 		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy G");
 		
-		while(rs.next()) {
-			TimelineEventBean teb = new TimelineEventBean(
-					rs.getInt("event_id"),
-					rs.getLong("from_date"),
-					rs.getObject("to_date") == null ? null : rs.getLong("to_date"),
-					rs.getString("from_precision"),
-					rs.getString("to_precision"),
-					rs.getString("name"),
-					rs.getInt("timeband_id"),
-					rs.getInt("importance_id"),
-					rs.getString("certainty"),
-					rs.getInt("event_type_id")
-					);
-			
-			if(teb.getFromDate() != null && teb.getToDate() != null) {				
-				logger.debug(String.format("returning: %s %s-%s (tb_id: %d)", teb.getName(), 
-						sdf.format(new Date((long) teb.getFromDate())), 
-						sdf.format(new Date((long) teb.getToDate())),
-						teb.getTimelineId()));
-			
-			} else if(teb.getFromDate() != null) {
-				logger.debug(String.format("returning: %s %s (tb_id: %d)", teb.getName(), 
-						sdf.format(new Date(teb.getFromDate())), teb.getTimelineId()));
-			} else {
-				logger.debug(String.format("returning: %s (tb_id: %d)", teb.getName(), teb.getTimelineId()));
+		if (logger.isTraceEnabled()) {
+			for (TimelineEventBean teb : events) {
+				if (teb.getFromDate() != null && teb.getToDate() != null) {
+					logger.trace(String.format("returning: %s %s-%s (tb_id: %d)", teb.getName(), sdf.format(new Date((long) teb.getFromDate())), sdf
+							.format(new Date((long) teb.getToDate())), teb.getTimelineId()));
+
+				} else if (teb.getFromDate() != null) {
+					logger.trace(String.format("returning: %s %s (tb_id: %d)", teb.getName(), sdf.format(new Date(teb.getFromDate())), teb
+							.getTimelineId()));
+				} else {
+					logger.trace(String.format("returning: %s (tb_id: %d)", teb.getName(), teb.getTimelineId()));
+				}
 			}
-			
-			result.add(teb);
 		}
+		logger.trace(String.format("Returning %d events to the client", events.size()));
 	}
 
-	//This method is used to determine which type of command this handler serves I believe...
 	@Override
 	public Class<GetEventsForDateRangeCommand> getActionType() {
-			return GetEventsForDateRangeCommand.class;
+		return GetEventsForDateRangeCommand.class;
 	}
 
 	@Override
-	public void rollback(GetEventsForDateRangeCommand arg0,
-			GetEventsForDateRangeResult arg1, ExecutionContext arg2)
-			throws ActionException {
-		
-		
+	public void rollback(GetEventsForDateRangeCommand arg0, GetEventsForDateRangeResult arg1, ExecutionContext arg2) throws ActionException {
+
 	}
 }
\ No newline at end of file

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -1,9 +1,6 @@
 package com.tyndalehouse.step.web.server.handler;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.util.List;
 
 import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
@@ -19,115 +16,90 @@
 import org.crosswire.jsword.passage.VerseRange;
 
 import com.google.inject.Inject;
-import com.tyndalehouse.step.web.server.db.DbProvider;
+import com.tyndalehouse.step.web.server.db.framework.ResultSetProcessor;
+import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
+import com.tyndalehouse.step.web.server.db.framework.UnableToRunQueryException;
+import com.tyndalehouse.step.web.server.db.timeline.TimelineOriginDbBean;
+import com.tyndalehouse.step.web.server.db.timeline.TimelineOriginProcessor;
 import com.tyndalehouse.step.web.shared.command.GetTimelineOriginForScriptureCommand;
 import com.tyndalehouse.step.web.shared.result.GetTimelineOriginForScriptureResult;
 
-public class GetTimelineOriginForScriptureHandler implements
-		ActionHandler<GetTimelineOriginForScriptureCommand, GetTimelineOriginForScriptureResult> {
-	private final Log logger;
+public class GetTimelineOriginForScriptureHandler implements ActionHandler<GetTimelineOriginForScriptureCommand, GetTimelineOriginForScriptureResult> {
+	private final Log log;
+	private final StepQueryRunner queryRunner;
 
 	@Inject
-	public GetTimelineOriginForScriptureHandler(Log logger) {
-		this.logger = logger;
+	public GetTimelineOriginForScriptureHandler(Log logger, StepQueryRunner queryRunner) {
+		this.log = logger;
+		this.queryRunner = queryRunner;
 	}
 
 	@Override
-	//TODO: build a proper sql statement to query all time bands in one go
-	//TODO: this needs to change to take into account the three different types of date precision but for now,
-	//let's get something working
-	public GetTimelineOriginForScriptureResult execute(
-			GetTimelineOriginForScriptureCommand event, ExecutionContext arg1)
-			throws ActionException {
-
-		Connection conn = null;
-//		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy G");
-
-		//TODO: do some cleaning up for DB code...
+	// TODO: build a proper sql statement to query all time bands in one go
+	// TODO: this needs to change to take into account the three different types
+	// of date precision but for now,
+	// let's get something working
+	public GetTimelineOriginForScriptureResult execute(GetTimelineOriginForScriptureCommand event, ExecutionContext arg1) throws ActionException {
 		try {
-			conn = DbProvider.getConnection();
-			
-			//TODO: this is bad - look at JSword to work out how to properly get the verserange out
+			// TODO: this is bad - look at JSword to work out how to properly
+			// get the verserange out
 			RocketPassage passage = (RocketPassage) resolveScriptureToVerseNumbers(event.getScriptureReference());
-			
-			//TODO: i guess this could come back with no range - check this here.
-			
-			//TODO: we're doing only the first range - ignoring others... What would we do with several ranges?
-			VerseRange range = passage.getRangeAt(0, RestrictionType.NONE);
-			int startVerseNo = range.getStart().getOrdinal();
-			int endVerseNo =  range.getEnd().getOrdinal();
 
-			//probably at the same time, we want to figure out if any events are an importance
-			//band, and if so return the recommended unit
-			
-			StringBuilder sql = new StringBuilder();
-			sql.append("select avg(ev.from_date) as ORIGIN from step.scripture_reference sr, step.event ev ");
-			sql.append("where target_type = 1 and ");
-			sql.append("((? between start_verse_id and end_verse_id) "); //-- the query start is between the event range
-			sql.append("or (? between start_verse_id and end_verse_id) "); //-- the query end is between the event range
-			sql.append("or (? < start_verse_id and ? > start_verse_id) "); //-- the query start is before the event start, but the end is after the event start
-			sql.append("or (? > end_verse_id and ? < end_verse_id)) "); //-- the end of the range is greater than event end, but the start is before the end
-			sql.append("and sr.TARGET_ID = ev.EVENT_ID");
-
-			//TODO: move all the prepared statements somewhere else so that
-			PreparedStatement ps = conn.prepareStatement(sql.toString());
-			int argPosition = 1;
-			ps.setInt(argPosition++, startVerseNo);
-			ps.setInt(argPosition++, endVerseNo);
-			ps.setInt(argPosition++, startVerseNo);
-			ps.setInt(argPosition++, endVerseNo);
-			ps.setInt(argPosition++, endVerseNo);
-			ps.setInt(argPosition++, startVerseNo);
-			
-			ResultSet rs = ps.executeQuery();
-						
-			//TODO: suggested scale needs to be looked up from timescale band table -
-			//and need to add that to the initial loading up
-			
-			if(rs.next()) {
-				return new GetTimelineOriginForScriptureResult(rs.getLong("ORIGIN"), 0L);
+			if (passage.isEmpty()) {
+				log.warn("No passage was requested");
 			} else {
-				//no passages found, so return an empty result
-				return new GetTimelineOriginForScriptureResult(true);
+
+				// TODO: we're doing only the first range - ignoring others...
+				// What would we do with several ranges? Interesting question - perhaps we could use as min/max
+				VerseRange range = passage.getRangeAt(0, RestrictionType.NONE);
+				int startVerseNo = range.getStart().getOrdinal();
+				int endVerseNo = range.getEnd().getOrdinal();
+
+				ResultSetProcessor<TimelineOriginDbBean> originProcessor = new TimelineOriginProcessor(startVerseNo, endVerseNo);
+
+				// TODO: should be able to ensure this is implied, rather having
+				// to cast directly
+				List<TimelineOriginDbBean> originList = queryRunner.run(originProcessor);
+
+				if (originList.size() != 0) {
+					TimelineOriginDbBean origin = originList.get(0);
+					return new GetTimelineOriginForScriptureResult(origin.getOrigin(), origin.getUnit(), origin.getTimebandId());
+				} else {
+					//TODO: work out the nearest passage and redo this...
+				}
 			}
-						
-		} catch (SQLException e) {
-			logger.error(e);
-			throw new ActionException(e);
 		} catch (NoSuchKeyException e) {
-			logger.warn("Could not resolve verse number", e);
+			log.warn("Could not resolve verse number", e);
+			//TODO: return a proper exception and show error message on the UI
 			return new GetTimelineOriginForScriptureResult(true);
-		} finally {
-			try {
-				DbProvider.finaliseConnection(conn);
-			} catch (SQLException e) {
-				logger.error("An error occured while trying to tear down the connection", e);
-			}
+		} catch (UnableToRunQueryException e) {
+			log.error("An error occured while loading the config for the query", e);
+			throw new ActionException(e);
 		}
+		return new GetTimelineOriginForScriptureResult(true);
 	}
 
-
 	/**
 	 * resolves a string to a range of verses
-	 * @throws NoSuchKeyException 
+	 * 
+	 * @throws NoSuchKeyException
 	 */
-	private Key resolveScriptureToVerseNumbers(String scriptureReference) throws NoSuchKeyException {
+	private Key resolveScriptureToVerseNumbers(final String scriptureReference) throws NoSuchKeyException {
 		KeyFactory keyFactory = PassageKeyFactory.instance();
 		return keyFactory.getKey(scriptureReference);
-		
-		
+
 	}
 
-	//This method is used to determine which type of command this handler serves I believe...
+	// This method is used to determine which type of command this handler
+	// serves I believe...
 	@Override
 	public Class<GetTimelineOriginForScriptureCommand> getActionType() {
-			return GetTimelineOriginForScriptureCommand.class;
+		return GetTimelineOriginForScriptureCommand.class;
 	}
 
 	@Override
-	public void rollback(GetTimelineOriginForScriptureCommand arg0,
-			GetTimelineOriginForScriptureResult arg1, ExecutionContext arg2)
+	public void rollback(GetTimelineOriginForScriptureCommand arg0, GetTimelineOriginForScriptureResult arg1, ExecutionContext arg2)
 			throws ActionException {
-		
-		
-	}}
\ No newline at end of file
+
+	}
+}
\ No newline at end of file

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -1,10 +1,5 @@
 package com.tyndalehouse.step.web.server.handler;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
 import java.util.List;
 
 import net.customware.gwt.dispatch.server.ActionHandler;
@@ -14,7 +9,9 @@
 import org.apache.commons.logging.Log;
 
 import com.google.inject.Inject;
-import com.tyndalehouse.step.web.server.db.DbProvider;
+import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
+import com.tyndalehouse.step.web.server.db.framework.UnableToRunQueryException;
+import com.tyndalehouse.step.web.server.db.timeline.TimelineSetupDataProcessor;
 import com.tyndalehouse.step.web.shared.beans.TimelineBean;
 import com.tyndalehouse.step.web.shared.command.GetTimelineUISetupCommand;
 import com.tyndalehouse.step.web.shared.result.GetTimelineUISetupResult;
@@ -22,60 +19,30 @@
 public class GetTimelineUISetupHandler implements
 		ActionHandler<GetTimelineUISetupCommand, GetTimelineUISetupResult> {
 	private final Log logger;
+	private final StepQueryRunner queryRunner;
 
 	@Inject
-	public GetTimelineUISetupHandler(Log logger) {
+	public GetTimelineUISetupHandler(Log logger, StepQueryRunner queryRunner) {
 		this.logger = logger;
+		this.queryRunner = queryRunner;
 	}
 
 	@Override
 	public GetTimelineUISetupResult execute(
 			GetTimelineUISetupCommand cmd, ExecutionContext arg1)
 			throws ActionException {
-		//we need to do how many timelines there are, the min and max of each of them
-		Connection conn = null; 
 		try {
-			conn = DbProvider.getConnection();
-			
-			//TODO: remove all prepared statements and ensure they are made into
-			//singletons
-			
-			String sqlStatement = 	"select t.timeband_id, t.timeband_description, t.timeband_code, t.timeband_unit " +
-									"from step.timeband t";
-			
-			PreparedStatement ps = conn.prepareStatement(sqlStatement);
-			ResultSet rs = ps.executeQuery();
-			
-			//TODO: do we need to sort those somehow? probably according 
-			//to how they should show on screen
-			List<TimelineBean> timelines = new ArrayList<TimelineBean>();
-			
-			//review this: perhaps we don't need to send all of this to the UI
-			while(rs.next()) {
-				TimelineBean tb = new TimelineBean(
-						rs.getInt("timeband_id"), 
-						rs.getString("timeband_description"), 
-						rs.getString("timeband_code"));
-				tb.setUnit(rs.getString("timeband_unit"));
-//				tb.setMinDate(rs.getLong("min_from_date"));
-//				tb.setMaxDate(rs.getLong("max_to_date"));
-//				tb.setEventCount(rs.getInt("event_count"));
-				timelines.add(tb);
-			}
-			
-			logger.debug(String.format("Returning %d timebands to the client.", timelines.size()));
+			List<TimelineBean> timelines = queryRunner.run(new TimelineSetupDataProcessor());
 			GetTimelineUISetupResult r = new GetTimelineUISetupResult();
 			r.setTimelines(timelines);
-			return r;
-		} catch(SQLException sqle) {
-			logger.error("A sql exception has occurred", sqle);
-			throw new ActionException("An error occured while trying to setup the timeline UI from data in the database.", sqle);
-		} finally {
-			try {
-				DbProvider.finaliseConnection(conn);
-			} catch (SQLException e) {
-				throw new ActionException("Cannot tear down connection.", e);
+
+			if(logger.isDebugEnabled()) {
+				logger.debug(String.format("Returning %d timebands to the client.", timelines.size()));
 			}
+			return r;
+		} catch (UnableToRunQueryException e) {
+			logger.error("An error occured while loading the config for the query", e);
+			throw new ActionException(e);
 		}
 	}
 

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/beans/TimelineBean.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/beans/TimelineBean.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/beans/TimelineBean.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -29,7 +29,6 @@
 
 	private String timelineDescription;
 	private String unit;
-//	private String timelineCode;
 
 	
 
@@ -37,12 +36,6 @@
 		
 	}
 	
-	public TimelineBean(int timelineId, String timelineDescription, String timelineCode) {
-		this.timelineId = timelineId;
-		this.timelineDescription = timelineDescription;
-//		this.timelineCode = timelineCode;
-	}
-	
 	/**
 	 * @return the timelineId
 	 */

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/command/GetEventsForDateRangeCommand.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/command/GetEventsForDateRangeCommand.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/command/GetEventsForDateRangeCommand.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -29,7 +29,6 @@
 	 */
 	public GetEventsForDateRangeCommand(List<TimeBandVisibleDate> visbleDates) {
 		this.visbleDates = visbleDates;
-		
 	}
 	
 	/**

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetTimelineOriginForScriptureResult.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetTimelineOriginForScriptureResult.java	2010-02-09 21:11:18 UTC (rev 78)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetTimelineOriginForScriptureResult.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -2,16 +2,17 @@
 
 import net.customware.gwt.dispatch.shared.Result;
 
+import com.tyndalehouse.step.web.shared.timeline.Unit;
+
 public class GetTimelineOriginForScriptureResult implements Result {
-
-
 	/**
 	 * generated serial version id 
 	 */
 	private static final long serialVersionUID = 4256230588330550554L;
 	private Long originDate;
-	private Long suggestedTimeScale;
+	private Unit suggestedTimeScale;
 	private boolean isEmpty;
+	private int timebandId;
 	
 	/**
 	 * @return the isEmpty
@@ -27,9 +28,10 @@
 		this.isEmpty = isEmpty;
 	}
 
-	public GetTimelineOriginForScriptureResult(Long originDate, Long suggestedTimeScale) {
-		this.setOriginDate(originDate);
-		this.setSuggestedTimeScale(suggestedTimeScale);
+	public GetTimelineOriginForScriptureResult(Long originDate, Unit unit, int timebandId) {
+		this.originDate = originDate;
+		this.suggestedTimeScale = unit;
+		this.timebandId = timebandId;
 		isEmpty = false;
 	}
 	
@@ -57,17 +59,33 @@
 	}
 
 	/**
-	 * @param suggestedTimeScale the suggestedTimeScale to set
+	 * @param unit the suggestedTimeScale to set
 	 */
-	public void setSuggestedTimeScale(Long suggestedTimeScale) {
-		this.suggestedTimeScale = suggestedTimeScale;
+	public void setSuggestedTimeScale(Unit unit) {
+		this.suggestedTimeScale = unit;
 	}
 
 	/**
 	 * @return the suggestedTimeScale
 	 */
-	public Long getSuggestedTimeScale() {
+	public Unit getSuggestedTimeScale() {
 		return suggestedTimeScale;
 	}
 
+	/**
+	 * gets the timeband id
+	 * @return timebandId
+	 */
+	public int getTimebandId() {
+		return timebandId;
+	}
+
+	/**
+	 * @param timebandId the timebandId to set
+	 */
+	public void setTimebandId(int timebandId) {
+		this.timebandId = timebandId;
+	}
+
+
 }

Copied: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/timeline/Unit.java (from rev 70, trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/components/Unit.java)
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/timeline/Unit.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/timeline/Unit.java	2010-02-09 21:43:00 UTC (rev 79)
@@ -0,0 +1,41 @@
+package com.tyndalehouse.step.web.shared.timeline;
+
+
+public enum Unit {
+	SECOND(1000L),
+	MINUTE(60L * 1000L),
+	HOUR(3600L * 1000L),
+	DAY(24L * 3600L * 1000L, "dd MMM yyyy G"),
+	WEEK(7L * 24L * 3600L * 1000L, "dd MMM yyyy G"),
+	MONTH((365L * 24 * 3600 * 1000L)/12, "MMM yyyy G"),
+	YEAR(365L * 24 * 3600 * 1000L, "yyyy G"),
+	DECADE(10L * 365L * 24 * 3600 * 1000L, "yyyy G"),
+	CENTURY(10L * 10L * 365L * 24 * 3600 * 1000L, "yyyy G"),
+	MILLENIUM(10L * 10L * 10L * 365L * 24 * 3600 * 1000L, "yyyy G");
+
+	private final long milliseconds;
+	private final String format;
+	
+	Unit(long milliseconds) {
+		this(milliseconds, "dd MMM YYYY G");
+	}
+	
+	Unit(long milliseconds, String format) {
+		this.format = format;
+		this.milliseconds = milliseconds;
+	}
+	
+	/**
+	 * @return the valueInMilliseconds
+	 */
+	public long getMilliseconds() {
+		return milliseconds;
+	}
+
+	/**
+	 * @return the format
+	 */
+	public String getFormat() {
+		return format;
+	}
+}




More information about the Tynstep-svn mailing list