aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-02-17 13:24:07 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-02-17 13:24:07 +1300
commit9f80fe9b90d9ddb1132c139072cfe3bac5a42491 (patch)
treefd8234a8cc7d7b5a7174dad6fe4c27c4017c0182 /src
parent29b57a52c6a66075261d7e6d4797fa1bcc7c8cb8 (diff)
downloadtrackermap-web-9f80fe9b90d9ddb1132c139072cfe3bac5a42491.tar.gz
trackermap-web-9f80fe9b90d9ddb1132c139072cfe3bac5a42491.tar.bz2
trackermap-web-9f80fe9b90d9ddb1132c139072cfe3bac5a42491.zip
Added settings controller
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/web/client/Application.java5
-rw-r--r--src/org/traccar/web/client/FormatterUtil.java17
-rw-r--r--src/org/traccar/web/client/controller/DeviceController.java7
-rw-r--r--src/org/traccar/web/client/controller/SettingsController.java31
-rw-r--r--src/org/traccar/web/client/view/DeviceView.java34
-rw-r--r--src/org/traccar/web/client/view/DeviceView.ui.xml14
6 files changed, 100 insertions, 8 deletions
diff --git a/src/org/traccar/web/client/Application.java b/src/org/traccar/web/client/Application.java
index 07e2586b..cd3424dd 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.SettingsController;
import org.traccar.web.client.controller.StateController;
import org.traccar.web.client.model.BaseStoreHandlers;
import org.traccar.web.client.model.DataService;
@@ -48,6 +49,7 @@ public class Application {
return logger;
}
+ private final SettingsController settingsController;
private final DeviceController deviceController;
private final StateController stateController;
private final MapController mapController;
@@ -56,7 +58,8 @@ public class Application {
private ApplicationView view;
public Application() {
- deviceController = new DeviceController(deviceHandler);
+ settingsController = new SettingsController();
+ deviceController = new DeviceController(deviceHandler, settingsController);
deviceController.getDeviceStore().addStoreHandlers(deviceStoreHandler);
stateController = new StateController();
mapController = new MapController(mapHandler);
diff --git a/src/org/traccar/web/client/FormatterUtil.java b/src/org/traccar/web/client/FormatterUtil.java
new file mode 100644
index 00000000..f5c7d3e1
--- /dev/null
+++ b/src/org/traccar/web/client/FormatterUtil.java
@@ -0,0 +1,17 @@
+package org.traccar.web.client;
+
+import java.util.Date;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+
+public class FormatterUtil {
+
+ public DateTimeFormat getTimeFormat() {
+ return DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
+ }
+
+ public String formatTime(Date time) {
+ return getTimeFormat().format(time);
+ }
+
+}
diff --git a/src/org/traccar/web/client/controller/DeviceController.java b/src/org/traccar/web/client/controller/DeviceController.java
index 75aa76fa..94c81ed3 100644
--- a/src/org/traccar/web/client/controller/DeviceController.java
+++ b/src/org/traccar/web/client/controller/DeviceController.java
@@ -30,7 +30,6 @@ import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
import com.sencha.gxt.widget.core.client.event.HideEvent;
-import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
public class DeviceController implements ContentController, DeviceView.DeviceHandler {
@@ -44,11 +43,11 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
private DeviceView deviceView;
- public DeviceController(DeviceHandler deviceHandler) {
+ public DeviceController(DeviceHandler deviceHandler, DeviceView.SettingsHandler settingsHandler) {
this.deviceHandler = deviceHandler;
DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
deviceStore = new ListStore<Device>(deviceProperties.id());
- deviceView = new DeviceView(this, deviceStore);
+ deviceView = new DeviceView(this, settingsHandler, deviceStore);
}
public ListStore<Device> getDeviceStore() {
@@ -108,7 +107,7 @@ public class DeviceController implements ContentController, DeviceView.DeviceHan
@Override
public void onRemove(final Device device) {
final ConfirmMessageBox dialog = new ConfirmMessageBox("Confirm", "Are you sure you want remove device?");
- dialog.addHideHandler(new HideHandler() {
+ dialog.addHideHandler(new HideEvent.HideHandler() {
@Override
public void onHide(HideEvent event) {
if (dialog.getHideButton() == dialog.getButtonById(PredefinedButton.YES.name())) {
diff --git a/src/org/traccar/web/client/controller/SettingsController.java b/src/org/traccar/web/client/controller/SettingsController.java
new file mode 100644
index 00000000..b98d1bc8
--- /dev/null
+++ b/src/org/traccar/web/client/controller/SettingsController.java
@@ -0,0 +1,31 @@
+package org.traccar.web.client.controller;
+
+import org.traccar.web.client.view.DeviceView;
+
+public class SettingsController implements DeviceView.SettingsHandler {
+
+ @Override
+ public void onAccountSelected() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onPreferencesSelected() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onUsersSelected() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onGlobalSelected() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/org/traccar/web/client/view/DeviceView.java b/src/org/traccar/web/client/view/DeviceView.java
index c3f3f7a3..8a0b6243 100644
--- a/src/org/traccar/web/client/view/DeviceView.java
+++ b/src/org/traccar/web/client/view/DeviceView.java
@@ -24,6 +24,7 @@ import org.traccar.web.client.model.DeviceProperties;
import org.traccar.web.shared.model.Device;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
@@ -37,6 +38,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent;
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;
+import com.sencha.gxt.widget.core.client.menu.Item;
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
public class DeviceView implements SelectionChangedEvent.SelectionChangedHandler<Device> {
@@ -80,8 +82,9 @@ public class DeviceView implements SelectionChangedEvent.SelectionChangedHandler
@UiField
Grid<Device> grid;
- public DeviceView(DeviceHandler deviceHandler, ListStore<Device> deviceStore) {
+ public DeviceView(DeviceHandler deviceHandler, SettingsHandler settingsHandler, ListStore<Device> deviceStore) {
this.deviceHandler = deviceHandler;
+ this.settingsHandler = settingsHandler;
this.deviceStore = deviceStore;
DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
@@ -138,4 +141,33 @@ public class DeviceView implements SelectionChangedEvent.SelectionChangedHandler
grid.getSelectionModel().select(deviceStore.findModel(device), false);
}
+ public interface SettingsHandler {
+ public void onAccountSelected();
+ public void onPreferencesSelected();
+ public void onUsersSelected();
+ public void onGlobalSelected();
+ }
+
+ private SettingsHandler settingsHandler;
+
+ @UiHandler("settingsAccount")
+ public void onSettingsAccountSelected(SelectionEvent<Item> event) {
+ settingsHandler.onAccountSelected();
+ }
+
+ @UiHandler("preferencesAccount")
+ public void onSettingsPreferencesSelected(SelectionEvent<Item> event) {
+ settingsHandler.onPreferencesSelected();
+ }
+
+ @UiHandler("usersAccount")
+ public void onSettingsUsersSelected(SelectionEvent<Item> event) {
+ settingsHandler.onUsersSelected();
+ }
+
+ @UiHandler("globalAccount")
+ public void onSettingsGlobalSelected(SelectionEvent<Item> event) {
+ settingsHandler.onGlobalSelected();
+ }
+
}
diff --git a/src/org/traccar/web/client/view/DeviceView.ui.xml b/src/org/traccar/web/client/view/DeviceView.ui.xml
index 77de651e..f612957d 100644
--- a/src/org/traccar/web/client/view/DeviceView.ui.xml
+++ b/src/org/traccar/web/client/view/DeviceView.ui.xml
@@ -6,7 +6,8 @@
xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
xmlns:toolbar="urn:import:com.sencha.gxt.widget.core.client.toolbar"
xmlns:grid="urn:import:com.sencha.gxt.widget.core.client.grid"
- xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button">
+ xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button"
+ xmlns:menu="urn:import:com.sencha.gxt.widget.core.client.menu">
<ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="toolBarRowData">
<ui:attributes width="1" height="-1" />
@@ -32,7 +33,16 @@
<button:TextButton ui:field="removeButton" text="Remove" enabled="false" />
<toolbar:FillToolItem />
<toolbar:SeparatorToolItem />
- <button:TextButton ui:field="settingsButton" text="Settings" enabled="false" />
+ <button:TextButton ui:field="settingsButton" text="Settings">
+ <button:menu>
+ <menu:Menu>
+ <menu:MenuItem text="Account" ui:field="settingsAccount" />
+ <menu:MenuItem text="Preferences" ui:field="preferencesAccount" />
+ <menu:MenuItem text="Users" ui:field="usersAccount" />
+ <menu:MenuItem text="Global" ui:field="globalAccount" />
+ </menu:Menu>
+ </button:menu>
+ </button:TextButton>
<button:TextButton ui:field="logoutButton" text="Logout" />
</toolbar:ToolBar>
</container:child>