aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-08-03 15:13:14 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-08-03 15:13:14 +1200
commitfcaf637431fee2cdd5ccab79b6de1edf44bac777 (patch)
tree28b12e76700f4ac03d4d10e0d0944762d30621a0 /src/org/traccar
parent207e4f459d1e91c66376916f2a99cf66f7d04bd0 (diff)
downloadtrackermap-web-fcaf637431fee2cdd5ccab79b6de1edf44bac777.tar.gz
trackermap-web-fcaf637431fee2cdd5ccab79b6de1edf44bac777.tar.bz2
trackermap-web-fcaf637431fee2cdd5ccab79b6de1edf44bac777.zip
Remove files and update readme
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/web/Traccar.gwt.xml22
-rw-r--r--src/org/traccar/web/client/Application.java155
-rw-r--r--src/org/traccar/web/client/ApplicationContext.java66
-rw-r--r--src/org/traccar/web/client/FormatterUtil.java42
-rw-r--r--src/org/traccar/web/client/Traccar.java42
-rw-r--r--src/org/traccar/web/client/controller/ArchiveController.java98
-rw-r--r--src/org/traccar/web/client/controller/ContentController.java26
-rw-r--r--src/org/traccar/web/client/controller/DeviceController.java139
-rw-r--r--src/org/traccar/web/client/controller/LoginController.java101
-rw-r--r--src/org/traccar/web/client/controller/MapController.java138
-rw-r--r--src/org/traccar/web/client/controller/SettingsController.java151
-rw-r--r--src/org/traccar/web/client/controller/StateController.java57
-rw-r--r--src/org/traccar/web/client/model/ApplicationSettingsProperties.java30
-rw-r--r--src/org/traccar/web/client/model/BaseAsyncCallback.java32
-rw-r--r--src/org/traccar/web/client/model/BaseStoreHandlers.java73
-rw-r--r--src/org/traccar/web/client/model/DataService.java62
-rw-r--r--src/org/traccar/web/client/model/DataServiceAsync.java60
-rw-r--r--src/org/traccar/web/client/model/DeviceProperties.java37
-rw-r--r--src/org/traccar/web/client/model/EnumKeyProvider.java13
-rw-r--r--src/org/traccar/web/client/model/PositionProperties.java48
-rw-r--r--src/org/traccar/web/client/model/StateItem.java31
-rw-r--r--src/org/traccar/web/client/model/StateItemProperties.java17
-rw-r--r--src/org/traccar/web/client/model/StateReader.java50
-rw-r--r--src/org/traccar/web/client/model/UserProperties.java34
-rw-r--r--src/org/traccar/web/client/model/UserSettingsProperties.java50
-rw-r--r--src/org/traccar/web/client/view/ApplicationSettingsDialog.java81
-rw-r--r--src/org/traccar/web/client/view/ApplicationSettingsDialog.ui.xml33
-rw-r--r--src/org/traccar/web/client/view/ApplicationView.java52
-rw-r--r--src/org/traccar/web/client/view/ApplicationView.ui.xml56
-rw-r--r--src/org/traccar/web/client/view/ArchiveView.java196
-rw-r--r--src/org/traccar/web/client/view/ArchiveView.ui.xml62
-rw-r--r--src/org/traccar/web/client/view/DeviceDialog.java84
-rw-r--r--src/org/traccar/web/client/view/DeviceDialog.ui.xml40
-rw-r--r--src/org/traccar/web/client/view/DeviceView.java186
-rw-r--r--src/org/traccar/web/client/view/DeviceView.ui.xml57
-rw-r--r--src/org/traccar/web/client/view/LoginDialog.java84
-rw-r--r--src/org/traccar/web/client/view/LoginDialog.ui.xml40
-rw-r--r--src/org/traccar/web/client/view/MapPositionRenderer.java185
-rw-r--r--src/org/traccar/web/client/view/MapView.java211
-rw-r--r--src/org/traccar/web/client/view/MarkerIconFactory.java51
-rw-r--r--src/org/traccar/web/client/view/StateView.java58
-rw-r--r--src/org/traccar/web/client/view/StateView.ui.xml22
-rw-r--r--src/org/traccar/web/client/view/UserDialog.java95
-rw-r--r--src/org/traccar/web/client/view/UserDialog.ui.xml47
-rw-r--r--src/org/traccar/web/client/view/UserSettingsDialog.java97
-rw-r--r--src/org/traccar/web/client/view/UserSettingsDialog.ui.xml33
-rw-r--r--src/org/traccar/web/client/view/UsersDialog.java110
-rw-r--r--src/org/traccar/web/client/view/UsersDialog.ui.xml50
-rw-r--r--src/org/traccar/web/server/model/DataServiceImpl.java467
-rw-r--r--src/org/traccar/web/shared/model/ApplicationSettings.java34
-rw-r--r--src/org/traccar/web/shared/model/Device.java83
-rw-r--r--src/org/traccar/web/shared/model/Position.java131
-rw-r--r--src/org/traccar/web/shared/model/User.java115
-rw-r--r--src/org/traccar/web/shared/model/UserSettings.java43
54 files changed, 0 insertions, 4377 deletions
diff --git a/src/org/traccar/web/Traccar.gwt.xml b/src/org/traccar/web/Traccar.gwt.xml
deleted file mode 100644
index 0f717663..00000000
--- a/src/org/traccar/web/Traccar.gwt.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
- "http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
-
-<module rename-to='traccar'>
-
- <inherits name='com.google.gwt.user.User'/>
- <inherits name="com.google.gwt.logging.Logging"/>
- <inherits name="com.google.gwt.xml.XML"/>
- <inherits name='com.sencha.gxt.ui.GXT'/>
- <inherits name='org.gwtopenmaps.openlayers.OpenLayers' />
-
- <set-property name="gwt.logging.enabled" value="FALSE"/>
- <set-property name="gwt.logging.consoleHandler" value="DISABLED"/>
-
- <entry-point class='org.traccar.web.client.Traccar'/>
-
- <source path='client'/>
- <source path='shared'/>
-
-</module>
diff --git a/src/org/traccar/web/client/Application.java b/src/org/traccar/web/client/Application.java
deleted file mode 100644
index cd3424dd..00000000
--- a/src/org/traccar/web/client/Application.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client;
-
-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;
-import org.traccar.web.client.model.DataServiceAsync;
-import org.traccar.web.client.view.ApplicationView;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.sencha.gxt.data.shared.event.StoreAddEvent;
-import com.sencha.gxt.data.shared.event.StoreHandlers;
-import com.sencha.gxt.data.shared.event.StoreRemoveEvent;
-
-public class Application {
-
- private static final DataServiceAsync dataService = GWT.create(DataService.class);
-
- public static DataServiceAsync getDataService() {
- return dataService;
- }
-
- private static Logger logger = Logger.getLogger("");
-
- public static Logger getLogger() {
- return logger;
- }
-
- private final SettingsController settingsController;
- private final DeviceController deviceController;
- private final StateController stateController;
- private final MapController mapController;
- private final ArchiveController archiveController;
-
- private ApplicationView view;
-
- public Application() {
- settingsController = new SettingsController();
- deviceController = new DeviceController(deviceHandler, settingsController);
- deviceController.getDeviceStore().addStoreHandlers(deviceStoreHandler);
- stateController = new StateController();
- mapController = new MapController(mapHandler);
- archiveController = new ArchiveController(archiveHanlder, deviceController.getDeviceStore());
- archiveController.getPositionStore().addStoreHandlers(archiveStoreHandler);
-
- view = new ApplicationView(
- 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
- public void onSelected(Position position) {
- mapController.selectArchivePosition(position);
- }
-
- };
-
- private StoreHandlers<Device> deviceStoreHandler = new BaseStoreHandlers<Device>() {
-
- @Override
- public void onAdd(StoreAddEvent<Device> event) {
- mapController.update();
- }
-
- @Override
- public void onRemove(StoreRemoveEvent<Device> event) {
- mapController.update();
- }
-
- };
-
- private StoreHandlers<Position> archiveStoreHandler = new BaseStoreHandlers<Position>() {
-
- @Override
- public void onAnything() {
- mapController.showArchivePositions(archiveController.getPositionStore().getAll());
- }
-
- };
-
-}
diff --git a/src/org/traccar/web/client/ApplicationContext.java b/src/org/traccar/web/client/ApplicationContext.java
deleted file mode 100644
index 80b8998d..00000000
--- a/src/org/traccar/web/client/ApplicationContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.traccar.web.client;
-
-import org.traccar.web.shared.model.ApplicationSettings;
-import org.traccar.web.shared.model.User;
-import org.traccar.web.shared.model.UserSettings;
-
-public class ApplicationContext {
-
- private static final ApplicationContext context = new ApplicationContext();
-
- public static ApplicationContext getInstance() {
- return context;
- }
-
- private FormatterUtil formatterUtil;
-
- public void setFormatterUtil(FormatterUtil formatterUtil) {
- this.formatterUtil = formatterUtil;
- }
-
- public FormatterUtil getFormatterUtil() {
- if (formatterUtil == null) {
- formatterUtil = new FormatterUtil();
- }
- return formatterUtil;
- }
-
- private ApplicationSettings applicationSettings;
-
- public void setApplicationSettings(ApplicationSettings applicationSettings) {
- this.applicationSettings = applicationSettings;
- }
-
- public ApplicationSettings getApplicationSettings() {
- if (applicationSettings != null) {
- return applicationSettings;
- } else {
- return new ApplicationSettings(); // default settings
- }
- }
-
- private User user;
-
- public void setUser(User user) {
- this.user = user;
- }
-
- public User getUser() {
- return user;
- }
-
- public void setUserSettings(UserSettings userSettings) {
- if (user != null) {
- user.setUserSettings(userSettings);
- }
- }
-
- public UserSettings getUserSettings() {
- if (user != null && user.getUserSettings() != null) {
- return user.getUserSettings();
- } else {
- return new UserSettings(); // default settings
- }
- }
-
-}
diff --git a/src/org/traccar/web/client/FormatterUtil.java b/src/org/traccar/web/client/FormatterUtil.java
deleted file mode 100644
index 36c24dcb..00000000
--- a/src/org/traccar/web/client/FormatterUtil.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.traccar.web.client;
-
-import com.google.gwt.i18n.client.CurrencyList;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.NumberFormat;
-
-public class FormatterUtil {
-
- public DateTimeFormat getTimeFormat() {
- return DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
- }
-
- private class SpeedNumberFormat extends NumberFormat {
-
- private final String unit;
- private final double factor;
-
- public SpeedNumberFormat(String unit, double factor) {
- super("0.##", CurrencyList.get().getDefault(), true);
- this.unit = unit;
- this.factor = factor;
- }
-
- @Override
- public String format(double number) {
- return super.format(number * factor) + " " + unit;
- }
-
- }
-
- public NumberFormat getSpeedFormat() {
- switch (ApplicationContext.getInstance().getUserSettings().getSpeedUnit()) {
- case kilometersPerHour:
- return new SpeedNumberFormat("km/h", 1.852);
- case milesPerHour:
- return new SpeedNumberFormat("mph", 1.150779);
- default:
- return new SpeedNumberFormat("kn", 1);
- }
- }
-
-}
diff --git a/src/org/traccar/web/client/Traccar.java b/src/org/traccar/web/client/Traccar.java
deleted file mode 100644
index d775bb4a..00000000
--- a/src/org/traccar/web/client/Traccar.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client;
-
-import org.traccar.web.client.controller.LoginController;
-import org.traccar.web.client.model.BaseAsyncCallback;
-import org.traccar.web.shared.model.ApplicationSettings;
-
-import com.google.gwt.core.client.EntryPoint;
-
-public class Traccar implements EntryPoint, LoginController.LoginHandler {
-
- @Override
- public void onModuleLoad() {
- Application.getDataService().updateApplicationSettings(null, new BaseAsyncCallback<ApplicationSettings>() {
- @Override
- public void onSuccess(ApplicationSettings result) {
- ApplicationContext.getInstance().setApplicationSettings(result);
- new LoginController().login(Traccar.this);
- }
- });
- }
-
- @Override
- public void onLogin() {
- new Application().run();
- }
-
-}
diff --git a/src/org/traccar/web/client/controller/ArchiveController.java b/src/org/traccar/web/client/controller/ArchiveController.java
deleted file mode 100644
index 9a0c18d0..00000000
--- a/src/org/traccar/web/client/controller/ArchiveController.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import java.util.Date;
-import java.util.List;
-
-import org.traccar.web.client.Application;
-import org.traccar.web.client.model.BaseAsyncCallback;
-import org.traccar.web.client.model.PositionProperties;
-import org.traccar.web.client.view.ArchiveView;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.core.client.GWT;
-import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.widget.core.client.ContentPanel;
-import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
-
-public class ArchiveController implements ContentController, ArchiveView.ArchiveHandler {
-
- public interface ArchiveHandler {
- public void onSelected(Position position);
- }
-
- private ArchiveHandler archiveHandler;
-
- private ListStore<Position> positionStore;
-
- private ArchiveView archiveView;
-
- public ArchiveController(ArchiveHandler archiveHandler, ListStore<Device> deviceStore) {
- this.archiveHandler = archiveHandler;
- PositionProperties positionProperties = GWT.create(PositionProperties.class);
- positionStore = new ListStore<Position>(positionProperties.id());
- archiveView = new ArchiveView(this, positionStore, deviceStore);
- }
-
- public ListStore<Position> getPositionStore() {
- return positionStore;
- }
-
- @Override
- public ContentPanel getView() {
- return archiveView.getView();
- }
-
- @Override
- public void run() {
- }
-
- @Override
- public void onSelected(Position position) {
- archiveHandler.onSelected(position);
- }
-
- @Override
- public void onLoad(Device device, Date from, Date to) {
- if (device != null && from != null && to != null) {
- Application.getDataService().getPositions(device, from, to, new BaseAsyncCallback<List<Position>>() {
- @Override
- public void onSuccess(List<Position> result) {
- positionStore.clear();
- if (result.isEmpty()) {
- new AlertMessageBox("Error", "No results found for selected period").show();
- } else {
- positionStore.addAll(result);
- }
- }
- });
- } else {
- new AlertMessageBox("Error", "All form fields must be filled first").show();
- }
- }
-
- @Override
- public void onClear() {
- positionStore.clear();
- }
-
- public void selectPosition(Position position) {
- archiveView.selectPosition(position);
- }
-
-}
diff --git a/src/org/traccar/web/client/controller/ContentController.java b/src/org/traccar/web/client/controller/ContentController.java
deleted file mode 100644
index 4fdea7c8..00000000
--- a/src/org/traccar/web/client/controller/ContentController.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import com.sencha.gxt.widget.core.client.ContentPanel;
-
-public interface ContentController {
-
- public ContentPanel getView();
-
- public void run();
-
-}
diff --git a/src/org/traccar/web/client/controller/DeviceController.java b/src/org/traccar/web/client/controller/DeviceController.java
deleted file mode 100644
index 599f7565..00000000
--- a/src/org/traccar/web/client/controller/DeviceController.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import java.util.List;
-
-import org.traccar.web.client.Application;
-import org.traccar.web.client.model.BaseAsyncCallback;
-import org.traccar.web.client.model.DeviceProperties;
-import org.traccar.web.client.view.DeviceDialog;
-import org.traccar.web.client.view.DeviceView;
-import org.traccar.web.shared.model.Device;
-
-import com.google.gwt.core.client.GWT;
-import com.sencha.gxt.data.shared.ListStore;
-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.AlertMessageBox;
-import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
-import com.sencha.gxt.widget.core.client.event.DialogHideEvent;
-
-public class DeviceController implements ContentController, DeviceView.DeviceHandler {
-
- public interface DeviceHandler {
- public void onSelected(Device device);
- }
-
- private DeviceHandler deviceHandler;
-
- private ListStore<Device> deviceStore;
-
- private DeviceView deviceView;
-
- 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, settingsHandler, deviceStore);
- }
-
- public ListStore<Device> getDeviceStore() {
- return deviceStore;
- }
-
- @Override
- public ContentPanel getView() {
- return deviceView.getView();
- }
-
- @Override
- public void run() {
- Application.getDataService().getDevices(new BaseAsyncCallback<List<Device>>() {
- @Override
- public void onSuccess(List<Device> result) {
- deviceStore.addAll(result);
- }
- });
- }
-
- @Override
- public void onSelected(Device device) {
- deviceHandler.onSelected(device);
- }
-
- @Override
- public void onAdd() {
- new DeviceDialog(new Device(), new DeviceDialog.DeviceHandler() {
- @Override
- public void onSave(Device device) {
- Application.getDataService().addDevice(device, new BaseAsyncCallback<Device>() {
- @Override
- public void onSuccess(Device result) {
- deviceStore.add(result);
- }
- @Override
- public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Device with this Unique ID already exists").show();
- }
- });
- }
- }).show();
- }
-
- @Override
- public void onEdit(Device device) {
- new DeviceDialog(new Device(device), new DeviceDialog.DeviceHandler() {
- @Override
- public void onSave(Device device) {
- Application.getDataService().updateDevice(device, new BaseAsyncCallback<Device>() {
- @Override
- public void onSuccess(Device result) {
- deviceStore.update(result);
- }
- @Override
- public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Device with this Unique ID already exists").show();
- }
- });
- }
- }).show();
- }
-
- @Override
- public void onRemove(final Device device) {
- final ConfirmMessageBox dialog = new ConfirmMessageBox("Confirm", "Are you sure you want remove device?");
- dialog.addDialogHideHandler(new DialogHideEvent.DialogHideHandler() {
- @Override
- public void onDialogHide(DialogHideEvent event) {
- if (event.getHideButton() == PredefinedButton.YES) {
- Application.getDataService().removeDevice(device, new BaseAsyncCallback<Device>() {
- @Override
- public void onSuccess(Device result) {
- deviceStore.remove(device);
- }
- });
- }
- }
- });
- dialog.show();
- }
-
- public void selectDevice(Device device) {
- deviceView.selectDevice(device);
- }
-
-}
diff --git a/src/org/traccar/web/client/controller/LoginController.java b/src/org/traccar/web/client/controller/LoginController.java
deleted file mode 100644
index 1aa152b8..00000000
--- a/src/org/traccar/web/client/controller/LoginController.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import org.traccar.web.client.Application;
-import org.traccar.web.client.ApplicationContext;
-import org.traccar.web.client.model.BaseAsyncCallback;
-import org.traccar.web.client.view.LoginDialog;
-import org.traccar.web.shared.model.User;
-
-import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
-
-public class LoginController implements LoginDialog.LoginHandler {
-
- private LoginDialog dialog;
-
- public interface LoginHandler {
- public void onLogin();
- }
-
- private LoginHandler loginHandler;
-
- public void login(final LoginHandler loginHandler) {
- this.loginHandler = loginHandler;
-
- Application.getDataService().authenticated(new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- ApplicationContext.getInstance().setUser(result);
- loginHandler.onLogin();
- }
- @Override
- public void onFailure(Throwable caught) {
- dialog = new LoginDialog(LoginController.this);
- dialog.show();
- }
- });
- }
-
- private boolean validate(String login, String password) {
- if (login == null || login.isEmpty() || password == null || password.isEmpty()) {
- new AlertMessageBox("Error", "User name and password must not be empty").show();
- return false;
- }
- return true;
- }
-
- @Override
- public void onLogin(String login, String password) {
- if (validate(login, password)) {
- Application.getDataService().login(login, password, new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- ApplicationContext.getInstance().setUser(result);
- if (loginHandler != null) {
- dialog.hide();
- loginHandler.onLogin();
- }
- }
- @Override
- public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "User name or password is invalid").show();
- }
- });
- }
- }
-
- @Override
- public void onRegister(String login, String password) {
- if (validate(login, password)) {
- Application.getDataService().register(login, password, new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- ApplicationContext.getInstance().setUser(result);
- if (loginHandler != null) {
- dialog.hide();
- loginHandler.onLogin();
- }
- }
- @Override
- public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Username is already taken").show();
- }
- });
- }
- }
-
-}
diff --git a/src/org/traccar/web/client/controller/MapController.java b/src/org/traccar/web/client/controller/MapController.java
deleted file mode 100644
index 13c736f5..00000000
--- a/src/org/traccar/web/client/controller/MapController.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.traccar.web.client.Application;
-import org.traccar.web.client.view.MapView;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.sencha.gxt.widget.core.client.ContentPanel;
-
-public class MapController implements ContentController, MapView.MapHandler {
-
- private static final int UPDATE_INTERVAL = 15000;
-
- public interface MapHandler {
- public void onDeviceSelected(Device device);
- public void onArchivePositionSelected(Position position);
- }
-
- private MapHandler mapHandler;
-
- private MapView mapView;
-
- public MapController(MapHandler mapHandler) {
- this.mapHandler = mapHandler;
- mapView = new MapView(this);
- }
-
- @Override
- public ContentPanel getView() {
- return mapView.getView();
- }
-
- private Timer updateTimer;
-
- @Override
- public void run() {
- updateTimer = new Timer() {
- @Override
- public void run() {
- update();
- }
- };
- update();
- }
-
- private Map<Long, Position> latestPositionMap = new HashMap<Long, Position>();
-
- public void update() {
- updateTimer.cancel();
- Application.getDataService().getLatestPositions(new AsyncCallback<List<Position>>() {
- @Override
- public void onSuccess(List<Position> result) {
- mapView.showLatestPositions(result);
- for (Position position : result) {
- latestPositionMap.put(position.getDevice().getId(), position);
- }
- for (Map.Entry<Long, PositionUpdateHandler> entry : positionUpdateMap.entrySet()) {
- entry.getValue().onUpdate(latestPositionMap.get(entry.getKey()));
- }
- updateTimer.schedule(UPDATE_INTERVAL);
- }
- @Override
- public void onFailure(Throwable caught) {
- updateTimer.schedule(UPDATE_INTERVAL);
- }
- });
- }
-
- public void selectDevice(Device device) {
- mapView.selectDevice(device);
- }
-
- public void showArchivePositions(List<Position> positions) {
- List<Position> sortedPositions = new LinkedList<Position>(positions);
- Collections.sort(sortedPositions, new Comparator<Position>() {
- @Override
- public int compare(Position o1, Position o2) {
- return o1.getTime().compareTo(o2.getTime());
- }
- });
- mapView.showArchivePositions(sortedPositions);
- }
-
- public void selectArchivePosition(Position position) {
- mapView.selectArchivePosition(position);
- }
-
- public interface PositionUpdateHandler {
- public void onUpdate(Position position);
- }
-
- private Map<Long, PositionUpdateHandler> positionUpdateMap = new HashMap<Long, PositionUpdateHandler>();
-
-
- public void registerPositionUpdate(Device device, PositionUpdateHandler handler) {
- positionUpdateMap.put(device.getId(), handler);
- handler.onUpdate(latestPositionMap.get(device.getId()));
- }
-
- public void unregisterPositionUpdate(Device device) {
- positionUpdateMap.remove(device.getId());
- }
-
- @Override
- public void onPositionSelected(Position position) {
- mapHandler.onDeviceSelected(position.getDevice());
- }
-
- @Override
- public void onArchivePositionSelected(Position position) {
- mapHandler.onArchivePositionSelected(position);
- }
-
-}
diff --git a/src/org/traccar/web/client/controller/SettingsController.java b/src/org/traccar/web/client/controller/SettingsController.java
deleted file mode 100644
index bd20288b..00000000
--- a/src/org/traccar/web/client/controller/SettingsController.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import java.util.List;
-
-import org.traccar.web.client.Application;
-import org.traccar.web.client.ApplicationContext;
-import org.traccar.web.client.model.BaseAsyncCallback;
-import org.traccar.web.client.model.UserProperties;
-import org.traccar.web.client.view.ApplicationSettingsDialog;
-import org.traccar.web.client.view.DeviceView;
-import org.traccar.web.client.view.UserDialog;
-import org.traccar.web.client.view.UserSettingsDialog;
-import org.traccar.web.client.view.UsersDialog;
-import org.traccar.web.shared.model.ApplicationSettings;
-import org.traccar.web.shared.model.User;
-import org.traccar.web.shared.model.UserSettings;
-
-import com.google.gwt.core.client.GWT;
-import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
-import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
-import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
-import com.sencha.gxt.widget.core.client.event.DialogHideEvent;
-
-public class SettingsController implements DeviceView.SettingsHandler {
-
- @Override
- public void onAccountSelected() {
- new UserDialog(
- ApplicationContext.getInstance().getUser(),
- new UserDialog.UserHandler() {
- @Override
- public void onSave(User user) {
- Application.getDataService().updateUser(user, new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- ApplicationContext.getInstance().setUser(result);
- }
- });
- }
- }).show();
- }
-
- @Override
- public void onPreferencesSelected() {
- new UserSettingsDialog(
- ApplicationContext.getInstance().getUserSettings(),
- new UserSettingsDialog.UserSettingsHandler() {
- @Override
- public void onSave(UserSettings userSettings) {
- ApplicationContext.getInstance().setUserSettings(userSettings);
- User user = ApplicationContext.getInstance().getUser();
- Application.getDataService().updateUser(user, new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- ApplicationContext.getInstance().setUser(result);
- }
- });
- }
- }).show();
- }
-
- @Override
- public void onUsersSelected() {
- Application.getDataService().getUsers(new BaseAsyncCallback<List<User>>() {
- @Override
- public void onSuccess(List<User> result) {
- UserProperties userProperties = GWT.create(UserProperties.class);
- final ListStore<User> userStore = new ListStore<User>(userProperties.id());
- userStore.addAll(result);
-
- new UsersDialog(userStore, new UsersDialog.UserHandler() {
-
- @Override
- public void onAdd() {
- new UserDialog(
- new User(),
- new UserDialog.UserHandler() {
- @Override
- public void onSave(User user) {
- Application.getDataService().addUser(user, new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- userStore.add(result);
- }
- @Override
- public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Username is already taken").show();
- }
- });
- }
- }).show();
- }
-
- @Override
- public void onRemove(final User user) {
- final ConfirmMessageBox dialog = new ConfirmMessageBox("Confirm", "Are you sure you want remove user?");
- dialog.addDialogHideHandler(new DialogHideEvent.DialogHideHandler() {
- @Override
- public void onDialogHide(DialogHideEvent event) {
- if (event.getHideButton() == PredefinedButton.YES) {
- Application.getDataService().removeUser(user, new BaseAsyncCallback<User>() {
- @Override
- public void onSuccess(User result) {
- userStore.remove(user);
- }
- });
- }
- }
- });
- dialog.show();
- }
-
- }).show();
- }
- });
- }
-
- @Override
- public void onApplicationSelected() {
- new ApplicationSettingsDialog(
- ApplicationContext.getInstance().getApplicationSettings(),
- new ApplicationSettingsDialog.ApplicationSettingsHandler() {
- @Override
- public void onSave(ApplicationSettings applicationSettings) {
- Application.getDataService().updateApplicationSettings(applicationSettings, new BaseAsyncCallback<ApplicationSettings>() {
- @Override
- public void onSuccess(ApplicationSettings result) {
- ApplicationContext.getInstance().setApplicationSettings(result);
- }
- });
- }
- }).show();
- }
-
-}
diff --git a/src/org/traccar/web/client/controller/StateController.java b/src/org/traccar/web/client/controller/StateController.java
deleted file mode 100644
index a19bec81..00000000
--- a/src/org/traccar/web/client/controller/StateController.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.controller;
-
-import org.traccar.web.client.model.StateItem;
-import org.traccar.web.client.model.StateItemProperties;
-import org.traccar.web.client.model.StateReader;
-import org.traccar.web.client.view.StateView;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.core.client.GWT;
-import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.widget.core.client.ContentPanel;
-
-public class StateController implements ContentController {
-
- private ListStore<StateItem> stateStore;
-
- private StateView stateView;
-
- public StateController() {
- StateItemProperties stateItemProperties = GWT.create(StateItemProperties.class);
- stateStore = new ListStore<StateItem>(stateItemProperties.id());
- stateView = new StateView(stateStore);
- }
-
- @Override
- public ContentPanel getView() {
- return stateView.getView();
- }
-
- @Override
- public void run() {
- }
-
- public void showState(Position position) {
- if (position != null) {
- stateStore.replaceAll(StateReader.getState(position));
- } else {
- stateStore.clear();
- }
- }
-
-}
diff --git a/src/org/traccar/web/client/model/ApplicationSettingsProperties.java b/src/org/traccar/web/client/model/ApplicationSettingsProperties.java
deleted file mode 100644
index b30572e5..00000000
--- a/src/org/traccar/web/client/model/ApplicationSettingsProperties.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import org.traccar.web.shared.model.ApplicationSettings;
-
-import com.sencha.gxt.core.client.ValueProvider;
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-import com.sencha.gxt.data.shared.PropertyAccess;
-
-public interface ApplicationSettingsProperties extends PropertyAccess<ApplicationSettings> {
-
- ModelKeyProvider<ApplicationSettings> id();
-
- ValueProvider<ApplicationSettings, Boolean> registrationEnabled();
-
-}
diff --git a/src/org/traccar/web/client/model/BaseAsyncCallback.java b/src/org/traccar/web/client/model/BaseAsyncCallback.java
deleted file mode 100644
index cb0c4792..00000000
--- a/src/org/traccar/web/client/model/BaseAsyncCallback.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
-
-public class BaseAsyncCallback<T> implements AsyncCallback<T> {
-
- @Override
- public void onFailure(Throwable caught) {
- new AlertMessageBox("Error", "Remote procedure call error").show();
- }
-
- @Override
- public void onSuccess(T result) {
- }
-
-}
diff --git a/src/org/traccar/web/client/model/BaseStoreHandlers.java b/src/org/traccar/web/client/model/BaseStoreHandlers.java
deleted file mode 100644
index f34ff3a3..00000000
--- a/src/org/traccar/web/client/model/BaseStoreHandlers.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import com.sencha.gxt.data.shared.event.StoreAddEvent;
-import com.sencha.gxt.data.shared.event.StoreClearEvent;
-import com.sencha.gxt.data.shared.event.StoreDataChangeEvent;
-import com.sencha.gxt.data.shared.event.StoreFilterEvent;
-import com.sencha.gxt.data.shared.event.StoreHandlers;
-import com.sencha.gxt.data.shared.event.StoreRecordChangeEvent;
-import com.sencha.gxt.data.shared.event.StoreRemoveEvent;
-import com.sencha.gxt.data.shared.event.StoreSortEvent;
-import com.sencha.gxt.data.shared.event.StoreUpdateEvent;
-
-public class BaseStoreHandlers<T> implements StoreHandlers<T> {
-
- @Override
- public void onAdd(StoreAddEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onRemove(StoreRemoveEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onFilter(StoreFilterEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onClear(StoreClearEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onUpdate(StoreUpdateEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onDataChange(StoreDataChangeEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onRecordChange(StoreRecordChangeEvent<T> event) {
- onAnything();
- }
-
- @Override
- public void onSort(StoreSortEvent<T> event) {
- onAnything();
- }
-
- public void onAnything() {
- }
-
-}
diff --git a/src/org/traccar/web/client/model/DataService.java b/src/org/traccar/web/client/model/DataService.java
deleted file mode 100644
index a693b6e6..00000000
--- a/src/org/traccar/web/client/model/DataService.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import java.util.Date;
-import java.util.List;
-
-import org.traccar.web.shared.model.ApplicationSettings;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-import org.traccar.web.shared.model.User;
-
-import com.google.gwt.user.client.rpc.RemoteService;
-import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
-
-@RemoteServiceRelativePath("dataService")
-public interface DataService extends RemoteService {
-
- User authenticated() throws IllegalStateException;
-
- User login(String login, String password);
-
- boolean logout();
-
- User register(String login, String password);
-
- List<User> getUsers();
-
- User addUser(User user);
-
- User updateUser(User user);
-
- User removeUser(User user);
-
- List<Device> getDevices();
-
- Device addDevice(Device device);
-
- Device updateDevice(Device device);
-
- Device removeDevice(Device device);
-
- List<Position> getPositions(Device device, Date from, Date to);
-
- List<Position> getLatestPositions();
-
- ApplicationSettings updateApplicationSettings(ApplicationSettings applicationSettings);
-
-}
diff --git a/src/org/traccar/web/client/model/DataServiceAsync.java b/src/org/traccar/web/client/model/DataServiceAsync.java
deleted file mode 100644
index b1830639..00000000
--- a/src/org/traccar/web/client/model/DataServiceAsync.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import java.util.Date;
-import java.util.List;
-
-import org.traccar.web.shared.model.ApplicationSettings;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-import org.traccar.web.shared.model.User;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-public interface DataServiceAsync {
-
- void authenticated(AsyncCallback<User> callback);
-
- void login(String login, String password, AsyncCallback<User> callback);
-
- void logout(AsyncCallback<Boolean> callback);
-
- void register(String login, String password, AsyncCallback<User> callback);
-
- void getUsers(AsyncCallback<List<User>> callback);
-
- void addUser(User user, AsyncCallback<User> callback);
-
- void updateUser(User user, AsyncCallback<User> callback);
-
- void removeUser(User user, AsyncCallback<User> callback);
-
- void getDevices(AsyncCallback<List<Device>> callback);
-
- void addDevice(Device device, AsyncCallback<Device> callback);
-
- void updateDevice(Device device, AsyncCallback<Device> callback);
-
- void removeDevice(Device device, AsyncCallback<Device> callback);
-
- void getLatestPositions(AsyncCallback<List<Position>> callback);
-
- void getPositions(Device device, Date from, Date to, AsyncCallback<List<Position>> callback);
-
- void updateApplicationSettings(ApplicationSettings applicationSettings, AsyncCallback<ApplicationSettings> callback);
-
-}
diff --git a/src/org/traccar/web/client/model/DeviceProperties.java b/src/org/traccar/web/client/model/DeviceProperties.java
deleted file mode 100644
index 35f946a2..00000000
--- a/src/org/traccar/web/client/model/DeviceProperties.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import org.traccar.web.shared.model.Device;
-
-import com.google.gwt.editor.client.Editor.Path;
-import com.sencha.gxt.core.client.ValueProvider;
-import com.sencha.gxt.data.shared.LabelProvider;
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-import com.sencha.gxt.data.shared.PropertyAccess;
-
-public interface DeviceProperties extends PropertyAccess<Device> {
-
- ModelKeyProvider<Device> id();
-
- ValueProvider<Device, String> uniqueId();
-
- ValueProvider<Device, String> name();
-
- @Path("name")
- LabelProvider<Device> label();
-
-}
diff --git a/src/org/traccar/web/client/model/EnumKeyProvider.java b/src/org/traccar/web/client/model/EnumKeyProvider.java
deleted file mode 100644
index c41d420e..00000000
--- a/src/org/traccar/web/client/model/EnumKeyProvider.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.traccar.web.client.model;
-
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-
-
-public class EnumKeyProvider<T extends Enum<T>> implements ModelKeyProvider<T> {
-
- @Override
- public String getKey(T item) {
- return String.valueOf(item.ordinal());
- }
-
-}
diff --git a/src/org/traccar/web/client/model/PositionProperties.java b/src/org/traccar/web/client/model/PositionProperties.java
deleted file mode 100644
index 86ab5327..00000000
--- a/src/org/traccar/web/client/model/PositionProperties.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import java.util.Date;
-
-import org.traccar.web.shared.model.Position;
-
-import com.sencha.gxt.core.client.ValueProvider;
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-import com.sencha.gxt.data.shared.PropertyAccess;
-
-public interface PositionProperties extends PropertyAccess<Position> {
-
- ModelKeyProvider<Position> id();
-
- ValueProvider<Position, Date> time();
-
- ValueProvider<Position, Boolean> valid();
-
- ValueProvider<Position, Double> latitude();
-
- ValueProvider<Position, Double> longitude();
-
- ValueProvider<Position, Double> altitude();
-
- ValueProvider<Position, Double> speed();
-
- ValueProvider<Position, Double> course();
-
- ValueProvider<Position, Double> power();
-
- ValueProvider<Position, String> address();
-
-}
diff --git a/src/org/traccar/web/client/model/StateItem.java b/src/org/traccar/web/client/model/StateItem.java
deleted file mode 100644
index 651d2a24..00000000
--- a/src/org/traccar/web/client/model/StateItem.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.traccar.web.client.model;
-
-
-public class StateItem {
-
- public StateItem(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- private String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-}
diff --git a/src/org/traccar/web/client/model/StateItemProperties.java b/src/org/traccar/web/client/model/StateItemProperties.java
deleted file mode 100644
index e3700a52..00000000
--- a/src/org/traccar/web/client/model/StateItemProperties.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.traccar.web.client.model;
-
-import com.google.gwt.editor.client.Editor.Path;
-import com.sencha.gxt.core.client.ValueProvider;
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-import com.sencha.gxt.data.shared.PropertyAccess;
-
-public interface StateItemProperties extends PropertyAccess<StateItem> {
-
- @Path("name")
- ModelKeyProvider<StateItem> id();
-
- ValueProvider<StateItem, String> name();
-
- ValueProvider<StateItem, String> value();
-
-}
diff --git a/src/org/traccar/web/client/model/StateReader.java b/src/org/traccar/web/client/model/StateReader.java
deleted file mode 100644
index 10ed9809..00000000
--- a/src/org/traccar/web/client/model/StateReader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.traccar.web.client.model;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.traccar.web.client.ApplicationContext;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.xml.client.Node;
-import com.google.gwt.xml.client.NodeList;
-import com.google.gwt.xml.client.XMLParser;
-
-public class StateReader {
-
- private static String toString(Object object) {
- if (object != null) {
- return object.toString();
- }
- return null;
- }
-
- public static List<StateItem> getState(Position position) {
- List<StateItem> state = new LinkedList<StateItem>();
-
- state.add(new StateItem("valid", toString(position.getValid())));
- state.add(new StateItem("time", ApplicationContext.getInstance().getFormatterUtil().getTimeFormat().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", ApplicationContext.getInstance().getFormatterUtil().getSpeedFormat().format(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) {
- try {
- NodeList nodes = XMLParser.parse(other).getFirstChild().getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- state.add(new StateItem(node.getNodeName(), node.getFirstChild().getNodeValue()));
- }
- } catch (Exception error) {
- }
- }
-
- return state;
- }
-
-}
diff --git a/src/org/traccar/web/client/model/UserProperties.java b/src/org/traccar/web/client/model/UserProperties.java
deleted file mode 100644
index cba2996f..00000000
--- a/src/org/traccar/web/client/model/UserProperties.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import org.traccar.web.shared.model.User;
-
-import com.sencha.gxt.core.client.ValueProvider;
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-import com.sencha.gxt.data.shared.PropertyAccess;
-
-public interface UserProperties extends PropertyAccess<User> {
-
- ModelKeyProvider<User> id();
-
- ValueProvider<User, String> login();
-
- ValueProvider<User, String> password();
-
- ValueProvider<User, Boolean> admin();
-
-}
diff --git a/src/org/traccar/web/client/model/UserSettingsProperties.java b/src/org/traccar/web/client/model/UserSettingsProperties.java
deleted file mode 100644
index dad7111d..00000000
--- a/src/org/traccar/web/client/model/UserSettingsProperties.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.model;
-
-import org.traccar.web.shared.model.UserSettings;
-import org.traccar.web.shared.model.UserSettings.SpeedUnit;
-
-import com.sencha.gxt.core.client.ValueProvider;
-import com.sencha.gxt.data.shared.LabelProvider;
-import com.sencha.gxt.data.shared.ModelKeyProvider;
-import com.sencha.gxt.data.shared.PropertyAccess;
-
-public interface UserSettingsProperties extends PropertyAccess<UserSettings> {
-
- ModelKeyProvider<UserSettings> id();
-
- ValueProvider<UserSettings, UserSettings.SpeedUnit> speedUnit();
-
- public static class SpeedUnitLabelProvider implements LabelProvider<UserSettings.SpeedUnit> {
-
- @Override
- public String getLabel(SpeedUnit item) {
- switch (item) {
- case kilometersPerHour:
- return "km/h";
- case knots:
- return "knots";
- case milesPerHour:
- return "mph";
- default:
- return null;
- }
- }
-
- }
-
-}
diff --git a/src/org/traccar/web/client/view/ApplicationSettingsDialog.java b/src/org/traccar/web/client/view/ApplicationSettingsDialog.java
deleted file mode 100644
index 24b9f96d..00000000
--- a/src/org/traccar/web/client/view/ApplicationSettingsDialog.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import org.traccar.web.shared.model.ApplicationSettings;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.editor.client.Editor;
-import com.google.gwt.editor.client.SimpleBeanEditorDriver;
-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.Widget;
-import com.sencha.gxt.widget.core.client.Window;
-import com.sencha.gxt.widget.core.client.event.SelectEvent;
-import com.sencha.gxt.widget.core.client.form.CheckBox;
-
-public class ApplicationSettingsDialog implements Editor<ApplicationSettings> {
-
- private static ApplicationSettingsDialogUiBinder uiBinder = GWT.create(ApplicationSettingsDialogUiBinder.class);
-
- interface ApplicationSettingsDialogUiBinder extends UiBinder<Widget, ApplicationSettingsDialog> {
- }
-
- private ApplicationSettingsDriver driver = GWT.create(ApplicationSettingsDriver.class);
-
- interface ApplicationSettingsDriver extends SimpleBeanEditorDriver<ApplicationSettings, ApplicationSettingsDialog> {
- }
-
- public interface ApplicationSettingsHandler {
- public void onSave(ApplicationSettings applicationSettings);
- }
-
- private ApplicationSettingsHandler applicationSettingsHandler;
-
- @UiField
- Window window;
-
- @UiField
- CheckBox registrationEnabled;
-
- public ApplicationSettingsDialog(ApplicationSettings applicationSettings, ApplicationSettingsHandler applicationSettingsHandler) {
- this.applicationSettingsHandler = applicationSettingsHandler;
- uiBinder.createAndBindUi(this);
- driver.initialize(this);
- driver.edit(applicationSettings);
- }
-
- public void show() {
- window.show();
- }
-
- public void hide() {
- window.hide();
- }
-
- @UiHandler("saveButton")
- public void onLoginClicked(SelectEvent event) {
- window.hide();
- applicationSettingsHandler.onSave(driver.flush());
- }
-
- @UiHandler("cancelButton")
- public void onRegisterClicked(SelectEvent event) {
- window.hide();
- }
-
-}
diff --git a/src/org/traccar/web/client/view/ApplicationSettingsDialog.ui.xml b/src/org/traccar/web/client/view/ApplicationSettingsDialog.ui.xml
deleted file mode 100644
index effdc4ad..00000000
--- a/src/org/traccar/web/client/view/ApplicationSettingsDialog.ui.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
- xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button">
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="verticalLayoutData">
- <ui:attributes width="1" height="-1" />
- </ui:with>
-
- <gxt:Window ui:field="window" pixelSize="300, 110" modal="true" headingText="Global Settings" focusWidget="{saveButton}">
- <container:VerticalLayoutContainer>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Registration">
- <form:widget>
- <form:CheckBox ui:field="registrationEnabled" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- </container:VerticalLayoutContainer>
-
- <gxt:button>
- <button:TextButton ui:field="saveButton" text="Save" />
- </gxt:button>
- <gxt:button>
- <button:TextButton ui:field="cancelButton" text="Cancel" />
- </gxt:button>
- </gxt:Window>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/ApplicationView.java b/src/org/traccar/web/client/view/ApplicationView.java
deleted file mode 100644
index dfa5335d..00000000
--- a/src/org/traccar/web/client/view/ApplicationView.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-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.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Widget;
-import com.sencha.gxt.widget.core.client.ContentPanel;
-
-public class ApplicationView extends Composite {
-
- private static ApplicationViewUiBinder uiBinder = GWT.create(ApplicationViewUiBinder.class);
-
- interface ApplicationViewUiBinder extends UiBinder<Widget, ApplicationView> {
- }
-
- @UiField(provided = true)
- ContentPanel devicePanel;
-
- @UiField(provided = true)
- ContentPanel statePanel;
-
- @UiField(provided = true)
- ContentPanel mapPanel;
-
- @UiField(provided = true)
- ContentPanel archivePanel;
-
- public ApplicationView(ContentPanel deviceView, ContentPanel stateView, ContentPanel mapView, ContentPanel archiveView) {
- devicePanel = deviceView;
- statePanel = stateView;
- mapPanel = mapView;
- archivePanel = archiveView;
- initWidget(uiBinder.createAndBindUi(this));
- }
-
-}
diff --git a/src/org/traccar/web/client/view/ApplicationView.ui.xml b/src/org/traccar/web/client/view/ApplicationView.ui.xml
deleted file mode 100644
index 0b05ab9b..00000000
--- a/src/org/traccar/web/client/view/ApplicationView.ui.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client">
-
- <ui:with type="com.sencha.gxt.core.client.util.Margins" field="topMargins">
- <ui:attributes top="5" right="0" bottom="0" left="0" />
- </ui:with>
- <ui:with type="com.sencha.gxt.core.client.util.Margins" field="westMargins">
- <ui:attributes top="5" right="5" bottom="0" left="5" />
- </ui:with>
- <ui:with type="com.sencha.gxt.core.client.util.Margins" field="centerMargins">
- <ui:attributes top="5" right="5" bottom="0" left="0" />
- </ui:with>
- <ui:with type="com.sencha.gxt.core.client.util.Margins" field="southMargins">
- <ui:attributes top="5" right="5" bottom="5" left="5" />
- </ui:with>
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData" field="westData">
- <ui:attributes size="0.15" maxSize="2147483647" margins="{westMargins}" split="true" />
- </ui:with>
- <ui:with type="com.sencha.gxt.widget.core.client.container.MarginData" field="centerData">
- <ui:attributes margins="{centerMargins}" />
- </ui:with>
- <ui:with type="com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData" field="southData">
- <ui:attributes size="0.25" maxSize="2147483647" margins="{southMargins}" split="true" />
- </ui:with>
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData" field="bottomData">
- <ui:attributes size="0.5" maxSize="2147483647" margins="{topMargins}" split="true" />
- </ui:with>
-
- <container:Viewport>
- <container:BorderLayoutContainer>
- <container:west layoutData="{westData}">
- <container:BorderLayoutContainer>
- <container:center>
- <gxt:ContentPanel ui:field="devicePanel" />
- </container:center>
- <container:south layoutData="{bottomData}">
- <gxt:ContentPanel ui:field="statePanel" />
- </container:south>
- </container:BorderLayoutContainer>
- </container:west>
- <container:center layoutData="{centerData}">
- <gxt:ContentPanel ui:field="mapPanel" />
- </container:center>
- <container:south layoutData="{southData}">
- <gxt:ContentPanel ui:field="archivePanel" />
- </container:south>
- </container:BorderLayoutContainer>
- </container:Viewport>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/ArchiveView.java b/src/org/traccar/web/client/view/ArchiveView.java
deleted file mode 100644
index 9cc579f8..00000000
--- a/src/org/traccar/web/client/view/ArchiveView.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.traccar.web.client.ApplicationContext;
-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;
-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.Widget;
-import com.sencha.gxt.cell.core.client.NumberCell;
-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;
-import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
-
-public class ArchiveView implements SelectionChangedEvent.SelectionChangedHandler<Position> {
-
- private static ArchiveViewUiBinder uiBinder = GWT.create(ArchiveViewUiBinder.class);
-
- interface ArchiveViewUiBinder extends UiBinder<Widget, ArchiveView> {
- }
-
- public interface ArchiveHandler {
- public void onSelected(Position position);
- public void onLoad(Device device, Date from, Date to);
- public void onClear();
- }
-
- private ArchiveHandler archiveHandler;
-
- @UiField
- ContentPanel contentPanel;
-
- public ContentPanel getView() {
- 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> positionStore;
-
- @UiField
- Grid<Position> grid;
-
- 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);
-
- List<ColumnConfig<Position, ?>> columnConfigList = new LinkedList<ColumnConfig<Position, ?>>();
-
- columnConfigList.add(new ColumnConfig<Position, Boolean>(positionProperties.valid(), 0, "Valid"));
-
- ColumnConfig<Position, Date> columnConfigDate = new ColumnConfig<Position, Date>(positionProperties.time(), 0, "Time");
- columnConfigDate.setCell(new DateCell(ApplicationContext.getInstance().getFormatterUtil().getTimeFormat()));
- columnConfigList.add(columnConfigDate);
-
- columnConfigList.add(new ColumnConfig<Position, Double>(positionProperties.latitude(), 0, "Latitude"));
- columnConfigList.add(new ColumnConfig<Position, Double>(positionProperties.longitude(), 0, "Longitude"));
- columnConfigList.add(new ColumnConfig<Position, Double>(positionProperties.altitude(), 0, "Altitude"));
-
- ColumnConfig<Position, Double> columnConfigDouble = new ColumnConfig<Position, Double>(positionProperties.speed(), 0, "Speed");
- columnConfigDouble.setCell(new NumberCell<Double>(ApplicationContext.getInstance().getFormatterUtil().getSpeedFormat()));
- columnConfigList.add(columnConfigDouble);
-
- columnConfigList.add(new ColumnConfig<Position, Double>(positionProperties.course(), 0, "Course"));
- columnConfigList.add(new ColumnConfig<Position, Double>(positionProperties.power(), 0, "Power"));
-
- columnModel = new ColumnModel<Position>(columnConfigList);
-
- uiBinder.createAndBindUi(this);
-
- grid.getSelectionModel().addSelectionChangedHandler(this);
- grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
-
- // Initialize with current time
- long min = 60 * 1000;
- Date now = new Date();
- Date to = new Date(((now.getTime() + 15 * min) / (15 * min)) * 15 * min);
- Date from = new Date(to.getTime() - 60 * min);
- fromDate.setValue(from);
- fromTime.setValue(from);
- toDate.setValue(to);
- toTime.setValue(to);
- }
-
- @Override
- public void onSelectionChanged(SelectionChangedEvent<Position> event) {
- if (event.getSelection().isEmpty()) {
- archiveHandler.onSelected(null);
- } else {
- archiveHandler.onSelected(event.getSelection().get(0));
- }
- }
-
- @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() {
- Device oldDevice = deviceCombo.getValue();
- if (oldDevice != null) {
- deviceCombo.setValue(deviceStore.findModel(oldDevice));
- }
- }
-
- };
-
- public void selectPosition(Position position) {
- grid.getSelectionModel().select(positionStore.findModel(position), false);
- }
-
-}
diff --git a/src/org/traccar/web/client/view/ArchiveView.ui.xml b/src/org/traccar/web/client/view/ArchiveView.ui.xml
deleted file mode 100644
index f27d38ff..00000000
--- a/src/org/traccar/web/client/view/ArchiveView.ui.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- 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:form="urn:import:com.sencha.gxt.widget.core.client.form">
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="toolBarRowData">
- <ui:attributes width="1" height="-1" />
- </ui:with>
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="layoutData">
- <ui:attributes width="1" height="1" />
- </ui:with>
-
- <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">
- <ui:attributes stripeRows="true" autoFill="true" />
- </ui:with>
-
- <gxt:ContentPanel ui:field="contentPanel" headingText="Archive">
- <container:VerticalLayoutContainer>
-
- <container:child layoutData="{toolBarRowData}">
- <toolbar:ToolBar>
-
- <toolbar:LabelToolItem label="Device:" />
- <form:ComboBox ui:field="deviceCombo" editable="false" triggerAction="ALL" />
- <toolbar:SeparatorToolItem />
-
- <toolbar:LabelToolItem label="From:" />
- <form:DateField width="125" ui:field="fromDate" />
- <toolbar:LabelToolItem width="5" />
- <form:TimeField width="75" ui:field="fromTime" triggerAction="ALL" />
- <toolbar:SeparatorToolItem />
-
- <toolbar:LabelToolItem label="To:" />
- <form:DateField width="125" ui:field="toDate" />
- <toolbar:LabelToolItem width="5" />
- <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="{positionStore}" cm="{columnModel}" view="{view}" />
- </container:child>
-
- </container:VerticalLayoutContainer>
- </gxt:ContentPanel>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/DeviceDialog.java b/src/org/traccar/web/client/view/DeviceDialog.java
deleted file mode 100644
index 9e94e963..00000000
--- a/src/org/traccar/web/client/view/DeviceDialog.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import org.traccar.web.shared.model.Device;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.editor.client.Editor;
-import com.google.gwt.editor.client.SimpleBeanEditorDriver;
-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.Widget;
-import com.sencha.gxt.widget.core.client.Window;
-import com.sencha.gxt.widget.core.client.event.SelectEvent;
-import com.sencha.gxt.widget.core.client.form.TextField;
-
-public class DeviceDialog implements Editor<Device> {
-
- private static DeviceDialogUiBinder uiBinder = GWT.create(DeviceDialogUiBinder.class);
-
- interface DeviceDialogUiBinder extends UiBinder<Widget, DeviceDialog> {
- }
-
- private DeviceDriver driver = GWT.create(DeviceDriver.class);
-
- interface DeviceDriver extends SimpleBeanEditorDriver<Device, DeviceDialog> {
- }
-
- public interface DeviceHandler {
- public void onSave(Device device);
- }
-
- private DeviceHandler deviceHandler;
-
- @UiField
- Window window;
-
- @UiField
- TextField name;
-
- @UiField
- TextField uniqueId;
-
- public DeviceDialog(Device device, DeviceHandler deviceHandler) {
- this.deviceHandler = deviceHandler;
- uiBinder.createAndBindUi(this);
- driver.initialize(this);
- driver.edit(device);
- }
-
- public void show() {
- window.show();
- }
-
- public void hide() {
- window.hide();
- }
-
- @UiHandler("saveButton")
- public void onLoginClicked(SelectEvent event) {
- window.hide();
- deviceHandler.onSave(driver.flush());
- }
-
- @UiHandler("cancelButton")
- public void onRegisterClicked(SelectEvent event) {
- window.hide();
- }
-
-}
diff --git a/src/org/traccar/web/client/view/DeviceDialog.ui.xml b/src/org/traccar/web/client/view/DeviceDialog.ui.xml
deleted file mode 100644
index 4f7ccc56..00000000
--- a/src/org/traccar/web/client/view/DeviceDialog.ui.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
- xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button">
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="verticalLayoutData">
- <ui:attributes width="1" height="-1" />
- </ui:with>
-
- <gxt:Window ui:field="window" pixelSize="300, 130" modal="true" headingText="Device" focusWidget="{saveButton}">
- <container:VerticalLayoutContainer>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Name">
- <form:widget>
- <form:TextField ui:field="name" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Unique Identifier">
- <form:widget>
- <form:TextField ui:field="uniqueId" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- </container:VerticalLayoutContainer>
-
- <gxt:button>
- <button:TextButton ui:field="saveButton" text="Save" />
- </gxt:button>
- <gxt:button>
- <button:TextButton ui:field="cancelButton" text="Cancel" />
- </gxt:button>
- </gxt:Window>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/DeviceView.java b/src/org/traccar/web/client/view/DeviceView.java
deleted file mode 100644
index 21d906c8..00000000
--- a/src/org/traccar/web/client/view/DeviceView.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.traccar.web.client.Application;
-import org.traccar.web.client.ApplicationContext;
-import org.traccar.web.client.model.BaseAsyncCallback;
-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;
-import com.google.gwt.user.client.Window;
-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.widget.core.client.ContentPanel;
-import com.sencha.gxt.widget.core.client.button.TextButton;
-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.menu.MenuItem;
-import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
-
-public class DeviceView implements SelectionChangedEvent.SelectionChangedHandler<Device> {
-
- private static DeviceViewUiBinder uiBinder = GWT.create(DeviceViewUiBinder.class);
-
- interface DeviceViewUiBinder extends UiBinder<Widget, DeviceView> {
- }
-
- public interface DeviceHandler {
- public void onSelected(Device device);
- public void onAdd();
- public void onEdit(Device device);
- public void onRemove(Device device);
- }
-
- private DeviceHandler deviceHandler;
-
- @UiField
- ContentPanel contentPanel;
-
- public ContentPanel getView() {
- return contentPanel;
- }
-
- @UiField
- TextButton addButton;
-
- @UiField
- TextButton editButton;
-
- @UiField
- TextButton removeButton;
-
- @UiField(provided = true)
- ColumnModel<Device> columnModel;
-
- @UiField(provided = true)
- ListStore<Device> deviceStore;
-
- @UiField
- Grid<Device> grid;
-
- @UiField
- MenuItem settingsUsers;
-
- @UiField
- MenuItem settingsGlobal;
-
- public DeviceView(DeviceHandler deviceHandler, SettingsHandler settingsHandler, ListStore<Device> deviceStore) {
- this.deviceHandler = deviceHandler;
- this.settingsHandler = settingsHandler;
- this.deviceStore = deviceStore;
-
- DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
-
- List<ColumnConfig<Device, ?>> columnConfigList = new LinkedList<ColumnConfig<Device, ?>>();
- columnConfigList.add(new ColumnConfig<Device, String>(deviceProperties.name(), 0, "Name"));
- columnConfigList.add(new ColumnConfig<Device, String>(deviceProperties.uniqueId(), 0, "Unique Identifier"));
- columnModel = new ColumnModel<Device>(columnConfigList);
-
- uiBinder.createAndBindUi(this);
-
- grid.getSelectionModel().addSelectionChangedHandler(this);
- grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
-
- if (ApplicationContext.getInstance().getUser().getAdmin()) {
- settingsUsers.enable();
- settingsGlobal.enable();
- }
- }
-
- @Override
- public void onSelectionChanged(SelectionChangedEvent<Device> event) {
- editButton.setEnabled(!event.getSelection().isEmpty());
- removeButton.setEnabled(!event.getSelection().isEmpty());
-
- if (event.getSelection().isEmpty()) {
- deviceHandler.onSelected(null);
- } else {
- deviceHandler.onSelected(event.getSelection().get(0));
- }
- }
-
- @UiHandler("addButton")
- public void onAddClicked(SelectEvent event) {
- deviceHandler.onAdd();
- }
-
- @UiHandler("editButton")
- public void onEditClicked(SelectEvent event) {
- deviceHandler.onEdit(grid.getSelectionModel().getSelectedItem());
- }
-
- @UiHandler("removeButton")
- public void onRemoveClicked(SelectEvent event) {
- deviceHandler.onRemove(grid.getSelectionModel().getSelectedItem());
- }
-
- @UiHandler("logoutButton")
- public void onLogoutClicked(SelectEvent event) {
- Application.getDataService().logout(new BaseAsyncCallback<Boolean>() {
- @Override
- public void onSuccess(Boolean result) {
- Window.Location.reload();
- }
- });
- }
-
- public void selectDevice(Device device) {
- grid.getSelectionModel().select(deviceStore.findModel(device), false);
- }
-
- public interface SettingsHandler {
- public void onAccountSelected();
- public void onPreferencesSelected();
- public void onUsersSelected();
- public void onApplicationSelected();
- }
-
- private SettingsHandler settingsHandler;
-
- @UiHandler("settingsAccount")
- public void onSettingsAccountSelected(SelectionEvent<Item> event) {
- settingsHandler.onAccountSelected();
- }
-
- @UiHandler("settingsPreferences")
- public void onSettingsPreferencesSelected(SelectionEvent<Item> event) {
- settingsHandler.onPreferencesSelected();
- }
-
- @UiHandler("settingsUsers")
- public void onSettingsUsersSelected(SelectionEvent<Item> event) {
- settingsHandler.onUsersSelected();
- }
-
- @UiHandler("settingsGlobal")
- public void onSettingsGlobalSelected(SelectionEvent<Item> event) {
- settingsHandler.onApplicationSelected();
- }
-
-}
diff --git a/src/org/traccar/web/client/view/DeviceView.ui.xml b/src/org/traccar/web/client/view/DeviceView.ui.xml
deleted file mode 100644
index 38721ca0..00000000
--- a/src/org/traccar/web/client/view/DeviceView.ui.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- 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: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" />
- </ui:with>
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="layoutData">
- <ui:attributes width="1" height="1" />
- </ui:with>
-
- <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">
- <ui:attributes stripeRows="true" autoFill="true" />
- </ui:with>
-
- <gxt:ContentPanel ui:field="contentPanel" headingText="Devices">
- <container:VerticalLayoutContainer>
-
- <container:child layoutData="{toolBarRowData}">
- <toolbar:ToolBar>
- <button:TextButton ui:field="addButton" text="Add" />
- <button:TextButton ui:field="editButton" text="Edit" enabled="false" />
- <button:TextButton ui:field="removeButton" text="Remove" enabled="false" />
- <toolbar:FillToolItem />
- <toolbar:SeparatorToolItem />
- <button:TextButton ui:field="settingsButton" text="Settings">
- <button:menu>
- <menu:Menu>
- <menu:MenuItem text="Account" ui:field="settingsAccount" />
- <menu:MenuItem text="Preferences" ui:field="settingsPreferences" />
- <menu:MenuItem text="Users" ui:field="settingsUsers" enabled="false" />
- <menu:MenuItem text="Global" ui:field="settingsGlobal" enabled="false" />
- </menu:Menu>
- </button:menu>
- </button:TextButton>
- <button:TextButton ui:field="logoutButton" text="Logout" />
- </toolbar:ToolBar>
- </container:child>
-
- <container:child layoutData="{layoutData}">
- <grid:Grid ui:field="grid" store="{deviceStore}" cm="{columnModel}" view="{view}" />
- </container:child>
-
- </container:VerticalLayoutContainer>
- </gxt:ContentPanel>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/LoginDialog.java b/src/org/traccar/web/client/view/LoginDialog.java
deleted file mode 100644
index 59b46239..00000000
--- a/src/org/traccar/web/client/view/LoginDialog.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import org.traccar.web.client.ApplicationContext;
-
-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.Widget;
-import com.sencha.gxt.widget.core.client.Window;
-import com.sencha.gxt.widget.core.client.button.TextButton;
-import com.sencha.gxt.widget.core.client.event.SelectEvent;
-import com.sencha.gxt.widget.core.client.form.PasswordField;
-import com.sencha.gxt.widget.core.client.form.TextField;
-
-public class LoginDialog {
-
- private static LoginDialogUiBinder uiBinder = GWT.create(LoginDialogUiBinder.class);
-
- interface LoginDialogUiBinder extends UiBinder<Widget, LoginDialog> {
- }
-
- public interface LoginHandler {
- public void onLogin(String login, String password);
- public void onRegister(String login, String password);
- }
-
- private LoginHandler loginHandler;
-
- @UiField
- Window window;
-
- @UiField
- TextField login;
-
- @UiField
- PasswordField password;
-
- @UiField
- TextButton registerButton;
-
- public LoginDialog(LoginHandler loginHandler) {
- this.loginHandler = loginHandler;
- uiBinder.createAndBindUi(this);
-
- if (ApplicationContext.getInstance().getApplicationSettings().getRegistrationEnabled()) {
- registerButton.enable();
- }
- }
-
- public void show() {
- window.show();
- }
-
- public void hide() {
- window.hide();
- }
-
- @UiHandler("loginButton")
- public void onLoginClicked(SelectEvent event) {
- loginHandler.onLogin(login.getText(), password.getText());
- }
-
- @UiHandler("registerButton")
- public void onRegisterClicked(SelectEvent event) {
- loginHandler.onRegister(login.getText(), password.getText());
- }
-
-}
diff --git a/src/org/traccar/web/client/view/LoginDialog.ui.xml b/src/org/traccar/web/client/view/LoginDialog.ui.xml
deleted file mode 100644
index c9314430..00000000
--- a/src/org/traccar/web/client/view/LoginDialog.ui.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
- xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button">
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="verticalLayoutData">
- <ui:attributes width="1" height="-1" />
- </ui:with>
-
- <gxt:Window ui:field="window" pixelSize="300, 130" modal="true" closable="false" headingText="Authentication" focusWidget="{loginButton}">
- <container:VerticalLayoutContainer>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="User">
- <form:widget>
- <form:TextField ui:field="login" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Password">
- <form:widget>
- <form:PasswordField ui:field="password" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- </container:VerticalLayoutContainer>
-
- <gxt:button>
- <button:TextButton ui:field="loginButton" text="Login" />
- </gxt:button>
- <gxt:button>
- <button:TextButton ui:field="registerButton" text="Register" enabled="false" />
- </gxt:button>
- </gxt:Window>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/MapPositionRenderer.java b/src/org/traccar/web/client/view/MapPositionRenderer.java
deleted file mode 100644
index 15ba082e..00000000
--- a/src/org/traccar/web/client/view/MapPositionRenderer.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.gwtopenmaps.openlayers.client.Icon;
-import org.gwtopenmaps.openlayers.client.Marker;
-import org.gwtopenmaps.openlayers.client.event.EventHandler;
-import org.gwtopenmaps.openlayers.client.event.EventObject;
-import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
-import org.gwtopenmaps.openlayers.client.geometry.LineString;
-import org.gwtopenmaps.openlayers.client.geometry.Point;
-import org.gwtopenmaps.openlayers.client.layer.Markers;
-import org.gwtopenmaps.openlayers.client.layer.Vector;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.dom.client.Style;
-import com.google.gwt.user.client.ui.RootPanel;
-
-
-public class MapPositionRenderer {
-
- public interface SelectHandler {
- public void onSelected(Position position);
- }
-
- private final MapView mapView;
- private final MarkerIconFactory.IconType iconType;
-
- protected Vector getVectorLayer() {
- return mapView.getVectorLayer();
- }
-
- protected Markers getMarkerLayer() {
- return mapView.getMarkerLayer();
- }
-
- private SelectHandler selectHandler;
-
- public MapPositionRenderer(MapView mapView, MarkerIconFactory.IconType iconType, SelectHandler selectHandler) {
- this.mapView = mapView;
- this.iconType = iconType;
- this.selectHandler = selectHandler;
- }
-
- private void addSelectEvent(Marker marker, final Position position) {
- if (selectHandler != null) {
- marker.getEvents().register("click", marker, new EventHandler() {
- @Override
- public void onHandle(EventObject eventObject) {
- selectHandler.onSelected(position);
- }
- });
- marker.getEvents().register("mouseover", marker, new EventHandler() {
- @Override
- public void onHandle(EventObject eventObject) {
- RootPanel.get().getElement().getStyle().setCursor(Style.Cursor.SE_RESIZE);
- }
- });
- marker.getEvents().register("mouseout", marker, new EventHandler() {
- @Override
- public void onHandle(EventObject eventObject) {
- RootPanel.get().getElement().getStyle().setCursor(Style.Cursor.AUTO);
- }
- });
- }
- }
-
- private void changeMarkerIcon(Long positionId, Icon icon) {
- Marker oldMarker = markerMap.get(positionId);
- Marker newMarker = new Marker(oldMarker.getLonLat(), icon);
- addSelectEvent(newMarker, positionMap.get(positionId));
- markerMap.put(positionId, newMarker);
- getMarkerLayer().addMarker(newMarker);
- getMarkerLayer().removeMarker(oldMarker);
- }
-
- private Map<Long, Marker> markerMap = new HashMap<Long, Marker>(); // Position.id -> Marker
- private Map<Long, Long> deviceMap = new HashMap<Long, Long>(); // Device.id -> Position.id
- private Map<Long, Position> positionMap = new HashMap<Long, Position>(); // Position.id -> Position
-
- private Long selectedPositionId;
- private Long selectedDeviceId;
-
- public void showPositions(List<Position> positions) {
- for (Marker marker : markerMap.values()) {
- getMarkerLayer().removeMarker(marker);
- }
- markerMap.clear();
- deviceMap.clear();
- positionMap.clear();
-
- for (Position position : positions) {
- Marker marker = new Marker(
- mapView.createLonLat(position.getLongitude(), position.getLatitude()),
- MarkerIconFactory.getIcon(iconType, false));
- markerMap.put(position.getId(), marker);
- deviceMap.put(position.getDevice().getId(), position.getId());
- positionMap.put(position.getId(), position);
- addSelectEvent(marker, position);
- getMarkerLayer().addMarker(marker);
- }
-
- if (selectedPositionId != null) {
- if (!selectPosition(null, selectedPositionId, false)) {
- selectedPositionId = null;
- }
- }
-
- if (selectedDeviceId != null) {
- if (!selectPosition(null, deviceMap.get(selectedDeviceId), false)) {
- selectedDeviceId = null;
- }
- }
- }
-
- public void showTrack(List<Position> positions) {
- getVectorLayer().destroyFeatures();
-
- if (!positions.isEmpty()) {
- Point[] linePoints = new Point[positions.size()];
-
- int i = 0;
- for (Position position : positions) {
- linePoints[i++] = mapView.createPoint(position.getLongitude(), position.getLatitude());
- }
-
- LineString lineString = new LineString(linePoints);
- getVectorLayer().addFeature(new VectorFeature(lineString));
- //mapView.getMap().zoomToExtent(lineString.getBounds());
- }
- }
-
- public void selectPosition(Position position, boolean center) {
- Long oldPositionId = selectedPositionId;
- Long newPositionId = (position != null) ? position.getId() : null;
- if (selectPosition(oldPositionId, newPositionId, center)) {
- selectedPositionId = position.getId();
- } else {
- selectedPositionId = null;
- }
- }
-
- public void selectDevice(Device device, boolean center) {
- Long oldPositionId = (selectedDeviceId != null) ? deviceMap.get(selectedDeviceId) : null;
- Long newPositionId = (device != null) ? deviceMap.get(device.getId()) : null;
- if (selectPosition(oldPositionId, newPositionId, center)) {
- selectedDeviceId = device.getId();
- } else {
- selectedDeviceId = null;
- }
- }
-
- private boolean selectPosition(Long oldPositionId, Long newPositionId, boolean center) {
- if (oldPositionId != null && markerMap.containsKey(oldPositionId)) {
- changeMarkerIcon(oldPositionId, MarkerIconFactory.getIcon(iconType, false));
- }
- if (newPositionId != null && markerMap.containsKey(newPositionId)) {
- changeMarkerIcon(newPositionId, MarkerIconFactory.getIcon(iconType, true));
- if (center) {
- mapView.getMap().panTo(markerMap.get(newPositionId).getLonLat());
- }
- return true;
- }
- return false;
- }
-
-}
diff --git a/src/org/traccar/web/client/view/MapView.java b/src/org/traccar/web/client/view/MapView.java
deleted file mode 100644
index db51cd36..00000000
--- a/src/org/traccar/web/client/view/MapView.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import java.util.List;
-
-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.Style;
-import org.gwtopenmaps.openlayers.client.control.LayerSwitcher;
-import org.gwtopenmaps.openlayers.client.control.ScaleLine;
-import org.gwtopenmaps.openlayers.client.geometry.Point;
-import org.gwtopenmaps.openlayers.client.layer.Bing;
-import org.gwtopenmaps.openlayers.client.layer.BingOptions;
-import org.gwtopenmaps.openlayers.client.layer.BingType;
-import org.gwtopenmaps.openlayers.client.layer.GoogleV3;
-import org.gwtopenmaps.openlayers.client.layer.GoogleV3MapType;
-import org.gwtopenmaps.openlayers.client.layer.GoogleV3Options;
-import org.gwtopenmaps.openlayers.client.layer.Markers;
-import org.gwtopenmaps.openlayers.client.layer.MarkersOptions;
-import org.gwtopenmaps.openlayers.client.layer.OSM;
-import org.gwtopenmaps.openlayers.client.layer.Vector;
-import org.gwtopenmaps.openlayers.client.layer.VectorOptions;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.logical.shared.ResizeEvent;
-import com.google.gwt.event.logical.shared.ResizeHandler;
-import com.google.gwt.user.client.Command;
-import com.sencha.gxt.widget.core.client.ContentPanel;
-
-public class MapView {
-
- public interface MapHandler {
- public void onPositionSelected(Position position);
- public void onArchivePositionSelected(Position position);
- }
-
- private MapHandler mapHandler;
-
- private ContentPanel contentPanel;
-
- public ContentPanel getView() {
- return contentPanel;
- }
-
- private MapWidget mapWidget;
- private Map map;
- private Vector vectorLayer;
- private Markers markerLayer;
-
- public Map getMap() {
- return map;
- }
-
- public Vector getVectorLayer() {
- return vectorLayer;
- }
-
- public Markers getMarkerLayer() {
- return markerLayer;
- }
-
- public LonLat createLonLat(double longitude, double latitude) {
- LonLat lonLat = new LonLat(longitude, latitude);
- lonLat.transform(new Projection("EPSG:4326").getProjectionCode(), map.getProjection());
- return lonLat;
- }
-
- public Point createPoint(double x, double y) {
- Point point = new Point(x, y);
- point.transform(new Projection("EPSG:4326"), new Projection(map.getProjection()));
- return point;
- }
-
- private void initMapLayers(Map map) {
- map.addLayer(OSM.Mapnik("OpenStreetMap"));
-
- GoogleV3Options gHybridOptions = new GoogleV3Options();
- gHybridOptions.setNumZoomLevels(20);
- gHybridOptions.setType(GoogleV3MapType.G_HYBRID_MAP);
- map.addLayer(new GoogleV3("Google Hybrid", gHybridOptions));
-
- GoogleV3Options gNormalOptions = new GoogleV3Options();
- gNormalOptions.setNumZoomLevels(22);
- gNormalOptions.setType(GoogleV3MapType.G_NORMAL_MAP);
- map.addLayer(new GoogleV3("Google Normal", gNormalOptions));
-
- GoogleV3Options gSatelliteOptions = new GoogleV3Options();
- gSatelliteOptions.setNumZoomLevels(20);
- gSatelliteOptions.setType(GoogleV3MapType.G_SATELLITE_MAP);
- map.addLayer(new GoogleV3("Google Satellite", gSatelliteOptions));
-
- GoogleV3Options gTerrainOptions = new GoogleV3Options();
- gTerrainOptions.setNumZoomLevels(16);
- gTerrainOptions.setType(GoogleV3MapType.G_TERRAIN_MAP);
- map.addLayer(new GoogleV3("Google Terrain", gTerrainOptions));
-
- final String bingKey = "AseEs0DLJhLlTNoxbNXu7DGsnnH4UoWuGue7-irwKkE3fffaClwc9q_Mr6AyHY8F";
- map.addLayer(new Bing(new BingOptions("Bing Road", bingKey, BingType.ROAD)));
- map.addLayer(new Bing(new BingOptions("Bing Hybrid", bingKey, BingType.HYBRID)));
- map.addLayer(new Bing(new BingOptions("Bing Aerial", bingKey, BingType.AERIAL)));
- }
-
- public MapView(MapHandler mapHandler) {
- this.mapHandler = mapHandler;
- contentPanel = new ContentPanel();
- contentPanel.setHeadingText("Map");
-
- MapOptions defaultMapOptions = new MapOptions();
-
- mapWidget = new MapWidget("100%", "100%", defaultMapOptions);
- map = mapWidget.getMap();
-
- Style style = new Style();
- style.setStrokeColor("blue");
- style.setStrokeWidth(3);
- style.setFillOpacity(1);
-
- VectorOptions vectorOptions = new VectorOptions();
- vectorOptions.setStyle(style);
- vectorLayer = new Vector("Vector", vectorOptions);
-
- MarkersOptions markersOptions = new MarkersOptions();
- markerLayer = new Markers("Markers", markersOptions);
-
- initMapLayers(map);
-
- map.addLayer(vectorLayer);
- map.addLayer(markerLayer);
-
- map.addControl(new LayerSwitcher());
- map.addControl(new ScaleLine());
- map.setCenter(createLonLat(12.5, 41.9), 1);
-
- contentPanel.add(mapWidget);
-
- // Update map size
- contentPanel.addResizeHandler(new ResizeHandler() {
- @Override
- public void onResize(ResizeEvent event) {
- Scheduler.get().scheduleDeferred(new Command() {
- @Override
- public void execute() {
- map.updateSize();
- }
- });
- }
- });
-
- latestPositionRenderer = new MapPositionRenderer(this, MarkerIconFactory.IconType.iconLatest, latestPositionSelectHandler);
- archivePositionRenderer = new MapPositionRenderer(this, MarkerIconFactory.IconType.iconArchive, archivePositionSelectHandler);
- }
-
- private final MapPositionRenderer latestPositionRenderer;
-
- private final MapPositionRenderer archivePositionRenderer;
-
- public void showLatestPositions(List<Position> positions) {
- latestPositionRenderer.showPositions(positions);
- }
-
- public void showArchivePositions(List<Position> positions) {
- archivePositionRenderer.showTrack(positions);
- archivePositionRenderer.showPositions(positions);
- }
-
- public void selectDevice(Device device) {
- latestPositionRenderer.selectDevice(device, true);
- }
-
- public void selectArchivePosition(Position position) {
- archivePositionRenderer.selectPosition(position, true);
- }
-
- private MapPositionRenderer.SelectHandler latestPositionSelectHandler = new MapPositionRenderer.SelectHandler() {
-
- @Override
- public void onSelected(Position position) {
- mapHandler.onPositionSelected(position);
- }
-
- };
-
- private MapPositionRenderer.SelectHandler archivePositionSelectHandler = new MapPositionRenderer.SelectHandler() {
-
- @Override
- public void onSelected(Position position) {
- mapHandler.onArchivePositionSelected(position);
- }
-
- };
-
-}
diff --git a/src/org/traccar/web/client/view/MarkerIconFactory.java b/src/org/traccar/web/client/view/MarkerIconFactory.java
deleted file mode 100644
index 46965d57..00000000
--- a/src/org/traccar/web/client/view/MarkerIconFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import org.gwtopenmaps.openlayers.client.Icon;
-import org.gwtopenmaps.openlayers.client.Pixel;
-import org.gwtopenmaps.openlayers.client.Size;
-
-class MarkerIconFactory {
-
- private static final Size iconSize = new Size(21, 25);
- private static final Pixel iconOffset = new Pixel(-10.5f, -25.0f);
-
- private static final String iconUrl = "http://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/img/";
- private static final String iconRed = iconUrl + "marker.png";
- private static final String iconBlue = iconUrl + "marker-blue.png";
- private static final String iconGreen = iconUrl + "marker-green.png";
- private static final String iconGold = iconUrl + "marker-gold.png";
-
- public static enum IconType {
- iconLatest,
- iconArchive
- };
-
- public static String getIconUrl(IconType type, boolean selected) {
- if (type == IconType.iconLatest) {
- return selected ? iconGreen : iconRed;
- } else if (type == IconType.iconArchive) {
- return selected ? iconGold : iconBlue;
- }
- return null;
- }
-
- public static Icon getIcon(IconType type, boolean selected) {
- return new Icon(getIconUrl(type, selected), iconSize, iconOffset);
- }
-
-}
diff --git a/src/org/traccar/web/client/view/StateView.java b/src/org/traccar/web/client/view/StateView.java
deleted file mode 100644
index 700d55a6..00000000
--- a/src/org/traccar/web/client/view/StateView.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.traccar.web.client.view;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.traccar.web.client.model.StateItem;
-import org.traccar.web.client.model.StateItemProperties;
-
-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.user.client.ui.Widget;
-import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.widget.core.client.ContentPanel;
-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 StateView {
-
- private static StateViewUiBinder uiBinder = GWT.create(StateViewUiBinder.class);
-
- interface StateViewUiBinder extends UiBinder<Widget, StateView> {
- }
-
- @UiField
- ContentPanel contentPanel;
-
- public ContentPanel getView() {
- return contentPanel;
- }
-
- @UiField(provided = true)
- ColumnModel<StateItem> columnModel;
-
- @UiField(provided = true)
- ListStore<StateItem> stateStore;
-
- @UiField
- Grid<StateItem> grid;
-
- public StateView(ListStore<StateItem> stateStore) {
- this.stateStore = stateStore;
-
- StateItemProperties stateItemProperties = GWT.create(StateItemProperties.class);
-
- List<ColumnConfig<StateItem, ?>> columnConfigList = new LinkedList<ColumnConfig<StateItem, ?>>();
- columnConfigList.add(new ColumnConfig<StateItem, String>(stateItemProperties.name(), 0, "Attribute"));
- columnConfigList.add(new ColumnConfig<StateItem, String>(stateItemProperties.value(), 0, "Value"));
- columnModel = new ColumnModel<StateItem>(columnConfigList);
-
- uiBinder.createAndBindUi(this);
-
- grid.getSelectionModel().setLocked(true);
- }
-
-}
-
diff --git a/src/org/traccar/web/client/view/StateView.ui.xml b/src/org/traccar/web/client/view/StateView.ui.xml
deleted file mode 100644
index 2a7c2ac9..00000000
--- a/src/org/traccar/web/client/view/StateView.ui.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- 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">
-
- <ui:with type="com.sencha.gxt.data.shared.ListStore" field="stateStore" />
- <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">
- <ui:attributes stripeRows="true" autoFill="true" />
- </ui:with>
-
- <gxt:ContentPanel ui:field="contentPanel" headingText="State">
- <grid:Grid ui:field="grid" store="{stateStore}" cm="{columnModel}" view="{view}" />
- </gxt:ContentPanel>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/UserDialog.java b/src/org/traccar/web/client/view/UserDialog.java
deleted file mode 100644
index ac2eca32..00000000
--- a/src/org/traccar/web/client/view/UserDialog.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import org.traccar.web.client.ApplicationContext;
-import org.traccar.web.shared.model.User;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.editor.client.Editor;
-import com.google.gwt.editor.client.SimpleBeanEditorDriver;
-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.Widget;
-import com.sencha.gxt.widget.core.client.Window;
-import com.sencha.gxt.widget.core.client.event.SelectEvent;
-import com.sencha.gxt.widget.core.client.form.CheckBox;
-import com.sencha.gxt.widget.core.client.form.PasswordField;
-import com.sencha.gxt.widget.core.client.form.TextField;
-
-public class UserDialog implements Editor<User> {
-
- private static UserDialogUiBinder uiBinder = GWT.create(UserDialogUiBinder.class);
-
- interface UserDialogUiBinder extends UiBinder<Widget, UserDialog> {
- }
-
- private UserDriver driver = GWT.create(UserDriver.class);
-
- interface UserDriver extends SimpleBeanEditorDriver<User, UserDialog> {
- }
-
- public interface UserHandler {
- public void onSave(User user);
- }
-
- private UserHandler userHandler;
-
- @UiField
- Window window;
-
- @UiField
- TextField login;
-
- @UiField
- PasswordField password;
-
- @UiField
- CheckBox admin;
-
- public UserDialog(User user, UserHandler userHandler) {
- this.userHandler = userHandler;
- uiBinder.createAndBindUi(this);
-
- if (ApplicationContext.getInstance().getUser().getAdmin()) {
- admin.setEnabled(true);
- }
-
- driver.initialize(this);
- driver.edit(user);
- }
-
- public void show() {
- window.show();
- }
-
- public void hide() {
- window.hide();
- }
-
- @UiHandler("saveButton")
- public void onLoginClicked(SelectEvent event) {
- window.hide();
- userHandler.onSave(driver.flush());
- }
-
- @UiHandler("cancelButton")
- public void onRegisterClicked(SelectEvent event) {
- window.hide();
- }
-
-}
diff --git a/src/org/traccar/web/client/view/UserDialog.ui.xml b/src/org/traccar/web/client/view/UserDialog.ui.xml
deleted file mode 100644
index 9f7fe21d..00000000
--- a/src/org/traccar/web/client/view/UserDialog.ui.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
- xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button">
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="verticalLayoutData">
- <ui:attributes width="1" height="-1" />
- </ui:with>
-
- <gxt:Window ui:field="window" pixelSize="300, 150" modal="true" headingText="Account" focusWidget="{saveButton}">
- <container:VerticalLayoutContainer>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="User">
- <form:widget>
- <form:TextField ui:field="login" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Password">
- <form:widget>
- <form:PasswordField ui:field="password" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Administrator">
- <form:widget>
- <form:CheckBox ui:field="admin" enabled="false" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- </container:VerticalLayoutContainer>
-
- <gxt:button>
- <button:TextButton ui:field="saveButton" text="Save" />
- </gxt:button>
- <gxt:button>
- <button:TextButton ui:field="cancelButton" text="Cancel" />
- </gxt:button>
- </gxt:Window>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/UserSettingsDialog.java b/src/org/traccar/web/client/view/UserSettingsDialog.java
deleted file mode 100644
index be13eca8..00000000
--- a/src/org/traccar/web/client/view/UserSettingsDialog.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import java.util.Arrays;
-
-import org.traccar.web.client.model.EnumKeyProvider;
-import org.traccar.web.client.model.UserSettingsProperties;
-import org.traccar.web.shared.model.UserSettings;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.editor.client.Editor;
-import com.google.gwt.editor.client.SimpleBeanEditorDriver;
-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.Widget;
-import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
-import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.widget.core.client.Window;
-import com.sencha.gxt.widget.core.client.event.SelectEvent;
-import com.sencha.gxt.widget.core.client.form.ComboBox;
-
-public class UserSettingsDialog implements Editor<UserSettings> {
-
- private static UserSettingsDialogUiBinder uiBinder = GWT.create(UserSettingsDialogUiBinder.class);
-
- interface UserSettingsDialogUiBinder extends UiBinder<Widget, UserSettingsDialog> {
- }
-
- private UserSettingsDriver driver = GWT.create(UserSettingsDriver.class);
-
- interface UserSettingsDriver extends SimpleBeanEditorDriver<UserSettings, UserSettingsDialog> {
- }
-
- public interface UserSettingsHandler {
- public void onSave(UserSettings userSettings);
- }
-
- private UserSettingsHandler userSettingsHandler;
-
- @UiField
- Window window;
-
- @UiField(provided = true)
- ComboBox<UserSettings.SpeedUnit> speedUnit;
-
- public UserSettingsDialog(UserSettings userSettings, UserSettingsHandler userSettingsHandler) {
- this.userSettingsHandler = userSettingsHandler;
-
- ListStore<UserSettings.SpeedUnit> speedUnitStore = new ListStore<UserSettings.SpeedUnit>(
- new EnumKeyProvider<UserSettings.SpeedUnit>());
- speedUnitStore.addAll(Arrays.asList(UserSettings.SpeedUnit.values()));
-
- speedUnit = new ComboBox<UserSettings.SpeedUnit>(
- speedUnitStore, new UserSettingsProperties.SpeedUnitLabelProvider());
- speedUnit.setForceSelection(true);
- speedUnit.setTriggerAction(TriggerAction.ALL);
-
- uiBinder.createAndBindUi(this);
- driver.initialize(this);
- driver.edit(userSettings);
- }
-
- public void show() {
- window.show();
- }
-
- public void hide() {
- window.hide();
- }
-
- @UiHandler("saveButton")
- public void onLoginClicked(SelectEvent event) {
- window.hide();
- userSettingsHandler.onSave(driver.flush());
- }
-
- @UiHandler("cancelButton")
- public void onRegisterClicked(SelectEvent event) {
- window.hide();
- }
-
-}
diff --git a/src/org/traccar/web/client/view/UserSettingsDialog.ui.xml b/src/org/traccar/web/client/view/UserSettingsDialog.ui.xml
deleted file mode 100644
index db6c6932..00000000
--- a/src/org/traccar/web/client/view/UserSettingsDialog.ui.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
- xmlns:button="urn:import:com.sencha.gxt.widget.core.client.button">
-
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="verticalLayoutData">
- <ui:attributes width="1" height="-1" />
- </ui:with>
-
- <gxt:Window ui:field="window" pixelSize="300, 110" modal="true" headingText="Preferences" focusWidget="{saveButton}">
- <container:VerticalLayoutContainer>
- <container:child layoutData="{verticalLayoutData}">
- <form:FieldLabel text="Speed Units">
- <form:widget>
- <form:ComboBox ui:field="speedUnit" />
- </form:widget>
- </form:FieldLabel>
- </container:child>
- </container:VerticalLayoutContainer>
-
- <gxt:button>
- <button:TextButton ui:field="saveButton" text="Save" />
- </gxt:button>
- <gxt:button>
- <button:TextButton ui:field="cancelButton" text="Cancel" />
- </gxt:button>
- </gxt:Window>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/client/view/UsersDialog.java b/src/org/traccar/web/client/view/UsersDialog.java
deleted file mode 100644
index 3da8979b..00000000
--- a/src/org/traccar/web/client/view/UsersDialog.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.client.view;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.traccar.web.client.model.UserProperties;
-import org.traccar.web.shared.model.User;
-
-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.Widget;
-import com.sencha.gxt.core.client.Style.SelectionMode;
-import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.widget.core.client.Window;
-import com.sencha.gxt.widget.core.client.button.TextButton;
-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.selection.SelectionChangedEvent;
-
-public class UsersDialog implements SelectionChangedEvent.SelectionChangedHandler<User> {
-
- private static UsersDialogUiBinder uiBinder = GWT.create(UsersDialogUiBinder.class);
-
- interface UsersDialogUiBinder extends UiBinder<Widget, UsersDialog> {
- }
-
- public interface UserHandler {
- public void onAdd();
- public void onRemove(User user);
- }
-
- private UserHandler userHandler;
-
- @UiField
- Window window;
-
- @UiField
- TextButton addButton;
-
- @UiField
- TextButton removeButton;
-
- @UiField(provided = true)
- ColumnModel<User> columnModel;
-
- @UiField(provided = true)
- ListStore<User> userStore;
-
- @UiField
- Grid<User> grid;
-
- public UsersDialog(ListStore<User> userStore, UserHandler userHandler) {
- this.userStore = userStore;
- this.userHandler = userHandler;
-
- UserProperties userProperties = GWT.create(UserProperties.class);
-
- List<ColumnConfig<User, ?>> columnConfigList = new LinkedList<ColumnConfig<User, ?>>();
- columnConfigList.add(new ColumnConfig<User, String>(userProperties.login(), 0, "Name"));
- columnConfigList.add(new ColumnConfig<User, Boolean>(userProperties.admin(), 0, "Administrator"));
- columnModel = new ColumnModel<User>(columnConfigList);
-
- uiBinder.createAndBindUi(this);
-
- grid.getSelectionModel().addSelectionChangedHandler(this);
- grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
- }
-
- public void show() {
- window.show();
- }
-
- public void hide() {
- window.hide();
- }
-
- @Override
- public void onSelectionChanged(SelectionChangedEvent<User> event) {
- removeButton.setEnabled(!event.getSelection().isEmpty());
- }
- @UiHandler("addButton")
- public void onAddClicked(SelectEvent event) {
- userHandler.onAdd();
- }
-
- @UiHandler("removeButton")
- public void onRemoveClicked(SelectEvent event) {
- userHandler.onRemove(grid.getSelectionModel().getSelectedItem());
- }
-
-}
diff --git a/src/org/traccar/web/client/view/UsersDialog.ui.xml b/src/org/traccar/web/client/view/UsersDialog.ui.xml
deleted file mode 100644
index 2110e760..00000000
--- a/src/org/traccar/web/client/view/UsersDialog.ui.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:gxt="urn:import:com.sencha.gxt.widget.core.client"
- xmlns:container="urn:import:com.sencha.gxt.widget.core.client.container"
- xmlns:form="urn:import:com.sencha.gxt.widget.core.client.form"
- 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: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" />
- </ui:with>
- <ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="layoutData">
- <ui:attributes width="1" height="1" />
- </ui:with>
-
- <ui:with type="com.sencha.gxt.data.shared.ListStore" field="userStore" />
- <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">
- <ui:attributes stripeRows="true" autoFill="true" />
- </ui:with>
-
- <gxt:Window ui:field="window" pixelSize="640, 480" modal="true" headingText="Users">
- <container:VerticalLayoutContainer>
- <container:child layoutData="{layoutData}">
- <gxt:ContentPanel ui:field="contentPanel" headerVisible="false">
- <container:VerticalLayoutContainer>
-
- <container:child layoutData="{toolBarRowData}">
- <toolbar:ToolBar>
- <button:TextButton ui:field="addButton" text="Add" />
- <button:TextButton ui:field="removeButton" text="Remove" enabled="false" />
- </toolbar:ToolBar>
- </container:child>
-
- <container:child layoutData="{layoutData}">
- <grid:Grid ui:field="grid" store="{userStore}" cm="{columnModel}" view="{view}" />
- </container:child>
-
- </container:VerticalLayoutContainer>
- </gxt:ContentPanel>
- </container:child>
- </container:VerticalLayoutContainer>
- </gxt:Window>
-
-</ui:UiBinder>
diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java
deleted file mode 100644
index f8d44fc0..00000000
--- a/src/org/traccar/web/server/model/DataServiceImpl.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.server.model;
-
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpSession;
-
-import org.traccar.web.client.model.DataService;
-import org.traccar.web.shared.model.ApplicationSettings;
-import org.traccar.web.shared.model.Device;
-import org.traccar.web.shared.model.Position;
-import org.traccar.web.shared.model.User;
-
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
-public class DataServiceImpl extends RemoteServiceServlet implements DataService {
-
- private static final long serialVersionUID = 1;
-
- private static final String PERSISTENCE_DATASTORE = "java:/DefaultDS";
- private static final String PERSISTENCE_UNIT_DEBUG = "debug";
- private static final String PERSISTENCE_UNIT_RELEASE = "release";
- private static final String ATTRIBUTE_USER = "traccar.user";
- private static final String ATTRIBUTE_ENTITYMANAGER = "traccar.entitymanager";
-
- private EntityManagerFactory entityManagerFactory;
-
- @Override
- public void init() throws ServletException {
- super.init();
-
- String persistenceUnit;
- try {
- Context context = new InitialContext();
- context.lookup(PERSISTENCE_DATASTORE);
- persistenceUnit = PERSISTENCE_UNIT_RELEASE;
- } catch (NamingException e) {
- persistenceUnit = PERSISTENCE_UNIT_DEBUG;
- }
-
- entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit);
-
- // Create Administrator account
- EntityManager entityManager = getServletEntityManager();
- TypedQuery<User> query = entityManager.createQuery("SELECT x FROM User x WHERE x.login = 'admin'", User.class);
- List<User> results = query.getResultList();
- if (results.isEmpty()) {
- User user = new User();
- user.setLogin("admin");
- user.setPassword("admin");
- user.setAdmin(true);
- createUser(entityManager, user);
- }
- }
-
- private EntityManager servletEntityManager;
-
- private EntityManager getServletEntityManager() {
- if (servletEntityManager == null) {
- servletEntityManager = entityManagerFactory.createEntityManager();
- }
- return servletEntityManager;
- }
-
- private EntityManager getSessionEntityManager() {
- HttpSession session = getThreadLocalRequest().getSession();
- EntityManager entityManager = (EntityManager) session.getAttribute(ATTRIBUTE_ENTITYMANAGER);
- if (entityManager == null) {
- entityManager = entityManagerFactory.createEntityManager();
- session.setAttribute(ATTRIBUTE_ENTITYMANAGER, entityManager);
- }
- return entityManager;
- }
-
- private void setSessionUser(User user) {
- HttpSession session = getThreadLocalRequest().getSession();
- if (user != null) {
- session.setAttribute(ATTRIBUTE_USER, user);
- } else {
- session.removeAttribute(ATTRIBUTE_USER);
- }
- }
-
- private User getSessionUser() {
- HttpSession session = getThreadLocalRequest().getSession();
- User user = (User) session.getAttribute(ATTRIBUTE_USER);
- if (user == null) {
- throw new IllegalStateException();
- }
- return user;
- }
-
- @Override
- public User authenticated() throws IllegalStateException {
- return getSessionUser();
- }
-
- @Override
- public User login(String login, String password) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- TypedQuery<User> query = entityManager.createQuery(
- "SELECT x FROM User x WHERE x.login = :login", User.class);
- query.setParameter("login", login);
- List<User> results = query.getResultList();
-
- if (!results.isEmpty() && password.equals(results.get(0).getPassword())) {
- User user = results.get(0);
- setSessionUser(user);
- return user;
- }
- throw new IllegalStateException();
- }
- }
-
- @Override
- public boolean logout() {
- setSessionUser(null);
- return true;
- }
-
- @Override
- public User register(String login, String password) {
- if (getApplicationSettings().getRegistrationEnabled()) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
-
- TypedQuery<User> query = entityManager.createQuery(
- "SELECT x FROM User x WHERE x.login = :login", User.class);
- query.setParameter("login", login);
- List<User> results = query.getResultList();
- if (results.isEmpty()) {
- User user = new User();
- user.setLogin(login);
- user.setPassword(password);
- createUser(getSessionEntityManager(), user);
- setSessionUser(user);
- return user;
- }
- else
- {
- throw new IllegalStateException();
- }
- }
- } else {
- throw new SecurityException();
- }
- }
-
- @Override
- public List<User> getUsers() {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- List<User> users = new LinkedList<User>();
- users.addAll(entityManager.createQuery("SELECT x FROM User x", User.class).getResultList());
- return users;
- }
- }
-
- @Override
- public User addUser(User user) {
- User currentUser = getSessionUser();
- if (user.getLogin().isEmpty() || user.getPassword().isEmpty()) {
- throw new IllegalArgumentException();
- }
- if (currentUser.getAdmin()) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
-
- String login = user.getLogin();
- TypedQuery<User> query = entityManager.createQuery("SELECT x FROM User x WHERE x.login = :login", User.class);
- query.setParameter("login", login);
- List<User> results = query.getResultList();
-
- if (results.isEmpty()) {
- entityManager.getTransaction().begin();
- try {
- entityManager.persist(user);
- entityManager.getTransaction().commit();
- return user;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- } else {
- throw new IllegalStateException();
- }
- }
- } else {
- throw new SecurityException();
- }
- }
-
- @Override
- public User updateUser(User user) {
- User currentUser = getSessionUser();
- if (user.getLogin().isEmpty() || user.getPassword().isEmpty()) {
- throw new IllegalArgumentException();
- }
- if (currentUser.getAdmin() || (currentUser.getId() == user.getId() && !user.getAdmin())) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- entityManager.getTransaction().begin();
- try {
- // TODO: better solution?
- if (currentUser.getId() == user.getId()) {
- currentUser.setLogin(user.getLogin());
- currentUser.setPassword(user.getPassword());
- currentUser.setUserSettings(user.getUserSettings());
- currentUser.setAdmin(user.getAdmin());
- entityManager.merge(currentUser);
- user = currentUser;
- } else {
- // TODO: handle other users
- }
-
- entityManager.getTransaction().commit();
- setSessionUser(user);
- return user;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- }
- } else {
- throw new SecurityException();
- }
- }
-
- @Override
- public User removeUser(User user) {
- User currentUser = getSessionUser();
- if (currentUser.getAdmin()) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- entityManager.getTransaction().begin();
- try {
- user = entityManager.merge(user);
- user.getDevices().clear();
- entityManager.remove(user);
- entityManager.getTransaction().commit();
- return user;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- }
- } else {
- throw new SecurityException();
- }
- }
-
- private void createUser(EntityManager entityManager, User user) {
- synchronized (entityManager) {
- entityManager.getTransaction().begin();
- try {
- entityManager.persist(user);
- entityManager.getTransaction().commit();
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- }
- }
-
- @Override
- public List<Device> getDevices() {
- List<Device> devices = new LinkedList<Device>();
- User user = getSessionUser();
- devices.addAll(user.getDevices());
- return devices;
- }
-
- @Override
- public Device addDevice(Device device) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- TypedQuery<Device> query = entityManager.createQuery("SELECT x FROM Device x WHERE x.uniqueId = :id", Device.class);
- query.setParameter("id", device.getUniqueId());
- List<Device> results = query.getResultList();
-
- User user = getSessionUser();
-
- if (results.isEmpty()) {
- entityManager.getTransaction().begin();
- try {
- entityManager.persist(device);
- user.getDevices().add(device);
- entityManager.getTransaction().commit();
- return device;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- }
- else
- {
- throw new IllegalStateException();
- }
- }
- }
-
-
- @Override
- public Device updateDevice(Device device) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
-
- TypedQuery<Device> query = entityManager.createQuery("SELECT x FROM Device x WHERE x.uniqueId = :id AND x.id <> :primary_id", Device.class);
- query.setParameter("primary_id", device.getId());
- query.setParameter("id", device.getUniqueId());
- List<Device> results = query.getResultList();
-
- if (results.isEmpty()) {
- entityManager.getTransaction().begin();
- try {
- Device tmp_device = entityManager.find(Device.class, device.getId());
- tmp_device.setName(device.getName());
- tmp_device.setUniqueId(device.getUniqueId());
- entityManager.getTransaction().commit();
- return tmp_device;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- }
- else
- {
- throw new IllegalStateException();
- }
- }
- }
-
- @Override
- public Device removeDevice(Device device) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- User user = getSessionUser();
- entityManager.getTransaction().begin();
- try {
- device = entityManager.merge(device);
- user.getDevices().remove(device);
- device.setLatestPosition(null);
- entityManager.flush();
- Query query = entityManager.createQuery("DELETE FROM Position x WHERE x.device = :device");
- query.setParameter("device", device);
- query.executeUpdate();
- entityManager.remove(device);
- entityManager.getTransaction().commit();
- return device;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- }
- }
-
- @Override
- public List<Position> getPositions(Device device, Date from, Date to) {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- List<Position> positions = new LinkedList<Position>();
- TypedQuery<Position> query = entityManager.createQuery(
- "SELECT x FROM Position x WHERE x.device = :device AND x.time BETWEEN :from AND :to", Position.class);
- query.setParameter("device", device);
- query.setParameter("from", from);
- query.setParameter("to", to);
- positions.addAll(query.getResultList());
- return positions;
- }
- }
-
- @Override
- public List<Position> getLatestPositions() {
- EntityManager entityManager = getSessionEntityManager();
- synchronized (entityManager) {
- List<Position> positions = new LinkedList<Position>();
- User user = getSessionUser();
- if (user.getDevices() != null && !user.getDevices().isEmpty()) {
- TypedQuery<Position> query = entityManager.createQuery(
- "SELECT x FROM Position x WHERE x.id IN (" +
- "SELECT y.latestPosition FROM Device y WHERE y IN (:devices))", Position.class);
- query.setParameter("devices", user.getDevices());
- positions.addAll(query.getResultList());
- }
- return positions;
- }
- }
-
- private ApplicationSettings applicationSettings;
-
- private ApplicationSettings getApplicationSettings() {
- if (applicationSettings == null) {
- EntityManager entityManager = getServletEntityManager();
- synchronized (entityManager) {
- TypedQuery<ApplicationSettings> query = entityManager.createQuery("SELECT x FROM ApplicationSettings x", ApplicationSettings.class);
- List<ApplicationSettings> resultList = query.getResultList();
- if (resultList == null || resultList.isEmpty()) {
- applicationSettings = new ApplicationSettings();
- entityManager.getTransaction().begin();
- try {
- entityManager.persist(applicationSettings);
- entityManager.getTransaction().commit();
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- } else {
- applicationSettings = resultList.get(0);
- }
- }
- }
- return applicationSettings;
- }
-
- @Override
- public ApplicationSettings updateApplicationSettings(ApplicationSettings applicationSettings) {
- if (applicationSettings == null) {
- return getApplicationSettings();
- } else {
- EntityManager entityManager = getServletEntityManager();
- synchronized (entityManager) {
- User user = getSessionUser();
- if (user.getAdmin()) {
- entityManager.getTransaction().begin();
- try {
- entityManager.merge(applicationSettings);
- entityManager.getTransaction().commit();
- this.applicationSettings = applicationSettings;
- return applicationSettings;
- } catch (RuntimeException e) {
- entityManager.getTransaction().rollback();
- throw e;
- }
- } else {
- throw new SecurityException();
- }
- }
- }
- }
-
-}
diff --git a/src/org/traccar/web/shared/model/ApplicationSettings.java b/src/org/traccar/web/shared/model/ApplicationSettings.java
deleted file mode 100644
index 6f5bfe5c..00000000
--- a/src/org/traccar/web/shared/model/ApplicationSettings.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.traccar.web.shared.model;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="application_settings")
-public class ApplicationSettings implements Serializable {
-
- private static final long serialVersionUID = 1;
-
- @Id
- @GeneratedValue
- private long id;
-
- public ApplicationSettings() {
- registrationEnabled = true;
- }
-
- private boolean registrationEnabled;
-
- public void setRegistrationEnabled(boolean registrationEnabled) {
- this.registrationEnabled = registrationEnabled;
- }
-
- public boolean getRegistrationEnabled() {
- return registrationEnabled;
- }
-
-}
diff --git a/src/org/traccar/web/shared/model/Device.java b/src/org/traccar/web/shared/model/Device.java
deleted file mode 100644
index 6f6d6c57..00000000
--- a/src/org/traccar/web/shared/model/Device.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.shared.model;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "devices")
-public class Device implements Serializable {
-
- private static final long serialVersionUID = 1;
-
- public Device() {
- }
-
- public Device(Device device) {
- id = device.id;
- uniqueId = device.uniqueId;
- name = device.name;
- }
-
- @Id
- @GeneratedValue
- private long id;
-
- public long getId() {
- return id;
- }
-
- @OneToOne(fetch = FetchType.EAGER)
- private Position latestPosition;
-
- public void setLatestPosition(Position latestPosition) {
- this.latestPosition = latestPosition;
- }
-
- public Position getLatestPosition() {
- return latestPosition;
- }
-
- @Column(unique = true)
- private String uniqueId;
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- private String name;
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
-}
diff --git a/src/org/traccar/web/shared/model/Position.java b/src/org/traccar/web/shared/model/Position.java
deleted file mode 100644
index d9ec3b3f..00000000
--- a/src/org/traccar/web/shared/model/Position.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.shared.model;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
-import org.hibernate.annotations.Index;
-
-@Entity
-@Table(name = "positions")
-public class Position implements Serializable, Cloneable {
-
- private static final long serialVersionUID = 1;
-
- public Position() {
- }
-
- public Position(Position position) {
- id = position.id;
- device = position.device;
- time = position.time;
- valid = position.valid;
- latitude = position.latitude;
- longitude = position.longitude;
- altitude = position.altitude;
- speed = position.speed;
- course = position.course;
- power = position.power;
- address = position.address;
- other = position.other;
- }
-
- @Id
- @GeneratedValue
- private long id;
-
- public long getId() {
- return id;
- }
-
- @ManyToOne(fetch = FetchType.EAGER)
- @Index(name = "positionsIndex")
- private Device device;
-
- public Device getDevice() {
- return device;
- }
-
- @Index(name = "positionsIndex")
- private Date time;
-
- public Date getTime() {
- return time;
- }
-
- private Boolean valid;
-
- public Boolean getValid() {
- return valid;
- }
-
- private Double latitude;
-
- public Double getLatitude() {
- return latitude;
- }
-
- private Double longitude;
-
- public Double getLongitude() {
- return longitude;
- }
-
- private Double altitude;
-
- public Double getAltitude() {
- return altitude;
- }
-
- private Double speed;
-
- public Double getSpeed() {
- return speed;
- }
-
- private Double course;
-
- public Double getCourse() {
- return course;
- }
-
- private Double power;
-
- public Double getPower() {
- return power;
- }
-
- private String address;
-
- public String getAddress() {
- return address;
- }
-
- private String other;
-
- public String getOther() {
- return other;
- }
-
-}
diff --git a/src/org/traccar/web/shared/model/User.java b/src/org/traccar/web/shared/model/User.java
deleted file mode 100644
index 20adc12a..00000000
--- a/src/org/traccar/web/shared/model/User.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.web.shared.model;
-
-import java.io.Serializable;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-
-import com.google.gwt.user.client.rpc.GwtTransient;
-
-@Entity
-@Table(name="users")
-public class User implements Serializable, Cloneable {
-
- private static final long serialVersionUID = 1;
-
- public User() {
- admin = false;
- }
-
- public User(User user) {
- id = user.id;
- login = user.login;
- password = user.password;
- admin = user.admin;
- }
-
- @Id
- @GeneratedValue
- private long id;
-
- public long getId() {
- return id;
- }
-
- @Column(unique = true)
- private String login;
-
- public void setLogin(String login) {
- this.login = login;
- }
-
- public String getLogin() {
- return login;
- }
-
- private String password;
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getPassword() {
- return password;
- }
-
- // TODO temporary nullable to migrate from old database
- private Boolean admin;
-
- public void setAdmin(boolean admin) {
- this.admin = admin;
- }
-
- public boolean getAdmin() {
- // TODO temporary nullable to migrate from old database
- return (admin == null) ? false : admin;
- }
-
- @GwtTransient
- @OneToMany(fetch = FetchType.EAGER)
- private List<Device> devices = new LinkedList<Device>();
-
- public void setDevices(List<Device> devices) {
- this.devices = devices;
- }
-
- public List<Device> getDevices() {
- return devices;
- }
-
- @OneToOne(cascade = CascadeType.ALL)
- private UserSettings userSettings;
-
- public void setUserSettings(UserSettings userSettings) {
- this.userSettings = userSettings;
- }
-
- public UserSettings getUserSettings() {
- return userSettings;
- }
-
-}
diff --git a/src/org/traccar/web/shared/model/UserSettings.java b/src/org/traccar/web/shared/model/UserSettings.java
deleted file mode 100644
index 3f6deeaf..00000000
--- a/src/org/traccar/web/shared/model/UserSettings.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.traccar.web.shared.model;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="user_settings")
-public class UserSettings implements Serializable {
-
- private static final long serialVersionUID = 1;
-
- @Id
- @GeneratedValue
- private long id;
-
- public UserSettings() {
- speedUnit = SpeedUnit.knots;
- }
-
- public enum SpeedUnit {
- knots,
- kilometersPerHour,
- milesPerHour
- }
-
- @Enumerated(EnumType.STRING)
- private SpeedUnit speedUnit;
-
- public void setSpeedUnit(SpeedUnit speedUnit) {
- this.speedUnit = speedUnit;
- }
-
- public SpeedUnit getSpeedUnit() {
- return speedUnit;
- }
-
-}