From 6d48729efb4bd1ac34bba003a8a4313a70a02cce Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 16 Feb 2013 16:55:44 +1300 Subject: Handle clicks on markers (fix #8) --- src/org/traccar/web/client/model/StateReader.java | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/org/traccar/web/client/model/StateReader.java (limited to 'src/org/traccar/web/client/model/StateReader.java') diff --git a/src/org/traccar/web/client/model/StateReader.java b/src/org/traccar/web/client/model/StateReader.java new file mode 100644 index 00000000..a3549179 --- /dev/null +++ b/src/org/traccar/web/client/model/StateReader.java @@ -0,0 +1,43 @@ +package org.traccar.web.client.model; + +import java.util.LinkedList; +import java.util.List; + +import org.traccar.web.shared.model.Position; +import org.traccar.web.shared.model.XmlParser; + +import com.google.gwt.i18n.client.DateTimeFormat; + +public class StateReader { + + private static String toString(Object object) { + if (object != null) { + return object.toString(); + } + return null; + } + + public static List getState(Position position) { + List state = new LinkedList(); + + state.add(new StateItem("valid", toString(position.getValid()))); + state.add(new StateItem("time", DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(position.getTime()))); + state.add(new StateItem("latitude", toString(position.getLatitude()))); + state.add(new StateItem("longitude", toString(position.getLongitude()))); + state.add(new StateItem("altitude", toString(position.getAltitude()))); + state.add(new StateItem("speed", toString(position.getSpeed()))); + state.add(new StateItem("course", toString(position.getCourse()))); + state.add(new StateItem("power", toString(position.getPower()))); + state.add(new StateItem("address", position.getAddress())); + + String other = position.getOther(); + if (other != null) { + for (String key : XmlParser.enumerateElements(other)) { + state.add(new StateItem(key, XmlParser.getElement(other, key))); + } + } + + return state; + } + +} -- cgit v1.2.3