diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-01-09 20:37:55 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-01-09 20:37:55 +1300 |
commit | 49ea27fa064054d0bccb22b0ef6ed081f4835a92 (patch) | |
tree | 5a84cfcbc03103297f1f66415dd03533fc8e9aa0 | |
parent | f0b99fd68cb3b6b484d50c1f9ebc0e77997fd2dd (diff) | |
download | etbsa-traccar-web-49ea27fa064054d0bccb22b0ef6ed081f4835a92.tar.gz etbsa-traccar-web-49ea27fa064054d0bccb22b0ef6ed081f4835a92.tar.bz2 etbsa-traccar-web-49ea27fa064054d0bccb22b0ef6ed081f4835a92.zip |
Remove old stuff
35 files changed, 0 insertions, 1988 deletions
diff --git a/Traccar.launch b/Traccar.launch deleted file mode 100644 index 5e184bf..0000000 --- a/Traccar.launch +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="com.google.gdt.eclipse.suite.webapp"> -<stringAttribute key="com.google.gdt.eclipse.suiteMainTypeProcessor.PREVIOUSLY_SET_MAIN_TYPE_NAME" value="com.google.gwt.dev.DevMode"/> -<booleanAttribute key="com.google.gdt.eclipse.suiteWarArgumentProcessor.IS_WAR_FROM_PROJECT_PROPERTIES" value="true"/> -<stringAttribute key="com.google.gwt.eclipse.core.URL" value="Traccar.html"/> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/traccar-web"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="4"/> -</listAttribute> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl Traccar.html -logLevel INFO -codeServerPort 9997 -port 8888 -war /home/user/Documents/gwt/traccar-web/src/main/webapp org.traccar.web.Traccar org.traccar.web.TraccarJUnit"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="traccar-web"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m -Dgwt.nowarn.legacy.tools"/> -</launchConfiguration> diff --git a/TraccarTest-dev.launch b/TraccarTest-dev.launch deleted file mode 100644 index abceae6..0000000 --- a/TraccarTest-dev.launch +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit"> -<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/> -<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/> -<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/> -<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/> -<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/> -<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/traccar-web/src/test/java/org/traccar/web/client/GwtTestTraccar.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> -<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> -<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> -<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.traccar.web.client.GwtTestTraccar"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="traccar-web"/> -</launchConfiguration> diff --git a/TraccarTest-prod.launch b/TraccarTest-prod.launch deleted file mode 100644 index 0405cfb..0000000 --- a/TraccarTest-prod.launch +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit"> -<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/> -<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/> -<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/> -<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/> -<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/> -<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/traccar-web/src/test/java/org/traccar/web/client/GwtTestTraccar.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> -<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> -<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> -<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.traccar.web.client.GwtTestTraccar"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="traccar-web"/> -</launchConfiguration> diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 6cea2e3..0000000 --- a/pom.xml +++ /dev/null @@ -1,201 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project - xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <!-- POM file generated with GWT webAppCreator --> - <modelVersion>4.0.0</modelVersion> - <groupId>org.traccar.web</groupId> - <artifactId>traccar-web</artifactId> - <packaging>war</packaging> - <version>1.0-SNAPSHOT</version> - <name>GWT Maven Archetype</name> - - <properties> - <gwtVersion>2.5.0</gwtVersion> - <smartGwtVersion>3.0</smartGwtVersion> - <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <repositories> - <repository> - <id>smartclient</id> - <name>smartclient.com</name> - <url>http://www.smartclient.com/maven2</url> - </repository> - </repositories> - - <dependencies> - <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-servlet</artifactId> - <version>${gwtVersion}</version> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-user</artifactId> - <version>${gwtVersion}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.7</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>javax.validation</groupId> - <artifactId>validation-api</artifactId> - <version>1.0.0.GA</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>javax.validation</groupId> - <artifactId>validation-api</artifactId> - <version>1.0.0.GA</version> - <classifier>sources</classifier> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.smartgwt</groupId> - <artifactId>smartgwt</artifactId> - <version>${smartGwtVersion}</version> - </dependency> - <dependency> - <groupId>org.gwtopenmaps.openlayers</groupId> - <artifactId>gwt-openlayers-client</artifactId> - <version>0.8</version> - </dependency> - <dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>5.1.21</version> - </dependency> - - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-core</artifactId> - <version>4.1.7.Final</version> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-annotations</artifactId> - <version>3.5.6-Final</version> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-entitymanager</artifactId> - <version>4.1.7.Final</version> - </dependency> - <dependency> - <groupId>org.hibernate.javax.persistence</groupId> - <artifactId>hibernate-jpa-2.0-api</artifactId> - <version>1.0.0.Final</version> - </dependency> - </dependencies> - - <build> - <!-- Generate compiled stuff in the folder used for developing mode --> - <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory> - - <plugins> - - <!-- GWT Maven Plugin --> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>gwt-maven-plugin</artifactId> - <version>2.5.0</version> - <executions> - <execution> - <goals> - <goal>compile</goal> - <goal>test</goal> - <!--<goal>i18n</goal>--> - <!--<goal>generateAsync</goal>--> - </goals> - </execution> - </executions> - <!-- Plugin configuration. There are many available options, see - gwt-maven-plugin documentation at codehaus.org --> - <configuration> - <runTarget>traccar.html</runTarget> - <hostedWebapp>${webappDirectory}</hostedWebapp> - <i18nMessagesBundle>org.traccar.web.client.Messages</i18nMessagesBundle> - </configuration> - </plugin> - - <!-- Copy static web files before executing gwt:run --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <version>2.1.1</version> - <executions> - <execution> - <phase>compile</phase> - <goals> - <goal>exploded</goal> - </goals> - </execution> - </executions> - <configuration> - <webappDirectory>${webappDirectory}</webappDirectory> - </configuration> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>2.3.2</version> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - - <!-- Debug and release configuration --> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.7</version> - <executions> - <execution> - <id>debug</id> - <phase>process-resources</phase> - <configuration> - <target> - <delete - file="${webappDirectory}/WEB-INF/classes/META-INF/persistence.xml" /> - <copy - file="${webappDirectory}/WEB-INF/classes/META-INF/persistence_debug.xml" - tofile="${webappDirectory}/WEB-INF/classes/META-INF/persistence.xml" /> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>release</id> - <phase>prepare-package</phase> - <configuration> - <target> - <delete - file="${webappDirectory}/WEB-INF/classes/META-INF/persistence.xml" /> - <copy - file="${webappDirectory}/WEB-INF/classes/META-INF/persistence_release.xml" - tofile="${webappDirectory}/WEB-INF/classes/META-INF/persistence.xml" /> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> - -</project> diff --git a/src/main/java/org/traccar/web/client/Style.java b/src/main/java/org/traccar/web/client/Style.java deleted file mode 100644 index 4f2c1fd..0000000 --- a/src/main/java/org/traccar/web/client/Style.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.traccar.web.client; - -public class Style { - - public static int getPadding() { - return 10; - } - - public static int getCellPadding() { - return 5; - } - - public static String getNoBorder() { - return "0px"; - } - -} diff --git a/src/main/java/org/traccar/web/client/Traccar.java b/src/main/java/org/traccar/web/client/Traccar.java deleted file mode 100644 index 5ea75cf..0000000 --- a/src/main/java/org/traccar/web/client/Traccar.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.traccar.web.client; - -import java.util.List; - -import org.traccar.web.client.controller.ArchiveController; -import org.traccar.web.client.controller.DeviceController; -import org.traccar.web.client.controller.LoginController; -import org.traccar.web.client.controller.MapController; -import org.traccar.web.client.database.DatabaseService; -import org.traccar.web.client.database.DatabaseServiceAsync; -import org.traccar.web.client.i18n.ApplicationConstants; -import org.traccar.web.shared.model.Device; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.smartgwt.client.util.SC; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.layout.HLayout; -import com.smartgwt.client.widgets.layout.VLayout; - -/** - * Entry point class - */ -public class Traccar implements EntryPoint, LoginController.LoginHandler { - - private static final ApplicationConstants constants = GWT.create(ApplicationConstants.class); - - public static ApplicationConstants getConstants() { - return constants; - } - - private static final DatabaseServiceAsync databaseService = GWT.create(DatabaseService.class); - - public static DatabaseServiceAsync getDatabaseService() { - return databaseService; - } - - /** - * Entry point method - */ - @Override - public void onModuleLoad() { - new LoginController().login(this); - } - - @Override - public void onLogin() { - createLayout(); - } - - private MapController mapController; - private DeviceController deviceController; - private ArchiveController archiveController; - - private void createLayout() { - mapController = new MapController(); - deviceController = new DeviceController(); - deviceController.setHandler(deviceHandler); - archiveController = new ArchiveController(); - - Canvas mainPanel = mapController.getView(); - mainPanel.setWidth("80%"); - - Canvas leftPanel = deviceController.getView(); - leftPanel.setWidth("20%"); - leftPanel.setShowResizeBar(true); - - Canvas bottomPanel = archiveController.getView(); - bottomPanel.setHeight("30%"); - - HLayout topLayout = new HLayout(); - topLayout.setHeight("70%"); - topLayout.addMember(leftPanel); - topLayout.addMember(mainPanel); - topLayout.setShowResizeBar(true); - topLayout.setResizeBarTarget("next"); - - VLayout mainLayout = new VLayout(); - mainLayout.setWidth100(); - mainLayout.setHeight100(); - mainLayout.addMember(topLayout); - mainLayout.addMember(bottomPanel); - - deviceController.setSettingsClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - SC.say("Coming soon..."); - } - }); - - mainLayout.draw(); - } - - DeviceController.DeviceHandler deviceHandler = new DeviceController.DeviceHandler() { - - @Override - public void onChanged(List<Device> devices) { - mapController.update(); - } - - @Override - public void onSelected(Device device) { - mapController.select(device); - } - - }; - -} diff --git a/src/main/java/org/traccar/web/client/controller/ArchiveController.java b/src/main/java/org/traccar/web/client/controller/ArchiveController.java deleted file mode 100644 index acd8252..0000000 --- a/src/main/java/org/traccar/web/client/controller/ArchiveController.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.traccar.web.client.controller; - -import org.traccar.web.client.view.ArchivePanel; - -import com.smartgwt.client.widgets.Canvas; - -public class ArchiveController implements PanelController { - - @Override - public Canvas getView() { - return new ArchivePanel(); - } - -} diff --git a/src/main/java/org/traccar/web/client/controller/DeviceController.java b/src/main/java/org/traccar/web/client/controller/DeviceController.java deleted file mode 100644 index 0c42e8a..0000000 --- a/src/main/java/org/traccar/web/client/controller/DeviceController.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.traccar.web.client.controller; - -import java.util.List; - -import org.traccar.web.client.Traccar; -import org.traccar.web.client.database.BaseAsyncCallback; -import org.traccar.web.client.view.DeviceDialog; -import org.traccar.web.client.view.DevicePanel; -import org.traccar.web.shared.model.Device; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.events.ClickHandler; - -public class DeviceController implements PanelController, DevicePanel.DeviceHandler, DeviceDialog.SaveHandler { - - public interface DeviceHandler { - public void onChanged(List<Device> devices); - public void onSelected(Device device); - } - - private DeviceHandler deviceHandler; - - public void setHandler(DeviceHandler deviceHandler) { - this.deviceHandler = deviceHandler; - } - - private final DevicePanel devicePanel; - - public DeviceController() { - devicePanel = new DevicePanel(); - devicePanel.setDeviceHandler(this); - Traccar.getDatabaseService().getDevices(updateCallback); - } - - @Override - public Canvas getView() { - return devicePanel; - } - - public void setSettingsClickHandler(ClickHandler handler) { - if (devicePanel != null) { - devicePanel.setSettingsClickHandler(handler); - } - } - - DeviceDialog dialog; - - @Override - public void onAdd() { - onEdit(new Device()); - } - - @Override - public void onEdit(Device device) { - dialog = new DeviceDialog(); - dialog.setSaveHandler(this); - dialog.setDevice(device); - dialog.draw(); - dialog.centerInPage(); - } - - @Override - public void onRemove(Device device) { - Traccar.getDatabaseService().removeDevice(device, saveCallback); - } - - @Override - public void onSelected(Device device) { - if (deviceHandler != null) { - deviceHandler.onSelected(device); - } - } - - @Override - public void onSave(Device device) { - Traccar.getDatabaseService().storeDevice(device, saveCallback); - } - - private AsyncCallback<Boolean> saveCallback = new BaseAsyncCallback<Boolean>() { - @Override - public void onSuccess(Boolean result) { - if (result) { - if (dialog != null) { - dialog.destroy(); - dialog = null; - } - Traccar.getDatabaseService().getDevices(updateCallback); - } - } - }; - - private AsyncCallback<List<Device>> updateCallback = new BaseAsyncCallback<List<Device>>() { - @Override - public void onSuccess(List<Device> result) { - devicePanel.updateDevices(result); - if (deviceHandler != null) { - deviceHandler.onChanged(result); - } - } - }; -} diff --git a/src/main/java/org/traccar/web/client/controller/LoginController.java b/src/main/java/org/traccar/web/client/controller/LoginController.java deleted file mode 100644 index b3193a1..0000000 --- a/src/main/java/org/traccar/web/client/controller/LoginController.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.traccar.web.client.controller; - -import org.traccar.web.client.Traccar; -import org.traccar.web.client.database.BaseAsyncCallback; -import org.traccar.web.client.view.LoginDialog; - -import com.smartgwt.client.util.SC; - -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; - - Traccar.getDatabaseService().authenticated(new BaseAsyncCallback<Boolean>() { - @Override - public void onSuccess(Boolean result) { - - if (result) { - loginHandler.onLogin(); - } else { - dialog = new LoginDialog(); - dialog.setLoginHandler(LoginController.this); - dialog.draw(); - dialog.centerInPage(); - } - } - }); - } - - private boolean validate(String login, String password) { - if (login == null || login.isEmpty() || password == null || password.isEmpty()) { - SC.warn(Traccar.getConstants().blankLoginPassword()); - return false; - } - return true; - } - - @Override - public void onLogin(String login, String password) { - if (validate(login, password)) { - Traccar.getDatabaseService().authenticate(login, password, new BaseAsyncCallback<Boolean>() { - @Override - public void onSuccess(Boolean result) { - if (result) { - if (loginHandler != null) { - dialog.destroy(); - loginHandler.onLogin(); - } - } else { - SC.warn(Traccar.getConstants().invalidLoginPassword()); - } - } - }); - } - } - - @Override - public void onRegister(String login, String password) { - if (validate(login, password)) { - Traccar.getDatabaseService().register(login, password, new BaseAsyncCallback<Boolean>() { - @Override - public void onSuccess(Boolean result) { - if (result) { - if (loginHandler != null) { - dialog.destroy(); - loginHandler.onLogin(); - } - } else { - SC.warn(Traccar.getConstants().registrationError()); - } - } - }); - } - } - -} diff --git a/src/main/java/org/traccar/web/client/controller/MapController.java b/src/main/java/org/traccar/web/client/controller/MapController.java deleted file mode 100644 index 8932050..0000000 --- a/src/main/java/org/traccar/web/client/controller/MapController.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.traccar.web.client.controller; - -import java.util.List; - -import org.traccar.web.client.Traccar; -import org.traccar.web.client.view.MapPanel; -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.smartgwt.client.widgets.Canvas; - -public class MapController implements PanelController { - - private static final int UPDATE_INTERVAL = 10000; - - private final MapPanel mapPanel; - - private final Timer updateTimer; - - public MapController() { - mapPanel = new MapPanel(); - updateTimer = new Timer() { - @Override - public void run() { - update(); - } - }; - update(); - } - - @Override - public Canvas getView() { - return mapPanel; - } - - public void select(Device device) { - mapPanel.select(device, true); - } - - public void update() { - updateTimer.cancel(); - Traccar.getDatabaseService().getLatestPositions(new AsyncCallback<List<Position>>() { - @Override - public void onSuccess(List<Position> result) { - mapPanel.showPositions(result); - updateTimer.schedule(UPDATE_INTERVAL); - } - @Override - public void onFailure(Throwable caught) { - updateTimer.schedule(UPDATE_INTERVAL); - } - }); - } - -} diff --git a/src/main/java/org/traccar/web/client/controller/PanelController.java b/src/main/java/org/traccar/web/client/controller/PanelController.java deleted file mode 100644 index 6f2492a..0000000 --- a/src/main/java/org/traccar/web/client/controller/PanelController.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.traccar.web.client.controller; - -import com.smartgwt.client.widgets.Canvas; - -public interface PanelController { - - Canvas getView(); - -} diff --git a/src/main/java/org/traccar/web/client/database/BaseAsyncCallback.java b/src/main/java/org/traccar/web/client/database/BaseAsyncCallback.java deleted file mode 100644 index bcc8c37..0000000 --- a/src/main/java/org/traccar/web/client/database/BaseAsyncCallback.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.traccar.web.client.database; - -import org.traccar.web.client.Traccar; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.util.SC; - -public class BaseAsyncCallback<T> implements AsyncCallback<T> { - - @Override - public void onFailure(Throwable caught) { - SC.warn(Traccar.getConstants().remoteProcedureCallError()); - } - - @Override - public void onSuccess(T result) { - } - -} diff --git a/src/main/java/org/traccar/web/client/database/DatabaseService.java b/src/main/java/org/traccar/web/client/database/DatabaseService.java deleted file mode 100644 index 4e68181..0000000 --- a/src/main/java/org/traccar/web/client/database/DatabaseService.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.traccar.web.client.database; - -import java.util.Date; -import java.util.List; - -import org.traccar.web.shared.model.Device; -import org.traccar.web.shared.model.Position; - -import com.google.gwt.user.client.rpc.RemoteService; -import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; - -@RemoteServiceRelativePath("databaseService") -public interface DatabaseService extends RemoteService { - - boolean authenticated(); - - boolean authenticate(String login, String password); - - boolean register(String login, String password); - - List<Device> getDevices(); - - boolean storeDevice(Device device); - - boolean removeDevice(Device device); - - List<Position> getPositions(Device device, Date from, Date to); - - List<Position> getLatestPositions(); - -} diff --git a/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java b/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java deleted file mode 100644 index 809574d..0000000 --- a/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.traccar.web.client.database; - -import java.util.Date; -import java.util.List; - -import org.traccar.web.shared.model.Device; -import org.traccar.web.shared.model.Position; - -import com.google.gwt.user.client.rpc.AsyncCallback; - -public interface DatabaseServiceAsync { - - void authenticated(AsyncCallback<Boolean> callback); - - void authenticate(String login, String password, AsyncCallback<Boolean> callback); - - void register(String login, String password, AsyncCallback<Boolean> callback); - - void getDevices(AsyncCallback<List<Device>> callback); - - void storeDevice(Device device, AsyncCallback<Boolean> callback); - - void removeDevice(Device device, AsyncCallback<Boolean> callback); - - void getPositions(Device device, Date from, Date to, AsyncCallback<List<Position>> callback); - - void getLatestPositions(AsyncCallback<List<Position>> callback); - -} diff --git a/src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java b/src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java deleted file mode 100644 index 41f3764..0000000 --- a/src/main/java/org/traccar/web/client/i18n/ApplicationConstants.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.traccar.web.client.i18n; - -import com.google.gwt.i18n.client.Constants; - -public interface ApplicationConstants extends Constants { - - @DefaultStringValue("User Authentication") - String userAuthentication(); - - @DefaultStringValue("Login") - String login(); - - @DefaultStringValue("Password") - String password(); - - @DefaultStringValue("Register") - String register(); - - @DefaultStringValue("Login and password fields must not be blank") - String blankLoginPassword(); - - @DefaultStringValue("Remote procedure call error") - String remoteProcedureCallError(); - - @DefaultStringValue("Invalid login or password") - String invalidLoginPassword(); - - @DefaultStringValue("Registration failed") - String registrationError(); - - @DefaultStringValue("Devices") - String devices(); - - @DefaultStringValue("Device") - String device(); - - @DefaultStringValue("Add") - String add(); - - @DefaultStringValue("Remove") - String remove(); - - @DefaultStringValue("Edit") - String edit(); - - @DefaultStringValue("Settings") - String settings(); - - @DefaultStringValue("Are you sure you want to remove selected device?") - String removeDeviceConfirmation(); - - @DefaultStringValue("Object") - String object(); - - @DefaultStringValue("Unique Identifier") - String uniqueId(); - - @DefaultStringValue("Name") - String name(); - - @DefaultStringValue("Save") - String save(); - - @DefaultStringValue("Cancel") - String cancel(); - - @DefaultStringValue("Mapnik") - String mapnik(); - - @DefaultStringValue("Markers") - String markers(); - - @DefaultStringValue("Map") - String map(); - -} diff --git a/src/main/java/org/traccar/web/client/view/ArchivePanel.java b/src/main/java/org/traccar/web/client/view/ArchivePanel.java deleted file mode 100644 index 3929be2..0000000 --- a/src/main/java/org/traccar/web/client/view/ArchivePanel.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.traccar.web.client.view; - -import com.smartgwt.client.widgets.form.fields.DateTimeItem; -import com.smartgwt.client.widgets.form.fields.SelectItem; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.layout.SectionStack; -import com.smartgwt.client.widgets.layout.SectionStackSection; -import com.smartgwt.client.widgets.toolbar.ToolStrip; -import com.smartgwt.client.widgets.toolbar.ToolStripButton; - -/** - * Archive widget - */ -public class ArchivePanel extends SectionStack { - - private ToolStrip toolbar; - private ListGrid list; - - public ArchivePanel() { - SectionStackSection section = new SectionStackSection("Archive"); - section.setCanCollapse(false); - section.setExpanded(true); - - toolbar = new ToolStrip(); - toolbar.setWidth100(); - - SelectItem deviceSelect = new SelectItem("device", "Device"); - //fontItem.setShowTitle(false); - //fontItem.setWidth(120); - toolbar.addFormItem(deviceSelect); - toolbar.addSeparator(); - - DateTimeItem from = new DateTimeItem("from", "From"); - toolbar.addFormItem(from); - toolbar.addSeparator(); - DateTimeItem to = new DateTimeItem("to", "To"); - toolbar.addFormItem(to); - toolbar.addSeparator(); - - ToolStripButton button = new ToolStripButton(); - button.setTitle("Load"); - toolbar.addButton(button); - - list = new ListGrid(); - list.setFields( - new ListGridField("deviceId", "Device Id"), - new ListGridField("time", "Time"), - new ListGridField("valid", "Valid"), - new ListGridField("latitude", "Latitude"), - new ListGridField("longitude", "Longitude"), - new ListGridField("speed", "Speed"), - new ListGridField("course", "Course"), - new ListGridField("power", "Power")); - - list.setCanSort(false); - list.setShowHeaderContextMenu(false); - list.setShowHeaderMenuButton(false); - - section.setItems(toolbar, list); - setSections(section); - } - -} diff --git a/src/main/java/org/traccar/web/client/view/DeviceDialog.java b/src/main/java/org/traccar/web/client/view/DeviceDialog.java deleted file mode 100644 index 119564a..0000000 --- a/src/main/java/org/traccar/web/client/view/DeviceDialog.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.traccar.web.client.view; - -import org.traccar.web.client.Style; -import org.traccar.web.client.Traccar; -import org.traccar.web.shared.model.Device; - -import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.widgets.IButton; -import com.smartgwt.client.widgets.Window; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.TextItem; -import com.smartgwt.client.widgets.form.fields.ToolbarItem; -import com.smartgwt.client.widgets.layout.Layout; - -public class DeviceDialog extends Window { - - public interface SaveHandler { - public void onSave(Device device); - } - - private SaveHandler saveHandler; - - public void setSaveHandler(SaveHandler saveHandler) { - this.saveHandler = saveHandler; - } - - private Device device; - - TextItem nameEdit; - TextItem uniqueIdEdit; - - public void setDevice(Device device) { - this.device = device; - nameEdit.setValue(device.getName()); - uniqueIdEdit.setValue(device.getUniqueId()); - } - - public DeviceDialog() { - setTitle(Traccar.getConstants().device()); - setAutoSize(true); - setIsModal(true); - - // Form - final DynamicForm form = new DynamicForm(); - form.setHeight100(); - form.setWidth100(); - - nameEdit = new TextItem(); - nameEdit.setTitle(Traccar.getConstants().name()); - uniqueIdEdit = new TextItem(); - uniqueIdEdit.setTitle(Traccar.getConstants().uniqueId()); - - final ToolbarItem toolbarItem = new ToolbarItem(); - toolbarItem.setButtons( - new IButton(Traccar.getConstants().save(), new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (saveHandler != null) { - device.setName(nameEdit.getValueAsString()); - device.setUniqueId(uniqueIdEdit.getValueAsString()); - saveHandler.onSave(device); - } - } - }), - new IButton(Traccar.getConstants().cancel(), new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - destroy(); - } - })); - toolbarItem.setAlign(Alignment.RIGHT); - toolbarItem.setColSpan(3); - - form.setFields(nameEdit, uniqueIdEdit, toolbarItem); - form.setCellPadding(Style.getCellPadding()); - - final Layout layout = new Layout(); - layout.setPadding(Style.getPadding()); - - layout.addMember(form); - - addItem(layout); - } - -} diff --git a/src/main/java/org/traccar/web/client/view/DevicePanel.java b/src/main/java/org/traccar/web/client/view/DevicePanel.java deleted file mode 100644 index 11a3bc3..0000000 --- a/src/main/java/org/traccar/web/client/view/DevicePanel.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.traccar.web.client.view; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.traccar.web.client.Traccar; -import org.traccar.web.shared.model.Device; - -import com.smartgwt.client.data.Record; -import com.smartgwt.client.util.BooleanCallback; -import com.smartgwt.client.util.SC; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; -import com.smartgwt.client.widgets.grid.events.SelectionEvent; -import com.smartgwt.client.widgets.layout.SectionStack; -import com.smartgwt.client.widgets.layout.SectionStackSection; -import com.smartgwt.client.widgets.toolbar.ToolStrip; -import com.smartgwt.client.widgets.toolbar.ToolStripButton; - -/** - * Device list widget - */ -public class DevicePanel extends SectionStack { - - private static final String COLUMN_ID = "id"; - private static final String COLUMN_NAME = "name"; - private static final String COLUMN_UNIQUE_ID = "uniqueId"; - - public interface DeviceHandler { - public void onAdd(); - public void onEdit(Device device); - public void onRemove(Device device); - public void onSelected(Device device); - } - - private DeviceHandler deviceHandler; - - public void setDeviceHandler(DeviceHandler deviceHandler) { - this.deviceHandler = deviceHandler; - } - - ToolStripButton addButton; - ToolStripButton removeButton; - ToolStripButton editButton; - private ToolStripButton settingsButton; - - private ListGrid list; - - private Map<Long, Device> deviceMap = new HashMap<Long, Device>(); - - public DevicePanel() { - SectionStackSection section = new SectionStackSection(Traccar.getConstants().devices()); - section.setCanCollapse(false); - section.setExpanded(true); - - ToolStrip toolbar = new ToolStrip(); - toolbar.setWidth100(); - - addButton = new ToolStripButton(); - addButton.setTitle(Traccar.getConstants().add()); - addButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (deviceHandler != null) { - deviceHandler.onAdd(); - } - } - }); - - removeButton = new ToolStripButton(); - removeButton.setTitle(Traccar.getConstants().remove()); - removeButton.setVisible(false); - removeButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - SC.ask(Traccar.getConstants().removeDeviceConfirmation(), new BooleanCallback() { - @Override - public void execute(Boolean value) { - if (value && deviceHandler != null && list.anySelected()) { - deviceHandler.onRemove(deviceMap.get(list.getSelectedRecord().getAttributeAsLong(COLUMN_ID))); - } - } - }); - } - }); - - editButton = new ToolStripButton(); - editButton.setVisible(false); - editButton.setTitle(Traccar.getConstants().edit()); - editButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (deviceHandler != null && list.anySelected()) { - deviceHandler.onEdit(deviceMap.get(list.getSelectedRecord().getAttributeAsLong(COLUMN_ID))); - } - } - }); - - toolbar.addButton(addButton); - toolbar.addButton(removeButton); - toolbar.addButton(editButton); - - toolbar.addFill(); - toolbar.addSeparator(); - - settingsButton = new ToolStripButton(); - settingsButton.setTitle(Traccar.getConstants().settings()); - toolbar.addButton(settingsButton); - - list = new ListGrid(); - list.setFields( - new ListGridField(COLUMN_NAME, Traccar.getConstants().name()), - new ListGridField(COLUMN_UNIQUE_ID, Traccar.getConstants().uniqueId())); - - list.setCanSort(false); - list.setShowHeaderContextMenu(false); - list.setShowHeaderMenuButton(false); - - list.addSelectionChangedHandler(new SelectionChangedHandler() { - @Override - public void onSelectionChanged(SelectionEvent event) { - removeButton.setVisible(list.anySelected()); - editButton.setVisible(list.anySelected()); - if (deviceHandler != null) { - if (list.anySelected()) { - deviceHandler.onSelected(deviceMap.get(list.getSelectedRecord().getAttributeAsLong(COLUMN_ID))); - } else { - deviceHandler.onSelected(null); - } - } - } - }); - - section.setItems(toolbar, list); - setSections(section); - } - - public void setSettingsClickHandler(ClickHandler handler) { - settingsButton.addClickHandler(handler); - } - - public void updateDevices(List<Device> devices) { - deviceMap.clear(); - for (Record record : list.getRecords()) { - list.removeData(record); - } - removeButton.setVisible(list.anySelected()); - editButton.setVisible(list.anySelected()); - - for (Device device : devices) { - deviceMap.put(device.getId(), device); - - Map<String, Object> map = new HashMap<String, Object>(); - map.put(COLUMN_ID, device.getId()); - map.put(COLUMN_NAME, device.getName()); - map.put(COLUMN_UNIQUE_ID, device.getUniqueId()); - - Record record = new Record(map); - list.addData(record); - } - } - -} diff --git a/src/main/java/org/traccar/web/client/view/LoginDialog.java b/src/main/java/org/traccar/web/client/view/LoginDialog.java deleted file mode 100644 index 625a29b..0000000 --- a/src/main/java/org/traccar/web/client/view/LoginDialog.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.traccar.web.client.view; - -import org.traccar.web.client.Style; -import org.traccar.web.client.Traccar; - -import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.widgets.IButton; -import com.smartgwt.client.widgets.Window; -import com.smartgwt.client.widgets.events.ClickEvent; -import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.PasswordItem; -import com.smartgwt.client.widgets.form.fields.TextItem; -import com.smartgwt.client.widgets.form.fields.ToolbarItem; -import com.smartgwt.client.widgets.layout.Layout; - -public class LoginDialog extends Window { - - public interface LoginHandler { - public void onLogin(String login, String password); - public void onRegister(String login, String password); - } - - private LoginHandler loginHandler; - - public void setLoginHandler(LoginHandler loginHandler) { - this.loginHandler = loginHandler; - } - - public LoginDialog() { - - // Window properties - setTitle(Traccar.getConstants().userAuthentication()); - setShowCloseButton(false); - setShowMinimizeButton(false); - setAutoSize(true); - setIsModal(true); - - // Login form - final DynamicForm form = new DynamicForm(); - form.setHeight100(); - form.setWidth100(); - final TextItem loginEdit = new TextItem(); - loginEdit.setTitle(Traccar.getConstants().login()); - final PasswordItem passwordEdit = new PasswordItem(); - passwordEdit.setTitle(Traccar.getConstants().password()); - - final ToolbarItem toolbarItem = new ToolbarItem(); - toolbarItem.setButtons( - new IButton(Traccar.getConstants().login(), new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (loginHandler != null) { - loginHandler.onLogin( - loginEdit.getValueAsString(), passwordEdit.getValueAsString()); - } - } - }), - new IButton(Traccar.getConstants().register(), new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (loginHandler != null) { - loginHandler.onRegister( - loginEdit.getValueAsString(), passwordEdit.getValueAsString()); - } - } - })); - toolbarItem.setAlign(Alignment.RIGHT); - toolbarItem.setColSpan(3); - - form.setFields(loginEdit, passwordEdit, toolbarItem); - form.setCellPadding(Style.getCellPadding()); - - final Layout layout = new Layout(); - layout.setPadding(Style.getPadding()); - - layout.addMember(form); - - addItem(layout); - } - -} diff --git a/src/main/java/org/traccar/web/client/view/MapPanel.java b/src/main/java/org/traccar/web/client/view/MapPanel.java deleted file mode 100644 index 4a2ea94..0000000 --- a/src/main/java/org/traccar/web/client/view/MapPanel.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.traccar.web.client.view; - -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.List; - -import org.gwtopenmaps.openlayers.client.Icon; -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.Marker; -import org.gwtopenmaps.openlayers.client.Pixel; -import org.gwtopenmaps.openlayers.client.Projection; -import org.gwtopenmaps.openlayers.client.Size; -import org.gwtopenmaps.openlayers.client.control.ScaleLine; -import org.gwtopenmaps.openlayers.client.layer.Markers; -import org.gwtopenmaps.openlayers.client.layer.OSM; -import org.traccar.web.client.Traccar; -import org.traccar.web.shared.model.Device; -import org.traccar.web.shared.model.Position; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.smartgwt.client.widgets.WidgetCanvas; -import com.smartgwt.client.widgets.events.DrawEvent; -import com.smartgwt.client.widgets.events.DrawHandler; -import com.smartgwt.client.widgets.events.ResizedEvent; -import com.smartgwt.client.widgets.events.ResizedHandler; -import com.smartgwt.client.widgets.layout.SectionStack; -import com.smartgwt.client.widgets.layout.SectionStackSection; - - -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://www.openlayers.org/api/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 Icon getLocationIcon() { - return new Icon(iconRed, iconSize, iconOffset); - } - - public static Icon getSelectedLocationIcon() { - return new Icon(iconGreen, iconSize, iconOffset); - } - - public static Icon getArchiveIcon() { - return new Icon(iconBlue, iconSize, iconOffset); - } - - public static Icon getSelectedArchiveIcon() { - return new Icon(iconGold, iconSize, iconOffset); - } - -} - -/** - * Map panel widget - */ -public class MapPanel extends SectionStack { - - private MapWidget mapWidget; - private Map map; - private WidgetCanvas mapWrapper; - private Markers markerLayer; - - private LonLat createPoint(double longitude, double latitude) { - LonLat point = new LonLat(longitude, latitude); - point.transform(new Projection("EPSG:4326").getProjectionCode(), map.getProjection()); - return point; - } - - private void createMapWidget() { - MapOptions defaultMapOptions = new MapOptions(); - defaultMapOptions.setNumZoomLevels(16); - - mapWidget = new MapWidget("100%", "100%", defaultMapOptions); - map = mapWidget.getMap(); - - OSM mapLayer = OSM.Mapnik(Traccar.getConstants().mapnik()); - mapLayer.setIsBaseLayer(true); - - markerLayer = new Markers(Traccar.getConstants().markers()); - - map.addLayer(mapLayer); - map.addLayer(markerLayer); - map.addControl(new ScaleLine()); - - map.setCenter(createPoint(12.5, 41.9), 1); - } - - public SectionStackSection section; - - public MapPanel() { - section = new SectionStackSection(Traccar.getConstants().map()); - section.setShowHeader(false); - section.setCanCollapse(false); - section.setExpanded(true); - - createMapWidget(); - - mapWrapper = new WidgetCanvas(mapWidget); - mapWrapper.setStyleName("defaultBorder"); - mapWrapper.setHeight100(); - mapWrapper.setWidth100(); - - // Map widget size hack - mapWrapper.addDrawHandler(new DrawHandler() { - @Override - public void onDraw(DrawEvent event) { - Element e = DOM.getElementById(mapWrapper.getID() + "_widget"); - if (e.getParentNode() != null) { - e.getParentElement().getStyle().setProperty("width", "100%"); - e.getParentElement().getStyle().setProperty("height", "100%"); - } - } - }); - - // Map resize handler - mapWrapper.addResizedHandler(new ResizedHandler() { - @Override - public void onResized(ResizedEvent event) { - map.updateSize(); - } - }); - - section.setItems(mapWrapper); - setSections(section); - } - - private AbstractMap<Device, Position> positionMap = new HashMap<Device, Position>(); - private AbstractMap<Device, Marker> markerMap = new HashMap<Device, Marker>(); - private Device selectedDevice; - - public void showPositions(List<Position> positions) { - positionMap.clear(); - markerMap.clear(); - markerLayer.clearMarkers(); - for (Position position : positions) { - positionMap.put(position.getDevice(), position); - Marker marker = new Marker( - createPoint(position.getLongitude(), position.getLatitude()), MarkerIconFactory.getLocationIcon()); - markerMap.put(position.getDevice(), marker); - markerLayer.addMarker(marker); - } - if (selectedDevice != null) { - select(selectedDevice, false); - } - } - - private void changeMarkerIcon(Marker marker, Icon icon) { - Marker newMarker = new Marker(marker.getLonLat(), icon); - markerLayer.removeMarker(marker); - markerLayer.addMarker(newMarker); - } - - public void select(Device device, boolean center) { - if (selectedDevice != null) { - changeMarkerIcon(markerMap.get(selectedDevice), MarkerIconFactory.getLocationIcon()); - } - if (device != null) { - Marker marker = markerMap.get(device); - if (center) { - map.panTo(marker.getLonLat()); - } - changeMarkerIcon(marker, MarkerIconFactory.getSelectedLocationIcon()); - } - selectedDevice = device; - } - -} diff --git a/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java b/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java deleted file mode 100644 index d466262..0000000 --- a/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java +++ /dev/null @@ -1,149 +0,0 @@ -package org.traccar.web.server.database; - -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.Persistence; -import javax.persistence.TypedQuery; -import javax.servlet.ServletException; -import javax.servlet.http.HttpSession; - -import org.traccar.web.client.database.DatabaseService; -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 DatabaseServiceImpl extends RemoteServiceServlet implements DatabaseService { - - private static final long serialVersionUID = 1; - - private static final String PERSISTENCE_UNIT = "traccar"; - private static final String ATTRIBUTE_USER = "user"; - - private EntityManager entityManager; - - @Override - public void init() throws ServletException { - super.init(); - entityManager = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT).createEntityManager(); - } - - private void setUser(User user) { - HttpSession session = getThreadLocalRequest().getSession(); - session.setAttribute(ATTRIBUTE_USER, user); - } - - private User getUser() { - HttpSession session = getThreadLocalRequest().getSession(); - return (User) session.getAttribute(ATTRIBUTE_USER); - } - - @Override - public boolean authenticated() { - return (getUser() != null); - } - - @Override - public boolean authenticate(String login, String password) { - TypedQuery<User> query = entityManager.createQuery( - "SELECT x FROM User x WHERE x.login = :login", User.class); - query.setParameter("login", login); - List<User> results = query.getResultList(); - - if (!results.isEmpty() && password.equals(results.get(0).getPassword())) { - setUser(results.get(0)); - return true; - } - return false; - } - - @Override - public boolean register(String login, String password) { - User user = new User(); - user.setLogin(login); - user.setPassword(password); - entityManager.getTransaction().begin(); - try { - entityManager.persist(user); - } finally { - entityManager.getTransaction().commit(); - } - setUser(user); - return true; - } - - @Override - public List<Device> getDevices() { - User user = getUser(); - List<Device> devices = new LinkedList<Device>(); - for (Device device : user.getDevices()) { - devices.add(device); - } - return devices; - } - - @Override - public boolean storeDevice(Device device) { - User user = getUser(); - boolean isNew = device.getId() == 0; - entityManager.getTransaction().begin(); - try { - device = entityManager.merge(device); - if (isNew) { - user.getDevices().add(device); - } - } finally { - entityManager.getTransaction().commit(); - } - return true; - } - - @Override - public boolean removeDevice(Device device) { - User user = getUser(); - entityManager.getTransaction().begin(); - try { - device = entityManager.merge(device); - user.getDevices().remove(device); - entityManager.remove(device); - } finally { - entityManager.getTransaction().commit(); - } - return true; - } - - @Override - public List<Position> getPositions(Device device, Date from, Date to) { - TypedQuery<Position> query = entityManager.createQuery( - "SELECT x FROM Position x WHERE x.device = :device AND x.time BETWEEN :from AND :to", Position.class); - query.setParameter("device", device); - query.setParameter("from", from); - query.setParameter("to", to); - - List<Position> positions = new LinkedList<Position>(); - for (Position position : query.getResultList()) { - positions.add(position); - } - return positions; - } - - @Override - public List<Position> getLatestPositions() { - User user = getUser(); - TypedQuery<Position> query = entityManager.createQuery( - "SELECT x FROM Position x WHERE (x.device, x.time) IN (" + - "SELECT y.device, MAX(y.time) FROM Position y WHERE y.device IN :devices GROUP BY y.device)", Position.class); - query.setParameter("devices", user.getDevices()); - - List<Position> positions = new LinkedList<Position>(); - for (Position position : query.getResultList()) { - positions.add(position); - } - return positions; - } - -} diff --git a/src/main/java/org/traccar/web/shared/model/Device.java b/src/main/java/org/traccar/web/shared/model/Device.java deleted file mode 100644 index 32f1c1f..0000000 --- a/src/main/java/org/traccar/web/shared/model/Device.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.traccar.web.shared.model; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "devices") -public class Device implements Serializable { - - private static final long serialVersionUID = 1; - - @Override - public boolean equals(Object obj) { - if (obj == null || obj.getClass() != this.getClass()) { - return false; - } - return id == ((Device) obj).id; - } - - @Override - public int hashCode() { - return (int) id; - } - - public Device() { - } - - // Constructor for testing - public Device(long id) { - this.id = id; - } - - @Id - @GeneratedValue - private long id; - - public long getId() { - return id; - } - - @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/main/java/org/traccar/web/shared/model/Position.java b/src/main/java/org/traccar/web/shared/model/Position.java deleted file mode 100644 index 69181df..0000000 --- a/src/main/java/org/traccar/web/shared/model/Position.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.traccar.web.shared.model; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Entity; -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 { - - private static final long serialVersionUID = 1; - - public Position() { - } - - @Id - @GeneratedValue - private long id; - - @ManyToOne - @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/main/java/org/traccar/web/shared/model/User.java b/src/main/java/org/traccar/web/shared/model/User.java deleted file mode 100644 index 181a09b..0000000 --- a/src/main/java/org/traccar/web/shared/model/User.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.traccar.web.shared.model; - -import java.io.Serializable; -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.Table; - -@Entity -@Table(name="users") -public class User implements Serializable { - - private static final long serialVersionUID = 1; - - public User() { - } - - @Id - @GeneratedValue - private long 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; - } - - @ManyToMany - private List<Device> devices; - - public List<Device> getDevices() { - return devices; - } - -} diff --git a/src/main/resources/META-INF/persistence_debug.xml b/src/main/resources/META-INF/persistence_debug.xml deleted file mode 100644 index a070dfa..0000000 --- a/src/main/resources/META-INF/persistence_debug.xml +++ /dev/null @@ -1,17 +0,0 @@ -<persistence xmlns="http://java.sun.com/xml/ns/persistence" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" - version="2.0"> - <persistence-unit name="traccar"> - <!--<jta-data-source>java:/DefaultDS</jta-data-source>--> - <properties> - <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> - <property name="hibernate.connection.url" value="jdbc:mysql://localhost/test"/> - <property name="hibernate.connection.username" value="root"/> - <property name="hibernate.connection.password" value="root"/> - <property name="hibernate.show_sql" value="true"/> - <!--<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>--> - <property name="hibernate.hbm2ddl.auto" value="validate"/> - </properties> - </persistence-unit> -</persistence> diff --git a/src/main/resources/META-INF/persistence_release.xml b/src/main/resources/META-INF/persistence_release.xml deleted file mode 100644 index dc5ac2d..0000000 --- a/src/main/resources/META-INF/persistence_release.xml +++ /dev/null @@ -1,12 +0,0 @@ -<persistence xmlns="http://java.sun.com/xml/ns/persistence" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" - version="2.0"> - <persistence-unit name="traccar"> - <jta-data-source>java:/DefaultDS</jta-data-source> - <properties> - <property name="hibernate.show_sql" value="true"/> - <property name="hibernate.hbm2ddl.auto" value="validate"/> - </properties> - </persistence-unit> -</persistence> diff --git a/src/main/resources/org/traccar/web/Traccar.gwt.xml b/src/main/resources/org/traccar/web/Traccar.gwt.xml deleted file mode 100644 index 086d2a4..0000000 --- a/src/main/resources/org/traccar/web/Traccar.gwt.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module rename-to='Traccar'> - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name='com.google.gwt.user.User' /> - - <!-- We need the JUnit module in the main module, --> - <!-- otherwise eclipse complains (Google plugin bug?) --> - <inherits name='com.google.gwt.junit.JUnit' /> - - <!-- Inherit the default GWT style sheet. You can change --> - <!-- the theme of your GWT application by uncommenting --> - <!-- any one of the following lines. --> - <!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> --> - <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> - <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> - - <!-- Other module inherits --> - <inherits name='com.smartgwt.SmartGwt' /> - <inherits name='org.gwtopenmaps.openlayers.OpenLayers' /> - - <!-- Specify the app entry point class. --> - <entry-point class='org.traccar.web.client.Traccar' /> - - <!-- Specify the paths for translatable code --> - <source path='client' /> - <source path='shared' /> - -</module> diff --git a/src/main/webapp/WEB-INF/classes/org/traccar/web/Traccar.gwt.xml b/src/main/webapp/WEB-INF/classes/org/traccar/web/Traccar.gwt.xml deleted file mode 100644 index 086d2a4..0000000 --- a/src/main/webapp/WEB-INF/classes/org/traccar/web/Traccar.gwt.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module rename-to='Traccar'> - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name='com.google.gwt.user.User' /> - - <!-- We need the JUnit module in the main module, --> - <!-- otherwise eclipse complains (Google plugin bug?) --> - <inherits name='com.google.gwt.junit.JUnit' /> - - <!-- Inherit the default GWT style sheet. You can change --> - <!-- the theme of your GWT application by uncommenting --> - <!-- any one of the following lines. --> - <!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> --> - <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> - <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> - - <!-- Other module inherits --> - <inherits name='com.smartgwt.SmartGwt' /> - <inherits name='org.gwtopenmaps.openlayers.OpenLayers' /> - - <!-- Specify the app entry point class. --> - <entry-point class='org.traccar.web.client.Traccar' /> - - <!-- Specify the paths for translatable code --> - <source path='client' /> - <source path='shared' /> - -</module> diff --git a/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages.properties b/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages.properties deleted file mode 100644 index c222555..0000000 --- a/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -sendButton = Send -nameField = Enter your name
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages_fr.properties b/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages_fr.properties deleted file mode 100644 index b4a7627..0000000 --- a/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages_fr.properties +++ /dev/null @@ -1,2 +0,0 @@ -sendButton = Envoyer -nameField = Entrez votre nom
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 5c46f87..0000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE web-app - PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/dtd/web-app_2_3.dtd"> - -<web-app> - - <!--<security-role> - <role-name>admin</role-name> - </security-role> - <security-role> - <role-name>user</role-name> - <security-role>--> - - <!--<security-constraint> - <web-resource-collection> - <url-pattern>/*</url-pattern> - </web-resource-collection> - <auth-constraint> - <role-name>admin</role-name> - <role-name>user</role-name> - </auth-constraint> - </security-constraint> - - <login-config> - <auth-method>BASIC</auth-method> - </login-config>--> - - <servlet> - <servlet-name>databaseService</servlet-name> - <servlet-class>org.traccar.web.server.database.DatabaseServiceImpl</servlet-class> - </servlet> - - <servlet-mapping> - <servlet-name>databaseService</servlet-name> - <url-pattern>/Traccar/databaseService</url-pattern> - </servlet-mapping> - - <welcome-file-list> - <welcome-file>traccar.html</welcome-file> - </welcome-file-list> - -</web-app> diff --git a/src/main/webapp/traccar.html b/src/main/webapp/traccar.html deleted file mode 100644 index 0bac1a4..0000000 --- a/src/main/webapp/traccar.html +++ /dev/null @@ -1,20 +0,0 @@ -<!doctype html> -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <title>Traccar</title> - <!--<script src="http://openlayers.org/api/2.11/OpenLayers.js"></script>--> - <script src="http://www.openlayers.org/api/OpenLayers.js"></script> - <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script> - <!--<script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>--> - <script type="text/javascript" language="javascript" src="Traccar/Traccar.nocache.js"></script> - </head> - <body> - <noscript> - <div> - Your web browser must have JavaScript enabled - in order for this application to display correctly. - </div> - </noscript> - </body> -</html> diff --git a/src/test/java/org/traccar/web/client/GwtTestTraccar.java b/src/test/java/org/traccar/web/client/GwtTestTraccar.java deleted file mode 100644 index 5564ee7..0000000 --- a/src/test/java/org/traccar/web/client/GwtTestTraccar.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.traccar.web.client; - -import com.google.gwt.junit.client.GWTTestCase; - -/** - * GWT JUnit <b>integration</b> tests must extend GWTTestCase. - * Using <code>"GwtTest*"</code> naming pattern exclude them from running with - * surefire during the test phase. - * - * If you run the tests using the Maven command line, you will have to - * navigate with your browser to a specific url given by Maven. - * See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html - * for details. - */ -public class GwtTestTraccar extends GWTTestCase { - - /** - * Must refer to a valid module that sources this class. - */ - @Override - public String getModuleName() { - return "org.traccar.web.TraccarJUnit"; - } - - /** - * Tests the FieldVerifier. - */ - public void testFieldVerifier() { - /*assertFalse(FieldVerifier.isValidName(null)); - assertFalse(FieldVerifier.isValidName("")); - assertFalse(FieldVerifier.isValidName("a")); - assertFalse(FieldVerifier.isValidName("ab")); - assertFalse(FieldVerifier.isValidName("abc")); - assertTrue(FieldVerifier.isValidName("abcd"));*/ - } - - /** - * This test will send a request to the server using the greetServer method in - * GreetingService and verify the response. - */ - public void testGreetingService() { - // Create the service that we will test. - /*GreetingServiceAsync greetingService = GWT.create(GreetingService.class); - ServiceDefTarget target = (ServiceDefTarget) greetingService; - target.setServiceEntryPoint(GWT.getModuleBaseURL() + "Traccar/greet"); - - // Since RPC calls are asynchronous, we will need to wait for a response - // after this test method returns. This line tells the test runner to wait - // up to 10 seconds before timing out. - delayTestFinish(10000); - - // Send a request to the server. - greetingService.greetServer("GWT User", new AsyncCallback<String>() { - public void onFailure(Throwable caught) { - // The request resulted in an unexpected error. - fail("Request failure: " + caught.getMessage()); - } - - public void onSuccess(String result) { - // Verify that the response is correct. - assertTrue(result.startsWith("Hello, GWT User!")); - - // Now that we have received a response, we need to tell the test runner - // that the test is complete. You must call finishTest() after an - // asynchronous test finishes successfully, or the test will time out. - finishTest(); - } - });*/ - } - - -} diff --git a/src/test/realm.properties b/src/test/realm.properties deleted file mode 100644 index 9a068c7..0000000 --- a/src/test/realm.properties +++ /dev/null @@ -1,2 +0,0 @@ -admin: admin,admin -user: user,user diff --git a/src/test/resources/org/traccar/web/TraccarJUnit.gwt.xml b/src/test/resources/org/traccar/web/TraccarJUnit.gwt.xml deleted file mode 100644 index 4c95789..0000000 --- a/src/test/resources/org/traccar/web/TraccarJUnit.gwt.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module> - <!-- Inherit our applications main module. --> - <inherits name='org.traccar.web.Traccar' /> - - <!-- Specify the path to any remote services. --> - <servlet path="/Traccar/greet" class="org.traccar.web.server.GreetingServiceImpl" /> - -</module> |