aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/client/Application.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-02-16 16:55:44 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-02-16 16:55:44 +1300
commit6d48729efb4bd1ac34bba003a8a4313a70a02cce (patch)
treeb834c03b8aeb3302bedb949a63f6b6d0ed4f2600 /src/org/traccar/web/client/Application.java
parent11b7037755c08654fba3b3781f83445244582d59 (diff)
downloadtrackermap-web-6d48729efb4bd1ac34bba003a8a4313a70a02cce.tar.gz
trackermap-web-6d48729efb4bd1ac34bba003a8a4313a70a02cce.tar.bz2
trackermap-web-6d48729efb4bd1ac34bba003a8a4313a70a02cce.zip
Handle clicks on markers (fix #8)
Diffstat (limited to 'src/org/traccar/web/client/Application.java')
-rw-r--r--src/org/traccar/web/client/Application.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/org/traccar/web/client/Application.java b/src/org/traccar/web/client/Application.java
index c8029959..07e2586b 100644
--- a/src/org/traccar/web/client/Application.java
+++ b/src/org/traccar/web/client/Application.java
@@ -20,6 +20,7 @@ import java.util.logging.Logger;
import org.traccar.web.client.controller.ArchiveController;
import org.traccar.web.client.controller.DeviceController;
import org.traccar.web.client.controller.MapController;
+import org.traccar.web.client.controller.StateController;
import org.traccar.web.client.model.BaseStoreHandlers;
import org.traccar.web.client.model.DataService;
import org.traccar.web.client.model.DataServiceAsync;
@@ -48,6 +49,7 @@ public class Application {
}
private final DeviceController deviceController;
+ private final StateController stateController;
private final MapController mapController;
private final ArchiveController archiveController;
@@ -56,31 +58,65 @@ public class Application {
public Application() {
deviceController = new DeviceController(deviceHandler);
deviceController.getDeviceStore().addStoreHandlers(deviceStoreHandler);
- mapController = new MapController();
+ stateController = new StateController();
+ mapController = new MapController(mapHandler);
archiveController = new ArchiveController(archiveHanlder, deviceController.getDeviceStore());
archiveController.getPositionStore().addStoreHandlers(archiveStoreHandler);
view = new ApplicationView(
- deviceController.getView(), mapController.getView(), archiveController.getView());
+ deviceController.getView(), stateController.getView(), mapController.getView(), archiveController.getView());
}
public void run() {
RootPanel.get().add(view);
deviceController.run();
+ stateController.run();
mapController.run();
archiveController.run();
}
private DeviceController.DeviceHandler deviceHandler = new DeviceController.DeviceHandler() {
+ private Device selected;
+
@Override
public void onSelected(Device device) {
+ if (selected != null) {
+ mapController.unregisterPositionUpdate(selected);
+ }
+ if (device != null) {
+ mapController.registerPositionUpdate(device, positionUpdateHandler);
+ }
+ selected = device;
mapController.selectDevice(device);
}
};
+ private MapController.PositionUpdateHandler positionUpdateHandler = new MapController.PositionUpdateHandler() {
+
+ @Override
+ public void onUpdate(Position position) {
+ stateController.showState(position);
+ }
+
+ };
+
+ private MapController.MapHandler mapHandler = new MapController.MapHandler() {
+
+ @Override
+ public void onDeviceSelected(Device device) {
+ deviceController.selectDevice(device);
+ }
+
+ @Override
+ public void onArchivePositionSelected(Position position) {
+ archiveController.selectPosition(position);
+ }
+
+ };
+
private ArchiveController.ArchiveHandler archiveHanlder = new ArchiveController.ArchiveHandler() {
@Override