aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/client/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/web/client/view')
-rw-r--r--src/org/traccar/web/client/view/ArchiveView.java88
-rw-r--r--src/org/traccar/web/client/view/ArchiveView.ui.xml20
-rw-r--r--src/org/traccar/web/client/view/DeviceView.java27
-rw-r--r--src/org/traccar/web/client/view/DeviceView.ui.xml4
4 files changed, 99 insertions, 40 deletions
diff --git a/src/org/traccar/web/client/view/ArchiveView.java b/src/org/traccar/web/client/view/ArchiveView.java
index 79621ba9..f61ffccc 100644
--- a/src/org/traccar/web/client/view/ArchiveView.java
+++ b/src/org/traccar/web/client/view/ArchiveView.java
@@ -4,7 +4,10 @@ import java.util.Date;
import java.util.LinkedList;
import java.util.List;
+import org.traccar.web.client.model.BaseStoreHandlers;
+import org.traccar.web.client.model.DeviceProperties;
import org.traccar.web.client.model.PositionProperties;
+import org.traccar.web.shared.model.Device;
import org.traccar.web.shared.model.Position;
import com.google.gwt.cell.client.DateCell;
@@ -12,15 +15,21 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Widget;
+import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.data.shared.ListStore;
+import com.sencha.gxt.data.shared.event.StoreHandlers;
import com.sencha.gxt.widget.core.client.ContentPanel;
+import com.sencha.gxt.widget.core.client.event.SelectEvent;
+import com.sencha.gxt.widget.core.client.form.ComboBox;
+import com.sencha.gxt.widget.core.client.form.DateField;
+import com.sencha.gxt.widget.core.client.form.TimeField;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
-public class ArchiveView extends Composite {
+public class ArchiveView {
private static ArchiveViewUiBinder uiBinder = GWT.create(ArchiveViewUiBinder.class);
@@ -29,6 +38,8 @@ public class ArchiveView extends Composite {
public interface ArchiveHandler {
public void onSelected(Position position);
+ public void onLoad(Device device, Date from, Date to);
+ public void onClear();
}
private ArchiveHandler archiveHandler;
@@ -40,17 +51,40 @@ public class ArchiveView extends Composite {
return contentPanel;
}
+ ListStore<Device> deviceStore;
+
+ @UiField
+ DateField fromDate;
+
+ @UiField
+ TimeField fromTime;
+
+ @UiField
+ DateField toDate;
+
+ @UiField
+ TimeField toTime;
+
+ @UiField(provided = true)
+ ComboBox<Device> deviceCombo;
+
@UiField(provided = true)
ColumnModel<Position> columnModel;
@UiField(provided = true)
- ListStore<Position> store;
+ ListStore<Position> positionStore;
@UiField
Grid<Position> grid;
- public ArchiveView(ArchiveHandler archiveHandler) {
+ public ArchiveView(ArchiveHandler archiveHandler, ListStore<Position> positionStore, ListStore<Device> deviceStore) {
this.archiveHandler = archiveHandler;
+ this.positionStore = positionStore;
+ deviceStore.addStoreHandlers(deviceStoreHandlers);
+ this.deviceStore = deviceStore;
+
+ DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
+ deviceCombo = new ComboBox<Device>(deviceStore, deviceProperties.label());
PositionProperties positionProperties = GWT.create(PositionProperties.class);
@@ -71,9 +105,51 @@ public class ArchiveView extends Composite {
columnModel = new ColumnModel<Position>(columnConfigList);
- store = new ListStore<Position>(positionProperties.id());
-
uiBinder.createAndBindUi(this);
+
+ grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
+
+ // Initialize with current time
+ Date now = new Date();
+ fromDate.setValue(now);
+ fromTime.setValue(now);
+ toDate.setValue(now);
+ toTime.setValue(now);
+ }
+
+ @SuppressWarnings("deprecation")
+ private static Date getCombineDate(DateField dateField, TimeField timeField) {
+ Date result = null;
+ Date date = dateField.getValue();
+ Date time = timeField.getValue();
+ if (date != null && time != null) {
+ result = new Date(
+ date.getYear(), date.getMonth(), date.getDate(),
+ time.getHours(), time.getMinutes(), time.getSeconds());
+ }
+ return result;
+ }
+
+ @UiHandler("loadButton")
+ public void onLoadClicked(SelectEvent event) {
+ archiveHandler.onLoad(
+ deviceCombo.getValue(),
+ getCombineDate(fromDate, fromTime),
+ getCombineDate(toDate, toTime));
+ }
+
+ @UiHandler("clearButton")
+ public void onClearClicked(SelectEvent event) {
+ archiveHandler.onClear();
}
+ private StoreHandlers<Device> deviceStoreHandlers = new BaseStoreHandlers<Device>() {
+
+ @Override
+ public void onAnything() {
+ deviceCombo.setValue(deviceStore.findModel(deviceCombo.getValue()));
+ }
+
+ };
+
}
diff --git a/src/org/traccar/web/client/view/ArchiveView.ui.xml b/src/org/traccar/web/client/view/ArchiveView.ui.xml
index 370eb024..f27d38ff 100644
--- a/src/org/traccar/web/client/view/ArchiveView.ui.xml
+++ b/src/org/traccar/web/client/view/ArchiveView.ui.xml
@@ -16,7 +16,7 @@
<ui:attributes width="1" height="1" />
</ui:with>
- <ui:with type="com.sencha.gxt.data.shared.ListStore" field="store" />
+ <ui:with type="com.sencha.gxt.data.shared.ListStore" field="positionStore" />
<ui:with type="com.sencha.gxt.widget.core.client.grid.ColumnModel" field="columnModel" />
<ui:with type="com.sencha.gxt.widget.core.client.grid.GridView" field="view">
@@ -30,28 +30,30 @@
<toolbar:ToolBar>
<toolbar:LabelToolItem label="Device:" />
- <form:TimeField /> <!-- put combobox here -->
+ <form:ComboBox ui:field="deviceCombo" editable="false" triggerAction="ALL" />
<toolbar:SeparatorToolItem />
<toolbar:LabelToolItem label="From:" />
- <form:DateField width="125" />
+ <form:DateField width="125" ui:field="fromDate" />
<toolbar:LabelToolItem width="5" />
- <form:TimeField width="75" />
+ <form:TimeField width="75" ui:field="fromTime" triggerAction="ALL" />
<toolbar:SeparatorToolItem />
<toolbar:LabelToolItem label="To:" />
- <form:DateField width="125" />
+ <form:DateField width="125" ui:field="toDate" />
<toolbar:LabelToolItem width="5" />
- <form:TimeField width="75" />
+ <form:TimeField width="75" ui:field="toTime" triggerAction="ALL" />
<toolbar:SeparatorToolItem />
-
+
<button:TextButton ui:field="loadButton" text="Load" />
-
+ <toolbar:FillToolItem />
+ <button:TextButton ui:field="clearButton" text="Clear" />
+
</toolbar:ToolBar>
</container:child>
<container:child layoutData="{layoutData}">
- <grid:Grid ui:field="grid" store="{store}" cm="{columnModel}" view="{view}" />
+ <grid:Grid ui:field="grid" store="{positionStore}" cm="{columnModel}" view="{view}" />
</container:child>
</container:VerticalLayoutContainer>
diff --git a/src/org/traccar/web/client/view/DeviceView.java b/src/org/traccar/web/client/view/DeviceView.java
index 157973e0..1213e5f0 100644
--- a/src/org/traccar/web/client/view/DeviceView.java
+++ b/src/org/traccar/web/client/view/DeviceView.java
@@ -1,6 +1,5 @@
package org.traccar.web.client.view;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -11,7 +10,6 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
-import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.data.shared.ListStore;
@@ -23,7 +21,7 @@ import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
-public class DeviceView extends Composite implements SelectionChangedEvent.SelectionChangedHandler<Device> {
+public class DeviceView implements SelectionChangedEvent.SelectionChangedHandler<Device> {
private static DeviceViewUiBinder uiBinder = GWT.create(DeviceViewUiBinder.class);
@@ -59,13 +57,14 @@ public class DeviceView extends Composite implements SelectionChangedEvent.Selec
ColumnModel<Device> columnModel;
@UiField(provided = true)
- ListStore<Device> store;
+ ListStore<Device> deviceStore;
@UiField
Grid<Device> grid;
- public DeviceView(DeviceHandler deviceHandler) {
+ public DeviceView(DeviceHandler deviceHandler, ListStore<Device> deviceStore) {
this.deviceHandler = deviceHandler;
+ this.deviceStore = deviceStore;
DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
@@ -74,8 +73,6 @@ public class DeviceView extends Composite implements SelectionChangedEvent.Selec
columnConfigList.add(new ColumnConfig<Device, String>(deviceProperties.uniqueId(), 0, "Unique Identifier"));
columnModel = new ColumnModel<Device>(columnConfigList);
- store = new ListStore<Device>(deviceProperties.id());
-
uiBinder.createAndBindUi(this);
grid.getSelectionModel().addSelectionChangedHandler(this);
@@ -94,35 +91,19 @@ public class DeviceView extends Composite implements SelectionChangedEvent.Selec
}
}
- public void load(Collection<Device> devices) {
- store.addAll(devices);
- }
-
@UiHandler("addButton")
public void onAddClicked(SelectEvent event) {
deviceHandler.onAdd();
}
- public void add(Device device) {
- store.add(store.size(), device);
- }
-
@UiHandler("editButton")
public void onEditClicked(SelectEvent event) {
deviceHandler.onEdit(grid.getSelectionModel().getSelectedItem());
}
- public void update(Device device) {
- store.update(device);
- }
-
@UiHandler("removeButton")
public void onRemoveClicked(SelectEvent event) {
deviceHandler.onRemove(grid.getSelectionModel().getSelectedItem());
}
- public void remove(Device device) {
- store.remove(device);
- }
-
}
diff --git a/src/org/traccar/web/client/view/DeviceView.ui.xml b/src/org/traccar/web/client/view/DeviceView.ui.xml
index d9988d5e..af1b33cd 100644
--- a/src/org/traccar/web/client/view/DeviceView.ui.xml
+++ b/src/org/traccar/web/client/view/DeviceView.ui.xml
@@ -15,7 +15,7 @@
<ui:attributes width="1" height="1" />
</ui:with>
- <ui:with type="com.sencha.gxt.data.shared.ListStore" field="store" />
+ <ui:with type="com.sencha.gxt.data.shared.ListStore" field="deviceStore" />
<ui:with type="com.sencha.gxt.widget.core.client.grid.ColumnModel" field="columnModel" />
<ui:with type="com.sencha.gxt.widget.core.client.grid.GridView" field="view">
@@ -37,7 +37,7 @@
</container:child>
<container:child layoutData="{layoutData}">
- <grid:Grid ui:field="grid" store="{store}" cm="{columnModel}" view="{view}" />
+ <grid:Grid ui:field="grid" store="{deviceStore}" cm="{columnModel}" view="{view}" />
</container:child>
</container:VerticalLayoutContainer>