You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
(115) |
May
(11) |
Jun
(5) |
Jul
(2) |
Aug
(10) |
Sep
(35) |
Oct
(14) |
Nov
(49) |
Dec
(27) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(57) |
Feb
(1) |
Mar
|
Apr
(2) |
May
(25) |
Jun
(134) |
Jul
(76) |
Aug
(34) |
Sep
(27) |
Oct
(5) |
Nov
|
Dec
(1) |
2008 |
Jan
(3) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(63) |
Nov
(30) |
Dec
(43) |
2009 |
Jan
(10) |
Feb
(420) |
Mar
(67) |
Apr
(3) |
May
(61) |
Jun
(21) |
Jul
(19) |
Aug
|
Sep
(6) |
Oct
(16) |
Nov
(1) |
Dec
|
2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
(7) |
May
(3) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: <chr...@us...> - 2006-11-25 14:20:21
|
Revision: 208 http://svn.sourceforge.net/japi/?rev=208&view=rev Author: christianhujer Date: 2006-11-25 06:20:20 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Improved package description. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/package.html Modified: libs/argparser/trunk/src/net/sf/japi/io/args/package.html =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/package.html 2006-11-25 14:19:43 UTC (rev 207) +++ libs/argparser/trunk/src/net/sf/japi/io/args/package.html 2006-11-25 14:20:20 UTC (rev 208) @@ -27,7 +27,28 @@ </head> <body> <p> - Parsing command line arguments. + ArgParser is a library for parsing command line arguments. </p> + <p> + It supports short options (e.g. <samp>-h</samp>) and long options (e.g. <samp>--help</samp>). + </p> + <p> + If an option takes a parameter, the argument value may follow the option as separate argument. + If the option is a long option, the value may alternatively be included in the argument string using the <code>'='</code>-character. + For instance, if an option has short name <samp>i</samp> and long name <samp>in</samp> and the option takes a String argument, the following variants are possible: + <samp>-i foo</samp>, <samp>--in foo</samp> and <samp>--in=foo</samp>. + </p> + <p> + Short options may be given in the same String. + For instance, if there are the short options <samp>v</samp>, <samp>i</samp> and <samp>s</samp>, all of them may be given together in a single String. + That means the following variants are possible: + <samp>-vis</samp>, <samp>-v -i -s</samp> and any combination of separated and concatenated versions like <samp>-v -is</samp>. + If short options take argument values and they are concatenated, the argument values are separate strings following the concatenated option in exactly the order of the concatenated options. + In <samp>-io foo bar</samp>, given that both, <samp>i</samp> and <samp>o</samp> take an argument value, <samp>foo</samp> is value for <samp>i</samp>, while <samp>bar</samp> is value for <samp>o</samp>. + </p> + <p> + The special option <code>--</code> will stop argument parsing. + All strings that follow the <code>--</code>-option are treated as command arguments, not options, even if they start with <code>-</code>. + </p> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-25 14:19:47
|
Revision: 207 http://svn.sourceforge.net/japi/?rev=207&view=rev Author: christianhujer Date: 2006-11-25 06:19:43 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Some minor improvements. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-11-25 10:16:15 UTC (rev 206) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-11-25 14:19:43 UTC (rev 207) @@ -28,10 +28,9 @@ /** * Parser for command line arguments. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * TODO: automatic argument conversion for option method invocation. - * TODO: better handling of boolean arguments - * TODO: Handling of - for STDIN as input argument filestream - * TODO: Support for I18N/L10N + * @todo automatic argument conversion for option method invocation. + * @todo better handling of boolean arguments + * @todo Handling of - for STDIN as input argument filestream */ public class ArgParser { @@ -61,6 +60,7 @@ * @throws RequiredOptionsMissingException in case an option is missing * @throws TerminalException in case argument parsing was stopped * @throws MissingArgumentException in the required argument for an option was missing + * @throws UnknownOptionException In case an option was specified that's not supported. */ private ArgParser(final Command command, final String... args) throws TerminalException, RequiredOptionsMissingException, UnknownOptionException, MissingArgumentException { this.command = command; @@ -70,7 +70,7 @@ argIterator = argList.listIterator(); parse(); checkRequiredMethods(); - int returnCode = 0; + int returnCode; try { returnCode = command.run(argList); } catch (final Exception e) { @@ -148,6 +148,8 @@ /** * Parses arguments into an arguments container and invokes the Command's {@link Command#run(List<String>)} method. * @throws TerminalException in case argument parsing was stopped + * @throws MissingArgumentException In case a required argument was missing. + * @throws UnknownOptionException In case a given option is not known. */ private void parse() throws TerminalException, UnknownOptionException, MissingArgumentException { try { @@ -187,6 +189,7 @@ /** * Invoke the argument method for the current option. * @throws TerminalException in case the invoked exception was terminal + * @throws UnknownOptionException In case a given option is not known. */ private void invokeMethod() throws TerminalException, UnknownOptionException { final Method method = argumentMethods.get(currentOption); @@ -201,9 +204,10 @@ final String arg = argIterator.next(); method.invoke(command, arg); argIterator.remove(); + } else if (parameterCount == 0) { + method.invoke(command); } else { - assert parameterCount == 0; - method.invoke(command); + throw new IllegalArgumentException("The number of parameters for option methods must be 0 or 1."); } } catch (final IllegalAccessException e) { System.err.println(e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-25 10:16:17
|
Revision: 206 http://svn.sourceforge.net/japi/?rev=206&view=rev Author: christianhujer Date: 2006-11-25 02:16:15 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Improvements on the build system. Modified Paths: -------------- libs/argparser/trunk/build.xml Modified: libs/argparser/trunk/build.xml =================================================================== --- libs/argparser/trunk/build.xml 2006-11-25 10:15:28 UTC (rev 205) +++ libs/argparser/trunk/build.xml 2006-11-25 10:16:15 UTC (rev 206) @@ -1,26 +1,44 @@ <?xml version="1.0" encoding="utf-8"?> <project name="japi lib argparser" default="compile"> + <property name="module.version" value="0.1" /> <property name="module.name" value="japi-lib-argparser" /> + <taskdef name="pack200" classpath="lib/Pack200Task.jar" classname="com.sun.tools.apache.ant.pack200.Pack200Task" /> - <target name="compile"> + + <target + name = "clean" + description = "Cleans Sandbox" + > + <delete dir="classes" /> + <delete dir="docs" /> + </target> + + <target + name = "compile" + description = "Compiles production classes" + > <mkdir dir="classes/production/argparser" /> <mkdir dir="classes/test/argparser" /> <javac srcdir="src" - destdir="classes" + destdir="classes/production" encoding="utf-8" source="1.5" target="1.5" > <classpath> - <fileset dir="lib" includes="*.jar" /> + <fileset dir="lib" includes="*.jar" excludes="LICENSE-*.jar" /> </classpath> + <exclude name="test/**/*.java" /> </javac> </target> + <target name = "dist" - description = "Packs distribution archives."> + description = "Packs distribution archives." + depends = "clean, compile" + > <!--depends = "clean, compile, doc" --> <delete dir="dist" /> @@ -91,15 +109,16 @@ <delete file="${distName}.src.tar" /> <delete file="${distName}.doc.tar" /> </target> + <target - name = "apiDoc" + name = "doc" description = "Creates public javadoc documentation." > - <mkdir dir="dest/doc/api/${module.version}" /> - <!--copy todir="dest/doc/api/${module.version}" file="src/doc/api/public/copyright.html" /> - <copy todir="dest/doc/api/${module.version}" file="src/doc/api/public/.htaccess" /--> + <mkdir dir="docs/api" /> + <!--copy todir="docs/api" file="src/doc/api/public/copyright.html" /> + <copy todir="docs/api" file="src/doc/api/public/.htaccess" /--> <javadoc - destdir = "dest/doc/api/${module.version}" + destdir = "docs/api" access = "protected" author = "yes" version = "yes" @@ -141,7 +160,8 @@ <tag enabled="true" name="invariant" description="Invariant:" scope="methods,fields" /> <tag enabled="true" name="note" description="Notes:" /> <tag enabled="true" name="warning" description="Warnings:" /> - <tag enabled="true" name="todo" description="Todo:" /> + <!--tag enabled="true" name="todo" description="Todo:" /--> + <taglet name="com.sun.tools.doclets.ToDoTaglet" path="" /> <tag enabled="true" name="fixme" description="Fixme:" /> <tag enabled="true" name="xxx" description="XXX:" /> </javadoc> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-25 10:15:31
|
Revision: 205 http://svn.sourceforge.net/japi/?rev=205&view=rev Author: christianhujer Date: 2006-11-25 02:15:28 -0800 (Sat, 25 Nov 2006) Log Message: ----------- Changed postcondition and precondition to be applicable to code only. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java 2006-11-21 22:23:03 UTC (rev 204) +++ libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java 2006-11-25 10:15:28 UTC (rev 205) @@ -19,6 +19,26 @@ super("postcondition", "Postconditions"); } + /** {@inheritDoc} */ + @Override public boolean inField() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean inOverview() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean inPackage() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean inType() { + return false; + } + /** * Register this Taglet. * @param tagletMap the map to register this tag to. Modified: libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java 2006-11-21 22:23:03 UTC (rev 204) +++ libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java 2006-11-25 10:15:28 UTC (rev 205) @@ -19,6 +19,26 @@ super("precondition", "Preconditions"); } + /** {@inheritDoc} */ + @Override public boolean inField() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean inOverview() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean inPackage() { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean inType() { + return false; + } + /** * Register this Taglet. * @param tagletMap the map to register this tag to. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-21 22:33:27
|
Revision: 204 http://svn.sourceforge.net/japi/?rev=204&view=rev Author: christianhujer Date: 2006-11-21 14:23:03 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Added todos. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java 2006-11-21 22:15:18 UTC (rev 203) +++ libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java 2006-11-21 22:23:03 UTC (rev 204) @@ -6,6 +6,8 @@ /** * Base class for Taglets that are simple blocks transforming into lists. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo add user definable background colour + * @todo auto-detect singular / plural of heading */ public abstract class BlockListTaglet implements Taglet { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-21 22:15:24
|
Revision: 203 http://svn.sourceforge.net/japi/?rev=203&view=rev Author: christianhujer Date: 2006-11-21 14:15:18 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Made constructors private. Added taglets for invariant, precondition and postcondition. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java Added Paths: ----------- libs/taglets/trunk/src/net/sf/japi/taglets/InvariantTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-21 21:25:58 UTC (rev 202) +++ libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -16,7 +16,7 @@ /** * Create an FixmeTaglet. */ - protected FixmeTaglet() { + private FixmeTaglet() { super("fixme", "Fixme"); } Added: libs/taglets/trunk/src/net/sf/japi/taglets/InvariantTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/InvariantTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/InvariantTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -0,0 +1,31 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + * Taglet for documenting invariants. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see PreconditionTaglet + * @see PostconditionTaglet + */ +public class InvariantTaglet extends BlockListTaglet { + + /** + * Create a InvariantTaglet. + */ + private InvariantTaglet() { + super("invariant", "Invariants"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map<String, Taglet> tagletMap) { + final Taglet taglet = new InvariantTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class WarningTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/InvariantTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java 2006-11-21 21:25:58 UTC (rev 202) +++ libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -15,7 +15,7 @@ /** * Create a WarningTaglet. */ - protected NoteTaglet() { + private NoteTaglet() { super("note", "Notes"); } Added: libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -0,0 +1,31 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + * Taglet for documenting postconditions. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see InvariantTaglet + * @see PreconditionTaglet + */ +public class PostconditionTaglet extends BlockListTaglet { + + /** + * Create a PostconditionTaglet. + */ + private PostconditionTaglet() { + super("postcondition", "Postconditions"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map<String, Taglet> tagletMap) { + final Taglet taglet = new PostconditionTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class WarningTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/PostconditionTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -0,0 +1,31 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + * Taglet for documenting preconditions. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see PostconditionTaglet + * @see InvariantTaglet + */ +public class PreconditionTaglet extends BlockListTaglet { + + /** + * Create a PreconditionTaglet. + */ + private PreconditionTaglet() { + super("precondition", "Preconditions"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map<String, Taglet> tagletMap) { + final Taglet taglet = new PreconditionTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class WarningTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/PreconditionTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-21 21:25:58 UTC (rev 202) +++ libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -18,7 +18,7 @@ /** * Create an TodoTaglet. */ - protected TodoTaglet() { + private TodoTaglet() { super("todo", "Todo"); } Modified: libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java 2006-11-21 21:25:58 UTC (rev 202) +++ libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -15,7 +15,7 @@ /** * Create a WarningTaglet. */ - protected WarningTaglet() { + private WarningTaglet() { super("warning", "Warnings"); } Modified: libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-21 21:25:58 UTC (rev 202) +++ libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-21 22:15:18 UTC (rev 203) @@ -16,7 +16,7 @@ /** * Create an XxxTaglet. */ - protected XxxTaglet() { + private XxxTaglet() { super("xxx", "XXX"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-21 21:26:26
|
Revision: 202 http://svn.sourceforge.net/japi/?rev=202&view=rev Author: christianhujer Date: 2006-11-21 13:25:58 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Added warning and note taglets. Added Paths: ----------- libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java Added: libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java 2006-11-21 21:25:58 UTC (rev 202) @@ -0,0 +1,31 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + * Taglet for entries in a warnings list. + * A warning states that somebody must take care of something when using the symbol documented with the warning. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see NoteTaglet for less severe notes + */ +public class NoteTaglet extends BlockListTaglet { + + /** + * Create a WarningTaglet. + */ + protected NoteTaglet() { + super("note", "Notes"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map<String, Taglet> tagletMap) { + final Taglet taglet = new NoteTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class WarningTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/NoteTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java 2006-11-21 21:25:58 UTC (rev 202) @@ -0,0 +1,31 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + * Taglet for entries in a warnings list. + * A warning states that somebody must take care of something when using the symbol documented with the warning. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see NoteTaglet for less severe notes + */ +public class WarningTaglet extends BlockListTaglet { + + /** + * Create a WarningTaglet. + */ + protected WarningTaglet() { + super("warning", "Warnings"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map<String, Taglet> tagletMap) { + final Taglet taglet = new WarningTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class WarningTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/WarningTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-21 21:25:00
|
Revision: 201 http://svn.sourceforge.net/japi/?rev=201&view=rev Author: christianhujer Date: 2006-11-21 13:24:59 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Fixed docu bugs. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-21 20:02:17 UTC (rev 200) +++ libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-21 21:24:59 UTC (rev 201) @@ -14,7 +14,7 @@ public class FixmeTaglet extends BlockListTaglet { /** - * Create an XxxTaglet. + * Create an FixmeTaglet. */ protected FixmeTaglet() { super("fixme", "Fixme"); Modified: libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-21 20:02:17 UTC (rev 200) +++ libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-21 21:24:59 UTC (rev 201) @@ -16,7 +16,7 @@ public class TodoTaglet extends BlockListTaglet { /** - * Create an XxxTaglet. + * Create an TodoTaglet. */ protected TodoTaglet() { super("todo", "Todo"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-21 20:02:20
|
Revision: 200 http://svn.sourceforge.net/japi/?rev=200&view=rev Author: christianhujer Date: 2006-11-21 12:02:17 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Improved comment, generified code. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-21 19:38:01 UTC (rev 199) +++ libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-21 20:02:17 UTC (rev 200) @@ -5,8 +5,11 @@ import java.util.Map; /** - * Taglet for fixme block tags. + * Taglet for entries in a fixme list. + * A fixme entry denotes code that is known to be bogus and needs fixing. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see TodoTaglet for general work that needs to be done + * @see XxxTaglet for code that looks bogus but seems to work */ public class FixmeTaglet extends BlockListTaglet { @@ -21,7 +24,7 @@ * Register this Taglet. * @param tagletMap the map to register this tag to. */ - public static void register(final Map tagletMap) { + public static void register(final Map<String, Taglet> tagletMap) { final Taglet taglet = new FixmeTaglet(); tagletMap.put(taglet.getName(), taglet); } Modified: libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-21 19:38:01 UTC (rev 199) +++ libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-21 20:02:17 UTC (rev 200) @@ -5,8 +5,13 @@ import java.util.Map; /** - * Taglet for todo block tags. + * Taglet for entries in a todo list. + * A todo entry states a missing or unimplemented feature or other work that needs to be done as soon as sombody has time for it. + * Todo entries shouldn't be used for code that is known to be or at least looks like being erraneous. + * For these situations, use either {@link XxxTaglet @xxx} or {@link FixmeTaglet @fixme}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see XxxTaglet for code that looks bogus but seems to work + * @see FixmeTaglet for code that is known to be bogus */ public class TodoTaglet extends BlockListTaglet { @@ -21,7 +26,7 @@ * Register this Taglet. * @param tagletMap the map to register this tag to. */ - public static void register(final Map tagletMap) { + public static void register(final Map<String, Taglet> tagletMap) { final Taglet taglet = new TodoTaglet(); tagletMap.put(taglet.getName(), taglet); } Modified: libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-21 19:38:01 UTC (rev 199) +++ libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-21 20:02:17 UTC (rev 200) @@ -5,8 +5,11 @@ import java.util.Map; /** - * Taglet for xxx block tags. + * Taglet for entries in an xxx list. + * An xxx entry denotes code that seems to work and looks bogus or might be a Schroedinbug. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see TodoTaglet for general work that needs to be done + * @see FixmeTaglet for code that is known to be bogus */ public class XxxTaglet extends BlockListTaglet { @@ -21,7 +24,7 @@ * Register this Taglet. * @param tagletMap the map to register this tag to. */ - public static void register(final Map tagletMap) { + public static void register(final Map<String, Taglet> tagletMap) { final Taglet taglet = new XxxTaglet(); tagletMap.put(taglet.getName(), taglet); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-21 19:38:10
|
Revision: 199 http://svn.sourceforge.net/japi/?rev=199&view=rev Author: christianhujer Date: 2006-11-21 11:38:01 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Removed unused import statement. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java 2006-11-20 21:48:45 UTC (rev 198) +++ libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java 2006-11-21 19:38:01 UTC (rev 199) @@ -3,8 +3,6 @@ import com.sun.javadoc.Tag; import com.sun.tools.doclets.Taglet; -import java.util.Map; - /** * Base class for Taglets that are simple blocks transforming into lists. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-20 21:48:47
|
Revision: 198 http://svn.sourceforge.net/japi/?rev=198&view=rev Author: christianhujer Date: 2006-11-20 13:48:45 -0800 (Mon, 20 Nov 2006) Log Message: ----------- Fixed some documentation bugs. Modified Paths: -------------- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java Modified: libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-20 21:10:28 UTC (rev 197) +++ libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-20 21:48:45 UTC (rev 198) @@ -5,6 +5,8 @@ import java.util.Map; /** + * Taglet for fixme block tags. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class FixmeTaglet extends BlockListTaglet { @@ -24,4 +26,4 @@ tagletMap.put(taglet.getName(), taglet); } -} // class XxxTaglet +} // class FixmeTaglet Modified: libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-20 21:10:28 UTC (rev 197) +++ libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-20 21:48:45 UTC (rev 198) @@ -5,6 +5,8 @@ import java.util.Map; /** + * Taglet for todo block tags. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class TodoTaglet extends BlockListTaglet { @@ -24,4 +26,4 @@ tagletMap.put(taglet.getName(), taglet); } -} // class XxxTaglet +} // class TodoTaglet Modified: libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-20 21:10:28 UTC (rev 197) +++ libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-20 21:48:45 UTC (rev 198) @@ -5,6 +5,8 @@ import java.util.Map; /** + * Taglet for xxx block tags. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class XxxTaglet extends BlockListTaglet { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-20 21:10:31
|
Revision: 197 http://svn.sourceforge.net/japi/?rev=197&view=rev Author: christianhujer Date: 2006-11-20 13:10:28 -0800 (Mon, 20 Nov 2006) Log Message: ----------- Added taglets. Added Paths: ----------- libs/taglets/ libs/taglets/branches/ libs/taglets/tags/ libs/taglets/trunk/ libs/taglets/trunk/build.xml libs/taglets/trunk/src/ libs/taglets/trunk/src/net/ libs/taglets/trunk/src/net/sf/ libs/taglets/trunk/src/net/sf/japi/ libs/taglets/trunk/src/net/sf/japi/taglets/ libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java Added: libs/taglets/trunk/build.xml =================================================================== --- libs/taglets/trunk/build.xml (rev 0) +++ libs/taglets/trunk/build.xml 2006-11-20 21:10:28 UTC (rev 197) @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<project name="japi lib taglets" default="compile"> + + <property name="module.version" value="0.1" /> + <property name="module.name" value="japi-lib-taglets" /> + + <taskdef name="pack200" classpath="lib/Pack200Task.jar" classname="com.sun.tools.apache.ant.pack200.Pack200Task" /> + + <target + name = "clean" + description = "Cleans Sandbox" + > + <delete dir="classes" /> + <delete dir="dist" /> + <delete dir="docs" /> + </target> + + <target + name = "compile" + description = "Compiles production classes" + > + <mkdir dir="classes/production/taglets" /> + <mkdir dir="classes/test/taglets" /> + <javac + srcdir="src" + destdir="classes/production" + encoding="utf-8" + source="1.5" + target="1.5" + > + <classpath> + <fileset dir="lib" includes="*.jar" excludes="LICENSE-*.jar" /> + </classpath> + <exclude name="test/**/*.java" /> + </javac> + </target> + + <target + name = "dist" + description = "Packs distribution archives." + depends = "clean, compile" + > + <!--depends = "clean, compile, doc" + --> + <delete dir="dist" /> + <mkdir dir="dist" /> + <property name="distName" value="dist/${module.name}-${module.version}" /> + <parallel> + <tar tarfile="${distName}.src.tar"> + <tarfileset dir="." prefix="${module.name}-${module.version}"> + <include name="src/**" /> + <include name="build.xml" /> + </tarfileset> + </tar> + <zip destfile="${distName}.src.zip"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="src/**" /> + <include name="build.xml" /> + </zipfileset> + </zip> + <jar destfile="${distName}.src.jar"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="src/**" /> + <include name="build.xml" /> + </zipfileset> + </jar> + <jar destfile="${distName}.jar"> + <zipfileset dir="classes/production" /> + <manifest> + <attribute name="Implementation-Title" value="JAPI" /> + <attribute name="Implementation-Vendor" value="Christian Hujer + the JAPI Developers" /> + <attribute name="Implementation-Version" value="${module.version}" /> + <attribute name="Implementation-URL" value="http://sourceforge.net/projects/japi/" /> + </manifest> + </jar> + <tar tarfile="${distName}.doc.tar"> + <tarfileset dir="." prefix="${module.name}-${module.version}"> + <include name="docs/**" /> + <include name="build.xml" /> + </tarfileset> + </tar> + <zip destfile="${distName}.doc.zip"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="docs/**" /> + <include name="build.xml" /> + </zipfileset> + </zip> + <jar destfile="${distName}.doc.jar"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="docs/**" /> + </zipfileset> + </jar> + </parallel> + <parallel> + <gzip src="${distName}.src.tar" destfile="${distName}.src.tar.gz" /> + <bzip2 src="${distName}.src.tar" destfile="${distName}.src.tar.bz2" /> + <gzip src="${distName}.doc.tar" destfile="${distName}.doc.tar.gz" /> + <bzip2 src="${distName}.doc.tar" destfile="${distName}.doc.tar.bz2" /> + <pack200 + src="${distName}.jar" + destfile="${distName}.pack.gz" + gzipoutput="true" + stripdebug="true" + effort="9" + keepfileorder="false" + modificationtime="latest" + deflatehint="false" + /> + </parallel> + <delete file="${distName}.src.tar" /> + <delete file="${distName}.doc.tar" /> + </target> + + <target + name = "doc" + description = "Creates public javadoc documentation." + > + <mkdir dir="docs/api" /> + <!--copy todir="docs/api" file="src/doc/api/public/copyright.html" /> + <copy todir="docs/api" file="src/doc/api/public/.htaccess" /--> + <javadoc + destdir = "docs/api" + access = "protected" + author = "yes" + version = "yes" + locale = "en_US" + use = "yes" + splitindex = "yes" + windowtitle = "JAPI Library Taglets ${module.version} API documentation" + doctitle = "JAPI<br />Yet another Java API<br />Library Taglets ${module.version} API documentation" + header = "JAPI Library Taglets ${module.version}<br />API Documentation" + footer = "JAPI<br />Yet another Java API<br />Library Taglets ${module.version} API documentation" + bottom = "<div style=" text-align:center;">© 2006 Christian Hujer. All rights reserved. See <a href="{@docRoot}/copyright.html">copyright</a></div>" + serialwarn = "yes" + charset = "utf-8" + docencoding = "utf-8" + encoding = "utf-8" + source = "1.5" + linksource = "yes" + link = "${user.javadoc.link}" + > + <!-- + overview = "src/overview.html" + --> + <classpath> + <fileset dir="lib" includes="*.jar" excludes="LICENSE-*.jar" /> + </classpath> + <sourcepath> + <pathelement path="${user.javadoc.javasrc}" /> + <pathelement path="src" /> + </sourcepath> + <packageset + dir="src" + defaultexcludes="yes" + > + <include name="net/**" /> + </packageset> + <tag enabled="true" name="retval" description="Return Values:" scope="methods" /> + <tag enabled="true" name="pre" description="Preconditions:" scope="methods,constructors" /> + <tag enabled="true" name="post" description="Postconditions:" scope="methods" /> + <tag enabled="true" name="invariant" description="Invariant:" scope="methods,fields" /> + <tag enabled="true" name="note" description="Notes:" /> + <tag enabled="true" name="warning" description="Warnings:" /> + <!--tag enabled="true" name="todo" description="Todo:" /--> + <taglet name="net.sf.japi.taglets.TodoTaglet" path="dist/japi-lib-taglets-0.1.jar" /> + <taglet name="net.sf.japi.taglets.XxxTaglet" path="dist/japi-lib-taglets-0.1.jar" /> + <taglet name="net.sf.japi.taglets.FixmeTaglet" path="dist/japi-lib-taglets-0.1.jar" /> + <!--tag enabled="true" name="fixme" description="Fixme:" /--> + <!--tag enabled="true" name="xxx" description="XXX:" /--> + </javadoc> + </target> +</project> Property changes on: libs/taglets/trunk/build.xml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF Added: libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java 2006-11-20 21:10:28 UTC (rev 197) @@ -0,0 +1,99 @@ +package net.sf.japi.taglets; + +import com.sun.javadoc.Tag; +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + * Base class for Taglets that are simple blocks transforming into lists. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class BlockListTaglet implements Taglet { + + /** The name of this Taglet. */ + private final String name; + + /** The title of this Taglet. */ + private final String title; + + /** + * Create a BLockListTaglet. + * @param name Name of this Taglet (e.g. "todo"). + * @param title Title of this Taglet (e.g. "Todo"). + */ + protected BlockListTaglet(final String name, final String title) { + this.name = name; + this.title = title; + } + + /** {@inheritDoc} */ + public String getName() { + return name; + } + + /** {@inheritDoc} */ + public boolean inConstructor() { + return true; + } + + /** {@inheritDoc} */ + public boolean inField() { + return true; + } + + /** {@inheritDoc} */ + public boolean inMethod() { + return true; + } + + /** {@inheritDoc} */ + public boolean inOverview() { + return true; + } + + /** {@inheritDoc} */ + public boolean inPackage() { + return true; + } + + /** {@inheritDoc} */ + public boolean inType() { + return true; + } + + /** {@inheritDoc} */ + public boolean isInlineTag() { + return false; + } + + /** {@inheritDoc} */ + public String toString(final Tag tag) { + final StringBuilder sb = new StringBuilder(); + sb.append("<DL><DT><B>"); + sb.append(title); + sb.append("</B></DT><DD><UL><LI>"); + sb.append(tag.text()); + sb.append("</LI></UL></DD></DL>"); + return sb.toString(); + } + + /** {@inheritDoc} */ + public String toString(final Tag[] tags) { + if (tags.length == 0) { + return null; + } + final StringBuilder sb = new StringBuilder(); + sb.append("<DL><DT><B>"); + sb.append(title); + sb.append("</B></DT><DD><UL>"); + for (final Tag tag : tags) { + sb.append("<LI>"); + sb.append(tag.text()); + sb.append("</LI>"); + } + sb.append("</UL></DD></DL>"); + return sb.toString(); + } + +} // class BlockListTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/BlockListTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java 2006-11-20 21:10:28 UTC (rev 197) @@ -0,0 +1,27 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + */ +public class FixmeTaglet extends BlockListTaglet { + + /** + * Create an XxxTaglet. + */ + protected FixmeTaglet() { + super("fixme", "Fixme"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map tagletMap) { + final Taglet taglet = new FixmeTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class XxxTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/FixmeTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java 2006-11-20 21:10:28 UTC (rev 197) @@ -0,0 +1,27 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + */ +public class TodoTaglet extends BlockListTaglet { + + /** + * Create an XxxTaglet. + */ + protected TodoTaglet() { + super("todo", "Todo"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map tagletMap) { + final Taglet taglet = new TodoTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class XxxTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/TodoTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java =================================================================== --- libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java (rev 0) +++ libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java 2006-11-20 21:10:28 UTC (rev 197) @@ -0,0 +1,27 @@ +package net.sf.japi.taglets; + +import com.sun.tools.doclets.Taglet; + +import java.util.Map; + +/** + */ +public class XxxTaglet extends BlockListTaglet { + + /** + * Create an XxxTaglet. + */ + protected XxxTaglet() { + super("xxx", "XXX"); + } + + /** + * Register this Taglet. + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map tagletMap) { + final Taglet taglet = new XxxTaglet(); + tagletMap.put(taglet.getName(), taglet); + } + +} // class XxxTaglet Property changes on: libs/taglets/trunk/src/net/sf/japi/taglets/XxxTaglet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-07 19:14:55
|
Revision: 196 http://svn.sourceforge.net/japi/?rev=196&view=rev Author: christianhujer Date: 2006-11-07 11:14:29 -0800 (Tue, 07 Nov 2006) Log Message: ----------- Improvements and bugfixes: Removed version support from BasicCommand (too little value, too often clashes with verbose). Changed ResourceBundle support. Changed Examples to use simpleParseAndRun() instead of parseAndRun(). Modified Paths: -------------- libs/argparser/trunk/argparser.ipr libs/argparser/trunk/src/doc/examples/Cat.java libs/argparser/trunk/src/doc/examples/Head.java libs/argparser/trunk/src/doc/examples/Tail.java libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties Added Paths: ----------- libs/argparser/trunk/src/doc/examples/head.properties libs/argparser/trunk/src/doc/examples/head_de.properties Modified: libs/argparser/trunk/argparser.ipr =================================================================== --- libs/argparser/trunk/argparser.ipr 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/argparser.ipr 2006-11-07 19:14:29 UTC (rev 196) @@ -635,6 +635,7 @@ <component name="ProjectModuleManager"> <modules> <module fileurl="file://$PROJECT_DIR$/argparser.iml" filepath="$PROJECT_DIR$/argparser.iml" /> + <module fileurl="file://$PROJECT_DIR$/argparser-examples.iml" filepath="$PROJECT_DIR$/argparser-examples.iml" /> </modules> </component> <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK"> @@ -650,6 +651,7 @@ </component> <component name="StarteamVcsAdapter" /> <component name="VssVcs" /> + <component name="XSLT-Support.FileAssociationsManager" /> <component name="com.intellij.jsf.UserDefinedFacesConfigs"> <option name="USER_DEFINED_CONFIGS"> <value> Modified: libs/argparser/trunk/src/doc/examples/Cat.java =================================================================== --- libs/argparser/trunk/src/doc/examples/Cat.java 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/src/doc/examples/Cat.java 2006-11-07 19:14:29 UTC (rev 196) @@ -7,10 +7,6 @@ import java.util.List; import net.sf.japi.io.args.ArgParser; import net.sf.japi.io.args.BasicCommand; -import net.sf.japi.io.args.MissingArgumentException; -import net.sf.japi.io.args.RequiredOptionsMissingException; -import net.sf.japi.io.args.TerminalException; -import net.sf.japi.io.args.UnknownOptionException; import org.jetbrains.annotations.NotNull; /** @@ -60,8 +56,8 @@ * Main method. * @param args Command line arguments */ - public static void main(final String... args) throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { - ArgParser.parseAndRun(new Head(), args); + public static void main(final String... args) { + ArgParser.simpleParseAndRun(new Head(), args); } } // class Cat Modified: libs/argparser/trunk/src/doc/examples/Head.java =================================================================== --- libs/argparser/trunk/src/doc/examples/Head.java 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/src/doc/examples/Head.java 2006-11-07 19:14:29 UTC (rev 196) @@ -6,13 +6,10 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; +import java.util.ResourceBundle; import net.sf.japi.io.args.ArgParser; import net.sf.japi.io.args.BasicCommand; -import net.sf.japi.io.args.MissingArgumentException; import net.sf.japi.io.args.Option; -import net.sf.japi.io.args.RequiredOptionsMissingException; -import net.sf.japi.io.args.TerminalException; -import net.sf.japi.io.args.UnknownOptionException; import org.jetbrains.annotations.NotNull; /** @@ -21,6 +18,9 @@ */ public class Head extends BasicCommand { + /** The ResourceBundle for locale-specific output. */ + private final ResourceBundle resourceBundle = ResourceBundle.getBundle("examples.head"); + /** The number of items to print. */ private int numItems = 10; @@ -128,8 +128,13 @@ * Main method. * @param args Command line arguments */ - public static void main(final String... args) throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { - ArgParser.parseAndRun(new Head(), args); + public static void main(final String... args) { + ArgParser.simpleParseAndRun(new Head(), args); } + /** {@inheritDoc} */ + @Override public ResourceBundle getBundle() { + return resourceBundle; + } + } // class Head Modified: libs/argparser/trunk/src/doc/examples/Tail.java =================================================================== --- libs/argparser/trunk/src/doc/examples/Tail.java 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/src/doc/examples/Tail.java 2006-11-07 19:14:29 UTC (rev 196) @@ -9,11 +9,7 @@ import java.util.List; import net.sf.japi.io.args.ArgParser; import net.sf.japi.io.args.BasicCommand; -import net.sf.japi.io.args.MissingArgumentException; import net.sf.japi.io.args.Option; -import net.sf.japi.io.args.RequiredOptionsMissingException; -import net.sf.japi.io.args.TerminalException; -import net.sf.japi.io.args.UnknownOptionException; import org.jetbrains.annotations.NotNull; /** @@ -136,8 +132,8 @@ * Main method. * @param args Command line arguments */ - public static void main(final String... args) throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { - ArgParser.parseAndRun(new Head(), args); + public static void main(final String... args) { + ArgParser.simpleParseAndRun(new Head(), args); } } // class Tail Added: libs/argparser/trunk/src/doc/examples/head.properties =================================================================== --- libs/argparser/trunk/src/doc/examples/head.properties (rev 0) +++ libs/argparser/trunk/src/doc/examples/head.properties 2006-11-07 19:14:29 UTC (rev 196) @@ -0,0 +1,10 @@ +net.sf.japi.io.args.OptionType.REQUIRED=required +net.sf.japi.io.args.OptionType.OPTIONAL=optional +net.sf.japi.io.args.OptionType.TERMINAL=terminal +help=Display this help and exit. +setExiting=Quit Java VM with error code. +setNotExiting=Don't quit Java VM (default). +setBytes=Print the first N bytes of each file. +setLines=Print the first N lines of each file (default: 10). +setQuiet=Never print headers giving file names. +setVerbose=Always print headers giving file names. Property changes on: libs/argparser/trunk/src/doc/examples/head.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/doc/examples/head_de.properties =================================================================== --- libs/argparser/trunk/src/doc/examples/head_de.properties (rev 0) +++ libs/argparser/trunk/src/doc/examples/head_de.properties 2006-11-07 19:14:29 UTC (rev 196) @@ -0,0 +1,10 @@ +net.sf.japi.io.args.OptionType.REQUIRED=erforderlich +net.sf.japi.io.args.OptionType.OPTIONAL=optional +net.sf.japi.io.args.OptionType.TERMINAL=abbrechend +help=Diese Hilfe anzeigen und beenden. +setExiting=Java VM mit Fehlercode beenden +setNotExiting=Java VM nicht beenden (Voreinstellung). +setBytes=Die ersten N Bytes jeder Datei ausgeben. +setLines=Die ersten N Zeilen jeder Datei ausgeben (Voreinstellung: 10). +setQuiet=Niemals Dateinamen vorab ausgeben. +setVerbose=Immer Dateinamen vorab ausgeben. Property changes on: libs/argparser/trunk/src/doc/examples/head_de.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-11-07 19:14:29 UTC (rev 196) @@ -1,10 +1,16 @@ package net.sf.japi.io.args; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Formatter; +import java.util.HashSet; +import java.util.List; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.Set; /** - * BasicCommand is a base class for commands that provides the options --help and --version. + * BasicCommand is a base class for commands that provides the options --help, --exit and --noexit. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public abstract class BasicCommand implements Command { @@ -27,12 +33,6 @@ maxOptionTypeWidth = tmpMaxOptionTypeWidth; } - /** Version Option. */ - @Option(type = OptionType.TERMINAL, names = {"v", "version"}) - public void version() { - // TODO - } - /** Exit Option. */ @Option(names = {"exit"}) public void setExiting() { @@ -106,6 +106,7 @@ /** * Get the ResourceBundle for the default locale. * If you override this method be sure to declare the bundle returned by the overridden method as parent of your bundle. + * @return ResourceBundle for default locale. */ public ResourceBundle getBundle() { return resourceBundle; Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2006-11-07 19:14:29 UTC (rev 196) @@ -2,4 +2,5 @@ net.sf.japi.io.args.OptionType.OPTIONAL=optional net.sf.japi.io.args.OptionType.TERMINAL=terminal help=Display this help and exit. -version=Display version information and exit. \ No newline at end of file +setExiting=Quit Java VM with error code. +setNotExiting=Don't quit Java VM (default). Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2006-11-06 22:29:50 UTC (rev 195) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2006-11-07 19:14:29 UTC (rev 196) @@ -2,4 +2,5 @@ net.sf.japi.io.args.OptionType.OPTIONAL=optional net.sf.japi.io.args.OptionType.TERMINAL=abbrechend help=Diese Hilfe anzeigen und beenden. -version=Versionsinformation anzeigen und beenden. \ No newline at end of file +setExiting=Java VM mit Fehlercode beenden +setNotExiting=Java VM nicht beenden (Voreinstellung). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 22:30:01
|
Revision: 195 http://svn.sourceforge.net/japi/?rev=195&view=rev Author: christianhujer Date: 2006-11-06 14:29:50 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Added some examples. Added Paths: ----------- libs/argparser/trunk/src/doc/ libs/argparser/trunk/src/doc/examples/ libs/argparser/trunk/src/doc/examples/Cat.java libs/argparser/trunk/src/doc/examples/Head.java libs/argparser/trunk/src/doc/examples/Tail.java Added: libs/argparser/trunk/src/doc/examples/Cat.java =================================================================== --- libs/argparser/trunk/src/doc/examples/Cat.java (rev 0) +++ libs/argparser/trunk/src/doc/examples/Cat.java 2006-11-06 22:29:50 UTC (rev 195) @@ -0,0 +1,67 @@ +package examples; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.BasicCommand; +import net.sf.japi.io.args.MissingArgumentException; +import net.sf.japi.io.args.RequiredOptionsMissingException; +import net.sf.japi.io.args.TerminalException; +import net.sf.japi.io.args.UnknownOptionException; +import org.jetbrains.annotations.NotNull; + +/** + * Java implementation of the UNIX command <q>cat</q> to demonstrate how to use the argparser library. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Cat extends BasicCommand { + + /** {@inheritDoc} */ + @SuppressWarnings({"InstanceMethodNamingConvention"}) + public int run(@NotNull final List<String> args) throws Exception { + int returnCode = 0; + if (args.size() == 0) { + copy(System.in, System.out); + } else { + for (final String arg : args) { + try { + final InputStream in = new FileInputStream(arg); + try { + copy(in, System.out); + } finally { + in.close(); + } + } catch (final IOException e) { + returnCode = 1; + System.err.println(e); + } + } + } + return returnCode; + } + + /** + * Copies data from one input stream to another. + * @param in InputStream to read from. + * @param out InputStream to write to. + * @throws IOException in case of I/O problems. + */ + private void copy(final InputStream in, final OutputStream out) throws IOException { + final byte[] buf = new byte[4096]; + for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { + out.write(buf, 0, bytesRead); + } + } + + /** + * Main method. + * @param args Command line arguments + */ + public static void main(final String... args) throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { + ArgParser.parseAndRun(new Head(), args); + } + +} // class Cat Property changes on: libs/argparser/trunk/src/doc/examples/Cat.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/doc/examples/Head.java =================================================================== --- libs/argparser/trunk/src/doc/examples/Head.java (rev 0) +++ libs/argparser/trunk/src/doc/examples/Head.java 2006-11-06 22:29:50 UTC (rev 195) @@ -0,0 +1,135 @@ +package examples; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; +import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.BasicCommand; +import net.sf.japi.io.args.MissingArgumentException; +import net.sf.japi.io.args.Option; +import net.sf.japi.io.args.RequiredOptionsMissingException; +import net.sf.japi.io.args.TerminalException; +import net.sf.japi.io.args.UnknownOptionException; +import org.jetbrains.annotations.NotNull; + +/** + * Java implementation of the UNIX command <q>head</q> to demonstrate how to use the argparser library. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Head extends BasicCommand { + + /** The number of items to print. */ + private int numItems = 10; + + /** + * The kind of items to print. + * <code>false</code>: print lines. + * <code>true</code>: print bytes. + */ + private boolean printBytes; + + /** + * Quiety / Verbosity. + * 0 = never print filenames. + * 1 = print filenames if more than one file. + * 2 = always print filenames. + */ + private int verbose = 1; + + /** + * Sets the number of lines to print. + * @param lines number of lines to print + */ + @Option(names = {"n", "lines"}) + public void setLines(final String lines) { + numItems = Integer.parseInt(lines); + printBytes = false; + } + + /** + * Sets the number of bytes to print. + * @param bytes number of bytes to print. + */ + @Option(names = {"c", "bytes"}) + public void setBytes(final String bytes) { + numItems = Integer.parseInt(bytes); + printBytes = true; + } + + /** + * Sets the command to be quiet. + */ + @Option(names = {"q", "quiet", "silent"}) + public void setQuiet() { + verbose = 0; + } + + /** + * Sets the command to be verbose. + */ + @Option(names = {"v", "verbose"}) + public void setVerbose() { + verbose = 2; + } + + /** + * {@inheritDoc} + */ + public int run(@NotNull final List<String> args) throws IOException { + int returnCode = 0; + if (args.size() == 0) { + if (verbose == 2) { + System.out.println("==> STDIN <=="); + } + copyItems(System.in); + } else { + for (final String arg : args) { + if (verbose == 2 || verbose == 1 && args.size() > 1) { + System.out.println("==> " + arg + " <=="); + } + try { + final InputStream in = new FileInputStream(arg); + try { + copyItems(in); + } finally { + in.close(); + } + } catch (final IOException e) { + System.err.println(e); + returnCode = 1; + } + } + } + return returnCode; + } + + /** + * Copies the configured number of items from the specified InputStream to System.out. + * @param in InputStream to run on + */ + private void copyItems(final InputStream in) throws IOException { + if (printBytes) { + for (int i = 0, b; i < numItems && (b = in.read()) != -1; i++) { + System.out.write(b); + } + } else { + BufferedReader lin = new BufferedReader(new InputStreamReader(in)); + String line; + for (int i = 0; i < numItems && (line = lin.readLine()) != null; i++) { + System.out.println(line); + } + } + } + + /** + * Main method. + * @param args Command line arguments + */ + public static void main(final String... args) throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { + ArgParser.parseAndRun(new Head(), args); + } + +} // class Head Property changes on: libs/argparser/trunk/src/doc/examples/Head.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/doc/examples/Tail.java =================================================================== --- libs/argparser/trunk/src/doc/examples/Tail.java (rev 0) +++ libs/argparser/trunk/src/doc/examples/Tail.java 2006-11-06 22:29:50 UTC (rev 195) @@ -0,0 +1,143 @@ +package examples; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; +import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.BasicCommand; +import net.sf.japi.io.args.MissingArgumentException; +import net.sf.japi.io.args.Option; +import net.sf.japi.io.args.RequiredOptionsMissingException; +import net.sf.japi.io.args.TerminalException; +import net.sf.japi.io.args.UnknownOptionException; +import org.jetbrains.annotations.NotNull; + +/** + * Java implementation of the UNIX command <q>tail</q> to demonstrate how to use the argparser library. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Tail extends BasicCommand { + + /** The number of items to print. */ + private int numItems = 10; + + /** + * The kind of items to print. + * <code>false</code>: print lines. + * <code>true</code>: print bytes. + */ + private boolean printBytes; + + /** + * Quiety / Verbosity. + * 0 = never print filenames. + * 1 = print filenames if more than one file. + * 2 = always print filenames. + */ + private int verbose = 1; + + /** + * Sets the number of lines to print. + * @param lines number of lines to print + */ + @Option(names = {"n", "lines"}) + public void setLines(final String lines) { + numItems = Integer.parseInt(lines); + printBytes = false; + } + + /** + * Sets the number of bytes to print. + * @param bytes number of bytes to print. + */ + @Option(names = {"c", "bytes"}) + public void setBytes(final String bytes) { + numItems = Integer.parseInt(bytes); + printBytes = true; + } + + /** + * Sets the command to be quiet. + */ + @Option(names = {"q", "quiet", "silent"}) + public void setQuiet() { + verbose = 0; + } + + /** + * Sets the command to be verbose. + */ + @Option(names = {"v", "verbose"}) + public void setVerbose() { + verbose = 2; + } + + /** {@inheritDoc} */ + @SuppressWarnings({"InstanceMethodNamingConvention"}) + public int run(@NotNull List<String> args) throws Exception { + int returnCode = 0; + for (final String arg : args) { + try { + final InputStream in = new BufferedInputStream(new FileInputStream(arg)); + try { + copy(in); + } finally { + in.close(); + } + } catch (final IOException e) { + returnCode = 1; + System.err.println(e); + } + } + return returnCode; + } + + private void copy(final InputStream in) throws IOException { + if (printBytes) { + copyBytes(in); + } else { + copyLines(in); + } + } + private void copyBytes(final InputStream in) throws IOException { + final InputStream lin = in instanceof BufferedInputStream ? in : new BufferedInputStream(in); + final byte[] buf = new byte[numItems]; + int bytesRead; + int loop = 0; + while ((bytesRead = lin.read(buf)) != -1) { + loop++; + } + if (loop >= 2) { + System.out.write(buf, bytesRead, buf.length - bytesRead); + } + System.out.write(buf, 0, bytesRead); + } + + private void copyLines(final InputStream in) throws IOException { + final String[] buf = new String[numItems]; + final BufferedReader lin = new BufferedReader(new InputStreamReader(in)); + int num = 0; + while ((buf[num++ % numItems] = lin.readLine()) != null); + if (num >= numItems) { + for (int i = num % numItems; i < numItems; i++) { + System.out.println(buf[i]); + } + } + for (int i = 0; i < num % numItems; i++) { + System.out.println(buf[i]); + } + } + + /** + * Main method. + * @param args Command line arguments + */ + public static void main(final String... args) throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { + ArgParser.parseAndRun(new Head(), args); + } + +} // class Tail Property changes on: libs/argparser/trunk/src/doc/examples/Tail.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 22:28:16
|
Revision: 194 http://svn.sourceforge.net/japi/?rev=194&view=rev Author: christianhujer Date: 2006-11-06 14:27:57 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Added isExiting and changed run() signature of Command. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/net/sf/japi/io/args/Command.java libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-11-06 22:26:24 UTC (rev 193) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2006-11-06 22:27:57 UTC (rev 194) @@ -29,8 +29,7 @@ * Parser for command line arguments. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * TODO: automatic argument conversion for option method invocation. - * TODO: Handling of --help - * TODO: Handling of --version + * TODO: better handling of boolean arguments * TODO: Handling of - for STDIN as input argument filestream * TODO: Support for I18N/L10N */ @@ -71,7 +70,16 @@ argIterator = argList.listIterator(); parse(); checkRequiredMethods(); - command.run(argList); + int returnCode = 0; + try { + returnCode = command.run(argList); + } catch (final Exception e) { + System.err.println(e); + returnCode = 1; + } + if (command.isExiting()) { + System.exit(returnCode); + } } /** Modified: libs/argparser/trunk/src/net/sf/japi/io/args/Command.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2006-11-06 22:26:24 UTC (rev 193) +++ libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2006-11-06 22:27:57 UTC (rev 194) @@ -34,8 +34,16 @@ * Run this command. * This method is invoked by {@link ArgParser} once it is finnished with parsing the arguments. * @param args the argument strings that were not parsed away by {@link ArgParser}. + * @return return code suitable for passing to {@link System#exit(int)} (whether {@link System#exit(int)} is really invoked depends on the configuration of the {@link ArgParser}.) + * @throws Exception in case of problems during command execution. */ @SuppressWarnings({"InstanceMethodNamingConvention"}) - void run(@NotNull List<String> args); + int run(@NotNull List<String> args) throws Exception; + /** + * Return whether after running this Command, {@link System#exit(int)} should be invoked. + * @return <code>true</code> if {@link ArgParser} should invoke {@link System#exit(int)} after this command, otherwise <code>false</code>. + */ + boolean isExiting(); + } // interface Command Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2006-11-06 22:26:24 UTC (rev 193) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2006-11-06 22:27:57 UTC (rev 194) @@ -35,9 +35,10 @@ /** {@inheritDoc} */ @SuppressWarnings({"InstanceMethodNamingConvention"}) - public void run(final List<String> args) { + public int run(final List<String> args) { runCalled = true; this.args = args; + return 0; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 22:26:33
|
Revision: 193 http://svn.sourceforge.net/japi/?rev=193&view=rev Author: christianhujer Date: 2006-11-06 14:26:24 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Added exit option to BasicCommand. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-10-30 10:57:59 UTC (rev 192) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2006-11-06 22:26:24 UTC (rev 193) @@ -1,13 +1,7 @@ package net.sf.japi.io.args; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Formatter; -import java.util.HashSet; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Set; +import java.util.*; /** * BasicCommand is a base class for commands that provides the options --help and --version. @@ -21,6 +15,9 @@ /** The maximum width of the option type field. */ private final int maxOptionTypeWidth; + /** @see Command#isExiting() */ + private boolean exiting; + /** Create a BasicCommand. */ protected BasicCommand() { int tmpMaxOptionTypeWidth = 0; @@ -36,6 +33,23 @@ // TODO } + /** Exit Option. */ + @Option(names = {"exit"}) + public void setExiting() { + exiting = true; + } + + /** No Exit Option. */ + @Option(names = {"noexit"}) + public void setNotExiting() { + exiting = false; + } + + /** {@inheritDoc} */ + public boolean isExiting() { + return exiting; + } + /** Help Option. */ @Option(type = OptionType.TERMINAL, names = {"h", "help"}) public void help() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-30 10:58:05
|
Revision: 192 http://svn.sourceforge.net/japi/?rev=192&view=rev Author: christianhujer Date: 2006-10-30 02:57:59 -0800 (Mon, 30 Oct 2006) Log Message: ----------- Changed source folder to be more specific. Modified Paths: -------------- libs/argparser/trunk/argparser.iml Modified: libs/argparser/trunk/argparser.iml =================================================================== --- libs/argparser/trunk/argparser.iml 2006-10-30 09:25:24 UTC (rev 191) +++ libs/argparser/trunk/argparser.iml 2006-10-30 10:57:59 UTC (rev 192) @@ -5,7 +5,7 @@ <component name="NewModuleRootManager" inherit-compiler-output="true"> <exclude-output /> <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/net" isTestSource="false" packagePrefix="net" /> <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" packagePrefix="test" /> </content> <orderEntry type="inheritedJdk" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-30 09:25:46
|
Revision: 191 http://svn.sourceforge.net/japi/?rev=191&view=rev Author: christianhujer Date: 2006-10-30 01:25:24 -0800 (Mon, 30 Oct 2006) Log Message: ----------- Added IntelliJ IDEA project files. Added Paths: ----------- libs/argparser/trunk/argparser.iml libs/argparser/trunk/argparser.ipr Added: libs/argparser/trunk/argparser.iml =================================================================== --- libs/argparser/trunk/argparser.iml (rev 0) +++ libs/argparser/trunk/argparser.iml 2006-10-30 09:25:24 UTC (rev 191) @@ -0,0 +1,191 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module version="4" relativePaths="true" type="JAVA_MODULE"> + <component name="DependecySynchronizer" /> + <component name="ModuleRootManager" /> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" packagePrefix="test" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="annotations" level="project" /> + <orderEntry type="library" name="junit" level="project" /> + <orderEntryProperties /> + </component> + <component name="copyright"> + <Base> + <setting name="state" value="2" /> + </Base> + <LanguageOptions name="$TEMPLATE$"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="4" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="CSS"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="HTML"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JAVA"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JSP"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JavaScript"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="Properties"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="XML"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + </component> +</module> + Property changes on: libs/argparser/trunk/argparser.iml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF Added: libs/argparser/trunk/argparser.ipr =================================================================== --- libs/argparser/trunk/argparser.ipr (rev 0) +++ libs/argparser/trunk/argparser.ipr 2006-10-30 09:25:24 UTC (rev 191) @@ -0,0 +1,697 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4" relativePaths="false"> + <component name="AntConfiguration"> + <defaultAnt bundledAnt="true" /> + </component> + <component name="BuildJarProjectSettings"> + <option name="BUILD_JARS_ON_MAKE" value="false" /> + </component> + <component name="CodeStyleProjectProfileManger"> + <option name="PROJECT_PROFILE" /> + <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" /> + </component> + <component name="CodeStyleSettingsManager"> + <option name="PER_PROJECT_SETTINGS" /> + <option name="USE_PER_PROJECT_SETTINGS" value="false" /> + </component> + <component name="CompilerConfiguration"> + <option name="DEFAULT_COMPILER" value="Javac" /> + <option name="DEPLOY_AFTER_MAKE" value="0" /> + <resourceExtensions> + <entry name=".+\.(properties|xml|html|dtd|tld)" /> + <entry name=".+\.(gif|png|jpeg|jpg)" /> + </resourceExtensions> + <wildcardResourcePatterns> + <entry name="?*.properties" /> + <entry name="?*.xml" /> + <entry name="?*.gif" /> + <entry name="?*.png" /> + <entry name="?*.jpeg" /> + <entry name="?*.jpg" /> + <entry name="?*.html" /> + <entry name="?*.dtd" /> + <entry name="?*.tld" /> + <entry name="?*.properties" /> + <entry name="?*.xml" /> + <entry name="?*.html" /> + <entry name="?*.dtd" /> + <entry name="?*.tld" /> + <entry name="?*.gif" /> + <entry name="?*.png" /> + <entry name="?*.jpeg" /> + <entry name="?*.jpg" /> + </wildcardResourcePatterns> + </component> + <component name="DataSourceManagerImpl" /> + <component name="DependenciesAnalyzeManager"> + <option name="myForwardDirection" value="false" /> + </component> + <component name="DependencyValidationManager" /> + <component name="EclipseCompilerSettings"> + <option name="DEBUGGING_INFO" value="true" /> + <option name="GENERATE_NO_WARNINGS" value="true" /> + <option name="DEPRECATION" value="false" /> + <option name="ADDITIONAL_OPTIONS_STRING" value="" /> + <option name="MAXIMUM_HEAP_SIZE" value="128" /> + </component> + <component name="EclipseEmbeddedCompilerSettings"> + <option name="DEBUGGING_INFO" value="true" /> + <option name="GENERATE_NO_WARNINGS" value="true" /> + <option name="DEPRECATION" value="false" /> + <option name="ADDITIONAL_OPTIONS_STRING" value="" /> + <option name="MAXIMUM_HEAP_SIZE" value="128" /> + </component> + <component name="EntryPointsManager"> + <entry_points /> + </component> + <component name="ExportToHTMLSettings"> + <option name="PRINT_LINE_NUMBERS" value="false" /> + <option name="OPEN_IN_BROWSER" value="false" /> + <option name="OUTPUT_DIRECTORY" /> + </component> + <component name="GUI Designer component loader factory" /> + <component name="IdProvider" IDEtalkID="ED349DBC49AC650043B9D99F1B6300AE" /> + <component name="InspectionProjectProfileManager"> + <option name="PROJECT_PROFILE" value="Project Default" /> + <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" /> + <scopes /> + <profiles> + <profile version="1.0" is_locked="false"> + <option name="myName" value="Project Default" /> + <option name="myLocal" value="false" /> + <used_levels> + <error> + <option name="myName" value="ERROR" /> + <option name="myVal" value="400" /> + </error> + <warning> + <option name="myName" value="WARNING" /> + <option name="myVal" value="300" /> + </warning> + <information> + <option name="myName" value="INFO" /> + <option name="myVal" value="200" /> + </information> + <server> + <option name="myName" value="SERVER PROBLEM" /> + <option name="myVal" value="100" /> + </server> + </used_levels> + <inspection_tool class="InstanceofChain" level="WARNING" enabled="true" /> + <inspection_tool class="ClassReferencesSubclass" level="WARNING" enabled="true" /> + <inspection_tool class="DeclareCollectionAsInterface" level="WARNING" enabled="true"> + <option name="ignoreLocalVariables" value="false" /> + <option name="ignorePrivateMethodsAndFields" value="false" /> + </inspection_tool> + <inspection_tool class="FeatureEnvy" level="WARNING" enabled="true" /> + <inspection_tool class="InstanceofThis" level="WARNING" enabled="true" /> + <inspection_tool class="MagicNumber" level="WARNING" enabled="true"> + <option name="m_ignoreInHashCode" value="true" /> + </inspection_tool> + <inspection_tool class="OverlyStrongTypeCast" level="WARNING" enabled="true" /> + <inspection_tool class="MethodOnlyUsedFromInnerClass" level="WARNING" enabled="true"> + <option name="ignoreMethodsAccessedFromAnonymousClass" value="false" /> + </inspection_tool> + <inspection_tool class="StaticMethodOnlyUsedInOneClass" level="WARNING" enabled="true" /> + <inspection_tool class="ReplaceAssignmentWithOperatorAssignment" level="WARNING" enabled="true"> + <option name="ignoreLazyOperators" value="true" /> + <option name="ignoreObscureOperators" value="false" /> + </inspection_tool> + <inspection_tool class="AssignmentToForLoopParameter" level="WARNING" enabled="true"> + <option name="m_checkForeachParameters" value="false" /> + </inspection_tool> + <inspection_tool class="AssignmentToCatchBlockParameter" level="WARNING" enabled="true" /> + <inspection_tool class="AssignmentToMethodParameter" level="WARNING" enabled="true"> + <option name="ignoreTransformationOfOriginalParameter" value="false" /> + </inspection_tool> + <inspection_tool class="NestedAssignment" level="WARNING" enabled="true" /> + <inspection_tool class="IncrementDecrementUsedAsExpression" level="WARNING" enabled="true" /> + <inspection_tool class="AnonymousClassMethodCount" level="WARNING" enabled="true"> + <option name="m_limit" value="1" /> + </inspection_tool> + <inspection_tool class="ClassInheritanceDepth" level="WARNING" enabled="true"> + <option name="m_limit" value="2" /> + </inspection_tool> + <inspection_tool class="ConstructorCount" level="WARNING" enabled="true"> + <option name="m_limit" value="5" /> + </inspection_tool> + <inspection_tool class="FieldCount" level="WARNING" enabled="true"> + <option name="m_countConstantFields" value="false" /> + <option name="m_considerStaticFinalFieldsConstant" value="false" /> + <option name="m_limit" value="10" /> + </inspection_tool> + <inspection_tool class="MethodCount" level="WARNING" enabled="true"> + <option name="m_limit" value="20" /> + </inspection_tool> + <inspection_tool class="ClassNestingDepth" level="WARNING" enabled="true"> + <option name="m_limit" value="1" /> + </inspection_tool> + <inspection_tool class="AnonymousClassComplexity" level="WARNING" enabled="true"> + <option name="m_limit" value="3" /> + </inspection_tool> + <inspection_tool class="ClassComplexity" level="WARNING" enabled="true"> + <option name="m_limit" value="80" /> + </inspection_tool> + <inspection_tool class="ClassCoupling" level="WARNING" enabled="true"> + <option name="m_includeJavaClasses" value="false" /> + <option name="m_includeLibraryClasses" value="false" /> + <option name="m_limit" value="15" /> + </inspection_tool> + <inspection_tool class="ThrowablePrintStackTrace" level="WARNING" enabled="true" /> + <inspection_tool class="ThreadDumpStack" level="WARNING" enabled="true" /> + <inspection_tool class="ObsoleteCollection" level="WARNING" enabled="true" /> + <inspection_tool class="SystemOutErr" level="WARNING" enabled="true" /> + <inspection_tool class="UseOfAnotherObjectsPrivateField" level="WARNING" enabled="true" /> + <inspection_tool class="AssignmentToCollectionFieldFromParameter" level="WARNING" enabled="true"> + <option name="ignorePrivateMethods" value="true" /> + </inspection_tool> + <inspection_tool class="AssignmentToDateFieldFromParameter" level="WARNING" enabled="true"> + <option name="ignorePrivateMethods" value="true" /> + </inspection_tool> + <inspection_tool class="PackageVisibleField" level="WARNING" enabled="true" /> + <inspection_tool class="PackageVisibleInnerClass" level="WARNING" enabled="true" /> + <inspection_tool class="ProtectedField" level="WARNING" enabled="true" /> + <inspection_tool class="ProtectedInnerClass" level="WARNING" enabled="true" /> + <inspection_tool class="PublicField" level="WARNING" enabled="true" /> + <inspection_tool class="PublicInnerClass" level="WARNING" enabled="true" /> + <inspection_tool class="ReturnOfCollectionField" level="WARNING" enabled="true"> + <option name="ignorePrivateMethods" value="true" /> + </inspection_tool> + <inspection_tool class="ReturnOfDateField" level="WARNING" enabled="true" /> + <inspection_tool class="OnDemandImport" level="WARNING" enabled="true" /> + <inspection_tool class="SamePackageImport" level="WARNING" enabled="true" /> + <inspection_tool class="JavaLangImport" level="WARNING" enabled="true" /> + <inspection_tool class="RedundantImport" level="WARNING" enabled="true" /> + <inspection_tool class="UnusedImport" level="WARNING" enabled="true" /> + <inspection_tool class="AbstractMethodCallInConstructor" level="WARNING" enabled="true" /> + <inspection_tool class="InstanceVariableUninitializedUse" level="WARNING" enabled="true"> + <option name="m_ignorePrimitives" value="false" /> + </inspection_tool> + <inspection_tool class="NonFinalStaticVariableUsedInClassInitialization" level="WARNING" enabled="true" /> + <inspection_tool class="OverridableMethodCallInConstructor" level="WARNING" enabled="true" /> + <inspection_tool class="OverriddenMethodCallInConstructor" level="WARNING" enabled="true" /> + <inspection_tool class="StaticVariableInitialization" level="WARNING" enabled="true"> + <option name="m_ignorePrimitives" value="false" /> + </inspection_tool> + <inspection_tool class="StaticVariableUninitializedUse" level="WARNING" enabled="true"> + <option name="m_ignorePrimitives" value="false" /> + </inspection_tool> + <inspection_tool class="ThisEscapedInConstructor" level="WARNING" enabled="true" /> + <inspection_tool class="NonThreadSafeLazyInitialization" level="WARNING" enabled="true" /> + <inspection_tool class="AssertAsName" level="WARNING" enabled="true" /> + <inspection_tool class="EnumAsName" level="WARNING" enabled="true" /> + <inspection_tool class="ClassWithoutConstructor" level="WARNING" enabled="true" /> + <inspection_tool class="FieldHasSetterButNoGetter" level="WARNING" enabled="true" /> + <inspection_tool class="JUnitAbstractTestClassNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][A-Za-z\d]*TestCase" /> + <option name="m_minLength" value="12" /> + <option name="m_maxLength" value="64" /> + </inspection_tool> + <inspection_tool class="TestCaseWithNoTestMethods" level="WARNING" enabled="true" /> + <inspection_tool class="JUnitTestClassNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][A-Za-z\d]*Test" /> + <option name="m_minLength" value="8" /> + <option name="m_maxLength" value="64" /> + </inspection_tool> + <inspection_tool class="TestMethodWithoutAssertion" level="WARNING" enabled="true" /> + <inspection_tool class="TestCaseInProductCode" level="WARNING" enabled="true" /> + <inspection_tool class="TestCaseWithConstructor" level="WARNING" enabled="true" /> + <inspection_tool class="BeforeOrAfterIsPublicVoidNoArg" level="WARNING" enabled="true" /> + <inspection_tool class="BeforeClassOrAfterClassIsPublicStaticVoidNoArg" level="WARNING" enabled="true" /> + <inspection_tool class="AssertsWithoutMessages" level="WARNING" enabled="true" /> + <inspection_tool class="MisorderedAssertEqualsParameters" level="WARNING" enabled="true" /> + <inspection_tool class="SetupCallsSuperSetup" level="WARNING" enabled="true" /> + <inspection_tool class="MisspelledSetUp" level="WARNING" enabled="true" /> + <inspection_tool class="SetupIsPublicVoidNoArg" level="WARNING" enabled="true" /> + <inspection_tool class="SimplifiableJUnitAssertion" level="WARNING" enabled="true" /> + <inspection_tool class="StaticSuite" level="WARNING" enabled="true" /> + <inspection_tool class="TeardownCallsSuperTeardown" level="WARNING" enabled="true" /> + <inspection_tool class="MisspelledTearDown" level="WARNING" enabled="true" /> + <inspection_tool class="TeardownIsPublicVoidNoArg" level="WARNING" enabled="true" /> + <inspection_tool class="TestMethodIsPublicVoidNoArg" level="WARNING" enabled="true" /> + <inspection_tool class="TestMethodInProductCode" level="WARNING" enabled="true" /> + <inspection_tool class="UnconstructableTestCase" level="WARNING" enabled="true" /> + <inspection_tool class="ClassWithMultipleLoggers" level="WARNING" enabled="true"> + <option name="loggerClassName" value="java.util.logging.Logger" /> + </inspection_tool> + <inspection_tool class="NonStaticFinalLogger" level="WARNING" enabled="true"> + <option name="loggerClassName" value="java.util.logging.Logger" /> + </inspection_tool> + <inspection_tool class="SystemGC" level="WARNING" enabled="true" /> + <inspection_tool class="StaticCollection" level="WARNING" enabled="true"> + <option name="m_ignoreWeakCollections" value="false" /> + </inspection_tool> + <inspection_tool class="StringBufferField" level="WARNING" enabled="true" /> + <inspection_tool class="ZeroLengthArrayInitialization" level="WARNING" enabled="true" /> + <inspection_tool class="ThreeNegationsPerMethod" level="WARNING" enabled="true"> + <option name="m_ignoreInEquals" value="true" /> + </inspection_tool> + <inspection_tool class="MethodWithMultipleLoops" level="WARNING" enabled="true" /> + <inspection_tool class="MultipleReturnPointsPerMethod" level="WARNING" enabled="true"> + <option name="m_limit" value="1" /> + </inspection_tool> + <inspection_tool class="ThrownExceptionsPerMethod" level="WARNING" enabled="true"> + <option name="m_limit" value="3" /> + </inspection_tool> + <inspection_tool class="ParametersPerMethod" level="WARNING" enabled="true"> + <option name="m_limit" value="5" /> + </inspection_tool> + <inspection_tool class="CyclomaticComplexity" level="WARNING" enabled="true"> + <option name="m_limit" value="10" /> + </inspection_tool> + <inspection_tool class="MethodCoupling" level="WARNING" enabled="true"> + <option name="m_includeJavaClasses" value="false" /> + <option name="m_includeLibraryClasses" value="false" /> + <option name="m_limit" value="10" /> + </inspection_tool> + <inspection_tool class="NonCommentSourceStatements" level="WARNING" enabled="true"> + <option name="m_limit" value="30" /> + </inspection_tool> + <inspection_tool class="NestingDepth" level="WARNING" enabled="true"> + <option name="m_limit" value="5" /> + </inspection_tool> + <inspection_tool class="AnnotationNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][A-Za-z\d]*" /> + <option name="m_minLength" value="8" /> + <option name="m_maxLength" value="64" /> + </inspection_tool> + <inspection_tool class="BooleanMethodNameMustStartWithQuestion" level="WARNING" enabled="true"> + <option name="nameCheckString" value="is,can,has,should,could,will,shall,check,contains,equals,add,put,remove,startsWith,endsWith" /> + </inspection_tool> + <inspection_tool class="ClassNameSameAsAncestorName" level="WARNING" enabled="true" /> + <inspection_tool class="ClassNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][A-Za-z\d]*" /> + <option name="m_minLength" value="8" /> + <option name="m_maxLength" value="64" /> + </inspection_tool> + <inspection_tool class="ConfusingMainMethod" level="WARNING" enabled="true" /> + <inspection_tool class="ConstantNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z_\d]*" /> + <option name="m_minLength" value="5" /> + <option name="m_maxLength" value="32" /> + </inspection_tool> + <inspection_tool class="EnumeratedClassNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][A-Za-z\d]*" /> + <option name="m_minLength" value="4" /> + <option name="m_maxLength" value="64" /> + </inspection_tool> + <inspection_tool class="EnumeratedConstantNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][_A-Za-z\d]*" /> + <option name="m_minLength" value="5" /> + <option name="m_maxLength" value="32" /> + </inspection_tool> + <inspection_tool class="ExceptionNameDoesntEndWithException" level="WARNING" enabled="true" /> + <inspection_tool class="InstanceMethodNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[a-z][A-Za-z\d]*" /> + <option name="m_minLength" value="4" /> + <option name="m_maxLength" value="32" /> + </inspection_tool> + <inspection_tool class="InstanceVariableNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[a-z][A-Za-z\d]*" /> + <option name="m_minLength" value="5" /> + <option name="m_maxLength" value="32" /> + </inspection_tool> + <inspection_tool class="InterfaceNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z][A-Za-z\d]*" /> + <option name="m_minLength" value="4" /> + <option name="m_maxLength" value="64" /> + </inspection_tool> + <inspection_tool class="LocalVariableNamingConvention" level="WARNING" enabled="true"> + <option name="m_ignoreForLoopParameters" value="false" /> + <option name="m_ignoreCatchParameters" value="false" /> + <option name="m_regex" value="[a-z][A-Za-z\d]*" /> + <option name="m_minLength" value="1" /> + <option name="m_maxLength" value="20" /> + </inspection_tool> + <inspection_tool class="MethodNameSameAsClassName" level="WARNING" enabled="true" /> + <inspection_tool class="MethodNameSameAsParentName" level="WARNING" enabled="true" /> + <inspection_tool class="MethodNamesDifferOnlyByCase" level="WARNING" enabled="true" /> + <inspection_tool class="ParameterNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[a-z][A-Za-z\d]*" /> + <option name="m_minLength" value="1" /> + <option name="m_maxLength" value="20" /> + </inspection_tool> + <inspection_tool class="NonBooleanMethodNameMayNotStartWithQuestion" level="WARNING" enabled="true"> + <option name="nameCheckString" value="is,can,has,should,could,will,shall,check,contains,equals,startsWith,endsWith" /> + </inspection_tool> + <inspection_tool class="UpperCaseFieldNameNotConstant" level="WARNING" enabled="true" /> + <inspection_tool class="NonExceptionNameEndsWithException" level="WARNING" enabled="true" /> + <inspection_tool class="OverloadedMethodsWithSameNumberOfParameters" level="WARNING" enabled="true" /> + <inspection_tool class="OverloadedVarargsMethod" level="WARNING" enabled="true" /> + <inspection_tool class="ParameterNameDiffersFromOverriddenParameter" level="WARNING" enabled="true"> + <option name="m_ignoreSingleCharacterNames" value="false" /> + <option name="m_ignoreOverridesOfLibraryMethods" value="false" /> + </inspection_tool> + <inspection_tool class="QuestionableName" level="WARNING" enabled="true"> + <option name="nameCheckString" value="foo,bar,baz" /> + </inspection_tool> + <inspection_tool class="StandardVariableNames" level="WARNING" enabled="true" /> + <inspection_tool class="StaticMethodNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[a-z][A-Za-z\d]*" /> + <option name="m_minLength" value="4" /> + <option name="m_maxLength" value="32" /> + </inspection_tool> + <inspection_tool class="StaticVariableNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="s_[a-z][A-Za-z\d]*" /> + <option name="m_minLength" value="5" /> + <option name="m_maxLength" value="32" /> + </inspection_tool> + <inspection_tool class="TypeParameterNamingConvention" level="WARNING" enabled="true"> + <option name="m_regex" value="[A-Z\d]" /> + <option name="m_minLength" value="1" /> + <option name="m_maxLength" value="1" /> + </inspection_tool> + <inspection_tool class="DollarSignInName" level="WARNING" enabled="true" /> + <inspection_tool class="RuntimeExec" level="WARNING" enabled="true" /> + <inspection_tool class="SystemExit" level="WARNING" enabled="true" /> + <inspection_tool class="SystemGetenv" level="WARNING" enabled="true" /> + <inspection_tool class="HardcodedFileSeparators" level="WARNING" enabled="true" /> + <inspection_tool class="NativeMethods" level="WARNING" enabled="true" /> + <inspection_tool class="UseOfAWTPeerClass" level="WARNING" enabled="true" /> + <inspection_tool class="UseOfJDBCDriverClass" level="WARNING" enabled="true" /> + <inspection_tool class="UseOfProcessBuilder" level="WARNING" enabled="true" /> + <inspection_tool class="UseOfSunClasses" level="WARNING" enabled="true" /> + <inspection_tool class="ChannelResource" level="WARNING" enabled="true" /> + <inspection_tool class="HibernateResource" level="WARNING" enabled="true" /> + <inspection_tool class="IOResource" level="WARNING" enabled="true" /> + <inspection_tool class="JDBCResource" level="WARNING" enabled="true" /> + <inspection_tool class="JNDIResource" level="WARNING" enabled="true" /> + <inspection_tool class="SocketResource" level="WARNING" enabled="true" /> + <inspection_tool class="DriverManagerGetConnection" level="WARNING" enabled="true" /> + <inspection_tool class="SystemProperties" level="WARNING" enabled="true" /> + <inspection_tool class="JDBCPrepareStatementWithNonConstantString" level="WARNING" enabled="true" /> + <inspection_tool class="RuntimeExecWithNonConstantString" level="WARNING" enabled="true" /> + <inspection_tool class="JDBCExecuteWithNonConstantString" level="WARNING" enabled="true" /> + <inspection_tool class="LoadLibraryWithNonConstantString" level="WARNING" enabled="true" /> + <inspection_tool class="SystemSetSecurityManager" level="WARNING" enabled="true" /> + <inspection_tool class="ClassLoaderInstantiation" level="WARNING" enabled="true" /> + <inspection_tool class="CloneableClassInSecureContext" level="WARNING" enabled="true" /> + <inspection_tool class="CustomClassloader" level="WARNING" enabled="true" /> + <inspection_tool class="CustomSecurityManager" level="WARNING" enabled="true" /> + <inspection_tool class="NonFinalClone" level="WARNING" enabled="true" /> + <inspection_tool class="PublicStaticArrayField" level="WARNING" enabled="true" /> + <inspection_tool class="PublicStaticCollectionField" level="WARNING" enabled="true" /> + <inspection_tool class="UnsecureRandomNumberGeneration" level="WARNING" enabled="true" /> + <inspection_tool class="ExternalizableWithSerializationMethods" level="WARNING" enabled="true" /> + <inspection_tool class="ReadObjectInitialization" level="WARNING" enabled="true" /> + <inspection_tool class="NonSerializableWithSerializationMethods" level="WARNING" enabled="true" /> + <inspection_tool class="NonSerializableWithSerialVersionUIDField" level="WARNING" enabled="true" /> + <inspection_tool class="NonSerializableFieldInSerializableClass" level="WARNING" enabled="true" /> + <inspection_tool class="NonSerializableObjectBoundToHttpSession" level="WARNING" enabled="true" /> + <inspection_tool class="NonSerializableObjectPassedToObjectStream" level="WARNING" enabled="true" /> + <inspection_tool class="ReadObjectAndWriteObjectPrivate" level="WARNING" enabled="true" /> + <inspection_tool class="ReadResolveAndWriteReplaceProtected" level="WARNING" enabled="true" /> + <inspection_tool class="SerializableWithUnconstructableAncestor" level="WARNING" enabled="true" /> + <inspection_tool class="SerializableHasSerializationMethods" level="WARNING" enabled="true"> + <option name="m_ignoreSerializableDueToInheritance" value="true" /> + </inspection_tool> + <inspection_tool class="SerializableHasSerialVersionUIDField" level="WARNING" enabled="true"> + <option name="m_ignoreSerializableDueToInheritance" value="true" /> + </inspection_tool> + <inspection_tool class="SerializableInnerClassHasSerialVersionUIDField" level="WARNING" enabled="true"> + <option name="m_ignoreSerializableDueToInheritance" value="true" /> + </inspection_tool> + <inspection_tool class="SerializableInnerClassWithNonSerializableOuterClass" level="WARNING" enabled="true"> + <option name="m_ignoreSerializableDueToInheritance" value="true" /> + </inspection_tool> + <inspection_tool class="SerialPersistentFieldsWithWrongSignature" level="WARNING" enabled="true" /> + <inspection_tool class="SerialVersionUIDNotStaticFinal" level="WARNING" enabled="true" /> + <inspection_tool class="TransientFieldInNonSerializableClass" level="WARNING" enabled="true" /> + <inspection_tool class="ClassEscapesItsScope" level="WARNING" enabled="true" /> + <inspection_tool class="FieldHidesSuperclassField" level="WARNING" enabled="true"> + <option name="m_ignoreInvisibleFields" value="true" /> + </inspection_tool> + <inspection_tool class="InnerClassVariableHidesOuterClassVariable" level="WARNING" enabled="true"> + <option name="m_ignoreInvisibleFields" value="true" /> + </inspection_tool> + <inspection_tool class="LocalVariableHidingMemberVariable" level="WARNING" enabled="true"> + <option name="m_ignoreInvisibleFields" value="true" /> + <option name="m_ignoreStaticMethods" value="true" /> + </inspection_tool> + <inspection_tool class="MethodOverloadsParentMethod" level="WARNING" enabled="true" /> + <inspection_tool class="MethodOverridesPackageLocalMethod" level="WARNING" enabled="true" /> + <inspection_tool class="MethodOverridesPrivateMethod" level="WARNING" enabled="true" /> + <inspection_tool class="MethodOverridesStaticMethod" level="WARNING" enabled="true" /> + <inspection_tool class="ParameterHidingMemberVariable" level="WARNING" enabled="true"> + <option name="m_ignoreInvisibleFields" value="true" /> + <option name="m_ignoreStaticMethodParametersHidingInstanceFields" value="true" /> + <option name="m_ignoreForConstructors" value="true" /> + <option name="m_ignoreForPropertySetters" value="true" /> + <option name="m_ignoreForAbstractMethods" value="true" /> + </inspection_tool> + <inspection_tool class="TypeParameterHidesVisibleType" level="WARNING" enabled="true" /> + <inspection_tool class="JavaDoc" level="WARNING" enabled="true"> + <option name="TOP_LEVEL_CLASS_OPTIONS"> + <value> + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> + <option name="REQUIRED_TAGS" value="" /> + </value> + </option> + <option name="INNER_CLASS_OPTIONS"> + <value> + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> + <option name="REQUIRED_TAGS" value="" /> + </value> + </option> + <option name="METHOD_OPTIONS"> + <value> + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> + <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" /> + </value> + </option> + <option name="FIELD_OPTIONS"> + <value> + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> + <option name="REQUIRED_TAGS" value="" /> + </value> + </option> + <option name="IGNORE_DEPRECATED" value="false" /> + <option name="IGNORE_JAVADOC_PERIOD" value="true" /> + <option name="myAdditionalJavadocTags" value="note,warning,todo,invariant,retval" /> + </inspection_tool> + </profile> + </profiles> + </component> + <component name="JavacSettings"> + <option name="DEBUGGING_INFO" value="true" /> + <option name="GENERATE_NO_WARNINGS" value="false" /> + <option name="DEPRECATION" value="true" /> + <option name="ADDITIONAL_OPTIONS_STRING" value="" /> + <option name="MAXIMUM_HEAP_SIZE" value="128" /> + </component> + <component name="JavadocGenerationManager"> + <option name="OUTPUT_DIRECTORY" /> + <option name="OPTION_SCOPE" value="protected" /> + <option name="OPTION_HIERARCHY" value="true" /> + <option name="OPTION_NAVIGATOR" value="true" /> + <option name="OPTION_INDEX" value="true" /> + <option name="OPTION_SEPARATE_INDEX" value="true" /> + <option name="OPTION_DOCUMENT_TAG_USE" value="false" /> + <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" /> + <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" /> + <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" /> + <option name="OPTION_DEPRECATED_LIST" value="true" /> + <option name="OTHER_OPTIONS" value="" /> + <option name="HEAP_SIZE" /> + <option name="LOCALE" /> + <option name="OPEN_IN_BROWSER" value="true" /> + </component> + <component name="JikesSettings"> + <option name="JIKES_PATH" value="" /> + <option name="DEBUGGING_INFO" value="true" /> + <option name="DEPRECATION" value="true" /> + <option name="GENERATE_NO_WARNINGS" value="false" /> + <option name="IS_EMACS_ERRORS_MODE" value="true" /> + <option name="ADDITIONAL_OPTIONS_STRING" value="" /> + </component> + <component name="LogConsolePreferences"> + <option name="FILTER_ERRORS" value="false" /> + <option name="FILTER_WARNINGS" value="false" /> + <option name="FILTER_INFO" value="true" /> + <option name="CUSTOM_FILTER" /> + </component> + <component name="Monitor.Log4jWindowPlugin" /> + <component name="Palette2"> + <group name="Swing"> + <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> + </item> + <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> + <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> + <initial-values> + <property name="text" value="Button" /> + </initial-values> + </item> + <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="RadioButton" /> + </initial-values> + </item> + <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="CheckBox" /> + </initial-values> + </item> + <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> + <initial-values> + <property name="text" value="Label" /> + </initial-values> + </item> + <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> + <preferred-size width="150" height="-1" /> + </default-constraints> + </item> + <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> + <preferred-size width="150" height="50" /> + </default-constraints> + </item> + <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> + <preferred-size width="200" height="200" /> + </default-constraints> + </item> + <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> + </item> + <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> + </item> + <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> + <preferred-size width="-1" height="20" /> + </default-constraints> + </item> + <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> + <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> + </item> + <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> + <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> + </item> + </group> + </component> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/argparser.iml" filepath="$PROJECT_DIR$/argparser.iml" /> + </modules> + </component> + <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/ideaclasses" /> + </component> + <component name="ProjectRunConfigurationManager" /> + <component name="RmicSettings"> + <option name="IS_EANABLED" value="false" /> + <option name="DEBUGGING_INFO" value="true" /> + <option name="GENERATE_NO_WARNINGS" value="false" /> + <option name="GENERATE_IIOP_STUBS" value="false" /> + <option name="ADDITIONAL_OPTIONS_STRING" value="" /> + </component> + <component name="StarteamVcsAdapter" /> + <component name="VssVcs" /> + <component name="com.intellij.jsf.UserDefinedFacesConfigs"> + <option name="USER_DEFINED_CONFIGS"> + <value> + <list size="0" /> + </value> + </option> + </component> + <component name="com.sixrr.metrics.MetricsReloaded"> + <option name="selectedProfile" value="Default" /> + <option name="autoscroll" value="false" /> + <option name="calculateMetrics" value="true" /> + <option name="includeTestClasses" value="false" /> + <option name="flattenInnerClasses" value="true" /> + <option name="cycleTableSpecificationString" value="" /> + <option name="shortCycleTableSpecificationString" value="" /> + </component> + <component name="copyright"> + <Base> + <setting name="state" value="2" /> + </Base> + </component> + <component name="libraryTable"> + <library name="annotations"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/annotations.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="junit"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/junit.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </component> + <component name="uidesigner-configuration"> + <option name="INSTRUMENT_CLASSES" value="true" /> + <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" /> + <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" /> + </component> + <UsedPathMacros /> +</project> + Property changes on: libs/argparser/trunk/argparser.ipr ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-30 09:18:44
|
Revision: 190 http://svn.sourceforge.net/japi/?rev=190&view=rev Author: christianhujer Date: 2006-10-30 01:18:24 -0800 (Mon, 30 Oct 2006) Log Message: ----------- Added required libraries. Added Paths: ----------- libs/argparser/trunk/lib/ libs/argparser/trunk/lib/LICENSE-Pack200Task.jar libs/argparser/trunk/lib/LICENSE-annotations.jar libs/argparser/trunk/lib/LICENSE-junit.jar libs/argparser/trunk/lib/Pack200Task.jar libs/argparser/trunk/lib/annotations.jar libs/argparser/trunk/lib/junit.jar Added: libs/argparser/trunk/lib/LICENSE-Pack200Task.jar =================================================================== --- libs/argparser/trunk/lib/LICENSE-Pack200Task.jar (rev 0) +++ libs/argparser/trunk/lib/LICENSE-Pack200Task.jar 2006-10-30 09:18:24 UTC (rev 190) @@ -0,0 +1,471 @@ +SUN PUBLIC LICENSE Version 1.0 + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the + Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to + the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original Code, + prior Modifications used by a Contributor, and the Modifications made + by that particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the + combination of the Original Code and Modifications, in each case + including portions thereof and corresponding documentation released + with the source code. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally + accepted in the software development community for the electronic + transfer of data. + + 1.5. "Executable" means Covered Code in any form other than Source + Code. + + 1.6. "Initial Developer" means the individual or entity identified as + the Initial Developer in the Source Code notice required by Exhibit A. + + 1.7. "Larger Work" means a work which combines Covered Code or + portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum + extent possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the + substance or structure of either the Original Code or any previous + Modifications. When Covered Code is released as a series of files, a + Modification is: + + A. Any addition to or deletion from the contents of a file containing + Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or + previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code + which is described in the Source Code notice required by Exhibit A as + Original Code, and which, at the time of its release under this + License is not already Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or + hereafter acquired, including without limitation, method, process, and + apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for + making modifications to it, including all modules it contains, plus + any associated documentation, interface definition files, scripts used + to control compilation and installation of an Executable, or source + code differential comparisons against either the Original Code or + another well known, available Covered Code of the Contributor's + choice. The Source Code can be in a compressed or archival form, + provided the appropriate decompression or de-archiving software is + widely available for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity + exercising rights under, and complying with all of the terms of, this + License or a future version of this License issued under Section 6.1. + For legal entities, "You" includes any entity which controls, is + controlled by, or is under common control with You. For purposes of + this definition, "control" means (a) the power, direct or indirect, to + cause the direction or management of such entity, whether by contract + or otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + +2. Source Code License. + +2.1 The Initial Developer Grant. + + The Initial Developer hereby grants You a world-wide, royalty-free, + non-exclusive license, subject to third party intellectual property + claims: + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer to use, reproduce, modify, + display, perform, sublicense and distribute the Original Code (or + portions thereof) with or without Modifications, and/or as part of a + Larger Work; and + + (b) under Patent Claims infringed by the making, using or selling of + Original Code, to make, have made, use, practice, sell, and offer for + sale, and/or otherwise dispose of the Original Code (or portions + thereof). + + (c) the licenses granted in this Section 2.1(a) and (b) are effective + on the date Initial Developer first distributes Original Code under + the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is + granted: 1) for code that You delete from the Original Code; 2) + separate from the Original Code; or 3) for infringements caused by: + i) the modification of the Original Code or ii) the combination of the + Original Code with other software or devices. + +2.2. Contributor Grant. + + Subject to third party intellectual property claims, each Contributor + hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Contributor, to use, reproduce, modify, + display, perform, sublicense and distribute the Modifications created + by such Contributor (or portions thereof) either on an unmodified + basis, with other Modifications, as Covered Code and/or as part of a + Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling of + Modifications made by that Contributor either alone and/or in + combination with its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, have made, and/or + otherwise dispose of: 1) Modifications made by that Contributor (or + portions thereof); and 2) the combination of Modifications made by + that Contributor with its Contributor Version (or portions of such + combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective + on the date Contributor first makes Commercial Use of the Covered + Code. + + (d) notwithstanding Section 2.2(b) above, no patent license is + granted: 1) for any code that Contributor has deleted from the + Contributor Version; 2) separate from the Contributor Version; 3) for + infringements caused by: i) third party modifications of Contributor + Version or ii) the combination of Modifications made by that + Contributor with other software (except as part of the Contributor + Version) or other devices; or 4) under Patent Claims infringed by + Covered Code in the absence of Modifications made by that Contributor. + +3. Distribution Obligations. + +3.1. Application of License. + + The Modifications which You create or to which You contribute are + governed by the terms of this License, including without limitation + Section 2.2. The Source Code version of Covered Code may be + distributed only under the terms of this License or a future version + of this License released under Section 6.1, and You must include a + copy of this License with every copy of the Source Code You + distribute. You may not offer or impose any terms on any Source Code + version that alters or restricts the applicable version of this + License or the recipients' rights hereunder. However, You may include + an additional document offering the additional rights described in + Section 3.5. + +3.2. Availability of Source Code. + + Any Modification which You create or to which You contribute must be + made available in Source Code form under the terms of this License + either on the same media as an Executable version or via an accepted + Electronic Distribution Mechanism to anyone to whom you made an + Executable version available; and if made available via Electronic + Distribution Mechanism, must remain available for at least twelve (12) + months after the date it initially became available, or at least six + (6) months after a subsequent version of that particular Modification + has been made available to such recipients. You are responsible for + ensuring that the Source Code version remains available even if the + Electronic Distribution Mechanism is maintained by a third party. + +3.3. Description of Modifications. + + You must cause all Covered Code to which You contribute to contain a + file documenting the changes You made to create that Covered Code and + the date of any change. You must include a prominent statement that + the Modification is derived, directly or indirectly, from Original + Code provided by the Initial Developer and including the name of the + Initial Developer in (a) the Source Code, and (b) in any notice in an + Executable version or related documentation in which You describe the + origin or ownership of the Covered Code. + +3.4. Intellectual Property Matters. + + (a) Third Party Claims. + + If Contributor has knowledge that a license under a third party's + intellectual property rights is required to exercise the rights + granted by such Contributor under Sections 2.1 or 2.2, Contributor + must include a text file with the Source Code distribution titled + "LEGAL'' which describes the claim and the party making the claim in + sufficient detail that a recipient will know whom to contact. If + Contributor obtains such knowledge after the Modification is made + available as described in Section 3.2, Contributor shall promptly + modify the LEGAL file in all copies Contributor makes available + thereafter and shall take other steps (such as notifying appropriate + mailing lists or newsgroups) reasonably calculated to inform those who + received the Covered Code that new knowledge has been obtained. + + (b) Contributor APIs. + + If Contributor's Modifications include an application programming + interface ("API") and Contributor has knowledge of patent licenses + which are reasonably necessary to implement that API, Contributor must + also include this information in the LEGAL file. + + (c) Representations. + + Contributor represents that, except as disclosed pursuant to Section + 3.4(a) above, Contributor believes that Contributor's Modifications + are Contributor's original creation(s) and/or Contributor has + sufficient rights to grant the rights conveyed by this License. + +3.5. Required Notices. + + You must duplicate the notice in Exhibit A in each file of the Source + Code. If it is not possible to put such notice in a particular Source + Code file due to its structure, then You must include such notice in a + location (such as a relevant directory) where a user would be likely + to look for such a notice. If You created one or more Modification(s) + You may add your name as a Contributor to the notice described in + Exhibit A. You must also duplicate this License in any documentation + for the Source Code where You describe recipients' rights or ownership + rights relating to Covered Code. You may choose to offer, and to + charge a fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Code. However, You + may do so only on Your own behalf, and not on behalf of the Initial + Developer or any Contributor. You must make it absolutely clear than + any such warranty, support, indemnity or liability obligation is + offered by You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred by the + Initial Developer or such Contributor as a result of warranty, + support, indemnity or liability terms You offer. + +3.6. Distribution of Executable Versions. + + You may distribute Covered Code in Executable form only if the + requirements of Section 3.1-3.5 have been met for that Covered Code, + and if You include a notice stating that the Source Code version of + the Covered Code is available under the terms of this License, + including a description of how and where You have fulfilled the + obligations of Section 3.2. The notice must be conspicuously included + in any notice in an Executable version, related documentation or + collateral in which You describe recipients' rights relating to the + Covered Code. You may distribute the Executable version of Covered + Code or ownership rights under a license of Your choice, which may + contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable version does not attempt to limit or alter the recipient's + rights in the Source Code version from the rights set forth in this + License. If You distribute the Executable version under a different + license You must make it absolutely clear that any terms which differ + from this License are offered by You alone, not by the Initial + Developer or any Contributor. You hereby agree to indemnify the + Initial Developer and every Contributor for any liability incurred by + the Initial Developer or such Contributor as a result of any such + terms You offer. + +3.7. Larger Works. + + You may create a Larger Work by combining Covered Code with other code + not governed by the terms of this License and distribute the Larger + Work as a single product. In such a case, You must make sure the + requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Code due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description + must be included in the LEGAL file described in Section 3.4 and must + be included with all distributions of the Source Code. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has + attached the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + +6.1. New Versions. + + Sun Microsystems, Inc. ("Sun") may publish revised and/or new versions + of the License from time to time. Each version will be given a + distinguishing version number. + +6.2. Effect of New Versions. + + Once Covered Code has been published under a particular version of the + License, You may always continue to use it under the terms of that + version. You may also choose to use such Covered Code under the terms + of any subsequent version of the License published by Sun. No one + other than Sun has the right to modify the terms applicable to Covered + Code created under this License. + +6.3. Derivative Works. + + If You create or use a modified version of this License (which you may + only do in order to apply it to code which is not already Covered Code + governed by this License), You must: (a) rename Your license so that + the phrases "Sun," "Sun Public License," or "SPL" or any confusingly + similar phrase do not appear in your license (except to note that your + license differs from this License) and (b) otherwise make it clear + that Your version of the license contains terms which differ from the + Sun Public License. (Filling in the name of the Initial Developer, + Original Code or Contributor in the notice described in Exhibit A + shall not of themselves be deemed to be modifications of this + License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS'' BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. + THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE + IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, + YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE + COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER + OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure + such breach within 30 days of becoming aware of the breach. All + sublicenses to the Covered Code which are properly granted shall + survive any termination of this License. Provisions which, by their + nature, must remain in effect beyond the termination of this License + shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement + claim (excluding declaratory judgment actions) against Initial Developer + or a Contributor (the Initial Developer or Contributor against whom + You file such action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly + infringes any patent, then any and all rights granted by such + Participant to You under Sections 2.1 and/or 2.2 of this License + shall, upon 60 days notice from Participant terminate prospectively, + unless if within 60 days after receipt of notice You either: (i) + agree in writing to pay Participant a mutually agreeable reasonable + royalty for Your past and future use of Modifications made by such + Participant, or (ii) withdraw Your litigation claim with respect to + the Contributor Version against such Participant. If within 60 days + of notice, a reasonable royalty and payment arrangement are not + mutually agreed upon in writing by the parties or the litigation claim + is not withdrawn, the rights granted by Participant to You under + Sections 2.1 and/or 2.2 automatically terminate at the expiration of + the 60 day notice period specified above. + + (b) any software, hardware, or device, other than such Participant's + Contributor Version, directly or indirectly infringes any patent, then + any rights granted to You by such Participant under Sections 2.1(b) + and 2.2(b) are revoked effective as of the date You first made, used, + sold, distributed, or had made, Modifications made by that + Participant. + + 8.3. If You assert a patent infringement claim against Participant + alleging that such Participant's Contributor Version directly or + indirectly infringes any patent where such claim is resolved (such as + by license or settlement) prior to the initiation of patent + infringement litigation, then the reasonable value of the licenses + granted by such Participant under Sections 2.1 or 2.2 shall be taken + into account in determining the amount or value of any payment or + license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, all + end user license agreements (excluding distributors and resellers) + which have been validly granted by You or any distributor hereunder + prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL + DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, + OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR + ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY + CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, + WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY + RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW + PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE + EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO + THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in 48 + C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" + and "commercial computer software documentation," as such terms are + used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. + 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all + U.S. Government End Users acquire Covered Code with only those rights + set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. This License shall be governed by + California law provisions (except to the extent applicable law, if + any, provides otherwise), excluding its conflict-of-law provisions. + With respect to disputes in which at least one party is a citizen of, + or an entity chartered or registered to do business in the United + States of America, any litigation relating to this License shall be + subject to the jurisdiction of the Federal Courts of the Northern + District of California, with venue lying in Santa Clara County, + California, with the losing party responsible for costs, including + without limitation, court costs and reasonable attorneys' fees and + expenses. The application of the United Nations Convention on + Contracts for the International Sale of Goods is expressly excluded. + Any law or regulation which provides that the language of a contract + shall be construed against the drafter shall not apply to this + License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, + out of its utilization of rights under this License and You agree to + work with Initial Developer and Contributors to distribute such + responsibility on an equitable basis. Nothing herein is intended or + shall be deemed to constitute any admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as + "Multiple-Licensed". "Multiple-Licensed" means that the Initial + Developer permits you to utilize portions of the Covered Code under + Your choice of the alternative licenses, if any, specified by the + Initial Developer in the file described in Exhibit A. + +Exhibit A -Sun Public License Notice. + + The contents of this file are subject to the Sun Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. A copy of the License is available at + http://www.sun.com/ + + The Original Code is _________________. The Initial Developer of the + Original Code is ___________. Portions created by ______ are Copyright + (C)_________. All Rights Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms + of the _____ license (the "[___] License"), in which case the + provisions of [______] License are applicable instead of those above. + If you wish to allow use of your version of this file only under the + terms of the [____] License and not to allow others to use your + version of this file under the SPL, indicate your decision by deleting + the provisions above and replace them with the notice and other + provisions required by the [___] License. If you do not delete the + provisions above, a recipient may use your version of this file under + either the SPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of + the notices in the Source Code files of the Original Code. You should + use the text of this Exhibit A rather than the text found in the + Original Code Source Code for Your Modifications.] Property changes on: libs/argparser/trunk/lib/LICENSE-Pack200Task.jar ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/lib/LICENSE-annotations.jar =================================================================== --- libs/argparser/trunk/lib/LICENSE-annotations.jar (rev 0) +++ libs/argparser/trunk/lib/LICENSE-annotations.jar 2006-10-30 09:18:24 UTC (rev 190) @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: libs/argparser/trunk/lib/LICENSE-annotations.jar ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/lib/LICENSE-junit.jar =================================================================== --- libs/argparser/trunk/lib/LICENSE-junit.jar (rev 0) +++ libs/argparser/trunk/lib/LICENSE-junit.jar 2006-10-30 09:18:24 UTC (rev 190) @@ -0,0 +1,213 @@ +Common Public License Version 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + + i) changes to the Program, and + + ii) additions to the Program; + + where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + + b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + + c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + + d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + + b) its license agreement: + + i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + + ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + + iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + + iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + + b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. Property changes on: libs/argparser/trunk/lib/LICENSE-junit.jar ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/lib/Pack200Task.jar =================================================================== (Binary files differ) Property changes on: libs/argparser/trunk/lib/Pack200Task.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: libs/argparser/trunk/lib/annotations.jar =================================================================== (Binary files differ) Property changes on: libs/argparser/trunk/lib/annotations.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: libs/argparser/trunk/lib/junit.jar =================================================================== (Binary files differ) Property changes on: libs/argparser/trunk/lib/junit.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-16 10:00:34
|
Revision: 189 http://svn.sourceforge.net/japi/?rev=189&view=rev Author: christianhujer Date: 2006-10-16 02:59:59 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Copied font classes from historic to swing-font subproject. Added Paths: ----------- libs/swing-font/trunk/src/ libs/swing-font/trunk/src/net/ libs/swing-font/trunk/src/net/sf/ libs/swing-font/trunk/src/net/sf/japi/ libs/swing-font/trunk/src/net/sf/japi/swing/ libs/swing-font/trunk/src/net/sf/japi/swing/font/ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyComboBox.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java libs/swing-font/trunk/src/net/sf/japi/swing/font/action.properties libs/swing-font/trunk/src/net/sf/japi/swing/font/action_de.properties libs/swing-font/trunk/src/net/sf/japi/swing/font/package.html Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/FontChooser.java) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,217 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.font; + +import java.awt.Component; +import java.awt.Font; +import static java.awt.Font.BOLD; +import static java.awt.Font.ITALIC; +import static java.awt.Font.PLAIN; +import java.awt.GraphicsEnvironment; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import static javax.swing.BorderFactory.createCompoundBorder; +import static javax.swing.BorderFactory.createEmptyBorder; +import static javax.swing.BorderFactory.createTitledBorder; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JList; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.PLAIN_MESSAGE; +import static javax.swing.JOptionPane.showConfirmDialog; +import javax.swing.JScrollPane; +import javax.swing.JSpinner; +import static javax.swing.ListSelectionModel.SINGLE_SELECTION; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import org.jetbrains.annotations.Nullable; +import net.sf.japi.swing.ActionFactory; +import static net.sf.japi.swing.ActionFactory.getFactory; + +/** Class for letting the user choose a font. + * There are two possibilities to use this class: + * <ul> + * <li>You can use an instance of FontChooser as a Pane and add it to the desired Container.</li> + * <li>You can use this class' static methods to display a Dialog which lets the user choose a font.</li> + * </ul> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class FontChooser extends JComponent implements ListSelectionListener, ChangeListener { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = getFactory("net.sf.japi.swing.font"); + + /** JList for Font Family. + * @serial include + */ + private JList familyList; + + /** JList for Font Style. + * @serial include + */ + private JList styleList; + + /** JList for Font Size. + * @serial include + */ + private JList sizeList; + + /** JSpinner for Font Size. + * @serial include + */ + private JSpinner sizeSpinner; + + /** FontPreview for Font. + * @serial include + */ + private FontPreview preview; + + /** Selected Font. + * @serial include + */ + private Font selectedFont; + + /** Create a new FontChooser. */ + public FontChooser() { + setBorder(createCompoundBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createTitledBorder(ACTION_FACTORY.getString("desiredFont_borderTitle"))), createEmptyBorder(8, 4, 4, 4))); + setLayout(new GridBagLayout()); + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(2, 2, 2, 2); + final JLabel familyLabel = ACTION_FACTORY.createLabel("family.label"); + final JLabel styleLabel = ACTION_FACTORY.createLabel("style.label"); + final JLabel sizeLabel = ACTION_FACTORY.createLabel("size.label"); + familyList = new JList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); + styleList = new JList(new Integer[] { PLAIN, ITALIC, BOLD, BOLD|ITALIC }); + styleList.setCellRenderer(new FontStyleListCellRenderer()); + sizeList = new JList(new Integer[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 32, 48, 64 }); + preview = new FontPreview(); + sizeSpinner = new JSpinner(new SpinnerNumberModel(12, 4, 100, 1)); + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.BOTH; + add(familyLabel, gbc); + add(styleLabel, gbc); + gbc.gridwidth = GridBagConstraints.REMAINDER; + add(sizeLabel, gbc); + gbc.gridwidth = 1; + gbc.gridheight = 2; + gbc.weighty = 1.0; + add(new JScrollPane(familyList), gbc); + add(new JScrollPane(styleList), gbc); + gbc.gridheight = 1; + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weighty = 0.0; + add(sizeSpinner, gbc); + gbc.weighty = 1.0; + add(new JScrollPane(sizeList), gbc); + gbc.gridwidth = 3; + add(preview, gbc); + familyList.addListSelectionListener(this); + styleList.addListSelectionListener(this); + sizeList.addListSelectionListener(this); + sizeSpinner.addChangeListener(this); + familyList.setSelectionMode(SINGLE_SELECTION); + styleList.setSelectionMode(SINGLE_SELECTION); + sizeList.setSelectionMode(SINGLE_SELECTION); + } + + /** Set the selected font. */ + public void setSelectedFont(final Font selectedFont) { + this.selectedFont = selectedFont; + preview.setFont(selectedFont); + //lock = true; + sizeSpinner.setValue(selectedFont.getSize()); + sizeList.setSelectedValue(selectedFont.getSize(), true); + styleList.setSelectedValue(selectedFont.getStyle(), true); + familyList.setSelectedValue(selectedFont.getFamily(), true); + //lock = false; + } + + /** Set the selected family. */ + private void updateFont() { + //if (lock) { return; } + final String family = familyList.getSelectedValue() == null ? selectedFont.getFamily() : (String) familyList.getSelectedValue(); + final int style = styleList.getSelectedValue() == null ? selectedFont.getStyle() : (Integer) styleList.getSelectedValue(); + final int size = sizeList.getSelectedValue() == null ? selectedFont.getSize() : (Integer) sizeSpinner.getValue(); + selectedFont = new Font(family, style, size); + preview.setFont(selectedFont); + } + + /** {@inheritDoc} */ + public void valueChanged(final ListSelectionEvent e) { + final Object source = e.getSource(); + if (source == familyList) { + // No special action except updateFont() + } else if (source == styleList) { + // No special action except updateFont() + } else if (source == sizeList) { + final Object size = sizeList.getSelectedValue(); + if (!sizeSpinner.getValue().equals(size) && size != null) { + sizeSpinner.setValue(size); + } + } else { + assert false; + } + updateFont(); + } + + /** {@inheritDoc} */ + public void stateChanged(final ChangeEvent e) { + final Object source = e.getSource(); + if (source == sizeSpinner) { + final Object size = sizeSpinner.getValue(); + if (!size.equals(sizeList.getSelectedValue())) { + sizeList.setSelectedValue(size, true); + } + } else { + assert false; + } + updateFont(); + } + + /** Show a dialog. + * @param parent Parent component + * @return seleced font or null + */ + public static Font showChooseFontDialog(final Component parent) { + return showChooseFontDialog(parent, Font.decode(null)); + } + + /** Show a dialog. + * @param parent Parent compnent + * @param font Font to modify + * @return selected font or null + */ + @Nullable public static Font showChooseFontDialog(final Component parent, final Font font) { + final FontChooser chooser = new FontChooser(); + chooser.setSelectedFont(font); + if (showConfirmDialog(parent, chooser, ACTION_FACTORY.getString("chooser.title"), OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION) { + return chooser.selectedFont; + } else { + return null; + } + } + +} // class FontChooser Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyComboBox.java (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/FontFamilyComboBox.java) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyComboBox.java (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyComboBox.java 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,72 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.font; + +import java.awt.Font; +import static java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment; +import java.util.HashMap; +import java.util.Map; +import javax.swing.JComboBox; + +/** ComboBox to choose the font family. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: FontFamilyComboBox.java,v 1.1 2006/03/26 01:26:27 christianhujer Exp $ + */ +public class FontFamilyComboBox extends JComboBox { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** The fonts to render. + * @serial include + */ + private Map<String,Font> fonts; + + /** Create a FontFamilyComboBox. */ + public FontFamilyComboBox() { + super(getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); + // initFonts(); the super class construction invokes setFont and thus initFonts(); + } + + /** {@inheritDoc} */ + @Override public void setFont(final Font font) { + super.setFont(font); + initFonts(); + } + + /** Initialize fonts. */ + private void initFonts() { + if (fonts == null) { + final FontFamilyListCellRenderer cellRenderer = new FontFamilyListCellRenderer(); + setRenderer(cellRenderer); + fonts = new HashMap<String,Font>(); + cellRenderer.setFonts(fonts); + } + Font base = getFont(); + if (base == null) { base = Font.decode(null); } + final int style = base.getStyle(); + final int size = base.getSize(); + for (final String family : getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) { + fonts.put(family, new Font(family, style, size)); + } + } + +} // class FontFamilyComboBox Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/FontFamilyListCellRenderer.java) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,61 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.font; + +import java.awt.Component; +import java.awt.Font; +import java.util.Map; +import javax.swing.JList; +import javax.swing.DefaultListCellRenderer; + +/** List cell renderer for letting the user choose the font family. + * This list cell renderer displays each font in its font. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: FontFamilyListCellRenderer.java,v 1.1 2006/03/26 01:26:27 christianhujer Exp $ + */ +public class FontFamilyListCellRenderer extends DefaultListCellRenderer { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** The fonts to render. + * @serial include + */ + private Map<String,Font> fonts; + + /** Set the fonts to render. + * The key of the map is the family name, the value of the map is the font to render. + * @param fonts fonts to render + */ + public void setFonts(final Map<String,Font> fonts) { + this.fonts = fonts; + } + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + //Font f = FontFamilyComboBox.this.getFont(); + //c.setFont(new Font((String)value, f.getStyle(), f.getSize())); + c.setFont(fonts.get((String)value)); + return c; + } + +} // class FontFamilyCellRenderer Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/FontPreview.java) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,58 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.font; + +import java.awt.Dimension; +import javax.swing.JTextField; +import net.sf.japi.swing.ActionFactory; +import static net.sf.japi.swing.ActionFactory.getFactory; + +/** Font Preview. + * Uses a localized text to display the font, but the user may edit the text to try out the characters she's interested in. + * This class is derived from JTextField, but never ever depend on that inheritance. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class FontPreview extends JTextField { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = getFactory("net.sf.japi.swing.font"); + + /** Create a new FontPreview. */ + public FontPreview() { + super(getDefaultText()); + setHorizontalAlignment(CENTER); + final Dimension d = getMinimumSize(); + d.height = 64; + setMinimumSize(d); + setPreferredSize(d); + } + + /** Get the default text for previewing a font. + * @return default text + */ + public static String getDefaultText() { + return ACTION_FACTORY.getString("font_preview_text"); + } + +} // class FontPreview Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/FontStyleListCellRenderer.java) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,82 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.font; + +import java.awt.Component; +import java.awt.Font; +import static java.awt.Font.BOLD; +import static java.awt.Font.ITALIC; +import static java.awt.Font.PLAIN; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import net.sf.japi.swing.ActionFactory; + +/** ListCellRenderer for font styles. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo improve performance + */ +public class FontStyleListCellRenderer extends DefaultListCellRenderer { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.font"); + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + final int style = (Integer) value; + setText(getTextFor(style)); + setFont(getFontFor(style)); + return c; + } + + /** Get the text representation of a style. + * @param style style to get text representation for + * @return text representation of style + * @todo store values + */ + private static String getTextFor(final int style) { + switch (style) { + case PLAIN: return ACTION_FACTORY.getString("font.style.plain"); + case BOLD: return ACTION_FACTORY.getString("font.style.bold"); + case ITALIC: return ACTION_FACTORY.getString("font.style.italic"); + case BOLD|ITALIC: return ACTION_FACTORY.getString("font.style.bolditalic"); + default: return ACTION_FACTORY.getString("font.style.unknown"); + } + } + + /** Get the font representation of a style. + * @param style style to get font representation for + * @return font representation of style + */ + private Font getFontFor(final int style) { + switch (style) { + case PLAIN: return getFont().deriveFont(PLAIN); + case BOLD: return getFont().deriveFont(BOLD); + case ITALIC: return getFont().deriveFont(ITALIC); + case BOLD|ITALIC: return getFont().deriveFont(BOLD|ITALIC); + default: return getFont().deriveFont(PLAIN); + } + } + +} // class FontStyleListCellRenderer Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/action.properties (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/action.properties) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/action.properties (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/action.properties 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,31 @@ +# +# JAPI - (Yet another (hopefully) useful) Java API +# +# Copyright (C) 2006 Christian Hujer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +desiredFont.borderTitle=Desired font +family.label=Family: +style.label=Style: +size.label=Size: +chooser.title=Choose Font +font.style.plain=Plain +font.style.bold=Bold +font.style.italic=Italic +font.style.bolditalic=Bold Italic +font.style.unknown=Unknown +font.preview.text=Falsches Spielen von Xylophonmusik qu\xE4lt jeden gr\xF6\xDFeren Zwerg Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/action_de.properties (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/action_de.properties) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/action_de.properties (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/action_de.properties 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,31 @@ +# +# JAPI - (Yet another (hopefully) useful) Java API +# +# Copyright (C) 2006 Christian Hujer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +desiredFont.borderTitle=Gew\xFCnschte Schriftart +family.label=Schriftart: +style.label=Schriftstil: +size.label=Gr\xF6\xDFe: +chooser.title=Schriftart ausw\xE4hlen +font.style.plain=Normal +font.style.bold=Fett +font.style.italic=Kursiv +font.style.bolditalic=Fett Kursiv +font.style.unknown=Unbekannt +font.preview.text=Falsches Spielen von Xylophonmusik qu\xE4lt jeden gr\xF6\xDFeren Zwerg Copied: libs/swing-font/trunk/src/net/sf/japi/swing/font/package.html (from rev 188, historic/trunk/src/app/net/sf/japi/swing/font/package.html) =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/package.html (rev 0) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/package.html 2006-10-16 09:59:59 UTC (rev 189) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JAPI - (Yet another (hopefully) useful) Java API + - + - Copyright (C) 2006 Christian Hujer + - + - This program is free software; you can redistribute it and/or + - modify it under the terms of the GNU General Public License as + - published by the Free Software Foundation; either version 2 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, but + - WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + - General Public License for more details. + - + - You should have received a copy of the GNU General Public License + - along with this program; if not, write to the Free Software + - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + - 02111-1307, USA. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> + <title>net.sf.japi.swing.font</title> + </head> + <body> + <p> + The package net.sf.japi.swing.font contains a font chooser and related classes. + </p> + </body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-14 12:50:33
|
Revision: 188 http://svn.sourceforge.net/japi/?rev=188&view=rev Author: christianhujer Date: 2006-10-14 05:50:10 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Copied preferences classes from historic to swing-prefs subproject. Added Paths: ----------- libs/swing-prefs/trunk/src/ libs/swing-prefs/trunk/src/net/ libs/swing-prefs/trunk/src/net/sf/ libs/swing-prefs/trunk/src/net/sf/japi/ libs/swing-prefs/trunk/src/net/sf/japi/swing/ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesGroup.java libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesPane.java libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/Prefs.java libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action.properties libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action_de.properties libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/package.html Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/AbstractPrefs.java) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,145 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.prefs; + +import java.net.URL; +import java.awt.LayoutManager; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.BoxLayout; +import net.sf.japi.swing.ColumnLayout; + +/** Abstract preferences implementation. + * Subclass this. + * Build the panel in your constructor. + * The default layout of an AbstractPrefs is {@link BoxLayout} with {@link BoxLayout#Y_AXIS}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractPrefs extends JPanel implements Prefs { + + /** The icon to be displayed in the list where the user can choose amongst preferences. + * @see #getListLabelIcon() + * @serial include + */ + private Icon listLabelIcon; + + /** The label text to be displayed in the list where the user can choose amongst preferences. + * @see #getListLabelText() + * @serial include + */ + private String listLabelText; + + /** The title text to be displayed as title for this prefs module. + * @see #getLabelText() + * @serial include + */ + private String labelText; + + /** The Help URL. + * @serial include + */ + private URL helpURL; + + /** The Help text (HTML). + * @serial include + */ + private String helpText; + + /** Constructor. */ + protected AbstractPrefs() { + super(new ColumnLayout()); + // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + } + + /** Constructor that allows setting the initial layout. + * @param layout Layout + */ + protected AbstractPrefs(final LayoutManager layout) { + super(layout); + } + + /** {@inheritDoc} */ + public final JComponent getEditComponent() { + return this; + } + + /** {@inheritDoc} */ + public final Icon getListLabelIcon() { + return listLabelIcon; + } + + /** Set the icon that is to be displayed in the list where the user can choose amongst preferences. + * @param listLabelIcon icon + */ + protected final void setListLabelIcon(final Icon listLabelIcon) { + this.listLabelIcon = listLabelIcon; + } + + /** {@inheritDoc} */ + public final String getListLabelText() { + return listLabelText; + } + + /** Set the label text that is to be displayed in the list where the user can choose amongst preferences. + * @param listLabelText text + */ + protected final void setListLabelText(final String listLabelText) { + this.listLabelText = listLabelText; + } + + /** {@inheritDoc} */ + public final String getLabelText() { + return labelText; + } + + /** Set the title text that is to be displayed as title for this prefs module. + * @param labelText text + */ + protected final void setLabelText(final String labelText) { + this.labelText = labelText; + } + + /** {@inheritDoc} */ + public final URL getHelpURL() { + return helpURL; + } + + /** Set the help URL. + * @param helpURL Help URL + */ + protected final void setHelpURL(final URL helpURL) { + this.helpURL = helpURL; + } + + /** {@inheritDoc} */ + public final String getHelpText() { + return helpText; + } + + /** Set the help text. + * @param helpText Help text + */ + protected final void setHelpText(final String helpText) { + this.helpText = helpText; + } + +} // class AbstractPrefs Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesGroup.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/PreferencesGroup.java) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesGroup.java (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesGroup.java 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,74 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.prefs; + +import static java.util.Arrays.asList; +import java.util.Iterator; +import java.util.List; +import javax.swing.AbstractListModel; + +/** A PreferencesGroup is an ordered set of {@link Prefs}, for use with {@link PreferencesPane}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class PreferencesGroup extends AbstractListModel implements Iterable<Prefs> { + + /** The preferences modules. + * @serial include + */ + private final List<Prefs> prefs; + + /** The preferences title. + * @serial include + */ + private final String title; + + /** Create a Preferences group. + * @param prefs Preferences modules to initially add + * @param title Title for Preferences + */ + public PreferencesGroup(final String title, final Prefs... prefs) { + this.title = title; + this.prefs = asList(prefs); + } + + /** Get the title. + * @return title + */ + public String getTitle() { + return title; + } + + /** {@inheritDoc} */ + public Iterator<Prefs> iterator() { + return prefs.iterator(); + } + + /** {@inheritDoc} */ + public int getSize() { + return prefs.size(); + } + + /** {@inheritDoc} */ + public Prefs getElementAt(final int index) { + return prefs.get(index); + } + +} // class PreferencesGroup Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesPane.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/PreferencesPane.java) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesPane.java (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/PreferencesPane.java 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,290 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.prefs; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.util.HashMap; +import java.util.Map; +import javax.swing.Action; +import static javax.swing.BorderFactory.createEmptyBorder; +import javax.swing.Box; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; +import javax.swing.border.Border; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import net.sf.japi.swing.ActionFactory; + +/** Panel to display preferences. + * @serial exclude This class is not intended to be serialized. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) +public final class PreferencesPane extends JOptionPane implements ListSelectionListener { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.prefs"); + + /** A map for DIALOGS that are already displaying. + * This map is used to prevent the dialog for the same PreferencesGroup be shown twice within the same application. + */ + private static final Map<PreferencesGroup,JDialog> DIALOGS = new HashMap<PreferencesGroup,JDialog>(); + + /** The group of preferences to display. */ + private final PreferencesGroup prefs; + + /** The currently selected preferences module. */ + private Prefs currentPref; + + /** Action for help. */ + private final Action helpAction = ACTION_FACTORY.createAction(false, "help" , this); + + /** Action for defaults. */ + private final Action defaultsAction = ACTION_FACTORY.createAction(false, "defaults", this); + + /** Action for ok. */ + private final Action okAction = ACTION_FACTORY.createAction(false, "ok" , this); + + /** Action for apply. */ + private final Action applyAction = ACTION_FACTORY.createAction(false, "apply" , this); + + /** Action for revert. */ + private final Action revertAction = ACTION_FACTORY.createAction(false, "revert" , this); + + /** Action for cancel. */ + private final Action cancelAction = ACTION_FACTORY.createAction(false, "cancel" , this); + + /** CardLayout for switching between prefs modules. + * @see #cardPanel + */ + private final CardLayout cards = new CardLayout(); + + /** Panel where the CardLayout for switching between prefs modules is used. + * @see #cards + */ + private final JPanel cardPanel = new JPanel(cards); + + /** Show Preferences. + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param prefs PreferencesGroup to be displayed + * @param modal <code>true</code> if the displayed dialog should be modal, otherwise <code>false</code> + */ + public static void showPreferencesDialog(final Component parentComponent, final PreferencesGroup prefs, final boolean modal) { + synchronized (DIALOGS) { + if (DIALOGS.containsKey(prefs)) { + DIALOGS.get(prefs).toFront(); + } else { + final PreferencesPane pane = new PreferencesPane(prefs); + final JDialog dialog = pane.createDialog(parentComponent, prefs.getTitle()); + DIALOGS.put(prefs, dialog); + dialog.setResizable(true); + dialog.setModal(modal); + dialog.setVisible(true); + } + } + } + + /** Create a PreferencesPane. + * @param prefs PreferencesGroup to create panel for + */ + private PreferencesPane(final PreferencesGroup prefs) { + this.prefs = prefs; + setMessage(createMessage()); + setOptions(createOptions()); + } + + /** Create the Message. + * @return subpanel + */ + private JComponent createMessage() { + final JPanel panel = new JPanel(new BorderLayout()); + panel.add(createList(), BorderLayout.WEST); + panel.add(createPanel(), BorderLayout.CENTER); + return panel; + } + + /** Create the list. + * @return list + */ + private JComponent createList() { + final JList list = new JList(prefs); + list.setCellRenderer(new PrefsListCellRenderer()); + list.setSelectedIndex(0); + list.addListSelectionListener(this); + return new JScrollPane(list); + } + + /** Create the Panel. + * @return panel + */ + private JComponent createPanel() { + int index = 0; + for (final Prefs pref : prefs) { + cardPanel.add(Integer.toString(index++), pref.getEditComponent()); + } + currentPref = prefs.getElementAt(0); + return cardPanel; + } + + /** Create the Options. + * @return options + */ + private Object[] createOptions() { + return new Object[] { + new JButton(helpAction), + new JButton(defaultsAction), + Box.createHorizontalStrut(50), + new JButton(okAction), + new JButton(applyAction), + Box.createHorizontalStrut(50), + new JButton(revertAction), + new JButton(cancelAction), + }; + } + + /** {@inheritDoc} */ + public void valueChanged(final ListSelectionEvent e) { + if (e.getValueIsAdjusting()) { + return; + } + final int index = ((JList) e.getSource()).getSelectedIndex(); + final Prefs newPref = prefs.getElementAt(index); + //noinspection ObjectEquality + if (currentPref == newPref) { + return; + } + if (currentPref.isChanged()) { + final int result = ACTION_FACTORY.showConfirmDialog(this, YES_NO_CANCEL_OPTION, QUESTION_MESSAGE, "prefsChanged", currentPref.getListLabelText()); + switch (result) { + case CLOSED_OPTION: + case CANCEL_OPTION: + ((JList) e.getSource()).setSelectedValue(currentPref, true); + return; + case YES_OPTION: + currentPref.apply(); + break; + case NO_OPTION: + default: + } + } + currentPref = newPref; + cards.show(cardPanel, Integer.toString(index)); + } + + /** Action method for cancel. + * @used + */ + public void cancel() { + setValue(CANCEL_OPTION); + } + + /** {@inheritDoc} */ + @Override public void setValue(final Object newValue) { + super.setValue(newValue); + //noinspection ObjectEquality + if (newValue != null && newValue != UNINITIALIZED_VALUE) { + synchronized (DIALOGS) { + DIALOGS.remove(prefs).dispose(); + } + } + } + + /** Action method for defaults. + * @used + */ + public void defaults() { + currentPref.defaults(); + } + + /** Action method for help. + * @used + */ + public void help() { + // TODO + } + + /** Action method for ok. + * @used + */ + @SuppressWarnings({"InstanceMethodNamingConvention"}) + public void ok() { + apply(); + setValue(OK_OPTION); + } + + /** Action method for apply. + * @used + */ + public void apply() { + if (currentPref.isChanged()) { + currentPref.apply(); + } + } + + /** Action method for revert. + * @used + */ + public void revert() { + if (currentPref.isChanged()) { + currentPref.revert(); + } + } + + /** Class for rendering preferences list items. */ + private static final class PrefsListCellRenderer extends DefaultListCellRenderer { + + /** The border. + * For some reason it gets lost when set in the initializer, so we store it and set it each time the renderer is used. + */ + private Border border = createEmptyBorder(10, 10, 10, 10); + + /** Create a PrefsListCellRenderer. */ + PrefsListCellRenderer() { + setHorizontalTextPosition(SwingConstants.CENTER); + setVerticalTextPosition(SwingConstants.BOTTOM); + setHorizontalAlignment(SwingConstants.CENTER); + setVerticalAlignment(SwingConstants.CENTER); + } + + /** {@inheritDoc} */ + @SuppressWarnings({"ReturnOfThis"}) + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + setBorder(border); + final Prefs pref = (Prefs) value; + setText(pref.getListLabelText()); + setIcon(pref.getListLabelIcon()); + return this; + } + + } // class PrefsListCellRenderer + +} // class PreferencesPane Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/Prefs.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/Prefs.java) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/Prefs.java (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/Prefs.java 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,85 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.prefs; + +import java.net.URL; +import javax.swing.Icon; +import javax.swing.JComponent; + +/** Interface that is to be implemented by classes that provide preferences. + * <p /> + * Often, implementations of this interface will subclass JComponent or JPanel. + * In that case {@link #getEditComponent()} will <code>return this</code>. + * {@link AbstractPrefs} provides a useful basic implementation of this interface. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface Prefs { + + /** Apply the changes in the UI to get into effect / be stored. */ + void apply(); + + /** Revert the preferences to the default values. */ + void defaults(); + + /** Provide a component for editing the prefs. + * The edit component MUST NOT automatically change preferences itself. + * Preferences MUST only changed when the method {@link #apply()} is invoked. + * @return component for editing the prefs + */ + JComponent getEditComponent(); + + /** Provide help (HTML). + * This method will only be queried if {@link #getHelpURL()} returns <code>null</code>. + * This method may return <code>null</code> as well, which means that this prefs does not provide any help. + * @return help text (HTML) or <code>null</code> + */ + String getHelpText(); + + /** Provide help. + * This method may return <code>null</code> in which case the method {@link #getHelpText()} will be queried instead. + * @return help url or <code>null</code> + */ + URL getHelpURL(); + + /** Provide text to be displayed as title for this prefs module. + * @return title of this prefs module + */ + String getLabelText(); + + /** Provide an icon to be displayed in the list where the user can choose amongst preferences. + * @return icon to be displayed in the list or <code>null</code> if no icon is available + */ + Icon getListLabelIcon(); + + /** Provide a label to be displayed in the list where the user can choose amongst preferences. + * @return text to be displayed in the list + */ + String getListLabelText(); + + /** Check whether there are unsaved changes. + * @return <code>true</code> if there are unsaved changes, otherwise <code>false</code> + */ + boolean isChanged(); + + /** Revert the preferences to the previously stored settings. */ + void revert(); + +} // class Prefs Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action.properties (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/action.properties) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action.properties (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action.properties 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,29 @@ +# JAPI - (Yet another (hopefully) useful) Java API +# +# Copyright (C) 2004-2006 Christian Hujer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# + + +help.text=Help +defaults.text=Defaults +ok.text=Ok +apply.text=Apply +revert.text=Revert +cancel.text=Cancel +prefsChanged.title=Prefs changed +prefsChanged.message=You have made changes to\nyour preferences for {0}.\n\nApply (keep) your changes? Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action_de.properties (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/action_de.properties) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action_de.properties (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/action_de.properties 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,29 @@ +# JAPI - (Yet another (hopefully) useful) Java API +# +# Copyright (C) 2004-2006 Christian Hujer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# + + +help.text=Hilfe +defaults.text=Voreinstellungen +ok.text=Ok +apply.text=Anwenden +revert.text=Zur\xFCcksetzen +cancel.text=Abbrechen +prefsChanged.title=Voreinstellungen ge\xE4ndert +prefsChanged.message=Sie haben Ihre Einstellungen\nzu {0} ge\xE4ndert.\n\n\xC4nderungen anwenden (behalten)? Copied: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/package.html (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/package.html) =================================================================== --- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/package.html (rev 0) +++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/package.html 2006-10-14 12:50:10 UTC (rev 188) @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JAPI - (Yet another (hopefully) useful) Java API + - + - Copyright (C) 2004-2006 Christian Hujer + - + - This program is free software; you can redistribute it and/or + - modify it under the terms of the GNU General Public License as + - published by the Free Software Foundation; either version 2 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, but + - WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + - General Public License for more details. + - + - You should have received a copy of the GNU General Public License + - along with this program; if not, write to the Free Software + - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + - 02111-1307, USA. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> + <title>net.sf.japi.swing.prefs</title> + </head> + <body> + <p> + This package contains useful Swing extension classes about handling user interfaces to user preferences. + </p> + <p> + The recommended way in using this package is: + </p> + <ol> + <li> + Create instances of {@link net.sf.japi.swing.prefs.Prefs} + <p /> + For this, you can do either or both: + <ul> + <li>subclass {@link net.sf.japi.swing.prefs.AbstractPrefs}</li> + <li>implement {@link net.sf.japi.swing.prefs.Prefs}</li> + </ul> + The most important methods of {@link net.sf.japi.swing.prefs.Prefs} are {@link net.sf.japi.swing.prefs.Prefs#isChanged()}, + {@link net.sf.japi.swing.prefs.Prefs#defaults()}, {@link net.sf.japi.swing.prefs.Prefs#revert()} and + {@link net.sf.japi.swing.prefs.Prefs#apply()}. + You implement these methods to get notified about the user's wishes about his / her input. + </li> + <li> + Create a {@link net.sf.japi.swing.prefs.PreferencesGroup} that contains these Prefs objects. + </li> + <li> + Invoke + {@link net.sf.japi.swing.prefs.PreferencesPane#showPreferencesDialog(java.awt.Component,net.sf.japi.swing.prefs.PreferencesGroup,boolean)} + to let the user change the preferences. + </li> + </ol> + </body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-14 12:49:47
|
Revision: 187 http://svn.sourceforge.net/japi/?rev=187&view=rev Author: christianhujer Date: 2006-10-14 05:49:23 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Copied action classes from historic to swing-action subproject. Added Paths: ----------- libs/swing-action/trunk/src/ libs/swing-action/trunk/src/net/ libs/swing-action/trunk/src/net/sf/ libs/swing-action/trunk/src/net/sf/japi/ libs/swing-action/trunk/src/net/sf/japi/swing/ libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java libs/swing-action/trunk/src/net/sf/japi/swing/ActionMethod.java libs/swing-action/trunk/src/net/sf/japi/swing/ActionProvider.java libs/swing-action/trunk/src/net/sf/japi/swing/DisposeAction.java libs/swing-action/trunk/src/net/sf/japi/swing/DummyAction.java libs/swing-action/trunk/src/net/sf/japi/swing/NamedActionMap.java libs/swing-action/trunk/src/net/sf/japi/swing/ReflectionAction.java libs/swing-action/trunk/src/net/sf/japi/swing/ToggleAction.java Copied: libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/ActionFactory.java) =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java (rev 0) +++ libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java 2006-10-14 12:49:23 UTC (rev 187) @@ -0,0 +1,1099 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.lang.reflect.Field; +import java.text.MessageFormat; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import static java.util.ResourceBundle.getBundle; +import java.util.WeakHashMap; +import java.util.ArrayList; +import java.util.prefs.Preferences; +import static java.util.prefs.Preferences.userNodeForPackage; +import javax.swing.AbstractAction; +import javax.swing.Action; +import static javax.swing.Action.ACCELERATOR_KEY; +import static javax.swing.Action.LONG_DESCRIPTION; +import static javax.swing.Action.MNEMONIC_KEY; +import static javax.swing.Action.NAME; +import static javax.swing.Action.SHORT_DESCRIPTION; +import static javax.swing.Action.SMALL_ICON; +import javax.swing.ActionMap; +import javax.swing.Icon; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JToolBar; +import javax.swing.JPopupMenu; +import static javax.swing.KeyStroke.getKeyStroke; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import static net.sf.japi.swing.IconManager.getDefaultIconManager; +import static net.sf.japi.swing.ReflectionAction.REFLECTION_MESSAGE_PROVIDER; +import static net.sf.japi.swing.ReflectionAction.REFLECTION_TARGET; +import static net.sf.japi.swing.ToggleAction.REFLECTION_PROPERTY_NAME; + +/** Class for creating and initializing {@link Action}s that are localized, user configurable and may invoke their final methods using Reflection; + * also handles extremely much useful stuff for i18n/l10n. + * It is meant as a general service for creating Action objects that have some comfort for the programmer in several aspects: + * <ul> + * <li>Allow zero or more ResourceBundles to be used when creating Actions</li> + * <li>Allow zero or more UserPreferences to be used when creating Actions</li> + * <li>Manage an ActionMap to which created Actions are automatically added</li> + * </ul> + * You may choose to use one or more ActionFactories, depending on the size of your application. + * You may use to spread Action configuration information accross one or more ResourceBundles and one or more Preferences, as you wish. + * When looking for values, the Preferences are queried first, in addition order, after that the ResourceBundles, again in addition order, until + * a value was found. The behaviour when no value was found is undefined. + * <h3>Usage</h3> + * The recommended usage is to + * <ol> + * <li> + * create and initialize an ActionFactory similar as the following example code, put it somewhere at the start of your program: + * <pre> + * ActionFactory myActionFactory = ActionFactory.getFactory("MyApplication"); + * myActionFactory.addBundle("com.mycompany.mypackage.myresource"); // not always required + * myActionFactory.addPref(MyClass.class); + * </pre> + * </li> + * <li> + * then use the ActionFactory from anywhere within the application like this: + * <pre> + * ActionFactory myActionFactory = ActionFactory.getFactory("MyApplication"); + * Action myAction = myActionFactory.createAction("load", this); + * </pre> + * </li> + * </ol> + * <p> + * All actions created or initialized by an instance of this class are optionally put into that instance's {@link ActionMap}. + * If they are stored, you can use that map for later retrieval. + * </p> + * <h4>Usage Notes: Factory Name</h4> + * <ul> + * <li> + * The factory name is used to try to load a resource bundle when a bundle is created. + * The factory name is used as package name for the bundle, the bundle name itself is "action". + * Example: When calling <code>ActionFactory.getFactory("net.sf.japi.swing");</code> for the first time, it is tried to load a + * {@link ResourceBundle} named <code>net.sf.japi.swing.actions</code> for that <code>ActionFactory</code>. + * This automatism has been implemented to save you from the need of initializing an ActionFactory before use. + * </li> + * </ul> + * <h4>Usage Notes: Action Key / Action Name</h4> + * The key you supply as first argument of {@link #createAction(boolean, String, Object)} determines several things: + * <ul> + * <li>The base name for the different keys in the preferences / resource bundle and other known Action Keys: + * <table border="1"> + * <tr><th>What</th><th>Preferences / Bundle key</th><th>Action key if stored in an action</th></tr> + * <tr><td>An (somewhat unique) ID</td><td>(<var>basename</var> itself)</td><td>{@link #ACTION_ID}</td></tr> + * <tr><td>The icon</td><td><code><var>basename</var> + ".icon"</code></td><td>{@link Action#SMALL_ICON}</td></tr> + * <tr><td>The tooltip help</td><td><code><var>basename</var> + ".shortdescription"</code></td><td>{@link Action#SHORT_DESCRIPTION}</td></tr> + * <tr><td>The long help</td><td><code><var>basename</var> + ".longdescription"</code></td><td>{@link Action#LONG_DESCRIPTION}</td></tr> + * <tr><td>The text label</td><td><code><var>basename</var> + ".text"</code></td><td>{@link Action#NAME}</td></tr> + * <tr><td>The keyboard accelerator</td><td><code><var>basename</var> + ".accel"</code></td><td>{@link Action#ACCELERATOR_KEY}</td></tr> + * <tr><td>The alternate keyboard accelerator</td><td><code><var>basename</var> + ".accel2"</code></td><td>{@link #ACCELERATOR_KEY_2}</td></tr> + * <tr><td>The mnemonic</td><td><code><var>basename</var> + ".mnemonic"</code></td><td>{@link Action#MNEMONIC_KEY}</td></tr> + * <tr><td>The method name</td><td></td><td>{@link ReflectionAction#REFLECTION_METHOD_NAME}</td></tr> + * <tr><td>The method</td><td></td><td>{@link ReflectionAction#REFLECTION_METHOD}</td></tr> + * <tr><td>The boolean property name</td><td></td><td>{@link ToggleAction#REFLECTION_PROPERTY_NAME}</td></tr> + * <tr><td>The target instance</td><td></td><td>{@link ReflectionAction#REFLECTION_TARGET}</td></tr> + * <tr><td>Exception handler dialogs</td><td><code><var>basename</var> + ".exception." + <var>exception class name</var> + ...</code><br/>The message can be formatted with 1 parameter that will be the localized message of the thrown exception.</td><td>n/a</td></tr> + * </table> + * </li> + * </ul> + * <p>Some methods are not related to actions, yet take base keys:</p> + * <ul> + * <li>The methods for dialogs, e.g. {@link #showMessageDialog(Component, String, Object...)}: + * <table border="1"> + * <tr><th>What</th><th>Preferences / Bundle key</th></tr> + * <tr><td>Dialog title</td><td><code><var>basename</var> + ".title"</code></td></tr> + * <tr><td>Dialog message</td><td><code><var>basename</var> + ".message"</code></td></tr> + * <tr><td>Dialog messagetype </td><td><code><var>basename</var> + ".messagetype"</code><br/>The message type should be one of the message types defined in {@link JOptionPane}, e.g. {@link JOptionPane#PLAIN_MESSAGE}.</td></tr> + * </table> + * </li> + * </ul> + * <h4>Final Notes</h4> + * <ul> + * <li> + * If by having read all this you think it might often be a good idea to use a package name as a factory name: this is completely right and the + * most common way of using an ActionFactory. + * </li> + * <li> + * If you think you're too lazy to hold your own ActionFactory reference and instead more often call {@link #getFactory(String)}, just go ahead + * and do so. + * Looking up created ActionFactories is extremely fast, and of course they are initialized exactly once, not more. + * </li> + * </ul> + * @see AbstractAction + * @see Action + * @see Preferences + * @see ResourceBundle + * @todo think about toolbar interaction + * @todo think about toolbar configuration + * @todo eventually rename this ActionBuilder and provide an ActionBuilderFactory. + * @todo whether a dialog is a onetime dialog should be a property and user configurable + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class ActionFactory { + + /** The key used for storing a somewhat unique id for this Action. */ + @NotNull public static final String ACTION_ID = "ActionID"; + + /** The key used for storing an alternative accelerator for this Action. + * Currently unused. + */ + @NotNull public static final String ACCELERATOR_KEY_2 = "AcceleratorKey2"; + + /** The ActionFactories. */ + @NotNull private static final Map<String, ActionFactory> FACTORIES = new WeakHashMap<String, ActionFactory>(); + + /** The parent ActionFactories. */ + @NotNull private final List<ActionFactory> parents = new LinkedList<ActionFactory>(); + + /** The ResourceBundles to look for. + * Type: ResourceBundle + */ + @NotNull private final List<ResourceBundle> bundles = new LinkedList<ResourceBundle>(); + + /** The Preferences to look for. + * Type: Preferences + */ + @NotNull private final List<Preferences> prefs = new LinkedList<Preferences>(); + + /** The ActionMap to which created Actions are automatically added. */ + @NotNull private final ActionMap actionMap = new NamedActionMap(); + + private List<ActionProvider> actionProviders = new ArrayList<ActionProvider>(); + + /** Get an ActionFactory. + * If there is no ActionFactory with name <var>key</var>, a new ActionFactory is created and stored. + * Future invocations of this method will constantly return that ActionFactory unless the key is garbage collected. + * If you must prevent the key from being garbage collected (and with it the ActionFactory), you may internalize the key ({@link String#intern()}). + * A good name for a key is the application or package name. + * The <code><var>key</var></code> may be a package name, in which case it is tried to load a {@link ResourceBundle} named "action" from that + * package and add it ({@link #addBundle(ResourceBundle)}); nothing special happens if that fails. + * @param key name of ActionFactory (which even may be <code>null</code> if you are too lazy to invent a key) + * @return ActionFactory for given key. The factory is created in case it didn't already exist. + */ + @NotNull public static ActionFactory getFactory(@Nullable final String key) { + ActionFactory factory = FACTORIES.get(key); + if (factory == null) { + factory = new ActionFactory(); + FACTORIES.put(key, factory); + try { + factory.addBundle(key + ".action"); + } catch (final MissingResourceException e) { + /* ignore */ + } + // eventually initialize factory here + } + return factory; + } + + /** Add a ResourceBundle to the list of used bundles. + * @param baseName the base name of the resource bundle, a fully qualified class name + * @see ResourceBundle#getBundle(String) + */ + public void addBundle(@NotNull final String baseName) { + //noinspection ConstantConditions + if (baseName == null) { + throw new NullPointerException("null bundle name not allowed"); + } + @NotNull final ResourceBundle newBundle = getBundle(baseName); + addBundle(newBundle); + @Nullable final String additionalBundles = newBundle.getString("ActionFactory.additionalBundles"); + if (additionalBundles != null) { + for (final String additionalBundle : additionalBundles.split("\\s+")) { + addBundle(additionalBundle); + } + } + } + + /** Method to find the JMenuItem for a specific Action. + * @param menuBar JMenuBar to search + * @param action Action to find JMenuItem for + * @return JMenuItem for action or <code>null</code> if none found + * @throws NullPointerException if <var>action</var> or <var>menuBar</var> is <code>null</code> + */ + @Nullable public static JMenuItem find(@NotNull final JMenuBar menuBar, @NotNull final Action action) { + //noinspection ConstantConditions + if (menuBar == null) { + throw new NullPointerException("null JMenuBar not allowed"); + } + //noinspection ConstantConditions + if (action == null) { + throw new NullPointerException("null Action not allowed"); + } + for (int i = 0; i < menuBar.getMenuCount(); i++) { + final JMenu menu = menuBar.getMenu(i); + if (menu.getAction() == action) { + return menu; + } else { + final JMenuItem ret = find(menu, action); + if (ret != null) { + return ret; + } + } + } + return null; + } + + /** Method to find the JMenuItem for a specific Action. + * @param menu JMenu to search + * @param action Action to find JMenuItem for + * @return JMenuItem for action or <code>null</code> if none found + * @throws NullPointerException if <var>menu</var> or <var>action</var> is <code>null</code> + */ + @Nullable public static JMenuItem find(@NotNull final JMenu menu, @NotNull final Action action) { + for (int i = 0; i < menu.getItemCount(); i++) { + final JMenuItem item = menu.getItem(i); + if (item == null) { + // Ignore Separators + } else if (item.getAction() == action) { + return item; + } else if (item instanceof JMenu) { + final JMenuItem ret = find((JMenu) item, action); + if (ret != null) { + return ret; + } + } + } + return null; + } + + /** Create an ActionFactory. + * This constructor is private to force users to use the method {@link #getFactory(String)} for recycling ActionFactories and profit of easy + * access to the same ActionFactory from within the whole application without passing around ActionFactory references. + */ + private ActionFactory() { + } + + /** Get the ActionMap. + * @return ActionMap + */ + @NotNull public ActionMap getActionMap() { + return actionMap; + } + + /** Add a ResourceBundle to the list of used bundles. + * @param bundle ResourceBundle to add + * @throws NullPointerException if <code>bundle == null</code> + */ + public void addBundle(@NotNull final ResourceBundle bundle) throws NullPointerException { + //noinspection ConstantConditions + if (bundle == null) { + throw new NullPointerException("null ResourceBundle not allowed"); + } + if (!bundles.contains(bundle)) { + // insert first because new bundles override old bundles + bundles.add(0, bundle); + } + } + + /** Add a parent to the list of used parents. + * @param parent Parent to use if lookups failed in this ActionFactory + * WARNING: Adding a descendents as parents of ancestors or vice versa will result in endless recursion and thus stack overflow! + * @throws NullPointerException if <code>parent == null</code> + */ + public void addParent(@NotNull final ActionFactory parent) throws NullPointerException { + //noinspection ConstantConditions + if (parent == null) { + throw new NullPointerException("null ActionFactory not allowed"); + } + parents.add(parent); + } + + /** Add a Preferences to the list of used preferences. + * @param pref Preferences to add + * @throws NullPointerException if <code>pref == null</code> + */ + public void addPref(@NotNull final Preferences pref) throws NullPointerException { + //noinspection ConstantConditions + if (pref == null) { + throw new NullPointerException("null ResourceBundle not allowed"); + } + if (!prefs.contains(pref)) { + prefs.add(pref); + } + } + + /** Add a Preferences to the list of used preferences. + * @param clazz the class whose package a user preference node is desired + * @see Preferences#userNodeForPackage(Class) + * @throws NullPointerException if <code>clazz == null</code> + */ + public void addPref(@NotNull final Class<?> clazz) { + //noinspection ConstantConditions + if (clazz == null) { + throw new NullPointerException("null Class not allowed"); + } + addPref(userNodeForPackage(clazz)); + } + + /** Creates actions. + * This is a loop variant of {@link #createAction(boolean,String)}. + * The actions created can be retrieved using {@link #getAction(String)} or via the ActionMap returned by {@link #getActionMap()}. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param keys Keys of actions to create + * @return Array with created actions + * @throws NullPointerException in case keys is or contains <code>null</code> + */ + public Action[] createActions(final boolean store, @NotNull final String... keys) throws NullPointerException { + final Action[] actions = new Action[keys.length]; + for (int i = 0; i < keys.length; i++) { + actions[i] = createAction(store, keys[i]); + } + return actions; + } + + /** Create an Action. + * The created Action is automatically stored together with all other Actions created by this Factory instance in an ActionMap, which you can + * retreive using {@link #getActionMap()}. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param key Key for Action, which is used as basename for access to Preferences and ResourceBundles and as ActionMap key (may not be + * <code>null</code>) + * @return created Action, which is a dummy in the sense that its {@link Action#actionPerformed(ActionEvent)} method does not do anything + * @throws NullPointerException in case <var>key</var> was <code>null</code> + * @see #createAction(boolean,String,Object) + * @see #createToggle(boolean,String,Object) + * @see #initAction(boolean,Action,String) + */ + public Action createAction(final boolean store, @NotNull final String key) throws NullPointerException { + // initAction() checks for null key + return initAction(store, new DummyAction(), key); + } + + /** Initialize an Action. + * This is a convenience method for Action users which want to use the services provided by this {@link ActionFactory} class but need more + * sophisticated Action objects they created on their own. + * So you can simply create an Action and pass it to this Initialization method to fill its data. + * The initialized Action is automatically stored together with all other Actions created by this Factory instance in an ActionMap, which you can + * retreive using {@link #getActionMap()}. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param action Action to fill + * @param key Key for Action, which is used as basename for access to Preferences and ResourceBundles and as ActionMap key (may not be <code>null</code>) + * @return the supplied Action object (<var>action</var>) is returned for convenience + * @throws NullPointerException in case <var>key</var> was <code>null</code> + */ + @SuppressWarnings({"NestedAssignment"}) + public Action initAction(final boolean store, @NotNull final Action action, @NotNull final String key) throws NullPointerException { + if (key == null) { throw new NullPointerException("null key for Action initialization not allowed."); } + action.putValue(ACTION_ID, key); + String value; + if ((value = getString(key + ".text" )) != null) { action.putValue(NAME, value); } + if ((value = getString(key + ".shortdescription")) != null) { action.putValue(SHORT_DESCRIPTION, value); } + if ((value = getString(key + ".longdescription" )) != null) { action.putValue(LONG_DESCRIPTION, value); } + if ((value = getString(key + ".accel" )) != null) { action.putValue(ACCELERATOR_KEY, getKeyStroke(value)); } + if ((value = getString(key + ".accel2" )) != null) { action.putValue(ACCELERATOR_KEY_2, getKeyStroke(value)); } + if ((value = getString(key + ".mnemonic" )) != null) { action.putValue(MNEMONIC_KEY, getKeyStroke(value).getKeyCode()); } + if ((value = getString(key + ".icon" )) != null) { + final Icon image = getDefaultIconManager().getIcon(value); + if (image != null) { action.putValue(SMALL_ICON, image); } + } + action.putValue(REFLECTION_MESSAGE_PROVIDER, this); + if (store) { + actionMap.put(key, action); + } + return action; + } + + /** Get a String. + * First looks one pref after another, in their addition order. + * Then looks one bundle after another, in their addition order. + * @param key Key to get String for + * @return the first value found or <code>null</code> if no value could be found + * @throws NullPointerException if <var>key</var> is <code>null</code> + */ + @Nullable public String getString(@NotNull final String key) throws NullPointerException { + if (key == null) { + throw new NullPointerException("null key not allowed"); + } + String value = null; + for (final Preferences pref : prefs) { + value = pref.get(key, value); + if (value != null) { + return value; + } + } + for (final ResourceBundle bundle : bundles) { + try { + value = bundle.getString(key); + return value; + } catch (final MissingResourceException e) { /* ignore */ + } catch (final ClassCastException e) { /* ignore */ + } // ignore exceptions because they don't mean errors just there's no resource, so parents are checked or null is returned. + } + for (final ActionFactory parent : parents) { + value = parent.getString(key); + if (value != null) { + return value; + } + } + return null; + } + + /** Get a String from the preferences, ignoring the resource bundles. + * @param key Key to get String for + * @return the first value found or <code>null</code> if no value could be found + * @throws NullPointerException if <var>key</var> is <code>null</code> + */ + @Nullable public String getStringFromPrefs(@NotNull final String key) throws NullPointerException { + if (key == null) { + throw new NullPointerException("null key not allowed"); + } + String value = null; + for (final Preferences pref : prefs) { + value = pref.get(key, value); + if (value != null) { + return value; + } + } + for (final ActionFactory parent : parents) { + value = parent.getStringFromPrefs(key); + if (value != null) { + return value; + } + } + return null; + } + + /** Get a String from the resource bundles, ignoring the preferences. + * @param key Key to get String for + * @return the first value found or <code>null</code> if no value could be found + * @throws NullPointerException if <var>key</var> is <code>null</code> + */ + @Nullable public String getStringFromBundles(@NotNull final String key) throws NullPointerException { + if (key == null) { + throw new NullPointerException("null key not allowed"); + } + String value; + for (final ResourceBundle bundle : bundles) { + try { + value = bundle.getString(key); + return value; + } catch (final MissingResourceException e) { /* ignore */ + } catch (final ClassCastException e) { /* ignore */ + } // ignore exceptions because they don't mean errors just there's no resource, so parents are checked or null is returned. + } + for (final ActionFactory parent : parents) { + value = parent.getStringFromBundles(key); + if (value != null) { + return value; + } + } + return null; + } + /** Creates actions. + * This is a loop variant of {@link #createAction(boolean,String,Object)}. + * The actions created can be retrieved using {@link #getAction(String)} or via the ActionMap returned by {@link #getActionMap()}. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param target Target object + * @param keys Keys of actions to create + * @return Array with created actions + * @throws NullPointerException in case keys is or contains <code>null</code> + */ + public Action[] createActions(final boolean store, final Object target, final String... keys) throws NullPointerException { + final Action[] actions = new Action[keys.length]; + for (int i = 0; i < keys.length; i++) { + actions[i] = createAction(store, keys[i], target); + } + return actions; + } + + /** Create an Action. + * The created Action is automatically stored together with all other Actions created by this Factory instance in an ActionMap, which you can + * retreive using {@link #getActionMap()}. + * The supplied object needs to have a zero argument method named <var>key</var>. + * You may pass <code>null</code> as object, which means that the object the method is invoked on is not defined yet. + * You may safely use the Action, it will not throw any Exceptions upon {@link Action#actionPerformed(ActionEvent)} but simply silently do nothing. + * The desired object can be set later using <code>action.putValue({@link ReflectionAction#REFLECTION_TARGET}, <var>object</var>)</code>. + * <p /> + * Users of this method can assume that the returned object behaves quite like {@link ReflectionAction}. + * Wether or not this method returns an instance of {@link ReflectionAction} should not be relied on. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param key Key for Action, which is used as basename for access to Preferences and ResourceBundles, as ActionMap key and as Reflection Method + * name within the supplied object (may not be <code>null</code>) + * @param object Instance to invoke method on if the Action was activated ({@link Action#actionPerformed(ActionEvent)}) + * @return created Action + * @throws NullPointerException in case <var>key</var> was <code>null</code> + * @see #createAction(boolean,String) + * @see #createToggle(boolean,String,Object) + * @see #initAction(boolean,Action,String) + */ + public Action createAction(final boolean store, final String key, final Object object) throws NullPointerException { + if (key == null) { throw new NullPointerException("null key for Action creation not allowed."); } + final Action action = new ReflectionAction(key, object); + initAction(store, action, key); + return action; + } + + /** Method for creating a Menu. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param menuKey action key for Menu + * @param keys Action keys for menu items + * @return menu created from the menu definition found + * @throws Error in case action definitions for <var>keys</var> weren't found + */ + public JMenu createMenu(final boolean store, final String menuKey, final String... keys) throws Error { + final JMenu menu = new JMenu(createAction(store, menuKey)); + for (final String key : keys) { + if (key != null && key.length() == 0) { + /* ignore this for empty menus */ + } else if (key == null || "-".equals(key) || "|".equals(key)) { + menu.addSeparator(); + } else { + final Action action = getAction(key); + if (action == null) { + throw new Error("No Action for key " + key); + } + if (action instanceof ToggleAction) { + menu.add(((ToggleAction) action).createCheckBoxMenuItem()); + } else { + menu.add(action); + } + } + } + return menu; + } + + /** Get an Action. + * For an action to be retrieved with this method, it must have been initialized with {@link #initAction(boolean,Action,String)}, either directly by + * invoking {@link #initAction(boolean,Action,String)} or indirectly by invoking one of this class' creation methods like {@link #createAction(boolean,String)}, + * {@link #createAction(boolean,String,Object)} or {@link #createToggle(boolean,String,Object)}. + * @param key Key of action to get + * @return Action for <var>key</var> + * This method does the same as <code>getActionMap().get(key)</code>. + */ + public Action getAction(final String key) { + Action action = actionMap.get(key); + if (action == null) { + for (final ActionProvider actionProvider : actionProviders) { + action = actionProvider.getAction(key); + if (action != null) { + actionMap.put(key, action); + break; + } + } + } + return action; + } + + /** Method for creating a menubar. + * @param store whether to store the initialized Actions in the ActionMap of this ActionFactory + * @param barKey Action key of menu to create + * @return JMenuBar created for <var>barKey</var> + * @throws NullPointerException if no menubar definition was found + * @todo make error handling consistent (see createMenu and others) + */ + @NotNull public JMenuBar createMenuBar(final boolean store, final String barKey) throws NullPointerException { + final JMenuBar menuBar = new JMenuBar(); + //noinspection ConstantConditions + for (final String key : getString(barKey + ".menubar").split("\\s+")) { + menuBar.add(createMenu(store, key)); + } + return menuBar; + } + + /** Method for creating a popup menu. + * @param store whether to store the initialized Actions in the ActionMap of this ActionFactory + * @param popupKey Action key of popup menu to create + * @return JPopupMenu created for <var>popupKey</var> + * @throws NullPointerException if no menubar definition was found + * @todo make error handling consistent (see createMenu and others) + */ + @NotNull public JPopupMenu createPopupMenu(final boolean store, final String popupKey) throws NullPointerException { + final JPopupMenu menu = new JPopupMenu(); + for (final String key : getString(popupKey + ".menu").split("\\s+")) { + if (key != null && key.length() == 0) { + /* ignore this for empty menus */ + } else if (key == null || "-".equals(key) || "|".equals(key)) { + menu.addSeparator(); + } else if (getString(key + ".menu") != null) { + menu.add(createMenu(store, key)); + } else { + final Action action = getAction(key); + if (action == null) { + throw new Error("No Action for key " + key); + } + if (action instanceof ToggleAction) { + menu.add(((ToggleAction) action).createCheckBoxMenuItem()); + } else { + menu.add(action); + } + } + } + return menu; + } + + /** Method for creating a Menu. + * This method assumes that the underlying properties contain an entry like <code>key + ".menu"</code> which lists the menu element's keys. + * Submenus are build recursively. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param menuKey action key for menu + * @return menu created from the menu definition found + * @throws Error in case a menu definition for <var>menuKey</var> wasn't found + */ + public JMenu createMenu(final boolean store, final String menuKey) throws Error { + final JMenu menu = new JMenu(createAction(store, menuKey)); + for (final String key : getString(menuKey + ".menu").split("\\s+")) { + if (key != null && key.length() == 0) { + /* ignore this for empty menus */ + } else if (key == null || "-".equals(key) || "|".equals(key)) { + menu.addSeparator(); + } else if (getString(key + ".menu") != null) { + menu.add(createMenu(store, key)); + } else { + final Action action = getAction(key); + if (action == null) { + throw new Error("No Action for key " + key); + } + if (action instanceof ToggleAction) { + menu.add(((ToggleAction) action).createCheckBoxMenuItem()); + } else { + menu.add(action); + } + } + } + return menu; + } + + /** Method for creating a menubar. + * @param store whether to store the initialized Actions in the ActionMap of this ActionFactory + * @param barKey Action key of menu to create + * @param target Target object + * @return JMenuBar created for <var>barKey</var> + */ + public JMenuBar createMenuBar(final boolean store, final String barKey, final Object target) { + final JMenuBar menuBar = new JMenuBar(); + final String menuBarSpec = getString(barKey + ".menubar"); + if (menuBarSpec == null) { + throw new RuntimeException("Missing Resource for " + barKey + ".menubar"); + } + for (final String key : menuBarSpec.split("\\s+")) { + menuBar.add(createMenu(store, key, target)); + } + return menuBar; + } + + /** Method for creating a popup menu. + * @param store whether to store the initialized Actions in the ActionMap of this ActionFactory + * @param popupKey Action key of popup menu to create + * @param target Target object + * @return JPopupMenu created for <var>barKey</var> + */ + public JPopupMenu createPopupMenu(final boolean store, final String popupKey, final Object target) { + final JPopupMenu menu = new JPopupMenu(); + for (final String key : getString(popupKey + ".menu").split("\\s+")) { + if (key != null && key.length() == 0) { + /* ignore this for empty menus */ + } else if (key == null || "-".equals(key) || "|".equals(key)) { + menu.addSeparator(); + } else if (getString(key + ".menu") != null) { + menu.add(createMenu(store, key, target)); + } else { + Action action = null; + if (store) { + action = getAction(key); + } + if (action == null) { + action = createAction(store, key, target); + } + if (action == null) { + throw new Error("No Action for key " + key); + } + if (action instanceof ToggleAction) { + menu.add(((ToggleAction) action).createCheckBoxMenuItem()); + } else { + menu.add(action); + } + } + } + return menu; + } + + /** Method for creating a Menu. + * This method assumes that the underlying properties contain an entry like <code>key + ".menu"</code> which lists the menu element's keys. + * Submenus are build recursively. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param menuKey action key for menu + * @param target Target object + * @return menu created from the menu definition found + * @throws Error in case a menu definition for <var>menuKey</var> wasn't found + */ + public JMenu createMenu(final boolean store, final String menuKey, final Object target) throws Error { + final JMenu menu = new JMenu(createAction(store, menuKey)); + for (final String key : getString(menuKey + ".menu").split("\\s+")) { + if (key != null && key.length() == 0) { + /* ignore this for empty menus */ + } else if (key == null || "-".equals(key) || "|".equals(key)) { + menu.addSeparator(); + } else if (getString(key + ".menu") != null) { + menu.add(createMenu(store, key, target)); + } else { + Action action = null; + if (store) { + action = getAction(key); + } + if (action == null) { + action = createAction(store, key, target); + } + if (action == null) { + throw new Error("No Action for key " + key); + } + if (action instanceof ToggleAction) { + menu.add(((ToggleAction) action).createCheckBoxMenuItem()); + } else { + menu.add(action); + } + } + } + return menu; + } + + /** Creates actions. + * This is a loop variant of {@link #createToggle(boolean,String,Object)}. + * The actions created can be retrieved using {@link #getAction(String)} or via the ActionMap returned by {@link #getActionMap()}. + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param target Target object + * @param keys Keys of actions to create + * @throws NullPointerException in case <var>keys</var> was or contained <code>null</code> + */ + public void createToggles(final boolean store, final Object target, final String... keys) throws NullPointerException { + for (final String key : keys) { + createToggle(store, key, target); + } + } + + /** Create an Action. + * The created Action is automatically stored together with all other Actions created by this Factory instance in an ActionMap, which you can + * retreive using {@link #getActionMap()}. + * The supplied object needs to have a boolean return void argument getter method and a void return boolean argument setter method matching the + * <var>key</var>. + * You may pass <code>null</code> as object, which means that the object the getters and setters are invoked on is not defined yet. + * You may safely use the Action, it will not throw any Exceptions upon {@link Action#actionPerformed(ActionEvent)} but simply silently do nothing. + * The desired object can be set later using <code>action.putValue({@link ToggleAction#REFLECTION_TARGET}, <var>object</var>)</code>. + * <p /> + * Users of this method can assume that the returned object behaves quite like {@link ToggleAction}. + * Wether or not this method returns an instance of {@link ToggleAction} shuold not be relied on. + * @see #createAction(boolean,String) + * @see #createAction(boolean,String,Object) + * @see #initAction(boolean,Action,String) + * @param store whether to store the initialized Action in the ActionMap of this ActionFactory + * @param key Key for Action, which is used as basename for access to Preferences and ResourceBundles, as ActionMap key and as Property name within + * the supplied object (may not be <code>null</code>) + * @param object Instance to invoke method on if the Action was activated ({@link Action#actionPerformed(ActionEvent)}) + * @throws NullPointerException in case <var>key</var> was <code>null</code> + * @return ToggleAction + */ + public Action createToggle(final boolean store, final String key, final Object object) throws NullPointerException { + final Action action = new ToggleAction(); + initAction(store, action, key); + action.putValue(REFLECTION_PROPERTY_NAME, key); + action.putValue(REFLECTION_TARGET, object); + return action; + } + + /** Method for creating a toolbar. + * @param keys Action keys for toolbar entries + * @return JToolBar created for <var>keys</var> + */ + public JToolBar createToolBar(final String... keys) { + final JToolBar toolBar = new JToolBar(); + for (final String key : keys) { + if (key == null || "-".equals(key) || "|".equals(key)) { + toolBar.addSeparator(); + } else { + final Action action = getAction(key); + if (action == null) { + throw new Error("No Action for key " + key); + } + toolBar.add(action); + } + } + return toolBar; + } + + /** Method for creating a toolbar. + * @param barKey Action keys of toolbar to create + * @return JToolBar created for <var>barKey</var> + */ + public JToolBar createToolBar(final String barKey) { + return createToolBar(getString(barKey + ".toolbar").split("\\s+")); + } + + /** Method for creating a toolbar. + * @param object Instance to invoke method on if the Action was activated ({@link Action#actionPerformed(ActionEvent)}) + * @param keys Action keys for toolbar entries + * @return JToolBar created for <var>keys</var> + */ + public JToolBar createToolBar(final Object object, final String... keys) { + final JToolBar toolBar = new JToolBar(); + for (final String key : keys) { + if (key == null || "-".equals(key) || "|".equals(key)) { + toolBar.addSeparator(); + } else { + Action action = getAction(key); + if (action == null) { + action = createAction(false, key, object); + } + toolBar.add(action); + } + } + return toolBar; + } + + /** Method for creating a toolbar. + * @param object Instance to invoke method on if the Action was activated ({@link Action#actionPerformed(ActionEvent)}) + * @param barKey Action keys of toolbar to create + * @return JToolBar created for <var>barKey</var> + */ + public JToolBar createToolBar(final Object object, final String barKey) { + return createToolBar(object, getString(barKey + ".toolbar").split("\\s+")); + } + + /** Method to find the JMenuItem for a specific Action key. + * @param menuBar JMenuBar to search + * @param key Key to find JMenuItem for + * @return JMenuItem for key or <code>null</code> if none found + */ + public JMenuItem find(final JMenuBar menuBar, final String key) { + return find(menuBar, getAction(key)); + } + + /** Get an icon. + * @param key i18n key for icon + * @return icon + */ + public Icon getIcon(final String key) { + return getDefaultIconManager().getIcon(getString(key)); + } + + /** Show a localized message dialog. + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param messageType the type of message to be displayed + * @param key localization key to use for the title, the message and eventually the icon + * @param args formatting arguments for the message text + * @deprecated use {@link #showMessageDialog(Component, String, Object...)} instead and put the messagetype in the action.properties file. + */ + @Deprecated public void showMessageDialog(final Component parentComponent, final int messageType, final String key, final Object... args) { + JOptionPane.showMessageDialog(parentComponent, format(key + ".message", args), format(key + ".title", args), messageType); + } + + /** Show a localized message dialog. + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param key localization key to use for the title, the message and eventually the icon + * @param args formatting arguments for the message text + */ + public void showMessageDialog(@Nullable final Component parentComponent, @NotNull final String key, final Object... args) { + JOptionPane.showMessageDialog(parentComponent, format(key + ".message", args), format(key + ".title", args), getMessageType(key)); + } + + /** Get the message type for a dialog. + * @param dialogKey dialog key + * @return message type + */ + public int getMessageType(@NotNull final String dialogKey) { + final String typeText = getString(dialogKey + ".messageType"); + if (typeText == null) { + return JOptionPane.PLAIN_MESSAGE; + } + if (!typeText.endsWith("_MESSAGE")) { + System.err.println("Warning: Illegal type value " + typeText + " for dialog " + dialogKey); // TODO: I18N/L10N + return JOptionPane.PLAIN_MESSAGE; + } + if ("PLAIN_MESSAGE".equals(typeText)) { + return JOptionPane.PLAIN_MESSAGE; + } else if ("QUESTION_MESSAGE".equals(typeText)) { + return JOptionPane.QUESTION_MESSAGE; + } else if ("WARNING_MESSAGE".equals(typeText)) { + return JOptionPane.WARNING_MESSAGE; + } else if ("INFORMATION_MESSAGE".equals(typeText)) { + return JOptionPane.INFORMATION_MESSAGE; + } else if ("ERROR_MESSAGE".equals(typeText)) { + return JOptionPane.ERROR_MESSAGE; + } else { + // key not known, try reflection. + try { + final Field f = JOptionPane.class.getField(typeText); + if (f.getType() == Integer.TYPE) { + return f.getInt(null); + } + } catch (final NoSuchFieldException e) { + System.err.println("Warning: Field " + typeText + " not found in JOptionPane (dialog: " + dialogKey + ")."); // TODO: I18N/L10N + e.printStackTrace(); //TODO + } catch (final IllegalAccessException e) { + System.err.println("Warning: Field " + typeText + " not accessible in JOptionPane (dialog: " + dialogKey + ")."); // TODO: I18N/L10N + e.printStackTrace(); //TODO + } + return JOptionPane.PLAIN_MESSAGE; + } + } + + /** Formats a message with parameters. + * It's a proxy method for using {@link MessageFormat}. + * @param key message key + * @param args parameters + * @return formatted String + * @see MessageFormat#format(String,Object...) + */ + public String format(@NotNull final String key, final Object... args) { + return MessageFormat.format(getString(key), args); + } + + /** Show a localized confirmation dialog which the user can suppress in future (remembering his choice). + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param optionType the option type + * @param messageType the type of message to be displayed + * @param key localization key to use for the title, the message and eventually the icon + * @param args formatting arguments for the message text + * @return an integer indicating the option selected by the user now or eventually in a previous choice + * @throws IllegalStateException if no preferences are associated + */ + public int showOnetimeConfirmDialog(@Nullable final Component parentComponent, final int optionType, final int messageType, @NotNull final String key, final Object... args) throws IllegalStateException { + @NonNls String showString = getString(key + ".show"); + if (showString == null) { + showString = getString(key + ".showDefault"); + } + if (showString == null) { + showString = "true"; + } + final boolean show = !"false".equalsIgnoreCase(showString); // undefined should be treated true + if (!show) { + try { + return Integer.parseInt(getString(key + ".choice")); + } catch (final Exception ignore) { + /* ignore, continue with dialog then. */ + } + } + final JCheckBox dontShowAgain = new JCheckBox(getString("dialogDontShowAgain"), true); + final int result = JOptionPane.showConfirmDialog(parentComponent, new Object[] { format(key + ".message", args), dontShowAgain }, format(key + ".title", args), optionType, messageType); + if (!dontShowAgain.isSelected()) { + if (prefs.size() > 0) { + prefs.get(0).put(key + ".show", "false"); + prefs.get(0).put(key + ".choice", Integer.toString(result)); + } else { + throw new IllegalStateException("Cannot store prefs for this dialog - no Preferences associated with this ActionFactory!"); + } + } + return result; + } + + /** Show a localized message dialog which the user can suppress in future. + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param messageType the type of message to be displayed + * @param key localization key to use for the title, the message and eventually the icon + * @param args formatting arguments for the message text + * @throws IllegalStateException if no preferences are associated + */ + public void showOnetimeMessageDialog(@Nullable final Component parentComponent, final int messageType, @NotNull final String key, final Object... args) throws IllegalStateException { + @NonNls String showString = getString(key + ".show"); + if (showString == null) { + showString = getString(key + ".showDefault"); + } + if (showString == null) { + showString = "true"; + } + final boolean show = !"false".equalsIgnoreCase(showString); // undefined should be treated true + if (show) { + final JCheckBox dontShowAgain = new JCheckBox(getString("dialogDontShowAgain"), true); + JOptionPane.showMessageDialog(parentComponent, new Object[] { format(key + ".message", args), dontShowAgain }, format(key + ".title", args), messageType); + if (!dontShowAgain.isSelected()) { + if (prefs.size() > 0) { + prefs.get(0).put(key + ".show", "false"); + } else { + throw new IllegalStateException("Cannot store prefs for this dialog - no Preferences associated with this ActionFactory!"); + } + } + } + } + + /** Show a localized question dialog. + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param key localization key to use for the title, the message and eventually the icon + * @param args formatting arguments for the message text + * @return <code>true</code> if user confirmed, otherwise <code>false</code> + */ + public boolean showQuestionDialog(final Component parentComponent, final String key, final Object... args) { + return showConfirmDialog(parentComponent, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, key, args) == JOptionPane.YES_OPTION; + } + + /** Show a localized confirmation dialog. + * @param parentComponent determines the Frame in which the dialog is displayed; if <code>null</code>, or if the <code>parentComponent</code> has + * no <code>Frame</code>, a default <code>Frame</code> is used + * @param optionType the option type + * @param messageType the type of message to be displayed + * @param key localization key to use for the title, the message and eventually the icon + * @param args formatting arguments for the message text + * @return an integer indicating the option selected by the user + */ + public int showConfirmDialog(final Component parentComponent, final int optionType, final int messageType, final String key, final Object... args) { + return JOptionPane.showConfirmDialog(parentComponent, format(key + ".message", args), format(key + ".title", args), optionType, messageType); + } + + /** Creates a label for a specified key. + * @param key Key to create label for + * @param args formatting arguments for the label text + * @return JLabel for key Key + * @note the label text will be the key if no String for the key was found + */ + public JLabel createLabel(final String key, final Object... args) { + return createLabel((Component) null, key, args); + } + + /** Creates a label for a specified key and component. + * @param component Component to associate label to (maybe <code>null</code>) + * @param key Key to create label for + * @param args formatting arguments for the label text + * @return JLabel for key Key + * @note the label text will be the key if no String for the key was found + * @todo support icons + * @todo support mnemonics + * @todo alignments and textpositions + */ + public JLabel createLabel(final Component component, final String key, final Object... args) { + final String labelText = format(key, args); + final JLabel label = new JLabel(labelText != null ? labelText : key); + label.setLabelFor(component); + return label; + } + + /** Registers an ActionProvider with this ActionFactory. + * @param actionProvider ActionProvider to register + */ + public void addActionProvider(final ActionProvider actionProvider) { + actionProviders.add(actionProvider); + } + +} // class ActionFactory Copied: libs/swing-action/trunk/src/net/sf/japi/swing/ActionMethod.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/ActionMethod.java) =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/ActionMethod.java (rev 0) +++ libs/swing-action/trunk/src/net/sf/japi/swing/ActionMethod.java 2006-10-14 12:49:23 UTC (rev 187) @@ -0,0 +1,41 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing; + +import java.lang.annotation.Documented; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** Annotation for methods that are Actions. + * {@link ActionFactory} in future will automatically configure and store Actions with properties for methods that are annotated with this Annotation. + * In future, this Annotation might get some attributes, but currently it hasn't got any. + * There is no guarantee for future attributes to be optional. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +@Documented +@Inherited +@Retention(RUNTIME) +@Target(METHOD) +public @interface ActionMethod { +} // @interface ActionMethod Copied: libs/swing-action/trunk/src/net/sf/japi/swing/ActionProvider.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/ActionProvider.java) =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/ActionProvider.java (rev 0) +++ libs/swing-action/trunk/src/net/sf/japi/swing/ActionProvider.java 2006-10-14 12:49:23 UTC (rev 187) @@ -0,0 +1,37 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You ... [truncated message content] |
From: <chr...@us...> - 2006-10-14 12:46:40
|
Revision: 186 http://svn.sourceforge.net/japi/?rev=186&view=rev Author: christianhujer Date: 2006-10-14 05:46:26 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Copied proxy preferences classes from historic to swing-proxyprefs subproject. Added Paths: ----------- libs/swing-proxyprefs/trunk/src/ libs/swing-proxyprefs/trunk/src/net/ libs/swing-proxyprefs/trunk/src/net/sf/ libs/swing-proxyprefs/trunk/src/net/sf/japi/ libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/ libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/ libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/ libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/ProxyPrefs.java libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/package.html Copied: libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/ProxyPrefs.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/proxy/ProxyPrefs.java) =================================================================== --- libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/ProxyPrefs.java (rev 0) +++ libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/ProxyPrefs.java 2006-10-14 12:46:26 UTC (rev 186) @@ -0,0 +1,50 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.prefs.proxy; + +import net.sf.japi.swing.prefs.AbstractPrefs; + +/** Proxy Configuration. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ProxyPrefs extends AbstractPrefs { + + /** {@inheritDoc} */ + public void apply() { + //TODO + } + + /** {@inheritDoc} */ + public void defaults() { + //TODO + } + + /** {@inheritDoc} */ + public boolean isChanged() { + return false; //TODO + } + + /** {@inheritDoc} */ + public void revert() { + //TODO + } + +} // class ProxyPrefs Copied: libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/package.html (from rev 181, historic/trunk/src/app/net/sf/japi/swing/prefs/proxy/package.html) =================================================================== --- libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/package.html (rev 0) +++ libs/swing-proxyprefs/trunk/src/net/sf/japi/swing/prefs/proxy/package.html 2006-10-14 12:46:26 UTC (rev 186) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JAPI - (Yet another (hopefully) useful) Java API + - + - Copyright (C) 2006 Christian Hujer + - + - This program is free software; you can redistribute it and/or + - modify it under the terms of the GNU General Public License as + - published by the Free Software Foundation; either version 2 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, but + - WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + - General Public License for more details. + - + - You should have received a copy of the GNU General Public License + - along with this program; if not, write to the Free Software + - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + - 02111-1307, USA. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> + <title>net.sf.japi.swing.prefs.proxy</title> + </head> + <body> + <p> + Proxy preferences. + </p> + </body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-14 12:44:19
|
Revision: 185 http://svn.sourceforge.net/japi/?rev=185&view=rev Author: christianhujer Date: 2006-10-14 05:44:08 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Copied tip of the day classes from historic to swing-tod subproject. Added Paths: ----------- libs/swing-tod/trunk/src/ libs/swing-tod/trunk/src/net/ libs/swing-tod/trunk/src/net/sf/ libs/swing-tod/trunk/src/net/sf/japi/ libs/swing-tod/trunk/src/net/sf/japi/swing/ libs/swing-tod/trunk/src/net/sf/japi/swing/TipOfTheDayManager.java Copied: libs/swing-tod/trunk/src/net/sf/japi/swing/TipOfTheDayManager.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/TipOfTheDayManager.java) =================================================================== --- libs/swing-tod/trunk/src/net/sf/japi/swing/TipOfTheDayManager.java (rev 0) +++ libs/swing-tod/trunk/src/net/sf/japi/swing/TipOfTheDayManager.java 2006-10-14 12:44:08 UTC (rev 185) @@ -0,0 +1,331 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; +import java.util.Random; +import java.util.ResourceBundle; +import static java.util.ResourceBundle.getBundle; +import java.util.prefs.Preferences; +import static java.util.prefs.Preferences.userNodeForPackage; +import java.io.InputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.security.PrivilegedAction; +import java.security.AccessController; +import javax.swing.Action; +import static javax.swing.Action.ACCELERATOR_KEY; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.KeyStroke; +import static javax.swing.SwingConstants.TRAILING; +import org.jetbrains.annotations.Nullable; +import static net.sf.japi.swing.ActionFactory.ACCELERATOR_KEY_2; +import static net.sf.japi.swing.IconManager.getDefaultIconManager; + +/** Class that manages tips of the day. + * The tips of the day are read from a property file. + * The name of the property file is tried to retrieve in exactly the following order: + * <ol> + * <li>The System Property <code>net.sf.japi.swing.tod</code> is queried and taken as a ResourceBundle base name.</li> + * <li>The Service file <code>META-INF/services/net.sf.japi.swing.tod</code> is read and its first line taken as a ResourceBundle base name.</li> + * </ol> + * If both fails, the behaviour is undefined. + * <p/> + * Setting the ResourceBundle for the TipOfTheDayManager via services is the preferred way, because you do not need any additional coding apart from + * invoking the TipOfTheDayManager somewhere at startup. + * <p /> + * The format of that property file follows the normal Java Properties convention, with the property keys being numbered, starting at "tod.text.1". + * Example: + * <pre># Tip Of The Days, English Version + * tod.text.1=<html>For analysis with other tools you can export the symbol map to XML, MS-Excel and CSV. + * tod.text.2=<html>For analysis with other tools you can export the mapping map to XML, MS-Excel and CSV. + * tod.text.3=<html>The supported map file formats are: Intel, GCC and MSVC. + * </pre> + * @fixme The preferences properties lastTipOfTheDayNumber and showTipOfTheDayAtStartup are stored in the wrong package, they must be stored in the client package instead of this package + * @todo Allow parametrization of properties, e.g. via a String sequence like <code>${property.name}</code>, which should then be looked up using + * a defined scheme from one or perhaps more definable {@link ActionFactory ActionFactories}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @serial exclude + */ +public final class TipOfTheDayManager extends JOptionPane { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing"); + + /** Random number generator for random tods. */ + private static final Random RND = new Random(); + + /** Preferences. */ + private static final Preferences PREFS = userNodeForPackage(TipOfTheDayManager.class); + + /** The Action keys used for accelerators. */ + private static final String[] ACCELERATOR_KEYS = new String[] { ACCELERATOR_KEY, ACCELERATOR_KEY_2 }; + + /** The static instance. */ + private static final TipOfTheDayManager INSTANCE = new TipOfTheDayManager(); + + /** JButton for close. */ + private JButton closeButton; + + /** JDialog. */ + private JDialog dialog; + + /** JCheckBox for showing at startup. */ + private JCheckBox showAtStartup = new JCheckBox(ACTION_FACTORY.createAction(false, "todShowAtStartup", null)); + + /** The JLabel showing the current number of the tod. */ + private JLabel currentTodIndex = new JLabel(); + + /** The JEditorPane displaying the tod text. */ + private JEditorPane todText = new JEditorPane("text/html", ""); + + /** List with tod texts. */ + private List<String> todTexts = new ArrayList<String>(); + + /** Number of current Tip of the day. + * In visible state, the index must range between 0 and the number of tods available - 1, inclusive. + */ + private int todIndex; + + /** Show Tip Of The Day at startup. + * This method is only a proxy for show(Component) but looks at user preferences. + * If the user chose not to see TipOfTheDays this method simply returns. + * @param parentComponent the parent component of this dialog. + */ + public static void showAtStartup(final Component parentComponent) { + if (PREFS.getBoolean("showTipOfTheDayAtStartup", true)) { + show(parentComponent); + } + } + + /** Show a Tip Of The Day. + * @param parentComponent the parent component of this dialog. + */ + public static void show(final Component parentComponent) { + if (INSTANCE.dialog == null) { + INSTANCE.dialog = INSTANCE.createDialog(parentComponent, ACTION_FACTORY.getString("tipOfTheDay.windowTitle")); + } + INSTANCE.dialog.getRootPane().setDefaultButton(INSTANCE.closeButton); + INSTANCE.dialog.setModal(false); + INSTANCE.dialog.setResizable(true); + INSTANCE.dialog.setVisible(true); + INSTANCE.closeButton.requestFocusInWindow(); + } + + /** Finds the bundle name. + * @return bundle name + */ + private static String getBundleName() { + String bundleName = System.getProperty("net.sf.japi.swing.tod"); + if (bundleName == null) { + bundleName = getServiceValue(getClassLoader()); + } + return bundleName; + } + + /** This method attempts to return the first line of the resource META_INF/services/net.sf.japi.swing.tod from the provided ClassLoader. + * @param classLoader ClassLoader, may not be <code>null</code>. + * @return first line of resource, or <code>null</code> + */ + @Nullable private static String getServiceValue(final ClassLoader classLoader) { + BufferedReader rd = null; + try { + final String serviceId = "META-INF/services/net.sf.japi.swing.tod"; + final InputStream in = getResourceAsStream(classLoader, serviceId); + if (in != null) { + try { + rd = new BufferedReader(new InputStreamReader(in, "UTF-8")); + } catch (final UnsupportedEncodingException e) { + rd = new BufferedReader(new InputStreamReader(in)); + } + return rd.readLine(); + } + } catch (final Exception e) { + /* ignore. */ + } finally { + try { rd.close(); } catch (final Exception e) { /* ignore */ } finally { rd = null; } + } + return null; + } + + /** Get a resource from a classloader as stream. + * @param classLoader ClassLoader to get resource from + * @param serviceId service file to get stream from + * @return stream for resource <var>serviceId</var> in <var>classLoader</var> + */ + private static InputStream getResourceAsStream(final ClassLoader classLoader, final String serviceId) { + return AccessController.doPrivileged(new PrivilegedAction<InputStream>() { + + /** {@inheritDoc} */ + public InputStream run() { + return classLoader == null ? + ClassLoader.getSystemResourceAsStream(serviceId) : + classLoader.getResourceAsStream(serviceId); + } + + }); + } + + /** Get the ClassLoader. + * @return ClassLoader + */ + private static ClassLoader getClassLoader() { + try { + final ClassLoader contextClassLoader = getContextClassLoader(); + if (contextClassLoader != null) { + return contextClassLoader; + } + } catch (final Exception e) { + /* ignore */ + } + return TipOfTheDayManager.class.getClassLoader(); + } + + /** Get the context ClassLoader. + * @return context ClassLoader + */ + private static ClassLoader getContextClassLoader() { + return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + + /** {@inheritDoc} */ + @Nullable public ClassLoader run() { + try { + return Thread.currentThread().getContextClassLoader(); + } catch (final SecurityException ex) { + return null; + } + } + + }); + } + + /** Constructor. */ + private TipOfTheDayManager() { + final String[] keys = { "todPrev", "todRand", "todNext", "todClose" }; + final Action[] actions = new Action[keys.length]; + final Object[] newOptions = new Object[keys.length]; + for (int i = 0; i < keys.length; i++) { + actions[i] = ACTION_FACTORY.createAction(false, keys[i], this); + newOptions[i] = new JButton(actions[i]); + if ("todClose".equals(keys[i])) { + closeButton = (JButton) newOptions[i]; + } + for (final String key : ACCELERATOR_KEYS) { + final KeyStroke ks = (KeyStroke) actions[i].getValue(key); + if (ks != null) { + getInputMap(WHEN_IN_FOCUSED_WINDOW).put(ks, keys[i]); + getActionMap().put(keys[i], actions[i]); + } + } + } + final Dimension size = new Dimension(512, 128); + showAtStartup.setSelected(PREFS.getBoolean("showTipOfTheDayAtStartup", true)); + final JScrollPane todTextScroller = new JScrollPane(todText); + todTextScroller.setMinimumSize(size); + todTextScroller.setPreferredSize(size); + todTextScroller.setFocusable(true); + todTextScroller.setAutoscrolls(true); + todText.setEditable(false); + todText.setRequestFocusEnabled(false); + currentTodIndex.setHorizontalAlignment(TRAILING); + loadTodTexts(); + setTodIndex(PREFS.getInt("lastTipOfTheDayNumber", -1) + 1); + setIcon(getDefaultIconManager().getIcon(ACTION_FACTORY.getString("tipOfTheDay.icon"))); + final JLabel heading = new JLabel(ACTION_FACTORY.getString("todHeading")); + final Font oldFont = heading.getFont(); + heading.setFont(oldFont.deriveFont((float) (oldFont.getSize2D() * 1.5))); + setMessage(new Object[] { heading, todTextScroller, currentTodIndex, showAtStartup }); + setMessageType(INFORMATION_MESSAGE); + setOptions(newOptions); + } + + /** Loads the Tip of the day texts. */ + private void loadTodTexts() { + final ResourceBundle todBundle = getBundle(getBundleName()); + for (int i = 1;; i++) { + try { + todTexts.add(todBundle.getString(new StringBuilder().append("tod.text.").append(i).toString())); + } catch (final MissingResourceException e) { + break; + } + } + } + + /** Sets the tod index. + * @param todIndex new todIndex + */ + private void setTodIndex(final int todIndex) { + try { + this.todIndex = (todIndex + todTexts.size()) % todTexts.size(); + todText.setText(todTexts.get(this.todIndex)); + currentTodIndex.setText(ACTION_FACTORY.format("todIndex", this.todIndex + 1, todTexts.size())); + } catch (final ArithmeticException e) { + todText.setText(ACTION_FACTORY.getString("todsUnavailable")); + currentTodIndex.setText(""); + } + } + + /** Returns number of current Tip of the day. + * In visible state, the index must range between 0 and the number of tods available - 1, inclusive. + * @return number of current Tip of the day. + */ + public int getTodIndex() { + return todIndex; + } + + /** Action method for close. */ + public void todClose() { + setValue(closeButton); + PREFS.putBoolean("showTipOfTheDayAtStartup", showAtStartup.isSelected()); + PREFS.putInt("lastTipOfTheDayNumber", todIndex); + dialog.setVisible(false); + dialog.dispose(); + dialog = null; + } + + /** Action method for next. */ + public void todNext() { + setTodIndex(todIndex + 1); + } + + /** Action method for previous. */ + public void todPrev() { + setTodIndex(todIndex - 1); + } + + /** Action method for random. */ + public void todRand() { + setTodIndex(RND.nextInt(todTexts.size())); + } + +} // class TipOfTheDayManager This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-14 12:43:44
|
Revision: 184 http://svn.sourceforge.net/japi/?rev=184&view=rev Author: christianhujer Date: 2006-10-14 05:43:19 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Copied bookmarks classes from historic to swing-bookmarks subproject. Added Paths: ----------- libs/swing-bookmarks/trunk/src/ libs/swing-bookmarks/trunk/src/net/ libs/swing-bookmarks/trunk/src/net/sf/ libs/swing-bookmarks/trunk/src/net/sf/japi/ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkManager.java libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferHandler.java libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferable.java libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTreeCellRenderer.java libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/Bookmarkable.java libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action.properties libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action_de.properties libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/package.html Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,84 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + + +// $Header: /cvsroot/japi/japi/src/app/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java,v 1.1 2006/03/26 01:26:25 christianhujer Exp $ + +package net.sf.japi.swing.bookmarks; + +import java.awt.Point; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.io.IOException; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import org.jetbrains.annotations.Nullable; +import static net.sf.japi.swing.bookmarks.BookmarkTransferable.getBookmarkDataFlavor; + +/** Class for dropping a bookmark over a JTree managing bookmarks. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class BookmarkDropTargetAdapter extends DropTargetAdapter { + + /** {@inheritDoc} */ + public void drop(final DropTargetDropEvent dtde) { + System.err.println("drop"); + final JTree tree = (JTree) dtde.getDropTargetContext().getComponent(); + BookmarkManager.Bookmark dest = getDestBookmark(dtde, tree); + final BookmarkManager.Bookmark src = getSourceBookmark(dtde); + int pos = -1; + if (!(dest instanceof BookmarkManager.BookmarkFolder)) { + pos = dest.getFolder().getIndex(dest); + dest = dest.getFolder(); + } + assert dest instanceof BookmarkManager.BookmarkFolder; + ((BookmarkManager.BookmarkFolder)dest).insert(src, pos); + tree.treeDidChange(); + } + + /** Find the destination bookmark for a drop event. + * @param dtde drop event + * @param tree JTree to find bookmark in + * @return destination bookmark + */ + private static BookmarkManager.Bookmark getDestBookmark(final DropTargetDropEvent dtde, final JTree tree) { + final Point p = dtde.getLocation(); + final TreePath tp = tree.getClosestPathForLocation(p.x, p.y); + return (BookmarkManager.Bookmark) tp.getLastPathComponent(); + } + + /** Find source bookmark for a drop event. + * @param dtde drop event + * @return source bookmark + */ + @Nullable private static BookmarkManager.Bookmark getSourceBookmark(final DropTargetDropEvent dtde) { + final Transferable source = dtde.getTransferable(); + try { + return (BookmarkManager.Bookmark) source.getTransferData(getBookmarkDataFlavor()); + } catch (final UnsupportedFlavorException e) { + return null; + } catch (final IOException e) { + return null; + } + } + +} // class BookmarkDropTargetAdapter Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkManager.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkManager.java) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkManager.java (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkManager.java 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,796 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.bookmarks; + +import java.awt.BorderLayout; +import java.awt.dnd.DropTarget; +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import static javax.swing.JOptionPane.ERROR_MESSAGE; +import static javax.swing.JOptionPane.QUESTION_MESSAGE; +import static javax.swing.JOptionPane.showInputDialog; +import static javax.swing.JOptionPane.showMessageDialog; +import javax.swing.JScrollPane; +import javax.swing.JToolBar; +import javax.swing.JTree; +import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.TreeNode; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.ls.DOMImplementationLS; +import org.xml.sax.SAXException; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.IconManager; +import net.sf.japi.util.EmptyEnumeration; + +/** Class for managing and displaying Bookmarks. + * Usage of this class works the following way: + * <ul> + * <li>implement the interface {@link Bookmarkable} and its methods</li> + * <li>instanciate this class once for each gruop / kind of bookmarks you want to manage. Normally, one instance is enough per application</li> + * <li>invoke {@link #createBookmarkMenu} to create your bookmarks menu</li> + * </ul> + * @author $Author: christianhujer $ + * @todo documentation + * @todo fix bookmark drag and drop indices + * @todo think about serialization of Actions + */ +public class BookmarkManager { + + /** The Bookmarks. */ + private BookmarkFolder bookmarks = new BookmarkFolder(); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.bookmarks"); + + /** The ProgramFrame this BookmarkManager manages bookmarks for. */ + private Bookmarkable bookmarkable; + + /** Create a new BookmarkManager. */ + public BookmarkManager(final Bookmarkable bookmarkable) { + this.bookmarkable = bookmarkable; + try { + load(); + save(); + } catch (final Exception e) { + e.printStackTrace(); + // TODO: improve dialog + showMessageDialog(bookmarkable.getBookmarkBlocker(), ACTION_FACTORY.getString("bookmarksCreated.message")); + } + } + + /** Create a Bookmark ToolBar. + * @return toolBar for Bookmarks + */ + public JToolBar createBookmarkToolBar() { + // Variant 1: JToolBar with JMenuBar with one entry "Lesezeichen" + final JToolBar toolBar = new JToolBar(ACTION_FACTORY.getString("bookmarkToolBar.name")); + final JMenuBar mb = new JMenuBar(); + mb.add(bookmarks.createMenu()); + toolBar.add(mb); + return toolBar; + + //// Variant 2: JToolBar with JMenus and JMenuItems (broken) + //JToolBar toolBar = new JToolBar(ACTION_FACTORY.getString("bookmarkToolBar.name")); + //for (Bookmark bookmark : bookmarks) { + // toolBar.add(bookmark.createMenu()); + //} + //return toolBar; + + //// Variant 3: JToolBar with JMenuBar with JMenus and JMenuItems (JMenuItems don't hover) + //JToolBar toolBar = new JToolBar(ACTION_FACTORY.getString("bookmarkToolBar.name")); + //JMenuBar mb = new JMenuBar(); + //for (Bookmark bookmark : bookmarks) { + // mb.add(bookmark.createMenu()); + //} + //toolBar.add(mb); + //return toolBar; + + //// Variant 4: JToolBar with a button activating a PopupMenu. + //// Doesn't work either, the popup menu is not correctly usable. + //JToolBar toolBar = new JToolBar(ACTION_FACTORY.getString("bookmarkToolBar.name")); + //final JPopupMenu menu = new JPopupMenu(ACTION_FACTORY.getString("bookmark.text")); + //menu.add(bookmarks.createMenu()); + //toolBar.add( + // new javax.swing.JButton( + // new AbstractAction() { + // public void actionPerformed(final ActionEvent e) { + // menu.setVisible(true); + // } + // } + // ) + //); + //return toolBar; + } + + /** Create a Bookmark Menu. + * @return JMenu for Bookmarks + */ + public JMenu createBookmarkMenu() { + final JMenu menu = bookmarks.createMenu(); + menu.add(new JMenuItem(manageBookmarks)); + return menu; + } + + /** Create a Bookmark ControlPanel. + * @return ControlPanel for Bookmarks + */ + public JComponent createBookmarkControlPanel() { + return new ControlPanel(); + } + + /** Recursive attach method. + * @param menu JMenu to attach bookmarks to + * @param bookmarks Bookmarks to attach + */ + private static void attach(final JMenu menu, final BookmarkFolder bookmarks) { + for (final Bookmark bookmark : bookmarks) { + if (bookmark instanceof BookmarkFolder) { + final JMenu newMenu = new JMenu(bookmark); + attach(newMenu, (BookmarkFolder) bookmark); + } else { + assert bookmark instanceof BookmarkItem; + menu.add(new JMenuItem(bookmark)); + } + } + } + + /** Action for managing the bookmarks. + * @serial include + */ + private Action manageBookmarks = ACTION_FACTORY.createAction(true, "manageBookmarks", this); + + /** Action for managing the bookmarks. */ + public void manageBookmarks() { + final JFrame f = new JFrame(ACTION_FACTORY.getString("manageBookmarks_shortdescription")); + f.getContentPane().add(createBookmarkControlPanel()); + //f.getContentPane().add(new JScrollPane(new JTree(bookmarks))); + f.pack(); + f.setVisible(true); + } + + /** Set the AddBookmark enabled state. + * @param enabled enabled state for AddBookmark action + */ + public void setAddBookmarkEnabled(final boolean enabled) { + bookmarks.setAddBookmarkEnabled(enabled); + } + + /** Load bookmarks from default file. + * @throws IOException in case of I/O problems + * @throws ParserConfigurationException in case of XML configuration problems + * @throws SAXException in case of XML document problems + */ + public void load() throws IOException, ParserConfigurationException, SAXException { + load(new File(System.getProperty("user.home"), ".jeduca.bookmarks.xml").toURL().toString()); + } + + /** Save bookmarks to default file. + * @throws IOException in case of I/O problems + * @throws ParserConfigurationException in case of XML configuration problems + */ + public void save() throws IOException, ParserConfigurationException { + save(new File(System.getProperty("user.home"), ".jeduca.bookmarks.xml").toURL().toString()); + } + + /** Save bookmarks to a file. + * @param uri URI of file to save + * @throws IOException in case of I/O problems + * @throws ParserConfigurationException in case of XML configuration problems + */ + public void save(final String uri) throws IOException, ParserConfigurationException { + final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + final DocumentBuilder db = dbf.newDocumentBuilder(); + final Document doc = db.newDocument(); + bookmarks.store(doc); + final DOMImplementation impl = doc.getImplementation(); + if (impl instanceof DOMImplementationLS) { + final DOMImplementationLS ls = (DOMImplementationLS) impl; + ls.createLSSerializer().writeToURI(doc, uri); + } + } + + /** Load bookmarks from a file. + * @param uri URI of file to load + * @throws IOException in case of I/O problems + * @throws ParserConfigurationException in case of XML configuration problems + * @throws SAXException in case of XML document problems + */ + public void load(final String uri) throws IOException, ParserConfigurationException, SAXException { + final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + final DocumentBuilder db = dbf.newDocumentBuilder(); + final Document doc = db.parse(uri); + bookmarks = new BookmarkFolder(doc); + } + + + /** Class for a ControlPanel to manage the bookmarks. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: BookmarkManager.java,v 1.2 2006/03/26 15:22:16 christianhujer Exp $ + */ + private class ControlPanel extends JComponent { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** Create a new ControlPanel. */ + ControlPanel() { + setLayout(new BorderLayout()); + final JTree tree = new JTree(bookmarks, true); + tree.setRootVisible(false); + tree.setCellRenderer(new BookmarkTreeCellRenderer()); + //tree.setEditable(true); + tree.setDragEnabled(true); + final DropTarget dt = new DropTarget(tree, new BookmarkDropTargetAdapter()); + tree.setTransferHandler(new BookmarkTransferHandler()); + add(new JScrollPane(tree)); + } + + } // class ControlPanel + + + /** Base class for bookmarks. + * There are two kinds of bookmarks: + * <ul> + * <li>{@link BookmarkItem}s for normal Bookmarks with title and url</li> + * <li>{@link BookmarkFolder}s for Folders within Bookmarks with a title and (possibly) contents</li> + * </ul> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: BookmarkManager.java,v 1.2 2006/03/26 15:22:16 christianhujer Exp $ + */ + public static abstract class Bookmark extends AbstractAction implements MutableTreeNode { + + /** Title for Bookmark. + * @serial include + */ + private String title; + + /** The folder (parent) of this bookmark. + * @serial include + */ + protected BookmarkFolder folder; + + ///** Create a Bookmark without title. + // * Should only be used by {@link BookmarkFolder#BookmarkFolder()}. + // */ + //protected Bookmark() { + //} + + /** Create a Bookmark. + * You must not forget to invoke {@link #setFolder(BookmarkFolder)} in order to make {@link #getParent()} for JTrees working. + * @param title title for Bookmark + */ + protected Bookmark(final String title) { + setTitle(title); + putValue(SMALL_ICON, IconManager.getDefaultIconManager().getIcon(ACTION_FACTORY.getString("bookmark.icon"))); + } + + /** {@inheritDoc} + * @return title of this Bookmark + */ + public String toString() { + return title; + } + + /** Get the folder (parent) of this bookmark. + * @return folder (parent) of this bookmark + */ + public BookmarkFolder getFolder() { + return folder; + } + + /** Set the folder (parent) of this bookmark. + * @param folder parent folder of this bookmark + */ + public void setFolder(final BookmarkFolder folder) { + if (this.folder != null) { + this.folder.remove(this); + } + this.folder = folder; + } + + /** Set this Bookmark's title. + * @param title new title for this Bookmark + */ + public void setTitle(final String title) { + this.title = title; + putValue(NAME, title); + } + + /** Create a MenuItem for this Bookmark + * @return MenuItem for this Bookmark + */ + public abstract JMenuItem createMenu(); + + /** Get this Bookmark's title. + * @return Bookmark title + */ + public String getTitle() { + return title; + } + + /** Store bookmarks in an XML Document. + * @param n Node (Element or Document) to attach to + */ + public abstract void store(final Node n); + + /** {@inheritDoc} */ + public Enumeration<Bookmark> children() { + return new EmptyEnumeration<Bookmark>(); + } + + /** {@inheritDoc} */ + public boolean getAllowsChildren() { + return false; + } + + /** {@inheritDoc} */ + public Bookmark getChildAt(final int childIndex) { + throw new IndexOutOfBoundsException(Integer.toString(childIndex)); + } + + /** {@inheritDoc} */ + public int getChildCount() { + return 0; + } + + /** {@inheritDoc} */ + public int getIndex(final TreeNode node) { + return 0; + } + + /** {@inheritDoc} */ + public BookmarkFolder getParent() { + return getFolder(); + } + + /** {@inheritDoc} */ + public boolean isLeaf() { + return true; + } + + /** {@inheritDoc} */ + public void insert(final MutableTreeNode child, final int index) { + throw new IllegalStateException("A bookmark cannot have children"); + } + + /** {@inheritDoc} */ + public void remove(final int index) { + throw new IllegalStateException("A bookmark has no children"); + } + + /** {@inheritDoc} */ + public void remove(final MutableTreeNode child) { + throw new IllegalStateException("A bookmark has no children"); + } + + /** {@inheritDoc} */ + public void removeFromParent() { + folder.remove(this); + } + + /** {@inheritDoc} */ + public void setParent(final MutableTreeNode newParent) { + if (newParent instanceof BookmarkFolder) { + setFolder((BookmarkFolder)newParent); + } else { + throw new IllegalArgumentException("Parent must be a BookmarkFolder, but was : " + newParent.getClass().getName()); + } + } + + /** {@inheritDoc} */ + public void setUserObject(final Object object) { + System.err.println("setUserObject was called but does not know what to do. Supplied object: " + object); + } + + } // class Bookmark + + + /** Class for Bookmark Separator. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: BookmarkManager.java,v 1.2 2006/03/26 15:22:16 christianhujer Exp $ + */ + public static class BookmarkSeparator extends Bookmark { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** Create a Bookmark Separator. */ + BookmarkSeparator() { + super("--------------------------------"); + } + + /** {@inheritDoc} + * @return always <code>null</code> + */ + @Override public JMenuItem createMenu() { + return null; + } + + /** {@inheritDoc} */ + @Override public void store(final Node n) { + final Element e = n.getOwnerDocument().createElement("separator"); + n.appendChild(e); + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + /* Do nothing */ + } + + } // class BookmarkSeparator + + + /** Class for Bookmark Items. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: BookmarkManager.java,v 1.2 2006/03/26 15:22:16 christianhujer Exp $ + */ + public class BookmarkItem extends Bookmark { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** URL of this Bookmark. + * @serial include + */ + private String url; + + /** Create a BookmarkItem. + * @param title title for this BookmarkItem + * @param url URL for this BookmarkItem + */ + public BookmarkItem(final String title, final String url) { + super(title); + setURL(url); + } + + /** Create a BookmarkItem from XML. + * @param el Element to create from + */ + BookmarkItem(final Element el) { + this(el.getAttribute("title"), el.getAttribute("href")); + } + + /** Set this BookmarkItem's url. + * @param url new url for this BookmarkItem + */ + public void setURL(final String url) { + this.url = url; + putValue(SHORT_DESCRIPTION, url); + } + + /** Get this BookmarkItem's url. + * @return BookmarkItem url + */ + public String getURL() { + return url; + } + + /** {@inheritDoc} */ + @Override public JMenuItem createMenu() { + return new JMenuItem(this); + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + bookmarkable.load(url); + } + + /** {@inheritDoc} */ + public void store(final Node n) { + final Element e = n.getOwnerDocument().createElement("bookmark"); + e.setAttribute("title", getTitle()); + e.setAttribute("href", getURL()); + n.appendChild(e); + } + + } // class BookmarkItem + + + /** Class for Bookmark folders. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @version $Id: BookmarkManager.java,v 1.2 2006/03/26 15:22:16 christianhujer Exp $ + */ + public class BookmarkFolder extends Bookmark implements Iterable<Bookmark> { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** The bookmarks in this folder. + * @serial include + */ + private List<Bookmark> bookmarks = new ArrayList<Bookmark>(); + + /** The Menus created for this folder. + * @serial include + */ + private List<JMenu> menus = new ArrayList<JMenu>(); + + /** Create a BookmarkFolder without a title. + * This should only be used for the basic BookmarkFolder containing all other BookmarkItems and BookmarkFolders. + */ + public BookmarkFolder() { + super(ACTION_FACTORY.getString("bookmark_text")); + } + + /** Create a BookmarkFolder. + * @param title title for BookmarkFolder + */ + public BookmarkFolder(final String title) { + super(title); + addBookmark.putValue(ACCELERATOR_KEY, null); + newBookmarkFolder.putValue(ACCELERATOR_KEY, null); + } + + /** Create a BookmarkFolder from XML. + * @param doc Document to create from + */ + BookmarkFolder(final Document doc) { + this(); + readNodes(doc.getDocumentElement()); + } + + /** Create a BookmarkFolder from XML. + * @param el Element to create from + */ + BookmarkFolder(final Element el) { + this(el.getAttribute("title")); + readNodes(el); + } + + /** Read nodes from XML. + * @param el XML Element to read nodes from + */ + private void readNodes(final Element el) { + final NodeList children = el.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + final Node n = children.item(i); + if (n instanceof Element) { + final Element e = (Element) n; + if ("bookmark".equals(e.getNodeName())) { + add(new BookmarkItem(e)); + } else if ("bookmarks".equals(e.getNodeName())) { + add(new BookmarkFolder(e)); + } else if ("separator".equals(e.getNodeName())) { + add(new BookmarkSeparator()); + } + } + } + } + + /** {@inheritDoc} */ + public Iterator<Bookmark> iterator() { + return bookmarks.iterator(); + } + + /** Add a Bookmark to this BookmarkFolder. + * @param bookmark Bookmark to add + */ + public void add(final Bookmark bookmark) { + final int pos = bookmarks.size(); + bookmarks.add(bookmark); + bookmark.setFolder(this); + for (JMenu menu : menus) { + menu.insert(bookmark.createMenu(), pos); + } + try { + save(); + } catch (final Exception e) { + showMessageDialog(bookmarkable.getBookmarkBlocker(), e, "Bookmarks-Fehler", ERROR_MESSAGE); + System.err.println(e); + e.printStackTrace(); + } + } + + /** Insert a Bookmark into this BookmarkFolder. + * @param bookmark Bookmark to add + * @param index desired index + */ + public void insert(final Bookmark bookmark, final int index) { + if (index < 0 || index > bookmarks.size()) { + throw new IllegalArgumentException("Invalid index: " + index + " (size: " + bookmarks.size() + ")"); + } + bookmark.setFolder(this); + bookmarks.add(index, bookmark); + for (JMenu menu : menus) { + menu.insert(bookmark.createMenu(), index); + } + try { + save(); + } catch (final Exception e) { + showMessageDialog(bookmarkable.getBookmarkBlocker(), e, "Bookmarks-Fehler", ERROR_MESSAGE); + System.err.println(e); + e.printStackTrace(); + } + } + + /** Remove a Bookmark from this BookmarkFolder. + * @param bookmark Bookmark to remove + */ + public void remove(final Bookmark bookmark) { + if (bookmarks.contains(bookmark)) { + remove(bookmarks.indexOf(bookmark)); + } else { + for (final Bookmark folder : bookmarks) { + if (folder instanceof BookmarkFolder) { + ((BookmarkFolder)folder).remove(bookmark); + } + } + } + } + + /** Remove a Bookmark from this BookmarkFolder. + * @param index Index of Bookmark to remove + */ + @Override public void remove(final int index) { + final Bookmark bookmark = bookmarks.remove(index); + bookmark.folder = null; + for (JMenu menu : menus) { + menu.remove(index); + } + } + + /** {@inheritDoc} */ + @Override public JMenu createMenu() { + final JMenu menu = new JMenu(getTitle()); + menu.setName(getTitle()); + for (Bookmark bookmark : bookmarks) { + if (bookmark instanceof BookmarkSeparator) { + menu.addSeparator(); + } else { + menu.add(bookmark.createMenu()); + } + } + menu.addSeparator(); + menu.add(new JMenuItem(addBookmark)); + menu.add(new JMenuItem(newBookmarkFolder)); + menus.add(menu); + return menu; + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + /* Do nothing */ + } + + /** Action for adding a bookmark. + * @serial include + */ + private Action addBookmark = ACTION_FACTORY.createAction(true, "addBookmark", this); + + /** Action for creating a new bookmark folder. + * @serial include + */ + private Action newBookmarkFolder = ACTION_FACTORY.createAction(true, "newBookmarkFolder", this); + + /** Add a bookmark for the currently selected Question from the currently selected QuestionCollection . */ + public void addBookmark() { + if (bookmarkable.isBookmarkPossible()) { + add(new BookmarkItem(bookmarkable.getBookmarkTitle(), bookmarkable.getBookmarkURL())); + } + } + + /** Create a new BookmarkFolder. */ + public void newBookmarkFolder() { + final String folderName = showInputDialog(bookmarkable.getBookmarkBlocker(), "Name für Lesezeichen", "Neuer Lesezeichen-Ordner", QUESTION_MESSAGE); + if (folderName == null) { + return; + } + add(new BookmarkFolder(folderName)); + } + + /** Set the AddBookmark enabled state. + * @param enabled enabled state for AddBookmark action + */ + public void setAddBookmarkEnabled(final boolean enabled) { + addBookmark.setEnabled(enabled); + for (Bookmark folder : bookmarks) { + if (folder instanceof BookmarkFolder) { + ((BookmarkFolder)folder).setAddBookmarkEnabled(enabled); + } + } + } + + /** {@inheritDoc} */ + @Override public void store(final Node n) { + final Element e = (n instanceof Document ? (Document) n : n.getOwnerDocument()).createElement("bookmarks"); + e.setAttribute("title", getTitle()); + n.appendChild(e); + for (Bookmark bookmark : bookmarks) { + bookmark.store(e); + } + } + + /** {@inheritDoc} */ + public Enumeration<Bookmark> children() { + return Collections.enumeration(bookmarks); + } + + /** {@inheritDoc} */ + @Override public boolean getAllowsChildren() { + return true; + } + + /** {@inheritDoc} */ + @Override public Bookmark getChildAt(final int childIndex) { + return bookmarks.get(childIndex); + } + + /** {@inheritDoc} */ + @Override public int getChildCount() { + return bookmarks.size(); + } + + /** {@inheritDoc} */ + @Override public int getIndex(final TreeNode node) { + return bookmarks.indexOf(node); + } + + /** {@inheritDoc} */ + @Override public boolean isLeaf() { + return false; + } + + /** {@inheritDoc} */ + @Override public void insert(final MutableTreeNode child, final int index) { + if (child instanceof Bookmark) { + insert((Bookmark)child, index); + } else { + throw new IllegalArgumentException("Children of BookmarkFolders must be instance of Bookmark but was " + child.getClass().getName()); + } + } + + ///** {@inheritDoc} */ + //public void remove(final int index) { + // remove(index); + //} + + /** {@inheritDoc} */ + @Override public void remove(final MutableTreeNode child) { + if (child instanceof Bookmark) { + remove((Bookmark)child); + } else { + throw new IllegalArgumentException("Node " + child + " not child of this BookmarkFolder."); + } + } + + } // class BookmarkFolder + +} // class BookmarkManager Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferHandler.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkTransferHandler.java) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferHandler.java (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferHandler.java 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,59 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.bookmarks; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import javax.swing.JComponent; +import javax.swing.JTree; +import javax.swing.TransferHandler; + +/** Class for DnD in Bookmarks displaying JTrees. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo improve implementation + */ +public class BookmarkTransferHandler extends TransferHandler { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** {@inheritDoc} */ + @Override + public Transferable createTransferable(final JComponent c) { + return new BookmarkTransferable((BookmarkManager.Bookmark)((JTree)c).getSelectionPath().getLastPathComponent()); + } + + /** {@inheritDoc} + * @todo correctly implement this + */ + @Override + public boolean canImport(final JComponent comp, final DataFlavor[] transferFlavors) { + // TODO + return true; + } + + /** {@inheritDoc} */ + @Override + public int getSourceActions(final JComponent c) { + return COPY_OR_MOVE; + } + +} // class BookmarkTransferHandler Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferable.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkTransferable.java) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferable.java (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTransferable.java 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,80 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.bookmarks; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; + +/** Class for transfering a bookmark through a clipboard or drag and drop. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class BookmarkTransferable implements Transferable { + + /** Data Flavor for Bookmarks. */ + private static final DataFlavor bookmarkDataFlavor = initBookmarkFlavor(); + + /** Initialize DataFlavor for Bookmarks. + * @return DataFlavor for Bookmarks + */ + private static DataFlavor initBookmarkFlavor() { + try { + return new DataFlavor("application/x-jtest-bookmark"); + } catch (ClassNotFoundException e) { + throw new Error(e); + } + } + + /** Supported DataFlavors. */ + private static DataFlavor[] flavors = { bookmarkDataFlavor }; + + /** Bookmark to be transferred. */ + private final BookmarkManager.Bookmark bookmark; + + /** Create a BookmarkTransferable. + * @param bookmark Bookmark to transfer + */ + public BookmarkTransferable(final BookmarkManager.Bookmark bookmark) { + this.bookmark = bookmark; + } + + /** {@inheritDoc} */ + public Object getTransferData(final DataFlavor flavor) { + return bookmark; + } + + /** {@inheritDoc} */ + public DataFlavor[] getTransferDataFlavors() { + return flavors; + } + + /** {@inheritDoc} */ + public boolean isDataFlavorSupported(final DataFlavor flavor) { + return flavor.equals(bookmarkDataFlavor); + } + + /** Get the DataFlavor for Bookmarks. + * @return DataFlavor for Bookmarks + */ + public static DataFlavor getBookmarkDataFlavor() { + return bookmarkDataFlavor; + } + +} // class BookmarkTransferable Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTreeCellRenderer.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkTreeCellRenderer.java) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTreeCellRenderer.java (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/BookmarkTreeCellRenderer.java 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,60 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.bookmarks; + +import java.awt.Component; +import javax.swing.JSeparator; +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeCellRenderer; + +/** Class for rendering TreeCells in JTrees which manage Bookmarks. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo improve separator + */ +public class BookmarkTreeCellRenderer extends DefaultTreeCellRenderer { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** JSeparator. + * @serial include + */ + private JSeparator sep = new JSeparator(); + + /** {@inheritDoc} */ + @Override public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { + if (!(value instanceof BookmarkManager.Bookmark)) { + throw new IllegalArgumentException("Supplied value must be a bookmark but was " + value.getClass().getName()); + //return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + } + if (value instanceof BookmarkManager.BookmarkSeparator) { + return super.getTreeCellRendererComponent(tree, "----------------", sel, expanded, leaf, row, hasFocus); + //sep.setMinimumSize(new Dimension(tree.getWidth() / 2, 2)); + //sep.setPreferredSize(new Dimension(tree.getWidth(), 2)); + //sep.setSize(5, tree.getWidth()); + ////sep.setBorder(new ); + //return sep; + } else { + return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + } + } + +} // class BookmarkTreeCellRenderer Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/Bookmarkable.java (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/Bookmarkable.java) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/Bookmarkable.java (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/Bookmarkable.java 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,63 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.swing.bookmarks; + +import java.awt.Component; +import net.sf.japi.swing.io.CanLoad; + +/** Interface for classes that want to interact with the BookmarkManager. + * Implement this interface if your class provides information for creating bookmarks. + * See the class {@link BookmarkManager} for more information on Bookmarks. + * @see BookmarkManager + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface Bookmarkable extends CanLoad { + + /** Get wether it currently is possible to create a bookmark. + * @return <code>true</code> if it is possible to create a bookmark, e.g. {@link #getBookmarkTitle()} and {@link #getBookmarkURL()} will return + * meaningful values, otherwise <code>false</code> + */ + boolean isBookmarkPossible(); + + /** Get the title for the Bookmark. + * @return title for Bookmark + */ + String getBookmarkTitle(); + + /** Get the URL for the Bookmark. + * @return url for Bookmark + */ + String getBookmarkURL(); + + /** {@inheritDoc} + * Invoked when the user requests to load a Bookmark. + * The implementor of this method is itself responsible of handling errors and displaying eventual error messages to the user + * @param url URL from bookmark + */ + boolean load(final String url); + + /** Get the component which to block for modal dialogs. + * It is safe to return <code>null</code>. + * @return component + */ + Component getBookmarkBlocker(); + +} // interface Bookmarkable Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action.properties (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/action.properties) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action.properties (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action.properties 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,54 @@ +# +# JAPI - (Yet another (hopefully) useful) Java API +# +# Copyright (C) 2006 Christian Hujer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# + +# $Header: /cvsroot/japi/japi/src/app/net/sf/japi/swing/bookmarks/action.properties,v 1.1 2006/03/26 01:26:25 christianhujer Exp $ +# Properties for Bookmarks + +########### +# Bookmarks + +bookmarkToolBar.name=Bookmarks toolbar + +bookmark.text=Bookmarks +bookmark.mnemonic=B +bookmark.icon=general/Bookmarks + +addBookmark.text=Add +addBookmark.shortdescription=Add bookmark for this question +addBookmark.longdescription=Adds a bookmark for this question +addBookmark.mnemonic=A +addBookmark.accel=ctrl pressed B +addBookmark.icon=general/Bookmarks + +newBookmarkFolder.text=New Folder... +newBookmarkFolder.shortdescription=Create a new Bookmark Folder +newBookmarkFolder.longdescription=Creates a new Bookmark Folder at the end of these Boookmarks +newBookmarkFolder.mnemonic=N +newBookmarkFolder.accel=ctrl pressed F +newBookmarkFolder.icon=general/Bookmarks + +manageBookmarks.text=Manage... +manageBookamrks.shortdescription=Manage bookmarks +manageBookmarks.longdescription=Show a dialog to manage your bookmarks +manageBookmarks.mnemonic=M +manageBookmarks.icon=general/Bookmarks + +bookmarksCreated.message=Bookmarks created Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action_de.properties (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/action_de.properties) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action_de.properties (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/action_de.properties 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,51 @@ +# +# JAPI - (Yet another (hopefully) useful) Java API +# +# Copyright (C) 2006 Christian Hujer +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# + +########### +# Bookmarks + +bookmarkToolBar.name=Lesezeichenleiste + +bookmark.text=Lesezeichen +bookmark.mnemonic=L +#bookmark.icon + +addBookmark.text=Hinzuf\xFCgen +addBookmark.shortdescription=Lesezeichen f\xFCr diese Frage hinzuf\xFCgen +addBookmark.longdescription=F\xFCgt ein Lesezeichen f\xFCr diese Frage in die Liste mit Lesezeichen ein +addBookmark.mnemonic=H +addBookmark.accel=ctrl pressed B +#addBookmark.icon + +newBookmarkFolder.text=Neuer Ordner... +newBookmarkFolder.shortdescription=Neuen Lesezeichen-Ordner erstellen +newBookmarkFolder.longdescription=Erstellt einen neuen Lesezeichen-Ordner am Ende dieser Lesezeichen +newBookmarkFolder.mnemonic=N +newBookmarkFolder.accel=ctrl pressed F +newBookmarkFolder.icon=general/Bookmarks + +manageBookmarks.text=Verwalten... +manageBookamrks.shortdescription=Lesezeichen verwalten +manageBookmarks.longdescription=Zeigt einen Dialog zum Verwalten der Lesezeichen +manageBookmarks.mnemonic=V +#manageBookmarks.icon=general/Bookmarks + +bookmarksCreated.message=Bookmarks erzeugt Copied: libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/package.html (from rev 181, historic/trunk/src/app/net/sf/japi/swing/bookmarks/package.html) =================================================================== --- libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/package.html (rev 0) +++ libs/swing-bookmarks/trunk/src/net/sf/japi/swing/bookmarks/package.html 2006-10-14 12:43:19 UTC (rev 184) @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JAPI - (Yet another (hopefully) useful) Java API + - + - Copyright (C) 2006 Christian Hujer + - + - This program is free software; you can redistribute it and/or + - modify it under the terms of the GNU General Public License as + - published by the Free Software Foundation; either version 2 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, but + - WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + - General Public License for more details. + - + - You should have received a copy of the GNU General Public License + - along with this program; if not, write to the Free Software + - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + - 02111-1307, USA. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> + <title>net.sf.japi.swing.bookmarks</title> + </head> + <body> + <p> + This package contains classes and interfaces related to bookmarks. + Using these classes you can: + </p> + <ul> + <li>Add a bookmark for the current document to the list of bookmarks</li> + <li>Create a Menu to display the bookmarks</li> + <li>Create a Toolbar to display the bookmarks</li> + <li>Activate a bookmark from the Menu or Toolbar and set the current document to the bookmark</li> + <li>Load bookmarks</li> + <li>Save bookmarks</li> + <li>Manage bookmarks (in progress)</li> + <li>Import bookmarks (planned)</li> + <li>Export bookmarks (planned)</li> + <li>Join bookmarks (planned)</li> + </ul> + </body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |