# HG changeset patch # User Jaroslav Tulach # Date 1272803083 -7200 # Node ID 26f9a0ec4315bdc7603e562c2380766d24f6f4a5 # Parent 481fbbbcc7b7a48fdafa9743ed1d7287f57f786d Showing stateful API on Progress example diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/build.xml Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project stateful. + + + diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/manifest.mf Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/nbproject/build-impl.xml Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,883 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/nbproject/genfiles.properties Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=0a6260c2 +build.xml.script.CRC32=de1f9cb3 +build.xml.stylesheet.CRC32=958a1d3e@1.38.0.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=0a6260c2 +nbproject/build-impl.xml.script.CRC32=6711875f +nbproject/build-impl.xml.stylesheet.CRC32=c75ce636@1.38.0.45 diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/nbproject/project.properties Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,71 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/stateful.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=stateful.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/nbproject/project.xml Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + stateful + + + + + + + + + diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/src/org/apidesign/stateful/api/Progress.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/src/org/apidesign/stateful/api/Progress.java Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,53 @@ +package org.apidesign.stateful.api; + +/** API for notifying progress. + * + * @author Jaroslav Tulach + */ +// BEGIN: progress.api +public abstract class Progress { + public static Progress create(String name) { + return createImpl(name); + } + public abstract void start(int totalAmount); + public abstract void progress(int howMuch); + public abstract void finish(); + // FINISH: progress.api + + Progress() { + } + + private static Progress createImpl(String name) { + return new Impl(name); + } + + private static final class Impl extends Progress { + private final String name; + private int total = -1; + private int current; + + public Impl(String name) { + this.name = name; + } + + @Override + public void start(int totalAmount) { + total = totalAmount; + } + + @Override + public void progress(int howMuch) { + if (total == -1) { + throw new IllegalStateException("Call start first!"); + } + current = howMuch; + } + + @Override + public void finish() { + total = -1; + current = 0; + } + + } +} diff -r 481fbbbcc7b7 -r 26f9a0ec4315 samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java Sun May 02 14:24:43 2010 +0200 @@ -0,0 +1,25 @@ +package org.apidesign.stateful.api; + +import junit.framework.TestCase; + +public class ProgressTest extends TestCase { + + public ProgressTest(String testName) { + super(testName); + } + + public void testProgressWithoutStart() { + try { + // BEGIN: progress.wrong.order + Progress p = Progress.create("WrongOrder"); + p.progress(10); + p.finish(); + // END: progress.wrong.order + + fail("Calling progress without start yields an exception!?"); + } catch (IllegalStateException ex) { + // OK + } + } + +}