[Tynstep-svn] r43 - in trunk/step-web-app: src/main/java/com/tyndalehouse/step/web/client/presenter src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline src/main/java/com/tyndalehouse/step/web/server/guice src/main/java/com/tyndalehouse/step/web/server/handler war/WEB-INF/lib war/css
ChrisBurrell at crosswire.org
ChrisBurrell at crosswire.org
Mon Dec 14 08:45:14 MST 2009
Author: ChrisBurrell
Date: 2009-12-14 08:45:14 -0700 (Mon, 14 Dec 2009)
New Revision: 43
Removed:
trunk/step-web-app/war/WEB-INF/lib/gwt-servlet.jar.svntmp
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/toolkit/timeline/TapeTrack.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/TimeConversionUtil.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/Timeline.java
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineConstants.java
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/DispatchServletModule.java
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java
trunk/step-web-app/war/css/step.css
Log:
new tape tracks on timebands, + no specific height needs to be defined. it grows automatically.
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 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/TimelinePresenter.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -103,6 +103,7 @@
List<TimelineEventBean> events = resultingEvents.getEvents();
Timeline tl = getDisplay().getTimeline();
+
for (TimelineEventBean ev : events) {
int timebandId = ev.getTimelineId();
@@ -222,7 +223,7 @@
// TODO: change the scale dynamically
band.setPixelsPerUnit(100);
- band.setHeight(400);
+ //band.setHeight(400);
band.setUnit(Unit.DECADE); //TODO: what if i want 8 years, or 25 years, etc.
// set the date to the middle of the band: TODO: again something
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TapeTrack.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TapeTrack.java 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TapeTrack.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -1,5 +1,6 @@
package com.tyndalehouse.step.web.client.toolkit.timeline;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
@@ -26,12 +27,66 @@
* if it is to be painted on this track
*/
private int latestPaintOpportunity;
+
+ private boolean appended;
public TapeTrack() {
+ appended = false;
track = DOM.createDiv();
+ track.setClassName("step-tape-track");
+ earliestPaintOpportunity = Integer.MAX_VALUE;
+ latestPaintOpportunity = Integer.MIN_VALUE;
+
+ setElement(track);
}
+ /**
+ * The events need to be added in order, otherwise the time taping will not be efficient
+ * Returns whether an event of width width can be painted at position pixel
+ * @param pixel pixel position at which to be painted
+ * @param width width of the event
+ * @return
+ */
public boolean canPaintAt(int pixel, int width) {
- return pixel > latestPaintOpportunity || pixel+width +1 < earliestPaintOpportunity;
+ return pixel > latestPaintOpportunity || (pixel + width + 1) < earliestPaintOpportunity;
}
+
+ /** Checks and then adds an event to the timetrack
+ * Logically it is still added to the band, but it is painted on the timetrack
+ * @param event even to be painted
+ * @return whether the event has been painted
+ */
+ public boolean addEvent(TimeEvent event) {
+ if(canPaintAt(event.getLeftPixelPosition(), event.getTotalWidth())) {
+ //Log.debug(event.getDescription() + " can be painted on timetrack");
+ event.paint(this);
+
+ //now update the available bands
+ //Log.debug("Old latest and earliest times were: " + latestPaintOpportunity + "," + earliestPaintOpportunity);
+ latestPaintOpportunity = Math.max(latestPaintOpportunity, event.getLeftPixelPosition() + event.getTotalWidth());
+ earliestPaintOpportunity = Math.min(earliestPaintOpportunity, event.getLeftPixelPosition());
+ //Log.debug("New latest and earliest times were: " + latestPaintOpportunity + "," + earliestPaintOpportunity);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * paints the timetrack on to the timeband
+ * @param band
+ */
+ public void paint(final TimeBand band) {
+ if(!appended) {
+ band.getBandDiv().appendChild(track);
+ appended = true;
+ }
+ }
+
+ /**
+ * @return the track
+ */
+ public Element getTrack() {
+ return track;
+ }
+
}
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 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBand.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -4,6 +4,8 @@
import java.util.List;
import java.util.TreeMap;
+import mx4j.util.TimeTask;
+
import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.ui.client.core.El;
import com.google.gwt.event.dom.client.MouseDownEvent;
@@ -40,7 +42,7 @@
private Element bandDiv;
/** height of the time band, defaults at 50px */
- private int height = 100;
+ //private int height = 100;
private int pixelsPerUnit;
@@ -226,6 +228,11 @@
return events;
}
+ /**
+ * Adds an event to the timeband, and therefore on to a random timetack.
+ * The first available spot to minimize the space required.
+ * @param event
+ */
public void addEvent(TimeEvent event) {
// need to check the event isn't already in our list:
if (!events.containsKey(event.getId())) {
@@ -233,7 +240,7 @@
if (isVisible()) {
//Log.debug("Request to paint event triggered");
- event.paint();
+ addEventToTapeTrack(event);
} else if (autoHide) {
// well the band is not visible, so if the event is in the
// visible section, then paint it
@@ -241,13 +248,44 @@
Log.debug("Adding event to hidden band: " + event.getDescription());
El el = new El(timebandContainer);
el.setDisplayed(true);
- event.paint();
+ addEventToTapeTrack(event);
}
}
// otherwise, autoHide is set to false, so leave hidden
}
}
+ public void addEventToTapeTrack(TimeEvent event) {
+ int startIndex = showScale ? 1 : 0; //leaving room for the scale band
+
+ while(startIndex < tapeTracks.size()) {
+ //Log.debug("Trying to add " + event.getDescription() + " to track " + startIndex);
+ //try and add event to track
+ if(tapeTracks.get(startIndex).addEvent(event)) {
+ return;
+ }
+ startIndex++;
+ }
+
+ //Log.debug("Going to create a new tape track");
+
+ //check that the event was added, otherwise log error or add timetrack
+ if(startIndex >= tapeTracks.size()) {
+ //did not manage to add it to tracks. therefore, let's add another one:
+ TapeTrack t = addNewTapeTrack();
+ t.addEvent(event);
+ }
+ resizeBand();
+ }
+
+
+ private TapeTrack addNewTapeTrack() {
+ TapeTrack t = new TapeTrack();
+ tapeTracks.add(t);
+ t.paint(this);
+ return t;
+ }
+
/**
* Removes an event from the band
*
@@ -299,20 +337,41 @@
// show scale band?
//TODO: only paint if we're rendering this band
- if (isRendered && showScale) {
+ if (showScale) {
+ //check if default time track has been added and add if not
+ if(tapeTracks.size() == 0) {
+ addNewTapeTrack();
+ }
+
if(timescale == null) {
timescale = new TimeScale(this);
}
timescale.paint();
}
-
+
+
// get the events to paint themselves (they will decide whether or not to
//paint if they are already showing...
for (TimeEvent te : events.values()) {
- te.paint();
+ addEventToTapeTrack(te);
}
}
+
+ private void resizeBand() {
+ //resize the timeband to take account of the number of timetracks
+ new El(timebandContainer).setHeight(tapeTracks.size() * TimelineConstants.TAPE_TRACK_HEIGHT);
+ }
+
+// //Remove this bit later, and have it dynamically add tracks
+// private void initTapeTracks() {
+// int countTapeTracks = height / TimelineConstants.TAPE_TRACK_HEIGHT;
+// tapeTracks = new ArrayList<TapeTrack>(countTapeTracks);
+// for(int ii = 0; ii < countTapeTracks; ii++) {
+// addNewTapeTrack();
+// }
+// }
+
protected void addBandToUI(int top) {
El el = new El(timebandContainer);
El gxtBandDiv = new El(bandDiv);
@@ -323,12 +382,13 @@
}
parent.getTimelineContainer().appendChild(timebandContainer);
+
timebandContainer.appendChild(bandDiv);
addLabelToBand();
el.setStyleName("step-timeband-container");
- el.setHeight(getHeight());
+// el.setHeight(getHeight());
// el.setTop(top);
gxtBandDiv.setHeight("100%");
@@ -339,7 +399,7 @@
Element timebandLabel = DOM.createDiv();
El gxtTimebandLabel = new El(timebandLabel);
gxtTimebandLabel.setStyleName("step-timeband-label", true);
- timebandLabel.setInnerText(description);
+ timebandLabel.setInnerText(description + "(" + id +")");
timebandContainer.appendChild(timebandLabel);
}
@@ -423,20 +483,20 @@
return currentDate;
}
- /**
- * @return the height
- */
- public int getHeight() {
- return height;
- }
+// /**
+// * @return the height
+// */
+// public int getHeight() {
+// return height;
+// }
- /**
- * @param height
- * the height to set
- */
- public void setHeight(int height) {
- this.height = height;
- }
+// /**
+// * @param height
+// * the height to set
+// */
+// public void setHeight(int height) {
+// this.height = height;
+// }
public void captureScrollLeft(MouseDownEvent e) {
this.mouseDownScrollLeft = timebandContainer.getScrollLeft();
@@ -656,4 +716,21 @@
Log.debug("Scroll left is " + new El(timebandContainer).getScrollLeft());
}
+
+ public void redrawEmptyBand() {
+ events.clear();
+ tapeTracks.clear();
+
+ //use El to remove all children
+ new El(bandDiv).removeChildren();
+
+ //bandDiv = DOM.createDiv();
+ requestWindow = null;
+
+ timescale.paint();
+ }
+
+ public int getSizeTapeTracks() {
+ return tapeTracks.size();
+ }
}
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeConversionUtil.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeConversionUtil.java 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeConversionUtil.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -37,7 +37,7 @@
* @param timeband
* @return
*/
- public static long timeToPixel(final long eventDate, TimeBand currentTimeband) {
+ public static int timeToPixel(final long eventDate, TimeBand currentTimeband) {
// here's what we start from
long millisecondPerUnit = currentTimeband.getUnit().getMilliseconds();
long pixelsPerUnit = currentTimeband.getPixelsPerUnit();
@@ -50,7 +50,7 @@
// calculate difference with current position on timeband
long differenceWithEvent = eventDate - currentOriginDate;
long pixelValueOnBand = currentOriginXPixel + (long) (differenceWithEvent / onePixelInMs);
- return pixelValueOnBand;
+ return (int) pixelValueOnBand;
}
public static String formatPixelToTime(final long pixelPosition, TimeBand timeband) {
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-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -1,6 +1,8 @@
package com.tyndalehouse.step.web.client.toolkit.timeline;
+import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.ui.client.core.El;
+import com.extjs.gxt.ui.client.util.TextMetrics;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@@ -37,15 +39,19 @@
* database
*/
private String eventType;
-
private Element eventDiv;
private Element icon;
private Element label;
+ private int leftPixelPosition;
+ private int totalWidth;
+
+ private int durationWidth;
+
/**
* events can move from one timeband to another
*/
- private TimeBand currentTimeBand;
+ private TimeBand currentTimeband;
private boolean isRendered = false;
@@ -54,21 +60,82 @@
this.description = description;
this.minDate = minDate;
this.maxDate = maxDate;
+ this.currentTimeband = tb;
+ this.leftPixelPosition = (int) TimeConversionUtil.timeToPixel(minDate.longValue(), currentTimeband);
+ eventDiv = DOM.createDiv();
+ icon = DOM.createDiv();
+ label = DOM.createDiv();
if (maxDate == null) {
// 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);
}
+
+ setupDivProperties();
+ }
- this.currentTimeBand = tb;
- eventDiv = DOM.createDiv();
- icon = DOM.createDiv();
- label = DOM.createDiv();
+ private void setupDivProperties() {
+ El gxtEvent = new El(eventDiv);
+ El gxtLabel = new El(label);
+
+ //setup div hierarchy
+ eventDiv.appendChild(icon);
+ eventDiv.appendChild(label);
+
+ //setup CSS properties
+ eventDiv.setClassName(TimelineConstants.EVENT);
+
+ //setup positioning
+ gxtEvent.setLeft(leftPixelPosition);
+
+ //setup values
+ label.setInnerText(description);
+
+ //specific properties
+ if (maxDate != null) {
+ setupDurationProperties();
+ } else {
+ setupPointInTimeProperties();
+ }
+
+ //all css is setup, take measurement of label element:
+
+ TextMetrics ruler = TextMetrics.get();
+ ruler.bind(new El(label));
+ int labelWidth = ruler.getWidth(description);
+ gxtLabel.setWidth(labelWidth);
+
+
+ //set up width: if event, then labelWidth, otherwise max(duration,label)
+ totalWidth = maxDate == null ? labelWidth : Math.max(durationWidth, labelWidth);
+ gxtEvent.setWidth(totalWidth);
}
/**
+ * Sets up point in time properties
+ */
+ private void setupPointInTimeProperties() {
+ El gxtLabel = new El(label);
+ gxtLabel.setStyleName(TimelineConstants.POINT_IN_TIME_LABEL, true);
+ }
+
+ /**
+ * Sets up duration properties
+ */
+ private void setupDurationProperties() {
+ El gxtIcon = new El(icon);
+ El gxtLabel = new El(label);
+ gxtIcon.setWidth((int) durationWidth);
+ gxtIcon.setStyleName(eventType, true);
+ gxtLabel.setStyleName(TimelineConstants.DURATION_LABEL, true);
+ }
+
+ /**
* This method removes an event from the current timeband
* and moves in onto a different timeband. This will be useful
* when time bands become invisible, or we are not interested
@@ -78,9 +145,9 @@
* @throws CannotDeleteEventException An event can't be moved from one timeband to another if deletions are disallowed
*/
public synchronized void moveTimeBand(TimeBand newTimeBand) throws CannotDeleteEventException {
- currentTimeBand.removeEvent(this.getId());
- currentTimeBand = newTimeBand;
- currentTimeBand.addEvent(this);
+ currentTimeband.removeEvent(this.getId());
+ currentTimeband = newTimeBand;
+ currentTimeband.addEvent(this);
}
/**
@@ -176,52 +243,11 @@
/**
* the main responsible culprit for painting events on the timeband
*/
- public synchronized void paint() {
+ public synchronized void paint(TapeTrack track) {
+ //all we do is attach it to the parent if need be.
if (!isRendered) {
- currentTimeBand.getBandDiv().appendChild(eventDiv);
-
- // the eventDiv will contain both divs, the actual event icon/div
- // display
- // and the label...
- eventDiv.appendChild(icon);
- eventDiv.appendChild(label);
-
- // currentTimeBand.getBandDiv().appendChild(label);
- eventDiv.setClassName(TimelineConstants.EVENT);
- // icon.setClassName(TimelineConstants.EVENT);
- // label.setClassName(TimelineConstants.EVENT);
-
- // use GXT to wrap our element:
- El gxtEvent = new El(eventDiv);
- El gxtIcon = new El(icon);
- El gxtLabel = new El(label);
-
- // setting left position of event holder (icon + text)
- long leftPixelPosition = TimeConversionUtil.timeToPixel(minDate.longValue(), currentTimeBand);
- gxtEvent.setLeft((int) leftPixelPosition);
-
- if (maxDate != null) {
- long width = TimeConversionUtil.timeToPixel(maxDate.longValue(), currentTimeBand) - leftPixelPosition;
- gxtIcon.setWidth((int) width);
- gxtIcon.setStyleName(eventType, true);
- gxtLabel.setLeft((int) leftPixelPosition);
- gxtLabel.setStyleName(TimelineConstants.DURATION_LABEL, true);
- } else {
- // point in time.
- gxtLabel.setStyleName(TimelineConstants.POINT_IN_TIME_LABEL, true);
- // gxtIcon.setWidth(TimelineConstants.POINT_IN_TIME_WIDTH_SPACE);
- gxtLabel.setLeft((int) leftPixelPosition + TimelineConstants.POINT_IN_TIME_WIDTH_SPACE);
- }
-
- // TODO: derive type from database first
- //
-
- // set the name of the event
- label.setInnerText(description);
- // eventDiv.setPropertyString("style", "left: " + leftOffset);
+ track.getTrack().appendChild(eventDiv);
isRendered = true;
- } else {
- //Log.debug("The event was showing already, so no repaint has occured: (" + getId() + ", " + getDescription() + ")");
}
}
@@ -262,23 +288,31 @@
* @param zoomRatio
*/
public void repaint() {
- currentTimeBand.getBandDiv().removeChild(eventDiv);
- isRendered = false;
- paint();
-
-// El element = new El(eventDiv);
-// element.setLeft((int) (element.getLeft() * zoomRatio));
-//
-// //reposition label
-// El gxtLabel = new El(label);
-// gxtLabel.setLeft((int) (gxtLabel.getLeft() * zoomRatio));
-//
-// if(maxDate != null) {
-// element.setWidth((int) (element.getWidth() * zoomRatio));
-// El gxtIcon = new El(icon);
-// gxtIcon.setWidth((int) (gxtIcon.getWidth() * zoomRatio));
-// } else {
-// }
+ eventDiv.getParentNode().removeChild(eventDiv);
+
+ //may want to paint on a different tape track
+ //this is a bit of a strange way of doing this!
+ currentTimeband.addEventToTapeTrack(this);
}
+ /**
+ * @return the leftPixelPosition
+ */
+ public int getLeftPixelPosition() {
+ return leftPixelPosition;
+ }
+
+ /**
+ * @param leftPixelPosition the leftPixelPosition to set
+ */
+ public void setLeftPixelPosition(int leftPixelPosition) {
+ this.leftPixelPosition = leftPixelPosition;
+ }
+
+ /**
+ * @return the totalWidth
+ */
+ public int getTotalWidth() {
+ return totalWidth;
+ }
}
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-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -177,7 +177,9 @@
int relativeTop = 0;
for (TimeBand tb : timebands) {
tb.paint(relativeTop);
- relativeTop += tb.getHeight();
+
+ //TODO: see if we really need to specify this, but for now get from number of timetracks
+ relativeTop += tb.getSizeTapeTracks() * TimelineConstants.TAPE_TRACK_HEIGHT;
}
// the total relative at this stage is the total height of the
@@ -290,6 +292,7 @@
//TODO: parameterize this depending on the length of the band
band.setCurrentDateX(32000);
band.scrollToCurrentDate();
+ band.redrawEmptyBand();
}
fireTimelineScrollEvent();
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineConstants.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineConstants.java 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineConstants.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -9,13 +9,13 @@
public static final String POINT_IN_TIME_EVENT = "step-timeline-pointInTime";
public static final String DURATION = "step-timeline-duration";
public static final String DURATION_LABEL = "step-time-duration-label";
- public static final String POINT_IN_TIME_LABEL = "step-time-point-in-time-label";
+ public static final String POINT_IN_TIME_LABEL = "step-time-point-in-time-label";
-
-
/**
* space between the icon and the text
*/
public static final int POINT_IN_TIME_WIDTH_SPACE = 15;
+ public static final int TAPE_TRACK_HEIGHT = 20 + 2;
+ public static final int EVENT_MIN_WIDTH = 2;
}
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/DispatchServletModule.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/DispatchServletModule.java 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/guice/DispatchServletModule.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -7,6 +7,7 @@
@Override
public void configureServlets() {
// NOTE: the servlet context will probably need changing
+
serve("/step/dispatch").with(CustomDispatchServiceServlet.class);
}
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 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java 2009-12-14 15:45:14 UTC (rev 43)
@@ -5,6 +5,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
import net.customware.gwt.dispatch.server.ActionHandler;
@@ -23,6 +24,7 @@
public class GetEventsForDateRangeHandler implements
ActionHandler<GetEventsForDateRangeCommand, GetEventsForDateRangeResult> {
private final Log logger;
+
@Inject
public GetEventsForDateRangeHandler(Log logger) {
@@ -39,7 +41,7 @@
Connection conn = null;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy G");
-
+
//TODO: do some cleaning up for DB code...
try {
conn = DbProvider.getConnection();
@@ -56,17 +58,21 @@
"certainty, event_type_id from step.event " +
"where (from_date between ? and ?" +
" or to_date between ? and ?" +
- " or (from_date < ? and to_date > ?))");
+ " or (from_date < ? and to_date > ?)) ");
if(!event.isShowDuration()) {
- sql.append(" and to_date is null");
+ sql.append(" and to_date is null ");
}
- sql.append(" and timeband_id = ?");
+ 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());
@@ -97,6 +103,8 @@
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
+ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy G");
+
while(rs.next()) {
TimelineEventBean teb = new TimelineEventBean(
rs.getInt("event_id"),
@@ -110,6 +118,20 @@
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()));
+ }
+
result.add(teb);
}
}
@@ -126,4 +148,5 @@
throws ActionException {
- }}
\ No newline at end of file
+ }
+}
\ No newline at end of file
Deleted: trunk/step-web-app/war/WEB-INF/lib/gwt-servlet.jar.svntmp
===================================================================
(Binary files differ)
Modified: trunk/step-web-app/war/css/step.css
===================================================================
--- trunk/step-web-app/war/css/step.css 2009-12-14 15:37:52 UTC (rev 42)
+++ trunk/step-web-app/war/css/step.css 2009-12-14 15:45:14 UTC (rev 43)
@@ -67,7 +67,7 @@
/* background-color: gold; */
position: relative;
/* border-style: dashed; */
- display: inline;
+ display: absolute;
padding: 0px;
margin: 0px;
}
@@ -78,8 +78,8 @@
margin-right: 0px;
margin-left: 0px;
margin-bottom: 1px;
-
list-style-type: none;
+ position: absolute;
}
.step-timeline-pointInTime {
@@ -109,7 +109,8 @@
}
.step-time-duration-label {
- display: inline;
+ display: inline;
+ margin-top: 5px;
}
.step-scale-band div {
@@ -134,3 +135,13 @@
.step-letgo {
cursor: hand; /* ? */
}
+
+
+.step-tape-track {
+ display: block;
+ height: 20px; /* TODO: to shove in properties file if they are possible? */
+ width: 100%;
+ position: relative;
+ border: 1px dotted red;
+ z-index: 110;
+}
More information about the Tynstep-svn
mailing list