From fcaf637431fee2cdd5ccab79b6de1edf44bac777 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 3 Aug 2015 15:13:14 +1200 Subject: Remove files and update readme --- .classpath | 11 - .project | 34 -- .settings/com.google.gdt.eclipse.core.prefs | 3 - .settings/com.google.gwt.eclipse.core.prefs | 3 - .settings/org.eclipse.jdt.core.prefs | 11 - .../org.eclipse.wst.common.project.facet.core.xml | 4 - README.md | 14 +- package.bat | 8 - package.sh | 9 - src/META-INF/persistence.xml | 22 - src/org/traccar/web/Traccar.gwt.xml | 22 - src/org/traccar/web/client/Application.java | 155 ------- src/org/traccar/web/client/ApplicationContext.java | 66 --- src/org/traccar/web/client/FormatterUtil.java | 42 -- src/org/traccar/web/client/Traccar.java | 42 -- .../web/client/controller/ArchiveController.java | 98 ----- .../web/client/controller/ContentController.java | 26 -- .../web/client/controller/DeviceController.java | 139 ------ .../web/client/controller/LoginController.java | 101 ----- .../web/client/controller/MapController.java | 138 ------ .../web/client/controller/SettingsController.java | 151 ------- .../web/client/controller/StateController.java | 57 --- .../model/ApplicationSettingsProperties.java | 30 -- .../web/client/model/BaseAsyncCallback.java | 32 -- .../web/client/model/BaseStoreHandlers.java | 73 ---- src/org/traccar/web/client/model/DataService.java | 62 --- .../traccar/web/client/model/DataServiceAsync.java | 60 --- .../traccar/web/client/model/DeviceProperties.java | 37 -- .../traccar/web/client/model/EnumKeyProvider.java | 13 - .../web/client/model/PositionProperties.java | 48 --- src/org/traccar/web/client/model/StateItem.java | 31 -- .../web/client/model/StateItemProperties.java | 17 - src/org/traccar/web/client/model/StateReader.java | 50 --- .../traccar/web/client/model/UserProperties.java | 34 -- .../web/client/model/UserSettingsProperties.java | 50 --- .../web/client/view/ApplicationSettingsDialog.java | 81 ---- .../client/view/ApplicationSettingsDialog.ui.xml | 33 -- .../traccar/web/client/view/ApplicationView.java | 52 --- .../traccar/web/client/view/ApplicationView.ui.xml | 56 --- src/org/traccar/web/client/view/ArchiveView.java | 196 --------- src/org/traccar/web/client/view/ArchiveView.ui.xml | 62 --- src/org/traccar/web/client/view/DeviceDialog.java | 84 ---- .../traccar/web/client/view/DeviceDialog.ui.xml | 40 -- src/org/traccar/web/client/view/DeviceView.java | 186 -------- src/org/traccar/web/client/view/DeviceView.ui.xml | 57 --- src/org/traccar/web/client/view/LoginDialog.java | 84 ---- src/org/traccar/web/client/view/LoginDialog.ui.xml | 40 -- .../web/client/view/MapPositionRenderer.java | 185 -------- src/org/traccar/web/client/view/MapView.java | 211 ---------- .../traccar/web/client/view/MarkerIconFactory.java | 51 --- src/org/traccar/web/client/view/StateView.java | 58 --- src/org/traccar/web/client/view/StateView.ui.xml | 22 - src/org/traccar/web/client/view/UserDialog.java | 95 ----- src/org/traccar/web/client/view/UserDialog.ui.xml | 47 --- .../web/client/view/UserSettingsDialog.java | 97 ----- .../web/client/view/UserSettingsDialog.ui.xml | 33 -- src/org/traccar/web/client/view/UsersDialog.java | 110 ----- src/org/traccar/web/client/view/UsersDialog.ui.xml | 50 --- .../traccar/web/server/model/DataServiceImpl.java | 467 --------------------- .../web/shared/model/ApplicationSettings.java | 34 -- src/org/traccar/web/shared/model/Device.java | 83 ---- src/org/traccar/web/shared/model/Position.java | 131 ------ src/org/traccar/web/shared/model/User.java | 115 ----- src/org/traccar/web/shared/model/UserSettings.java | 43 -- war/WEB-INF/web.xml | 26 -- war/traccar.html | 28 -- 66 files changed, 7 insertions(+), 4543 deletions(-) delete mode 100644 .classpath delete mode 100644 .project delete mode 100644 .settings/com.google.gdt.eclipse.core.prefs delete mode 100644 .settings/com.google.gwt.eclipse.core.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100755 package.bat delete mode 100755 package.sh delete mode 100644 src/META-INF/persistence.xml delete mode 100644 src/org/traccar/web/Traccar.gwt.xml delete mode 100644 src/org/traccar/web/client/Application.java delete mode 100644 src/org/traccar/web/client/ApplicationContext.java delete mode 100644 src/org/traccar/web/client/FormatterUtil.java delete mode 100644 src/org/traccar/web/client/Traccar.java delete mode 100644 src/org/traccar/web/client/controller/ArchiveController.java delete mode 100644 src/org/traccar/web/client/controller/ContentController.java delete mode 100644 src/org/traccar/web/client/controller/DeviceController.java delete mode 100644 src/org/traccar/web/client/controller/LoginController.java delete mode 100644 src/org/traccar/web/client/controller/MapController.java delete mode 100644 src/org/traccar/web/client/controller/SettingsController.java delete mode 100644 src/org/traccar/web/client/controller/StateController.java delete mode 100644 src/org/traccar/web/client/model/ApplicationSettingsProperties.java delete mode 100644 src/org/traccar/web/client/model/BaseAsyncCallback.java delete mode 100644 src/org/traccar/web/client/model/BaseStoreHandlers.java delete mode 100644 src/org/traccar/web/client/model/DataService.java delete mode 100644 src/org/traccar/web/client/model/DataServiceAsync.java delete mode 100644 src/org/traccar/web/client/model/DeviceProperties.java delete mode 100644 src/org/traccar/web/client/model/EnumKeyProvider.java delete mode 100644 src/org/traccar/web/client/model/PositionProperties.java delete mode 100644 src/org/traccar/web/client/model/StateItem.java delete mode 100644 src/org/traccar/web/client/model/StateItemProperties.java delete mode 100644 src/org/traccar/web/client/model/StateReader.java delete mode 100644 src/org/traccar/web/client/model/UserProperties.java delete mode 100644 src/org/traccar/web/client/model/UserSettingsProperties.java delete mode 100644 src/org/traccar/web/client/view/ApplicationSettingsDialog.java delete mode 100644 src/org/traccar/web/client/view/ApplicationSettingsDialog.ui.xml delete mode 100644 src/org/traccar/web/client/view/ApplicationView.java delete mode 100644 src/org/traccar/web/client/view/ApplicationView.ui.xml delete mode 100644 src/org/traccar/web/client/view/ArchiveView.java delete mode 100644 src/org/traccar/web/client/view/ArchiveView.ui.xml delete mode 100644 src/org/traccar/web/client/view/DeviceDialog.java delete mode 100644 src/org/traccar/web/client/view/DeviceDialog.ui.xml delete mode 100644 src/org/traccar/web/client/view/DeviceView.java delete mode 100644 src/org/traccar/web/client/view/DeviceView.ui.xml delete mode 100644 src/org/traccar/web/client/view/LoginDialog.java delete mode 100644 src/org/traccar/web/client/view/LoginDialog.ui.xml delete mode 100644 src/org/traccar/web/client/view/MapPositionRenderer.java delete mode 100644 src/org/traccar/web/client/view/MapView.java delete mode 100644 src/org/traccar/web/client/view/MarkerIconFactory.java delete mode 100644 src/org/traccar/web/client/view/StateView.java delete mode 100644 src/org/traccar/web/client/view/StateView.ui.xml delete mode 100644 src/org/traccar/web/client/view/UserDialog.java delete mode 100644 src/org/traccar/web/client/view/UserDialog.ui.xml delete mode 100644 src/org/traccar/web/client/view/UserSettingsDialog.java delete mode 100644 src/org/traccar/web/client/view/UserSettingsDialog.ui.xml delete mode 100644 src/org/traccar/web/client/view/UsersDialog.java delete mode 100644 src/org/traccar/web/client/view/UsersDialog.ui.xml delete mode 100644 src/org/traccar/web/server/model/DataServiceImpl.java delete mode 100644 src/org/traccar/web/shared/model/ApplicationSettings.java delete mode 100644 src/org/traccar/web/shared/model/Device.java delete mode 100644 src/org/traccar/web/shared/model/Position.java delete mode 100644 src/org/traccar/web/shared/model/User.java delete mode 100644 src/org/traccar/web/shared/model/UserSettings.java delete mode 100644 war/WEB-INF/web.xml delete mode 100644 war/traccar.html diff --git a/.classpath b/.classpath deleted file mode 100644 index 7c0039c..0000000 --- a/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index 8e2b32c..0000000 --- a/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - traccar - - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.google.gdt.eclipse.core.webAppProjectValidator - - - - - com.google.gwt.eclipse.core.gwtProjectValidator - - - - - - org.eclipse.jdt.core.javanature - com.google.gwt.eclipse.core.gwtNature - org.eclipse.wst.common.project.facet.core.nature - - diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs deleted file mode 100644 index cc6cb35..0000000 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -warSrcDir=war -warSrcDirIsOutput=true diff --git a/.settings/com.google.gwt.eclipse.core.prefs b/.settings/com.google.gwt.eclipse.core.prefs deleted file mode 100644 index 2adad03..0000000 --- a/.settings/com.google.gwt.eclipse.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -filesCopiedToWebInfLib=gwt-servlet.jar -gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBW11dPjwvZXh0cmEtYXJncz48dm0tYXJncz48IVtDREFUQVstWG14NTEybV1dPjwvdm0tYXJncz48ZW50cnktcG9pbnQtbW9kdWxlPm9yZy50cmFjY2FyLndlYi5UcmFjY2FyPC9lbnRyeS1wb2ludC1tb2R1bGU+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\= diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8000cd6..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index bcfc325..0000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/README.md b/README.md index 07537d1..21ba820 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -# [Traccar Web Interface](https://www.traccar.org) +# ~~Traccar Web Interface~~ -## Status +Repository is **DEPRECATED**. It contains **old** Traccar web interface (GWT-based). New web interface can be found here: -**The project is in frozen state.** I am working on a completely new web interface based on pure JavaScript. +* [**New Traccar Web Interface**](https://github.com/tananaev/traccar/tree/master/web) + +For any issues related to Traccar server of web interface please use main issue tracker: + +* [**Traccar Issue Tracker**](https://github.com/tananaev/traccar/issues) ## Contacts @@ -10,10 +14,6 @@ Author - Anton Tananaev ([anton.tananaev@gmail.com](mailto:anton.tananaev@gmail. Website - [https://www.traccar.org](https://www.traccar.org) -## Overview - -Traccar is open source server for various GPS tracking devices. This repository contains web interface for Traccar server. - ## License Apache License, Version 2.0 diff --git a/package.bat b/package.bat deleted file mode 100755 index afcc943..0000000 --- a/package.bat +++ /dev/null @@ -1,8 +0,0 @@ -rm -f traccar-web.war -md tmp -mv war/WEB-INF/deploy/ tmp/ -mv war/WEB-INF/lib/h2-* tmp/ -jar cv -C war/ . > traccar-web.war -mv tmp/h2-* war/WEB-INF/lib/ -mv tmp/deploy/ war/WEB-INF/ -rm -r -f tmp/ diff --git a/package.sh b/package.sh deleted file mode 100755 index 4f49cea..0000000 --- a/package.sh +++ /dev/null @@ -1,9 +0,0 @@ -rm -f traccar-web.war -mkdir tmp/ -mv war/WEB-INF/deploy/ tmp/ -mv war/WEB-INF/lib/h2-* tmp/ -jar cv -C war/ . > traccar-web.war -mv tmp/h2-* war/WEB-INF/lib/ -mv tmp/deploy/ war/WEB-INF/ -rm -r -f tmp/ - diff --git a/src/META-INF/persistence.xml b/src/META-INF/persistence.xml deleted file mode 100644 index 0dc8efb..0000000 --- a/src/META-INF/persistence.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - java:/DefaultDS - - - - - - - - - - - - - - - - diff --git a/src/org/traccar/web/Traccar.gwt.xml b/src/org/traccar/web/Traccar.gwt.xml deleted file mode 100644 index 0f71766..0000000 --- a/src/org/traccar/web/Traccar.gwt.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/org/traccar/web/client/Application.java b/src/org/traccar/web/client/Application.java deleted file mode 100644 index cd3424d..0000000 --- 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 deviceStoreHandler = new BaseStoreHandlers() { - - @Override - public void onAdd(StoreAddEvent event) { - mapController.update(); - } - - @Override - public void onRemove(StoreRemoveEvent event) { - mapController.update(); - } - - }; - - private StoreHandlers archiveStoreHandler = new BaseStoreHandlers() { - - @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 80b8998..0000000 --- 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 36c24dc..0000000 --- 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 d775bb4..0000000 --- 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() { - @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 9a0c18d..0000000 --- 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 positionStore; - - private ArchiveView archiveView; - - public ArchiveController(ArchiveHandler archiveHandler, ListStore deviceStore) { - this.archiveHandler = archiveHandler; - PositionProperties positionProperties = GWT.create(PositionProperties.class); - positionStore = new ListStore(positionProperties.id()); - archiveView = new ArchiveView(this, positionStore, deviceStore); - } - - public ListStore 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>() { - @Override - public void onSuccess(List 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 4fdea7c..0000000 --- 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 599f756..0000000 --- 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 deviceStore; - - private DeviceView deviceView; - - public DeviceController(DeviceHandler deviceHandler, DeviceView.SettingsHandler settingsHandler) { - this.deviceHandler = deviceHandler; - DeviceProperties deviceProperties = GWT.create(DeviceProperties.class); - deviceStore = new ListStore(deviceProperties.id()); - deviceView = new DeviceView(this, settingsHandler, deviceStore); - } - - public ListStore getDeviceStore() { - return deviceStore; - } - - @Override - public ContentPanel getView() { - return deviceView.getView(); - } - - @Override - public void run() { - Application.getDataService().getDevices(new BaseAsyncCallback>() { - @Override - public void onSuccess(List 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() { - @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() { - @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() { - @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 1aa152b..0000000 --- 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() { - @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() { - @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() { - @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 13c736f..0000000 --- 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 latestPositionMap = new HashMap(); - - public void update() { - updateTimer.cancel(); - Application.getDataService().getLatestPositions(new AsyncCallback>() { - @Override - public void onSuccess(List result) { - mapView.showLatestPositions(result); - for (Position position : result) { - latestPositionMap.put(position.getDevice().getId(), position); - } - for (Map.Entry 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 positions) { - List sortedPositions = new LinkedList(positions); - Collections.sort(sortedPositions, new Comparator() { - @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 positionUpdateMap = new HashMap(); - - - 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 bd20288..0000000 --- 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() { - @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() { - @Override - public void onSuccess(User result) { - ApplicationContext.getInstance().setUser(result); - } - }); - } - }).show(); - } - - @Override - public void onUsersSelected() { - Application.getDataService().getUsers(new BaseAsyncCallback>() { - @Override - public void onSuccess(List result) { - UserProperties userProperties = GWT.create(UserProperties.class); - final ListStore userStore = new ListStore(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() { - @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() { - @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() { - @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 a19bec8..0000000 --- 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 stateStore; - - private StateView stateView; - - public StateController() { - StateItemProperties stateItemProperties = GWT.create(StateItemProperties.class); - stateStore = new ListStore(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 b30572e..0000000 --- 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 { - - ModelKeyProvider id(); - - ValueProvider 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 cb0c479..0000000 --- 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 implements AsyncCallback { - - @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 f34ff3a..0000000 --- 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 implements StoreHandlers { - - @Override - public void onAdd(StoreAddEvent event) { - onAnything(); - } - - @Override - public void onRemove(StoreRemoveEvent event) { - onAnything(); - } - - @Override - public void onFilter(StoreFilterEvent event) { - onAnything(); - } - - @Override - public void onClear(StoreClearEvent event) { - onAnything(); - } - - @Override - public void onUpdate(StoreUpdateEvent event) { - onAnything(); - } - - @Override - public void onDataChange(StoreDataChangeEvent event) { - onAnything(); - } - - @Override - public void onRecordChange(StoreRecordChangeEvent event) { - onAnything(); - } - - @Override - public void onSort(StoreSortEvent 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 a693b6e..0000000 --- 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 getUsers(); - - User addUser(User user); - - User updateUser(User user); - - User removeUser(User user); - - List getDevices(); - - Device addDevice(Device device); - - Device updateDevice(Device device); - - Device removeDevice(Device device); - - List getPositions(Device device, Date from, Date to); - - List 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 b183063..0000000 --- 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 callback); - - void login(String login, String password, AsyncCallback callback); - - void logout(AsyncCallback callback); - - void register(String login, String password, AsyncCallback callback); - - void getUsers(AsyncCallback> callback); - - void addUser(User user, AsyncCallback callback); - - void updateUser(User user, AsyncCallback callback); - - void removeUser(User user, AsyncCallback callback); - - void getDevices(AsyncCallback> callback); - - void addDevice(Device device, AsyncCallback callback); - - void updateDevice(Device device, AsyncCallback callback); - - void removeDevice(Device device, AsyncCallback callback); - - void getLatestPositions(AsyncCallback> callback); - - void getPositions(Device device, Date from, Date to, AsyncCallback> callback); - - void updateApplicationSettings(ApplicationSettings applicationSettings, AsyncCallback 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 35f946a..0000000 --- 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 { - - ModelKeyProvider id(); - - ValueProvider uniqueId(); - - ValueProvider name(); - - @Path("name") - LabelProvider 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 c41d420..0000000 --- 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> implements ModelKeyProvider { - - @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 86ab532..0000000 --- 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 { - - ModelKeyProvider id(); - - ValueProvider time(); - - ValueProvider valid(); - - ValueProvider latitude(); - - ValueProvider longitude(); - - ValueProvider altitude(); - - ValueProvider speed(); - - ValueProvider course(); - - ValueProvider power(); - - ValueProvider 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 651d2a2..0000000 --- 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 e3700a5..0000000 --- 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 { - - @Path("name") - ModelKeyProvider id(); - - ValueProvider name(); - - ValueProvider 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 10ed980..0000000 --- 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 getState(Position position) { - List state = new LinkedList(); - - 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 cba2996..0000000 --- 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 { - - ModelKeyProvider id(); - - ValueProvider login(); - - ValueProvider password(); - - ValueProvider 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 dad7111..0000000 --- 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 { - - ModelKeyProvider id(); - - ValueProvider speedUnit(); - - public static class SpeedUnitLabelProvider implements LabelProvider { - - @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 24b9f96..0000000 --- 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 { - - private static ApplicationSettingsDialogUiBinder uiBinder = GWT.create(ApplicationSettingsDialogUiBinder.class); - - interface ApplicationSettingsDialogUiBinder extends UiBinder { - } - - private ApplicationSettingsDriver driver = GWT.create(ApplicationSettingsDriver.class); - - interface ApplicationSettingsDriver extends SimpleBeanEditorDriver { - } - - 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 effdc4a..0000000 --- a/src/org/traccar/web/client/view/ApplicationSettingsDialog.ui.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 dfa5335..0000000 --- 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 { - } - - @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 0b05ab9..0000000 --- a/src/org/traccar/web/client/view/ApplicationView.ui.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 9cc579f..0000000 --- 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 { - - private static ArchiveViewUiBinder uiBinder = GWT.create(ArchiveViewUiBinder.class); - - interface ArchiveViewUiBinder extends UiBinder { - } - - 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 deviceStore; - - @UiField - DateField fromDate; - - @UiField - TimeField fromTime; - - @UiField - DateField toDate; - - @UiField - TimeField toTime; - - @UiField(provided = true) - ComboBox deviceCombo; - - @UiField(provided = true) - ColumnModel columnModel; - - @UiField(provided = true) - ListStore positionStore; - - @UiField - Grid grid; - - public ArchiveView(ArchiveHandler archiveHandler, ListStore positionStore, ListStore deviceStore) { - this.archiveHandler = archiveHandler; - this.positionStore = positionStore; - deviceStore.addStoreHandlers(deviceStoreHandlers); - this.deviceStore = deviceStore; - - DeviceProperties deviceProperties = GWT.create(DeviceProperties.class); - deviceCombo = new ComboBox(deviceStore, deviceProperties.label()); - - PositionProperties positionProperties = GWT.create(PositionProperties.class); - - List> columnConfigList = new LinkedList>(); - - columnConfigList.add(new ColumnConfig(positionProperties.valid(), 0, "Valid")); - - ColumnConfig columnConfigDate = new ColumnConfig(positionProperties.time(), 0, "Time"); - columnConfigDate.setCell(new DateCell(ApplicationContext.getInstance().getFormatterUtil().getTimeFormat())); - columnConfigList.add(columnConfigDate); - - columnConfigList.add(new ColumnConfig(positionProperties.latitude(), 0, "Latitude")); - columnConfigList.add(new ColumnConfig(positionProperties.longitude(), 0, "Longitude")); - columnConfigList.add(new ColumnConfig(positionProperties.altitude(), 0, "Altitude")); - - ColumnConfig columnConfigDouble = new ColumnConfig(positionProperties.speed(), 0, "Speed"); - columnConfigDouble.setCell(new NumberCell(ApplicationContext.getInstance().getFormatterUtil().getSpeedFormat())); - columnConfigList.add(columnConfigDouble); - - columnConfigList.add(new ColumnConfig(positionProperties.course(), 0, "Course")); - columnConfigList.add(new ColumnConfig(positionProperties.power(), 0, "Power")); - - columnModel = new ColumnModel(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 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 deviceStoreHandlers = new BaseStoreHandlers() { - - @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 f27d38f..0000000 --- a/src/org/traccar/web/client/view/ArchiveView.ui.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 9e94e96..0000000 --- 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 { - - private static DeviceDialogUiBinder uiBinder = GWT.create(DeviceDialogUiBinder.class); - - interface DeviceDialogUiBinder extends UiBinder { - } - - private DeviceDriver driver = GWT.create(DeviceDriver.class); - - interface DeviceDriver extends SimpleBeanEditorDriver { - } - - 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 4f7ccc5..0000000 --- a/src/org/traccar/web/client/view/DeviceDialog.ui.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 21d906c..0000000 --- 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 { - - private static DeviceViewUiBinder uiBinder = GWT.create(DeviceViewUiBinder.class); - - interface DeviceViewUiBinder extends UiBinder { - } - - 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 columnModel; - - @UiField(provided = true) - ListStore deviceStore; - - @UiField - Grid grid; - - @UiField - MenuItem settingsUsers; - - @UiField - MenuItem settingsGlobal; - - public DeviceView(DeviceHandler deviceHandler, SettingsHandler settingsHandler, ListStore deviceStore) { - this.deviceHandler = deviceHandler; - this.settingsHandler = settingsHandler; - this.deviceStore = deviceStore; - - DeviceProperties deviceProperties = GWT.create(DeviceProperties.class); - - List> columnConfigList = new LinkedList>(); - columnConfigList.add(new ColumnConfig(deviceProperties.name(), 0, "Name")); - columnConfigList.add(new ColumnConfig(deviceProperties.uniqueId(), 0, "Unique Identifier")); - columnModel = new ColumnModel(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 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() { - @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 event) { - settingsHandler.onAccountSelected(); - } - - @UiHandler("settingsPreferences") - public void onSettingsPreferencesSelected(SelectionEvent event) { - settingsHandler.onPreferencesSelected(); - } - - @UiHandler("settingsUsers") - public void onSettingsUsersSelected(SelectionEvent event) { - settingsHandler.onUsersSelected(); - } - - @UiHandler("settingsGlobal") - public void onSettingsGlobalSelected(SelectionEvent 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 38721ca..0000000 --- a/src/org/traccar/web/client/view/DeviceView.ui.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 59b4623..0000000 --- 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 { - } - - 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 c931443..0000000 --- a/src/org/traccar/web/client/view/LoginDialog.ui.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 15ba082..0000000 --- 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 markerMap = new HashMap(); // Position.id -> Marker - private Map deviceMap = new HashMap(); // Device.id -> Position.id - private Map positionMap = new HashMap(); // Position.id -> Position - - private Long selectedPositionId; - private Long selectedDeviceId; - - public void showPositions(List 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 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 db51cd3..0000000 --- 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 positions) { - latestPositionRenderer.showPositions(positions); - } - - public void showArchivePositions(List 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 46965d5..0000000 --- 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 700d55a..0000000 --- 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 { - } - - @UiField - ContentPanel contentPanel; - - public ContentPanel getView() { - return contentPanel; - } - - @UiField(provided = true) - ColumnModel columnModel; - - @UiField(provided = true) - ListStore stateStore; - - @UiField - Grid grid; - - public StateView(ListStore stateStore) { - this.stateStore = stateStore; - - StateItemProperties stateItemProperties = GWT.create(StateItemProperties.class); - - List> columnConfigList = new LinkedList>(); - columnConfigList.add(new ColumnConfig(stateItemProperties.name(), 0, "Attribute")); - columnConfigList.add(new ColumnConfig(stateItemProperties.value(), 0, "Value")); - columnModel = new ColumnModel(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 2a7c2ac..0000000 --- a/src/org/traccar/web/client/view/StateView.ui.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - 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 ac2eca3..0000000 --- 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 { - - private static UserDialogUiBinder uiBinder = GWT.create(UserDialogUiBinder.class); - - interface UserDialogUiBinder extends UiBinder { - } - - private UserDriver driver = GWT.create(UserDriver.class); - - interface UserDriver extends SimpleBeanEditorDriver { - } - - 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 9f7fe21..0000000 --- a/src/org/traccar/web/client/view/UserDialog.ui.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 be13eca..0000000 --- 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 { - - private static UserSettingsDialogUiBinder uiBinder = GWT.create(UserSettingsDialogUiBinder.class); - - interface UserSettingsDialogUiBinder extends UiBinder { - } - - private UserSettingsDriver driver = GWT.create(UserSettingsDriver.class); - - interface UserSettingsDriver extends SimpleBeanEditorDriver { - } - - public interface UserSettingsHandler { - public void onSave(UserSettings userSettings); - } - - private UserSettingsHandler userSettingsHandler; - - @UiField - Window window; - - @UiField(provided = true) - ComboBox speedUnit; - - public UserSettingsDialog(UserSettings userSettings, UserSettingsHandler userSettingsHandler) { - this.userSettingsHandler = userSettingsHandler; - - ListStore speedUnitStore = new ListStore( - new EnumKeyProvider()); - speedUnitStore.addAll(Arrays.asList(UserSettings.SpeedUnit.values())); - - speedUnit = new ComboBox( - 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 db6c693..0000000 --- a/src/org/traccar/web/client/view/UserSettingsDialog.ui.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 3da8979..0000000 --- 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 { - - private static UsersDialogUiBinder uiBinder = GWT.create(UsersDialogUiBinder.class); - - interface UsersDialogUiBinder extends UiBinder { - } - - 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 columnModel; - - @UiField(provided = true) - ListStore userStore; - - @UiField - Grid grid; - - public UsersDialog(ListStore userStore, UserHandler userHandler) { - this.userStore = userStore; - this.userHandler = userHandler; - - UserProperties userProperties = GWT.create(UserProperties.class); - - List> columnConfigList = new LinkedList>(); - columnConfigList.add(new ColumnConfig(userProperties.login(), 0, "Name")); - columnConfigList.add(new ColumnConfig(userProperties.admin(), 0, "Administrator")); - columnModel = new ColumnModel(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 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 2110e76..0000000 --- a/src/org/traccar/web/client/view/UsersDialog.ui.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 f8d44fc..0000000 --- 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 query = entityManager.createQuery("SELECT x FROM User x WHERE x.login = 'admin'", User.class); - List 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 query = entityManager.createQuery( - "SELECT x FROM User x WHERE x.login = :login", User.class); - query.setParameter("login", login); - List 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 query = entityManager.createQuery( - "SELECT x FROM User x WHERE x.login = :login", User.class); - query.setParameter("login", login); - List 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 getUsers() { - EntityManager entityManager = getSessionEntityManager(); - synchronized (entityManager) { - List users = new LinkedList(); - 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 query = entityManager.createQuery("SELECT x FROM User x WHERE x.login = :login", User.class); - query.setParameter("login", login); - List 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 getDevices() { - List devices = new LinkedList(); - User user = getSessionUser(); - devices.addAll(user.getDevices()); - return devices; - } - - @Override - public Device addDevice(Device device) { - EntityManager entityManager = getSessionEntityManager(); - synchronized (entityManager) { - TypedQuery query = entityManager.createQuery("SELECT x FROM Device x WHERE x.uniqueId = :id", Device.class); - query.setParameter("id", device.getUniqueId()); - List 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 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 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 getPositions(Device device, Date from, Date to) { - EntityManager entityManager = getSessionEntityManager(); - synchronized (entityManager) { - List positions = new LinkedList(); - TypedQuery 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 getLatestPositions() { - EntityManager entityManager = getSessionEntityManager(); - synchronized (entityManager) { - List positions = new LinkedList(); - User user = getSessionUser(); - if (user.getDevices() != null && !user.getDevices().isEmpty()) { - TypedQuery 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 query = entityManager.createQuery("SELECT x FROM ApplicationSettings x", ApplicationSettings.class); - List 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 6f5bfe5..0000000 --- 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 6f6d6c5..0000000 --- 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 d9ec3b3..0000000 --- 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 20adc12..0000000 --- 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 devices = new LinkedList(); - - public void setDevices(List devices) { - this.devices = devices; - } - - public List 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 3f6deea..0000000 --- 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; - } - -} diff --git a/war/WEB-INF/web.xml b/war/WEB-INF/web.xml deleted file mode 100644 index 5cd9b71..0000000 --- a/war/WEB-INF/web.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - dataService - org.traccar.web.server.model.DataServiceImpl - - - - dataService - /traccar/dataService - - - - traccar.html - - - - 0 - - - diff --git a/war/traccar.html b/war/traccar.html deleted file mode 100644 index 67c5be1..0000000 --- a/war/traccar.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Traccar - - - - - - - - - - - - - - - - -- cgit v1.2.3