diff options
-rw-r--r-- | Traccar.launch | 17 | ||||
-rw-r--r-- | TraccarTest-dev.launch | 22 | ||||
-rw-r--r-- | TraccarTest-prod.launch | 22 | ||||
-rw-r--r-- | pom.xml | 133 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/ArchivePanel.java | 64 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/DevicePanel.java | 54 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/MapPanel.java | 108 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/client/Traccar.java | 49 | ||||
-rw-r--r-- | src/main/resources/org/traccar/web/Traccar.gwt.xml | 28 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/classes/org/traccar/web/Traccar.gwt.xml | 26 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages.properties | 2 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages_fr.properties | 2 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/jetty-web.xml | 10 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/web.xml | 33 | ||||
-rw-r--r-- | src/main/webapp/traccar.html | 20 | ||||
-rw-r--r-- | src/test/java/org/traccar/web/client/GwtTestTraccar.java | 75 | ||||
-rw-r--r-- | src/test/realm.properties | 2 | ||||
-rw-r--r-- | src/test/resources/org/traccar/web/TraccarJUnit.gwt.xml | 9 |
18 files changed, 676 insertions, 0 deletions
diff --git a/Traccar.launch b/Traccar.launch new file mode 100644 index 00000000..5e184bfd --- /dev/null +++ b/Traccar.launch @@ -0,0 +1,17 @@ +<?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 new file mode 100644 index 00000000..abceae61 --- /dev/null +++ b/TraccarTest-dev.launch @@ -0,0 +1,22 @@ +<?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 new file mode 100644 index 00000000..0405cfb0 --- /dev/null +++ b/TraccarTest-prod.launch @@ -0,0 +1,22 @@ +<?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 new file mode 100644 index 00000000..cfb2bdcd --- /dev/null +++ b/pom.xml @@ -0,0 +1,133 @@ +<?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.4.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> + </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>${gwtVersion}</version> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>test</goal> + <!--<goal>i18n</goal>--> + <goal>generateAsync</goal> + </goals> + </execution> + </executions> + <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.5</source> + <target>1.5</target> + </configuration> + </plugin> + + </plugins> + </build> + +</project> diff --git a/src/main/java/org/traccar/web/client/ArchivePanel.java b/src/main/java/org/traccar/web/client/ArchivePanel.java new file mode 100644 index 00000000..d8f7ea77 --- /dev/null +++ b/src/main/java/org/traccar/web/client/ArchivePanel.java @@ -0,0 +1,64 @@ +package org.traccar.web.client; + +import com.smartgwt.client.widgets.toolbar.ToolStrip; +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.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.DateTimeItem; +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/DevicePanel.java b/src/main/java/org/traccar/web/client/DevicePanel.java new file mode 100644 index 00000000..ba30fefb --- /dev/null +++ b/src/main/java/org/traccar/web/client/DevicePanel.java @@ -0,0 +1,54 @@ +package org.traccar.web.client; + +import com.smartgwt.client.widgets.toolbar.ToolStrip; +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.ToolStripButton; + +/** + * Device list widget + */ +public class DevicePanel extends SectionStack { + + private ToolStrip toolbar; + private ListGrid list; + + public DevicePanel() { + SectionStackSection section = new SectionStackSection("Devices"); + section.setCanCollapse(false); + section.setExpanded(true); + + toolbar = new ToolStrip(); + toolbar.setWidth100(); + + ToolStripButton button = new ToolStripButton(); + button.setTitle("Add"); + toolbar.addButton(button); + button = new ToolStripButton(); + button.setTitle("Remove"); + toolbar.addButton(button); + button = new ToolStripButton(); + button.setTitle("Edit"); + toolbar.addButton(button); + toolbar.addFill(); + toolbar.addSeparator(); + button = new ToolStripButton(); + button.setTitle("Settings"); + toolbar.addButton(button); + + list = new ListGrid(); + list.setFields( + new ListGridField("id", "Id"), + new ListGridField("imei", "IMEI")); + + 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/MapPanel.java b/src/main/java/org/traccar/web/client/MapPanel.java new file mode 100644 index 00000000..72ed0d3b --- /dev/null +++ b/src/main/java/org/traccar/web/client/MapPanel.java @@ -0,0 +1,108 @@ +package org.traccar.web.client; + +import com.smartgwt.client.widgets.layout.SectionStack; +import com.smartgwt.client.widgets.layout.SectionStackSection; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.WidgetCanvas; +import com.smartgwt.client.widgets.events.ResizedEvent; +import com.smartgwt.client.widgets.events.ResizedHandler; +import com.smartgwt.client.widgets.events.DragResizeStopEvent; +import com.smartgwt.client.widgets.events.DragResizeStopHandler; +import com.smartgwt.client.widgets.events.DrawEvent; +import com.smartgwt.client.widgets.events.DrawHandler; +import com.smartgwt.client.types.Overflow; + +import com.google.gwt.core.client.Scheduler; + +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.control.LayerSwitcher; +import org.gwtopenmaps.openlayers.client.control.OverviewMap; +import org.gwtopenmaps.openlayers.client.control.ScaleLine; +import org.gwtopenmaps.openlayers.client.layer.OSM; + +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; + +import com.google.gwt.event.logical.shared.AttachEvent; +import org.gwtopenmaps.openlayers.client.layer.*; + +/** + * Map panel widget + */ +public class MapPanel extends SectionStack { + + private final static int BORDER_SIZE = 1; + + private MapWidget mapWidget; + private WidgetCanvas mapWrapper; + + private MapWidget createMapWidget() { + MapOptions defaultMapOptions = new MapOptions(); + defaultMapOptions.setNumZoomLevels(16); + + MapWidget mapWidget = new MapWidget("100%", "100%", defaultMapOptions); + + // Google layer + /*GoogleV3Options layerOptiond = new GoogleV3Options(); + layerOptiond.setIsBaseLayer(true); + layerOptiond.setType(GoogleV3MapType.G_NORMAL_MAP); + GoogleV3 layer = new GoogleV3("Google", layerOptiond);*/ + + // Open Street Map layer + OSM layer = OSM.Mapnik("Mapnik"); + layer.setIsBaseLayer(true); + + Map map = mapWidget.getMap(); + map.addLayer(layer); + map.addControl(new ScaleLine()); + + // Default center + LonLat lonLat = new LonLat(12.5, 41.9); + lonLat.transform(new Projection("EPSG:4326").getProjectionCode(), map.getProjection()); + map.setCenter(lonLat, 1); + + return mapWidget; + } + + public MapPanel() { + SectionStackSection section = new SectionStackSection("Map"); + section.setCanCollapse(false); + section.setExpanded(true); + + mapWidget = 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) { + mapWidget.getMap().updateSize(); + } + }); + + section.setItems(mapWrapper); + setSections(section); + } + +} diff --git a/src/main/java/org/traccar/web/client/Traccar.java b/src/main/java/org/traccar/web/client/Traccar.java new file mode 100644 index 00000000..6c8cdf18 --- /dev/null +++ b/src/main/java/org/traccar/web/client/Traccar.java @@ -0,0 +1,49 @@ +package org.traccar.web.client; + +import com.google.gwt.core.client.EntryPoint; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +/** + * Entry point class + */ +public class Traccar implements EntryPoint { + + private DevicePanel devicePanel; + private ArchivePanel archivePanel; + private MapPanel mapPanel; + + /** + * Entry point method + */ + public void onModuleLoad() { + + devicePanel = new DevicePanel(); + devicePanel.setWidth("20%"); + devicePanel.setShowResizeBar(true); + + mapPanel = new MapPanel(); + mapPanel.setWidth("80%"); + + HLayout hLayout = new HLayout(); + hLayout.setHeight("70%"); + hLayout.addMember(devicePanel); + hLayout.addMember(mapPanel); + hLayout.setShowResizeBar(true); + hLayout.setResizeBarTarget("next"); + + archivePanel = new ArchivePanel(); + archivePanel.setHeight("30%"); + + VLayout mainLayout = new VLayout(); + mainLayout.setWidth100(); + mainLayout.setHeight100(); + mainLayout.addMember(hLayout); + mainLayout.addMember(archivePanel); + mainLayout.draw(); + } +} diff --git a/src/main/resources/org/traccar/web/Traccar.gwt.xml b/src/main/resources/org/traccar/web/Traccar.gwt.xml new file mode 100644 index 00000000..086d2a48 --- /dev/null +++ b/src/main/resources/org/traccar/web/Traccar.gwt.xml @@ -0,0 +1,28 @@ +<?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 new file mode 100644 index 00000000..ff123394 --- /dev/null +++ b/src/main/webapp/WEB-INF/classes/org/traccar/web/Traccar.gwt.xml @@ -0,0 +1,26 @@ +<?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 --> + + <!-- 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 new file mode 100644 index 00000000..c222555b --- /dev/null +++ b/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages.properties @@ -0,0 +1,2 @@ +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 new file mode 100644 index 00000000..b4a76270 --- /dev/null +++ b/src/main/webapp/WEB-INF/classes/org/traccar/web/client/Messages_fr.properties @@ -0,0 +1,2 @@ +sendButton = Envoyer +nameField = Entrez votre nom
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jetty-web.xml b/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 00000000..f959e1b3 --- /dev/null +++ b/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,10 @@ +<Configure class="org.mortbay.jetty.webapp.WebAppContext"> + <Get name="securityHandler"> + <Set name="userRealm"> + <New class="org.mortbay.jetty.security.HashUserRealm"> + <Set name="name">Test Realm</Set> + <Set name="config"><SystemProperty name="jetty.home" default="."/>/src/test/realm.properties</Set> + </New> + </Set> + </Get> +</Configure> diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..81fa375a --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,33 @@ +<?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>--> + + <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 new file mode 100644 index 00000000..0bac1a44 --- /dev/null +++ b/src/main/webapp/traccar.html @@ -0,0 +1,20 @@ +<!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 new file mode 100644 index 00000000..2c6a4454 --- /dev/null +++ b/src/test/java/org/traccar/web/client/GwtTestTraccar.java @@ -0,0 +1,75 @@ +package org.traccar.web.client; + +import org.traccar.web.shared.FieldVerifier; +import com.google.gwt.core.client.GWT; +import com.google.gwt.junit.client.GWTTestCase; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; + +/** + * 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. + */ + 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 new file mode 100644 index 00000000..9a068c7f --- /dev/null +++ b/src/test/realm.properties @@ -0,0 +1,2 @@ +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 new file mode 100644 index 00000000..4c957890 --- /dev/null +++ b/src/test/resources/org/traccar/web/TraccarJUnit.gwt.xml @@ -0,0 +1,9 @@ +<?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> |