diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-03 11:02:30 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-03 11:02:30 +1300 |
commit | 9cc6eebd2e4c95fa3ac633df7a4d1255a2f00c39 (patch) | |
tree | cd1bb509448bd690b37892566a6be8369be80a40 /src/main/java | |
download | trackermap-web-9cc6eebd2e4c95fa3ac633df7a4d1255a2f00c39.tar.gz trackermap-web-9cc6eebd2e4c95fa3ac633df7a4d1255a2f00c39.tar.bz2 trackermap-web-9cc6eebd2e4c95fa3ac633df7a4d1255a2f00c39.zip |
Created project
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/web/client/ArchivePanel.java | 64 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/DevicePanel.java | 54 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/MapPanel.java | 108 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/Traccar.java | 49 |
4 files changed, 275 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/web/client/ArchivePanel.java b/src/main/java/org/traccar/web/client/ArchivePanel.java new file mode 100644 index 00000000..d8f7ea77 --- /dev/null +++ b/src/main/java/org/traccar/web/client/ArchivePanel.java @@ -0,0 +1,64 @@ +package org.traccar.web.client; + +import com.smartgwt.client.widgets.toolbar.ToolStrip; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.layout.SectionStack; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.DateTimeItem; +import com.smartgwt.client.widgets.toolbar.ToolStripButton; + +/** + * Archive widget + */ +public class ArchivePanel extends SectionStack { + + private ToolStrip toolbar; + private ListGrid list; + + public ArchivePanel() { + SectionStackSection section = new SectionStackSection("Archive"); + section.setCanCollapse(false); + section.setExpanded(true); + + toolbar = new ToolStrip(); + toolbar.setWidth100(); + + SelectItem deviceSelect = new SelectItem("device", "Device"); + //fontItem.setShowTitle(false); + //fontItem.setWidth(120); + toolbar.addFormItem(deviceSelect); + toolbar.addSeparator(); + + DateTimeItem from = new DateTimeItem("from", "From"); + toolbar.addFormItem(from); + toolbar.addSeparator(); + DateTimeItem to = new DateTimeItem("to", "To"); + toolbar.addFormItem(to); + toolbar.addSeparator(); + + ToolStripButton button = new ToolStripButton(); + button.setTitle("Load"); + toolbar.addButton(button); + + list = new ListGrid(); + list.setFields( + new ListGridField("deviceId", "Device Id"), + new ListGridField("time", "Time"), + new ListGridField("valid", "Valid"), + new ListGridField("latitude", "Latitude"), + new ListGridField("longitude", "Longitude"), + new ListGridField("speed", "Speed"), + new ListGridField("course", "Course"), + new ListGridField("power", "Power")); + + list.setCanSort(false); + list.setShowHeaderContextMenu(false); + list.setShowHeaderMenuButton(false); + + section.setItems(toolbar, list); + setSections(section); + } + +} diff --git a/src/main/java/org/traccar/web/client/DevicePanel.java b/src/main/java/org/traccar/web/client/DevicePanel.java new file mode 100644 index 00000000..ba30fefb --- /dev/null +++ b/src/main/java/org/traccar/web/client/DevicePanel.java @@ -0,0 +1,54 @@ +package org.traccar.web.client; + +import com.smartgwt.client.widgets.toolbar.ToolStrip; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.layout.SectionStack; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.toolbar.ToolStripButton; + +/** + * Device list widget + */ +public class DevicePanel extends SectionStack { + + private ToolStrip toolbar; + private ListGrid list; + + public DevicePanel() { + SectionStackSection section = new SectionStackSection("Devices"); + section.setCanCollapse(false); + section.setExpanded(true); + + toolbar = new ToolStrip(); + toolbar.setWidth100(); + + ToolStripButton button = new ToolStripButton(); + button.setTitle("Add"); + toolbar.addButton(button); + button = new ToolStripButton(); + button.setTitle("Remove"); + toolbar.addButton(button); + button = new ToolStripButton(); + button.setTitle("Edit"); + toolbar.addButton(button); + toolbar.addFill(); + toolbar.addSeparator(); + button = new ToolStripButton(); + button.setTitle("Settings"); + toolbar.addButton(button); + + list = new ListGrid(); + list.setFields( + new ListGridField("id", "Id"), + new ListGridField("imei", "IMEI")); + + list.setCanSort(false); + list.setShowHeaderContextMenu(false); + list.setShowHeaderMenuButton(false); + + section.setItems(toolbar, list); + setSections(section); + } + +} diff --git a/src/main/java/org/traccar/web/client/MapPanel.java b/src/main/java/org/traccar/web/client/MapPanel.java new file mode 100644 index 00000000..72ed0d3b --- /dev/null +++ b/src/main/java/org/traccar/web/client/MapPanel.java @@ -0,0 +1,108 @@ +package org.traccar.web.client; + +import com.smartgwt.client.widgets.layout.SectionStack; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.WidgetCanvas; +import com.smartgwt.client.widgets.events.ResizedEvent; +import com.smartgwt.client.widgets.events.ResizedHandler; +import com.smartgwt.client.widgets.events.DragResizeStopEvent; +import com.smartgwt.client.widgets.events.DragResizeStopHandler; +import com.smartgwt.client.widgets.events.DrawEvent; +import com.smartgwt.client.widgets.events.DrawHandler; +import com.smartgwt.client.types.Overflow; + +import com.google.gwt.core.client.Scheduler; + +import org.gwtopenmaps.openlayers.client.LonLat; +import org.gwtopenmaps.openlayers.client.Map; +import org.gwtopenmaps.openlayers.client.MapOptions; +import org.gwtopenmaps.openlayers.client.MapWidget; +import org.gwtopenmaps.openlayers.client.Projection; +import org.gwtopenmaps.openlayers.client.control.LayerSwitcher; +import org.gwtopenmaps.openlayers.client.control.OverviewMap; +import org.gwtopenmaps.openlayers.client.control.ScaleLine; +import org.gwtopenmaps.openlayers.client.layer.OSM; + +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; + +import com.google.gwt.event.logical.shared.AttachEvent; +import org.gwtopenmaps.openlayers.client.layer.*; + +/** + * Map panel widget + */ +public class MapPanel extends SectionStack { + + private final static int BORDER_SIZE = 1; + + private MapWidget mapWidget; + private WidgetCanvas mapWrapper; + + private MapWidget createMapWidget() { + MapOptions defaultMapOptions = new MapOptions(); + defaultMapOptions.setNumZoomLevels(16); + + MapWidget mapWidget = new MapWidget("100%", "100%", defaultMapOptions); + + // Google layer + /*GoogleV3Options layerOptiond = new GoogleV3Options(); + layerOptiond.setIsBaseLayer(true); + layerOptiond.setType(GoogleV3MapType.G_NORMAL_MAP); + GoogleV3 layer = new GoogleV3("Google", layerOptiond);*/ + + // Open Street Map layer + OSM layer = OSM.Mapnik("Mapnik"); + layer.setIsBaseLayer(true); + + Map map = mapWidget.getMap(); + map.addLayer(layer); + map.addControl(new ScaleLine()); + + // Default center + LonLat lonLat = new LonLat(12.5, 41.9); + lonLat.transform(new Projection("EPSG:4326").getProjectionCode(), map.getProjection()); + map.setCenter(lonLat, 1); + + return mapWidget; + } + + public MapPanel() { + SectionStackSection section = new SectionStackSection("Map"); + section.setCanCollapse(false); + section.setExpanded(true); + + mapWidget = createMapWidget(); + + mapWrapper = new WidgetCanvas(mapWidget); + mapWrapper.setStyleName("defaultBorder"); + mapWrapper.setHeight100(); + mapWrapper.setWidth100(); + + // Map widget size hack + mapWrapper.addDrawHandler(new DrawHandler() { + @Override + public void onDraw(DrawEvent event) { + Element e = DOM.getElementById(mapWrapper.getID() + "_widget"); + if (e.getParentNode() != null) { + e.getParentElement().getStyle().setProperty("width", "100%"); + e.getParentElement().getStyle().setProperty("height", "100%"); + } + } + }); + + // Map resize handler + mapWrapper.addResizedHandler(new ResizedHandler() { + @Override + public void onResized(ResizedEvent event) { + mapWidget.getMap().updateSize(); + } + }); + + section.setItems(mapWrapper); + setSections(section); + } + +} diff --git a/src/main/java/org/traccar/web/client/Traccar.java b/src/main/java/org/traccar/web/client/Traccar.java new file mode 100644 index 00000000..6c8cdf18 --- /dev/null +++ b/src/main/java/org/traccar/web/client/Traccar.java @@ -0,0 +1,49 @@ +package org.traccar.web.client; + +import com.google.gwt.core.client.EntryPoint; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +/** + * Entry point class + */ +public class Traccar implements EntryPoint { + + private DevicePanel devicePanel; + private ArchivePanel archivePanel; + private MapPanel mapPanel; + + /** + * Entry point method + */ + public void onModuleLoad() { + + devicePanel = new DevicePanel(); + devicePanel.setWidth("20%"); + devicePanel.setShowResizeBar(true); + + mapPanel = new MapPanel(); + mapPanel.setWidth("80%"); + + HLayout hLayout = new HLayout(); + hLayout.setHeight("70%"); + hLayout.addMember(devicePanel); + hLayout.addMember(mapPanel); + hLayout.setShowResizeBar(true); + hLayout.setResizeBarTarget("next"); + + archivePanel = new ArchivePanel(); + archivePanel.setHeight("30%"); + + VLayout mainLayout = new VLayout(); + mainLayout.setWidth100(); + mainLayout.setHeight100(); + mainLayout.addMember(hLayout); + mainLayout.addMember(archivePanel); + mainLayout.draw(); + } +} |