Overhaul zxing.appspot.com. Update to GWT 2.4, work around deprecations. Scrub, update and simplify code and deployment a little. Add a few enhancements like control over EC level and encoding.
git-svn-id: https://zxing.googlecode.com/svn/trunk@2030 59b500cc-1b3d-0410-9834-0bbf25fbcc57
|
@ -15,5 +15,5 @@ version=2.0
|
||||||
# Uncomment and set this variable if building the zxing.appspot.com subdirectory. It points to the
|
# Uncomment and set this variable if building the zxing.appspot.com subdirectory. It points to the
|
||||||
# location of the Google Web Toolkit (GWT) which can be downloaded here:
|
# location of the Google Web Toolkit (GWT) which can be downloaded here:
|
||||||
# http://code.google.com/webtoolkit/
|
# http://code.google.com/webtoolkit/
|
||||||
# It builds against GWT 2.0.1 at the moment.
|
# It builds against GWT 2.4 at the moment.
|
||||||
#GWT-home=/usr/local/gwt
|
#GWT-home=/usr/local/gwt
|
||||||
|
|
14
zxing.appspot.com/Generator.launch
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||||
|
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
|
||||||
|
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||||
|
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="Generator" path="1" type="4"/> "/>
|
||||||
|
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/Generator/src" path="3" type="2"/> "/>
|
||||||
|
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento project="Generator"/> </runtimeClasspathEntry> "/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war war -startupUrl Generator.html com.google.zxing.web.generator.Generator"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Generator"/>
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||||
|
</launchConfiguration>
|
|
@ -1,14 +1,84 @@
|
||||||
To compile:
|
--- Generated by GWT WebAppCreator ---
|
||||||
----------
|
|
||||||
Run 'ant' in this directory. You might get a lot of warnings with
|
|
||||||
[WARN] but you should not get any errors.
|
|
||||||
|
|
||||||
|
Congratulations, you've successfully generated a starter project! What next?
|
||||||
|
|
||||||
To test:
|
-- Option A: Import your project into Eclipse (recommended) --
|
||||||
-------
|
|
||||||
View the file "build/site/generator/index.html" in any browser. You can do
|
|
||||||
this from the commandline with:
|
|
||||||
|
|
||||||
firefox build/site/generator/index.html
|
If you use Eclipse, you can simply import the generated project into Eclipse.
|
||||||
|
We've tested against Eclipse 3.4 and 3.5. Later versions will likely also
|
||||||
|
work, earlier versions may not.
|
||||||
|
|
||||||
Now you can try out your changes.
|
If the directory containing this file does not have a .classpath or .project
|
||||||
|
file, generate them by running 'ant eclipse.generate'
|
||||||
|
|
||||||
|
In Eclipse, go to the File menu and choose:
|
||||||
|
|
||||||
|
File -> Import... -> Existing Projects into Workspace
|
||||||
|
|
||||||
|
Browse to the directory containing this file,
|
||||||
|
select "Generator".
|
||||||
|
|
||||||
|
Be sure to uncheck "Copy projects into workspace" if it is checked.
|
||||||
|
|
||||||
|
Click Finish.
|
||||||
|
|
||||||
|
You can now browse the project in Eclipse.
|
||||||
|
|
||||||
|
To launch your web app in GWT development mode, go to the Run menu and choose:
|
||||||
|
|
||||||
|
Run -> Open Debug Dialog...
|
||||||
|
|
||||||
|
Under Java Application, you should find a launch configuration
|
||||||
|
named "Generator". Select and click "Debug".
|
||||||
|
|
||||||
|
You can now use the built-in debugger to debug your web app in development mode.
|
||||||
|
|
||||||
|
If you supplied the junit path when invoking webAppCreator, you should see
|
||||||
|
launch configurations for running your tests in development and production
|
||||||
|
mode.
|
||||||
|
|
||||||
|
-- Option B: Build from the command line with Ant --
|
||||||
|
|
||||||
|
If you prefer to work from the command line, you can use Ant to build your
|
||||||
|
project. (http://ant.apache.org/) Ant uses the generated 'build.xml' file
|
||||||
|
which describes exactly how to build your project. This file has been tested
|
||||||
|
to work against Ant 1.7.1. The following assumes 'ant' is on your command
|
||||||
|
line path.
|
||||||
|
|
||||||
|
To run development mode, just type 'ant devmode'.
|
||||||
|
|
||||||
|
To compile your project for deployment, just type 'ant'.
|
||||||
|
|
||||||
|
To compile and also bundle into a .war file, type 'ant war'.
|
||||||
|
|
||||||
|
If you supplied the junit path when invoking webAppCreator, you can type 'ant
|
||||||
|
test' to run tests in development and production mode.
|
||||||
|
|
||||||
|
For a full listing of other targets, type 'ant -p'.
|
||||||
|
|
||||||
|
-- Option C: Using another IDE --
|
||||||
|
|
||||||
|
GWT projects can be run in other IDEs as well, but will require some manual
|
||||||
|
setup. If you go this route, be sure to:
|
||||||
|
|
||||||
|
* Have your IDE build .class files into 'war/WEB-INF/classes'.
|
||||||
|
* Add gwt-user.jar and gwt-dev.jar to your project build path.
|
||||||
|
* When creating a launch configuration, add a classpath entry for your 'src'
|
||||||
|
folder (this is somewhat unusual but GWT needs access to your source files).
|
||||||
|
|
||||||
|
If you get stuck, try to mimic what the Ant 'build.xml' would do.
|
||||||
|
|
||||||
|
-- Option D: Using Maven --
|
||||||
|
|
||||||
|
If you have generated your project with the option '-maven', you have a 'pom.xml'
|
||||||
|
file ready to use. Assuming you have 'maven2' installed in your system, 'mvn' is
|
||||||
|
in your path, and you have access to maven repositories, you should be able to run:
|
||||||
|
|
||||||
|
mvn clean # delete temporary stuff
|
||||||
|
mvn test # run all the tests (gwt and junit)
|
||||||
|
mvn gwt:run # run development mode
|
||||||
|
mvn gwt:compile # compile to javascript
|
||||||
|
mvn package # generate a .war package ready to deploy
|
||||||
|
|
||||||
|
For more information about other available goals, read maven and gwt-maven-plugin
|
||||||
|
documentation (http://maven.apache.org, http://mojo.codehaus.org/gwt-maven-plugin)
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
application: zxing
|
|
||||||
version: 2
|
|
||||||
runtime: python
|
|
||||||
api_version: 1
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
- url: /generator
|
|
||||||
script: redirect.py
|
|
||||||
|
|
||||||
- url: /scan
|
|
||||||
static_files: site/scan.html
|
|
||||||
upload: site/scan.html
|
|
||||||
|
|
||||||
- url: /favicon.ico
|
|
||||||
static_files: static/favicon.ico
|
|
||||||
upload: static/favicon.ico
|
|
||||||
|
|
||||||
- url: (.*)/
|
|
||||||
static_files: site\1/index.html
|
|
||||||
upload: site/index.html
|
|
||||||
|
|
||||||
- url: /
|
|
||||||
static_dir: site
|
|
|
@ -14,66 +14,92 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project name="zxing.appspot.com" default="build">
|
<project name="zxing.appspot.com" default="build" basedir=".">
|
||||||
<property file="../build.properties"/>
|
|
||||||
|
|
||||||
<!-- Properties -->
|
<loadproperties srcFile="../build.properties" />
|
||||||
<property name="outdir" value="build"/>
|
|
||||||
<property name="outdir-site" value="${outdir}/site"/>
|
|
||||||
<property name="yaml-file" value="app.yaml"/>
|
|
||||||
<property name="redirect-script" value="redirect.py"/>
|
|
||||||
<property name="generator-package" value="com.google.zxing.web.generator.Generator"/>
|
|
||||||
|
|
||||||
<!-- Contains pre-built jars like gwt-incubator.jar -->
|
<!-- Arguments to gwtc and devmode targets -->
|
||||||
<property name="external-libs" value="generator/libs"/>
|
<property name="gwt.args" value="" />
|
||||||
|
|
||||||
<!-- Create the output directories if they don't exist yet. -->
|
<!-- Configure path to GWT SDK -->
|
||||||
<target name="create-dirs">
|
<property name="gwt.sdk" location="${GWT-home}" />
|
||||||
<echo>Creating output directories if needed...</echo>
|
|
||||||
<mkdir dir="${outdir}"/>
|
<path id="project.class.path">
|
||||||
<mkdir dir="${outdir-site}"/>
|
<pathelement location="war/WEB-INF/classes"/>
|
||||||
|
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
|
||||||
|
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
|
||||||
|
<!-- Add any additional non-server libs (such as JUnit) -->
|
||||||
|
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<target name="libs" description="Copy libs to WEB-INF/lib">
|
||||||
|
<mkdir dir="war/WEB-INF/lib" />
|
||||||
|
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
|
||||||
|
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
|
||||||
|
<!-- Add any additional server libs that need to be copied -->
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Generate the HTML and JS from the Java source. -->
|
<target name="javac" depends="libs" description="Compile java source to bytecode">
|
||||||
<target name="compile" depends="create-dirs">
|
<mkdir dir="war/WEB-INF/classes"/>
|
||||||
<java classname="com.google.gwt.dev.GWTCompiler" fork="true" failonerror="true">
|
<javac srcdir="src" includes="**" encoding="utf-8"
|
||||||
<jvmarg value="-Xmx256M"/>
|
destdir="war/WEB-INF/classes"
|
||||||
<classpath>
|
source="6" target="6" nowarn="true"
|
||||||
<pathelement path="generator/src"/>
|
debug="true" debuglevel="lines,vars,source"
|
||||||
<fileset dir="${GWT-home}" includes="*.jar"/>
|
includeantruntime="false">
|
||||||
<fileset dir="${external-libs}" includes="*.jar"/>
|
<classpath refid="project.class.path"/>
|
||||||
</classpath>
|
</javac>
|
||||||
<arg line="-out ${outdir-site}"/>
|
<copy todir="war/WEB-INF/classes">
|
||||||
<arg value="${generator-package}"/>
|
<fileset dir="src" excludes="**/*.java"/>
|
||||||
</java>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- Part of copying all the needed pieces into ${outdir-site} so it can be uploaded. -->
|
|
||||||
<target name="copy-static-files" depends="create-dirs">
|
|
||||||
<echo>Copying static files...</echo>
|
|
||||||
<copy file="${yaml-file}" todir="${outdir}"/>
|
|
||||||
<copy file="${redirect-script}" todir="${outdir}"/>
|
|
||||||
<copy todir="${outdir-site}">
|
|
||||||
<fileset dir="static"/>
|
|
||||||
</copy>
|
</copy>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!--
|
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
|
||||||
The GWTCompiler adds the package name to the output directory, but we want to change that to
|
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
|
||||||
mirror the user-perceived site layout. We also want to rename the main HTML file.
|
<classpath>
|
||||||
-->
|
<pathelement location="src"/>
|
||||||
<target name="rename-generator" depends="compile">
|
<path refid="project.class.path"/>
|
||||||
<echo>Renaming generator output...</echo>
|
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
|
||||||
<move file="${outdir-site}/${generator-package}" tofile="${outdir-site}/generator"/>
|
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
|
||||||
<move file="${outdir-site}/generator/Generator.html" tofile="${outdir-site}/generator/index.html"/>
|
</classpath>
|
||||||
|
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
|
||||||
|
<jvmarg value="-Xmx256M"/>
|
||||||
|
<arg value="-strict"/>
|
||||||
|
<arg line="-war"/>
|
||||||
|
<arg value="war"/>
|
||||||
|
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
|
||||||
|
<arg line="${gwt.args}"/>
|
||||||
|
<arg value="com.google.zxing.web.generator.Generator"/>
|
||||||
|
</java>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="build" depends="compile,copy-static-files,rename-generator">
|
<target name="devmode" depends="javac" description="Run development mode">
|
||||||
|
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="src"/>
|
||||||
|
<path refid="project.class.path"/>
|
||||||
|
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
|
||||||
|
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
|
||||||
|
</classpath>
|
||||||
|
<jvmarg value="-Xmx256M"/>
|
||||||
|
<arg value="-startupUrl"/>
|
||||||
|
<arg value="Generator.html"/>
|
||||||
|
<arg line="-war"/>
|
||||||
|
<arg value="war"/>
|
||||||
|
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
|
||||||
|
<arg line="${gwt.args}"/>
|
||||||
|
<arg value="com.google.zxing.web.generator.Generator"/>
|
||||||
|
</java>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="clean">
|
<target name="build" depends="gwtc" description="Build this project" />
|
||||||
<delete dir="${outdir}"/>
|
|
||||||
|
<target name="war" depends="build" description="Create a war file">
|
||||||
|
<zip destfile="Generator.war" basedir="war"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="clean" description="Cleans this project">
|
||||||
|
<delete dir="war/WEB-INF/classes" failonerror="false" />
|
||||||
|
<delete dir="war/generator" failonerror="false" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="lib" path="gwt-user.jar"/>
|
|
||||||
<classpathentry kind="lib" path="gwt.jar"/>
|
|
||||||
<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/>
|
|
||||||
<classpathentry kind="lib" path="libs/gwt-incubator.jar"/>
|
|
||||||
<classpathentry kind="lib" path="libs/gwt-maps.jar"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>BarcodeGenerator</name>
|
|
||||||
<comment>BarcodeGenerator project</comment>
|
|
||||||
<projects/>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments/>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
<linkedResources>
|
|
||||||
<link>
|
|
||||||
<name>gwt-user.jar</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>GWT_HOME/gwt-user.jar</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>gwt.jar</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>GWT_JAR</locationURI>
|
|
||||||
</link>
|
|
||||||
</linkedResources>
|
|
||||||
</projectDescription>
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
|
||||||
<listEntry value="/BarcodeGenerator/gwt.jar"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
|
||||||
<listEntry value="1"/>
|
|
||||||
</listAttribute>
|
|
||||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
|
||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
|
||||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="BarcodeGenerator" path="1" type="4"/> "/>
|
|
||||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/BarcodeGenerator/src" path="3" type="2"/> "/>
|
|
||||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="BarcodeGenerator"/> </runtimeClasspathEntry> "/>
|
|
||||||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/BarcodeGenerator/gwt.jar" path="3" type="2"/> "/>
|
|
||||||
</listAttribute>
|
|
||||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0 (MacOS X Default)"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out www com.google.zxing.web.generator.Generator/Generator.html"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="BarcodeGenerator"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -XstartOnFirstThread"/>
|
|
||||||
</launchConfiguration>
|
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
To develop with Eclipse.
|
|
||||||
|
|
||||||
Before importing the project, you need to define some variables.
|
|
||||||
- In Eclipse Preferences, go to General->Workspace->Linked Resources.
|
|
||||||
- Click New and add the 2 following variables:
|
|
||||||
- GWT_HOME that point to the directory containing gwt-user.jar
|
|
||||||
- GWT_JAR that point to the gwt-dev-XXX.jar file directly. (XXX will be linux, mac, etc)
|
|
||||||
- then you can import the project by File->Import...->Existing project into workspace.
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<module>
|
|
||||||
<!-- Inherit the core Web Toolkit stuff. -->
|
|
||||||
<inherits name='com.google.gwt.user.User'/>
|
|
||||||
<!-- Inherit the default GWT style sheet. -->
|
|
||||||
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
|
|
||||||
<!-- Other module inherits -->
|
|
||||||
<inherits name='com.google.gwt.widgetideas.WidgetIdeas' />
|
|
||||||
<inherits name='com.google.gwt.libideas.LibIdeas' />
|
|
||||||
<inherits name='com.google.gwt.maps.GoogleMaps' />
|
|
||||||
<!-- Specify the app entry point class. -->
|
|
||||||
<entry-point class='com.google.zxing.web.generator.client.Generator'/>
|
|
||||||
<!-- Specify the application specific style sheet. -->
|
|
||||||
<stylesheet src='Generator.css' />
|
|
||||||
<stylesheet src='DatePickerDemo.css' />
|
|
||||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjEOGGB_IEuss4QYUzB6Z0BRlY4xXjGBjgubjQXCS8Djm2jdpYBQn9f8dHtxpg30ararqd3GCyq_T4A' />
|
|
||||||
</module>
|
|
|
@ -1,218 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2008 ZXing authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
|
||||||
|
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
|
||||||
import com.google.gwt.http.client.URL;
|
|
||||||
import com.google.gwt.maps.client.MapWidget;
|
|
||||||
import com.google.gwt.maps.client.control.SmallMapControl;
|
|
||||||
import com.google.gwt.maps.client.event.MapClickHandler;
|
|
||||||
import com.google.gwt.maps.client.event.MarkerDragEndHandler;
|
|
||||||
import com.google.gwt.maps.client.event.MapClickHandler.MapClickEvent;
|
|
||||||
import com.google.gwt.maps.client.geom.LatLng;
|
|
||||||
import com.google.gwt.maps.client.overlay.Marker;
|
|
||||||
import com.google.gwt.maps.client.overlay.MarkerOptions;
|
|
||||||
import com.google.gwt.user.client.ui.Button;
|
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.ClickListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
|
||||||
import com.google.gwt.user.client.ui.SimplePanel;
|
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A generator for geo location. It also accepts a google maps links and
|
|
||||||
* extracts the coordinates and query from the URL.
|
|
||||||
*
|
|
||||||
* @author Yohann Coppel
|
|
||||||
*/
|
|
||||||
public class GeoLocationGenerator implements GeneratorSource, ChangeListener {
|
|
||||||
private static final String LON_REGEXP = "[+-]?[0-9]+(.[0-9]+)?";
|
|
||||||
private static final String LAT_REGEXP = "[+-]?[0-9]+(.[0-9]+)?";
|
|
||||||
|
|
||||||
Grid table = null;
|
|
||||||
TextBox latitude = new TextBox();
|
|
||||||
TextBox longitude = new TextBox();
|
|
||||||
TextBox query = new TextBox();
|
|
||||||
MapWidget map = new MapWidget();
|
|
||||||
Marker mapMarker = null;
|
|
||||||
private ChangeListener changeListener;
|
|
||||||
|
|
||||||
public GeoLocationGenerator(ChangeListener listener,
|
|
||||||
KeyPressHandler keyListener) {
|
|
||||||
this.changeListener = listener;
|
|
||||||
latitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
|
||||||
latitude.addChangeListener(listener);
|
|
||||||
latitude.addChangeListener(this);
|
|
||||||
latitude.addKeyPressHandler(keyListener);
|
|
||||||
longitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
|
||||||
longitude.addChangeListener(listener);
|
|
||||||
longitude.addChangeListener(this);
|
|
||||||
longitude.addKeyPressHandler(keyListener);
|
|
||||||
query.addChangeListener(listener);
|
|
||||||
query.addKeyPressHandler(keyListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return "Geo location";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() throws GeneratorException {
|
|
||||||
String que = getQueryField();
|
|
||||||
if (null != que && que.length() > 0) {
|
|
||||||
if (null == getLatitudeField()) {
|
|
||||||
latitude.setText("0");
|
|
||||||
}
|
|
||||||
if (null == getLongitudeField()) {
|
|
||||||
longitude.setText("0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String lat = getLatitudeField();
|
|
||||||
String lon = getLongitudeField();
|
|
||||||
|
|
||||||
if (null != que && que.length() > 0) {
|
|
||||||
return "geo:"+lat+ ',' +lon+"?q="+que;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "geo:"+lat+ ',' +lon;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getQueryField() {
|
|
||||||
String que = query.getText();
|
|
||||||
que = que.replace("&", "%26");
|
|
||||||
return que;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getLongitudeField() throws GeneratorException {
|
|
||||||
String lon = longitude.getText();
|
|
||||||
if (!lon.matches(LON_REGEXP)) {
|
|
||||||
throw new GeneratorException("Longitude is not a correct value.");
|
|
||||||
}
|
|
||||||
double val = Double.parseDouble(lon);
|
|
||||||
if (val < -180 || val > 180) {
|
|
||||||
throw new GeneratorException("Longitude must be in [-180:180]");
|
|
||||||
}
|
|
||||||
return lon;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getLatitudeField() throws GeneratorException {
|
|
||||||
String lat = latitude.getText();
|
|
||||||
if (!lat.matches(LAT_REGEXP)) {
|
|
||||||
throw new GeneratorException("Latitude is not a correct value.");
|
|
||||||
}
|
|
||||||
double val = Double.parseDouble(lat);
|
|
||||||
if (val < -90 || val > 90) {
|
|
||||||
throw new GeneratorException("Latitude must be in [-90:90]");
|
|
||||||
}
|
|
||||||
return lat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Grid getWidget() {
|
|
||||||
if (table != null) {
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
table = new Grid(6, 2);
|
|
||||||
|
|
||||||
table.setText(0, 0, "Latitude");
|
|
||||||
table.setWidget(0, 1, latitude);
|
|
||||||
table.setText(1, 0, "Longitude");
|
|
||||||
table.setWidget(1, 1, longitude);
|
|
||||||
table.setText(2, 0, "Query");
|
|
||||||
table.setWidget(2, 1, query);
|
|
||||||
table.setText(3, 0, "OR");
|
|
||||||
table.setText(3, 1, "enter a Google Maps link and click Fill:");
|
|
||||||
|
|
||||||
map.setSize("256px", "256px");
|
|
||||||
map.addControl(new SmallMapControl());
|
|
||||||
map.getElement().getStyle().setProperty("overflow", "hidden");
|
|
||||||
map.addMapClickHandler(new MapClickHandler() {
|
|
||||||
public void onClick(MapClickEvent event) {
|
|
||||||
mapClick(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
table.setText(4, 0, "OR");
|
|
||||||
table.setText(4, 1, "use the map to select a location:");
|
|
||||||
SimplePanel sp = new SimplePanel();
|
|
||||||
sp.add(map);
|
|
||||||
table.setWidget(5, 1, sp);
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void mapClick(MapClickEvent event) {
|
|
||||||
latitude.setText(String.valueOf(event.getLatLng().getLatitude()));
|
|
||||||
longitude.setText(String.valueOf(event.getLatLng().getLongitude()));
|
|
||||||
setMapMarker(event.getLatLng().getLatitude(), event.getLatLng().getLongitude(), false);
|
|
||||||
changeListener.onChange(latitude);
|
|
||||||
changeListener.onChange(longitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void mapMarkerMoved() {
|
|
||||||
latitude.setText(String.valueOf(mapMarker.getLatLng().getLatitude()));
|
|
||||||
longitude.setText(String.valueOf(mapMarker.getLatLng().getLongitude()));
|
|
||||||
changeListener.onChange(latitude);
|
|
||||||
changeListener.onChange(longitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setMapMarker(double lat, double lon, boolean zoomAndCenter) {
|
|
||||||
if (mapMarker != null) {
|
|
||||||
map.removeOverlay(mapMarker);
|
|
||||||
}
|
|
||||||
LatLng ll = LatLng.newInstance(lat, lon);
|
|
||||||
if (zoomAndCenter) {
|
|
||||||
map.setCenter(ll);
|
|
||||||
map.setZoomLevel(12);
|
|
||||||
}
|
|
||||||
if (mapMarker != null) {
|
|
||||||
mapMarker.setLatLng(ll);
|
|
||||||
} else {
|
|
||||||
MarkerOptions opt = MarkerOptions.newInstance();
|
|
||||||
opt.setDraggable(true);
|
|
||||||
mapMarker = new Marker(ll, opt);
|
|
||||||
mapMarker.addMarkerDragEndHandler(new MarkerDragEndHandler() {
|
|
||||||
public void onDragEnd(MarkerDragEndEvent event) {
|
|
||||||
mapMarkerMoved();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
map.addOverlay(mapMarker);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
|
||||||
if (widget == latitude) {
|
|
||||||
getLatitudeField();
|
|
||||||
}
|
|
||||||
if (widget == longitude) {
|
|
||||||
getLongitudeField();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFocus() {
|
|
||||||
latitude.setFocus(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onChange(Widget sender) {
|
|
||||||
if (sender == latitude || sender == longitude) {
|
|
||||||
try {
|
|
||||||
double lat = Double.parseDouble(getLatitudeField());
|
|
||||||
double lon = Double.parseDouble(getLongitudeField());
|
|
||||||
setMapMarker(lat, lon, true);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
} catch (GeneratorException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
/**
|
|
||||||
Date picker styles, most of these will eventually move into a default resource bundle.
|
|
||||||
*/
|
|
||||||
.gwt-DatePicker {
|
|
||||||
width: 150px;
|
|
||||||
border: 1px solid #f1f1f1;
|
|
||||||
border-bottom: 2px solid #f1f1f1;
|
|
||||||
color: 6b6b6b;
|
|
||||||
cursor: default;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker td {
|
|
||||||
font-family: Arial;
|
|
||||||
font-size: 65%;
|
|
||||||
padding: 2px;
|
|
||||||
text-align: center;
|
|
||||||
padding: 2px;
|
|
||||||
outline: none;
|
|
||||||
-moz-outline: none;
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker td,.month-selector td :focus {
|
|
||||||
outline: none
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DateBox input {
|
|
||||||
width: 8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Calendar styles
|
|
||||||
*/
|
|
||||||
.calendar-view {
|
|
||||||
background-color: white;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendar-view .filler-cell {
|
|
||||||
color: #bfbfbf;
|
|
||||||
padding: 1px;
|
|
||||||
cursor: hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendar-view .date-cell {
|
|
||||||
padding: 1px;
|
|
||||||
cursor:hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendar-view .selected-cell {
|
|
||||||
background: #aaccee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendar-view .day-title {
|
|
||||||
background: #dbe6de;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .calendar-view .highlighted-cell {
|
|
||||||
border: 1px solid #eeeeee;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendar-view .today-cell {
|
|
||||||
border: 1px solid black;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .calendar-view .weekend {
|
|
||||||
background: #f1f1f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendar-view .disabled-cell {
|
|
||||||
color: graytext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Month selector styles
|
|
||||||
*/
|
|
||||||
.month-selector {
|
|
||||||
background: #dbe6de;
|
|
||||||
width: 100%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.month-selector td {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.month-selector .month-label {
|
|
||||||
text-align: center;
|
|
||||||
background: #dbe6de;
|
|
||||||
}
|
|
||||||
|
|
||||||
.month-selector .month-backward {
|
|
||||||
padding-right: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.month-selector .month-forward {
|
|
||||||
padding-left: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************
|
|
||||||
helper styles
|
|
||||||
******************************/
|
|
||||||
.log-panel {
|
|
||||||
position: relative;
|
|
||||||
float: right;
|
|
||||||
border: 1px solid black;
|
|
||||||
margin-left: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-TabPanel {
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-TabPanelBottom {
|
|
||||||
background-color: #E8EEF7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-TabBar {
|
|
||||||
padding-top: 2px;
|
|
||||||
border-bottom: 4px solid #87B3FF;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-TabBar .gwt-TabBarItem {
|
|
||||||
padding: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
cursor: hand;
|
|
||||||
background-color: #e8eef7;
|
|
||||||
border-bottom: 2px solid white;
|
|
||||||
margin-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-TabBar .gwt-TabBarItem-selected {
|
|
||||||
padding: 4px;
|
|
||||||
font-weight: bold;
|
|
||||||
cursor: default;
|
|
||||||
background-color: #87b3ff;
|
|
||||||
border-bottom: 2px solid #87b3ff;
|
|
||||||
margin-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Styles demo*/
|
|
||||||
.gwt-DatePicker .red-date {
|
|
||||||
background-color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .blue-background {
|
|
||||||
background-color: blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .red-text {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .green-border {
|
|
||||||
border: 5px solid green;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .big-text {
|
|
||||||
font-size: x-large;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .underlined-and-bold-text {
|
|
||||||
font-weight: bold;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gwt-DatePicker .yellow-background {
|
|
||||||
background-color: yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* date range styles */
|
|
||||||
.filler {
|
|
||||||
width: 30px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
||||||
<title>QR Code Generator</title>
|
|
||||||
<script type="text/javascript" language="javascript" src="com.google.zxing.web.generator.Generator.nocache.js"></script>
|
|
||||||
<link rel="stylesheet" href="Generator.css" type="text/css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="header">
|
|
||||||
<h1>QR Code Generator <span>from the ZXing Project</span></h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="ui"></div>
|
|
||||||
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
|
|
||||||
<div id="footer">
|
|
||||||
<a href="http://code.google.com/p/zxing/">ZXing Project Home Page</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,17 +0,0 @@
|
||||||
from google.appengine.ext import webapp
|
|
||||||
from google.appengine.ext.webapp.util import run_wsgi_app
|
|
||||||
|
|
||||||
class BlogHandler(webapp.RequestHandler):
|
|
||||||
def get(self, tail = ''):
|
|
||||||
self.redirect('/generator/'+tail, permanent = True)
|
|
||||||
|
|
||||||
application = webapp.WSGIApplication(
|
|
||||||
[
|
|
||||||
(r'^/generator$', BlogHandler)
|
|
||||||
])
|
|
||||||
|
|
||||||
def main():
|
|
||||||
run_wsgi_app(application)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module rename-to='generator'>
|
||||||
|
<!-- Inherit the core Web Toolkit stuff. -->
|
||||||
|
<inherits name='com.google.gwt.user.User'/>
|
||||||
|
|
||||||
|
<!-- 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.clean.Clean'/>
|
||||||
|
<!-- <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.google.gwt.gen2.picker.Picker'/>
|
||||||
|
|
||||||
|
<!-- Specify the app entry point class. -->
|
||||||
|
<entry-point class='com.google.zxing.web.generator.client.Generator'/>
|
||||||
|
|
||||||
|
<!-- Specify the paths for translatable code -->
|
||||||
|
<source path='client'/>
|
||||||
|
<source path='shared'/>
|
||||||
|
|
||||||
|
</module>
|
|
@ -16,68 +16,67 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.gen2.picker.client.TimePicker;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
import com.google.gwt.user.client.Element;
|
import com.google.gwt.user.client.Element;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.CheckBox;
|
import com.google.gwt.user.client.ui.CheckBox;
|
||||||
import com.google.gwt.user.client.ui.ClickListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.ListBox;
|
import com.google.gwt.user.client.ui.ListBox;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.google.gwt.widgetideas.client.event.ChangeEvent;
|
import com.google.gwt.user.datepicker.client.DatePicker;
|
||||||
import com.google.gwt.widgetideas.client.event.ChangeHandler;
|
|
||||||
import com.google.gwt.widgetideas.datepicker.client.DateBox;
|
|
||||||
import com.google.gwt.widgetideas.datepicker.client.TimePicker;
|
|
||||||
import com.google.zxing.web.generator.client.TimeZoneList.TimeZoneInfo;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Generator for calendar events. Output is in VCal format.
|
* A Generator for calendar events.
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class CalendarEventGenerator implements GeneratorSource {
|
public final class CalendarEventGenerator implements GeneratorSource {
|
||||||
public static final String[] FULL_DAY_ONLY_IDS = { "fullDayOnlyInfo1",
|
|
||||||
"fullDayOnlyInfo2", "fullDayOnlyInfo3", "fullDayOnlyInfo4" };
|
private static final String[] FULL_DAY_ONLY_IDS =
|
||||||
|
{ "fullDayOnlyInfo1", "fullDayOnlyInfo2", "fullDayOnlyInfo3", "fullDayOnlyInfo4" };
|
||||||
private static final long ONE_HOUR = 60L * 60 * 1000;
|
private static final long ONE_HOUR = 60L * 60 * 1000;
|
||||||
|
|
||||||
Grid table = null;
|
private Grid table;
|
||||||
TextBox eventName = new TextBox();
|
private final TextBox eventName = new TextBox();
|
||||||
CheckBox fullDay = new CheckBox();
|
private final CheckBox fullDay = new CheckBox();
|
||||||
DateBox datePicker1 = new DateBox();
|
private final DatePicker datePicker1 = new DatePicker();
|
||||||
DateBox datePicker2 = new DateBox();
|
private final DatePicker datePicker2 = new DatePicker();
|
||||||
TimePicker timePicker1 = new TimePicker(new Date(), DateTimeFormat
|
private final TimePicker timePicker1 = new TimePicker(new Date(), DateTimeFormat
|
||||||
.getFormat("a"), DateTimeFormat.getFormat("hh"), DateTimeFormat
|
.getFormat("a"), DateTimeFormat.getFormat("hh"), DateTimeFormat
|
||||||
.getFormat("mm"), null);
|
.getFormat("mm"), null);
|
||||||
TimePicker timePicker2 = new TimePicker(new Date(), DateTimeFormat
|
private final TimePicker timePicker2 = new TimePicker(new Date(), DateTimeFormat
|
||||||
.getFormat("a"), DateTimeFormat.getFormat("hh"), DateTimeFormat
|
.getFormat("a"), DateTimeFormat.getFormat("hh"), DateTimeFormat
|
||||||
.getFormat("mm"), null);
|
.getFormat("mm"), null);
|
||||||
CheckBox summerTime = new CheckBox();
|
private final CheckBox summerTime = new CheckBox();
|
||||||
ListBox timeZones = new ListBox();
|
private final ListBox timeZones = new ListBox();
|
||||||
Date timePicker1PreviousDate = null;
|
private Date timePicker1PreviousDate = null;
|
||||||
TextBox location = new TextBox();
|
private final TextBox location = new TextBox();
|
||||||
TextBox description = new TextBox();
|
private final TextBox description = new TextBox();
|
||||||
|
|
||||||
public CalendarEventGenerator(final ChangeListener listener,
|
public CalendarEventGenerator(final ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
KeyPressHandler keyListener) {
|
|
||||||
eventName.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
eventName.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
eventName.addChangeListener(listener);
|
eventName.addChangeHandler(handler);
|
||||||
eventName.addKeyPressHandler(keyListener);
|
eventName.addKeyPressHandler(keyListener);
|
||||||
datePicker1.setAnimationEnabled(true);
|
timePicker2.setDateTime(addMilliseconds(timePicker1.getDateTime(), ONE_HOUR));
|
||||||
datePicker2.setAnimationEnabled(true);
|
|
||||||
timePicker2
|
|
||||||
.setDateTime(addMilliseconds(timePicker1.getDateTime(), ONE_HOUR));
|
|
||||||
timePicker1PreviousDate = timePicker1.getDateTime();
|
timePicker1PreviousDate = timePicker1.getDateTime();
|
||||||
|
|
||||||
buildTimeZoneList();
|
buildTimeZoneList();
|
||||||
timeZones.setSelectedIndex(25);
|
timeZones.setSelectedIndex(25);
|
||||||
timeZones.addKeyPressHandler(keyListener);
|
timeZones.addKeyPressHandler(keyListener);
|
||||||
timePicker1.addChangeHandler(new ChangeHandler<Date>() {
|
timePicker1.addValueChangeHandler(new ValueChangeHandler<Date>() {
|
||||||
public void onChange(ChangeEvent<Date> event) {
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<Date> dateValueChangeEvent) {
|
||||||
Date time = timePicker1PreviousDate;
|
Date time = timePicker1PreviousDate;
|
||||||
Date time1 = timePicker1.getDateTime();
|
Date time1 = timePicker1.getDateTime();
|
||||||
Date time2 = timePicker2.getDateTime();
|
Date time2 = timePicker2.getDateTime();
|
||||||
|
@ -95,29 +94,40 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
timePicker1PreviousDate = time1;
|
timePicker1PreviousDate = time1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
timePicker2.addChangeHandler(new ChangeHandler<Date>() {
|
timePicker2.addValueChangeHandler(new ValueChangeHandler<Date>() {
|
||||||
public void onChange(ChangeEvent<Date> event) {
|
@Override
|
||||||
listener.onChange(timePicker2);
|
public void onValueChange(ValueChangeEvent<Date> dateValueChangeEvent) {
|
||||||
|
// Hack to stitch together these old and new APIs
|
||||||
|
ChangeEvent event = new ChangeEvent() {
|
||||||
|
@Override
|
||||||
|
public Object getSource() {
|
||||||
|
return timePicker2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handler.onChange(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildTimeZoneList() {
|
private void buildTimeZoneList() {
|
||||||
for (TimeZoneInfo info : TimeZoneList.TIMEZONES) {
|
for (TimeZoneInfo info : TimeZoneList.TIMEZONES) {
|
||||||
timeZones.addItem(info.GMTRelative + ' ' + info.abreviation, String.valueOf(info.gmtDiff));
|
timeZones.addItem(info.getGMTRelative() + ' ' + info.getAbreviation(),
|
||||||
|
String.valueOf(info.getGmtDiff()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Calendar event";
|
return "Calendar event";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
datePicker1.getDatePicker().setSelectedDate(new Date());
|
datePicker1.setValue(new Date());
|
||||||
datePicker2.getDatePicker().setSelectedDate(new Date());
|
datePicker2.setValue(new Date());
|
||||||
table = new Grid(10, 2);
|
table = new Grid(10, 2);
|
||||||
|
|
||||||
table.setText(0, 0, "All day event");
|
table.setText(0, 0, "All day event");
|
||||||
|
@ -155,24 +165,22 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
table.getRowFormatter().getElement(6).setId(FULL_DAY_ONLY_IDS[2]);
|
table.getRowFormatter().getElement(6).setId(FULL_DAY_ONLY_IDS[2]);
|
||||||
table.getRowFormatter().getElement(7).setId(FULL_DAY_ONLY_IDS[3]);
|
table.getRowFormatter().getElement(7).setId(FULL_DAY_ONLY_IDS[3]);
|
||||||
|
|
||||||
fullDay.addClickListener(new ClickListener() {
|
fullDay.addClickHandler(new ClickHandler() {
|
||||||
public void onClick(Widget sender) {
|
@Override
|
||||||
CheckBox cb = (CheckBox) sender;
|
public void onClick(ClickEvent event) {
|
||||||
setFullDay(cb.isChecked());
|
CheckBox cb = (CheckBox) event.getSource();
|
||||||
|
for (String s : FULL_DAY_ONLY_IDS) {
|
||||||
|
Element element = DOM.getElementById(s);
|
||||||
|
String style = cb.getValue() ? "none" : "";
|
||||||
|
DOM.setStyleAttribute(element, "display", style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setFullDay(boolean fullDay) {
|
@Override
|
||||||
for (String s : FULL_DAY_ONLY_IDS) {
|
|
||||||
Element element = DOM.getElementById(s);
|
|
||||||
String style = fullDay ? "none" : "";
|
|
||||||
DOM.setStyleAttribute(element, "display", style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String eventName = getEventNameField();
|
String eventName = getEventNameField();
|
||||||
String dates = getDateTimeFields();
|
String dates = getDateTimeFields();
|
||||||
|
@ -194,14 +202,13 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
throw new GeneratorException("Event name must be at least 1 character.");
|
throw new GeneratorException("Event name must be at least 1 character.");
|
||||||
}
|
}
|
||||||
if (inputName.contains("\n")) {
|
if (inputName.contains("\n")) {
|
||||||
throw new GeneratorException(
|
throw new GeneratorException("Event name should not contain \\n characters.");
|
||||||
"Event name should not contain \\n characters.");
|
|
||||||
}
|
}
|
||||||
return "SUMMARY:" + inputName + "\r\n";
|
return "SUMMARY:" + inputName + "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDateTimeFields() throws GeneratorException {
|
private String getDateTimeFields() throws GeneratorException {
|
||||||
if (fullDay.isChecked()) {
|
if (fullDay.getValue()) {
|
||||||
return getFullDayDateFields();
|
return getFullDayDateFields();
|
||||||
}
|
}
|
||||||
return getDateTimeValues();
|
return getDateTimeValues();
|
||||||
|
@ -232,9 +239,9 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFullDayDateFields() throws GeneratorException {
|
private String getFullDayDateFields() throws GeneratorException {
|
||||||
Date date1 = datePicker1.getDatePicker().getSelectedDate();
|
Date date1 = datePicker1.getValue();
|
||||||
Date date2 = datePicker2.getDatePicker().getSelectedDate();
|
Date date2 = datePicker2.getValue();
|
||||||
if (null == date1 || null == date2) {
|
if (date1 == null || date2 == null) {
|
||||||
throw new GeneratorException("Start and end dates must be set.");
|
throw new GeneratorException("Start and end dates must be set.");
|
||||||
}
|
}
|
||||||
if (date1.after(date2)) {
|
if (date1.after(date2)) {
|
||||||
|
@ -252,27 +259,24 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDateTimeValues() throws GeneratorException {
|
private String getDateTimeValues() throws GeneratorException {
|
||||||
Date date1 = datePicker1.getDatePicker().getSelectedDate();
|
Date date1 = datePicker1.getValue();
|
||||||
Date date2 = datePicker2.getDatePicker().getSelectedDate();
|
Date date2 = datePicker2.getValue();
|
||||||
Date time1 = timePicker1.getDateTime();
|
Date time1 = timePicker1.getDateTime();
|
||||||
Date time2 = timePicker2.getDateTime();
|
Date time2 = timePicker2.getDateTime();
|
||||||
if (null == date1 || null == date2 || null == time1 || null == time2) {
|
if (date1 == null || date2 == null || time1 == null || time2 == null) {
|
||||||
throw new GeneratorException("Start and end dates/times must be set.");
|
throw new GeneratorException("Start and end dates/times must be set.");
|
||||||
}
|
}
|
||||||
String timezoneDelta = timeZones.getValue(timeZones.getSelectedIndex());
|
String timezoneDelta = timeZones.getValue(timeZones.getSelectedIndex());
|
||||||
long diffTimeZone = Long.parseLong(timezoneDelta);
|
long diffTimeZone = Long.parseLong(timezoneDelta);
|
||||||
if (summerTime.isChecked()) {
|
if (summerTime.getValue()) {
|
||||||
diffTimeZone += ONE_HOUR;
|
diffTimeZone += ONE_HOUR;
|
||||||
}
|
}
|
||||||
Date dateTime1 = addMilliseconds(mergeDateAndTime(date1, time1),
|
Date dateTime1 = addMilliseconds(mergeDateAndTime(date1, time1), -diffTimeZone);
|
||||||
-diffTimeZone);
|
Date dateTime2 = addMilliseconds(mergeDateAndTime(date2, time2), -diffTimeZone);
|
||||||
Date dateTime2 = addMilliseconds(mergeDateAndTime(date2, time2),
|
|
||||||
-diffTimeZone);
|
|
||||||
if (dateTime1.after(dateTime2)) {
|
if (dateTime1.after(dateTime2)) {
|
||||||
throw new GeneratorException("Ending date is after starting date.");
|
throw new GeneratorException("Ending date is after starting date.");
|
||||||
}
|
}
|
||||||
DateTimeFormat isoFormatter = DateTimeFormat
|
DateTimeFormat isoFormatter = DateTimeFormat.getFormat("yyyyMMdd'T'HHmmss'Z'");
|
||||||
.getFormat("yyyyMMdd'T'HHmmss'Z'");
|
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
output.append("DTSTART:");
|
output.append("DTSTART:");
|
||||||
output.append(isoFormatter.format(dateTime1));
|
output.append(isoFormatter.format(dateTime1));
|
||||||
|
@ -294,11 +298,11 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
return merger.parse(d + t);
|
return merger.parse(d + t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == eventName) {
|
if (widget == eventName) {
|
||||||
getEventNameField();
|
getEventNameField();
|
||||||
} else if (widget == datePicker1 || widget == timePicker1 || widget == datePicker2
|
} else if (widget == datePicker1 || widget == timePicker1 || widget == datePicker2 || widget == timePicker2) {
|
||||||
|| widget == timePicker2) {
|
|
||||||
getDateTimeFields();
|
getDateTimeFields();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,6 +311,7 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
return new Date(time1.getTime() + milliseconds);
|
return new Date(time1.getTime() + milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
eventName.setFocus(true);
|
eventName.setFocus(true);
|
||||||
}
|
}
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
|
import com.google.gwt.user.client.ui.ListBox;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
@ -27,30 +28,36 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class ContactInfoGenerator implements GeneratorSource {
|
public final class ContactInfoGenerator implements GeneratorSource {
|
||||||
Grid table = null;
|
|
||||||
TextBox name = new TextBox();
|
private Grid table;
|
||||||
TextBox company = new TextBox();
|
private final ListBox encoding = new ListBox();
|
||||||
TextBox tel = new TextBox();
|
private final TextBox name = new TextBox();
|
||||||
TextBox url = new TextBox();
|
private final TextBox company = new TextBox();
|
||||||
TextBox email = new TextBox();
|
private final TextBox tel = new TextBox();
|
||||||
TextBox address = new TextBox();
|
private final TextBox url = new TextBox();
|
||||||
TextBox address2 = new TextBox();
|
private final TextBox email = new TextBox();
|
||||||
TextBox memo = new TextBox();
|
private final TextBox address = new TextBox();
|
||||||
TextBox[] widgets = {name, company, tel, url, email, address, address2, memo};
|
private final TextBox address2 = new TextBox();
|
||||||
|
private final TextBox memo = new TextBox();
|
||||||
public ContactInfoGenerator(ChangeListener changeListener,
|
|
||||||
KeyPressHandler keyListener) {
|
public ContactInfoGenerator(ChangeHandler changeHandler, KeyPressHandler keyListener) {
|
||||||
|
TextBox[] widgets = {name, company, tel, url, email, address, address2, memo};
|
||||||
for (TextBox w: widgets) {
|
for (TextBox w: widgets) {
|
||||||
w.addChangeListener(changeListener);
|
w.addChangeHandler(changeHandler);
|
||||||
w.addKeyPressHandler(keyListener);
|
w.addKeyPressHandler(keyListener);
|
||||||
}
|
}
|
||||||
|
encoding.addItem("MECARD");
|
||||||
|
encoding.addItem("vCard");
|
||||||
|
encoding.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Contact information";
|
return "Contact information";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String name = getNameField();
|
String name = getNameField();
|
||||||
String company = getCompanyField();
|
String company = getCompanyField();
|
||||||
|
@ -63,74 +70,69 @@ public class ContactInfoGenerator implements GeneratorSource {
|
||||||
|
|
||||||
// Build the output with obtained data.
|
// Build the output with obtained data.
|
||||||
// note that some informations may just be "" if they were not specified.
|
// note that some informations may just be "" if they were not specified.
|
||||||
//return getVCard(name, company, tel, url, email, address, memo);
|
if ("vCard".equals(encoding.getValue(encoding.getSelectedIndex()))) {
|
||||||
|
return getVCard(name, company, tel, url, email, address, address2, memo);
|
||||||
|
}
|
||||||
return getMeCard(name, company, tel, url, email, address, address2, memo);
|
return getMeCard(name, company, tel, url, email, address, address2, memo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMeCard(String name, String company, String tel, String url,
|
private static String getMeCard(String name, String company, String tel, String url,
|
||||||
String email, String address, String address2, String memo) {
|
String email, String address, String address2, String memo) {
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder(100);
|
||||||
output.append("MECARD:");
|
output.append("MECARD:");
|
||||||
name = name.replace(",", ""); // remove commas -- reserved char in MECARD
|
maybeAppendMECARD(output, "N", name.replace(",", ""));
|
||||||
output.append("N:").append(name).append(';');
|
maybeAppendMECARD(output, "ORG", company);
|
||||||
maybeAppend(output, "ORG:", company); // Not standard; don't generate
|
maybeAppendMECARD(output, "TEL", tel);
|
||||||
maybeAppend(output, "TEL:", tel);
|
maybeAppendMECARD(output, "URL", url);
|
||||||
maybeAppend(output, "URL:", url);
|
maybeAppendMECARD(output, "EMAIL", email);
|
||||||
maybeAppend(output, "EMAIL:", email);
|
maybeAppendMECARD(output, "ADR", buildAddress(address, address2));
|
||||||
if (address.length() > 0 || address2.length() > 0) {
|
maybeAppendMECARD(output, "NOTE", memo);
|
||||||
output.append("ADR:");
|
|
||||||
if (address.length() > 0) {
|
|
||||||
output.append(address);
|
|
||||||
}
|
|
||||||
if (address2.length() > 0) {
|
|
||||||
if (address.length() > 0) {
|
|
||||||
output.append(' ');
|
|
||||||
}
|
|
||||||
output.append(address2);
|
|
||||||
}
|
|
||||||
output.append(';');
|
|
||||||
}
|
|
||||||
maybeAppend(output, "NOTE:", memo);
|
|
||||||
output.append(';');
|
output.append(';');
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String buildAddress(String address, String address2) {
|
||||||
|
if (address.length() > 0) {
|
||||||
|
if (address2.length() > 0) {
|
||||||
|
return address + ' ' + address2;
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
if (address2.length() > 0) {
|
||||||
|
return address2;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
private static void maybeAppend(StringBuilder output, String prefix, String value) {
|
private static void maybeAppendMECARD(StringBuilder output, String prefix, String value) {
|
||||||
if (value.length() > 0) {
|
if (value.length() > 0) {
|
||||||
output.append(prefix).append(value).append(';');
|
value = value.replaceAll("([:;])", "\\\\$1");
|
||||||
|
value = value.replaceAll("\\n", "");
|
||||||
|
output.append(prefix).append(':').append(value).append(';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*// VCARD GENERATION. Keep this in case we want to go back to vcard format
|
private static String getVCard(String name, String company, String tel, String url,
|
||||||
// or have the option.
|
String email, String address, String address2, String memo) {
|
||||||
private String getVCard(String name, String company, String tel, String url,
|
StringBuilder output = new StringBuilder(100);
|
||||||
String email, String address, String memo) {
|
output.append("BEGIN:VCARD\n");
|
||||||
String output = "BEGIN:VCARD\n";
|
maybeAppendvCard(output, "N", name);
|
||||||
output += "N:" + name + "\n";
|
maybeAppendvCard(output, "ORG", company);
|
||||||
output += company.length() > 0 ? "ORG:" + company + "\n" : "";
|
maybeAppendvCard(output, "TEL", tel);
|
||||||
output += tel.length() > 0 ? "TEL:" + tel + "\n" : "";
|
maybeAppendvCard(output, "URL", url);
|
||||||
output += url.length() > 0 ? "URL:" + url + "\n" : "";
|
maybeAppendvCard(output, "EMAIL", email);
|
||||||
output += email.length() > 0 ? "EMAIL:" + email + "\n" : "";
|
maybeAppendvCard(output, "ADR", buildAddress(address, address2));
|
||||||
output += address.length() > 0 ? "ADR:" + address + "\n" : "";
|
maybeAppendvCard(output, "NOTE", memo);
|
||||||
output += memo.length() > 0 ? "NOTE:" + memo + "\n" : "";
|
output.append("END:VCARD");
|
||||||
output += "END:VCARD";
|
return output.toString();
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
private static void maybeAppendvCard(StringBuilder output, String prefix, String value) {
|
||||||
private static String parseTextField(String name, TextBox textBox) throws GeneratorException {
|
if (value.length() > 0) {
|
||||||
String input = textBox.getText();
|
value = value.replaceAll("([\\\\:;])", "\\\\$1");
|
||||||
if (input.length() < 1) {
|
value = value.replaceAll("\\n", "\\\\n");
|
||||||
return "";
|
output.append(prefix).append(':').append(value).append('\n');
|
||||||
}
|
}
|
||||||
if (input.contains("\n")) {
|
|
||||||
throw new GeneratorException(name + " field must not contain \\n characters.");
|
|
||||||
}
|
|
||||||
if (input.contains(";")) {
|
|
||||||
throw new GeneratorException(name + " field must not contains ; characters");
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNameField() throws GeneratorException {
|
private String getNameField() throws GeneratorException {
|
||||||
|
@ -138,11 +140,11 @@ public class ContactInfoGenerator implements GeneratorSource {
|
||||||
if (input.length() < 1) {
|
if (input.length() < 1) {
|
||||||
throw new GeneratorException("Name must be at least 1 character.");
|
throw new GeneratorException("Name must be at least 1 character.");
|
||||||
}
|
}
|
||||||
return parseTextField("Name", name);
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCompanyField() throws GeneratorException {
|
private String getCompanyField() {
|
||||||
return parseTextField("Company", company);
|
return company.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTelField() throws GeneratorException {
|
private String getTelField() throws GeneratorException {
|
||||||
|
@ -177,24 +179,25 @@ public class ContactInfoGenerator implements GeneratorSource {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAddressField() throws GeneratorException {
|
private String getAddressField() {
|
||||||
return parseTextField("Address", address);
|
return address.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAddress2Field() throws GeneratorException {
|
private String getAddress2Field() {
|
||||||
return parseTextField("Address 2", address2);
|
return address2.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMemoField() throws GeneratorException {
|
private String getMemoField() {
|
||||||
return parseTextField("Memo", memo);
|
return memo.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
// early termination if the table has already been constructed
|
// early termination if the table has already been constructed
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
table = new Grid(8, 2);
|
table = new Grid(9, 2);
|
||||||
|
|
||||||
table.setText(0, 0, "Name");
|
table.setText(0, 0, "Name");
|
||||||
table.setWidget(0, 1, name);
|
table.setWidget(0, 1, name);
|
||||||
|
@ -212,22 +215,42 @@ public class ContactInfoGenerator implements GeneratorSource {
|
||||||
table.setWidget(6, 1, url);
|
table.setWidget(6, 1, url);
|
||||||
table.setText(7, 0, "Memo");
|
table.setText(7, 0, "Memo");
|
||||||
table.setWidget(7, 1, memo);
|
table.setWidget(7, 1, memo);
|
||||||
|
table.setText(8, 0, "Encoding");
|
||||||
|
table.setWidget(8, 1, encoding);
|
||||||
|
|
||||||
name.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
name.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == name) getNameField();
|
if (widget == name) {
|
||||||
if (widget == company) getCompanyField();
|
getNameField();
|
||||||
if (widget == tel) getTelField();
|
}
|
||||||
if (widget == email) getEmailField();
|
if (widget == company) {
|
||||||
if (widget == address) getAddressField();
|
getCompanyField();
|
||||||
if (widget == address2) getAddress2Field();
|
}
|
||||||
if (widget == url) getUrlField();
|
if (widget == tel) {
|
||||||
if (widget == memo) getMemoField();
|
getTelField();
|
||||||
|
}
|
||||||
|
if (widget == email) {
|
||||||
|
getEmailField();
|
||||||
|
}
|
||||||
|
if (widget == address) {
|
||||||
|
getAddressField();
|
||||||
|
}
|
||||||
|
if (widget == address2) {
|
||||||
|
getAddress2Field();
|
||||||
|
}
|
||||||
|
if (widget == url) {
|
||||||
|
getUrlField();
|
||||||
|
}
|
||||||
|
if (widget == memo) {
|
||||||
|
getMemoField();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
name.setFocus(true);
|
name.setFocus(true);
|
||||||
}
|
}
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -27,23 +27,25 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class EmailGenerator implements GeneratorSource {
|
public final class EmailGenerator implements GeneratorSource {
|
||||||
Grid table = null;
|
|
||||||
TextBox email = new TextBox();
|
private Grid table;
|
||||||
|
private final TextBox email = new TextBox();
|
||||||
|
|
||||||
public EmailGenerator(ChangeListener listener, KeyPressHandler keyListener) {
|
public EmailGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
email.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
email.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
email.addChangeListener(listener);
|
email.addChangeHandler(handler);
|
||||||
email.addKeyPressHandler(keyListener);
|
email.addKeyPressHandler(keyListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Email address";
|
return "Email address";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String email = getEmailField();
|
return "mailto:" + getEmailField();
|
||||||
return "mailto:"+email;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEmailField() throws GeneratorException {
|
private String getEmailField() throws GeneratorException {
|
||||||
|
@ -55,24 +57,25 @@ public class EmailGenerator implements GeneratorSource {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
table = new Grid(1, 2);
|
table = new Grid(1, 2);
|
||||||
|
|
||||||
table.setText(0, 0, "Address");
|
table.setText(0, 0, "Address");
|
||||||
table.setWidget(0, 1, email);
|
table.setWidget(0, 1, email);
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == email) {
|
if (widget == email) {
|
||||||
getEmailField();
|
getEmailField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
email.setFocus(true);
|
email.setFocus(true);
|
||||||
}
|
}
|
|
@ -17,77 +17,78 @@
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
import com.google.gwt.dom.client.Element;
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.http.client.URL;
|
import com.google.gwt.http.client.URL;
|
||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
|
import com.google.gwt.user.client.Element;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.ClickListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.HTMLTable;
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
import com.google.gwt.user.client.ui.Image;
|
||||||
import com.google.gwt.user.client.ui.ListBox;
|
import com.google.gwt.user.client.ui.ListBox;
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
import com.google.gwt.user.client.ui.SimplePanel;
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
|
import com.google.gwt.user.client.ui.TextArea;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
public final class Generator implements EntryPoint {
|
||||||
* Entry point classes define <code>onModuleLoad()</code>. Setup the page, and loads
|
|
||||||
* all different generators.
|
|
||||||
*
|
|
||||||
* @author Yohann Coppel
|
|
||||||
*/
|
|
||||||
public class Generator implements EntryPoint {
|
|
||||||
// public static final StringConstants S = GWT.create(StringConstants.class);
|
|
||||||
private final List<GeneratorSource> generators = new ArrayList<GeneratorSource>();
|
private final List<GeneratorSource> generators = new ArrayList<GeneratorSource>();
|
||||||
ListBox genList = new ListBox();
|
private final ListBox genList = new ListBox();
|
||||||
ListBox sizeList = new ListBox();
|
private final ListBox sizeList = new ListBox();
|
||||||
Image result = new Image("");//http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=http://google.com");
|
private final ListBox ecLevelList = new ListBox();
|
||||||
Grid topPanel = new Grid(5, 1);
|
private final ListBox encodingList = new ListBox();
|
||||||
GeneratorSource selectedGenerator = null;
|
private final Image result = new Image("");
|
||||||
private Button generateButton;
|
private final HTMLTable topPanel = new Grid(5, 1);
|
||||||
VerticalPanel rightPanel = new VerticalPanel();
|
private GeneratorSource selectedGenerator = null;
|
||||||
TextBox urlResult = new TextBox();
|
private final VerticalPanel rightPanel = new VerticalPanel();
|
||||||
HTML downloadText = new HTML("<a href=\"\" id=\"downloadlink\" >Download</a> or embed with this URL:");
|
private final TextBox urlResult = new TextBox();
|
||||||
//Element errorElement = null;
|
private final Widget downloadText =
|
||||||
|
new HTML("<a href=\"\" id=\"downloadlink\" >Download</a> or embed with this URL:");
|
||||||
|
private final TextArea rawTextResult = new TextArea();
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
loadGenerators();
|
loadGenerators();
|
||||||
|
|
||||||
HorizontalPanel mainPanel = new HorizontalPanel();
|
HorizontalPanel mainPanel = new HorizontalPanel();
|
||||||
setupLeftPanel();
|
setupLeftPanel();
|
||||||
topPanel.getElement().setId("leftpanel");
|
topPanel.getElement().setId("leftpanel");
|
||||||
Widget leftPanel = topPanel;
|
Widget leftPanel = topPanel;
|
||||||
|
|
||||||
mainPanel.add(leftPanel);
|
mainPanel.add(leftPanel);
|
||||||
|
|
||||||
SimplePanel div = new SimplePanel();
|
SimplePanel div = new SimplePanel();
|
||||||
SimplePanel div2 = new SimplePanel();
|
SimplePanel div2 = new SimplePanel();
|
||||||
div2.add(result);
|
div2.add(result);
|
||||||
div2.getElement().setId("innerresult");
|
div2.getElement().setId("innerresult");
|
||||||
div.add(div2);
|
div.add(div2);
|
||||||
div.getElement().setId("imageresult");
|
div.getElement().setId("imageresult");
|
||||||
|
|
||||||
urlResult.getElement().setId("urlresult");
|
urlResult.getElement().setId("urlresult");
|
||||||
|
rawTextResult.getElement().setId("rawtextresult");
|
||||||
|
rawTextResult.setCharacterWidth(50);
|
||||||
|
rawTextResult.setVisibleLines(8);
|
||||||
downloadText.getElement().setId("downloadText");
|
downloadText.getElement().setId("downloadText");
|
||||||
rightPanel.add(div);
|
rightPanel.add(div);
|
||||||
rightPanel.add(downloadText);
|
rightPanel.add(downloadText);
|
||||||
rightPanel.add(urlResult);
|
rightPanel.add(urlResult);
|
||||||
|
rightPanel.add(rawTextResult);
|
||||||
mainPanel.add(rightPanel);
|
mainPanel.add(rightPanel);
|
||||||
mainPanel.getElement().setId("mainpanel");
|
mainPanel.getElement().setId("mainpanel");
|
||||||
RootPanel.get("ui").add(mainPanel);
|
RootPanel.get("ui").add(mainPanel);
|
||||||
//RootPanel.get().add(output);
|
|
||||||
//output.setHeight("200px");
|
|
||||||
//output.setWidth("500px");
|
|
||||||
setWidget(1);
|
setWidget(1);
|
||||||
invalidateBarcode();
|
invalidateBarcode();
|
||||||
}
|
}
|
||||||
|
@ -105,99 +106,119 @@ public class Generator implements EntryPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadGenerators() {
|
private void loadGenerators() {
|
||||||
generators.add(new CalendarEventGenerator(changeListener, keyPressHandler));
|
generators.add(new CalendarEventGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new ContactInfoGenerator(changeListener, keyPressHandler));
|
generators.add(new ContactInfoGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new EmailGenerator(changeListener, keyPressHandler));
|
generators.add(new EmailGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new GeoLocationGenerator(changeListener, keyPressHandler));
|
generators.add(new GeoLocationGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new PhoneNumberGenerator(changeListener, keyPressHandler));
|
generators.add(new PhoneNumberGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new SmsAddressGenerator(changeListener, keyPressHandler));
|
generators.add(new SmsAddressGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new TextGenerator(changeListener));
|
generators.add(new TextGenerator(changeHandler));
|
||||||
generators.add(new UrlGenerator(changeListener, keyPressHandler));
|
generators.add(new UrlGenerator(changeHandler, keyPressHandler));
|
||||||
generators.add(new WifiGenerator(changeListener, keyPressHandler));
|
generators.add(new WifiGenerator(changeHandler, keyPressHandler));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupLeftPanel() {
|
void setupLeftPanel() {
|
||||||
topPanel.setHTML(2, 0,
|
topPanel.setHTML(2, 0,
|
||||||
"<span id=\"errorMessageID\" class=\""+StylesDefs.ERROR_MESSAGE+"\"></span>");
|
"<span id=\"errorMessageID\" class=\""+StylesDefs.ERROR_MESSAGE+"\"></span>");
|
||||||
|
|
||||||
// fills up the list of generators
|
// fills up the list of generators
|
||||||
for(GeneratorSource generator: generators) {
|
for(GeneratorSource generator: generators) {
|
||||||
genList.addItem(generator.getName());
|
genList.addItem(generator.getName());
|
||||||
setGridStyle(generator.getWidget());
|
setGridStyle(generator.getWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeList.addItem("S", "120");
|
sizeList.addItem("Small", "120");
|
||||||
sizeList.addItem("M", "230");
|
sizeList.addItem("Medium", "230");
|
||||||
sizeList.addItem("L", "350");
|
sizeList.addItem("Large", "350");
|
||||||
sizeList.setSelectedIndex(2);
|
sizeList.setSelectedIndex(2);
|
||||||
|
|
||||||
|
ecLevelList.addItem("L");
|
||||||
|
ecLevelList.addItem("M");
|
||||||
|
ecLevelList.addItem("Q");
|
||||||
|
ecLevelList.addItem("H");
|
||||||
|
ecLevelList.setSelectedIndex(0);
|
||||||
|
|
||||||
// updates the second row of the table with the content of the selected
|
encodingList.addItem("UTF-8");
|
||||||
// generator
|
encodingList.addItem("ISO-8859-1");
|
||||||
genList.addChangeListener(new ChangeListener() {
|
encodingList.addItem("Shift_JIS");
|
||||||
public void onChange(Widget sender) {
|
encodingList.setSelectedIndex(0);
|
||||||
|
|
||||||
|
// updates the second row of the table with the content of the selected generator
|
||||||
|
genList.addChangeHandler(new ChangeHandler() {
|
||||||
|
@Override
|
||||||
|
public void onChange(ChangeEvent Event) {
|
||||||
int i = genList.getSelectedIndex();
|
int i = genList.getSelectedIndex();
|
||||||
setWidget(i);
|
setWidget(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// grid for the generator picker
|
// grid for the generator picker
|
||||||
Grid selectionTable = new Grid(1, 2);
|
HTMLTable selectionTable = new Grid(1, 2);
|
||||||
selectionTable.setText(0, 0, "Contents");
|
selectionTable.setText(0, 0, "Contents");
|
||||||
selectionTable.setWidget(0, 1, genList);
|
selectionTable.setWidget(0, 1, genList);
|
||||||
setGridStyle(selectionTable);
|
setGridStyle(selectionTable);
|
||||||
|
|
||||||
topPanel.setWidget(0, 0, selectionTable);
|
topPanel.setWidget(0, 0, selectionTable);
|
||||||
|
|
||||||
// grid for the generate button
|
// grid for the generate button
|
||||||
Grid generateGrid = new Grid(1, 2);
|
HTMLTable generateGrid = new Grid(1, 2);
|
||||||
setGridStyle(generateGrid);
|
setGridStyle(generateGrid);
|
||||||
|
|
||||||
generateButton = new Button("Generate →");
|
Button generateButton = new Button("Generate →");
|
||||||
generateButton.addClickListener(new ClickListener() {
|
generateButton.addClickHandler(new ClickHandler() {
|
||||||
public void onClick(Widget sender) {
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
generate();
|
generate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
generateGrid.setWidget(0,1,generateButton);
|
generateGrid.setWidget(0, 1, generateButton);
|
||||||
topPanel.setWidget(4, 0, generateGrid);
|
topPanel.setWidget(4, 0, generateGrid);
|
||||||
|
|
||||||
Grid sizeTable = new Grid(1, 2);
|
HTMLTable configTable = new Grid(3, 2);
|
||||||
sizeTable.setText(0, 0, "Barcode size");
|
configTable.setText(0, 0, "Barcode size");
|
||||||
sizeTable.setWidget(0, 1, sizeList);
|
configTable.setWidget(0, 1, sizeList);
|
||||||
setGridStyle(sizeTable);
|
configTable.setText(1, 0, "Error correction");
|
||||||
topPanel.setWidget(3, 0, sizeTable);
|
configTable.setWidget(1, 1, ecLevelList);
|
||||||
|
configTable.setText(2, 0, "Character encoding");
|
||||||
|
configTable.setWidget(2, 1, encodingList);
|
||||||
|
setGridStyle(configTable);
|
||||||
|
topPanel.setWidget(3, 0, configTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setGridStyle(Grid grid) {
|
private static void setGridStyle(HTMLTable grid) {
|
||||||
grid.getColumnFormatter().addStyleName(0, "firstColumn");
|
grid.getColumnFormatter().addStyleName(0, "firstColumn");
|
||||||
grid.getColumnFormatter().addStyleName(1, "secondColumn");
|
grid.getColumnFormatter().addStyleName(1, "secondColumn");
|
||||||
CellFormatter cellFormatter = grid.getCellFormatter();
|
HTMLTable.CellFormatter cellFormatter = grid.getCellFormatter();
|
||||||
for(int i = 0; i < grid.getRowCount(); ++i) {
|
for (int i = 0; i < grid.getRowCount(); ++i) {
|
||||||
cellFormatter.addStyleName(i, 0, "firstColumn");
|
cellFormatter.addStyleName(i, 0, "firstColumn");
|
||||||
cellFormatter.addStyleName(i, 1, "secondColumn");
|
cellFormatter.addStyleName(i, 1, "secondColumn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getUrl(int sizeX, int sizeY, String content) {
|
private static String getUrl(int sizeX, int sizeY, String ecLevel, String encoding, String content) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder(100);
|
||||||
result.append("http://chart.apis.google.com/chart?cht=qr&chs=");
|
result.append("http://chart.apis.google.com/chart?cht=qr");
|
||||||
result.append(sizeX).append('x').append(sizeY);
|
result.append("&chs=").append(sizeX).append('x').append(sizeY);
|
||||||
result.append("&chl=");
|
result.append("&chld=").append(ecLevel);
|
||||||
result.append(URL.encodeComponent(content));
|
result.append("&choe=").append(encoding);
|
||||||
|
result.append("&chl=").append(URL.encodeQueryString(content));
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generate() {
|
private void generate() {
|
||||||
try {
|
try {
|
||||||
String text = selectedGenerator.getText();
|
String text = selectedGenerator.getText();
|
||||||
eraseErrorMessage();
|
eraseErrorMessage();
|
||||||
int size = Integer.parseInt(sizeList
|
int size = Integer.parseInt(sizeList.getValue(sizeList.getSelectedIndex()));
|
||||||
.getValue(sizeList.getSelectedIndex()));
|
String ecLevel = ecLevelList.getValue(ecLevelList.getSelectedIndex());
|
||||||
String url = getUrl(size, size, text);
|
String encoding = encodingList.getValue(encodingList.getSelectedIndex());
|
||||||
|
String url = getUrl(size, size, ecLevel, encoding, text);
|
||||||
result.setUrl(url);
|
result.setUrl(url);
|
||||||
result.setVisible(true);
|
result.setVisible(true);
|
||||||
urlResult.setText(url);
|
urlResult.setText(url);
|
||||||
urlResult.setVisible(true);
|
urlResult.setVisible(true);
|
||||||
|
rawTextResult.setText(text);
|
||||||
|
rawTextResult.setVisible(true);
|
||||||
Element linkElement = DOM.getElementById("downloadlink");
|
Element linkElement = DOM.getElementById("downloadlink");
|
||||||
linkElement.setAttribute("href", url);
|
linkElement.setAttribute("href", url);
|
||||||
downloadText.setVisible(true);
|
downloadText.setVisible(true);
|
||||||
|
@ -207,30 +228,33 @@ public class Generator implements EntryPoint {
|
||||||
showErrorMessage(error);
|
showErrorMessage(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidateBarcode() {
|
void invalidateBarcode() {
|
||||||
result.setVisible(false);
|
result.setVisible(false);
|
||||||
urlResult.setText("");
|
urlResult.setText("");
|
||||||
urlResult.setVisible(false);
|
urlResult.setVisible(false);
|
||||||
|
rawTextResult.setText("");
|
||||||
|
rawTextResult.setVisible(false);
|
||||||
Element linkElement = DOM.getElementById("downloadlink");
|
Element linkElement = DOM.getElementById("downloadlink");
|
||||||
linkElement.setAttribute("href", "");
|
linkElement.setAttribute("href", "");
|
||||||
downloadText.setVisible(false);
|
downloadText.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showErrorMessage(String error) {
|
private static void showErrorMessage(String error) {
|
||||||
Element errorElement = DOM.getElementById("errorMessageID");
|
Element errorElement = DOM.getElementById("errorMessageID");
|
||||||
errorElement.setInnerHTML(error);
|
errorElement.setInnerHTML(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void eraseErrorMessage() {
|
private static void eraseErrorMessage() {
|
||||||
Element errorElement = DOM.getElementById("errorMessageID");
|
Element errorElement = DOM.getElementById("errorMessageID");
|
||||||
errorElement.setInnerHTML(" ");
|
errorElement.setInnerHTML(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeListener changeListener = new ChangeListener() {
|
private final ChangeHandler changeHandler = new ChangeHandler() {
|
||||||
public void onChange(Widget sender) {
|
@Override
|
||||||
|
public void onChange(ChangeEvent event) {
|
||||||
try {
|
try {
|
||||||
selectedGenerator.validate(sender);
|
selectedGenerator.validate((Widget) event.getSource());
|
||||||
eraseErrorMessage();
|
eraseErrorMessage();
|
||||||
} catch (GeneratorException ex) {
|
} catch (GeneratorException ex) {
|
||||||
String error = ex.getMessage();
|
String error = ex.getMessage();
|
||||||
|
@ -239,8 +263,8 @@ public class Generator implements EntryPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public KeyPressHandler keyPressHandler = new KeyPressHandler() {
|
private final KeyPressHandler keyPressHandler = new KeyPressHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onKeyPress(KeyPressEvent event) {
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
if (event.getCharCode() == '\n' || event.getCharCode() == '\r') {
|
if (event.getCharCode() == '\n' || event.getCharCode() == '\r') {
|
|
@ -23,8 +23,10 @@ package com.google.zxing.web.generator.client;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class GeneratorException extends Exception {
|
final class GeneratorException extends Exception {
|
||||||
public GeneratorException(String message) {
|
|
||||||
|
GeneratorException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generator for geo location. It also accepts a google maps links and
|
||||||
|
* extracts the coordinates and query from the URL.
|
||||||
|
*
|
||||||
|
* @author Yohann Coppel
|
||||||
|
*/
|
||||||
|
public final class GeoLocationGenerator implements GeneratorSource {
|
||||||
|
|
||||||
|
private static final String LON_REGEXP = "[+-]?[0-9]+(.[0-9]+)?";
|
||||||
|
private static final String LAT_REGEXP = "[+-]?[0-9]+(.[0-9]+)?";
|
||||||
|
|
||||||
|
private Grid table;
|
||||||
|
private final TextBox latitude = new TextBox();
|
||||||
|
private final TextBox longitude = new TextBox();
|
||||||
|
private final TextBox query = new TextBox();
|
||||||
|
|
||||||
|
public GeoLocationGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
|
latitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
|
latitude.addChangeHandler(handler);
|
||||||
|
latitude.addKeyPressHandler(keyListener);
|
||||||
|
longitude.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
|
longitude.addChangeHandler(handler);
|
||||||
|
longitude.addKeyPressHandler(keyListener);
|
||||||
|
query.addChangeHandler(handler);
|
||||||
|
query.addKeyPressHandler(keyListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Geo location";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText() throws GeneratorException {
|
||||||
|
String que = getQueryField();
|
||||||
|
if (que != null && que.length() > 0) {
|
||||||
|
if (getLatitudeField() == null) {
|
||||||
|
latitude.setText("0");
|
||||||
|
}
|
||||||
|
if (getLongitudeField() == null) {
|
||||||
|
longitude.setText("0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String lat = getLatitudeField();
|
||||||
|
String lon = getLongitudeField();
|
||||||
|
|
||||||
|
if (que != null && que.length() > 0) {
|
||||||
|
return "geo:" + lat + ',' + lon + "?q=" + que;
|
||||||
|
}
|
||||||
|
return "geo:" + lat + ',' + lon;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getQueryField() {
|
||||||
|
String que = query.getText();
|
||||||
|
que = que.replace("&", "%26");
|
||||||
|
return que;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLongitudeField() throws GeneratorException {
|
||||||
|
String lon = longitude.getText();
|
||||||
|
if (!lon.matches(LON_REGEXP)) {
|
||||||
|
throw new GeneratorException("Longitude is not a correct value.");
|
||||||
|
}
|
||||||
|
double val = Double.parseDouble(lon);
|
||||||
|
if (val < -180.0 || val > 180.0) {
|
||||||
|
throw new GeneratorException("Longitude must be in [-180:180]");
|
||||||
|
}
|
||||||
|
return lon;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLatitudeField() throws GeneratorException {
|
||||||
|
String lat = latitude.getText();
|
||||||
|
if (!lat.matches(LAT_REGEXP)) {
|
||||||
|
throw new GeneratorException("Latitude is not a correct value.");
|
||||||
|
}
|
||||||
|
double val = Double.parseDouble(lat);
|
||||||
|
if (val < -90.0 || val > 90.0) {
|
||||||
|
throw new GeneratorException("Latitude must be in [-90:90]");
|
||||||
|
}
|
||||||
|
return lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Grid getWidget() {
|
||||||
|
if (table != null) {
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
table = new Grid(3, 2);
|
||||||
|
|
||||||
|
table.setText(0, 0, "Latitude");
|
||||||
|
table.setWidget(0, 1, latitude);
|
||||||
|
table.setText(1, 0, "Longitude");
|
||||||
|
table.setWidget(1, 1, longitude);
|
||||||
|
table.setText(2, 0, "Query");
|
||||||
|
table.setWidget(2, 1, query);
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
|
if (widget == latitude) {
|
||||||
|
getLatitudeField();
|
||||||
|
}
|
||||||
|
if (widget == longitude) {
|
||||||
|
getLongitudeField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocus() {
|
||||||
|
latitude.setFocus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -27,21 +27,23 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class PhoneNumberGenerator implements GeneratorSource {
|
public final class PhoneNumberGenerator implements GeneratorSource {
|
||||||
Grid table = null;
|
|
||||||
TextBox number = new TextBox();
|
private Grid table;
|
||||||
|
private final TextBox number = new TextBox();
|
||||||
|
|
||||||
public PhoneNumberGenerator(ChangeListener listener,
|
public PhoneNumberGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
KeyPressHandler keyListener) {
|
|
||||||
number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
number.addChangeListener(listener);
|
number.addChangeHandler(handler);
|
||||||
number.addKeyPressHandler(keyListener);
|
number.addKeyPressHandler(keyListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Phone number";
|
return "Phone number";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String tel = getTelField();
|
String tel = getTelField();
|
||||||
return "tel:" + tel;
|
return "tel:" + tel;
|
||||||
|
@ -57,6 +59,7 @@ public class PhoneNumberGenerator implements GeneratorSource {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
return table;
|
return table;
|
||||||
|
@ -69,12 +72,14 @@ public class PhoneNumberGenerator implements GeneratorSource {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == number) {
|
if (widget == number) {
|
||||||
getTelField();
|
getTelField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
number.setFocus(true);
|
number.setFocus(true);
|
||||||
}
|
}
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.TextArea;
|
import com.google.gwt.user.client.ui.TextArea;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
@ -29,23 +29,25 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class SmsAddressGenerator implements GeneratorSource {
|
public final class SmsAddressGenerator implements GeneratorSource {
|
||||||
Grid table = null;
|
|
||||||
TextBox number = new TextBox();
|
|
||||||
TextArea message = new TextArea();
|
|
||||||
|
|
||||||
public SmsAddressGenerator(ChangeListener listener,
|
private Grid table;
|
||||||
KeyPressHandler keyListener) {
|
private final TextBox number = new TextBox();
|
||||||
|
private final TextArea message = new TextArea();
|
||||||
|
|
||||||
|
public SmsAddressGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
number.addChangeListener(listener);
|
number.addChangeHandler(handler);
|
||||||
number.addKeyPressHandler(keyListener);
|
number.addKeyPressHandler(keyListener);
|
||||||
message.addChangeListener(listener);
|
message.addChangeHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "SMS";
|
return "SMS";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String inputNumber = getTelField();
|
String inputNumber = getTelField();
|
||||||
String inputMessage = getMessageField();
|
String inputMessage = getMessageField();
|
||||||
|
@ -77,6 +79,7 @@ public class SmsAddressGenerator implements GeneratorSource {
|
||||||
return inputMessage;
|
return inputMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
return table;
|
return table;
|
||||||
|
@ -92,6 +95,7 @@ public class SmsAddressGenerator implements GeneratorSource {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == number) {
|
if (widget == number) {
|
||||||
getTelField();
|
getTelField();
|
||||||
|
@ -101,6 +105,7 @@ public class SmsAddressGenerator implements GeneratorSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
number.setFocus(true);
|
number.setFocus(true);
|
||||||
}
|
}
|
|
@ -21,7 +21,11 @@ package com.google.zxing.web.generator.client;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class StylesDefs {
|
final class StylesDefs {
|
||||||
public static final String INPUT_FIELD_REQUIRED = "required";
|
|
||||||
public static final String ERROR_MESSAGE = "errorMessage";
|
static final String INPUT_FIELD_REQUIRED = "required";
|
||||||
|
static final String ERROR_MESSAGE = "errorMessage";
|
||||||
|
|
||||||
|
private StylesDefs() {
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.TextArea;
|
import com.google.gwt.user.client.ui.TextArea;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -26,25 +26,28 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class TextGenerator implements GeneratorSource {
|
public final class TextGenerator implements GeneratorSource {
|
||||||
TextArea text = new TextArea();
|
|
||||||
Grid table = null;
|
private Grid table;
|
||||||
String error = "";
|
private final TextArea text = new TextArea();
|
||||||
|
|
||||||
public TextGenerator(ChangeListener listener) {
|
public TextGenerator(ChangeHandler handler) {
|
||||||
text.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
text.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
text.addChangeListener(listener);
|
text.addChangeHandler(handler);
|
||||||
|
text.setVisibleLines(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Text";
|
return "Text";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
return getTextField();
|
return getTextField();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextField() throws GeneratorException {
|
String getTextField() throws GeneratorException {
|
||||||
String input = text.getText();
|
String input = text.getText();
|
||||||
if (input.length() == 0) {
|
if (input.length() == 0) {
|
||||||
throw new GeneratorException("Text should be at least 1 character.");
|
throw new GeneratorException("Text should be at least 1 character.");
|
||||||
|
@ -52,6 +55,7 @@ public class TextGenerator implements GeneratorSource {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
// early termination if the table has already been constructed
|
// early termination if the table has already been constructed
|
||||||
|
@ -67,16 +71,18 @@ public class TextGenerator implements GeneratorSource {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrorMessage() {
|
public static String getErrorMessage() {
|
||||||
return error;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == text) {
|
if (widget == text) {
|
||||||
getTextField();
|
getTextField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
text.setFocus(true);
|
text.setFocus(true);
|
||||||
}
|
}
|
|
@ -16,10 +16,34 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
import com.google.gwt.i18n.client.Messages;
|
final class TimeZoneInfo {
|
||||||
|
|
||||||
|
private final String abreviation;
|
||||||
|
private final String longName;
|
||||||
|
private final String GMTRelative;
|
||||||
|
private final long gmtDiff;
|
||||||
|
|
||||||
|
TimeZoneInfo(String abreviation, String longName, String relative, long gmtDiff) {
|
||||||
|
GMTRelative = relative;
|
||||||
|
this.abreviation = abreviation;
|
||||||
|
this.gmtDiff = gmtDiff;
|
||||||
|
this.longName = longName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getAbreviation() {
|
||||||
|
return abreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getLongName() {
|
||||||
|
return longName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getGMTRelative() {
|
||||||
|
return GMTRelative;
|
||||||
|
}
|
||||||
|
|
||||||
|
long getGmtDiff() {
|
||||||
|
return gmtDiff;
|
||||||
|
}
|
||||||
|
|
||||||
// Not used yet. A first atempt to localization.
|
|
||||||
public interface StringConstants extends Messages {
|
|
||||||
String codeType();
|
|
||||||
String generateButton();
|
|
||||||
}
|
}
|
|
@ -22,57 +22,47 @@ package com.google.zxing.web.generator.client;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class TimeZoneList {
|
final class TimeZoneList {
|
||||||
public static class TimeZoneInfo {
|
|
||||||
String abreviation;
|
private TimeZoneList() {
|
||||||
String longName;
|
|
||||||
String GMTRelative;
|
|
||||||
long gmtDiff;
|
|
||||||
public TimeZoneInfo(String abreviation, String longName, String relative, long gmtDiff) {
|
|
||||||
super();
|
|
||||||
GMTRelative = relative;
|
|
||||||
this.abreviation = abreviation;
|
|
||||||
this.gmtDiff = gmtDiff;
|
|
||||||
this.longName = longName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final long ONE_HOUR = 60L * 60 * 1000;
|
||||||
|
private static final long THIRTY_MIN = 30L * 60 * 1000;
|
||||||
|
|
||||||
private static final long ONE_HOUR = 60L*60*1000;
|
static final TimeZoneInfo[] TIMEZONES = {
|
||||||
private static final long THIRTY_MIN = 30L*60*1000;
|
new TimeZoneInfo("GMT", "Greenwich Mean Time", "GMT", 0), // 0
|
||||||
|
new TimeZoneInfo("UTC", "Universal Coordinated Time", "GMT", 0),
|
||||||
public static final TimeZoneInfo[] TIMEZONES = {
|
new TimeZoneInfo("ECT", "European Central Time", "GMT+1:00", ONE_HOUR),
|
||||||
new TimeZoneInfo("GMT", "Greenwich Mean Time", "GMT", 0 * ONE_HOUR + 0 * THIRTY_MIN), // 0
|
new TimeZoneInfo("EET", "Eastern European Time", "GMT+2:00", 2 * ONE_HOUR),
|
||||||
new TimeZoneInfo("UTC", "Universal Coordinated Time", "GMT", 0 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("ART", "(Arabic) Egypt Standard Time", "GMT+2:00", 2 * ONE_HOUR),
|
||||||
new TimeZoneInfo("ECT", "European Central Time", "GMT+1:00", 1 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("EAT", "Eastern African Time", "GMT+3:00", 3 * ONE_HOUR), // 5
|
||||||
new TimeZoneInfo("EET", "Eastern European Time", "GMT+2:00", 2 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("MET", "Middle East Time", "GMT+3:30", 3 * ONE_HOUR + THIRTY_MIN),
|
||||||
new TimeZoneInfo("ART", "(Arabic) Egypt Standard Time", "GMT+2:00", 2 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("NET", "Near East Time", "GMT+4:00", 4 * ONE_HOUR),
|
||||||
new TimeZoneInfo("EAT", "Eastern African Time", "GMT+3:00", 3 * ONE_HOUR + 0 * THIRTY_MIN), // 5
|
new TimeZoneInfo("PLT", "Pakistan Lahore Time", "GMT+5:00", 5 * ONE_HOUR),
|
||||||
new TimeZoneInfo("MET", "Middle East Time", "GMT+3:30", 3 * ONE_HOUR + 1 * THIRTY_MIN),
|
new TimeZoneInfo("IST", "India Standard Time", "GMT+5:30", 5 * ONE_HOUR + THIRTY_MIN),
|
||||||
new TimeZoneInfo("NET", "Near East Time", "GMT+4:00", 4 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("BST", "Bangladesh Standard Time", "GMT+6:00", 6 * ONE_HOUR), // 10
|
||||||
new TimeZoneInfo("PLT", "Pakistan Lahore Time", "GMT+5:00", 5 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("VST", "Vietnam Standard Time", "GMT+7:00", 7 * ONE_HOUR),
|
||||||
new TimeZoneInfo("IST", "India Standard Time", "GMT+5:30", 5 * ONE_HOUR + 1 * THIRTY_MIN),
|
new TimeZoneInfo("CTT", "China Taiwan Time", "GMT+8:00", 8 * ONE_HOUR),
|
||||||
new TimeZoneInfo("BST", "Bangladesh Standard Time", "GMT+6:00", 6 * ONE_HOUR + 0 * THIRTY_MIN), // 10
|
new TimeZoneInfo("JST", "Japan Standard Time", "GMT+9:00", 9 * ONE_HOUR),
|
||||||
new TimeZoneInfo("VST", "Vietnam Standard Time", "GMT+7:00", 7 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("ACT", "Australia Central Time", "GMT+9:30", 9 * ONE_HOUR + THIRTY_MIN),
|
||||||
new TimeZoneInfo("CTT", "China Taiwan Time", "GMT+8:00", 8 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("AET", "Australia Eastern Time", "GMT+10:00", 10 * ONE_HOUR), // 15
|
||||||
new TimeZoneInfo("JST", "Japan Standard Time", "GMT+9:00", 9 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("SST", "Solomon Standard Time", "GMT+11:00", 11 * ONE_HOUR),
|
||||||
new TimeZoneInfo("ACT", "Australia Central Time", "GMT+9:30", 9 * ONE_HOUR + 1 * THIRTY_MIN),
|
new TimeZoneInfo("NST", "New Zealand Standard Time", "GMT+12:00", 12 * ONE_HOUR),
|
||||||
new TimeZoneInfo("AET", "Australia Eastern Time", "GMT+10:00", 10 * ONE_HOUR + 0 * THIRTY_MIN), // 15
|
new TimeZoneInfo("MIT", "Midway Islands Time", "GMT-11:00", -11 * ONE_HOUR),
|
||||||
new TimeZoneInfo("SST", "Solomon Standard Time", "GMT+11:00", 11 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("HST", "Hawaii Standard Time", "GMT-10:00", -10 * ONE_HOUR),
|
||||||
new TimeZoneInfo("NST", "New Zealand Standard Time", "GMT+12:00", 12 * ONE_HOUR + 0 * THIRTY_MIN),
|
new TimeZoneInfo("AST", "Alaska Standard Time", "GMT-9:00", -9 * ONE_HOUR), // 20
|
||||||
new TimeZoneInfo("MIT", "Midway Islands Time", "GMT-11:00", -11 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("PST", "Pacific Standard Time", "GMT-8:00", -8 * ONE_HOUR),
|
||||||
new TimeZoneInfo("HST", "Hawaii Standard Time", "GMT-10:00", -10 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("PNT", "Phoenix Standard Time", "GMT-7:00", -7 * ONE_HOUR),
|
||||||
new TimeZoneInfo("AST", "Alaska Standard Time", "GMT-9:00", -9 * ONE_HOUR - 0 * THIRTY_MIN), // 20
|
new TimeZoneInfo("MST", "Mountain Standard Time", "GMT-7:00", -7 * ONE_HOUR),
|
||||||
new TimeZoneInfo("PST", "Pacific Standard Time", "GMT-8:00", -8 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("CST", "Central Standard Time", "GMT-6:00", -6 * ONE_HOUR),
|
||||||
new TimeZoneInfo("PNT", "Phoenix Standard Time", "GMT-7:00", -7 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("EST", "Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR), // 25
|
||||||
new TimeZoneInfo("MST", "Mountain Standard Time", "GMT-7:00", -7 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("IET", "Indiana Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR),
|
||||||
new TimeZoneInfo("CST", "Central Standard Time", "GMT-6:00", -6 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("PRT", "Puerto Rico and US Virgin Islands Time", "GMT-4:00", -4 * ONE_HOUR),
|
||||||
new TimeZoneInfo("EST", "Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR - 0 * THIRTY_MIN), // 25
|
new TimeZoneInfo("CNT", "Canada Newfoundland Time", "GMT-3:30", -3 * ONE_HOUR - THIRTY_MIN),
|
||||||
new TimeZoneInfo("IET", "Indiana Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("AGT", "Argentina Standard Time", "GMT-3:00", -3 * ONE_HOUR),
|
||||||
new TimeZoneInfo("PRT", "Puerto Rico and US Virgin Islands Time", "GMT-4:00", -4 * ONE_HOUR - 0 * THIRTY_MIN),
|
new TimeZoneInfo("BET", "Brazil Eastern Time", "GMT-3:00", -3 * ONE_HOUR), // 30
|
||||||
new TimeZoneInfo("CNT", "Canada Newfoundland Time", "GMT-3:30", -3 * ONE_HOUR - 1 * THIRTY_MIN),
|
new TimeZoneInfo("CAT", "Central African Time", "GMT-1:00", -1 * ONE_HOUR),
|
||||||
new TimeZoneInfo("AGT", "Argentina Standard Time", "GMT-3:00", -3 * ONE_HOUR - 0 * THIRTY_MIN),
|
|
||||||
new TimeZoneInfo("BET", "Brazil Eastern Time", "GMT-3:00", -3 * ONE_HOUR - 0 * THIRTY_MIN), // 30
|
|
||||||
new TimeZoneInfo("CAT", "Central African Time", "GMT-1:00", -1 * ONE_HOUR - 0 * THIRTY_MIN),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -27,16 +27,18 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public class UrlGenerator implements GeneratorSource {
|
public final class UrlGenerator implements GeneratorSource {
|
||||||
Grid table = null;
|
|
||||||
TextBox url = new TextBox();
|
private Grid table;
|
||||||
|
private final TextBox url = new TextBox();
|
||||||
|
|
||||||
public UrlGenerator(ChangeListener listener, KeyPressHandler keyListener) {
|
public UrlGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
url.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
url.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||||
url.addChangeListener(listener);
|
url.addChangeHandler(handler);
|
||||||
url.addKeyPressHandler(keyListener);
|
url.addKeyPressHandler(keyListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
// early termination if the table has already been constructed
|
// early termination if the table has already been constructed
|
||||||
|
@ -54,10 +56,12 @@ public class UrlGenerator implements GeneratorSource {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "URL";
|
return "URL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
return getUrlField();
|
return getUrlField();
|
||||||
}
|
}
|
||||||
|
@ -68,12 +72,14 @@ public class UrlGenerator implements GeneratorSource {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == url) {
|
if (widget == url) {
|
||||||
getUrlField();
|
getUrlField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
url.setFocus(true);
|
url.setFocus(true);
|
||||||
}
|
}
|
|
@ -22,18 +22,22 @@ package com.google.zxing.web.generator.client;
|
||||||
*
|
*
|
||||||
* @author Yohann Coppel
|
* @author Yohann Coppel
|
||||||
*/
|
*/
|
||||||
public final class Validators {
|
final class Validators {
|
||||||
public static String filterNumber(String number) {
|
|
||||||
|
private Validators() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static String filterNumber(String number) {
|
||||||
return number.replaceAll("[ \\.,\\-\\(\\)]", "");
|
return number.replaceAll("[ \\.,\\-\\(\\)]", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateNumber(String number) throws GeneratorException {
|
static void validateNumber(String number) throws GeneratorException {
|
||||||
if (!number.matches("\\+?[0-9]+")) {
|
if (!number.matches("\\+?[0-9]+")) {
|
||||||
throw new GeneratorException("Phone number must be digits only.");
|
throw new GeneratorException("Phone number must be digits only.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateUrl(String url) throws GeneratorException {
|
static void validateUrl(String url) throws GeneratorException {
|
||||||
if (!isBasicallyValidURI(url)) {
|
if (!isBasicallyValidURI(url)) {
|
||||||
throw new GeneratorException("URL is not valid.");
|
throw new GeneratorException("URL is not valid.");
|
||||||
}
|
}
|
||||||
|
@ -45,13 +49,10 @@ public final class Validators {
|
||||||
}
|
}
|
||||||
int period = uri.indexOf('.');
|
int period = uri.indexOf('.');
|
||||||
// Look for period in a domain but followed by at least a two-char TLD
|
// Look for period in a domain but followed by at least a two-char TLD
|
||||||
if (period >= uri.length() - 2) {
|
return period < uri.length() - 2 && (period >= 0 || uri.indexOf(':') >= 0);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return period >= 0 || uri.indexOf(':') >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateEmail(String email) throws GeneratorException {
|
static void validateEmail(String email) throws GeneratorException {
|
||||||
//FIXME: we can have a better check for email here.
|
//FIXME: we can have a better check for email here.
|
||||||
if (!email.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")) {
|
if (!email.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")) {
|
||||||
throw new GeneratorException("Email is not valid.");
|
throw new GeneratorException("Email is not valid.");
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
package com.google.zxing.web.generator.client;
|
package com.google.zxing.web.generator.client;
|
||||||
|
|
||||||
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.ui.ChangeListener;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
|
import com.google.gwt.user.client.ui.HasText;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
import com.google.gwt.user.client.ui.ListBox;
|
import com.google.gwt.user.client.ui.ListBox;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -28,29 +29,30 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Vikram Aggarwal
|
* @author Vikram Aggarwal
|
||||||
*/
|
*/
|
||||||
public class WifiGenerator implements GeneratorSource {
|
public final class WifiGenerator implements GeneratorSource {
|
||||||
Grid table = null;
|
|
||||||
TextBox ssid = new TextBox();
|
private Grid table;
|
||||||
TextBox password = new TextBox();
|
private final TextBox ssid = new TextBox();
|
||||||
final boolean multipleSelections = false;
|
private final TextBox password = new TextBox();
|
||||||
ListBox networkType = new ListBox(multipleSelections);
|
private final ListBox networkType = new ListBox(false);
|
||||||
TextBox[] widgets = {ssid, password };
|
|
||||||
|
public WifiGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||||
public WifiGenerator(ChangeListener changeListener, KeyPressHandler keyListener) {
|
networkType.addItem("WEP", "WEP");
|
||||||
networkType.addItem("WEP", "WEP");
|
networkType.addItem("WPA/WPA2", "WPA");
|
||||||
networkType.addItem("WPA/WPA2", "WPA");
|
networkType.addItem("No encryption", "nopass");
|
||||||
networkType.addItem("No encryption", "nopass");
|
TextBox[] widgets = {ssid, password};
|
||||||
|
|
||||||
for (TextBox w: widgets) {
|
for (TextBox w: widgets) {
|
||||||
w.addChangeListener(changeListener);
|
w.addChangeHandler(handler);
|
||||||
w.addKeyPressHandler(keyListener);
|
w.addKeyPressHandler(keyListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Wifi network";
|
return "Wifi network";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String ssid = getSsidField();
|
String ssid = getSsidField();
|
||||||
String password = getPasswordField();
|
String password = getPasswordField();
|
||||||
|
@ -60,7 +62,7 @@ public class WifiGenerator implements GeneratorSource {
|
||||||
return getWifiString(ssid, password, networkType);
|
return getWifiString(ssid, password, networkType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getWifiString(String ssid, String password, String type) {
|
private static String getWifiString(String ssid, String password, String type) {
|
||||||
StringBuilder output = new StringBuilder(100);
|
StringBuilder output = new StringBuilder(100);
|
||||||
output.append("WIFI:");
|
output.append("WIFI:");
|
||||||
output.append("S:").append(ssid).append(';');
|
output.append("S:").append(ssid).append(';');
|
||||||
|
@ -76,7 +78,7 @@ public class WifiGenerator implements GeneratorSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String parseTextField(String name, TextBox textBox) throws GeneratorException {
|
private static String parseTextField(String name, HasText textBox) throws GeneratorException {
|
||||||
String input = textBox.getText();
|
String input = textBox.getText();
|
||||||
if (input.length() < 1) {
|
if (input.length() < 1) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -107,6 +109,7 @@ public class WifiGenerator implements GeneratorSource {
|
||||||
return networkType.getValue(networkType.getSelectedIndex());
|
return networkType.getValue(networkType.getSelectedIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Grid getWidget() {
|
public Grid getWidget() {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
// early termination if the table has already been constructed
|
// early termination if the table has already been constructed
|
||||||
|
@ -125,6 +128,7 @@ public class WifiGenerator implements GeneratorSource {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Widget widget) throws GeneratorException {
|
public void validate(Widget widget) throws GeneratorException {
|
||||||
if (widget == ssid) {
|
if (widget == ssid) {
|
||||||
getSsidField();
|
getSsidField();
|
||||||
|
@ -137,6 +141,7 @@ public class WifiGenerator implements GeneratorSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
ssid.setFocus(true);
|
ssid.setFocus(true);
|
||||||
}
|
}
|
|
@ -1,39 +0,0 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
||||||
<title>Zebra Crossing</title>
|
|
||||||
<link rel="stylesheet" href="style.css" type="text/css"/>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="header">
|
|
||||||
<h1>Zebra Crossing<span> from the ZXing Project</span></h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table cellpadding="4" cellspacing="8">
|
|
||||||
<tr>
|
|
||||||
<td valign="top">
|
|
||||||
<img src="zxingiconsmall.png" width="48" height="48">
|
|
||||||
</td>
|
|
||||||
<td valign="top">
|
|
||||||
A web page you are viewing would like to scan a barcode with your camera phone. To do
|
|
||||||
this, you need to install a new application.
|
|
||||||
<p>
|
|
||||||
If you are using an Android device,
|
|
||||||
<a href="market://search?q=pname:com.google.zxing.client.android">click here</a> to
|
|
||||||
install Barcode Scanner. Once installed, it will launch automatically the next time you
|
|
||||||
click on the hyperlink which brought you here.
|
|
||||||
<p>
|
|
||||||
For all other mobile devices, please see
|
|
||||||
<a href="http://code.google.com/p/zxing/wiki/GetTheReader">these installation instructions</a>.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div id="footer">
|
|
||||||
<a href="http://code.google.com/p/zxing/">ZXing Project Home Page</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -47,18 +47,11 @@ body {
|
||||||
|
|
||||||
position: relative;
|
position: relative;
|
||||||
display: table;
|
display: table;
|
||||||
#position: relative;
|
|
||||||
}
|
}
|
||||||
#innerresult {
|
#innerresult {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
#position: absolute;
|
|
||||||
#top: 50%;
|
|
||||||
}
|
|
||||||
#innerresult img {
|
|
||||||
#position: relative;
|
|
||||||
#top: -50%;
|
|
||||||
}
|
}
|
||||||
#downloadText {
|
#downloadText {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
@ -66,6 +59,9 @@ body {
|
||||||
#urlresult {
|
#urlresult {
|
||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
#rawtextresult {
|
||||||
|
width: 350px;
|
||||||
|
}
|
||||||
.firstColumn {
|
.firstColumn {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
@ -97,7 +93,7 @@ body {
|
||||||
background-color: #fffbcc;
|
background-color: #fffbcc;
|
||||||
}
|
}
|
||||||
.required {
|
.required {
|
||||||
background: #ffffff url(required-field-bg.png) repeat-y;
|
background: #ffffff url(static/required-field-bg.png) repeat-y;
|
||||||
}
|
}
|
||||||
.errorMessage {
|
.errorMessage {
|
||||||
padding-left: 110px;
|
padding-left: 110px;
|
29
zxing.appspot.com/war/Generator.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<link type="text/css" rel="stylesheet" href="Generator.css">
|
||||||
|
<title>QR Code Generator from the ZXing Project</title>
|
||||||
|
<script type="text/javascript" language="javascript" src="generator/generator.nocache.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
|
||||||
|
<noscript>
|
||||||
|
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
|
||||||
|
Your web browser must have JavaScript enabled
|
||||||
|
in order for this application to display correctly.
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<div id="header">
|
||||||
|
<h1>QR Code Generator <span>from the ZXing Project</span></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="ui"></div>
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
<a href="http://code.google.com/p/zxing/">ZXing Project Home Page</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
10
zxing.appspot.com/war/WEB-INF/web.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
|
||||||
|
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>index.html</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
|
||||||
|
</web-app>
|
21
zxing.appspot.com/war/app.yaml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
application: zxing
|
||||||
|
version: 2
|
||||||
|
runtime: python
|
||||||
|
api_version: 1
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- url: /generator
|
||||||
|
static_files: Generator.html
|
||||||
|
upload: Generator.html
|
||||||
|
|
||||||
|
- url: /scan
|
||||||
|
static_files: scan.html
|
||||||
|
upload: scan.html
|
||||||
|
|
||||||
|
- url: /
|
||||||
|
static_files: index.html
|
||||||
|
upload: index.html
|
||||||
|
|
||||||
|
- url: /(.*)
|
||||||
|
static_files: \1
|
||||||
|
upload: /
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -9,26 +9,22 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<h1>Zebra Crossing<span> from the ZXing Project</span></h1>
|
<h1>Zebra Crossing <span>from the ZXing Project</span></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table width="600" cellpadding="4" cellspacing="8">
|
<table width="600" cellpadding="4" cellspacing="8">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<img src="zxingicon.png" width="128" height="128">
|
<img src="zxingicon.png" width="128" height="128"/>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
Welcome to the Zebra Crossing site at zxing.appspot.com.
|
<p>Welcome to the Zebra Crossing site at zxing.appspot.com.</p>
|
||||||
<p>
|
<p> This site features a <a href="generator">QR Code Generator</a>, which
|
||||||
This site features a <a href="generator">QR Code Generator</a>, which
|
|
||||||
allows you to create a two-dimensional barcode that can be scanned
|
allows you to create a two-dimensional barcode that can be scanned
|
||||||
with a camera phone. These QR Codes can contain a URL, contact
|
with a camera phone. These QR Codes can contain a URL, contact
|
||||||
information, a calendar event, and much more.
|
information, a calendar event, and much more.</p>
|
||||||
<p>
|
<p>The <a href="http://code.google.com/p/zxing/">ZXing Project</a> exists
|
||||||
The <a href="http://code.google.com/p/zxing/">ZXing Project</a> exists
|
to provide an open source barcode scanner for a range of devices.</p>
|
||||||
to provide an open source barcode scanner for a range of devices. You
|
|
||||||
can <a href="http://code.google.com/p/zxing/wiki/GetTheReader">
|
|
||||||
download the software</a> for your phone here.
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
35
zxing.appspot.com/war/scan.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Zebra Crossing</title>
|
||||||
|
<link rel="stylesheet" href="style.css" type="text/css"/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<h1>Zebra Crossing <span>from the ZXing Project</span></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table cellpadding="4" cellspacing="8">
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<img src="zxingiconsmall.png" width="48" height="48"/>
|
||||||
|
</td>
|
||||||
|
<td valign="top">
|
||||||
|
<p>A web page you are viewing would like to scan a barcode with your camera phone. To do
|
||||||
|
this, you need to install a new application.</p>
|
||||||
|
<p>If you are using an Android device,
|
||||||
|
<a href="market://details?id=com.google.zxing.client.android">click here</a> to
|
||||||
|
install Barcode Scanner. Once installed, it will launch automatically the next time you
|
||||||
|
click on the hyperlink which brought you here.</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
<a href="http://code.google.com/p/zxing/">ZXing Project Home Page</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |