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
|
||||
# location of the Google Web Toolkit (GWT) which can be downloaded here:
|
||||
# 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
|
||||
|
|
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:
|
||||
----------
|
||||
Run 'ant' in this directory. You might get a lot of warnings with
|
||||
[WARN] but you should not get any errors.
|
||||
--- Generated by GWT WebAppCreator ---
|
||||
|
||||
Congratulations, you've successfully generated a starter project! What next?
|
||||
|
||||
To test:
|
||||
-------
|
||||
View the file "build/site/generator/index.html" in any browser. You can do
|
||||
this from the commandline with:
|
||||
-- Option A: Import your project into Eclipse (recommended) --
|
||||
|
||||
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
|
||||
limitations under the License.
|
||||
-->
|
||||
<project name="zxing.appspot.com" default="build">
|
||||
<property file="../build.properties"/>
|
||||
<project name="zxing.appspot.com" default="build" basedir=".">
|
||||
|
||||
<!-- 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"/>
|
||||
<loadproperties srcFile="../build.properties" />
|
||||
|
||||
<!-- Contains pre-built jars like gwt-incubator.jar -->
|
||||
<property name="external-libs" value="generator/libs"/>
|
||||
<!-- Arguments to gwtc and devmode targets -->
|
||||
<property name="gwt.args" value="" />
|
||||
|
||||
<!-- Create the output directories if they don't exist yet. -->
|
||||
<target name="create-dirs">
|
||||
<echo>Creating output directories if needed...</echo>
|
||||
<mkdir dir="${outdir}"/>
|
||||
<mkdir dir="${outdir-site}"/>
|
||||
<!-- Configure path to GWT SDK -->
|
||||
<property name="gwt.sdk" location="${GWT-home}" />
|
||||
|
||||
<path id="project.class.path">
|
||||
<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>
|
||||
|
||||
<!-- Generate the HTML and JS from the Java source. -->
|
||||
<target name="compile" depends="create-dirs">
|
||||
<java classname="com.google.gwt.dev.GWTCompiler" fork="true" failonerror="true">
|
||||
<jvmarg value="-Xmx256M"/>
|
||||
<classpath>
|
||||
<pathelement path="generator/src"/>
|
||||
<fileset dir="${GWT-home}" includes="*.jar"/>
|
||||
<fileset dir="${external-libs}" includes="*.jar"/>
|
||||
</classpath>
|
||||
<arg line="-out ${outdir-site}"/>
|
||||
<arg value="${generator-package}"/>
|
||||
</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"/>
|
||||
<target name="javac" depends="libs" description="Compile java source to bytecode">
|
||||
<mkdir dir="war/WEB-INF/classes"/>
|
||||
<javac srcdir="src" includes="**" encoding="utf-8"
|
||||
destdir="war/WEB-INF/classes"
|
||||
source="6" target="6" nowarn="true"
|
||||
debug="true" debuglevel="lines,vars,source"
|
||||
includeantruntime="false">
|
||||
<classpath refid="project.class.path"/>
|
||||
</javac>
|
||||
<copy todir="war/WEB-INF/classes">
|
||||
<fileset dir="src" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!--
|
||||
The GWTCompiler adds the package name to the output directory, but we want to change that to
|
||||
mirror the user-perceived site layout. We also want to rename the main HTML file.
|
||||
-->
|
||||
<target name="rename-generator" depends="compile">
|
||||
<echo>Renaming generator output...</echo>
|
||||
<move file="${outdir-site}/${generator-package}" tofile="${outdir-site}/generator"/>
|
||||
<move file="${outdir-site}/generator/Generator.html" tofile="${outdir-site}/generator/index.html"/>
|
||||
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
|
||||
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
|
||||
<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>
|
||||
<!-- 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 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 name="clean">
|
||||
<delete dir="${outdir}"/>
|
||||
<target name="build" depends="gwtc" description="Build this project" />
|
||||
|
||||
<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>
|
||||
|
||||
</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;
|
||||
|
||||
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.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.user.client.DOM;
|
||||
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.ClickListener;
|
||||
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.Widget;
|
||||
import com.google.gwt.widgetideas.client.event.ChangeEvent;
|
||||
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 com.google.gwt.user.datepicker.client.DatePicker;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A Generator for calendar events. Output is in VCal format.
|
||||
* A Generator for calendar events.
|
||||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class CalendarEventGenerator implements GeneratorSource {
|
||||
public static final String[] FULL_DAY_ONLY_IDS = { "fullDayOnlyInfo1",
|
||||
"fullDayOnlyInfo2", "fullDayOnlyInfo3", "fullDayOnlyInfo4" };
|
||||
public final class CalendarEventGenerator implements GeneratorSource {
|
||||
|
||||
private static final String[] FULL_DAY_ONLY_IDS =
|
||||
{ "fullDayOnlyInfo1", "fullDayOnlyInfo2", "fullDayOnlyInfo3", "fullDayOnlyInfo4" };
|
||||
private static final long ONE_HOUR = 60L * 60 * 1000;
|
||||
|
||||
Grid table = null;
|
||||
TextBox eventName = new TextBox();
|
||||
CheckBox fullDay = new CheckBox();
|
||||
DateBox datePicker1 = new DateBox();
|
||||
DateBox datePicker2 = new DateBox();
|
||||
TimePicker timePicker1 = new TimePicker(new Date(), DateTimeFormat
|
||||
private Grid table;
|
||||
private final TextBox eventName = new TextBox();
|
||||
private final CheckBox fullDay = new CheckBox();
|
||||
private final DatePicker datePicker1 = new DatePicker();
|
||||
private final DatePicker datePicker2 = new DatePicker();
|
||||
private final TimePicker timePicker1 = new TimePicker(new Date(), DateTimeFormat
|
||||
.getFormat("a"), DateTimeFormat.getFormat("hh"), DateTimeFormat
|
||||
.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("mm"), null);
|
||||
CheckBox summerTime = new CheckBox();
|
||||
ListBox timeZones = new ListBox();
|
||||
Date timePicker1PreviousDate = null;
|
||||
TextBox location = new TextBox();
|
||||
TextBox description = new TextBox();
|
||||
private final CheckBox summerTime = new CheckBox();
|
||||
private final ListBox timeZones = new ListBox();
|
||||
private Date timePicker1PreviousDate = null;
|
||||
private final TextBox location = new TextBox();
|
||||
private final TextBox description = new TextBox();
|
||||
|
||||
public CalendarEventGenerator(final ChangeListener listener,
|
||||
KeyPressHandler keyListener) {
|
||||
public CalendarEventGenerator(final ChangeHandler handler, KeyPressHandler keyListener) {
|
||||
eventName.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||
eventName.addChangeListener(listener);
|
||||
eventName.addChangeHandler(handler);
|
||||
eventName.addKeyPressHandler(keyListener);
|
||||
datePicker1.setAnimationEnabled(true);
|
||||
datePicker2.setAnimationEnabled(true);
|
||||
timePicker2
|
||||
.setDateTime(addMilliseconds(timePicker1.getDateTime(), ONE_HOUR));
|
||||
timePicker2.setDateTime(addMilliseconds(timePicker1.getDateTime(), ONE_HOUR));
|
||||
timePicker1PreviousDate = timePicker1.getDateTime();
|
||||
|
||||
buildTimeZoneList();
|
||||
timeZones.setSelectedIndex(25);
|
||||
timeZones.addKeyPressHandler(keyListener);
|
||||
timePicker1.addChangeHandler(new ChangeHandler<Date>() {
|
||||
public void onChange(ChangeEvent<Date> event) {
|
||||
timePicker1.addValueChangeHandler(new ValueChangeHandler<Date>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<Date> dateValueChangeEvent) {
|
||||
Date time = timePicker1PreviousDate;
|
||||
Date time1 = timePicker1.getDateTime();
|
||||
Date time2 = timePicker2.getDateTime();
|
||||
|
@ -95,29 +94,40 @@ public class CalendarEventGenerator implements GeneratorSource {
|
|||
timePicker1PreviousDate = time1;
|
||||
}
|
||||
});
|
||||
timePicker2.addChangeHandler(new ChangeHandler<Date>() {
|
||||
public void onChange(ChangeEvent<Date> event) {
|
||||
listener.onChange(timePicker2);
|
||||
timePicker2.addValueChangeHandler(new ValueChangeHandler<Date>() {
|
||||
@Override
|
||||
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() {
|
||||
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() {
|
||||
return "Calendar event";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
datePicker1.getDatePicker().setSelectedDate(new Date());
|
||||
datePicker2.getDatePicker().setSelectedDate(new Date());
|
||||
datePicker1.setValue(new Date());
|
||||
datePicker2.setValue(new Date());
|
||||
table = new Grid(10, 2);
|
||||
|
||||
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(7).setId(FULL_DAY_ONLY_IDS[3]);
|
||||
|
||||
fullDay.addClickListener(new ClickListener() {
|
||||
public void onClick(Widget sender) {
|
||||
CheckBox cb = (CheckBox) sender;
|
||||
setFullDay(cb.isChecked());
|
||||
fullDay.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
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;
|
||||
}
|
||||
|
||||
private static void setFullDay(boolean fullDay) {
|
||||
for (String s : FULL_DAY_ONLY_IDS) {
|
||||
Element element = DOM.getElementById(s);
|
||||
String style = fullDay ? "none" : "";
|
||||
DOM.setStyleAttribute(element, "display", style);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String eventName = getEventNameField();
|
||||
String dates = getDateTimeFields();
|
||||
|
@ -194,14 +202,13 @@ public class CalendarEventGenerator implements GeneratorSource {
|
|||
throw new GeneratorException("Event name must be at least 1 character.");
|
||||
}
|
||||
if (inputName.contains("\n")) {
|
||||
throw new GeneratorException(
|
||||
"Event name should not contain \\n characters.");
|
||||
throw new GeneratorException("Event name should not contain \\n characters.");
|
||||
}
|
||||
return "SUMMARY:" + inputName + "\r\n";
|
||||
}
|
||||
|
||||
private String getDateTimeFields() throws GeneratorException {
|
||||
if (fullDay.isChecked()) {
|
||||
if (fullDay.getValue()) {
|
||||
return getFullDayDateFields();
|
||||
}
|
||||
return getDateTimeValues();
|
||||
|
@ -232,9 +239,9 @@ public class CalendarEventGenerator implements GeneratorSource {
|
|||
}
|
||||
|
||||
private String getFullDayDateFields() throws GeneratorException {
|
||||
Date date1 = datePicker1.getDatePicker().getSelectedDate();
|
||||
Date date2 = datePicker2.getDatePicker().getSelectedDate();
|
||||
if (null == date1 || null == date2) {
|
||||
Date date1 = datePicker1.getValue();
|
||||
Date date2 = datePicker2.getValue();
|
||||
if (date1 == null || date2 == null) {
|
||||
throw new GeneratorException("Start and end dates must be set.");
|
||||
}
|
||||
if (date1.after(date2)) {
|
||||
|
@ -252,27 +259,24 @@ public class CalendarEventGenerator implements GeneratorSource {
|
|||
}
|
||||
|
||||
private String getDateTimeValues() throws GeneratorException {
|
||||
Date date1 = datePicker1.getDatePicker().getSelectedDate();
|
||||
Date date2 = datePicker2.getDatePicker().getSelectedDate();
|
||||
Date date1 = datePicker1.getValue();
|
||||
Date date2 = datePicker2.getValue();
|
||||
Date time1 = timePicker1.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.");
|
||||
}
|
||||
String timezoneDelta = timeZones.getValue(timeZones.getSelectedIndex());
|
||||
long diffTimeZone = Long.parseLong(timezoneDelta);
|
||||
if (summerTime.isChecked()) {
|
||||
if (summerTime.getValue()) {
|
||||
diffTimeZone += ONE_HOUR;
|
||||
}
|
||||
Date dateTime1 = addMilliseconds(mergeDateAndTime(date1, time1),
|
||||
-diffTimeZone);
|
||||
Date dateTime2 = addMilliseconds(mergeDateAndTime(date2, time2),
|
||||
-diffTimeZone);
|
||||
Date dateTime1 = addMilliseconds(mergeDateAndTime(date1, time1), -diffTimeZone);
|
||||
Date dateTime2 = addMilliseconds(mergeDateAndTime(date2, time2), -diffTimeZone);
|
||||
if (dateTime1.after(dateTime2)) {
|
||||
throw new GeneratorException("Ending date is after starting date.");
|
||||
}
|
||||
DateTimeFormat isoFormatter = DateTimeFormat
|
||||
.getFormat("yyyyMMdd'T'HHmmss'Z'");
|
||||
DateTimeFormat isoFormatter = DateTimeFormat.getFormat("yyyyMMdd'T'HHmmss'Z'");
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append("DTSTART:");
|
||||
output.append(isoFormatter.format(dateTime1));
|
||||
|
@ -294,11 +298,11 @@ public class CalendarEventGenerator implements GeneratorSource {
|
|||
return merger.parse(d + t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == eventName) {
|
||||
getEventNameField();
|
||||
} else if (widget == datePicker1 || widget == timePicker1 || widget == datePicker2
|
||||
|| widget == timePicker2) {
|
||||
} else if (widget == datePicker1 || widget == timePicker1 || widget == datePicker2 || widget == timePicker2) {
|
||||
getDateTimeFields();
|
||||
}
|
||||
}
|
||||
|
@ -307,6 +311,7 @@ public class CalendarEventGenerator implements GeneratorSource {
|
|||
return new Date(time1.getTime() + milliseconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
eventName.setFocus(true);
|
||||
}
|
|
@ -16,9 +16,10 @@
|
|||
|
||||
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.ChangeListener;
|
||||
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.Widget;
|
||||
|
||||
|
@ -27,30 +28,36 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class ContactInfoGenerator implements GeneratorSource {
|
||||
Grid table = null;
|
||||
TextBox name = new TextBox();
|
||||
TextBox company = new TextBox();
|
||||
TextBox tel = new TextBox();
|
||||
TextBox url = new TextBox();
|
||||
TextBox email = new TextBox();
|
||||
TextBox address = new TextBox();
|
||||
TextBox address2 = new TextBox();
|
||||
TextBox memo = new TextBox();
|
||||
TextBox[] widgets = {name, company, tel, url, email, address, address2, memo};
|
||||
|
||||
public ContactInfoGenerator(ChangeListener changeListener,
|
||||
KeyPressHandler keyListener) {
|
||||
public final class ContactInfoGenerator implements GeneratorSource {
|
||||
|
||||
private Grid table;
|
||||
private final ListBox encoding = new ListBox();
|
||||
private final TextBox name = new TextBox();
|
||||
private final TextBox company = new TextBox();
|
||||
private final TextBox tel = new TextBox();
|
||||
private final TextBox url = new TextBox();
|
||||
private final TextBox email = new TextBox();
|
||||
private final TextBox address = new TextBox();
|
||||
private final TextBox address2 = new TextBox();
|
||||
private final TextBox memo = new TextBox();
|
||||
|
||||
public ContactInfoGenerator(ChangeHandler changeHandler, KeyPressHandler keyListener) {
|
||||
TextBox[] widgets = {name, company, tel, url, email, address, address2, memo};
|
||||
for (TextBox w: widgets) {
|
||||
w.addChangeListener(changeListener);
|
||||
w.addChangeHandler(changeHandler);
|
||||
w.addKeyPressHandler(keyListener);
|
||||
}
|
||||
encoding.addItem("MECARD");
|
||||
encoding.addItem("vCard");
|
||||
encoding.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Contact information";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String name = getNameField();
|
||||
String company = getCompanyField();
|
||||
|
@ -63,74 +70,69 @@ public class ContactInfoGenerator implements GeneratorSource {
|
|||
|
||||
// Build the output with obtained data.
|
||||
// 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);
|
||||
}
|
||||
|
||||
private String getMeCard(String name, String company, String tel, String url,
|
||||
String email, String address, String address2, String memo) {
|
||||
StringBuilder output = new StringBuilder();
|
||||
private static String getMeCard(String name, String company, String tel, String url,
|
||||
String email, String address, String address2, String memo) {
|
||||
StringBuilder output = new StringBuilder(100);
|
||||
output.append("MECARD:");
|
||||
name = name.replace(",", ""); // remove commas -- reserved char in MECARD
|
||||
output.append("N:").append(name).append(';');
|
||||
maybeAppend(output, "ORG:", company); // Not standard; don't generate
|
||||
maybeAppend(output, "TEL:", tel);
|
||||
maybeAppend(output, "URL:", url);
|
||||
maybeAppend(output, "EMAIL:", email);
|
||||
if (address.length() > 0 || address2.length() > 0) {
|
||||
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);
|
||||
maybeAppendMECARD(output, "N", name.replace(",", ""));
|
||||
maybeAppendMECARD(output, "ORG", company);
|
||||
maybeAppendMECARD(output, "TEL", tel);
|
||||
maybeAppendMECARD(output, "URL", url);
|
||||
maybeAppendMECARD(output, "EMAIL", email);
|
||||
maybeAppendMECARD(output, "ADR", buildAddress(address, address2));
|
||||
maybeAppendMECARD(output, "NOTE", memo);
|
||||
output.append(';');
|
||||
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) {
|
||||
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
|
||||
// or have the option.
|
||||
private String getVCard(String name, String company, String tel, String url,
|
||||
String email, String address, String memo) {
|
||||
String output = "BEGIN:VCARD\n";
|
||||
output += "N:" + name + "\n";
|
||||
output += company.length() > 0 ? "ORG:" + company + "\n" : "";
|
||||
output += tel.length() > 0 ? "TEL:" + tel + "\n" : "";
|
||||
output += url.length() > 0 ? "URL:" + url + "\n" : "";
|
||||
output += email.length() > 0 ? "EMAIL:" + email + "\n" : "";
|
||||
output += address.length() > 0 ? "ADR:" + address + "\n" : "";
|
||||
output += memo.length() > 0 ? "NOTE:" + memo + "\n" : "";
|
||||
output += "END:VCARD";
|
||||
|
||||
return output;
|
||||
private static String getVCard(String name, String company, String tel, String url,
|
||||
String email, String address, String address2, String memo) {
|
||||
StringBuilder output = new StringBuilder(100);
|
||||
output.append("BEGIN:VCARD\n");
|
||||
maybeAppendvCard(output, "N", name);
|
||||
maybeAppendvCard(output, "ORG", company);
|
||||
maybeAppendvCard(output, "TEL", tel);
|
||||
maybeAppendvCard(output, "URL", url);
|
||||
maybeAppendvCard(output, "EMAIL", email);
|
||||
maybeAppendvCard(output, "ADR", buildAddress(address, address2));
|
||||
maybeAppendvCard(output, "NOTE", memo);
|
||||
output.append("END:VCARD");
|
||||
return output.toString();
|
||||
}
|
||||
*/
|
||||
|
||||
private static String parseTextField(String name, TextBox textBox) throws GeneratorException {
|
||||
String input = textBox.getText();
|
||||
if (input.length() < 1) {
|
||||
return "";
|
||||
|
||||
private static void maybeAppendvCard(StringBuilder output, String prefix, String value) {
|
||||
if (value.length() > 0) {
|
||||
value = value.replaceAll("([\\\\:;])", "\\\\$1");
|
||||
value = value.replaceAll("\\n", "\\\\n");
|
||||
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 {
|
||||
|
@ -138,11 +140,11 @@ public class ContactInfoGenerator implements GeneratorSource {
|
|||
if (input.length() < 1) {
|
||||
throw new GeneratorException("Name must be at least 1 character.");
|
||||
}
|
||||
return parseTextField("Name", name);
|
||||
return input;
|
||||
}
|
||||
|
||||
private String getCompanyField() throws GeneratorException {
|
||||
return parseTextField("Company", company);
|
||||
private String getCompanyField() {
|
||||
return company.getText();
|
||||
}
|
||||
|
||||
private String getTelField() throws GeneratorException {
|
||||
|
@ -177,24 +179,25 @@ public class ContactInfoGenerator implements GeneratorSource {
|
|||
return input;
|
||||
}
|
||||
|
||||
private String getAddressField() throws GeneratorException {
|
||||
return parseTextField("Address", address);
|
||||
private String getAddressField() {
|
||||
return address.getText();
|
||||
}
|
||||
|
||||
private String getAddress2Field() throws GeneratorException {
|
||||
return parseTextField("Address 2", address2);
|
||||
private String getAddress2Field() {
|
||||
return address2.getText();
|
||||
}
|
||||
|
||||
private String getMemoField() throws GeneratorException {
|
||||
return parseTextField("Memo", memo);
|
||||
private String getMemoField() {
|
||||
return memo.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
// early termination if the table has already been constructed
|
||||
return table;
|
||||
}
|
||||
table = new Grid(8, 2);
|
||||
table = new Grid(9, 2);
|
||||
|
||||
table.setText(0, 0, "Name");
|
||||
table.setWidget(0, 1, name);
|
||||
|
@ -212,22 +215,42 @@ public class ContactInfoGenerator implements GeneratorSource {
|
|||
table.setWidget(6, 1, url);
|
||||
table.setText(7, 0, "Memo");
|
||||
table.setWidget(7, 1, memo);
|
||||
table.setText(8, 0, "Encoding");
|
||||
table.setWidget(8, 1, encoding);
|
||||
|
||||
name.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == name) getNameField();
|
||||
if (widget == company) getCompanyField();
|
||||
if (widget == tel) getTelField();
|
||||
if (widget == email) getEmailField();
|
||||
if (widget == address) getAddressField();
|
||||
if (widget == address2) getAddress2Field();
|
||||
if (widget == url) getUrlField();
|
||||
if (widget == memo) getMemoField();
|
||||
if (widget == name) {
|
||||
getNameField();
|
||||
}
|
||||
if (widget == company) {
|
||||
getCompanyField();
|
||||
}
|
||||
if (widget == tel) {
|
||||
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() {
|
||||
name.setFocus(true);
|
||||
}
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
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.ChangeListener;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
@ -27,23 +27,25 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class EmailGenerator implements GeneratorSource {
|
||||
Grid table = null;
|
||||
TextBox email = new TextBox();
|
||||
public final class EmailGenerator implements GeneratorSource {
|
||||
|
||||
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.addChangeListener(listener);
|
||||
email.addChangeHandler(handler);
|
||||
email.addKeyPressHandler(keyListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Email address";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String email = getEmailField();
|
||||
return "mailto:"+email;
|
||||
return "mailto:" + getEmailField();
|
||||
}
|
||||
|
||||
private String getEmailField() throws GeneratorException {
|
||||
|
@ -55,24 +57,25 @@ public class EmailGenerator implements GeneratorSource {
|
|||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
table = new Grid(1, 2);
|
||||
|
||||
table.setText(0, 0, "Address");
|
||||
table.setWidget(0, 1, email);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == email) {
|
||||
getEmailField();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
email.setFocus(true);
|
||||
}
|
|
@ -17,77 +17,78 @@
|
|||
package com.google.zxing.web.generator.client;
|
||||
|
||||
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.KeyPressHandler;
|
||||
import com.google.gwt.http.client.URL;
|
||||
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.ChangeListener;
|
||||
import com.google.gwt.user.client.ui.ClickListener;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
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.Image;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
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.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
public final class Generator implements EntryPoint {
|
||||
|
||||
private final List<GeneratorSource> generators = new ArrayList<GeneratorSource>();
|
||||
ListBox genList = new ListBox();
|
||||
ListBox sizeList = new ListBox();
|
||||
Image result = new Image("");//http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=http://google.com");
|
||||
Grid topPanel = new Grid(5, 1);
|
||||
GeneratorSource selectedGenerator = null;
|
||||
private Button generateButton;
|
||||
VerticalPanel rightPanel = new VerticalPanel();
|
||||
TextBox urlResult = new TextBox();
|
||||
HTML downloadText = new HTML("<a href=\"\" id=\"downloadlink\" >Download</a> or embed with this URL:");
|
||||
//Element errorElement = null;
|
||||
|
||||
private final ListBox genList = new ListBox();
|
||||
private final ListBox sizeList = new ListBox();
|
||||
private final ListBox ecLevelList = new ListBox();
|
||||
private final ListBox encodingList = new ListBox();
|
||||
private final Image result = new Image("");
|
||||
private final HTMLTable topPanel = new Grid(5, 1);
|
||||
private GeneratorSource selectedGenerator = null;
|
||||
private final VerticalPanel rightPanel = new VerticalPanel();
|
||||
private final TextBox urlResult = new TextBox();
|
||||
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() {
|
||||
loadGenerators();
|
||||
|
||||
|
||||
HorizontalPanel mainPanel = new HorizontalPanel();
|
||||
setupLeftPanel();
|
||||
topPanel.getElement().setId("leftpanel");
|
||||
Widget leftPanel = topPanel;
|
||||
|
||||
|
||||
mainPanel.add(leftPanel);
|
||||
|
||||
|
||||
SimplePanel div = new SimplePanel();
|
||||
SimplePanel div2 = new SimplePanel();
|
||||
div2.add(result);
|
||||
div2.getElement().setId("innerresult");
|
||||
div.add(div2);
|
||||
div.getElement().setId("imageresult");
|
||||
|
||||
|
||||
urlResult.getElement().setId("urlresult");
|
||||
rawTextResult.getElement().setId("rawtextresult");
|
||||
rawTextResult.setCharacterWidth(50);
|
||||
rawTextResult.setVisibleLines(8);
|
||||
downloadText.getElement().setId("downloadText");
|
||||
rightPanel.add(div);
|
||||
rightPanel.add(downloadText);
|
||||
rightPanel.add(urlResult);
|
||||
rightPanel.add(rawTextResult);
|
||||
mainPanel.add(rightPanel);
|
||||
mainPanel.getElement().setId("mainpanel");
|
||||
RootPanel.get("ui").add(mainPanel);
|
||||
//RootPanel.get().add(output);
|
||||
//output.setHeight("200px");
|
||||
//output.setWidth("500px");
|
||||
setWidget(1);
|
||||
invalidateBarcode();
|
||||
}
|
||||
|
@ -105,99 +106,119 @@ public class Generator implements EntryPoint {
|
|||
}
|
||||
|
||||
private void loadGenerators() {
|
||||
generators.add(new CalendarEventGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new ContactInfoGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new EmailGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new GeoLocationGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new PhoneNumberGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new SmsAddressGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new TextGenerator(changeListener));
|
||||
generators.add(new UrlGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new WifiGenerator(changeListener, keyPressHandler));
|
||||
generators.add(new CalendarEventGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new ContactInfoGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new EmailGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new GeoLocationGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new PhoneNumberGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new SmsAddressGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new TextGenerator(changeHandler));
|
||||
generators.add(new UrlGenerator(changeHandler, keyPressHandler));
|
||||
generators.add(new WifiGenerator(changeHandler, keyPressHandler));
|
||||
}
|
||||
|
||||
public void setupLeftPanel() {
|
||||
|
||||
void setupLeftPanel() {
|
||||
topPanel.setHTML(2, 0,
|
||||
"<span id=\"errorMessageID\" class=\""+StylesDefs.ERROR_MESSAGE+"\"></span>");
|
||||
|
||||
|
||||
// fills up the list of generators
|
||||
for(GeneratorSource generator: generators) {
|
||||
genList.addItem(generator.getName());
|
||||
setGridStyle(generator.getWidget());
|
||||
}
|
||||
|
||||
sizeList.addItem("S", "120");
|
||||
sizeList.addItem("M", "230");
|
||||
sizeList.addItem("L", "350");
|
||||
sizeList.addItem("Small", "120");
|
||||
sizeList.addItem("Medium", "230");
|
||||
sizeList.addItem("Large", "350");
|
||||
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
|
||||
// generator
|
||||
genList.addChangeListener(new ChangeListener() {
|
||||
public void onChange(Widget sender) {
|
||||
encodingList.addItem("UTF-8");
|
||||
encodingList.addItem("ISO-8859-1");
|
||||
encodingList.addItem("Shift_JIS");
|
||||
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();
|
||||
setWidget(i);
|
||||
}
|
||||
});
|
||||
|
||||
// grid for the generator picker
|
||||
Grid selectionTable = new Grid(1, 2);
|
||||
HTMLTable selectionTable = new Grid(1, 2);
|
||||
selectionTable.setText(0, 0, "Contents");
|
||||
selectionTable.setWidget(0, 1, genList);
|
||||
setGridStyle(selectionTable);
|
||||
|
||||
|
||||
topPanel.setWidget(0, 0, selectionTable);
|
||||
|
||||
|
||||
// grid for the generate button
|
||||
Grid generateGrid = new Grid(1, 2);
|
||||
HTMLTable generateGrid = new Grid(1, 2);
|
||||
setGridStyle(generateGrid);
|
||||
|
||||
generateButton = new Button("Generate →");
|
||||
generateButton.addClickListener(new ClickListener() {
|
||||
public void onClick(Widget sender) {
|
||||
|
||||
Button generateButton = new Button("Generate →");
|
||||
generateButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
generate();
|
||||
}
|
||||
});
|
||||
generateGrid.setWidget(0,1,generateButton);
|
||||
generateGrid.setWidget(0, 1, generateButton);
|
||||
topPanel.setWidget(4, 0, generateGrid);
|
||||
|
||||
Grid sizeTable = new Grid(1, 2);
|
||||
sizeTable.setText(0, 0, "Barcode size");
|
||||
sizeTable.setWidget(0, 1, sizeList);
|
||||
setGridStyle(sizeTable);
|
||||
topPanel.setWidget(3, 0, sizeTable);
|
||||
|
||||
HTMLTable configTable = new Grid(3, 2);
|
||||
configTable.setText(0, 0, "Barcode size");
|
||||
configTable.setWidget(0, 1, sizeList);
|
||||
configTable.setText(1, 0, "Error correction");
|
||||
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(1, "secondColumn");
|
||||
CellFormatter cellFormatter = grid.getCellFormatter();
|
||||
for(int i = 0; i < grid.getRowCount(); ++i) {
|
||||
HTMLTable.CellFormatter cellFormatter = grid.getCellFormatter();
|
||||
for (int i = 0; i < grid.getRowCount(); ++i) {
|
||||
cellFormatter.addStyleName(i, 0, "firstColumn");
|
||||
cellFormatter.addStyleName(i, 1, "secondColumn");
|
||||
}
|
||||
}
|
||||
|
||||
protected String getUrl(int sizeX, int sizeY, String content) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("http://chart.apis.google.com/chart?cht=qr&chs=");
|
||||
result.append(sizeX).append('x').append(sizeY);
|
||||
result.append("&chl=");
|
||||
result.append(URL.encodeComponent(content));
|
||||
private static String getUrl(int sizeX, int sizeY, String ecLevel, String encoding, String content) {
|
||||
StringBuilder result = new StringBuilder(100);
|
||||
result.append("http://chart.apis.google.com/chart?cht=qr");
|
||||
result.append("&chs=").append(sizeX).append('x').append(sizeY);
|
||||
result.append("&chld=").append(ecLevel);
|
||||
result.append("&choe=").append(encoding);
|
||||
result.append("&chl=").append(URL.encodeQueryString(content));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
private void generate() {
|
||||
try {
|
||||
String text = selectedGenerator.getText();
|
||||
eraseErrorMessage();
|
||||
int size = Integer.parseInt(sizeList
|
||||
.getValue(sizeList.getSelectedIndex()));
|
||||
String url = getUrl(size, size, text);
|
||||
int size = Integer.parseInt(sizeList.getValue(sizeList.getSelectedIndex()));
|
||||
String ecLevel = ecLevelList.getValue(ecLevelList.getSelectedIndex());
|
||||
String encoding = encodingList.getValue(encodingList.getSelectedIndex());
|
||||
String url = getUrl(size, size, ecLevel, encoding, text);
|
||||
result.setUrl(url);
|
||||
result.setVisible(true);
|
||||
urlResult.setText(url);
|
||||
urlResult.setVisible(true);
|
||||
rawTextResult.setText(text);
|
||||
rawTextResult.setVisible(true);
|
||||
Element linkElement = DOM.getElementById("downloadlink");
|
||||
linkElement.setAttribute("href", url);
|
||||
downloadText.setVisible(true);
|
||||
|
@ -207,30 +228,33 @@ public class Generator implements EntryPoint {
|
|||
showErrorMessage(error);
|
||||
}
|
||||
}
|
||||
|
||||
public void invalidateBarcode() {
|
||||
|
||||
void invalidateBarcode() {
|
||||
result.setVisible(false);
|
||||
urlResult.setText("");
|
||||
urlResult.setVisible(false);
|
||||
rawTextResult.setText("");
|
||||
rawTextResult.setVisible(false);
|
||||
Element linkElement = DOM.getElementById("downloadlink");
|
||||
linkElement.setAttribute("href", "");
|
||||
downloadText.setVisible(false);
|
||||
}
|
||||
|
||||
public void showErrorMessage(String error) {
|
||||
|
||||
private static void showErrorMessage(String error) {
|
||||
Element errorElement = DOM.getElementById("errorMessageID");
|
||||
errorElement.setInnerHTML(error);
|
||||
}
|
||||
|
||||
public void eraseErrorMessage() {
|
||||
|
||||
private static void eraseErrorMessage() {
|
||||
Element errorElement = DOM.getElementById("errorMessageID");
|
||||
errorElement.setInnerHTML(" ");
|
||||
}
|
||||
|
||||
public ChangeListener changeListener = new ChangeListener() {
|
||||
public void onChange(Widget sender) {
|
||||
|
||||
private final ChangeHandler changeHandler = new ChangeHandler() {
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
try {
|
||||
selectedGenerator.validate(sender);
|
||||
selectedGenerator.validate((Widget) event.getSource());
|
||||
eraseErrorMessage();
|
||||
} catch (GeneratorException ex) {
|
||||
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
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (event.getCharCode() == '\n' || event.getCharCode() == '\r') {
|
|
@ -23,8 +23,10 @@ package com.google.zxing.web.generator.client;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class GeneratorException extends Exception {
|
||||
public GeneratorException(String message) {
|
||||
final class GeneratorException extends Exception {
|
||||
|
||||
GeneratorException(String 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;
|
||||
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
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.TextBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
@ -27,21 +27,23 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class PhoneNumberGenerator implements GeneratorSource {
|
||||
Grid table = null;
|
||||
TextBox number = new TextBox();
|
||||
public final class PhoneNumberGenerator implements GeneratorSource {
|
||||
|
||||
private Grid table;
|
||||
private final TextBox number = new TextBox();
|
||||
|
||||
public PhoneNumberGenerator(ChangeListener listener,
|
||||
KeyPressHandler keyListener) {
|
||||
public PhoneNumberGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||
number.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||
number.addChangeListener(listener);
|
||||
number.addChangeHandler(handler);
|
||||
number.addKeyPressHandler(keyListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Phone number";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String tel = getTelField();
|
||||
return "tel:" + tel;
|
||||
|
@ -57,6 +59,7 @@ public class PhoneNumberGenerator implements GeneratorSource {
|
|||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
return table;
|
||||
|
@ -69,12 +72,14 @@ public class PhoneNumberGenerator implements GeneratorSource {
|
|||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == number) {
|
||||
getTelField();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
number.setFocus(true);
|
||||
}
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
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.ChangeListener;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.TextArea;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
|
@ -29,23 +29,25 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class SmsAddressGenerator implements GeneratorSource {
|
||||
Grid table = null;
|
||||
TextBox number = new TextBox();
|
||||
TextArea message = new TextArea();
|
||||
public final class SmsAddressGenerator implements GeneratorSource {
|
||||
|
||||
public SmsAddressGenerator(ChangeListener listener,
|
||||
KeyPressHandler keyListener) {
|
||||
private Grid table;
|
||||
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.addChangeListener(listener);
|
||||
number.addChangeHandler(handler);
|
||||
number.addKeyPressHandler(keyListener);
|
||||
message.addChangeListener(listener);
|
||||
message.addChangeHandler(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SMS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String inputNumber = getTelField();
|
||||
String inputMessage = getMessageField();
|
||||
|
@ -77,6 +79,7 @@ public class SmsAddressGenerator implements GeneratorSource {
|
|||
return inputMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
return table;
|
||||
|
@ -92,6 +95,7 @@ public class SmsAddressGenerator implements GeneratorSource {
|
|||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == number) {
|
||||
getTelField();
|
||||
|
@ -101,6 +105,7 @@ public class SmsAddressGenerator implements GeneratorSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
number.setFocus(true);
|
||||
}
|
|
@ -21,7 +21,11 @@ package com.google.zxing.web.generator.client;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class StylesDefs {
|
||||
public static final String INPUT_FIELD_REQUIRED = "required";
|
||||
public static final String ERROR_MESSAGE = "errorMessage";
|
||||
final class StylesDefs {
|
||||
|
||||
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;
|
||||
|
||||
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.TextArea;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
@ -26,25 +26,28 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class TextGenerator implements GeneratorSource {
|
||||
TextArea text = new TextArea();
|
||||
Grid table = null;
|
||||
String error = "";
|
||||
|
||||
public TextGenerator(ChangeListener listener) {
|
||||
public final class TextGenerator implements GeneratorSource {
|
||||
|
||||
private Grid table;
|
||||
private final TextArea text = new TextArea();
|
||||
|
||||
public TextGenerator(ChangeHandler handler) {
|
||||
text.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
|
||||
text.addChangeListener(listener);
|
||||
text.addChangeHandler(handler);
|
||||
text.setVisibleLines(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
return getTextField();
|
||||
}
|
||||
|
||||
public String getTextField() throws GeneratorException {
|
||||
String getTextField() throws GeneratorException {
|
||||
String input = text.getText();
|
||||
if (input.length() == 0) {
|
||||
throw new GeneratorException("Text should be at least 1 character.");
|
||||
|
@ -52,6 +55,7 @@ public class TextGenerator implements GeneratorSource {
|
|||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
// early termination if the table has already been constructed
|
||||
|
@ -67,16 +71,18 @@ public class TextGenerator implements GeneratorSource {
|
|||
return table;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return error;
|
||||
public static String getErrorMessage() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == text) {
|
||||
getTextField();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
text.setFocus(true);
|
||||
}
|
|
@ -16,10 +16,34 @@
|
|||
|
||||
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
|
||||
*/
|
||||
public class TimeZoneList {
|
||||
public static class TimeZoneInfo {
|
||||
String abreviation;
|
||||
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;
|
||||
}
|
||||
final class TimeZoneList {
|
||||
|
||||
private TimeZoneList() {
|
||||
}
|
||||
|
||||
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;
|
||||
private static final long THIRTY_MIN = 30L*60*1000;
|
||||
|
||||
public static final TimeZoneInfo[] TIMEZONES = {
|
||||
new TimeZoneInfo("GMT", "Greenwich Mean Time", "GMT", 0 * ONE_HOUR + 0 * THIRTY_MIN), // 0
|
||||
new TimeZoneInfo("UTC", "Universal Coordinated Time", "GMT", 0 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("ECT", "European Central Time", "GMT+1:00", 1 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("EET", "Eastern European Time", "GMT+2:00", 2 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("ART", "(Arabic) Egypt Standard Time", "GMT+2:00", 2 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("EAT", "Eastern African Time", "GMT+3:00", 3 * ONE_HOUR + 0 * THIRTY_MIN), // 5
|
||||
new TimeZoneInfo("MET", "Middle East Time", "GMT+3:30", 3 * ONE_HOUR + 1 * THIRTY_MIN),
|
||||
new TimeZoneInfo("NET", "Near East Time", "GMT+4:00", 4 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("PLT", "Pakistan Lahore Time", "GMT+5:00", 5 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("IST", "India Standard Time", "GMT+5:30", 5 * ONE_HOUR + 1 * THIRTY_MIN),
|
||||
new TimeZoneInfo("BST", "Bangladesh Standard Time", "GMT+6:00", 6 * ONE_HOUR + 0 * THIRTY_MIN), // 10
|
||||
new TimeZoneInfo("VST", "Vietnam Standard Time", "GMT+7:00", 7 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("CTT", "China Taiwan Time", "GMT+8:00", 8 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("JST", "Japan Standard Time", "GMT+9:00", 9 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("ACT", "Australia Central Time", "GMT+9:30", 9 * ONE_HOUR + 1 * THIRTY_MIN),
|
||||
new TimeZoneInfo("AET", "Australia Eastern Time", "GMT+10:00", 10 * ONE_HOUR + 0 * THIRTY_MIN), // 15
|
||||
new TimeZoneInfo("SST", "Solomon Standard Time", "GMT+11:00", 11 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("NST", "New Zealand Standard Time", "GMT+12:00", 12 * ONE_HOUR + 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("MIT", "Midway Islands Time", "GMT-11:00", -11 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("HST", "Hawaii Standard Time", "GMT-10:00", -10 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("AST", "Alaska Standard Time", "GMT-9:00", -9 * ONE_HOUR - 0 * THIRTY_MIN), // 20
|
||||
new TimeZoneInfo("PST", "Pacific Standard Time", "GMT-8:00", -8 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("PNT", "Phoenix Standard Time", "GMT-7:00", -7 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("MST", "Mountain Standard Time", "GMT-7:00", -7 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("CST", "Central Standard Time", "GMT-6:00", -6 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("EST", "Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR - 0 * THIRTY_MIN), // 25
|
||||
new TimeZoneInfo("IET", "Indiana Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("PRT", "Puerto Rico and US Virgin Islands Time", "GMT-4:00", -4 * ONE_HOUR - 0 * THIRTY_MIN),
|
||||
new TimeZoneInfo("CNT", "Canada Newfoundland Time", "GMT-3:30", -3 * ONE_HOUR - 1 * THIRTY_MIN),
|
||||
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),
|
||||
static final TimeZoneInfo[] TIMEZONES = {
|
||||
new TimeZoneInfo("GMT", "Greenwich Mean Time", "GMT", 0), // 0
|
||||
new TimeZoneInfo("UTC", "Universal Coordinated Time", "GMT", 0),
|
||||
new TimeZoneInfo("ECT", "European Central Time", "GMT+1:00", ONE_HOUR),
|
||||
new TimeZoneInfo("EET", "Eastern European Time", "GMT+2:00", 2 * ONE_HOUR),
|
||||
new TimeZoneInfo("ART", "(Arabic) Egypt Standard Time", "GMT+2:00", 2 * ONE_HOUR),
|
||||
new TimeZoneInfo("EAT", "Eastern African Time", "GMT+3:00", 3 * ONE_HOUR), // 5
|
||||
new TimeZoneInfo("MET", "Middle East Time", "GMT+3:30", 3 * ONE_HOUR + THIRTY_MIN),
|
||||
new TimeZoneInfo("NET", "Near East Time", "GMT+4:00", 4 * ONE_HOUR),
|
||||
new TimeZoneInfo("PLT", "Pakistan Lahore Time", "GMT+5:00", 5 * ONE_HOUR),
|
||||
new TimeZoneInfo("IST", "India Standard Time", "GMT+5:30", 5 * ONE_HOUR + THIRTY_MIN),
|
||||
new TimeZoneInfo("BST", "Bangladesh Standard Time", "GMT+6:00", 6 * ONE_HOUR), // 10
|
||||
new TimeZoneInfo("VST", "Vietnam Standard Time", "GMT+7:00", 7 * ONE_HOUR),
|
||||
new TimeZoneInfo("CTT", "China Taiwan Time", "GMT+8:00", 8 * ONE_HOUR),
|
||||
new TimeZoneInfo("JST", "Japan Standard Time", "GMT+9:00", 9 * ONE_HOUR),
|
||||
new TimeZoneInfo("ACT", "Australia Central Time", "GMT+9:30", 9 * ONE_HOUR + THIRTY_MIN),
|
||||
new TimeZoneInfo("AET", "Australia Eastern Time", "GMT+10:00", 10 * ONE_HOUR), // 15
|
||||
new TimeZoneInfo("SST", "Solomon Standard Time", "GMT+11:00", 11 * ONE_HOUR),
|
||||
new TimeZoneInfo("NST", "New Zealand Standard Time", "GMT+12:00", 12 * ONE_HOUR),
|
||||
new TimeZoneInfo("MIT", "Midway Islands Time", "GMT-11:00", -11 * ONE_HOUR),
|
||||
new TimeZoneInfo("HST", "Hawaii Standard Time", "GMT-10:00", -10 * ONE_HOUR),
|
||||
new TimeZoneInfo("AST", "Alaska Standard Time", "GMT-9:00", -9 * ONE_HOUR), // 20
|
||||
new TimeZoneInfo("PST", "Pacific Standard Time", "GMT-8:00", -8 * ONE_HOUR),
|
||||
new TimeZoneInfo("PNT", "Phoenix Standard Time", "GMT-7:00", -7 * ONE_HOUR),
|
||||
new TimeZoneInfo("MST", "Mountain Standard Time", "GMT-7:00", -7 * ONE_HOUR),
|
||||
new TimeZoneInfo("CST", "Central Standard Time", "GMT-6:00", -6 * ONE_HOUR),
|
||||
new TimeZoneInfo("EST", "Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR), // 25
|
||||
new TimeZoneInfo("IET", "Indiana Eastern Standard Time", "GMT-5:00", -5 * ONE_HOUR),
|
||||
new TimeZoneInfo("PRT", "Puerto Rico and US Virgin Islands Time", "GMT-4:00", -4 * ONE_HOUR),
|
||||
new TimeZoneInfo("CNT", "Canada Newfoundland Time", "GMT-3:30", -3 * ONE_HOUR - THIRTY_MIN),
|
||||
new TimeZoneInfo("AGT", "Argentina Standard Time", "GMT-3:00", -3 * ONE_HOUR),
|
||||
new TimeZoneInfo("BET", "Brazil Eastern Time", "GMT-3:00", -3 * ONE_HOUR), // 30
|
||||
new TimeZoneInfo("CAT", "Central African Time", "GMT-1:00", -1 * ONE_HOUR),
|
||||
};
|
||||
|
||||
}
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
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.ChangeListener;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
@ -27,16 +27,18 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public class UrlGenerator implements GeneratorSource {
|
||||
Grid table = null;
|
||||
TextBox url = new TextBox();
|
||||
public final class UrlGenerator implements GeneratorSource {
|
||||
|
||||
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.addChangeListener(listener);
|
||||
url.addChangeHandler(handler);
|
||||
url.addKeyPressHandler(keyListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
// early termination if the table has already been constructed
|
||||
|
@ -54,10 +56,12 @@ public class UrlGenerator implements GeneratorSource {
|
|||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "URL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
return getUrlField();
|
||||
}
|
||||
|
@ -68,12 +72,14 @@ public class UrlGenerator implements GeneratorSource {
|
|||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == url) {
|
||||
getUrlField();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
url.setFocus(true);
|
||||
}
|
|
@ -22,18 +22,22 @@ package com.google.zxing.web.generator.client;
|
|||
*
|
||||
* @author Yohann Coppel
|
||||
*/
|
||||
public final class Validators {
|
||||
public static String filterNumber(String number) {
|
||||
final class Validators {
|
||||
|
||||
private Validators() {
|
||||
}
|
||||
|
||||
static String filterNumber(String number) {
|
||||
return number.replaceAll("[ \\.,\\-\\(\\)]", "");
|
||||
}
|
||||
|
||||
public static void validateNumber(String number) throws GeneratorException {
|
||||
static void validateNumber(String number) throws GeneratorException {
|
||||
if (!number.matches("\\+?[0-9]+")) {
|
||||
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)) {
|
||||
throw new GeneratorException("URL is not valid.");
|
||||
}
|
||||
|
@ -45,13 +49,10 @@ public final class Validators {
|
|||
}
|
||||
int period = uri.indexOf('.');
|
||||
// Look for period in a domain but followed by at least a two-char TLD
|
||||
if (period >= uri.length() - 2) {
|
||||
return false;
|
||||
}
|
||||
return period >= 0 || uri.indexOf(':') >= 0;
|
||||
return period < uri.length() - 2 && (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.
|
||||
if (!email.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")) {
|
||||
throw new GeneratorException("Email is not valid.");
|
|
@ -16,9 +16,10 @@
|
|||
|
||||
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.ChangeListener;
|
||||
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.ListBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
@ -28,29 +29,30 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
*
|
||||
* @author Vikram Aggarwal
|
||||
*/
|
||||
public class WifiGenerator implements GeneratorSource {
|
||||
Grid table = null;
|
||||
TextBox ssid = new TextBox();
|
||||
TextBox password = new TextBox();
|
||||
final boolean multipleSelections = false;
|
||||
ListBox networkType = new ListBox(multipleSelections);
|
||||
TextBox[] widgets = {ssid, password };
|
||||
|
||||
public WifiGenerator(ChangeListener changeListener, KeyPressHandler keyListener) {
|
||||
networkType.addItem("WEP", "WEP");
|
||||
networkType.addItem("WPA/WPA2", "WPA");
|
||||
networkType.addItem("No encryption", "nopass");
|
||||
|
||||
public final class WifiGenerator implements GeneratorSource {
|
||||
|
||||
private Grid table;
|
||||
private final TextBox ssid = new TextBox();
|
||||
private final TextBox password = new TextBox();
|
||||
private final ListBox networkType = new ListBox(false);
|
||||
|
||||
public WifiGenerator(ChangeHandler handler, KeyPressHandler keyListener) {
|
||||
networkType.addItem("WEP", "WEP");
|
||||
networkType.addItem("WPA/WPA2", "WPA");
|
||||
networkType.addItem("No encryption", "nopass");
|
||||
TextBox[] widgets = {ssid, password};
|
||||
for (TextBox w: widgets) {
|
||||
w.addChangeListener(changeListener);
|
||||
w.addChangeHandler(handler);
|
||||
w.addKeyPressHandler(keyListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Wifi network";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String ssid = getSsidField();
|
||||
String password = getPasswordField();
|
||||
|
@ -60,7 +62,7 @@ public class WifiGenerator implements GeneratorSource {
|
|||
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);
|
||||
output.append("WIFI:");
|
||||
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();
|
||||
if (input.length() < 1) {
|
||||
return "";
|
||||
|
@ -107,6 +109,7 @@ public class WifiGenerator implements GeneratorSource {
|
|||
return networkType.getValue(networkType.getSelectedIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grid getWidget() {
|
||||
if (table != null) {
|
||||
// early termination if the table has already been constructed
|
||||
|
@ -125,6 +128,7 @@ public class WifiGenerator implements GeneratorSource {
|
|||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Widget widget) throws GeneratorException {
|
||||
if (widget == ssid) {
|
||||
getSsidField();
|
||||
|
@ -137,6 +141,7 @@ public class WifiGenerator implements GeneratorSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
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;
|
||||
display: table;
|
||||
#position: relative;
|
||||
}
|
||||
#innerresult {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
width: 100%;
|
||||
#position: absolute;
|
||||
#top: 50%;
|
||||
}
|
||||
#innerresult img {
|
||||
#position: relative;
|
||||
#top: -50%;
|
||||
}
|
||||
#downloadText {
|
||||
font-size: 11px;
|
||||
|
@ -66,6 +59,9 @@ body {
|
|||
#urlresult {
|
||||
width: 350px;
|
||||
}
|
||||
#rawtextresult {
|
||||
width: 350px;
|
||||
}
|
||||
.firstColumn {
|
||||
width: 100px;
|
||||
text-align: right;
|
||||
|
@ -97,7 +93,7 @@ body {
|
|||
background-color: #fffbcc;
|
||||
}
|
||||
.required {
|
||||
background: #ffffff url(required-field-bg.png) repeat-y;
|
||||
background: #ffffff url(static/required-field-bg.png) repeat-y;
|
||||
}
|
||||
.errorMessage {
|
||||
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>
|
||||
<head>
|
||||
|
@ -9,26 +9,22 @@
|
|||
|
||||
<body>
|
||||
<div id="header">
|
||||
<h1>Zebra Crossing<span> from the ZXing Project</span></h1>
|
||||
<h1>Zebra Crossing <span>from the ZXing Project</span></h1>
|
||||
</div>
|
||||
|
||||
<table width="600" cellpadding="4" cellspacing="8">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<img src="zxingicon.png" width="128" height="128">
|
||||
<img src="zxingicon.png" width="128" height="128"/>
|
||||
</td>
|
||||
<td valign="top">
|
||||
Welcome to the Zebra Crossing site at zxing.appspot.com.
|
||||
<p>
|
||||
This site features a <a href="generator">QR Code Generator</a>, which
|
||||
<p>Welcome to the Zebra Crossing site at zxing.appspot.com.</p>
|
||||
<p> This site features a <a href="generator">QR Code Generator</a>, which
|
||||
allows you to create a two-dimensional barcode that can be scanned
|
||||
with a camera phone. These QR Codes can contain a URL, contact
|
||||
information, a calendar event, and much more.
|
||||
<p>
|
||||
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. You
|
||||
can <a href="http://code.google.com/p/zxing/wiki/GetTheReader">
|
||||
download the software</a> for your phone here.
|
||||
information, a calendar event, and much more.</p>
|
||||
<p>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>
|
||||
</td>
|
||||
</tr>
|
||||
</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 |