git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268948 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,153 +0,0 @@ | |||||
| 2000-11-27 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/ActionManager.java: Added ability to | |||||
| generate popup menus from a list of action IDs. | |||||
| 2000-11-24 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/Console.java: Added context colorization. | |||||
| 2000-11-20 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/command/DisplayErrorCmd.java: Added | |||||
| code to allow display of stack backtrace if needed. | |||||
| 2000-11-18 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/customizer/PropertiesPropertyEditor.java: | |||||
| Added proper editing capability. Rows are added and removed | |||||
| automatically. | |||||
| * org/apache/tools/ant/gui/customizer/XXXPropertyEditor.java: | |||||
| Removed stray event firing upon setting value of property to edit. | |||||
| 2000-11-16 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/customizer/StringPropertyEditor.java: | |||||
| Changed underlying widget type to JTextPane so that it would | |||||
| accomidate multi-line strings property. | |||||
| * org/apache/tools/ant/gui/acs/ACSTreeNodeElement.java: Fixed | |||||
| nasty java.lang.IllegalAccessException bug that I thought was | |||||
| related to Java 1.3 Blackdown RC1, but wasn't. It was related to | |||||
| using Jikes, which interprests method resolution differently than | |||||
| javac, resulting in a call trying to access a private method | |||||
| implementation of a public interface. | |||||
| * org/apache/tools/ant/gui/ResourceManager.java: Added convenience | |||||
| method for getting resource images for a given class. | |||||
| * org/apache/tools/ant/gui/AntAction.java: Added toggle property. | |||||
| * org/apache/tools/ant/gui/ActionManager.java: Added ability to | |||||
| handle toggle actions to menu bar (still need to add support to | |||||
| tool bar). | |||||
| * org/apache/tools/ant/gui/EventResponder.java: Added emacs | |||||
| notifier command. | |||||
| * org/apache/tools/ant/gui/ide/EmacsNotifier.java: Imported. | |||||
| * org/apache/tools/ant/gui/ProjectProxy.java: Added code to add | |||||
| listeners registered with the AppContext to the build. | |||||
| * org/apache/tools/ant/gui/AppContext.java: Now allows registering | |||||
| of build listeners to be added to project at build time. | |||||
| * org/apache/tools/ant/gui/Main.java: Added loading of build file | |||||
| provided on command line. | |||||
| 2000-11-14 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/Antidote.java: Added top area widget, | |||||
| which is *not* managed inside a split pane. | |||||
| * org/apache/tools/ant/gui/ProjectNavigator.java: Added minimum | |||||
| size to keep resizing of parent from hiding widget. | |||||
| * org/apache/tools/ant/gui/ActionManager.java: Large functionality | |||||
| addtion for allowing action enabled/disabled state to be defined | |||||
| in the configuration file. The triggering of state changes is | |||||
| based on the firing of specific events. | |||||
| * org/apache/tools/ant/gui/AntAction.java: Broke out from inner | |||||
| class of ActionManager to its own self (I'm my own man!). | |||||
| * org/apache/tools/ant/gui/command/CloseCmd.java: Added firing of | |||||
| ProjectClosedEvent so state updates could occur. | |||||
| * org/apache/tools/ant/gui/resources/action.properties: Added | |||||
| enabledOn and disabledOn event specifications. | |||||
| * org/apache/tools/ant/gui/Console.java: Improved reporting level | |||||
| handling (some events weren't getting reported). | |||||
| 2000-11-10 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/PropertyEditor.java: Added new | |||||
| DynamicCustomizer class instead of HTML based info. | |||||
| 2000-11-09 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/ProjectProxy.java: Started rework of | |||||
| project data model, using elements from the XML parser directly | |||||
| through the new Ant Construction Set package. | |||||
| 2000-11-08 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/About.java: Useless tweaking inspired | |||||
| by procrastination. | |||||
| 2000-11-05 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/LogLevelEnum.java: Added log level | |||||
| enumeration for use with combo boxes (drops nicely into default model). | |||||
| * org/apache/tools/ant/gui/event/BuildEventType.java: Added | |||||
| delivering of event to a BuildListener based on enumeration value. | |||||
| * org/apache/tools/ant/gui/ProjectProxy.java: Added generation of | |||||
| BuildEvent on project start and finish, as the project itself | |||||
| doesn't generate theses events (unfortunately). | |||||
| * org/apache/tools/ant/gui/Console.java: Added filtering level, | |||||
| and clearing of buffer when a new build starts. | |||||
| * org/apache/tools/ant/gui/AntEditor.java: Added automatic border | |||||
| for all subclasses. | |||||
| 2000-11-04 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/ProjectProxy.java: Added inner class to | |||||
| execute the build in a separate thread. | |||||
| * org/apache/tools/ant/gui/event/EventBus.java: Added check to see | |||||
| if postEvent() is being called on the AWTEvent thread, and if not, | |||||
| post the dispatching of the event to that thread. This is needed | |||||
| as most of the listeners will be bound to GUI components and will | |||||
| be updating their state (which must occur on the event thread). | |||||
| * org/apache/tools/ant/gui/ProjectProxy.java: Added a | |||||
| BuildListener to forward events to the EventBus. | |||||
| 2000-11-03 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/Antidote.java: Removed hard-coded | |||||
| Console class. | |||||
| * org/apache/tools/ant/gui/Console.java: Changed to a real | |||||
| AntEditor class, initialized by the config file. | |||||
| 2000-11-02 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/event/EventBus.java: Added interrupt | |||||
| level support. | |||||
| * org/apache/tools/ant/gui/About.java: Created | |||||
| 2000-11-01 Simeon H.K. Fitch <simeon@fitch.net> | |||||
| * org/apache/tools/ant/gui/Main.java: Added XMLHelper.init() call | |||||
| * build.xml: Updated run target to include ant.jar in classpath. | |||||
| @@ -1,68 +0,0 @@ | |||||
| A N T I D O T E | |||||
| What is it? | |||||
| ----------- | |||||
| Antidote is the Java based GUI interface to the Ant build tool. | |||||
| Status | |||||
| ------ | |||||
| Antidote is in the early stages of development. Its usefulnes is limited, and | |||||
| will not be distributed with the binary versions of Ant until it is deemed | |||||
| featureful and robust enough for end user use. That being said, it currently | |||||
| will load an Ant build.xml file, allow you to edit some of the file's | |||||
| properties, save it, and launch a build starting at any target in the | |||||
| project. | |||||
| The Latest Version | |||||
| ------------------ | |||||
| The latest version is the current CVS version, which may or may not be useful | |||||
| at any given time. The source code is not being base-lined at any specific | |||||
| version at this time. | |||||
| Documentation | |||||
| ------------- | |||||
| Any documentation that exists for Antidote can be found in the antidote/docs | |||||
| directory. Documentation is primarily developement based documentation as | |||||
| Antidote is not yet mature enough for reliable user documentation. | |||||
| Building | |||||
| -------- | |||||
| Antidote requres JAXP 1.0.1 from Sun (http://java.sun.com/xml). Some time in | |||||
| the future it is hoped at any w3c based XML will be usable, but at the | |||||
| current time the Sun library is needed. The easiest way to install the | |||||
| jaxp.jar and parsers.jar file that comes with the distribution is to copy | |||||
| them into your $JAVA_HOME/jre/lib/ext directory. | |||||
| There is a build.xml file in the same directory as this file that will work | |||||
| with Ant 1.2. It is recommended that Ant be built first (from ../..), | |||||
| followed by this directory. By default, the compiled classes will be written | |||||
| to ~/built/antidote/classes, but the JAR file and launch scripts are written | |||||
| to the Ant build directory (~/build/ant). | |||||
| Running | |||||
| ------- | |||||
| Antidote requires at least Java 1.2 to run. | |||||
| Upon successful building of Ant and Antidote (in that order), go to | |||||
| ~/build/ant/bin and run "antidote". You will probably have to set the | |||||
| environment variable "ANT_HOME" to "~/build/ant" in the shell that you launch | |||||
| antidote from. If desired, you can provide the build file to launch at statup | |||||
| as the first argument on the command line to "antidote". | |||||
| Licensing | |||||
| --------- | |||||
| This software is licensed under the terms you may find in the file | |||||
| named "LICENSE" provided with this distribution. | |||||
| Thanks for using Antidote. | |||||
| The Apache Jakarta Project | |||||
| <http://jakarta.apache.org/> | |||||
| @@ -1,69 +0,0 @@ | |||||
| TODO List: | |||||
| * Rewrite ACSFactory to use it's own parser rather than the implementation | |||||
| specific com.sun.xml.tree.SimpleElementFactory class (only available | |||||
| in JAXP from Sun). | |||||
| * Add editors for defining file sets, and other "sets". | |||||
| * Write wizzard framework. | |||||
| * Implement a build progress reporter. | |||||
| * Implement a "Worker Thread" pattern that allows workers to have | |||||
| their work done in a thread property registered with Antidote, and | |||||
| provide support to that worker to provide progress updates via | |||||
| the GUI. Should also provide support for hour-glass cursor | |||||
| handling, and AWT event blocking until task is completed. This | |||||
| would be used for things such as loading files or other tasks | |||||
| that the user must wait for completion. | |||||
| * Add menu option to select the compiler to use, which then sets | |||||
| the "build.compiler" property. Better yet, create a generic menu | |||||
| building capability that allows the setting of a property from a | |||||
| list of options. | |||||
| * Add ability to put an "all" or "don't care" specifyer on the action | |||||
| "enableOn" and "disableOn" properties. | |||||
| * Add ability to view task dependencies more fully. | |||||
| * Add better editors for specific tasks. | |||||
| * Add a Progress Monitor for file loading (especially for slow boxen like | |||||
| mine) . | |||||
| * Implement some for of refid hyperlinking functionality. | |||||
| * Implement context sensitive menus for the console window, allowing | |||||
| an error to be selected and invoked in IDE. | |||||
| * Write preferences framwork, including persistence support. | |||||
| * Provide some sort of class path debugging support. | |||||
| * Add "syntax" colorization to the console window {done}, | |||||
| with a preferences editor for setting up the styles {not-done}. | |||||
| * Figure out an approach to gracefully stopping a running build. | |||||
| * Add error handler for SAX parser to better report loading errors. | |||||
| * Project properties viewer, including the ability to view | |||||
| dependencies (local and cascading). | |||||
| * Acquire or implement a logging facility. | |||||
| * Eat more dog food. | |||||
| (pending Ant 2.0) | |||||
| * Need Ant API access to: | |||||
| - Tasks within a Target | |||||
| - The topo sorted task list to get flattened dependencies | |||||
| - The build setup code to recduce code replication. | |||||
| - Normalize the Ant data model to represent a more consistent | |||||
| tree structure, and more bean-like API. | |||||
| * Better define the data model architecture, and how it interfaces | |||||
| with the Ant data model. | |||||
| @@ -1,48 +0,0 @@ | |||||
| #! /bin/sh | |||||
| if [ -f $HOME/.antrc ] ; then | |||||
| . $HOME/.antrc | |||||
| fi | |||||
| if [ "$ANT_HOME" = "" ] ; then | |||||
| # try to find ANT | |||||
| if [ -d /opt/ant ] ; then | |||||
| ANT_HOME=/opt/ant | |||||
| fi | |||||
| if [ -d ${HOME}/opt/ant ] ; then | |||||
| ANT_HOME=${HOME}/opt/ant | |||||
| fi | |||||
| ## resolve links - $0 may be a link to ant's home | |||||
| PRG=$0 | |||||
| progname=`basename $0` | |||||
| while [ -h "$PRG" ] ; do | |||||
| ls=`ls -ld "$PRG"` | |||||
| link=`expr "$ls" : '.*-> \(.*\)$'` | |||||
| if expr "$link" : '.*/.*' > /dev/null; then | |||||
| PRG="$link" | |||||
| else | |||||
| PRG="`dirname $PRG`/$link" | |||||
| fi | |||||
| done | |||||
| ANT_HOME=`dirname "$PRG"`/.. | |||||
| fi | |||||
| # Allow .antrc to specifiy flags to java cmd | |||||
| if [ "$JAVACMD" = "" ] ; then | |||||
| JAVACMD=java | |||||
| fi | |||||
| LOCALCLASSPATH=`echo $ANT_HOME/lib/*.jar | tr ' ' ':'` | |||||
| if [ "$CLASSPATH" != "" ] ; then | |||||
| LOCALCLASSPATH=$CLASSPATH:$LOCALCLASSPATH | |||||
| fi | |||||
| $JAVACMD -classpath $LOCALCLASSPATH -Dant.home=${ANT_HOME} org.apache.tools.ant.gui.Main $@ | |||||
| @@ -1,48 +0,0 @@ | |||||
| @echo off | |||||
| rem Slurp the command line arguments. This loop allows for an unlimited number of | |||||
| rem agruments (up to the command line limit, anyway). | |||||
| set ANT_CMD_LINE_ARGS= | |||||
| :setupArgs | |||||
| if %1a==a goto doneArgs | |||||
| set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 | |||||
| shift | |||||
| goto setupArgs | |||||
| :doneArgs | |||||
| rem The doneArgs label is here just to provide a place for the argument list loop | |||||
| rem to break out to. | |||||
| rem find ANT_HOME | |||||
| if not "%ANT_HOME%"=="" goto checkJava | |||||
| rem check for ant in Program Files on system drive | |||||
| rem if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive | |||||
| rem set ANT_HOME=%SystemDrive%\Program Files\ant | |||||
| rem goto checkJava | |||||
| rem :checkSystemDrive | |||||
| rem check for ant in root directory of system drive | |||||
| rem if not exist "%SystemDrive%\ant" goto noAntHome | |||||
| rem set ANT_HOME=%SystemDrive%\ant | |||||
| rem goto checkJava | |||||
| :noAntHome | |||||
| echo ANT_HOME is not set and ant could not be located. Please set ANT_HOME. | |||||
| goto end | |||||
| :checkJava | |||||
| if "%JAVACMD%" == "" set JAVACMD=java | |||||
| set LOCALCLASSPATH="%CLASSPATH%" | |||||
| for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" "%%i" | |||||
| %JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%" org.apache.tools.ant.gui.Main %ANT_CMD_LINE_ARGS% | |||||
| goto end | |||||
| :end | |||||
| set LOCALCLASSPATH= | |||||
| set ANT_CMD_LINE_ARGS= | |||||
| @@ -1,214 +0,0 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="Antidote" default="main" basedir="."> | |||||
| <!-- Give user a chance to override without editing this file | |||||
| (and without typing -D each time it compiles it) --> | |||||
| <property file="${user.home}/.ant.properties" /> | |||||
| <property name="Name" value="Antidote"/> | |||||
| <property name="name" value="antidote"/> | |||||
| <property name="version" value="0.1"/> | |||||
| <property name="ant.home" value="../../"/> | |||||
| <property name="src.bin.dir" value="bin"/> | |||||
| <property name="src.etc.dir" value="etc"/> | |||||
| <property name="src.dir" value="."/> | |||||
| <property name="docs.dir" value="docs"/> | |||||
| <property name="build.dir" value="../../../build/antidote"/> | |||||
| <property name="ant.build.dir" value="../../../build/ant"/> | |||||
| <property name="lib.dir" value="${ant.build.dir}/lib"/> | |||||
| <property name="bin.dir" value="${ant.build.dir}/bin"/> | |||||
| <property name="build.classes" value="${build.dir}/classes"/> | |||||
| <property name="build.javadocs" value="${build.dir}/javadocs"/> | |||||
| <property name="ant.dist.dir" value="../../../dist/ant"/> | |||||
| <path id="classpath"> | |||||
| <pathelement location="${lib.dir}/ant.jar"/> | |||||
| </path> | |||||
| <property name="packages" value="org.apache.tools.ant.gui.*"/> | |||||
| <property name="manifest" value="etc/manifest"/> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Set some the defaults the user can override in .ant.properties --> | |||||
| <!-- =================================================================== --> | |||||
| <property name="build.compiler" value="modern"/> | |||||
| <property name="build.compiler.emacs" value="on"/> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Define a global set of patterns that can be referenced by --> | |||||
| <!-- its id attribute --> | |||||
| <!-- =================================================================== --> | |||||
| <patternset id="chmod.patterns"> | |||||
| <include name="**/antidote" /> | |||||
| </patternset> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Prepares the build directory --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="prepare"> | |||||
| <mkdir dir="${build.dir}"/> | |||||
| <mkdir dir="${ant.build.dir}"/> | |||||
| <tstamp /> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Compiles the source code --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="compile" depends="prepare"> | |||||
| <mkdir dir="${build.classes}"/> | |||||
| <javac srcdir="${src.dir}" | |||||
| destdir="${build.classes}" | |||||
| debug="on" | |||||
| deprecation="on" | |||||
| optimize="off" > | |||||
| <classpath refid="classpath" /> | |||||
| </javac> | |||||
| <copy todir="${build.classes}"> | |||||
| <fileset dir="${src.dir}"> | |||||
| <include name="**/*.properties" /> | |||||
| <include name="**/*.gif" /> | |||||
| <include name="**/*.dtd" /> | |||||
| </fileset> | |||||
| </copy> | |||||
| <filter token="VERSION" value="${version}" /> | |||||
| <filter token="DATE" value="${TODAY}" /> | |||||
| <filter token="TIME" value="${TSTAMP}" /> | |||||
| <copy todir="${build.classes}" | |||||
| overwrite="true" | |||||
| filtering="on"> | |||||
| <fileset dir="${src.dir}"> | |||||
| <include name="**/version.txt" /> | |||||
| </fileset> | |||||
| </copy> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Creates the jar archive --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="jar" depends="compile"> | |||||
| <mkdir dir="${lib.dir}"/> | |||||
| <jar jarfile="${lib.dir}/${name}.jar" | |||||
| basedir="${build.classes}" | |||||
| includes="org/**" | |||||
| manifest="${manifest}" | |||||
| /> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Creates the binary structure --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="main" depends="jar" description="Creates the binary structure"> | |||||
| <mkdir dir="${bin.dir}"/> | |||||
| <copy todir="${bin.dir}"> | |||||
| <fileset dir="${src.bin.dir}"/> | |||||
| </copy> | |||||
| <chmod perm="+x"> | |||||
| <fileset dir="${bin.dir}"> | |||||
| <patternset refid="chmod.patterns"/> | |||||
| </fileset> | |||||
| </chmod> | |||||
| <fixcrlf srcdir="${bin.dir}" includes="antidote" cr="remove"/> | |||||
| <fixcrlf srcdir="${bin.dir}" includes="*.bat" cr="add"/> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Creates the API documentation --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="javadocs" depends="prepare" description="Creates the API documentation"> | |||||
| <mkdir dir="${build.javadocs}"/> | |||||
| <javadoc packagenames="${packages}" | |||||
| sourcepath="${basedir}/${src.dir}" | |||||
| destdir="${build.javadocs}" | |||||
| author="true" | |||||
| private="true" | |||||
| version="true" | |||||
| windowtitle="${Name} API" | |||||
| doctitle="${Name}" | |||||
| bottom="Copyright © 2000 Apache Software Foundation. All Rights Reserved."> | |||||
| <group title="Antidote" packages="org.apache.tools.ant.gui*" /> | |||||
| </javadoc> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Creates the distribution --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="dist" depends="main,jar,javadocs" description="Creates the distribution"> | |||||
| <mkdir dir="${ant.dist.dir}"/> | |||||
| <mkdir dir="${ant.dist.dir}/bin"/> | |||||
| <mkdir dir="${ant.dist.dir}/lib"/> | |||||
| <mkdir dir="${ant.dist.dir}/docs"/> | |||||
| <mkdir dir="${ant.dist.dir}/docs/api"/> | |||||
| <mkdir dir="${ant.dist.dir}/src"/> | |||||
| <copy todir="${ant.dist.dir}/src"> | |||||
| <fileset dir="${src.dir}"/> | |||||
| </copy> | |||||
| <copy todir="${ant.dist.dir}/lib"> | |||||
| <fileset dir="${lib.dir}"/> | |||||
| </copy> | |||||
| <copy todir="${ant.dist.dir}/bin"> | |||||
| <fileset dir="bin"/> | |||||
| </copy> | |||||
| <copy todir="${ant.dist.dir}/docs"> | |||||
| <fileset dir="${docs.dir}"/> | |||||
| </copy> | |||||
| <copy todir="${ant.dist.dir}/docs/api"> | |||||
| <fileset dir="${build.javadocs}"/> | |||||
| </copy> | |||||
| <fixcrlf srcdir="${ant.dist.dir}/bin" includes="antidote" cr="remove"/> | |||||
| <fixcrlf srcdir="${ant.dist.dir}/bin" includes="*.bat" cr="add"/> | |||||
| <chmod perm="+x"> | |||||
| <fileset dir="${ant.dist.dir}/bin"> | |||||
| <patternset refid="chmod.patterns"/> | |||||
| </fileset> | |||||
| </chmod> | |||||
| <copy file="README" tofile="${ant.dist.dir}/README"/> | |||||
| <copy file="WHATSNEW" tofile="${ant.dist.dir}/WHATSNEW"/> | |||||
| <copy file="TODO" tofile="${ant.dist.dir}/TODO"/> | |||||
| <copy file="LICENSE" tofile="${ant.dist.dir}/LICENSE"/> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Packages the distribution with ZIP --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="dist-zip" depends="dist"> | |||||
| <zip zipfile="${Name}-${version}.zip" basedir="${ant.dist.dir}" includes="**"/> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Packages the distribution with TAR-GZIP --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="dist-tgz" depends="dist"> | |||||
| <tar tarfile="${Name}-${version}.tar" basedir="${ant.dist.dir}" includes="**"/> | |||||
| <gzip zipfile="${Name}-${version}.tar.gz" src="${Name}-${version}.tar"/> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Cleans up generated stuff --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="clean"> | |||||
| <delete dir="${build.dir}"/> | |||||
| <delete dir="${ant.dist.dir}"/> | |||||
| </target> | |||||
| <!-- =================================================================== --> | |||||
| <!-- Total cleanup --> | |||||
| <!-- =================================================================== --> | |||||
| <target name="total-clean" depends="clean"> | |||||
| <delete dir="${bin.dir}"/> | |||||
| <delete file="${lib.dir}/${name}.jar"/> | |||||
| <delete file="${Name}-${version}.zip"/> | |||||
| <delete file="${Name}-${version}.tar"/> | |||||
| <delete file="${Name}-${version}.tar.gz"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -1,253 +0,0 @@ | |||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "strict.dtd"> | |||||
| <HTML> | |||||
| <HEAD> | |||||
| <TITLE>Antidote Design Overview</TITLE> | |||||
| </HEAD> | |||||
| <BODY> | |||||
| <H1>Antidote Design Overview</H1> | |||||
| <P>Version 0.2 (2000/12/18)</P> | |||||
| <P>Authors: | |||||
| <A HREF="mailto:simeon@fitch.net">Simeon H.K. Fitch</A> | |||||
| </P> | |||||
| <H2>Introduction</H2> | |||||
| <P>The purpose of this document is to communicate the overall | |||||
| structure and design patters used in Antidote, the GUI for | |||||
| Ant. This document is a work in progress, as well as a living | |||||
| document, and it is most likely not be in full synchronization with | |||||
| the source code. Therefore, if there is any doubt, view the source | |||||
| ;-)</P> | |||||
| <H2>Overview</H2> | |||||
| <P>The Antidote architecture design aims to provide a high level | |||||
| of modularity and extensibility. Ideally the components of | |||||
| Antidote will be able to be assembled in different configurations | |||||
| to provide the type of application or plug-in desired.</P> | |||||
| <P>To acheive this modularity, a high level of decoupling is | |||||
| necessary. The standard UI design approach of providing separation | |||||
| of view (presentation) from model (data) is applied, leveraging | |||||
| the built-in Ant data model where possible, as well as the | |||||
| predifined Swing model interfaces. Furthermore, the architecture | |||||
| is highly event driven, whereby modules communicate via a shared | |||||
| communications channel.</P> | |||||
| <P>To a large extent, the configuration of application modules is | |||||
| driven by localized configuration files, allowing new modules or | |||||
| data views to be added, as well as providing multi-language | |||||
| support.</P> | |||||
| <P>The diagram below conveys a high altitude view of the | |||||
| application's structure. As the application grows, new components | |||||
| will be plugged in to what will be described as the <TT>EventBus</TT>. | |||||
| <TT><PRE> | |||||
| Antidote Component Architecture | |||||
| +---------------+ +----------------+ +-------------+ +-------------+ | |||||
| | | | | | | | | | |||||
| | ActionManager | | EventResponder | | AntModule | | AntModule | | |||||
| | | | | |(ProjectNav) | |(SourceEdit) | | |||||
| +---------------+ +----------------+ +-------------+ +-------------+ | |||||
| | ^ ^ ^ | |||||
| | | | | | |||||
| ActionEvent EventObject AntEvent AntEvent | |||||
| | | | | | |||||
| v v v v | |||||
| /---------------------------------------------------------------------\ | |||||
| / \ | |||||
| < EventBus > | |||||
| \ / | |||||
| \---------------------------------------------------------------------/ | |||||
| | ^ ^ ^ | |||||
| | | | | | |||||
| EventObject ChangeEvent BuildEvent EventObject | |||||
| | | | | | |||||
| v | | v | |||||
| +---------------+ +----------------+ +-------------+ +--------------+ | |||||
| | | | | | | | | | |||||
| | Console | | ProjectProxy | | Ant | | (Your Module)| | |||||
| | | | | | | | | | |||||
| +---------------+ +----------------+ +-------------+ +--------------+ | |||||
| </TT></PRE> | |||||
| <H2>Event Bus</H2> | |||||
| <P>The backbone of the application is the <TT>EventBus</TT>. Any | |||||
| component of the application can post events to the | |||||
| <TT>EventBus</TT>. Components that wish to receive events are | |||||
| called <TT>BusMember</TT>s.</P> | |||||
| <P>The <TT>EventBus</TT> will dispatch any object of type | |||||
| <TT>java.util.Event</TT>, which means that Ant <TT>BuildEvent</TT> | |||||
| objects, as well as <TT>AWTEvent</TT> objects can be posted (if desired). A | |||||
| new class of events called <TT>AntEvent</TT> is defined for Antidote | |||||
| specific events, which have the additional capability of being | |||||
| cancelled mid-dispatch.</P> | |||||
| <P>Each <TT>BusMember</TT> must provide a <TT>BusFilter</TT> instance, | |||||
| which is the members' means of telling the bus which | |||||
| events it is interested in. This allows a <TT>BusMember</TT> to, | |||||
| say, only receive <TT>AntEvent</TT> objects.</P> | |||||
| <P>When a <TT>BusMember</TT> registers itself with the | |||||
| <TT>EventBus</TT>, it must provide a (so called) <I>interrupt | |||||
| level</I> which is a integer value defining a relative ordering | |||||
| for dispatching <TT>EventObject</TT>s to <TT>BusMember</TT>s. The | |||||
| purpose of this is to allow certain <TT>BusMember</TT> instances | |||||
| to see an event before others, and in the case of <TT>AntEvent</TT | |||||
| objects, keep the event from propogating onward. The | |||||
| <TT>EventBus</TT> class defines the interrupt level constants | |||||
| <TT>VETOING=1</TT>, <TT>MONITORING=5</TT>, and <TT>RESPONDING=10</TT> to | |||||
| help define categories of members. The implied purpose being that: | |||||
| <UL> | |||||
| <LI><TT>VETOING</TT>: Listens for certain types of events, and | |||||
| may process them in a non-default manner to determine if the | |||||
| event should be cancelled before being dispatched to the | |||||
| <TT>RESPONDING</TT> group. | |||||
| <LI><TT>MONITORING</TT>: Just listens for events, like a logger | |||||
| or status monitor.</LI> | |||||
| <LI><TT>RESPONDING</TT>: Process events in a default manner, | |||||
| knowing that the event has passed any <TT>VETOING</TT> members.</LI> | |||||
| </UL> | |||||
| Within a specific interrupt level, the order in which members will | |||||
| receive events is undefied. A <TT>BusMember</TT> may be registered | |||||
| at a level that is +/- of one of the defined levels, as long as it | |||||
| follows the constraint <TT>MONITORING <= interruptLevel <= | |||||
| MAX_INTERRUPT</TT>.</P> | |||||
| <H2>Actions and ActionManager</H2> | |||||
| <P>Extensive use of the <TT>javax.swing.Action</TT> interface is | |||||
| made for defining the set of menu and tool bar options that are | |||||
| available. The configuration file <TT>action.properties</TT> | |||||
| exists to define what should appear in the menu and toolbar, how | |||||
| it is displayed, and the <TT>Action</TT> command name that is | |||||
| dispatched when the user invokes that action. A class called | |||||
| <TT>ActionManager</TT> exists for not only processing the | |||||
| configuration file, but also for dispatching invoked action events | |||||
| to the <TT>EventBus</TT>, and for controlling the enabled state of | |||||
| an <TT>Action</TT>. When a new menu item or toolbar button is | |||||
| desired, first it is added to the <TT>action.properties</TT> file, | |||||
| and then the code to respond to it is added to the | |||||
| <TT>EventResponder</TT> (see below). | |||||
| <H2>Commands and EventResponder</H2> | |||||
| <P>At some point in the stages of event processing, an event may | |||||
| require the data model to be modified, or some other task be | |||||
| performed. The <TT>Command</TT> interface is defined to classify | |||||
| code which performs some task or operation. This is distinct from | |||||
| an <TT>Action</TT>, which is a user request for an operation. A | |||||
| <TT>Command</TT> class is the encapsulation of the operation | |||||
| itself.</P> | |||||
| <P>When an <TT>Action</TT> generates an <TT>ActionEvent</TT>, the | |||||
| event is posted to the <TT>EventBus</TT> which delivers the event | |||||
| to all interested <TT>BusMember</TT>s. It eventually makes it to | |||||
| the <TT>EventResponder</TT> instance (registered at the | |||||
| <TT>RESPONDING</TT> interrupt level), which is responsible for | |||||
| translating specific events into <TT>Command</TT> objects, and | |||||
| then executing the <TT>Command</TT> object. For example, when the | |||||
| user selects the "Open..." menu option, an <TT>ActionEvent</TT> is | |||||
| generated by the Swing <TT>MenuItem</TT> class, which is then | |||||
| posted to the <TT>EventBus</TT> by the <TT>ActionManager</TT>. The | |||||
| <TT>ActionEvent</TT> is delivered to the <TT>EventResponder</TT>, | |||||
| which converts the <TT>ActionEvent</TT> into a <TT>Command</TT> | |||||
| instance. The <TT>EventResponder</TT> then calls the method | |||||
| <TT>Command.execute()</TT> to invoke the command (which displays a | |||||
| dialog for selecting a file to open).</P> | |||||
| <P>When adding new <TT>Action</TT>s or general tasks to the | |||||
| application, a <TT>Command</TT> object should be created to | |||||
| encapsulate the behavior. This includes most operations which | |||||
| modify the state of the data model.</P> | |||||
| <P>The purpose of this encapsulation is to allow the clean | |||||
| separation of making a request, and servicing a request. Due to | |||||
| various conditions in the application state, the actualy response | |||||
| to a request may change, as well as who services it. This | |||||
| design approach facilitates that.</P> | |||||
| <H2>Data Model and Views</H2> | |||||
| <P><I>NB: This part of the architecture is not fleshed out very well. There | |||||
| needs to be a discussion of the degree to which the Antidote development | |||||
| should be able to impose changes on the Ant data model, and to what level | |||||
| that model should be mirrored in the Antidote code base. The coupling | |||||
| between them should be kept low, and at the same time changes to one should | |||||
| affect the other minimally. Still, features like property change events and | |||||
| bean introspection (or BeanInfo) may be needed to be added to the Ant data | |||||
| model. Right now the data model is encapsulated in the package | |||||
| <TT>org.apache.tools.ant.gui.acs</TT> (where "<TT>acs</TT>" stands for "Ant | |||||
| Construction Set").</I></P> | |||||
| <H2>Application Context</H2> | |||||
| <P>In order to keep the coupling amoung application modules to a | |||||
| minimum, a single point of reference is needed for coordination | |||||
| and data sharing. The class <TT>AppContext</TT> is the catch-all | |||||
| class for containing the application state. Most modules and | |||||
| <TT>Command</TT> classes require an instance of the | |||||
| <TT>AppContext</TT> class. Because all state information in | |||||
| contained in an <TT>AppContext</TT> instance, multiple instances | |||||
| of Antidote can run inside the same JVM as long as each has it's | |||||
| own <TT>AppContext</TT>. (Interestingly, two instances of the | |||||
| Antidote could conceivably share an <TT>AppContext</TT> instance | |||||
| through RMI, allowing remote interaction/collaboration.)</P> | |||||
| <H2>Configuration and ResourceManager</H2> | |||||
| <P>Full "i18n" support should be assumed in modern applications, | |||||
| and all user viewable strings should be defined in a configuration | |||||
| file. For Antidote this configuraiton file is | |||||
| <TT>antidote.properties</TT>, which is located (with other UI | |||||
| resources) in the subpackage "resources".</P> | |||||
| <P>To aid in the lookup of text properties, as well as other | |||||
| resources like icons, a class called <TT>ResourceManager</TT> is | |||||
| defined. There are various convenience methods attached to this | |||||
| class, which will likely grow to make looking up configuration | |||||
| values as easy as possible.</P> | |||||
| <P>The organization of configuration properties is based on the | |||||
| fully qualifed path of the class that requires the property. For | |||||
| example, the "about" box contains a messages, so it looks for the | |||||
| property "<TT>org.apache.tools.ant.gui.About.message</TT>" for the text | |||||
| message it should display. Therefore, the <TT>ResourceManager</TT> | |||||
| method <TT>getString()</TT> takes a <TT>Class</TT> instance as | |||||
| well as a <TT>String</TT> key. Please see the | |||||
| <TT>ResourceManager</TT> documentation for more information. Given | |||||
| this support, no user visible strings should appear in the source | |||||
| code itself.</P> | |||||
| <H2>Other Resources</H2> | |||||
| <P>Other information about development on Antidote:</P> | |||||
| <UL> | |||||
| <LI><A HREF="uml/index.html">Antidote UML Static Class Diagrams</A></LI> | |||||
| <LI><A HREF="gui-requirements.html">Antidote Feature Wishlist</A></LI> | |||||
| <LI><A HREF="new-module-howto.html">Antidote Module HOWTO</A></LI> | |||||
| </UL> | |||||
| <HR> | |||||
| <P ALIGN="center">Copyright © 2000 Apache Software Foundation. All | |||||
| rights Reserved.</P> | |||||
| </BODY> | |||||
| </HTML> | |||||
| @@ -1,335 +0,0 @@ | |||||
| (NOTE: the following text is a vision for an Ant GUI by Stefan Vaillant | |||||
| <mailto:Stephan.Vaillant@nokia.com> called Anttool. It is included here in the | |||||
| Antidote docs section as it provides a better vision for what the GUI should be | |||||
| than the current requirements document, and should be considered an integral | |||||
| part of the long-term plans for Antidote. Simeon Fitch) | |||||
| ----------------------------------------------------------------------- | |||||
| ******************** | |||||
| **Anttool Proposal** | |||||
| ******************** | |||||
| By: Stefan Vaillant <mailto:Stephan.Vaillant@nokia.com> | |||||
| ----------------------------------------------------------------------- | |||||
| Anttool Overview: | |||||
| ----------------- | |||||
| With Anttool a user can manage the build process for existing ant build files. | |||||
| By using the grafical user interface, the user can adjust certain properties to | |||||
| his environment, start and cancel builds, monitor their progress and call | |||||
| appropiate programs to fix problems. It is not possible to modify the build | |||||
| file. Instead, an external XML editor or antidote should be used. | |||||
| For inexperienced users, the tool provides an easy and efficient way to install | |||||
| open source software: load software to the local system, build it and install | |||||
| it. The tool can be used without any knowledge of XML or the ant DTD. Instead, | |||||
| the user just adjusts the relevant properties to his environment and starts the | |||||
| build. | |||||
| For programmers, the tool supports the basic build/test/edit cycle. Given an | |||||
| existing ant build file, the programmer can use the grafical user interface to | |||||
| execute individual targets, browse the effects of the build and start editors to | |||||
| fix problems that occured during the build. | |||||
| I general, anttool is ment for users who see the build file as a black-box: They | |||||
| are not primarily interested in the internal structure of the build file nor in | |||||
| modifiying it. Instead, they want to call ant with the appropiate arguments and | |||||
| want to see, what is the result of the build. | |||||
| Therefore, anttool only shows targets and properties that are relevant for these | |||||
| users. Tasks are not shown at all. | |||||
| Anttool User Interface: | |||||
| ----------------------- | |||||
| The user interface of anttool is devided into two panels: The "Control Panel" | |||||
| shows all loaded build files and their targets. The "Project Panel" shows | |||||
| details for one project, including the logging information from the last | |||||
| build(s), the editable properties of an build and relevant files of that build. | |||||
| By default, the user interface does not show targets or properties that have no | |||||
| description or a descriuption starting with a ".". These targets or properties | |||||
| are called "hidden" in the following text. | |||||
| The Control Panel: | |||||
| ------------------ | |||||
| The Control Panel shows a tree with all loaded projects. For each project the | |||||
| non-hidden targets are shown. (Anttool can be configured to show also hidden | |||||
| targets, see Configuration below). | |||||
| If you move the cursor over a project or target, a description for it will be | |||||
| shown as a tooltip. | |||||
| Two icons are prefixing the name of the project or target: one is visualizing | |||||
| the state of the project or target, the other is a button to start or cancel the | |||||
| project or target. The state icon can have the following different colors: | |||||
| - green if the execution was successfull. | |||||
| - yellow if an execution is needed because the output files are | |||||
| out-of-date [not possible with current ant version?] | |||||
| - red if the execution resulted in errors. | |||||
| - white (i.e. nothing) if the state is unknown | |||||
| [Alternative: what about buttons labeled with the target name? | |||||
| The button is used for start/stopping the build. | |||||
| No tree required then. ] | |||||
| If you select a node in the tree, the Project Panel (see below) will show | |||||
| details for the relevant project. | |||||
| If you right-click on a node in the tree, a pop-up menu will show the following | |||||
| commands: | |||||
| edit: open XML editor at selected element | |||||
| open: in new window [? is that needed] | |||||
| The Project Panel: | |||||
| ------------------ | |||||
| The Project Panel consists of three tabs: | |||||
| The "Build Log" tab shows information about the last build(s), the "Properties" | |||||
| tab shows non-hidden properties and the "Files" tab shows files relevant for the | |||||
| project. | |||||
| The Build Log Tab: | |||||
| In this tab you can monitor the build on detail. A tree shows the executed | |||||
| targets of a build, their tasks and log messages for each task. The start time | |||||
| is noted after the build name. | |||||
| In the pop-up menu, you can choose from the following commands: | |||||
| edit: open editor for shown file at shown location. | |||||
| show log level->Error/Warning/Info/Verbose/Debug | |||||
| (only the items possible are shown, | |||||
| see configuration.) | |||||
| The Properties Tab: | |||||
| The properties tab shows all non-hidden properties of the project. (optionally, | |||||
| also hidden properties can be shown, see Configuratin below.) | |||||
| Each Property is shown as follows: | |||||
| <Name>: <entry field> <reset checkbox> | |||||
| where | |||||
| <Name> is name of the property, with "." and "-" replaced by " " | |||||
| and first letters capatilized. | |||||
| <entry field> is a text field to enter a value for the properts. | |||||
| In some cases, special benas are shown: | |||||
| Name ends with ".dir" => provide a file chooser to select a directory | |||||
| Name ends with ".lib" => provide a file chooser to select .jar file | |||||
| Name is "build.compiler" => provide combo box with possible compilers. | |||||
| [selecting JDK's seems not well support in ant? | |||||
| If you have e.g. JDK 1.2.1 and 1.2.2 installed, | |||||
| how to easily select the compiler version?] | |||||
| Name ends with ".jdk" => let the user select one of the configures | |||||
| JDK's | |||||
| [more general then build.compiler, but supported by ant?] | |||||
| Name ends with ".file" => provide a file chooser | |||||
| <reset checkbox> resets the value to the (default) value that is | |||||
| contained in the .xml file | |||||
| All values entered are save in a file | |||||
| $HOME/.ant/<full-path-build-file>.property. (See also Configuration.) | |||||
| If property values are changed, then ant is called with | |||||
| main("-Dproperty1=value1 .."). | |||||
| [show also (class)pathes as property, use id instead of name? But: is that | |||||
| required? Why not simply define individual properties for the required | |||||
| libraries and combine them then to a path. ] | |||||
| The File Set Tab: | |||||
| This tab show files that are releated to the project. For each non-hidden | |||||
| fileset of the project, the id of the fileset is shown and all files included to | |||||
| that fileset. | |||||
| If you right-click on a file, a pop-up menu is shown with which you can start | |||||
| programs to deal with these files. The relevant configuration information is | |||||
| extracted from the existing operation system settings. | |||||
| [or: one tab for each fileset?] | |||||
| Repository: | |||||
| ----------- | |||||
| [This needs some more work.] | |||||
| Anttool also simplyfies the loading of source files form the web. By using the | |||||
| repository mechanism of anttool, you can perform the complete workflow from | |||||
| download to install with just a few mouse clicks: | |||||
| select one out of the Repositories from the main menu. | |||||
| Anttool will query the server for a list of up-to-date | |||||
| packages. | |||||
| select one of the presented packages | |||||
| Anttool will then download the selected package: | |||||
| In case a .zip (or similar) package was selected, | |||||
| the file is downloaded and | |||||
| unpacked to "/Users/"<name>. | |||||
| In case a CVS repository was selected, | |||||
| the files are downloaded to "/Users/"<name>. | |||||
| Afterwards | |||||
| a file with the name "build.xml" is searched | |||||
| and loaded to anttool. | |||||
| Optionally, the file "$HOME/.ant/default.properties" | |||||
| is copied to "$HOME/.ant/<full-path-build-file>.properties, | |||||
| overwriting the defaults in the downloaded build file | |||||
| with your preferences (e.g. installation directory, JDK, ...) | |||||
| [copy only relevant properties?] | |||||
| check if the properties in the selected project match your intention. | |||||
| press "start" on the project | |||||
| Anttool Configuration: | |||||
| ----------------------- | |||||
| The menu "Tools" in the menu bar allows you to adjust Anttool behavior to your | |||||
| preferences and environment. | |||||
| The following menu entries are available: | |||||
| Configure JDKs: | |||||
| Can be used to configure the JDKs available | |||||
| on your system. The configured values are offered | |||||
| for properties that end with ".jdk". | |||||
| The screen offers a table to edit a set of names | |||||
| and pathes. | |||||
| By pressing "rescan" the system is scanned for new JDKs | |||||
| by consulting the installed software. | |||||
| [Should there be one combo box | |||||
| Anttool JDK: <internal|JDK list|....> | |||||
| that indicates the JDK that should be used to run ant? | |||||
| Should that be even project specific setting? | |||||
| ] | |||||
| Configure Repository: [better name?] | |||||
| Anttool is aware of certain places where Anttool supporting software | |||||
| can be found on the internet. | |||||
| These URLs can be configured here. | |||||
| These repositories are offered to the user when he selects | |||||
| the "Repository" menu in the menu bar. | |||||
| The screen offers a table to edit a set of names | |||||
| and URLs. | |||||
| Configure Libraries: | |||||
| Can be used to configure the libraries available | |||||
| on your system. The configured values are offered | |||||
| for properties that end with ".lib". | |||||
| The screen offers a table to edit a set of names | |||||
| and pathes. | |||||
| By pressing "rescan" the system is scanned for new libraries | |||||
| by searching below a directory. | |||||
| Preferences: | |||||
| show hidden targets: bool | |||||
| [or: offer addition menu to start hidden targets?] | |||||
| show hidden filesets: bool | |||||
| show hidden properties: bool | |||||
| log level used for build: ... | |||||
| number of log files saved: | |||||
| number of log files shown in UI: | |||||
| Directory to save property values: | |||||
| file name remembered in file menu: | |||||
| checkig for new files in filesets: [seconds] | |||||
| autoload new buildfile: [seconds, 0= never] | |||||
| General features: | |||||
| ----------------- | |||||
| The menubar menu's are | |||||
| File | |||||
| Open... | |||||
| Close | |||||
| ------- | |||||
| 1 buildfile.xml | |||||
| 2 .... | |||||
| 3 ... | |||||
| ------ | |||||
| Exit | |||||
| Repository | |||||
| Apache... as configured | |||||
| <name2>... | |||||
| .... | |||||
| Options | |||||
| Configure JDKs... | |||||
| Configure Repository... | |||||
| Configure Libraries... | |||||
| Preferences... | |||||
| Look&Feel... | |||||
| Help | |||||
| Antool Help... | |||||
| Ant Web Home calls netscape | |||||
| ----------- | |||||
| About... | |||||
| Build files can be dragged and dropped into anttool. | |||||
| The set off loaded build files should be saved on exit and | |||||
| reloaded on restart automatically. | |||||
| Technical questions on the internals of anttool | |||||
| ----------------------------------------------- | |||||
| - How to detect if a target needs to be run (yellow color)? | |||||
| Seems not be possible currently. | |||||
| One solution [what will ant 2.0 contain?]: | |||||
| Define new abstract class "MonitoredTask", inherited from Task. | |||||
| Copy, Javac, javadoc, etc inherit from these. | |||||
| MonitoredTask defines: | |||||
| execute() { prepareTask(); if (executionNeeded) { perform() }; } | |||||
| executionNeeded: boolean // signals that I need to run because output is | |||||
| older than input | |||||
| perform() | |||||
| performMap() // what will happen with each file, i.e. | |||||
| Main.java -> Main.class | |||||
| UI.java -> UI.class | |||||
| ... | |||||
| or | |||||
| Main.class -> lib.jar | |||||
| UI.class -> lib.jar | |||||
| size of Map should be equal to number of steps reported in loggin. | |||||
| Only "executionNeeded" is required to add a yellow flag for targets. The | |||||
| performMap would be nice to have. It could be used later to show a finegrained | |||||
| graph (or matrix) about what is happening during a build. | |||||
| Add configuration item on how often call the funtions (i.e. how often to do | |||||
| the polling.) | |||||
| - How to do the calling of the external tools? | |||||
| XML editor? (how to generate the dtd? How to execute "antstructure" | |||||
| withour changing the build file.) | |||||
| How to simulate the windows functionality for e.g. open java source with | |||||
| JBuilder? | |||||
| How to read the registry information? | |||||
| How to do DDE calls? | |||||
| - is there any free installation tool for java? | |||||
| (to install anttool itself) | |||||
| @@ -1,250 +0,0 @@ | |||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "strict.dtd"> | |||||
| <HTML> | |||||
| <HEAD> | |||||
| <TITLE>Ant GUI Feature List</TITLE> | |||||
| </HEAD> | |||||
| <BODY> | |||||
| <H1>Ant GUI Feature List</H1> | |||||
| <P>Version 0.4 (2000/11/06)</P> | |||||
| <P>Authors: | |||||
| <A HREF="mailto:simeon@fitch.net">Simeon H.K. Fitch</A>, | |||||
| <A HREF="mailto:chris@christophertodd.com">Chris Todd</A>, | |||||
| <A HREF="mailto:clint.combs@contrado.com">Clint Combs</A>, | |||||
| <A HREF="mailto:conor@ebinteractive.com.au">Conor MacNeill</A>, | |||||
| <A HREF="mailto:matthew.k.heun@gaerospace.com">Matthew Kuperus Heun</A>, | |||||
| <A HREF="mailto:duncan@x180.com">James Duncan Davidson</A> | |||||
| <P>The purpose of this document is to capture the proposed feature list for | |||||
| the Ant Graphical User Interface. This is not a hard requirements | |||||
| specification; you won't find the word "shall" in it (other than that one | |||||
| time). :-)</P> | |||||
| <P>In general, the purpose of the GUI is to allow the quick generation and | |||||
| modification of Ant build files, helping the user define their build process | |||||
| and track down build problems. For it to be successful it must make the user | |||||
| more efficient and productive, insofar as their involvement in build | |||||
| management and use of Ant goes. It should first address the needs of the | |||||
| novice Ant user, and then add abilities for the "power" user. This does not | |||||
| imply that the UI should be "dumbed down", it just means that usability | |||||
| should come before slick but complicated features.</P> | |||||
| <P>The features are in a loose order of expressed interested by | |||||
| contributors.</P> | |||||
| <!-- Section List --> | |||||
| <OL TYPE="A"> | |||||
| <LI><H2>Build Management</H2></LI> | |||||
| <P>Once a build file is created, the user will want to start and | |||||
| stop it from the UI. This will serve both as a testing facility as well as | |||||
| a general compile tool. Monitoring of the build can occur through the Ant | |||||
| BuildListener interface.</P> | |||||
| <OL> | |||||
| <LI>Build execution.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Initiate a build starting from any task.</LI> | |||||
| <LI>Stop a currently active build.</LI> | |||||
| </OL> | |||||
| <LI>Build monitoring.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide feedback on the current status of the build.<BR> | |||||
| <I>This is where you can have more fun with the directed graph view, | |||||
| where the current build activity is highlighted on the screen, making | |||||
| the whole thing behave like a dynamic state transition diagram. You | |||||
| can then highlight the node where the build fails, etc.</I></LI> | |||||
| <LI>Show log messages from the build, allowing the user to determine | |||||
| the task they originated from.</LI> | |||||
| <LI>Provide the ability to filter logged messages, adn to display the | |||||
| messages in color codes corresponding to logging levels.</LI> | |||||
| <LI>Allow the installation of custom log listeners</LI> | |||||
| <LI>Record runtime statistics to determine bottleneck in the build | |||||
| process<BR> | |||||
| <I>This may be of limited use, as calling <javac> probably takes | |||||
| the most time. But maybe not.</I></LI> | |||||
| </OL> | |||||
| </OL> | |||||
| <BR> | |||||
| <LI><H2>Build Wizard (auto-configure)</H2></LI> | |||||
| <P>To make starting a new project with Ant as easy as possible, the a | |||||
| wizard type of UI can be used where the user provides some basic | |||||
| information and the application deduces what a default build.xml file for | |||||
| it should look like.</P> | |||||
| <OL> | |||||
| <LI>Project attributes.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide input for the required project attributes.<BR> | |||||
| <I>This probably means project name and default target.</I></LI> | |||||
| </OL> | |||||
| <LI>Project directories.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Ask for the source directory.</LI> | |||||
| <LI>Ask for the destination directory.</LI> | |||||
| <LI>Ask for the necessary JAR files.</LI> | |||||
| </OL> | |||||
| <LI>Project properties.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide a default set of project properties.<BR> | |||||
| <I>In here would be things like classpath, build.compiler, version, | |||||
| etc.</I></LI> | |||||
| <LI>Allow the user to add to or remove from properties the default set | |||||
| of properties.</LI> | |||||
| </OL> | |||||
| <LI>Task creation</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide a list of "standard" tasks to insert into the project.<BR> | |||||
| <I>This would be tasks like <javac> and | |||||
| <javadoc>.</I></LI> | |||||
| <LI>Generate default init, compile, javadoc, and clean targets.</LI> | |||||
| </OL> | |||||
| <LI>Creation review.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide a review of the contents of the generated build.xml | |||||
| file.</LI> | |||||
| <LI>Allow the user to go back to any step in the process to change a | |||||
| setting.</LI> | |||||
| <LI>Prompt the user to save the build.xml file.</LI> | |||||
| </OL> | |||||
| </OL> | |||||
| <BR> | |||||
| <LI><H2>IDE Integration</H2></LI> | |||||
| <P>Components of the Ant GUI shoule support plugging into IDEs and code | |||||
| editors.</P> | |||||
| <OL> | |||||
| <LI>Emacs</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide support for launching builds from emacs, and notification | |||||
| of errors.</LI> | |||||
| </OL> | |||||
| <LI>JEdit</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide JEdit plug-in.</LI> | |||||
| </OL> | |||||
| <LI>ProjectBuilder</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide integration with OSX ProjectBuilder.</LI> | |||||
| </OL> | |||||
| <LI>NetBeans</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide integration with the NetBeans IDE.</LI> | |||||
| </OL> | |||||
| </OL> | |||||
| <BR> | |||||
| <LI><H2>Project Editing</H2></LI> | |||||
| <P>The Ant UI will be centered around the project file. All operations of | |||||
| the UI will be on a project, whether it be existing or new. <I>How | |||||
| sub-projects are handled (i.e. via the <ant> task) needs to be | |||||
| determined.</I></P> | |||||
| <OL> | |||||
| <LI>Load a project.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Read the native Ant XML format as defined by the Ant users' | |||||
| manual.</LI> | |||||
| <LI>When possible, automatically handle changes in the Ant element | |||||
| set, or at least changes to the task set, as well as the valid set of | |||||
| attributes.<BR> | |||||
| <I>Possible approach: load "default.properties", use | |||||
| introspection to discover attribute set, then reference some other | |||||
| mechanism for attributes that are manifested as properties.</I> | |||||
| </LI> | |||||
| <LI>Report errors in the XML source.</LI> | |||||
| <LI>Provide a list of recently opened documents for | |||||
| quick reloading.</LI> | |||||
| </OL> | |||||
| <LI>View project contents.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>View the project in it's XML source format.</LI> | |||||
| <LI>View the project in a non-source format.<BR> | |||||
| <I>This is left ambiguous to keep the implementation out of the | |||||
| requirements. The different presentation formats are likely to evolve | |||||
| over time.</I> | |||||
| </LI> | |||||
| <LI>View the project properties.</LI> | |||||
| <LI>View the project contents (tasks).</LI> | |||||
| </OL> | |||||
| <LI>Modify a project.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Edit via the XML source.</LI> | |||||
| <LI>Edit properties via a property sheet.</LI> | |||||
| <LI>Provide facility for editing XML references used in the build | |||||
| file.</LI> | |||||
| </OL> | |||||
| <LI>Save a project.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Save to the native Ant XML format as defined by the Ant users' | |||||
| manual.</LI> | |||||
| <LI>Default save name is "build.xml".</LI> | |||||
| <LI>Verify before overwriting existing file when in "Save as" | |||||
| mode.</LI> | |||||
| </OL> | |||||
| <LI>Create a new project.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Define a project name.</LI> | |||||
| <LI>Define the default target.</LI> | |||||
| <LI>Define the project base directory.</LI> | |||||
| </OL> | |||||
| </OL> | |||||
| <BR> | |||||
| <LI><H2>Task Editing</H2></LI> | |||||
| <P>Tasks define what it is that Ant is to do, and will be the object most | |||||
| edited in the UI. <U>Task</U> <I>is to</I> <U>Paragraph</U> <I>as</I> | |||||
| <U>Project</U> <I>is to</I> <U>Document</U>. | |||||
| <OL> | |||||
| <LI>View tasks.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>View a sorted list of tasks.<BR> | |||||
| <I>Provide sorting based on name, depth in dependency tree, how many | |||||
| tasks depend in it...</I></LI> | |||||
| <LI>View tasks as a directed graph.<BR> | |||||
| <I>Need a good graph editing library. Looked at <A | |||||
| HREF="http://gef.tigris.org">GEF</A> but it still needs a lot of | |||||
| work, to make it easily reusable. Long term status unknown.</I></LI> | |||||
| <LI>View tasks as a dependency tree.</LI> | |||||
| <LI>View task as a properties sheet.</LI> | |||||
| <LI>Provide dependency viewing, both immediate and "flattened" | |||||
| views.</LI> | |||||
| </OL> | |||||
| <LI>Modify task.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Allow editing of a task via a property sheet.</LI> | |||||
| <LI>Allow editing of a task via XML source.</LI> | |||||
| <LI>Allow the graphical editing of task dependencies<BR> | |||||
| <I>This is where you can go hog wild with the component wiring type of | |||||
| UI. </I></LI> | |||||
| <LI>Allow non-graphical editing of dependencies.</LI> | |||||
| <LI>Provide detection of circular dependencies.</LI> | |||||
| <LI>Facilitate definition of conditional tasks with evaluation | |||||
| editor.</LI> | |||||
| </OL> | |||||
| </OL> | |||||
| <BR> | |||||
| <LI><H2>Build File Source Editing</H2></LI> | |||||
| <P>This section listes desired features for editing the Ant build file | |||||
| directly. Some components of this could be met by a generic XML editing | |||||
| capability, but other parts will be Ant specific features.</P> | |||||
| <OL> | |||||
| <LI>XML Editor.</LI> | |||||
| <OL TYPE="a"> | |||||
| <LI>Provide syntax higlighting.</LI> | |||||
| <LI>Provide auto-indentation.</LI> | |||||
| <LI>Provide smart tag completion.</LI> | |||||
| <LI>Provide visual highlighting of syntax errors.</LI> | |||||
| <LI>Support auto-reparsing of contents and model update.</LI> | |||||
| </OL> | |||||
| </OL> | |||||
| <HR> | |||||
| <P ALIGN="center">Copyright © 2000 Apache Software Foundation. All | |||||
| rights Reserved.</P> | |||||
| </BODY> | |||||
| </HTML> | |||||
| @@ -1,89 +0,0 @@ | |||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "strict.dtd"> | |||||
| <HTML> | |||||
| <HEAD> | |||||
| <TITLE>Antidote New Module HOWTO</TITLE> | |||||
| </HEAD> | |||||
| <BODY> | |||||
| <H1>Antidote New Module HOWTO</H1> | |||||
| <P>Version 0.1 (2000/12/18)</P> | |||||
| <P>Authors: | |||||
| <A HREF="mailto:simeon@fitch.net">Simeon H.K. Fitch</A> | |||||
| </P> | |||||
| <H2>Introduction</H2> | |||||
| <P>The purpose of this document is to provide an overview of the | |||||
| basic steps one must undertake to add a new module to | |||||
| Antidote. Please see <A HREF="design-overview.html">The Antidote | |||||
| Design Overview</A> for information on what a module is and how it | |||||
| fits into Antidote. If you've already got all that, then read | |||||
| on!</P> | |||||
| <P>NB: <I>Please submit updates and criticisms to this, particularly | |||||
| areas that were unclear, missing, or difficult to follow.</I></P> | |||||
| <H2>1) Specialize <TT>org.apache.tools.ant.gui.core.AntModule</TT></H2> | |||||
| <P>All modules must inherit from the <TT>AntModule</TT> | |||||
| class. This will probably irritate some of you, but it essentially | |||||
| enforces inheritance from <TT>javax.swing.JComponent</TT> and | |||||
| provides encapsulated handling of the <TT>AppContext</TT> instance | |||||
| that is so important to this class.</P> | |||||
| <P>Your module is required to implement the | |||||
| <TT>AntModule.contextualize(AppContext)</TT> method. The first | |||||
| thing this method should do is call | |||||
| <TT>AntModule.setContext(AppContext)</TT>, and then it is safe for | |||||
| it to begin constructing its display, using whatever resources it | |||||
| needs from the given <TT>AppContext</TT> instance. Think of this | |||||
| in a similar manner to <TT>Applet.init()</TT> or | |||||
| <TT>Servlet.init()</TT>. | |||||
| <H2>2) Update | |||||
| <TT>org/apache/tools/ant/gui/resources/antidote.properties</TT></H2> | |||||
| <H3>2a) Externalize All Displayable Strings</H3> | |||||
| <P>All displayable strings must be externalized to the | |||||
| <TT>antidote.properties</TT> file, and looked up via the | |||||
| <TT>AppContext.getResources()</TT> method after the | |||||
| <TT>AntModule.contextualize()</TT> method has been called. Follow | |||||
| the naming convention currently used in the properties file and | |||||
| you should have to problems. This task should be done | |||||
| <B>during</B> development of your module. Under no cercumstances | |||||
| should your module be submitted or committed without this task | |||||
| being completed. Remember that Antidote has an international | |||||
| audience.</P> | |||||
| <H3>2b) Add Module to List of Auto-Loaded Modules</H3> | |||||
| <P>Look for the properties with the format | |||||
| <TT>org.apache.tools.ant.gui.Antidote.xxx.modules</TT> where | |||||
| <TT>xxx</TT> is one of {left | right | top | bottom}. Depending on | |||||
| where you want your module to appear, and the order that you want | |||||
| it to appear in relationship to the other modules, add the class | |||||
| name of your module appropriately. If multiple modules are listed | |||||
| for a single property (via a comma delimited list), then each | |||||
| module will have it's own tab in a <TT>javax.swing.JTabbedPane</TT>. | |||||
| <P>NB:<I>This goofy way of constructing the main screen will probably | |||||
| change to something much more general (but not as general as, say | |||||
| <A HREF="http://www.alphaworks.ibm.com/tech/bml">BML</A>).</P> | |||||
| <H2>Run it!</H2> | |||||
| <P>That should be all you need to do, at least to get your module | |||||
| plugged in. Check out the source code for | |||||
| <TT>ProjectNavigator</TT> and <TT>PropertyEditor</TT> for module | |||||
| examples that use the various facilities of the Antidote | |||||
| framework.</P> | |||||
| <HR> | |||||
| <P ALIGN="center">Copyright © 2000 Apache Software Foundation. All | |||||
| rights Reserved.</P> | |||||
| </BODY> | |||||
| </HTML> | |||||
| @@ -1,44 +0,0 @@ | |||||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "strict.dtd"> | |||||
| <HTML> | |||||
| <HEAD> | |||||
| <TITLE>Antidote UML Static Class Diagrams</TITLE> | |||||
| </HEAD> | |||||
| <BODY> | |||||
| <H1>Antidote UML Static Class Diagrams</H1> | |||||
| <P>Version 0.1 (2000/12/19)</P> | |||||
| <P>Authors: | |||||
| <A HREF="mailto:simeon@fitch.net">Simeon H.K. Fitch</A> | |||||
| </P> | |||||
| <H2>Diagram Images</H2> | |||||
| <P>The following UML static class diagrams were generated using <A | |||||
| HREF="http://www.togethersoft.com">Together/J</A>, reverse engineering the | |||||
| existing code. They are no means guaranteed to be kept up to date, and are | |||||
| only a snapshot of development in progress. Their purpose is to help give | |||||
| people a quick glance a the class structure of the various packages that | |||||
| make up.</P> | |||||
| <OL> | |||||
| <LI><A HREF="org-apache-tools-ant-gui.gif">org.apache.tools.ant.gui</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-acs.gif">org.apache.tools.ant.gui.acs</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-core.gif">org.apache.tools.ant.gui.core</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-command.gif">org.apache.tools.ant.gui.command</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-customizer.gif">org.apache.tools.ant.gui.customizer</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-event.gif">org.apache.tools.ant.gui.event</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-ide.gif">org.apache.tools.ant.gui.ide</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-modules.gif">org.apache.tools.ant.gui.modules</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-modules-console.gif">org.apache.tools.ant.gui.modules.console</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-modules-edit.gif">org.apache.tools.ant.gui.modules.edit</A></LI> | |||||
| <LI><A HREF="org-apache-tools-ant-gui-util.gif">org.apache.tools.ant.gui.util</A></LI> | |||||
| </OL> | |||||
| <HR> | |||||
| <P ALIGN="center">Copyright © 2000 Apache Software Foundation. All | |||||
| rights Reserved.</P> | |||||
| </BODY> | |||||
| </HTML> | |||||
| @@ -1,4 +0,0 @@ | |||||
| Manifest-Version: 1.0 | |||||
| Main-Class: org.apache.tools.ant.gui.Main | |||||
| @@ -1,142 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui; | |||||
| import org.apache.tools.ant.gui.util.WindowUtils; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import javax.swing.*; | |||||
| import java.io.IOException; | |||||
| import java.util.*; | |||||
| import java.awt.BorderLayout; | |||||
| import java.awt.Dimension; | |||||
| import java.awt.event.ActionListener; | |||||
| import java.awt.event.ActionEvent; | |||||
| /** | |||||
| * Dialog displaying information on the application. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class About extends JDialog { | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public About(AppContext context) { | |||||
| super(context.getParentFrame(), true); | |||||
| setDefaultCloseOperation(DISPOSE_ON_CLOSE); | |||||
| String version = null; | |||||
| String date = null; | |||||
| Properties props = new Properties(); | |||||
| try { | |||||
| props.load(getClass().getResourceAsStream("version.txt")); | |||||
| } | |||||
| catch(IOException ex) { | |||||
| // XXX log me. | |||||
| ex.printStackTrace(); | |||||
| return; | |||||
| } | |||||
| version = props.getProperty("VERSION", "??"); | |||||
| date = props.getProperty("DATE", "??"); | |||||
| String message = context.getResources().getMessage( | |||||
| getClass(), "message", | |||||
| new Object[] { version, date }); | |||||
| String title = context.getResources().getString( | |||||
| getClass(), "title"); | |||||
| setTitle(title); | |||||
| JTextPane contents = new JTextPane(); | |||||
| contents.setContentType("text/html"); | |||||
| contents.setText(message); | |||||
| contents.setEditable(false); | |||||
| // XXX Still not sure why this is necessary. JTextPane doesn't | |||||
| // seem to report a "true" preferred size. | |||||
| contents.setPreferredSize( | |||||
| new Dimension(contents.getPreferredSize().width, 450)); | |||||
| getContentPane().add(BorderLayout.CENTER, contents); | |||||
| // Add the OK button. | |||||
| JButton ok = new JButton( | |||||
| context.getResources().getString(getClass(), "ok")); | |||||
| ok.addActionListener(new ActionHandler()); | |||||
| JPanel p = new JPanel(); | |||||
| p.add(ok); | |||||
| getContentPane().add(BorderLayout.SOUTH, p); | |||||
| getRootPane().setDefaultButton(ok); | |||||
| // Just go ahead and show it... | |||||
| pack(); | |||||
| WindowUtils.centerWindow(context.getParentFrame(), this); | |||||
| setVisible(true); | |||||
| } | |||||
| /** Handles press of the OK button. */ | |||||
| private class ActionHandler implements ActionListener { | |||||
| public void actionPerformed(ActionEvent e) { | |||||
| WindowUtils.sendCloseEvent(About.this); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,147 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui; | |||||
| import org.apache.tools.ant.gui.core.*; | |||||
| import javax.swing.*; | |||||
| import java.awt.BorderLayout; | |||||
| import java.awt.Dimension; | |||||
| import java.lang.reflect.Constructor; | |||||
| /** | |||||
| * The root class for the Ant GUI. Assembles all the graphical components | |||||
| * based on the configuration files. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class Antidote extends JComponent { | |||||
| /** Source of application state data. */ | |||||
| private AppContext _context = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public Antidote(AppContext context) { | |||||
| setLayout(new BorderLayout()); | |||||
| _context = context; | |||||
| // Add the various modules to the editing area. | |||||
| JSplitPane splitter = new JSplitPane(); | |||||
| splitter.add(JSplitPane.LEFT, populateModules("left")); | |||||
| splitter.add(JSplitPane.RIGHT, populateModules("right")); | |||||
| // This is necessary because, frankly, the JSplitPane widget | |||||
| // sucks, and doesn't provide enought (working) control over the | |||||
| // initial size of it's subcomponents. setDividerLocation(double) | |||||
| // doesn't seem to work until after the widget is visible. | |||||
| splitter.setPreferredSize(new Dimension(500, 300)); | |||||
| // Top bottom splitter. | |||||
| JSplitPane splitter2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); | |||||
| splitter2.setOneTouchExpandable(true); | |||||
| splitter2.add(JSplitPane.TOP, splitter); | |||||
| splitter2.add(JSplitPane.BOTTOM, populateModules("bottom")); | |||||
| add(BorderLayout.CENTER, splitter2); | |||||
| splitter2.resetToPreferredSizes(); | |||||
| add(BorderLayout.NORTH, populateModules("top")); | |||||
| setPreferredSize(new Dimension(640, 480)); | |||||
| } | |||||
| /** | |||||
| * Instantiate the configured modules. | |||||
| * | |||||
| * @return Component containing the modules(s). | |||||
| */ | |||||
| private JComponent populateModules(String prefix) { | |||||
| String[] classNames = _context.getResources(). | |||||
| getStringArray(getClass(), prefix + ".modules"); | |||||
| AntModule[] modules = new AntModule[classNames.length]; | |||||
| for(int i = 0; i < classNames.length; i++) { | |||||
| try { | |||||
| Class type = Class.forName(classNames[i]); | |||||
| modules[i] = (AntModule) type.newInstance(); | |||||
| modules[i].contextualize(_context); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| // XXX log me. | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| if(modules.length == 1) { | |||||
| return modules[0]; | |||||
| } | |||||
| else if(modules.length > 1) { | |||||
| JTabbedPane tabbed = new JTabbedPane(JTabbedPane.BOTTOM); | |||||
| for(int i = 0; i < modules.length; i++) { | |||||
| tabbed.addTab(modules[i].getName(), modules[i]); | |||||
| } | |||||
| return tabbed; | |||||
| } | |||||
| else { | |||||
| return new JLabel("I shouldn't be here..."); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,161 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui; | |||||
| import org.apache.tools.ant.gui.core.ResourceManager; | |||||
| /** | |||||
| * Class encapsulating the parsing of command-line arguments for Antidote. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class Args { | |||||
| private ResourceManager _resources = null; | |||||
| private boolean _wizardMode = false; | |||||
| private String _fileName = null; | |||||
| private boolean _debugMode = false; | |||||
| /** | |||||
| * Ctor for parsing command line arguments. | |||||
| * | |||||
| * @param args Arguments to parse. | |||||
| */ | |||||
| public Args(String[] args) { | |||||
| for(int i = 0; i < args.length; i++) { | |||||
| String arg = args[i]; | |||||
| if(i == args.length - 1 && !arg.startsWith("-")) { | |||||
| _fileName = arg; | |||||
| } | |||||
| else if(arg.startsWith("-h")) { | |||||
| System.out.println(getUsage()); | |||||
| System.exit(0); | |||||
| } | |||||
| else if(arg.equals("-wizard")) { | |||||
| _wizardMode = true; | |||||
| } | |||||
| else if(arg.equals("-debug")) { | |||||
| _debugMode = true; | |||||
| } | |||||
| else { | |||||
| String msg = getResources().getMessage( | |||||
| "invalidArg", new Object[] { arg }); | |||||
| abort(msg); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the resources, loading them if necessary. | |||||
| * | |||||
| * @return Loaded resources. | |||||
| */ | |||||
| private ResourceManager getResources() { | |||||
| if(_resources == null) { | |||||
| _resources = new ResourceManager( | |||||
| "org.apache.tools.ant.gui.resources.args"); | |||||
| } | |||||
| return _resources; | |||||
| } | |||||
| /** | |||||
| * Print message and exit. | |||||
| * | |||||
| * @param error Error message to print. | |||||
| */ | |||||
| private void abort(String error) { | |||||
| System.err.println(error); | |||||
| System.err.println(getUsage()); | |||||
| System.exit(1); | |||||
| } | |||||
| /** | |||||
| * Get the command line usage of Antidote. | |||||
| * | |||||
| * @return Command line usage help. | |||||
| */ | |||||
| public String getUsage() { | |||||
| return getResources().getString("usage"); | |||||
| } | |||||
| /** | |||||
| * Get the build filename. | |||||
| * | |||||
| * @return Build file name. | |||||
| */ | |||||
| public String getBuildFile() { | |||||
| return _fileName; | |||||
| } | |||||
| /** | |||||
| * Determine if wizard mode was requested for generating a new | |||||
| * build file. | |||||
| * | |||||
| * @return True if wizard mode, false otherwise. | |||||
| */ | |||||
| public boolean isWizardMode() { | |||||
| return _wizardMode; | |||||
| } | |||||
| /** | |||||
| * Determine if debug mode was requested. | |||||
| * | |||||
| * @return True if debug mode, false otherwise. | |||||
| */ | |||||
| public boolean isDebugMode() { | |||||
| return _debugMode; | |||||
| } | |||||
| } | |||||
| @@ -1,155 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui; | |||||
| import org.apache.tools.ant.gui.core.*; | |||||
| import org.apache.tools.ant.gui.util.XMLHelper; | |||||
| import org.apache.tools.ant.gui.wizard.Wizard; | |||||
| import org.apache.tools.ant.gui.wizard.build.BuildData; | |||||
| import org.apache.tools.ant.gui.wizard.WizardListener; | |||||
| import org.apache.tools.ant.gui.command.LoadFileCmd; | |||||
| import org.apache.tools.ant.gui.event.EventBus; | |||||
| import org.apache.tools.ant.gui.acs.ACSFactory; | |||||
| import javax.swing.*; | |||||
| import java.awt.BorderLayout; | |||||
| import java.io.File; | |||||
| /** | |||||
| * Launch point for the Antidote GUI. Configurs it as an application. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class Main { | |||||
| /** | |||||
| * Application start. | |||||
| * | |||||
| * @param args TBD | |||||
| */ | |||||
| public static void main(String[] args) { | |||||
| XMLHelper.init(); | |||||
| Args settings = new Args(args); | |||||
| try { | |||||
| JFrame f = new JFrame("Antidote"); | |||||
| f.setDefaultCloseOperation(3 /*JFrame.EXIT_ON_CLOSE*/); | |||||
| AppContext context = new AppContext(f); | |||||
| if(!settings.isWizardMode()) { | |||||
| EventResponder resp = new EventResponder(context); | |||||
| Antidote gui = new Antidote(context); | |||||
| JMenuBar menu = context.getActions().createMenuBar(); | |||||
| f.setJMenuBar(menu); | |||||
| f.getContentPane().add(BorderLayout.CENTER, gui); | |||||
| f.getContentPane().add(BorderLayout.NORTH, | |||||
| context.getActions().createToolBar()); | |||||
| // Add the project selection menu. | |||||
| ProjectSelectionMenu ps = new ProjectSelectionMenu(context); | |||||
| ps.insertInto(menu); | |||||
| // Add debugging items. | |||||
| if(settings.isDebugMode()) { | |||||
| context.getEventBus().addMember( | |||||
| EventBus.VETOING, new EventDebugMonitor()); | |||||
| } | |||||
| // Load a build file if one is provided. | |||||
| if(settings.getBuildFile() != null) { | |||||
| LoadFileCmd load = new LoadFileCmd(context); | |||||
| load.setFile(new File(settings.getBuildFile())); | |||||
| load.run(); | |||||
| } | |||||
| } | |||||
| else { | |||||
| // We are in wizard mode. Create it. | |||||
| Wizard wiz = new Wizard(new BuildData()); | |||||
| // XXX this is temporary for testing. Eventually | |||||
| // it will launch the regular antidote screen with the | |||||
| // results of the wizard. | |||||
| wiz.addWizardListener(new WizardListener() { | |||||
| public void finished(Object model) { | |||||
| BuildData data = (BuildData) model; | |||||
| System.out.println(data.createProject()); | |||||
| System.exit(0); | |||||
| } | |||||
| public void canceled() { | |||||
| System.exit(0); | |||||
| } | |||||
| }); | |||||
| f.getContentPane().add(BorderLayout.CENTER, wiz); | |||||
| } | |||||
| ImageIcon icon = | |||||
| context.getResources().loadImageIcon("icon-small.gif"); | |||||
| if(icon != null) { | |||||
| f.setIconImage(icon.getImage()); | |||||
| } | |||||
| else { | |||||
| System.out.println("Application icon not found."); | |||||
| } | |||||
| f.pack(); | |||||
| f.setVisible(true); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,73 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.core.ResourceManager; | |||||
| import java.beans.*; | |||||
| /** | |||||
| * Specialized BeanDescriptor for providing more descriptive information. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| class ACSBeanDescriptor extends BeanDescriptor { | |||||
| public ACSBeanDescriptor(BaseBeanInfo type) { | |||||
| super(type.getType(), type.getCustomizerType()); | |||||
| setDisplayName( | |||||
| type.getResources().getString(type.getClass(), "beanName")); | |||||
| setShortDescription( | |||||
| type.getResources().getString(type.getClass(), "beanDescription")); | |||||
| } | |||||
| } | |||||
| @@ -1,73 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| /** | |||||
| * Default element used when no other element is specificed. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSDefaultElement extends ACSElement { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSDefaultElement() { | |||||
| } | |||||
| } | |||||
| @@ -1,504 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import java.io.*; | |||||
| import java.net.*; | |||||
| import java.util.*; | |||||
| import org.w3c.dom.*; | |||||
| import javax.xml.parsers.*; | |||||
| import org.xml.sax.SAXException; | |||||
| import org.xml.sax.InputSource; | |||||
| import com.sun.xml.parser.Parser; | |||||
| import com.sun.xml.parser.DtdEventListener; | |||||
| import com.sun.xml.parser.ValidatingParser; | |||||
| import com.sun.xml.tree.*; | |||||
| import com.sun.xml.parser.Resolver; | |||||
| /** | |||||
| * Reads the ANT DTD and provides information about it. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class ACSDocumentType extends java.lang.Object { | |||||
| /** ID for core elements */ | |||||
| public final static int CORE_ELEMENT = 0; | |||||
| /** ID for optional elements */ | |||||
| public final static int OPTIONAL_ELEMENT = 1; | |||||
| /** True if the DTD has been loaded */ | |||||
| private boolean isInit = false; | |||||
| /** Hold the core DTD elements */ | |||||
| private HashMap coreElementMap = new HashMap(); | |||||
| /** Hold the optional DTD elements */ | |||||
| private HashMap optionalElementMap = new HashMap(); | |||||
| /** Hold the DTD elements */ | |||||
| private HashMap elementMap; | |||||
| /** First part of the XML document used to load the DTD */ | |||||
| private final static String XMLDOC_1 = | |||||
| "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + | |||||
| "<!DOCTYPE project SYSTEM \"file:/"; | |||||
| /** Second part of the XML document used to load the DTD */ | |||||
| private final static String XMLDOC_2 = | |||||
| "\"><project name=\"sample-project\">" + | |||||
| "</project>"; | |||||
| /** DTD which holds the core tasks */ | |||||
| private final static String DTD_1 = "project.dtd"; | |||||
| /** DTD which holds the optional tasks */ | |||||
| private final static String DTD_2 = "project-ext.dtd"; | |||||
| /** DTD which holds the shared elements */ | |||||
| private final static String DTD_SHARE = "share.dtd"; | |||||
| /** | |||||
| * Standard ctor. | |||||
| */ | |||||
| public ACSDocumentType() { | |||||
| } | |||||
| /** | |||||
| * Loads the DTD if not already loaded. | |||||
| */ | |||||
| public void init() { | |||||
| // Return if already inited. | |||||
| if (isInit) { | |||||
| return; | |||||
| } | |||||
| try { | |||||
| // Setup the parser | |||||
| Parser p = new Parser(); | |||||
| p.setEntityResolver(new ACSResolver()); | |||||
| // Setup the builder | |||||
| XmlDocumentBuilder builder = new XmlDocumentBuilder(); | |||||
| SimpleElementFactory fact = new SimpleElementFactory(); | |||||
| fact.addMapping(new Properties(), | |||||
| ACSDocumentType.class.getClassLoader()); | |||||
| builder.setElementFactory(fact); | |||||
| builder.setParser(p); | |||||
| DtdHandler dtdh = new DtdHandler(); | |||||
| p.setDTDHandler(dtdh); | |||||
| String coreDoc = XMLDOC_1 + DTD_1 + XMLDOC_2; | |||||
| String optionalDoc = XMLDOC_1 + DTD_2 + XMLDOC_2; | |||||
| // Parse the core task DTD | |||||
| elementMap = coreElementMap; | |||||
| InputSource xmldocCore = new InputSource( | |||||
| new ByteArrayInputStream(coreDoc.getBytes())); | |||||
| p.parse(xmldocCore); | |||||
| // Parse the core task DTD | |||||
| elementMap = optionalElementMap; | |||||
| InputSource xmldocOptional = new InputSource( | |||||
| new ByteArrayInputStream(optionalDoc.getBytes())); | |||||
| p.parse(xmldocOptional); | |||||
| isInit = true; | |||||
| } catch (Exception e) { | |||||
| System.out.println(e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns the dtd element. | |||||
| * | |||||
| * @param elementType CORE_ELEMENT or OPTIONAL_ELEMENT | |||||
| * @param name the element name | |||||
| */ | |||||
| public DtdElement findElement(int elementType, String name) { | |||||
| if (elementType == OPTIONAL_ELEMENT) { | |||||
| return (DtdElement) optionalElementMap.get(name); | |||||
| } | |||||
| return (DtdElement) coreElementMap.get(name); | |||||
| } | |||||
| /** | |||||
| * Class which represents a DTD element. | |||||
| */ | |||||
| static class DtdElement { | |||||
| private String _name; | |||||
| private String[] _contentModel; | |||||
| private DtdAttributes _map = new DtdAttributes(); | |||||
| public String getName() { | |||||
| return _name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| _name = name; | |||||
| } | |||||
| public String[] getContentModel() { | |||||
| return _contentModel; | |||||
| } | |||||
| public void setContentModel(String[] model) { | |||||
| _contentModel = model; | |||||
| } | |||||
| public DtdAttributes getAttributes() { | |||||
| return _map; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Class which represents a DTD attribute. | |||||
| */ | |||||
| static class DtdAttribute { | |||||
| private String _name; | |||||
| private String _type; | |||||
| private String[] _options; | |||||
| private String _defaultValue; | |||||
| private boolean _isFixed; | |||||
| private boolean _isRequired; | |||||
| public String getName() { | |||||
| return _name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| _name = name; | |||||
| } | |||||
| public String getType() { | |||||
| return _type; | |||||
| } | |||||
| public void setType(String type) { | |||||
| _type = type; | |||||
| } | |||||
| public String getDefaultValue() { | |||||
| return _defaultValue; | |||||
| } | |||||
| public void setDefaultValue(String value) { | |||||
| _defaultValue = value; | |||||
| } | |||||
| public String[] getOptions() { | |||||
| return _options; | |||||
| } | |||||
| public void setOptions(String[] s) { | |||||
| _options = s; | |||||
| } | |||||
| public boolean isFixed() { | |||||
| return _isFixed; | |||||
| } | |||||
| public void setFixed(boolean value) { | |||||
| _isFixed = value; | |||||
| } | |||||
| public boolean isRequired() { | |||||
| return _isRequired; | |||||
| } | |||||
| public void setRequired(boolean value) { | |||||
| _isRequired = value; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Class which represents a collection of DTD attributes. | |||||
| */ | |||||
| public static class DtdAttributes extends HashMap { | |||||
| /** | |||||
| * Default constructor | |||||
| */ | |||||
| public DtdAttributes() { | |||||
| } | |||||
| /** | |||||
| * Adds the Attribute | |||||
| * | |||||
| * @param attribute new attribute | |||||
| */ | |||||
| public void addAttribute(DtdAttribute attribute) { | |||||
| put(attribute.getName(), attribute); | |||||
| } | |||||
| /** | |||||
| * Return the requested attribute | |||||
| * | |||||
| * @param name attribute name | |||||
| * @returns the requested attribute | |||||
| */ | |||||
| public DtdAttribute getAttribute(String name) { | |||||
| return (DtdAttribute) get(name); | |||||
| } | |||||
| /** | |||||
| * @returns an array of the optional attribute names | |||||
| */ | |||||
| public String[] getOptionalAttributes() { | |||||
| ArrayList list = new ArrayList(); | |||||
| Iterator i = values().iterator(); | |||||
| while(i.hasNext()) { | |||||
| DtdAttribute a = (DtdAttribute)i.next(); | |||||
| if (!a.isRequired()) { | |||||
| list.add(a.getName()); | |||||
| } | |||||
| } | |||||
| String[] result = new String[list.size()]; | |||||
| list.toArray(result); | |||||
| return result; | |||||
| } | |||||
| /** | |||||
| * @returns an array of the required attribute names | |||||
| */ | |||||
| public String[] getRequiredAttributes() { | |||||
| ArrayList list = new ArrayList(); | |||||
| Iterator i = values().iterator(); | |||||
| while(i.hasNext()) { | |||||
| DtdAttribute a = (DtdAttribute)i.next(); | |||||
| if (a.isRequired()) { | |||||
| list.add(a.getName()); | |||||
| } | |||||
| } | |||||
| String[] result = new String[list.size()]; | |||||
| list.toArray(result); | |||||
| return result; | |||||
| } | |||||
| /** | |||||
| * @returns an array of the all attribute names | |||||
| */ | |||||
| public String[] getAttributes() { | |||||
| ArrayList list = new ArrayList(); | |||||
| Iterator i = values().iterator(); | |||||
| while(i.hasNext()) { | |||||
| DtdAttribute a = (DtdAttribute)i.next(); | |||||
| list.add(a.getName()); | |||||
| } | |||||
| String[] result = new String[list.size()]; | |||||
| list.toArray(result); | |||||
| return result; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * When parsing XML documents, DTD related events are signaled through | |||||
| * this interface. | |||||
| */ | |||||
| class DtdHandler implements DtdEventListener { | |||||
| public void externalDtdDecl ( | |||||
| String publicId, | |||||
| String systemId) | |||||
| throws SAXException { } | |||||
| public void internalDtdDecl ( | |||||
| String internalSubset) | |||||
| throws SAXException { } | |||||
| public void internalEntityDecl ( | |||||
| String name, | |||||
| String value) | |||||
| throws SAXException { } | |||||
| public void externalEntityDecl ( | |||||
| String name, | |||||
| String publicId, | |||||
| String systemId) | |||||
| throws SAXException { } | |||||
| public void endDtd () | |||||
| throws SAXException { } | |||||
| public void notationDecl ( | |||||
| String name, | |||||
| String publicId, | |||||
| String systemId) | |||||
| throws SAXException { } | |||||
| public void unparsedEntityDecl ( | |||||
| String name, | |||||
| String publicId, | |||||
| String systemId, | |||||
| String notationName) | |||||
| throws SAXException { } | |||||
| public void startDtd ( | |||||
| String rootName | |||||
| ) throws SAXException | |||||
| { | |||||
| elementMap.clear(); | |||||
| } | |||||
| /** | |||||
| * Reports an attribute declaration found within the DTD. | |||||
| * | |||||
| * @param elementName The name of the element to which the attribute | |||||
| * applies; this includes a namespace prefix if one was used within | |||||
| * the DTD. | |||||
| * @param attributeName The name of the attribute being declared; this | |||||
| * includes a namespace prefix if one was used within the DTD. | |||||
| * @param attributeType The type of the attribute, either CDATA, NMTOKEN, | |||||
| * NMTOKENS, ENTITY, ENTITIES, NOTATION, ID, IDREF, or IDREFS as | |||||
| * defined in the XML specification; or null for enumerations. | |||||
| * @param options When attributeType is null or NOTATION, this is an | |||||
| * array of the values which are permitted; it is otherwise null. | |||||
| * @param defaultValue When not null, this provides the default value | |||||
| * of this attribute. | |||||
| * @param isFixed When true, the defaultValue is the only legal value. | |||||
| * (Precludes isRequired.) | |||||
| * @param isRequired When true, the attribute value must be provided | |||||
| * for each element of the named type. (Precludes isFixed.) | |||||
| */ | |||||
| public void attributeDecl ( | |||||
| String elementName, | |||||
| String attributeName, | |||||
| String attributeType, | |||||
| String options [], | |||||
| String defaultValue, | |||||
| boolean isFixed, | |||||
| boolean isRequired | |||||
| ) throws SAXException | |||||
| { | |||||
| // Try to find the element. | |||||
| DtdElement e = (DtdElement) elementMap.get(elementName); | |||||
| if (e == null) { | |||||
| throw new SAXException("element " + elementName + | |||||
| " not declared before attributes"); | |||||
| } | |||||
| // Update the element's attribute. | |||||
| DtdAttribute attrib = new DtdAttribute(); | |||||
| attrib.setName(attributeName); | |||||
| attrib.setType(attributeType); | |||||
| attrib.setFixed(isFixed); | |||||
| attrib.setRequired(isRequired); | |||||
| attrib.setDefaultValue(defaultValue); | |||||
| attrib.setOptions(options); | |||||
| e.getAttributes().addAttribute(attrib); | |||||
| } | |||||
| /** | |||||
| * Reports an element declaration found within the DTD. The content | |||||
| * model will be a string such as "ANY", "EMPTY", "(#PCDATA|foo)*", | |||||
| * or "(caption?,tr*)". | |||||
| * | |||||
| * @param elementName The name of the element; this includes a namespace | |||||
| * prefix if one was used within the DTD. | |||||
| * @param contentModel The content model as defined in the DTD, with | |||||
| * any whitespace removed. | |||||
| */ | |||||
| public void elementDecl ( | |||||
| String elementName, | |||||
| String contentModel | |||||
| ) throws SAXException | |||||
| { | |||||
| DtdElement e = new DtdElement(); | |||||
| e.setName(elementName); | |||||
| // Break the contentModel string into pieces. | |||||
| ArrayList list = new ArrayList(); | |||||
| StringTokenizer st = new StringTokenizer(contentModel, "|()*"); | |||||
| while (st.hasMoreTokens()) { | |||||
| String s = st.nextToken(); | |||||
| if ( s.length() > 0 && !"EMPTY".equals(s) ) { | |||||
| list.add(s); | |||||
| } | |||||
| } | |||||
| String[] array = new String[list.size()]; | |||||
| list.toArray(array); | |||||
| e.setContentModel(array); | |||||
| // Update the map | |||||
| elementMap.put(e.getName(), e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * We provide the location for the ant dtds. | |||||
| */ | |||||
| class ACSResolver implements org.xml.sax.EntityResolver { | |||||
| /** | |||||
| * We process the project.dtd and project-ext.dtd. | |||||
| * | |||||
| * @param name Used to find alternate copies of the entity, when | |||||
| * this value is non-null; this is the XML "public ID". | |||||
| * @param uri Used when no alternate copy of the entity is found; | |||||
| * this is the XML "system ID", normally a URI. | |||||
| */ | |||||
| public InputSource resolveEntity ( | |||||
| String publicId, | |||||
| String systemId) | |||||
| throws SAXException, IOException { | |||||
| InputStream result = null; | |||||
| // Is it the project.dtd? | |||||
| if (systemId.indexOf(DTD_1) != -1) { | |||||
| try { | |||||
| // Look for it as a resource | |||||
| result = getClass().getResourceAsStream(DTD_1); | |||||
| } catch (Exception e) {} | |||||
| } | |||||
| // Is it the project-ext.dtd? | |||||
| if (systemId.indexOf(DTD_2) != -1) { | |||||
| try { | |||||
| // Look for it as a resource | |||||
| result = getClass().getResourceAsStream(DTD_2); | |||||
| } catch (Exception e) {} | |||||
| } | |||||
| if (result != null) { | |||||
| return new InputSource(result); | |||||
| } | |||||
| // Is it the share.dtd? | |||||
| if (systemId.indexOf(DTD_SHARE) != -1) { | |||||
| try { | |||||
| // Look for it as a resource | |||||
| result = getClass().getResourceAsStream(DTD_SHARE); | |||||
| } catch (Exception e) {} | |||||
| } | |||||
| if (result != null) { | |||||
| return new InputSource(result); | |||||
| } | |||||
| // Otherwise, use the default impl. | |||||
| com.sun.xml.parser.Resolver r = new com.sun.xml.parser.Resolver(); | |||||
| return r.resolveEntity(publicId, systemId); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,103 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.acs.ACSDocumentType.DtdElement; | |||||
| import java.util.Properties; | |||||
| /** | |||||
| * Represents the attributes defined by the DTD. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class ACSDtdDefinedAttributes extends Properties { | |||||
| ACSDocumentType.DtdElement _element = null; | |||||
| /** | |||||
| * Default constructor | |||||
| */ | |||||
| public ACSDtdDefinedAttributes() { | |||||
| this(null); | |||||
| } | |||||
| /** | |||||
| * Constructor | |||||
| * | |||||
| * @param element provides information about possible attributes. | |||||
| */ | |||||
| public ACSDtdDefinedAttributes(ACSDocumentType.DtdElement element) { | |||||
| _element = element; | |||||
| } | |||||
| /** | |||||
| * Return the required attributes or null. | |||||
| */ | |||||
| public String[] getRequiredAttributes() { | |||||
| if (_element == null) { | |||||
| return null; | |||||
| } | |||||
| return _element.getAttributes().getRequiredAttributes(); | |||||
| } | |||||
| /** | |||||
| * Return the optional attributes or null. | |||||
| */ | |||||
| public String[] getOptionalAttributes() { | |||||
| if (_element == null) { | |||||
| return null; | |||||
| } | |||||
| return _element.getAttributes().getOptionalAttributes(); | |||||
| } | |||||
| } | |||||
| @@ -1,329 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.command.NewElementCmd; | |||||
| import org.apache.tools.ant.gui.util.Collections; | |||||
| import org.w3c.dom.*; | |||||
| import java.beans.*; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Element defined by the DTD. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class ACSDtdDefinedElement extends ACSTreeNodeElement | |||||
| implements ACSInfoProvider { | |||||
| /** Property name for the task type. */ | |||||
| public static final String TASK_TYPE = "taskType"; | |||||
| /** Property name for attributes. It's called "namedValues" so | |||||
| * it doesn't collide with the Node.getAttributes() method. */ | |||||
| public static final String NAMED_VALUES = "namedValues"; | |||||
| /** The ANT DTD */ | |||||
| static ACSDocumentType docType = new ACSDocumentType(); | |||||
| /** Our menu string */ | |||||
| public String[] menuString = null; | |||||
| /** The DTD element we represent */ | |||||
| private ACSDocumentType.DtdElement _dtdElement = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSDtdDefinedElement() { | |||||
| // Load the DTD | |||||
| docType.init(); | |||||
| } | |||||
| /** | |||||
| * Get the task type. | |||||
| * | |||||
| * @return Task type. | |||||
| */ | |||||
| public String getTaskType() { | |||||
| return getTagName(); | |||||
| } | |||||
| /** | |||||
| * Get the display name of this. | |||||
| * | |||||
| * @return Display name. | |||||
| */ | |||||
| public String getDisplayName() { | |||||
| String name = getTagName(); | |||||
| // Is there only one attribute? | |||||
| if (getAttributes().getLength() == 1) { | |||||
| Node onlyNode = getAttributes().item(0); | |||||
| // Display the only attribute | |||||
| name += ": " + onlyNode.getNodeValue(); | |||||
| } else { | |||||
| // Display one of these attributes | |||||
| // if they are present. | |||||
| final String[] DISPLAY_ATTRIBUTES = | |||||
| { | |||||
| "name", | |||||
| "id", | |||||
| "property" | |||||
| }; | |||||
| for(int i = 0; i < DISPLAY_ATTRIBUTES.length; i++) { | |||||
| Node testNode = | |||||
| getAttributes().getNamedItem(DISPLAY_ATTRIBUTES[i]); | |||||
| if (testNode != null) { | |||||
| name += ": " + testNode.getNodeValue(); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| return name; | |||||
| } | |||||
| /** | |||||
| * Set the task type. | |||||
| * | |||||
| * @param type Type name. | |||||
| */ | |||||
| public void setTaskType(String type) { | |||||
| setTag(type); | |||||
| } | |||||
| /** | |||||
| * Get the attributes (named value mappings). This method is not named | |||||
| * getAttributes() because there is already a method of that name in | |||||
| * the Node interface. | |||||
| * | |||||
| * @return Name-value mappings. | |||||
| */ | |||||
| public ACSDtdDefinedAttributes getNamedValues() { | |||||
| ACSDtdDefinedAttributes retval = | |||||
| new ACSDtdDefinedAttributes(getDtdElement()); | |||||
| NamedNodeMap attribs = getAttributes(); | |||||
| for(int i = 0, len = attribs.getLength(); i < len; i++) { | |||||
| Node n = attribs.item(i); | |||||
| retval.setProperty(n.getNodeName(), n.getNodeValue()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the attributes. This method sets the Node attirbutes using | |||||
| * the given Map containing name-value pairs. | |||||
| * | |||||
| * @param attributes New attribute set. | |||||
| */ | |||||
| public void setNamedValues(ACSDtdDefinedAttributes attributes) { | |||||
| // XXX this code really sucks. It is really annoying that the | |||||
| // DOM interfaces don't have a general "setAttributes()" or | |||||
| // "removeAllAttributes()" method, but instead make you | |||||
| // remove each attribute individually, or require you to figure | |||||
| // out what the differences are between the two. | |||||
| // Although this is very inefficient, I'm taking the conceptually | |||||
| // simplistic approach to this and brute force removing the existing | |||||
| // set and replacing it with a brand new set. If this becomes a | |||||
| // performance concern (which I doubt it will) it can be optimized | |||||
| // later. | |||||
| ACSDtdDefinedAttributes old = (ACSDtdDefinedAttributes) getNamedValues(); | |||||
| Enumeration enum = old.propertyNames(); | |||||
| while(enum.hasMoreElements()) { | |||||
| String name = (String) enum.nextElement(); | |||||
| removeAttribute(name); | |||||
| } | |||||
| enum = attributes.propertyNames(); | |||||
| while(enum.hasMoreElements()) { | |||||
| String key = (String) enum.nextElement(); | |||||
| setAttribute(key, attributes.getProperty(key)); | |||||
| } | |||||
| firePropertyChange(NAMED_VALUES, old, attributes); | |||||
| } | |||||
| /** | |||||
| * Returns the menu items which may be used for this element. | |||||
| */ | |||||
| public String[] getMenuString() { | |||||
| // If it already exists, use it. | |||||
| if (menuString != null) { | |||||
| return menuString; | |||||
| } | |||||
| // Find the DtdElement | |||||
| String name = getTagName(); | |||||
| // Are we the project element? | |||||
| boolean isProject = false; | |||||
| if (name.equals("project")) { | |||||
| isProject = true; | |||||
| } | |||||
| ACSDocumentType.DtdElement e = | |||||
| docType.findElement(ACSDocumentType.CORE_ELEMENT, name); | |||||
| if (e == null) { | |||||
| e = docType.findElement(ACSDocumentType.OPTIONAL_ELEMENT, name); | |||||
| } | |||||
| if (e != null) { | |||||
| // Use the content model (all the possible | |||||
| // sub-elements) to create the menu. | |||||
| String[] temp = e.getContentModel(); | |||||
| // Sort the items | |||||
| List list = Collections.fill(null, temp); | |||||
| java.util.Collections.sort(list); | |||||
| list.toArray(temp); | |||||
| int size = (temp.length > 5) ? 5 : temp.length; | |||||
| // The project doesn't need a delete menu | |||||
| if (isProject) { | |||||
| menuString = new String[size+1]; | |||||
| } else { | |||||
| menuString = new String[size+2]; | |||||
| } | |||||
| System.arraycopy(temp, 0, menuString, 0, size); | |||||
| } else { | |||||
| // This is for elements not in the DTD | |||||
| menuString = new String[2]; | |||||
| } | |||||
| if (isProject) { | |||||
| menuString[menuString.length-1] = "newElement"; | |||||
| } else { | |||||
| // Add the delete and generic create commands | |||||
| menuString[menuString.length-1] = "deleteElement"; | |||||
| menuString[menuString.length-2] = "newElement"; | |||||
| } | |||||
| return menuString; | |||||
| } | |||||
| /** | |||||
| * Returns the string to use if an action ID is not found. | |||||
| * In our case, the newElement command is used. | |||||
| */ | |||||
| public String getDefaultActionID() { | |||||
| return "newElement"; | |||||
| } | |||||
| /** | |||||
| * Returns a string array which contains this elements | |||||
| * possible children. | |||||
| * | |||||
| * @param childType ACSDocumentType.CORE_ELEMENT or | |||||
| * ACSDocumentType.OPTIONAL_ELEMENT | |||||
| */ | |||||
| public String[] getPossibleChildren(int childType) { | |||||
| String name = getTagName(); | |||||
| ACSDocumentType.DtdElement e = | |||||
| docType.findElement(childType, name); | |||||
| if (e != null) { | |||||
| return e.getContentModel(); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * Adds the attributes which are required by this node. | |||||
| */ | |||||
| public void addRequiredAttributes() { | |||||
| ACSDocumentType.DtdElement e = getDtdElement(); | |||||
| if (e == null) { | |||||
| return; | |||||
| } | |||||
| String[] attributes = e.getAttributes().getRequiredAttributes(); | |||||
| if (attributes == null) { | |||||
| return; | |||||
| } | |||||
| for(int i = 0; i < attributes.length; i++) { | |||||
| if ( getAttributes().getNamedItem(attributes[i]) == null) { | |||||
| // XXX should set to default? | |||||
| setAttribute(attributes[i], ""); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns the DTD element we represent | |||||
| */ | |||||
| private ACSDocumentType.DtdElement getDtdElement() { | |||||
| if (_dtdElement != null) { | |||||
| return _dtdElement; | |||||
| } | |||||
| String name = getNodeName(); | |||||
| _dtdElement = docType.findElement(ACSDocumentType.CORE_ELEMENT, name); | |||||
| if (_dtdElement == null) { | |||||
| _dtdElement = docType.findElement( | |||||
| ACSDocumentType.OPTIONAL_ELEMENT, name); | |||||
| } | |||||
| return _dtdElement; | |||||
| } | |||||
| } | |||||
| @@ -1,139 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.customizer.DynamicCustomizer; | |||||
| import org.apache.tools.ant.gui.modules.edit.DtdAttributePropertyEditor; | |||||
| import java.beans.*; | |||||
| /** | |||||
| * BeanInfo for the ACSDtdDefinedElement class. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class ACSDtdDefinedElementBeanInfo extends BaseBeanInfo { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSDtdDefinedElementBeanInfo() { | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public Class getType() { | |||||
| return ACSDtdDefinedElement.class; | |||||
| } | |||||
| /** | |||||
| * Get the customizer type. | |||||
| * | |||||
| * @return Customizer type. | |||||
| */ | |||||
| public Class getCustomizerType() { | |||||
| return Customizer.class; | |||||
| } | |||||
| /** | |||||
| * Get the property descriptors. | |||||
| * | |||||
| * @return Property descriptors. | |||||
| */ | |||||
| public PropertyDescriptor[] getPropertyDescriptors() { | |||||
| PropertyDescriptor[] retval = null; | |||||
| try { | |||||
| retval = new PropertyDescriptor[] { | |||||
| new PropertyDescriptor(ACSDtdDefinedElement.TASK_TYPE, | |||||
| ACSDtdDefinedElement.class, | |||||
| "getTaskType", null), | |||||
| new PropertyDescriptor(ACSDtdDefinedElement.NAMED_VALUES, | |||||
| ACSDtdDefinedElement.class), | |||||
| new PropertyDescriptor(ACSDtdDefinedElement.XML_STRING, | |||||
| ACSDtdDefinedElement.class, | |||||
| "getXMLString", null) | |||||
| }; | |||||
| int pos = 0; | |||||
| retval[pos++].setDisplayName(getResources().getString( | |||||
| getClass(),ACSDtdDefinedElement.TASK_TYPE)); | |||||
| retval[pos++].setDisplayName(getResources().getString( | |||||
| getClass(),ACSDtdDefinedElement.NAMED_VALUES)); | |||||
| retval[pos++].setDisplayName(getResources().getString( | |||||
| getClass(),ACSDtdDefinedElement.XML_STRING)); | |||||
| setSortingOrder(retval); | |||||
| } catch(IntrospectionException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new Error(ex.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** Customizer for this bean info. */ | |||||
| public static class Customizer extends DynamicCustomizer { | |||||
| static { | |||||
| PropertyEditorManager.registerEditor( | |||||
| ACSDtdDefinedAttributes.class, DtdAttributePropertyEditor.class); | |||||
| } | |||||
| public Customizer() { | |||||
| super(ACSDtdDefinedElement.class); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,153 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| import java.beans.PropertyChangeListener; | |||||
| import java.beans.PropertyChangeEvent; | |||||
| import java.beans.PropertyChangeSupport; | |||||
| /** | |||||
| * Abstract base class for all Ant Construction Set | |||||
| * elements. Depends on the JAXP XML library from Sun. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch */ | |||||
| public abstract class ACSElement extends ElementNode { | |||||
| /** Name of the 'xmlString' property. */ | |||||
| public static final String XML_STRING = "xmlString"; | |||||
| /** Event support. */ | |||||
| private PropertyChangeSupport _propSupport = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| protected ACSElement() { | |||||
| } | |||||
| /** | |||||
| * Get the display name of this. | |||||
| * | |||||
| * @return Display name. | |||||
| */ | |||||
| public String getDisplayName() { | |||||
| return getTagName(); | |||||
| } | |||||
| /** | |||||
| * Get the XML representation of this. | |||||
| * | |||||
| * @return XML representation. | |||||
| */ | |||||
| public String getXMLString() { | |||||
| return toString(); | |||||
| } | |||||
| /** | |||||
| * Set the given attribute. | |||||
| * | |||||
| * @param name Name of the attribute. | |||||
| * @param value Value of the attribute. | |||||
| */ | |||||
| public void setAttribute(String name, String value) { | |||||
| if(value == null && getAttribute(name).length() != 0) { | |||||
| removeAttribute(name); | |||||
| } | |||||
| else { | |||||
| super.setAttribute(name, value); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Add a change listener. | |||||
| * | |||||
| * @param l Listener to add. | |||||
| */ | |||||
| public void addPropertyChangeListener(PropertyChangeListener l) { | |||||
| if(_propSupport == null) { | |||||
| _propSupport = new PropertyChangeSupport(this); | |||||
| } | |||||
| _propSupport.addPropertyChangeListener(l); | |||||
| } | |||||
| /** | |||||
| * Remove a change listener | |||||
| * | |||||
| * @param l Listener to remove. | |||||
| */ | |||||
| public void removePropertyChangeListener(PropertyChangeListener l) { | |||||
| if(_propSupport == null) { | |||||
| _propSupport = new PropertyChangeSupport(this); | |||||
| } | |||||
| _propSupport.removePropertyChangeListener(l); | |||||
| } | |||||
| /** | |||||
| * Fire a change event to all listener. | |||||
| * | |||||
| * @param propName Name of the property. | |||||
| * @param oldValue The old value. | |||||
| * @param newValue The new value. | |||||
| */ | |||||
| protected void firePropertyChange( | |||||
| String propName, Object oldValue, Object newValue) { | |||||
| if(_propSupport != null) { | |||||
| _propSupport.firePropertyChange(propName, oldValue, newValue); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,299 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import javax.xml.parsers.*; | |||||
| import java.io.IOException; | |||||
| import java.io.File; | |||||
| import java.net.URL; | |||||
| import org.w3c.dom.*; | |||||
| import org.xml.sax.SAXException; | |||||
| import com.sun.xml.parser.Parser; | |||||
| import com.sun.xml.tree.*; | |||||
| import java.util.Properties; | |||||
| import java.util.Enumeration; | |||||
| import com.sun.xml.parser.Resolver; | |||||
| /** | |||||
| * Factory for loading Ant Construction set elements. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSFactory { | |||||
| /** Singleton instance of the factory. */ | |||||
| private static ACSFactory _instance = null; | |||||
| /** Element maping. */ | |||||
| private static final Properties _elementMap = new Properties(); | |||||
| static { | |||||
| try { | |||||
| // First we bootstrap our knowledge of the Ant tasks by reading | |||||
| // in the taskdef definitions and assigning them the default | |||||
| // task element class. | |||||
| _elementMap.load(org.apache.tools.ant.taskdefs.Ant.class. | |||||
| getResourceAsStream("defaults.properties")); | |||||
| Enumeration enum = _elementMap.propertyNames(); | |||||
| while(enum.hasMoreElements()) { | |||||
| String name = (String) enum.nextElement(); | |||||
| // XXX the name of the class needs to be stored externally. | |||||
| _elementMap.setProperty( | |||||
| name, "org.apache.tools.ant.gui.acs.ACSDtdDefinedElement"); | |||||
| } | |||||
| // Then we add/override the local definitions. | |||||
| _elementMap.load(ACSFactory.class. | |||||
| getResourceAsStream("acs-element.properties")); | |||||
| } | |||||
| catch(Throwable ex) { | |||||
| // If something wrong happens here we can't do much more... | |||||
| ex.printStackTrace(); | |||||
| System.exit(1); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| private ACSFactory() { | |||||
| } | |||||
| /** | |||||
| * Get an instance of the factory. | |||||
| * | |||||
| * @return Factory instance. | |||||
| */ | |||||
| public static ACSFactory getInstance() { | |||||
| if(_instance == null) { | |||||
| _instance = new ACSFactory(); | |||||
| } | |||||
| return _instance; | |||||
| } | |||||
| /** | |||||
| * Load a project from the given XML file. | |||||
| * XXX fix me. | |||||
| * | |||||
| * @param location Location of the file. | |||||
| * @return Loaded project. | |||||
| */ | |||||
| public ACSProjectElement load(File location) throws IOException { | |||||
| return load(new URL("file", null, location.getPath())); | |||||
| } | |||||
| /** | |||||
| * Load a project from the given XML file. | |||||
| * XXX fix me. | |||||
| * | |||||
| * @param location Location of the file. | |||||
| * @return Loaded project. | |||||
| */ | |||||
| public ACSProjectElement load(URL location) throws IOException { | |||||
| XmlDocument doc = null; | |||||
| try { | |||||
| SAXParser sax = SAXParserFactory.newInstance().newSAXParser(); | |||||
| Parser parser = (Parser) sax.getParser(); | |||||
| XmlDocumentBuilder builder = new XmlDocumentBuilder(); | |||||
| builder.setIgnoringLexicalInfo(false); | |||||
| SimpleElementFactory fact = new SimpleElementFactory(); | |||||
| fact.addMapping(_elementMap, ACSFactory.class.getClassLoader()); | |||||
| builder.setElementFactory(fact); | |||||
| parser.setDocumentHandler(builder); | |||||
| parser.setEntityResolver(new Resolver()); | |||||
| //parser.setErrorHandler(); | |||||
| sax.parse(location.openStream(), null); | |||||
| doc = builder.getDocument(); | |||||
| } | |||||
| catch(ParserConfigurationException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new IOException(ex.getMessage()); | |||||
| } | |||||
| catch(SAXException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new IOException(ex.getMessage()); | |||||
| } | |||||
| return (ACSProjectElement) doc.getDocumentElement(); | |||||
| } | |||||
| /** | |||||
| * Create a new, empty project. | |||||
| * | |||||
| * @return Empty project. | |||||
| */ | |||||
| public ACSProjectElement createProject() { | |||||
| SimpleElementFactory fact = new SimpleElementFactory(); | |||||
| fact.addMapping(_elementMap, ACSFactory.class.getClassLoader()); | |||||
| XmlDocument doc = new XmlDocument(); | |||||
| doc.setElementFactory(fact); | |||||
| return (ACSProjectElement) doc.createElement("project"); | |||||
| } | |||||
| /** | |||||
| * Create a new target. | |||||
| * | |||||
| * @param project Project the target is assigned to. | |||||
| * @return New, unnamed target. | |||||
| */ | |||||
| public ACSTargetElement createTarget(ACSProjectElement project) { | |||||
| ACSTargetElement retval = (ACSTargetElement) project. | |||||
| getOwnerDocument().createElement("target"); | |||||
| indent(project, 1); | |||||
| project.appendChild(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Create a new task. | |||||
| * | |||||
| * @param target Target the task is assigned to. | |||||
| * @return New, unnamed task. | |||||
| */ | |||||
| public ACSTaskElement createTask(ACSTargetElement target) { | |||||
| ACSTaskElement retval = (ACSTaskElement) target. | |||||
| getOwnerDocument().createElement("task"); | |||||
| indent(target, 2); | |||||
| target.appendChild(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Create a new property. | |||||
| * | |||||
| * @param node the Node to assign the property to. | |||||
| * @return New, unnamed property. | |||||
| */ | |||||
| public ACSPropertyElement createProperty(ACSElement node) { | |||||
| ACSPropertyElement retval = (ACSPropertyElement) node. | |||||
| getOwnerDocument().createElement("property"); | |||||
| // XXX fixme. | |||||
| indent(node, 1); | |||||
| node.appendChild(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Create a new element. | |||||
| * | |||||
| * @param node the Node to assign the property to. | |||||
| * @param name the new elements type. | |||||
| * @return New, unnamed property. | |||||
| */ | |||||
| public ACSElement createElement(ACSElement node, String name) { | |||||
| ACSElement retval = (ACSElement) node. | |||||
| getOwnerDocument().createElement(name); | |||||
| // XXX fixme. | |||||
| indent(node, 1); | |||||
| addRequiredAttributes(retval); | |||||
| node.appendChild(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Add required attributes to the node. | |||||
| * | |||||
| * @param node the Node to add the attrinutes to. | |||||
| */ | |||||
| public void addRequiredAttributes(ACSElement node) { | |||||
| if (node instanceof ACSDtdDefinedElement) { | |||||
| ACSDtdDefinedElement dtdElement = | |||||
| (ACSDtdDefinedElement) node; | |||||
| dtdElement.addRequiredAttributes(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Insert a new line and indentation at the end of the given | |||||
| * node in preparation for a new element being added. | |||||
| * | |||||
| * @param node Node to append indent to. | |||||
| * @param level Indentation level. | |||||
| */ | |||||
| private void indent(ACSElement node, int level) { | |||||
| StringBuffer buf = new StringBuffer("\n"); | |||||
| for(int i = 0; i < level; i++) { | |||||
| buf.append(" "); | |||||
| } | |||||
| Text text = node.getOwnerDocument().createTextNode(buf.toString()); | |||||
| node.appendChild(text); | |||||
| } | |||||
| /** | |||||
| * Test code | |||||
| * | |||||
| * @param args XML file to parse. | |||||
| */ | |||||
| public static void main(String[] args) { | |||||
| try { | |||||
| ACSFactory f = ACSFactory.getInstance(); | |||||
| System.out.println(f.load(new File(args[0]))); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,75 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| /** | |||||
| * Provides menu infomation for a node. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public interface ACSInfoProvider { | |||||
| /** | |||||
| * Returns the menu items which may be used on this node. | |||||
| * If the strings are not valid action IDs, use | |||||
| * <code>getDefaultActionID</code> to find the action for the menu item. | |||||
| */ | |||||
| public String[] getMenuString(); | |||||
| /** | |||||
| * Returns the action ID to use for a menu item which does not | |||||
| * represent a valid action ID. | |||||
| */ | |||||
| public String getDefaultActionID(); | |||||
| } | |||||
| @@ -1,127 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| import java.util.StringTokenizer; | |||||
| /** | |||||
| * Class representing an element with a name and description. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSNamedElement extends ACSDtdDefinedElement { | |||||
| /** The 'name' property name. */ | |||||
| public static final String NAME = "name"; | |||||
| /** The discription property name. */ | |||||
| public static final String DESCRIPTION = "description"; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSNamedElement() { | |||||
| } | |||||
| /** | |||||
| * Get the target name. | |||||
| * | |||||
| * @return Target name. | |||||
| */ | |||||
| public String getName() { | |||||
| return getAttribute(NAME); | |||||
| } | |||||
| /** | |||||
| * Set the name. | |||||
| * | |||||
| * @param name New name value. | |||||
| */ | |||||
| public void setName(String name) { | |||||
| String old = getName(); | |||||
| setAttribute(NAME, name); | |||||
| firePropertyChange(NAME, old, name); | |||||
| } | |||||
| /** | |||||
| * Get the long description of the target. | |||||
| * | |||||
| * @return Target description. | |||||
| */ | |||||
| public String getDescription() { | |||||
| return getAttribute(DESCRIPTION); | |||||
| } | |||||
| /** | |||||
| * Set the description | |||||
| * | |||||
| * @param description New description value. | |||||
| */ | |||||
| public void setDescription(String description) { | |||||
| String old = getDescription(); | |||||
| setAttribute(DESCRIPTION, description); | |||||
| firePropertyChange(DESCRIPTION, old, description); | |||||
| } | |||||
| /** | |||||
| * Get the display name. | |||||
| * | |||||
| * @return Display name. | |||||
| */ | |||||
| public String getDisplayName() { | |||||
| return getName(); | |||||
| } | |||||
| } | |||||
| @@ -1,167 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| import java.net.URL; | |||||
| import java.io.File; | |||||
| /** | |||||
| * Class representing a project element in the build file. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSProjectElement extends ACSNamedElement { | |||||
| /** The 'default' property name. */ | |||||
| public static final String DEFAULT = "default"; | |||||
| /** The 'basdir' property name. */ | |||||
| public static final String BASEDIR = "basedir"; | |||||
| /** Property name of the persistence location. */ | |||||
| public static final String LOCATION = "location"; | |||||
| /** The location where this project is persisted. */ | |||||
| private URL _location = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSProjectElement() { | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public Class getType() { | |||||
| return ACSProjectElement.class; | |||||
| } | |||||
| /** | |||||
| * Get the name of the default target. | |||||
| * | |||||
| * @return Default target name. | |||||
| */ | |||||
| public String getDefault() { | |||||
| return getAttribute(DEFAULT); | |||||
| } | |||||
| /** | |||||
| * Set the name of the default target. | |||||
| * | |||||
| * @param def Name of the default target. | |||||
| */ | |||||
| public void setDefault(String def) { | |||||
| String old = getDefault(); | |||||
| setAttribute(DEFAULT, def); | |||||
| firePropertyChange(DEFAULT, old, def); | |||||
| } | |||||
| /** | |||||
| * Get the specified base directory for the build. | |||||
| * | |||||
| * @return Base directory | |||||
| */ | |||||
| public String getBasedir() { | |||||
| return getAttribute(BASEDIR); | |||||
| } | |||||
| /** | |||||
| * Set the base directory for builds. | |||||
| * | |||||
| * @param baseDir Build base directory. | |||||
| */ | |||||
| public void setBasedir(String baseDir) { | |||||
| String old = getBasedir(); | |||||
| setAttribute(BASEDIR, baseDir); | |||||
| firePropertyChange(BASEDIR, old, baseDir); | |||||
| } | |||||
| /** | |||||
| * Get the location where this project is persisted. | |||||
| * | |||||
| * @return Saved location, or null if not persisted. | |||||
| */ | |||||
| public URL getLocation() { | |||||
| return _location; | |||||
| } | |||||
| /** | |||||
| * Set the loction where the project is persisted. | |||||
| * | |||||
| * @param location Location of project. | |||||
| */ | |||||
| public void setLocation(URL location) { | |||||
| URL old = _location; | |||||
| _location = location; | |||||
| firePropertyChange(LOCATION, old, _location); | |||||
| } | |||||
| /** | |||||
| * Set the loction where the project is persisted. | |||||
| * | |||||
| * @param location Location of project as a file. | |||||
| */ | |||||
| public void setLocation(File location) { | |||||
| try { | |||||
| setLocation(new URL("file", null, location.getAbsolutePath())); | |||||
| } | |||||
| catch(java.net.MalformedURLException ex) { | |||||
| // No reason why this should happen. | |||||
| // xxx Log me. | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,136 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.customizer.DynamicCustomizer; | |||||
| import java.beans.*; | |||||
| /** | |||||
| * BeanInfo for the ACSProjectElement class. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSProjectElementBeanInfo extends BaseBeanInfo { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSProjectElementBeanInfo() { | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public Class getType() { | |||||
| return ACSProjectElement.class; | |||||
| } | |||||
| /** | |||||
| * Get the customizer type. | |||||
| * | |||||
| * @return Customizer type. | |||||
| */ | |||||
| public Class getCustomizerType() { | |||||
| return Customizer.class; | |||||
| } | |||||
| /** | |||||
| * Get the property descriptors. | |||||
| * | |||||
| * @return Property descriptors. | |||||
| */ | |||||
| public PropertyDescriptor[] getPropertyDescriptors() { | |||||
| PropertyDescriptor[] retval = null; | |||||
| try { | |||||
| retval = new PropertyDescriptor[] { | |||||
| new PropertyDescriptor(ACSProjectElement.NAME, | |||||
| ACSProjectElement.class), | |||||
| new PropertyDescriptor(ACSProjectElement.DESCRIPTION, | |||||
| ACSProjectElement.class), | |||||
| new PropertyDescriptor(ACSProjectElement.DEFAULT, | |||||
| ACSProjectElement.class), | |||||
| new PropertyDescriptor(ACSProjectElement.BASEDIR, | |||||
| ACSProjectElement.class) | |||||
| }; | |||||
| retval[0].setDisplayName(getResources().getString( | |||||
| getClass(),ACSProjectElement.NAME)); | |||||
| retval[1].setDisplayName(getResources().getString( | |||||
| getClass(),ACSProjectElement.DESCRIPTION)); | |||||
| retval[2].setDisplayName(getResources().getString( | |||||
| getClass(),ACSProjectElement.DEFAULT)); | |||||
| retval[3].setDisplayName(getResources().getString( | |||||
| getClass(),ACSProjectElement.BASEDIR)); | |||||
| setSortingOrder(retval); | |||||
| } | |||||
| catch(IntrospectionException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new Error(ex.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** Customizer for this bean info. */ | |||||
| public static class Customizer extends DynamicCustomizer { | |||||
| public Customizer() { | |||||
| super(ACSProjectElement.class); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,154 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| /** | |||||
| * Element containing a property definition. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSPropertyElement extends ACSDtdDefinedElement { | |||||
| /** The 'name' property name. */ | |||||
| public static final String NAME = "name"; | |||||
| /** The 'value' property name. */ | |||||
| public static final String VALUE = "value"; | |||||
| /** The file to load properties from. */ | |||||
| public static final String FILE = "file"; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSPropertyElement() { | |||||
| } | |||||
| /** | |||||
| * Get the display name of this. | |||||
| * | |||||
| * @return Display name. | |||||
| */ | |||||
| public String getDisplayName() { | |||||
| String file = getFile(); | |||||
| if(file == null || file.trim().length() == 0) { | |||||
| return getName(); | |||||
| } | |||||
| else { | |||||
| return "file: " + file; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the property name. | |||||
| * | |||||
| * @return Property name. | |||||
| */ | |||||
| public String getName() { | |||||
| return getAttribute(NAME); | |||||
| } | |||||
| /** | |||||
| * Set the property name. | |||||
| * | |||||
| * @param name Property name. | |||||
| */ | |||||
| public void setName(String name) { | |||||
| String old = getName(); | |||||
| setAttribute(NAME, name); | |||||
| firePropertyChange(NAME, old, name); | |||||
| } | |||||
| /** | |||||
| * Get the property value. | |||||
| * | |||||
| * @return Property value. | |||||
| */ | |||||
| public String getValue() { | |||||
| return getAttribute(VALUE); | |||||
| } | |||||
| /** | |||||
| * Set the property value. | |||||
| * | |||||
| * @param name Property value. | |||||
| */ | |||||
| public void setValue(String value) { | |||||
| String old = getValue(); | |||||
| setAttribute(VALUE, value); | |||||
| firePropertyChange(VALUE, old, value); | |||||
| } | |||||
| /** | |||||
| * Get the external property file. | |||||
| * | |||||
| * @return Property file. | |||||
| */ | |||||
| public String getFile() { | |||||
| return getAttribute(FILE); | |||||
| } | |||||
| /** | |||||
| * Set the external property file. | |||||
| * | |||||
| * @param name Property file. | |||||
| */ | |||||
| public void setFile(String file) { | |||||
| String old = getFile(); | |||||
| setAttribute(FILE, file); | |||||
| firePropertyChange(FILE, old, file); | |||||
| } | |||||
| } | |||||
| @@ -1,132 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.customizer.DynamicCustomizer; | |||||
| import java.beans.*; | |||||
| /** | |||||
| * BeanInfo for the ACSPropertyElement class. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSPropertyElementBeanInfo extends BaseBeanInfo { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSPropertyElementBeanInfo() { | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public Class getType() { | |||||
| return ACSPropertyElement.class; | |||||
| } | |||||
| /** | |||||
| * Get the customizer type. | |||||
| * | |||||
| * @return Customizer type. | |||||
| */ | |||||
| public Class getCustomizerType() { | |||||
| return Customizer.class; | |||||
| } | |||||
| /** | |||||
| * Get the property descriptors. | |||||
| * | |||||
| * @return Property descriptors. | |||||
| */ | |||||
| public PropertyDescriptor[] getPropertyDescriptors() { | |||||
| PropertyDescriptor[] retval = null; | |||||
| try { | |||||
| retval = new PropertyDescriptor[] { | |||||
| new PropertyDescriptor(ACSPropertyElement.FILE, | |||||
| ACSPropertyElement.class), | |||||
| new PropertyDescriptor(ACSPropertyElement.NAME, | |||||
| ACSPropertyElement.class), | |||||
| new PropertyDescriptor(ACSPropertyElement.VALUE, | |||||
| ACSPropertyElement.class) | |||||
| }; | |||||
| retval[0].setDisplayName(getResources().getString( | |||||
| getClass(),ACSPropertyElement.FILE)); | |||||
| retval[1].setDisplayName(getResources().getString( | |||||
| getClass(),ACSPropertyElement.NAME)); | |||||
| retval[2].setDisplayName(getResources().getString( | |||||
| getClass(),ACSPropertyElement.VALUE)); | |||||
| setSortingOrder(retval); | |||||
| } | |||||
| catch(IntrospectionException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new Error(ex.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** Customizer for this bean info. */ | |||||
| public static class Customizer extends DynamicCustomizer { | |||||
| public Customizer() { | |||||
| super(ACSPropertyElement.class); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,182 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| import java.util.StringTokenizer; | |||||
| /** | |||||
| * Class representing a build target. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSTargetElement extends ACSNamedElement implements Cloneable{ | |||||
| /** Dependency property name. */ | |||||
| public static final String DEPENDS = "depends"; | |||||
| /** 'if' clause property name. */ | |||||
| public static final String IF = "if"; | |||||
| /** 'unless' clause property name. */ | |||||
| public static final String UNLESS = "unless"; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSTargetElement() { | |||||
| } | |||||
| /** | |||||
| * Get the set of dependency names. | |||||
| * | |||||
| * @return Dependency names. | |||||
| */ | |||||
| public String[] getDepends() { | |||||
| String depends = getAttribute(DEPENDS); | |||||
| StringTokenizer tok = new StringTokenizer(depends,","); | |||||
| String[] retval = new String[tok.countTokens()]; | |||||
| for(int i = 0; i < retval.length; i++) { | |||||
| retval[i] = tok.nextToken().trim(); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the list of dependency names. | |||||
| * | |||||
| * @param depends Dependency names. | |||||
| */ | |||||
| public void setDepends(String[] depends) { | |||||
| String old = getAttribute(DEPENDS); | |||||
| StringBuffer buf = new StringBuffer(); | |||||
| for(int i = 0; depends != null && i < depends.length; i++) { | |||||
| buf.append(depends[i]); | |||||
| if(i < depends.length - 1) { | |||||
| buf.append(", "); | |||||
| } | |||||
| } | |||||
| setAttribute(DEPENDS, buf.toString()); | |||||
| firePropertyChange(DEPENDS, old, buf.toString()); | |||||
| } | |||||
| /** | |||||
| * Get the 'if' clause. | |||||
| * | |||||
| * @return 'if' clause. | |||||
| */ | |||||
| public String getIf() { | |||||
| return getAttribute(IF); | |||||
| } | |||||
| /** | |||||
| * Set the 'if' clause. | |||||
| * | |||||
| * @param val 'if' clause value. | |||||
| */ | |||||
| public void setIf(String val) { | |||||
| String old = getIf(); | |||||
| setAttribute(IF, val); | |||||
| firePropertyChange(IF, old, val); | |||||
| } | |||||
| /** | |||||
| * Get the 'unless' clause. | |||||
| * | |||||
| * @return 'unless' clause. | |||||
| */ | |||||
| public String getUnless() { | |||||
| return getAttribute(UNLESS); | |||||
| } | |||||
| /** | |||||
| * Set the 'unless' clause. | |||||
| * | |||||
| * @param val 'unless' clase value. | |||||
| */ | |||||
| public void setUnless(String val) { | |||||
| String old = getUnless(); | |||||
| setAttribute(UNLESS, val); | |||||
| firePropertyChange(UNLESS, old, val); | |||||
| } | |||||
| /** | |||||
| * Copys the depends of a given target to the current. | |||||
| * | |||||
| * @param Source target for the copy operation. | |||||
| */ | |||||
| public void copyDependsFromTarget(ACSTargetElement newTarget) { | |||||
| setDepends(newTarget.getDepends()); | |||||
| } | |||||
| /** | |||||
| * Copys the depends of a given target to the current. | |||||
| * I can't override clone, because I need an ACSTargetElement | |||||
| * to be returned! | |||||
| * | |||||
| * @return A clones target element | |||||
| */ | |||||
| public ACSTargetElement getClone() { | |||||
| ACSTargetElement retVal = null; | |||||
| try { | |||||
| retVal = (ACSTargetElement)clone(); | |||||
| retVal.setDepends(getDepends()); | |||||
| } catch (java.lang.CloneNotSupportedException ex) { | |||||
| // Cannot occur, for ACSTarget implements Clonable! | |||||
| } | |||||
| return retVal; | |||||
| } | |||||
| } | |||||
| @@ -1,153 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.customizer.DynamicCustomizer; | |||||
| import java.beans.*; | |||||
| /** | |||||
| * BeanInfo for the ACSTargetElement class. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSTargetElementBeanInfo extends BaseBeanInfo { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSTargetElementBeanInfo() { | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public Class getType() { | |||||
| return ACSTargetElement.class; | |||||
| } | |||||
| /** | |||||
| * Get the customizer type. | |||||
| * | |||||
| * @return Customizer type. | |||||
| */ | |||||
| public Class getCustomizerType() { | |||||
| return Customizer.class; | |||||
| } | |||||
| /** | |||||
| * Get the property descriptors. | |||||
| * | |||||
| * @return Property descriptors. | |||||
| */ | |||||
| public PropertyDescriptor[] getPropertyDescriptors() { | |||||
| PropertyDescriptor[] retval = null; | |||||
| try { | |||||
| retval = new PropertyDescriptor[] { | |||||
| new PropertyDescriptor(ACSTargetElement.NAME, | |||||
| ACSTargetElement.class), | |||||
| new PropertyDescriptor(ACSTargetElement.DESCRIPTION, | |||||
| ACSTargetElement.class), | |||||
| new PropertyDescriptor(ACSTargetElement.DEPENDS, | |||||
| ACSTargetElement.class, | |||||
| "getClone", "copyDependsFromTarget"), | |||||
| new PropertyDescriptor(ACSTargetElement.IF, | |||||
| ACSTargetElement.class), | |||||
| new PropertyDescriptor(ACSTargetElement.UNLESS, | |||||
| ACSTargetElement.class), | |||||
| new PropertyDescriptor(ACSTargetElement.XML_STRING, | |||||
| ACSTargetElement.class, | |||||
| "getXMLString", null) | |||||
| }; | |||||
| // Set display names. | |||||
| retval[0].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTargetElement.NAME)); | |||||
| retval[1].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTargetElement.DESCRIPTION)); | |||||
| retval[2].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTargetElement.DEPENDS)); | |||||
| retval[3].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTargetElement.IF)); | |||||
| retval[4].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTargetElement.UNLESS)); | |||||
| retval[5].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTargetElement.XML_STRING)); | |||||
| setSortingOrder(retval); | |||||
| } | |||||
| catch(IntrospectionException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new Error(ex.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** Customizer for this bean info. */ | |||||
| public static class Customizer extends DynamicCustomizer { | |||||
| static { | |||||
| PropertyEditorManager.registerEditor( | |||||
| org.apache.tools.ant.gui.acs.ACSTargetElement.class, org.apache.tools.ant.gui.modules.edit.DependentTargetPropertyEditor.class); | |||||
| } | |||||
| public Customizer() { | |||||
| super(ACSTargetElement.class); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,153 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.w3c.dom.Node; | |||||
| import org.w3c.dom.NamedNodeMap; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Element containing a property definition. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSTaskElement extends ACSTreeNodeElement { | |||||
| /** Property name for the task type. */ | |||||
| public static final String TASK_TYPE = "taskType"; | |||||
| /** Property name for attributes. It's called "namedValues" so | |||||
| * it doesn't collide with the Node.getAttributes() method. */ | |||||
| public static final String NAMED_VALUES = "namedValues"; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSTaskElement() { | |||||
| } | |||||
| /** | |||||
| * Get the task type. | |||||
| * | |||||
| * @return Task type. | |||||
| */ | |||||
| public String getTaskType() { | |||||
| return getTagName(); | |||||
| } | |||||
| /** | |||||
| * Set the task type. | |||||
| * | |||||
| * @param type Type name. | |||||
| */ | |||||
| public void setTaskType(String type) { | |||||
| setTag(type); | |||||
| } | |||||
| /** | |||||
| * Get the attributes (named value mappings). This method is not named | |||||
| * getAttributes() because there is already a method of that name in | |||||
| * the Node interface. | |||||
| * | |||||
| * @return Name-value mappings. | |||||
| */ | |||||
| public Properties getNamedValues() { | |||||
| Properties retval = new Properties(); | |||||
| NamedNodeMap attribs = getAttributes(); | |||||
| for(int i = 0, len = attribs.getLength(); i < len; i++) { | |||||
| Node n = attribs.item(i); | |||||
| retval.setProperty(n.getNodeName(), n.getNodeValue()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the attributes. This method sets the Node attirbutes using | |||||
| * the given Map containing name-value pairs. | |||||
| * | |||||
| * @param attributes New attribute set. | |||||
| */ | |||||
| public void setNamedValues(Properties props) { | |||||
| // XXX this code really sucks. It is really annoying that the | |||||
| // DOM interfaces don't have a general "setAttributes()" or | |||||
| // "removeAllAttributes()" method, but instead make you | |||||
| // remove each attribute individually, or require you to figure | |||||
| // out what the differences are between the two. | |||||
| // Although this is very inefficient, I'm taking the conceptually | |||||
| // simplistic approach to this and brute force removing the existing | |||||
| // set and replacing it with a brand new set. If this becomes a | |||||
| // performance concern (which I doubt it will) it can be optimized | |||||
| // later. | |||||
| Properties old = getNamedValues(); | |||||
| Enumeration enum = old.propertyNames(); | |||||
| while(enum.hasMoreElements()) { | |||||
| String name = (String) enum.nextElement(); | |||||
| removeAttribute(name); | |||||
| } | |||||
| enum = props.propertyNames(); | |||||
| while(enum.hasMoreElements()) { | |||||
| String key = (String) enum.nextElement(); | |||||
| setAttribute(key, props.getProperty(key)); | |||||
| } | |||||
| firePropertyChange(NAMED_VALUES, old, props); | |||||
| } | |||||
| } | |||||
| @@ -1,134 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.customizer.DynamicCustomizer; | |||||
| import java.beans.*; | |||||
| /** | |||||
| * BeanInfo for the ACSTaskElement class. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ACSTaskElementBeanInfo extends BaseBeanInfo { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ACSTaskElementBeanInfo() { | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public Class getType() { | |||||
| return ACSTaskElement.class; | |||||
| } | |||||
| /** | |||||
| * Get the customizer type. | |||||
| * | |||||
| * @return Customizer type. | |||||
| */ | |||||
| public Class getCustomizerType() { | |||||
| return Customizer.class; | |||||
| } | |||||
| /** | |||||
| * Get the property descriptors. | |||||
| * | |||||
| * @return Property descriptors. | |||||
| */ | |||||
| public PropertyDescriptor[] getPropertyDescriptors() { | |||||
| PropertyDescriptor[] retval = null; | |||||
| try { | |||||
| retval = new PropertyDescriptor[] { | |||||
| new PropertyDescriptor(ACSTaskElement.TASK_TYPE, | |||||
| ACSTaskElement.class, | |||||
| "getTaskType", null), | |||||
| new PropertyDescriptor(ACSTaskElement.NAMED_VALUES, | |||||
| ACSTaskElement.class), | |||||
| new PropertyDescriptor(ACSTaskElement.XML_STRING, | |||||
| ACSTaskElement.class, | |||||
| "getXMLString", null) | |||||
| }; | |||||
| retval[0].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTaskElement.TASK_TYPE)); | |||||
| retval[1].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTaskElement.NAMED_VALUES)); | |||||
| retval[2].setDisplayName(getResources().getString( | |||||
| getClass(),ACSTaskElement.XML_STRING)); | |||||
| setSortingOrder(retval); | |||||
| } | |||||
| catch(IntrospectionException ex) { | |||||
| ex.printStackTrace(); | |||||
| throw new Error(ex.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** Customizer for this bean info. */ | |||||
| public static class Customizer extends DynamicCustomizer { | |||||
| public Customizer() { | |||||
| super(ACSTaskElement.class); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,71 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.w3c.dom.Node; | |||||
| import org.w3c.dom.NodeList; | |||||
| import com.sun.xml.tree.ElementNode; | |||||
| import javax.swing.tree.TreeNode; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Abstract base class for all ACSElement classes that are also tree node. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public abstract class ACSTreeNodeElement extends ACSElement { | |||||
| } | |||||
| @@ -1,159 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.core.ResourceManager; | |||||
| import org.apache.tools.ant.gui.customizer.DynamicCustomizer; | |||||
| import java.beans.*; | |||||
| import javax.swing.ImageIcon; | |||||
| import java.awt.Image; | |||||
| /** | |||||
| * Abstract base class for ACS BeanInfo classes. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| abstract class BaseBeanInfo extends SimpleBeanInfo { | |||||
| /** Property name for specifiying a sorting order. */ | |||||
| public static final String SORT_ORDER = DynamicCustomizer.SORT_ORDER; | |||||
| /** Resource provider for bean info. */ | |||||
| private static ResourceManager _resources = new ResourceManager(); | |||||
| /** Icon for this. */ | |||||
| private Image _icon = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| protected BaseBeanInfo() { | |||||
| // Load the icon. | |||||
| ImageIcon img = _resources.getImageIcon(getClass(), "icon"); | |||||
| if(img != null) { | |||||
| _icon = img.getImage(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the local resources. | |||||
| * | |||||
| * @return Resources. | |||||
| */ | |||||
| ResourceManager getResources() { | |||||
| return _resources; | |||||
| } | |||||
| /** | |||||
| * Get the bean descriptor. | |||||
| * | |||||
| * @return Bean descriptor. | |||||
| */ | |||||
| public BeanDescriptor getBeanDescriptor() { | |||||
| return new ACSBeanDescriptor(this); | |||||
| } | |||||
| /** | |||||
| * Get the icon for displaying this bean. | |||||
| * | |||||
| * @param kind Kind of icon. XXX currently ignored | |||||
| * @return Image for bean, or null if none. | |||||
| */ | |||||
| public Image getIcon(int kind) { | |||||
| // XXX kind is currently ignored. | |||||
| return _icon; | |||||
| } | |||||
| /** | |||||
| * Set the sorting order property of the given objects based | |||||
| * on the order that they appear in the array. | |||||
| * | |||||
| * @param vals FeatureDescriptors to set sorting order property for. | |||||
| */ | |||||
| protected void setSortingOrder(FeatureDescriptor[] vals) { | |||||
| for(int i = 0; i < vals.length; i++) { | |||||
| vals[i].setValue(SORT_ORDER, new Integer(i)); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the type that this BeanInfo represents. | |||||
| * | |||||
| * @return Type. | |||||
| */ | |||||
| public abstract Class getType(); | |||||
| /** | |||||
| * Get the type of the customizer to use. | |||||
| * | |||||
| * @return Customizer to use. | |||||
| */ | |||||
| public abstract Class getCustomizerType(); | |||||
| /** | |||||
| * Gets the beans <code>PropertyDescriptor</code>s. | |||||
| * | |||||
| * @return An array of PropertyDescriptors describing the editable | |||||
| * properties supported by this bean. May return null if the | |||||
| * information should be obtained by automatic analysis. | |||||
| * <p> | |||||
| * If a property is indexed, then its entry in the result array will | |||||
| * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor. | |||||
| * A client of getPropertyDescriptors can use "instanceof" to check | |||||
| * if a given PropertyDescriptor is an IndexedPropertyDescriptor. | |||||
| */ | |||||
| public abstract PropertyDescriptor[] getPropertyDescriptors(); | |||||
| } | |||||
| @@ -1,312 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import javax.swing.tree.*; | |||||
| import javax.swing.event.TreeModelListener; | |||||
| import javax.swing.event.TreeModelEvent; | |||||
| import org.w3c.dom.Node; | |||||
| import org.w3c.dom.NodeList; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Provides a tree model view of the Project class. XXX This | |||||
| * is a major hack right now that needs to be cleaned up. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon H.K. Fitch */ | |||||
| public class ElementTreeModel implements TreeModel { | |||||
| /** Root of the tree. */ | |||||
| private ACSProjectElement _root = null; | |||||
| /** List of listeners. */ | |||||
| private List _listeners = new ArrayList(); | |||||
| public ElementTreeModel(ACSProjectElement root) { | |||||
| _root = root; | |||||
| } | |||||
| /** | |||||
| * Returns the root of the tree. Returns null only if the tree has | |||||
| * no nodes. | |||||
| * | |||||
| * @return the root of the tree | |||||
| */ | |||||
| public Object getRoot() { | |||||
| return _root; | |||||
| } | |||||
| /** | |||||
| * Gets the set of children that this tree model is interested in. | |||||
| * NB: This is <b>really</b> inefficient, but may not be an issue given | |||||
| * the number of times it is ultimately called. A profiler definately needs | |||||
| * to be applied here. | |||||
| * | |||||
| * @param parent Parent to extract children from. | |||||
| */ | |||||
| private List getChildren(Node parent) { | |||||
| NodeList children = parent.getChildNodes(); | |||||
| int length = children.getLength(); | |||||
| List retval = new ArrayList(length); | |||||
| for(int i = 0; i < length; i++) { | |||||
| // XXX This is where we will eventually add dynamic filtering | |||||
| // capabilities. | |||||
| Node n = children.item(i); | |||||
| if(n instanceof ACSTreeNodeElement) { | |||||
| retval.add(n); | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Returns the child of <I>parent</I> at index <I>index</I> in the parent's | |||||
| * child array. <I>parent</I> must be a node previously obtained from | |||||
| * this data source. This should not return null if <i>index</i> | |||||
| * is a valid index for <i>parent</i> (that is <i>index</i> >= 0 && | |||||
| * <i>index</i> < getChildCount(<i>parent</i>)). | |||||
| * | |||||
| * @param parent a node in the tree, obtained from this data source | |||||
| * @return the child of <I>parent</I> at index <I>index</I> | |||||
| */ | |||||
| public Object getChild(Object parent, int index) { | |||||
| if(parent instanceof Node) { | |||||
| Node n = (Node) parent; | |||||
| List children = getChildren(n); | |||||
| return children.get(index); | |||||
| } | |||||
| else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns the number of children of <I>parent</I>. Returns 0 if the node | |||||
| * is a leaf or if it has no children. <I>parent</I> must be a node | |||||
| * previously obtained from this data source. | |||||
| * | |||||
| * @param parent a node in the tree, obtained from this data source | |||||
| * @return the number of children of the node <I>parent</I> | |||||
| */ | |||||
| public int getChildCount(Object parent) { | |||||
| if(parent instanceof Node) { | |||||
| Node n = (Node) parent; | |||||
| return getChildren(n).size(); | |||||
| } | |||||
| else { | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns true if <I>node</I> is a leaf. It is possible for this method | |||||
| * to return false even if <I>node</I> has no children. A directory in a | |||||
| * filesystem, for example, may contain no files; the node representing | |||||
| * the directory is not a leaf, but it also has no children. | |||||
| * | |||||
| * @param node a node in the tree, obtained from this data source | |||||
| * @return true if <I>node</I> is a leaf | |||||
| */ | |||||
| public boolean isLeaf(Object node) { | |||||
| if(node instanceof Node) { | |||||
| Node n = (Node) node; | |||||
| return getChildren(n).size() == 0; | |||||
| } | |||||
| else { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns the index of child in parent. | |||||
| */ | |||||
| public int getIndexOfChild(Object parent, Object child) { | |||||
| if(parent instanceof Node && child instanceof Node) { | |||||
| Node n = (Node) parent; | |||||
| List children = getChildren(n); | |||||
| int count = children.size(); | |||||
| for(int i = 0; i < count; i++) { | |||||
| if(children.get(i) == child) return i; | |||||
| } | |||||
| } | |||||
| return -1; | |||||
| } | |||||
| /** | |||||
| * Messaged when the user has altered the value for the item identified | |||||
| * by <I>path</I> to <I>newValue</I>. If <I>newValue</I> signifies | |||||
| * a truly new value the model should post a treeNodesChanged | |||||
| * event. | |||||
| * | |||||
| * @param path path to the node that the user has altered. | |||||
| * @param newValue the new value from the TreeCellEditor. | |||||
| */ | |||||
| public void valueForPathChanged(TreePath path, Object newValue) { | |||||
| // XXX What should the implementation be here? | |||||
| fireNodeChanged((Node) path.getLastPathComponent()); | |||||
| } | |||||
| /** | |||||
| * Adds a listener for the TreeModelEvent posted after the tree changes. | |||||
| * | |||||
| * @see #removeTreeModelListener | |||||
| * @param l the listener to add | |||||
| */ | |||||
| public void addTreeModelListener(TreeModelListener l) { | |||||
| _listeners.add(l); | |||||
| } | |||||
| /** | |||||
| * Removes a listener previously added with <B>addTreeModelListener()</B>. | |||||
| * | |||||
| * @see #addTreeModelListener | |||||
| * @param l the listener to remove | |||||
| */ | |||||
| public void removeTreeModelListener(TreeModelListener l) { | |||||
| _listeners.remove(l); | |||||
| } | |||||
| /** | |||||
| * Get the list of nodes from the root to the | |||||
| * given node. | |||||
| * | |||||
| * @param startNode Node to get path for. | |||||
| */ | |||||
| public Node[] getPathToRoot(Node startNode) { | |||||
| return getPathToRoot(startNode, 0); | |||||
| } | |||||
| /** | |||||
| * A recursive method for generating a list of nodes defining | |||||
| * the path from the given node to the root. | |||||
| * | |||||
| * @param node Node to get path for. | |||||
| * @param depth The number of calls taken towards the root. | |||||
| */ | |||||
| private Node[] getPathToRoot(Node node, int depth) { | |||||
| Node[] retval = null; | |||||
| depth++; | |||||
| if(node == _root || node.getParentNode() == null) { | |||||
| retval = new Node[depth]; | |||||
| } | |||||
| else { | |||||
| retval = getPathToRoot(node.getParentNode(), depth); | |||||
| } | |||||
| retval[retval.length - depth] = node; | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Fire a node change event. | |||||
| * | |||||
| * @param node Node that changed. | |||||
| */ | |||||
| public void fireNodeChanged(Node node) { | |||||
| TreeModelEvent event = new TreeModelEvent(this, getPathToRoot(node)); | |||||
| // XXX This doen't support modifying the list during dispatch... | |||||
| Iterator it = _listeners.iterator(); | |||||
| while(it.hasNext()) { | |||||
| TreeModelListener l = (TreeModelListener) it.next(); | |||||
| l.treeNodesChanged(event); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Fire a node change event. | |||||
| * | |||||
| * @param node Node that changed. | |||||
| */ | |||||
| public void fireNodeAdded(Node node) { | |||||
| Node parent = node.getParentNode(); | |||||
| TreeModelEvent event = null; | |||||
| if(parent == null) { | |||||
| event = new TreeModelEvent(this, getPathToRoot(node)); | |||||
| } | |||||
| else { | |||||
| Node[] path = getPathToRoot(parent); | |||||
| int[] indicies = null; | |||||
| Node[] children = new Node[] { node }; | |||||
| // XXX Right now we assume that the node was added at the end. | |||||
| // This may not be the case in the future. | |||||
| if(parent.getLastChild() == node) { | |||||
| List filteredChildren = getChildren(parent); | |||||
| indicies = new int[] { filteredChildren.indexOf(node) }; | |||||
| } | |||||
| else { | |||||
| throw new UnsupportedOperationException( | |||||
| "Haven't implemented non-append notification yet."); | |||||
| } | |||||
| event = new TreeModelEvent(this, path, indicies, children); | |||||
| } | |||||
| // XXX This doen't support modifying the list during dispatch... | |||||
| Iterator it = _listeners.iterator(); | |||||
| while(it.hasNext()) { | |||||
| TreeModelListener l = (TreeModelListener) it.next(); | |||||
| l.treeNodesInserted(event); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,103 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.acs; | |||||
| import org.apache.tools.ant.gui.acs.ACSElement; | |||||
| import org.apache.tools.ant.gui.acs.ACSTargetElement; | |||||
| import javax.swing.tree.DefaultTreeSelectionModel; | |||||
| import javax.swing.tree.TreePath; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Selection model for the currently selected targets. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ElementTreeSelectionModel extends DefaultTreeSelectionModel { | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ElementTreeSelectionModel() { | |||||
| setSelectionMode(DISCONTIGUOUS_TREE_SELECTION); | |||||
| } | |||||
| /** | |||||
| * Convenience method for providing the set of currently selected | |||||
| * elements. NB: It returns all of the nodes in the selection path, | |||||
| * so the root node will be a selected element whenever a child is | |||||
| * selected. | |||||
| * | |||||
| * @return the currently selected elements. | |||||
| */ | |||||
| public ACSElement[] getSelectedElements() { | |||||
| TreePath[] path = getSelectionPaths(); | |||||
| List values = new LinkedList(); | |||||
| for(int i = 0; path != null && i < path.length; i++) { | |||||
| TreePath curr = path[i]; | |||||
| for(int j = 0; j < curr.getPathCount(); j++) { | |||||
| Object item = curr.getPathComponent(j); | |||||
| if(item instanceof ACSElement) { | |||||
| values.add(item); | |||||
| } | |||||
| } | |||||
| } | |||||
| ACSElement[] retval = new ACSElement[values.size()]; | |||||
| values.toArray(retval); | |||||
| return retval; | |||||
| } | |||||
| } | |||||
| @@ -1,14 +0,0 @@ | |||||
| # | |||||
| # Property file mapping DOM nodes to Java class names. | |||||
| # | |||||
| # The default element | |||||
| *Element=org.apache.tools.ant.gui.acs.ACSDtdDefinedElement | |||||
| # Specific elements. | |||||
| project=org.apache.tools.ant.gui.acs.ACSProjectElement | |||||
| property=org.apache.tools.ant.gui.acs.ACSPropertyElement | |||||
| target=org.apache.tools.ant.gui.acs.ACSTargetElement | |||||
| task=org.apache.tools.ant.gui.acs.ACSTaskElement | |||||
| @@ -1,9 +0,0 @@ | |||||
| <HTML><BODY> <H1>Ant Construction Set</H1> | |||||
| <P>This package contains the tools for constructing and manipulating an Ant | |||||
| build file</P> | |||||
| <P><B>NB</B>: Requires the <A HREF="http://java.sun.com/xml">Java API for XML | |||||
| Parsing</A> from Sun.</P> | |||||
| </BODY> | |||||
| </HTML> | |||||
| @@ -1,255 +0,0 @@ | |||||
| <?xml version="1.0" encoding="iso-8859-1"?> | |||||
| <!-- | |||||
| The Apache Software License, Version 1.1 | |||||
| Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| reserved. | |||||
| Redistribution and use in source and binary forms, with or without | |||||
| modification, are permitted provided that the following conditions | |||||
| are met: | |||||
| 1. Redistributions of source code must retain the above copyright | |||||
| notice, this list of conditions and the following disclaimer. | |||||
| 2. Redistributions in binary form must reproduce the above copyright | |||||
| notice, this list of conditions and the following disclaimer in | |||||
| the documentation and/or other materials provided with the | |||||
| distribution. | |||||
| 3. The end-user documentation included with the redistribution, if | |||||
| any, must include the following acknowlegement: | |||||
| "This product includes software developed by the | |||||
| Apache Software Foundation (http://www.apache.org/)." | |||||
| Alternately, this acknowlegement may appear in the software itself, | |||||
| if and wherever such third-party acknowlegements normally appear. | |||||
| 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| Foundation" must not be used to endorse or promote products derived | |||||
| from this software without prior written permission. For written | |||||
| permission, please contact apache@apache.org. | |||||
| 5. Products derived from this software may not be called "Apache" | |||||
| nor may "Apache" appear in their names without prior written | |||||
| permission of the Apache Group. | |||||
| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| SUCH DAMAGE. | |||||
| ==================================================================== | |||||
| This software consists of voluntary contributions made by many | |||||
| individuals on behalf of the Apache Software Foundation. For more | |||||
| information on the Apache Software Foundation, please see | |||||
| <http://www.apache.org/>. | |||||
| --> | |||||
| <!-- @author Michel CASABIANCA --> | |||||
| <!-- @version $Revision$ --> | |||||
| <!ENTITY % share-file SYSTEM "file:/share.dtd"> | |||||
| %share-file; | |||||
| <!ELEMENT target (p4sync | p4label | p4have | p4submit | p4edit | p4change | junit | ddcreator | ejbc | wlrun | wlstop | ejbjar | weblogic | TOPLink | PropertyFile)*> | |||||
| <!-- *********** PERFORCE ************** --> | |||||
| <!ELEMENT p4sync EMPTY> | |||||
| <!ATTLIST p4sync | |||||
| view CDATA #IMPLIED | |||||
| label CDATA #IMPLIED | |||||
| force CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT p4change EMPTY> | |||||
| <!ELEMENT p4edit EMPTY> | |||||
| <!ATTLIST p4edit | |||||
| view CDATA #REQUIRED | |||||
| change CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT p4submit EMPTY> | |||||
| <!ATTLIST p4submit | |||||
| change CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT p4have EMPTY> | |||||
| <!ELEMENT p4label EMPTY> | |||||
| <!ATTLIST p4label | |||||
| name CDATA #REQUIRED | |||||
| view CDATA #IMPLIED | |||||
| desc CDATA #IMPLIED | |||||
| > | |||||
| <!-- *********** JUNIT ************** --> | |||||
| <!ELEMENT junit (jvmarg | batchtest | test | formatter | sysproperty)*> | |||||
| <!ATTLIST junit | |||||
| printsummary CDATA #IMPLIED | |||||
| fork CDATA #IMPLIED | |||||
| haltonerror CDATA #IMPLIED | |||||
| haltonfailure CDATA #IMPLIED | |||||
| timeout CDATA #IMPLIED | |||||
| maxmemory CDATA #IMPLIED | |||||
| jvm CDATA #IMPLIED | |||||
| dir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT jvmarg EMPTY> | |||||
| <!ATTLIST jvmarg | |||||
| value CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT sysproperty EMPTY> | |||||
| <!ATTLIST sysproperty | |||||
| key CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT formatter EMPTY> | |||||
| <!ATTLIST formatter | |||||
| type CDATA #IMPLIED | |||||
| classname CDATA #IMPLIED | |||||
| extension CDATA #REQUIRED | |||||
| usefile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT test EMPTY> | |||||
| <!ATTLIST test | |||||
| name CDATA #REQUIRED | |||||
| fork CDATA #IMPLIED | |||||
| haltonerror CDATA #IMPLIED | |||||
| haltonfailure CDATA #IMPLIED | |||||
| todir CDATA #IMPLIED | |||||
| outfile CDATA #IMPLIED | |||||
| if CDATA #IMPLIED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT batchtest EMPTY> | |||||
| <!ATTLIST batchtest | |||||
| fork CDATA #IMPLIED | |||||
| haltonerror CDATA #IMPLIED | |||||
| haltonfailure CDATA #IMPLIED | |||||
| todir CDATA #IMPLIED | |||||
| if CDATA #IMPLIED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!-- *********** EJB ************** --> | |||||
| <!ELEMENT ddcreator (include | exclude)*> | |||||
| <!ATTLIST ddcreator | |||||
| descriptors CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| classpath CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT ejbc (include | exclude)*> | |||||
| <!ATTLIST ejbc | |||||
| descriptors CDATA #REQUIRED | |||||
| manifest CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| src CDATA #REQUIRED | |||||
| classpath CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT wlrun (classpath | wlclasspath)*> | |||||
| <!ATTLIST wlrun | |||||
| beahome CDATA #REQUIRED | |||||
| home CDATA #REQUIRED | |||||
| Domain CDATA #REQUIRED | |||||
| classpath CDATA #IMPLIED | |||||
| wlclasspath CDATA #IMPLIED | |||||
| properties CDATA #IMPLIED | |||||
| name CDATA #IMPLIED | |||||
| policy CDATA #IMPLIED | |||||
| username CDATA #IMPLIED | |||||
| password CDATA #IMPLIED | |||||
| pkPassword CDATA #IMPLIED | |||||
| jvmargs CDATA #IMPLIED | |||||
| args CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT wlstop (classpath)*> | |||||
| <!ATTLIST wlstop | |||||
| beahome CDATA #REQUIRED | |||||
| classpath CDATA #REQUIRED | |||||
| user CDATA #REQUIRED | |||||
| password CDATA #REQUIRED | |||||
| url CDATA #IMPLIED | |||||
| delay CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT ejbjar (classpath | dtd | support)*> | |||||
| <!ATTLIST ejbjar | |||||
| descriptordir CDATA #IMPLIED | |||||
| srcdir CDATA #REQUIRED | |||||
| destdir CDATA #REQUIRED | |||||
| basejarname CDATA #IMPLIED | |||||
| basenameterminator CDATA #IMPLIED | |||||
| genericjarsuffix CDATA #IMPLIED | |||||
| classpath CDATA #IMPLIED | |||||
| latdestdir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT dtd EMPTY> | |||||
| <!ATTLIST dtd | |||||
| publicId CDATA #REQUIRED | |||||
| location CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT support (include | exclude)*> | |||||
| <!ATTLIST support | |||||
| dir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT weblogic (classpath | dtd | support)*> | |||||
| <!ATTLIST weblogic | |||||
| destdir CDATA #IMPLIED | |||||
| genericjarsuffix CDATA #IMPLIED | |||||
| suffix CDATA #IMPLIED | |||||
| wlclasspath CDATA #IMPLIED | |||||
| keepgeneric CDATA #IMPLIED | |||||
| compiler CDATA #IMPLIED | |||||
| rebuild CDATA #IMPLIED | |||||
| keepgenerated CDATA #IMPLIED | |||||
| args CDATA #IMPLIED | |||||
| weblogicdtd CDATA #IMPLIED | |||||
| wldtd CDATA #IMPLIED | |||||
| ejbdtd CDATA #IMPLIED | |||||
| newCMP CDATA #IMPLIED | |||||
| oldCMP CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT TOPLink (classpath | dtd | support)*> | |||||
| <!ATTLIST TOPLink | |||||
| destdir CDATA #IMPLIED | |||||
| genericjarsuffix CDATA #IMPLIED | |||||
| suffix CDATA #IMPLIED | |||||
| wlclasspath CDATA #IMPLIED | |||||
| keepgeneric CDATA #IMPLIED | |||||
| compiler CDATA #IMPLIED | |||||
| rebuild CDATA #IMPLIED | |||||
| keepgenerated CDATA #IMPLIED | |||||
| args CDATA #IMPLIED | |||||
| weblogicdtd CDATA #IMPLIED | |||||
| wldtd CDATA #IMPLIED | |||||
| ejbdtd CDATA #IMPLIED | |||||
| newCMP CDATA #IMPLIED | |||||
| oldCMP CDATA #IMPLIED | |||||
| toplinkdescriptor CDATA #IMPLIED | |||||
| toplinkdtd CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT wlclasspath (pathelement | path | fileset)*> | |||||
| <!ATTLIST wlclasspath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!-- *********** PERFORCE ************** --> | |||||
| <!ELEMENT PropertyFile (entry)*> | |||||
| <!ATTLIST PropertyFile | |||||
| file CDATA #REQUIRED | |||||
| comment CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT entry EMPTY> | |||||
| <!ATTLIST entry | |||||
| key CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| type CDATA #IMPLIED | |||||
| operation CDATA #IMPLIED | |||||
| default CDATA #IMPLIED | |||||
| pattern CDATA #IMPLIED | |||||
| > | |||||
| @@ -1,424 +0,0 @@ | |||||
| <?xml version="1.0" encoding="iso-8859-1"?> | |||||
| <!-- | |||||
| The Apache Software License, Version 1.1 | |||||
| Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| reserved. | |||||
| Redistribution and use in source and binary forms, with or without | |||||
| modification, are permitted provided that the following conditions | |||||
| are met: | |||||
| 1. Redistributions of source code must retain the above copyright | |||||
| notice, this list of conditions and the following disclaimer. | |||||
| 2. Redistributions in binary form must reproduce the above copyright | |||||
| notice, this list of conditions and the following disclaimer in | |||||
| the documentation and/or other materials provided with the | |||||
| distribution. | |||||
| 3. The end-user documentation included with the redistribution, if | |||||
| any, must include the following acknowlegement: | |||||
| "This product includes software developed by the | |||||
| Apache Software Foundation (http://www.apache.org/)." | |||||
| Alternately, this acknowlegement may appear in the software itself, | |||||
| if and wherever such third-party acknowlegements normally appear. | |||||
| 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| Foundation" must not be used to endorse or promote products derived | |||||
| from this software without prior written permission. For written | |||||
| permission, please contact apache@apache.org. | |||||
| 5. Products derived from this software may not be called "Apache" | |||||
| nor may "Apache" appear in their names without prior written | |||||
| permission of the Apache Group. | |||||
| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| SUCH DAMAGE. | |||||
| ==================================================================== | |||||
| This software consists of voluntary contributions made by many | |||||
| individuals on behalf of the Apache Software Foundation. For more | |||||
| information on the Apache Software Foundation, please see | |||||
| <http://www.apache.org/>. | |||||
| --> | |||||
| <!-- @author Michel CASABIANCA --> | |||||
| <!-- @version $Revision$ --> | |||||
| <!ENTITY % share-file SYSTEM "file:/share.dtd"> | |||||
| %share-file; | |||||
| <!ELEMENT target (ant | antcall | available | chmod | copy | cvs | delete | deltree | echo | exec | expand | fail | filter | get | gzip | fixcrlf | jar | java | javac | javadoc | keysubst | mail | mkdir | property | recorder | rename | replace | rmic | tar | taskdef | tstamp | uptodate | zip | path | classpath)*> | |||||
| <!ATTLIST target | |||||
| name CDATA #REQUIRED | |||||
| depends CDATA #IMPLIED | |||||
| if CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT ant (property)*> | |||||
| <!ATTLIST ant | |||||
| antfile CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| target CDATA #IMPLIED | |||||
| output CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT antcall (param)*> | |||||
| <!ATTLIST antcall | |||||
| target CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT param EMPTY> | |||||
| <!ATTLIST param | |||||
| name CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT available EMPTY> | |||||
| <!ATTLIST available | |||||
| property CDATA #REQUIRED | |||||
| classname CDATA #REQUIRED | |||||
| resource CDATA #REQUIRED | |||||
| file CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT chmod (includes | excludes | patternset | fileset)*> | |||||
| <!ATTLIST chmod | |||||
| file CDATA #IMPLIED | |||||
| dir CDATA #IMPLIED | |||||
| perm CDATA #REQUIRED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| parallel CDATA #IMPLIED | |||||
| type CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT copy (fileset | mapper)*> | |||||
| <!ATTLIST copy | |||||
| file CDATA #IMPLIED | |||||
| todir CDATA #IMPLIED | |||||
| todir CDATA #IMPLIED | |||||
| preservelastmodified CDATA #IMPLIED | |||||
| overwrite CDATA #IMPLIED | |||||
| filtering CDATA #IMPLIED | |||||
| flatten CDATA #IMPLIED | |||||
| includeEmptyDirs CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT cvs EMPTY> | |||||
| <!ATTLIST cvs | |||||
| cvsRoot CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| package CDATA #REQUIRED | |||||
| tag CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT delete (fileset)*> | |||||
| <!ATTLIST delete | |||||
| file CDATA #IMPLIED | |||||
| dir CDATA #IMPLIED | |||||
| verbose CDATA #IMPLIED | |||||
| quiet CDATA #IMPLIED | |||||
| includeEmptyDirs CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT deltree EMPTY> | |||||
| <!ATTLIST deltree | |||||
| dir CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT echo EMPTY> | |||||
| <!ATTLIST echo | |||||
| message CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT exec EMPTY> | |||||
| <!ATTLIST exec | |||||
| command CDATA #REQUIRED | |||||
| dir CDATA #REQUIRED | |||||
| os CDATA #IMPLIED | |||||
| output CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT expand EMPTY> | |||||
| <!ATTLIST expand | |||||
| src CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT filter EMPTY> | |||||
| <!ATTLIST filter | |||||
| token CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT get EMPTY> | |||||
| <!ATTLIST get | |||||
| src CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| verbose CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT gzip EMPTY> | |||||
| <!ATTLIST gzip | |||||
| src CDATA #REQUIRED | |||||
| zipfile CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT fail EMPTY> | |||||
| <!ELEMENT fixcrlf (includes | excludes | patternset)*> | |||||
| <!ATTLIST fixcrlf | |||||
| srcdir CDATA #REQUIRED | |||||
| destDir CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| cr CDATA #IMPLIED | |||||
| tab CDATA #IMPLIED | |||||
| eof CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| tablength CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT jar (metainf | include | exclude | patternset | fileset)*> | |||||
| <!ATTLIST jar | |||||
| jarfile CDATA #REQUIRED | |||||
| basedir CDATA #REQUIRED | |||||
| compress CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| manifest CDATA #IMPLIED | |||||
| whenempty CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT metainf (include | exclude | patternset)*> | |||||
| <!ATTLIST metainf | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT java EMPTY> | |||||
| <!ATTLIST java | |||||
| classname CDATA #REQUIRED | |||||
| args CDATA #IMPLIED | |||||
| fork CDATA #IMPLIED | |||||
| jvmargs CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT javac (classpath | exclude | property)*> | |||||
| <!ATTLIST javac | |||||
| srcdir CDATA #REQUIRED | |||||
| destdir CDATA #REQUIRED | |||||
| includes CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| classpath CDATA #IMPLIED | |||||
| bootclasspath CDATA #IMPLIED | |||||
| extdirs CDATA #IMPLIED | |||||
| debug CDATA #IMPLIED | |||||
| optimize CDATA #IMPLIED | |||||
| deprecation CDATA #IMPLIED | |||||
| filtering CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT javadoc (link | group | doclet | sourcepath | classpath | bootclasspath)> | |||||
| <!ATTLIST javadoc | |||||
| sourcepath CDATA #REQUIRED | |||||
| destdir CDATA #REQUIRED | |||||
| sourcefiles CDATA #IMPLIED | |||||
| packagenames CDATA #IMPLIED | |||||
| classpath CDATA #IMPLIED | |||||
| bootclasspath CDATA #IMPLIED | |||||
| extdirs CDATA #IMPLIED | |||||
| overview CDATA #IMPLIED | |||||
| public CDATA #IMPLIED | |||||
| protected CDATA #IMPLIED | |||||
| package CDATA #IMPLIED | |||||
| private CDATA #IMPLIED | |||||
| old CDATA #IMPLIED | |||||
| verbose CDATA #IMPLIED | |||||
| locale CDATA #IMPLIED | |||||
| encoding CDATA #IMPLIED | |||||
| version CDATA #IMPLIED | |||||
| use CDATA #IMPLIED | |||||
| author CDATA #IMPLIED | |||||
| splitindex CDATA #IMPLIED | |||||
| windowtitle CDATA #IMPLIED | |||||
| doctitle CDATA #IMPLIED | |||||
| header CDATA #IMPLIED | |||||
| footer CDATA #IMPLIED | |||||
| bottom CDATA #IMPLIED | |||||
| link CDATA #IMPLIED | |||||
| linkoffline CDATA #IMPLIED | |||||
| group CDATA #IMPLIED | |||||
| nodedeprecated CDATA #IMPLIED | |||||
| nodedeprecatedlist CDATA #IMPLIED | |||||
| notree CDATA #IMPLIED | |||||
| noindex CDATA #IMPLIED | |||||
| nohelp CDATA #IMPLIED | |||||
| nonavbar CDATA #IMPLIED | |||||
| serialwarn CDATA #IMPLIED | |||||
| helpfile CDATA #IMPLIED | |||||
| stylesheetfile CDATA #IMPLIED | |||||
| charset CDATA #IMPLIED | |||||
| docencoding CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT link EMPTY> | |||||
| <!ATTLIST link | |||||
| href CDATA #REQUIRED | |||||
| offline CDATA #IMPLIED | |||||
| packagelistLoc CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT group EMPTY> | |||||
| <!ATTLIST group | |||||
| title CDATA #REQUIRED | |||||
| packages CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT doclet (param)*> | |||||
| <!ATTLIST doclet | |||||
| name CDATA #REQUIRED | |||||
| path CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT sourcepath (pathelement | path | fileset)*> | |||||
| <!ATTLIST sourcepath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT bootclasspath (pathelement | path | fileset)*> | |||||
| <!ATTLIST bootclasspath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT keysubst EMPTY> | |||||
| <!ATTLIST keysubst | |||||
| src CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| sep CDATA #IMPLIED | |||||
| keys CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT mail EMPTY> | |||||
| <!ATTLIST mail | |||||
| from CDATA #REQUIRED | |||||
| tolist CDATA #REQUIRED | |||||
| message CDATA #REQUIRED | |||||
| files CDATA #IMPLIED | |||||
| mailhost CDATA #IMPLIED | |||||
| subject CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT mapper EMPTY> | |||||
| <!ATTLIST mapper | |||||
| type CDATA #REQUIRED | |||||
| from CDATA #REQUIRED | |||||
| to CDATA #REQUIRED | |||||
| classname CDATA #IMPLIED | |||||
| classpath CDATA #IMPLIED | |||||
| classpathref CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT mkdir EMPTY> | |||||
| <!ATTLIST mkdir | |||||
| dir CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT recorder EMPTY> | |||||
| <!ATTLIST recorder | |||||
| name CDATA #REQUIRED | |||||
| action CDATA #IMPLIED | |||||
| append CDATA #IMPLIED | |||||
| loglevel CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT rename EMPTY> | |||||
| <!ATTLIST rename | |||||
| src CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| replace CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT replace EMPTY> | |||||
| <!ATTLIST replace | |||||
| file CDATA #REQUIRED | |||||
| token CDATA #REQUIRED | |||||
| value CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT rmic EMPTY> | |||||
| <!ATTLIST rmic | |||||
| base CDATA #REQUIRED | |||||
| classname CDATA #REQUIRED | |||||
| filtering CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT tar (includes | excludes | patternset | fileset | tarfileset)*> | |||||
| <!ATTLIST tar | |||||
| tarfile CDATA #REQUIRED | |||||
| basedir CDATA #REQUIRED | |||||
| includes CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT tarfileset (include | exclude | patternset)*> | |||||
| <!ATTLIST tarfileset | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| prefix CDATA #IMPLIED | |||||
| fullpath CDATA #IMPLIED | |||||
| src CDATA #IMPLIED | |||||
| mode CDATA #IMPLIED | |||||
| username CDATA #IMPLIED | |||||
| groupname CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT tstamp (format)*> | |||||
| <!ELEMENT format EMPTY> | |||||
| <!ATTLIST format | |||||
| property CDATA #REQUIRED | |||||
| pattern CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT uptodate (srcfiles | mapper)*> | |||||
| <!ATTLIST uptodate | |||||
| property CDATA #REQUIRED | |||||
| value CDATA #IMPLIED | |||||
| targetfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT srcfiles (include | exclude | patternset)*> | |||||
| <!ATTLIST srcfiles | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT zip (fileset | zipfileset)*> | |||||
| <!ATTLIST zip | |||||
| zipfile CDATA #REQUIRED | |||||
| basedir CDATA #REQUIRED | |||||
| items CDATA #IMPLIED | |||||
| ignore CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT zipfileset (include | exclude | patternset)*> | |||||
| <!ATTLIST zipfileset | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| prefix CDATA #IMPLIED | |||||
| fullpath CDATA #IMPLIED | |||||
| src CDATA #IMPLIED | |||||
| > | |||||
| @@ -1,118 +0,0 @@ | |||||
| <?xml version="1.0" encoding="iso-8859-1"?> | |||||
| <!-- | |||||
| The Apache Software License, Version 1.1 | |||||
| Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| reserved. | |||||
| Redistribution and use in source and binary forms, with or without | |||||
| modification, are permitted provided that the following conditions | |||||
| are met: | |||||
| 1. Redistributions of source code must retain the above copyright | |||||
| notice, this list of conditions and the following disclaimer. | |||||
| 2. Redistributions in binary form must reproduce the above copyright | |||||
| notice, this list of conditions and the following disclaimer in | |||||
| the documentation and/or other materials provided with the | |||||
| distribution. | |||||
| 3. The end-user documentation included with the redistribution, if | |||||
| any, must include the following acknowlegement: | |||||
| "This product includes software developed by the | |||||
| Apache Software Foundation (http://www.apache.org/)." | |||||
| Alternately, this acknowlegement may appear in the software itself, | |||||
| if and wherever such third-party acknowlegements normally appear. | |||||
| 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| Foundation" must not be used to endorse or promote products derived | |||||
| from this software without prior written permission. For written | |||||
| permission, please contact apache@apache.org. | |||||
| 5. Products derived from this software may not be called "Apache" | |||||
| nor may "Apache" appear in their names without prior written | |||||
| permission of the Apache Group. | |||||
| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| SUCH DAMAGE. | |||||
| ==================================================================== | |||||
| This software consists of voluntary contributions made by many | |||||
| individuals on behalf of the Apache Software Foundation. For more | |||||
| information on the Apache Software Foundation, please see | |||||
| <http://www.apache.org/>. | |||||
| --> | |||||
| <!-- @author Michel CASABIANCA --> | |||||
| <!-- @version $Revision$ --> | |||||
| <!ELEMENT project (target | property | path | taskdef | patternset | fileset)*> | |||||
| <!ATTLIST project | |||||
| name CDATA #REQUIRED | |||||
| default CDATA #REQUIRED | |||||
| basedir CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT property EMPTY> | |||||
| <!ATTLIST property | |||||
| name CDATA #IMPLIED | |||||
| value CDATA #IMPLIED | |||||
| resource CDATA #IMPLIED | |||||
| file CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT path (pathelement | path)*> | |||||
| <!ATTLIST path | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT classpath (pathelement | path | fileset)*> | |||||
| <!ATTLIST classpath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT fileset (include | exclude | patternset)*> | |||||
| <!ATTLIST fileset | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT patternset (include | exclude)*> | |||||
| <!ATTLIST patternset | |||||
| id CDATA #REQUIRED | |||||
| refid CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT exclude EMPTY> | |||||
| <!ATTLIST exclude | |||||
| name CDATA #REQUIRED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT include EMPTY> | |||||
| <!ATTLIST include | |||||
| name CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT pathelement EMPTY> | |||||
| <!ATTLIST pathelement | |||||
| location CDATA #IMPLIED | |||||
| path CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT taskdef EMPTY> | |||||
| <!ATTLIST taskdef | |||||
| name CDATA #REQUIRED | |||||
| classname CDATA #REQUIRED | |||||
| > | |||||
| @@ -1,84 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.About; | |||||
| import java.awt.Window; | |||||
| import java.awt.event.WindowEvent; | |||||
| /** | |||||
| * Handler for the About command. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class AboutCmd extends AbstractCommand { | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| */ | |||||
| public AboutCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Show the about box. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| new About(getContext()); | |||||
| } | |||||
| } | |||||
| @@ -1,91 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| /** | |||||
| * Convenience base class for Command implementations. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public abstract class AbstractCommand implements Command { | |||||
| /** Application context. */ | |||||
| private AppContext _context = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| protected AbstractCommand(AppContext context) { | |||||
| _context = context; | |||||
| } | |||||
| /** | |||||
| * Get the application context that was provided to setContext(); | |||||
| * | |||||
| * @return Application context. | |||||
| */ | |||||
| protected AppContext getContext() { | |||||
| return _context; | |||||
| } | |||||
| /** | |||||
| * Run the command. From interface Runnable. | |||||
| * | |||||
| */ | |||||
| public abstract void run(); | |||||
| } | |||||
| @@ -1,128 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| q * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.ErrorEvent; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| import org.apache.tools.ant.gui.acs.ACSTargetElement; | |||||
| import org.apache.tools.ant.gui.event.ShowConsoleEvent; | |||||
| /** | |||||
| * Starts an Ant build. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class BuildCmd extends AbstractCommand { | |||||
| /** Project to build. */ | |||||
| private ACSProjectElement _project = null; | |||||
| /** Targets to build. */ | |||||
| private ACSTargetElement[] _targets = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| */ | |||||
| public BuildCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Set the specific project to build (instead of the default). | |||||
| * | |||||
| * @param project Project to build. | |||||
| */ | |||||
| public void setProject(ACSProjectElement project) { | |||||
| _project = project; | |||||
| } | |||||
| /** | |||||
| * Set the specific targets to build (instead of the default). | |||||
| * | |||||
| * @param targets Array of targets to build. | |||||
| */ | |||||
| public void setTargets(ACSTargetElement[] targets) { | |||||
| _targets = targets; | |||||
| } | |||||
| /** | |||||
| * Start the Ant build. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| // Show the build console | |||||
| getContext().getEventBus().postEvent( | |||||
| new ShowConsoleEvent(getContext())); | |||||
| if(_project == null) { | |||||
| _project = getContext().getSelectionManager().getSelectedProject(); | |||||
| } | |||||
| if(_targets == null) { | |||||
| _targets = getContext().getSelectionManager().getSelectedTargets(); | |||||
| } | |||||
| if(_project != null) { | |||||
| try { | |||||
| getContext().getProjectManager().build(_project, _targets); | |||||
| } | |||||
| catch(Throwable ex) { | |||||
| getContext().getEventBus().postEvent( | |||||
| new ErrorEvent(getContext(), ex)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,81 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.util.ChangeLookAndFeel; | |||||
| /** | |||||
| * ChangeLookAndFeel command. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Erik Meade | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ChangeLookAndFeelCmd extends AbstractCommand { | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| */ | |||||
| public ChangeLookAndFeelCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Successfully do nothing. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| new ChangeLookAndFeel(getContext()); | |||||
| } | |||||
| } | |||||
| @@ -1,111 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.ProjectClosedEvent; | |||||
| import org.apache.tools.ant.gui.event.ProjectSelectedEvent; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| /** | |||||
| * Handler for the close command. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class CloseCmd extends AbstractCommand { | |||||
| /** Project to close. */ | |||||
| private ACSProjectElement _project = null; | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| */ | |||||
| public CloseCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Set the specific project to close (instead of the default). | |||||
| * | |||||
| * @param project Project to close. | |||||
| */ | |||||
| public void setProject(ACSProjectElement project) { | |||||
| _project = project; | |||||
| } | |||||
| /** | |||||
| * Send a close event to the parent window. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| if(_project == null) { | |||||
| _project = getContext().getSelectionManager().getSelectedProject(); | |||||
| } | |||||
| if(_project != null) { | |||||
| getContext().getProjectManager().close(_project); | |||||
| getContext().getEventBus().postEvent( | |||||
| new ProjectClosedEvent(getContext())); | |||||
| ACSProjectElement[] open = | |||||
| getContext().getProjectManager().getOpen(); | |||||
| if(open != null && open.length > 0) { | |||||
| getContext().getEventBus().postEvent( | |||||
| new ProjectSelectedEvent(getContext(), open[0])); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,72 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| /** | |||||
| * Interface for commands. | |||||
| * Details TBD | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public interface Command extends Runnable { | |||||
| /** | |||||
| * Run the command. From interface Runnable. | |||||
| * | |||||
| */ | |||||
| void run(); | |||||
| } | |||||
| @@ -1,106 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import java.util.EventObject; | |||||
| import javax.swing.JOptionPane; | |||||
| import org.w3c.dom.Node; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.DeleteElementEvent; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| /** | |||||
| * Command for removing the selected element. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class DeleteElementCmd extends AbstractCommand { | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public DeleteElementCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Delete the selected element. | |||||
| */ | |||||
| public void run() { | |||||
| // Ask "Are you sure?" | |||||
| int option = JOptionPane.showConfirmDialog(null, "Are You Sure?", | |||||
| "Confirm Delete", JOptionPane.YES_NO_OPTION); | |||||
| if (option == JOptionPane.YES_OPTION) { | |||||
| // Find the element to remove | |||||
| ACSElement[] vals = getContext().getSelectionManager(). | |||||
| getSelectedElements(); | |||||
| if(vals != null && vals.length > 0) { | |||||
| Node item = vals[vals.length - 1]; | |||||
| // Find the parent and remove the element. | |||||
| Node parent = item.getParentNode(); | |||||
| parent.removeChild(item); | |||||
| // Notify the tree the element was removed. | |||||
| DeleteElementEvent event = new DeleteElementEvent( | |||||
| getContext(), (ACSElement) parent); | |||||
| getContext().getEventBus().postEvent(event); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,164 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.util.StackFrame; | |||||
| import javax.swing.*; | |||||
| import java.awt.FlowLayout; | |||||
| import java.awt.event.ActionListener; | |||||
| import java.awt.event.ActionEvent; | |||||
| /** | |||||
| * Command for displaying an arbitrary error message to the user. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon H.K. Fitch | |||||
| */ | |||||
| public class DisplayErrorCmd extends AbstractCommand { | |||||
| /** Text description of error. */ | |||||
| private String _message = null; | |||||
| /** Throwable associated with the error. */ | |||||
| private Throwable _ex = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public DisplayErrorCmd(AppContext context) { | |||||
| this(context, null, null); | |||||
| } | |||||
| /** | |||||
| * No Throwable constructor. | |||||
| * | |||||
| * @param context Application context. | |||||
| * @param message Error message. | |||||
| */ | |||||
| public DisplayErrorCmd(AppContext context, String message) { | |||||
| this(context, message, null); | |||||
| } | |||||
| /** | |||||
| * Standard constuctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| * @param message Error message. | |||||
| * @param ex Throwable assocated with error. | |||||
| */ | |||||
| public DisplayErrorCmd(AppContext context, String message, Throwable ex) { | |||||
| super(context); | |||||
| _message = message; | |||||
| _ex = ex; | |||||
| } | |||||
| /** | |||||
| * Set the error message. | |||||
| * | |||||
| * @param message Error message. | |||||
| */ | |||||
| public void setMessage(String message) { | |||||
| _message = message; | |||||
| } | |||||
| /** | |||||
| * Set the throwable associated with the error. | |||||
| * | |||||
| * @param ex Throwable associated with the error. | |||||
| */ | |||||
| public void setThrowable(Throwable ex) { | |||||
| _ex = ex; | |||||
| } | |||||
| /** | |||||
| * Display the error. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| String title = getContext().getResources(). | |||||
| getString(getClass(), "title"); | |||||
| JOptionPane.showMessageDialog( | |||||
| getContext().getParentFrame(), new MsgPanel(), | |||||
| title, JOptionPane.ERROR_MESSAGE); | |||||
| } | |||||
| // Panel for assembling the error information. | |||||
| private class MsgPanel extends JPanel implements ActionListener { | |||||
| public MsgPanel() { | |||||
| setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); | |||||
| add(new JLabel(_message)); | |||||
| if(_ex != null) { | |||||
| add(new JLabel(_ex.getMessage())); | |||||
| JButton b = new JButton(getContext().getResources(). | |||||
| getString(DisplayErrorCmd.class, | |||||
| "expand")); | |||||
| b.addActionListener(this); | |||||
| add(Box.createVerticalStrut(20)); | |||||
| add(b); | |||||
| } | |||||
| } | |||||
| // Called when the user clicks the expand button. | |||||
| public void actionPerformed(ActionEvent e) { | |||||
| JComponent source = (JComponent) e.getSource(); | |||||
| JComponent parent = (JComponent) source.getParent(); | |||||
| parent.remove(source); | |||||
| JTextArea text = new JTextArea(); | |||||
| text.setEditable(false); | |||||
| text.setText(StackFrame.toString(_ex)); | |||||
| parent.add(new JScrollPane(text)); | |||||
| SwingUtilities.windowForComponent(parent).pack(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,91 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.ide.EmacsNotifier; | |||||
| /** | |||||
| * Toggle on or off the sending of error events to emacs so that | |||||
| * it can display the source of the error. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class EmacsNotifyCmd extends AbstractCommand { | |||||
| /** A global notifier can be used as it stores no state. */ | |||||
| private static EmacsNotifier _notifier = new EmacsNotifier(); | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public EmacsNotifyCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Turn on or off the notifying of emacs. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| if(getContext().getProjectManager(). | |||||
| isRegisteredBuildListener(_notifier)) { | |||||
| getContext().getProjectManager().removeBuildListener(_notifier); | |||||
| } | |||||
| else { | |||||
| getContext().getProjectManager().addBuildListener(_notifier); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,86 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.util.WindowUtils; | |||||
| import java.awt.Window; | |||||
| import java.awt.event.WindowEvent; | |||||
| /** | |||||
| * Handler for an exit command . | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ExitCmd extends AbstractCommand { | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public ExitCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Send a close event to the parent window. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| // Manually send a window close event to the window. | |||||
| WindowUtils.sendCloseEvent(getContext().getParentFrame()); | |||||
| } | |||||
| } | |||||
| @@ -1,119 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.ErrorEvent; | |||||
| import org.apache.tools.ant.gui.event.NewProjectEvent; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| import java.io.File; | |||||
| import java.io.IOException; | |||||
| /** | |||||
| * Command for reading in a build file and initializing the data model. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class LoadFileCmd extends AbstractCommand { | |||||
| /** The file to load. */ | |||||
| private File _file = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public LoadFileCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Set the file to load. | |||||
| * | |||||
| * @param file File to load. | |||||
| */ | |||||
| public void setFile(File file) { | |||||
| _file = file; | |||||
| } | |||||
| /** | |||||
| * Open the file and load it. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| if(!_file.exists()) { | |||||
| String message = getContext().getResources().getMessage( | |||||
| getClass(), "noFile", new Object[] { _file.toString() }); | |||||
| getContext().getEventBus(). | |||||
| postEvent(new ErrorEvent(getContext(), message)); | |||||
| } | |||||
| else { | |||||
| try { | |||||
| ACSProjectElement project = | |||||
| getContext().getProjectManager().open(_file); | |||||
| getContext().getEventBus().postEvent( | |||||
| new NewProjectEvent(getContext(), project)); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| String message = getContext().getResources().getMessage( | |||||
| getClass(), "loadError", | |||||
| new Object[] { _file.toString() }); | |||||
| getContext().getEventBus(). | |||||
| postEvent(new ErrorEvent(getContext(), message, ex)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,159 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import java.util.EventObject; | |||||
| import javax.swing.AbstractButton; | |||||
| import javax.swing.Action; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.NewBaseElementEvent; | |||||
| import org.apache.tools.ant.gui.event.RefreshDisplayEvent; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| import org.apache.tools.ant.gui.util.WindowUtils; | |||||
| import org.apache.tools.ant.gui.core.AntAction; | |||||
| /** | |||||
| * Command for creating a new propertyh. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class NewElementCmd extends AbstractCommand { | |||||
| /** New count for this session. Used to create default names, | |||||
| * numbered as a convenience. */ | |||||
| private static int _count = 1; | |||||
| private EventObject _event = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public NewElementCmd(AppContext context, EventObject event) { | |||||
| super(context); | |||||
| _event = event; | |||||
| } | |||||
| /** | |||||
| * Creates a new xml element based on the button which | |||||
| * was pressed. The button text may contain the name | |||||
| * of the new element or a dialog box is presented which | |||||
| * asks the user for the element type. | |||||
| */ | |||||
| public void run() { | |||||
| // Find which element is selected. | |||||
| ACSElement[] vals = getContext().getSelectionManager(). | |||||
| getSelectedElements(); | |||||
| if(vals == null || vals.length == 0) { | |||||
| return; | |||||
| } | |||||
| // Find the text of the button which was pressed | |||||
| // to determine the type of element to create. | |||||
| Object source = _event.getSource(); | |||||
| if (!(source instanceof AbstractButton)) { | |||||
| return; | |||||
| } | |||||
| AbstractButton button = (AbstractButton) source; | |||||
| String name = button.getText(); | |||||
| // Get the AntAction | |||||
| String cmdStr = button.getActionCommand(); | |||||
| AntAction antAction = getContext().getActions().getAction(cmdStr); | |||||
| if (antAction == null) { | |||||
| return; | |||||
| } | |||||
| ACSElement e = vals[vals.length - 1]; | |||||
| // Should we prompt the user use the element type? | |||||
| if (antAction.getName().equals(name)) { | |||||
| // Display the dialog box. | |||||
| ACSDtdDefinedElement dtde = (ACSDtdDefinedElement) e; | |||||
| NewElementDlg dlg = new NewElementDlg( | |||||
| getContext().getParentFrame(), true); | |||||
| dlg.setLists( | |||||
| dtde.getPossibleChildren(ACSDocumentType.CORE_ELEMENT), | |||||
| dtde.getPossibleChildren(ACSDocumentType.OPTIONAL_ELEMENT) ); | |||||
| dlg.pack(); | |||||
| WindowUtils.centerWindow(dlg); | |||||
| dlg.setTitle("Select the new element type"); | |||||
| dlg.setVisible(true); | |||||
| // Get the element type | |||||
| if (dlg.getCancel()) { | |||||
| name = ""; | |||||
| } else { | |||||
| name = dlg.getElementName(); | |||||
| } | |||||
| } | |||||
| if (name.length() > 0) { | |||||
| // Create the new element | |||||
| ACSElement retval = | |||||
| ACSFactory.getInstance().createElement(e, name); | |||||
| getContext().getEventBus().postEvent( | |||||
| new NewBaseElementEvent(getContext(), retval)); | |||||
| } else { | |||||
| // Request a refresh so the popup menu is removed | |||||
| // from the display. | |||||
| getContext().getEventBus().postEvent( | |||||
| new RefreshDisplayEvent(getContext())); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,429 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import javax.swing.*; | |||||
| import java.util.List; | |||||
| import java.util.ArrayList; | |||||
| import org.apache.tools.ant.gui.util.Collections; | |||||
| /** | |||||
| * A Dialog which asks for a new xml element's type. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class NewElementDlg extends javax.swing.JDialog { | |||||
| // Dialog's components | |||||
| private javax.swing.JPanel _southPanel; | |||||
| private javax.swing.JPanel _buttonPanel; | |||||
| private javax.swing.JButton _buttonOK; | |||||
| private javax.swing.JButton _buttonCancel; | |||||
| private javax.swing.JCheckBox _optionalButton; | |||||
| private javax.swing.JPanel _selectPanel; | |||||
| private javax.swing.JPanel _panelData; | |||||
| private javax.swing.JLabel _label; | |||||
| private javax.swing.JTextField _elementText; | |||||
| private javax.swing.JScrollPane _listScrollPane; | |||||
| private javax.swing.JList _elementList; | |||||
| /** set to true if cancel is pressed */ | |||||
| private boolean _cancel = true; | |||||
| /** holds the element type */ | |||||
| private String _elementName; | |||||
| /** list of core tasks */ | |||||
| private List _coreElements; | |||||
| /** list of optional tasks */ | |||||
| private List _optionalElements; | |||||
| /** list of tasks to display */ | |||||
| private List _elements; | |||||
| /** | |||||
| * Creates new form NewElementDlg | |||||
| */ | |||||
| public NewElementDlg(java.awt.Frame parent, boolean modal) { | |||||
| super(parent, modal); | |||||
| initComponents(); | |||||
| enableButtons(); | |||||
| } | |||||
| /** | |||||
| * Fills the listbox with the input list. | |||||
| */ | |||||
| public void setLists(String[] coreElements, String[] optionalElements) { | |||||
| // Are there any items to display? | |||||
| if ( (coreElements == null || coreElements.length == 0) && | |||||
| (optionalElements == null || optionalElements.length == 0 ) ) { | |||||
| // Hide the list | |||||
| _listScrollPane.setVisible(false); | |||||
| _optionalButton.setVisible(false); | |||||
| } else { | |||||
| // Are there any core elements? | |||||
| if (coreElements == null) { | |||||
| _coreElements = new ArrayList(); | |||||
| // Display the optional elements | |||||
| _optionalButton.setSelected(true); | |||||
| _optionalButton.setVisible(false); | |||||
| } else { | |||||
| // Create a sorted list of the core elements | |||||
| List temp = Collections.fill(null, coreElements); | |||||
| java.util.Collections.sort(temp); | |||||
| _coreElements = temp; | |||||
| } | |||||
| // Are there any optional elements? | |||||
| if (optionalElements == null) { | |||||
| _optionalElements = new ArrayList(); | |||||
| // Display the core elements | |||||
| _optionalButton.setSelected(false); | |||||
| _optionalButton.setVisible(false); | |||||
| } else { | |||||
| // Create a sorted list of the optional elements | |||||
| List temp = Collections.fill(null, optionalElements); | |||||
| java.util.Collections.sort(temp); | |||||
| _optionalElements = temp; | |||||
| } | |||||
| // Are the lists the same? | |||||
| if (_optionalElements.containsAll(_coreElements) && | |||||
| _coreElements.containsAll(_optionalElements) ) { | |||||
| // Hide the button | |||||
| _optionalButton.setVisible(false); | |||||
| } | |||||
| } | |||||
| enableButtons(); | |||||
| } | |||||
| /** | |||||
| * Returns true if cancel was pressed | |||||
| */ | |||||
| public boolean getCancel() { | |||||
| return _cancel; | |||||
| } | |||||
| /** | |||||
| * Returns the entered element type | |||||
| */ | |||||
| public String getElementName() { | |||||
| return _elementName; | |||||
| } | |||||
| /** | |||||
| * Enable or disable buttons | |||||
| */ | |||||
| private void enableButtons() { | |||||
| // Enable the OK button? | |||||
| if (isInputValid()) { | |||||
| _buttonOK.setEnabled(true); | |||||
| } else { | |||||
| _buttonOK.setEnabled(false); | |||||
| } | |||||
| // Display the core or optional elements? | |||||
| Object oldList = _elements; | |||||
| if (_optionalButton.isSelected()) { | |||||
| _elements = _optionalElements; | |||||
| } else { | |||||
| _elements = _coreElements; | |||||
| } | |||||
| // Did the list change? | |||||
| if (oldList != _elements) { | |||||
| _elementList.setListData(_elements.toArray()); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns true if the user input is valid. | |||||
| */ | |||||
| private boolean isInputValid() { | |||||
| return ( isXMLName( _elementText.getText() ) ); | |||||
| } | |||||
| /** | |||||
| * Returns true if the value is a legal XML name. | |||||
| * | |||||
| * @param value the string being tested | |||||
| */ | |||||
| public boolean isXMLName (String value) | |||||
| { | |||||
| if (value == null || value.length() == 0) | |||||
| return false; | |||||
| char c = value.charAt (0); | |||||
| if (!isLetter (c) && c != '_' && c != ':') | |||||
| return false; | |||||
| for (int i = 1; i < value.length (); i++) | |||||
| if (!isNameChar (value.charAt (i))) | |||||
| return false; | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * Returns true if the character is allowed to be a non-initial | |||||
| * character in an XML name. | |||||
| */ | |||||
| public boolean isNameChar (char c) | |||||
| { | |||||
| if (isLetter (c)) | |||||
| return true; | |||||
| else if (c == '>') | |||||
| return false; | |||||
| else if (c >= '0' && c <= '9') | |||||
| return true; | |||||
| else if (c == '.' || c == '-' || c == '_' || c == ':') | |||||
| return true; | |||||
| else | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * Returns true if the character is a letter. | |||||
| */ | |||||
| public boolean isLetter (char c) | |||||
| { | |||||
| if (c >= 'a' && c <= 'z') | |||||
| return true; | |||||
| if (c >= 'A' && c <= 'Z') | |||||
| return true; | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * This method is called from within the constructor to | |||||
| * initialize the form. | |||||
| */ | |||||
| private void initComponents() { | |||||
| _southPanel = new javax.swing.JPanel(); | |||||
| _buttonPanel = new javax.swing.JPanel(); | |||||
| _buttonOK = new javax.swing.JButton(); | |||||
| _buttonCancel = new javax.swing.JButton(); | |||||
| _selectPanel = new javax.swing.JPanel(); | |||||
| _panelData = new javax.swing.JPanel(); | |||||
| _label = new javax.swing.JLabel(); | |||||
| _elementText = new javax.swing.JTextField(); | |||||
| _listScrollPane = new javax.swing.JScrollPane(); | |||||
| _elementList = new javax.swing.JList(); | |||||
| _optionalButton = new javax.swing.JCheckBox( | |||||
| "show optional elements", false); | |||||
| getContentPane().setLayout(new java.awt.BorderLayout(10, 10)); | |||||
| addWindowListener(new java.awt.event.WindowAdapter() { | |||||
| public void windowClosing(java.awt.event.WindowEvent evt) { | |||||
| closeDialog(evt); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _southPanel.setLayout(new java.awt.FlowLayout(2, 2, 0)); | |||||
| _southPanel.setPreferredSize(new java.awt.Dimension(156, 50)); | |||||
| _southPanel.setMinimumSize(new java.awt.Dimension(154, 50)); | |||||
| _buttonPanel.setLayout(new java.awt.FlowLayout(1, 2, 0)); | |||||
| _buttonPanel.setPreferredSize(new java.awt.Dimension(146, 50)); | |||||
| _buttonPanel.setMinimumSize(new java.awt.Dimension(150, 50)); | |||||
| _buttonPanel.setAlignmentY(0.0F); | |||||
| _buttonPanel.setAlignmentX(0.0F); | |||||
| _buttonOK.setText("OK"); | |||||
| _buttonOK.setPreferredSize(new java.awt.Dimension(50, 30)); | |||||
| _buttonOK.setMaximumSize(new java.awt.Dimension(50, 30)); | |||||
| _buttonOK.setMargin(new java.awt.Insets(10, 10, 10, 10)); | |||||
| _buttonOK.setMinimumSize(new java.awt.Dimension(50, 30)); | |||||
| _buttonOK.addActionListener(new java.awt.event.ActionListener() { | |||||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
| clickOK(evt); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _buttonPanel.add(_buttonOK); | |||||
| _buttonCancel.setText("Cancel"); | |||||
| _buttonCancel.setPreferredSize(new java.awt.Dimension(70, 30)); | |||||
| _buttonCancel.setMaximumSize(new java.awt.Dimension(60, 30)); | |||||
| _buttonCancel.setMargin(new java.awt.Insets(10, 10, 10, 10)); | |||||
| _buttonCancel.setMinimumSize(new java.awt.Dimension(60, 30)); | |||||
| _buttonCancel.addActionListener(new java.awt.event.ActionListener() { | |||||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
| clickCancel(evt); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _buttonPanel.add(_buttonCancel); | |||||
| _southPanel.add(_buttonPanel); | |||||
| getContentPane().add(_southPanel, java.awt.BorderLayout.SOUTH); | |||||
| _selectPanel.setLayout(new java.awt.BorderLayout(10, 10)); | |||||
| _selectPanel.setBorder(new javax.swing.border.EtchedBorder()); | |||||
| _label.setText("Element Type:"); | |||||
| _label.setAlignmentX(0.5F); | |||||
| _panelData.add(_label); | |||||
| _elementText.setPreferredSize(new java.awt.Dimension(110, 25)); | |||||
| _elementText.setMargin(new java.awt.Insets(2, 2, 2, 2)); | |||||
| _elementText.setMinimumSize(new java.awt.Dimension(14, 25)); | |||||
| _elementText.addKeyListener(new java.awt.event.KeyAdapter() { | |||||
| public void keyReleased(java.awt.event.KeyEvent evt) { | |||||
| _elementTextKeyReleased(evt); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _panelData.add(_elementText); | |||||
| _selectPanel.add(_panelData, java.awt.BorderLayout.SOUTH); | |||||
| _elementList.setMaximumSize(new java.awt.Dimension(100, 20)); | |||||
| _elementList.setMinimumSize(new java.awt.Dimension(10, 10)); | |||||
| _elementList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { | |||||
| public void valueChanged(javax.swing.event.ListSelectionEvent evt) { | |||||
| itemSelected(evt); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _elementList.addMouseListener(new java.awt.event.MouseAdapter() { | |||||
| public void mouseClicked(java.awt.event.MouseEvent evt) { | |||||
| itemMouseClicked(evt); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _listScrollPane.setViewportView(_elementList); | |||||
| _optionalButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); | |||||
| _optionalButton.addActionListener(new java.awt.event.ActionListener() { | |||||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
| enableButtons(); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _selectPanel.add(_optionalButton, java.awt.BorderLayout.NORTH); | |||||
| _selectPanel.add(_listScrollPane, java.awt.BorderLayout.CENTER); | |||||
| getContentPane().add(_selectPanel, java.awt.BorderLayout.CENTER); | |||||
| pack(); | |||||
| } | |||||
| /** Called when a key is released */ | |||||
| private void _elementTextKeyReleased(java.awt.event.KeyEvent evt) { | |||||
| enableButtons(); | |||||
| } | |||||
| /** Called when an item is selected from the list */ | |||||
| private void itemSelected(javax.swing.event.ListSelectionEvent evt) { | |||||
| // Update the text field | |||||
| _elementText.setText((String) _elementList.getSelectedValue()); | |||||
| enableButtons(); | |||||
| } | |||||
| /** Called when the list is clicked */ | |||||
| private void itemMouseClicked(java.awt.event.MouseEvent evt) { | |||||
| int count = evt.getClickCount(); | |||||
| Object obj = _elementList.getSelectedValue(); | |||||
| // Double click on an item? | |||||
| if (count == 2 && obj != null) { | |||||
| // Update the text field | |||||
| _elementText.setText((String) _elementList.getSelectedValue()); | |||||
| // Process like OK was pressed | |||||
| if (isInputValid()) { | |||||
| clickOK(null); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** Called when the Cancel button is pressed */ | |||||
| private void clickCancel(java.awt.event.ActionEvent evt) { | |||||
| // Make us invisible | |||||
| setVisible(false); | |||||
| dispose(); | |||||
| // Set the cancel flag | |||||
| _cancel = true; | |||||
| } | |||||
| /** Called when the OK button is pressed */ | |||||
| private void clickOK(java.awt.event.ActionEvent evt) { | |||||
| // Make us invisible | |||||
| setVisible(false); | |||||
| dispose(); | |||||
| // Return selected item. | |||||
| _cancel = false; | |||||
| _elementName = _elementText.getText(); | |||||
| } | |||||
| /** Closes the dialog */ | |||||
| private void closeDialog(java.awt.event.WindowEvent evt) { | |||||
| setVisible(false); | |||||
| dispose(); | |||||
| } | |||||
| /** | |||||
| * Test the dialog | |||||
| * | |||||
| * @param args the command line arguments | |||||
| */ | |||||
| public static void main(String args[]) { | |||||
| new NewElementDlg(new javax.swing.JFrame(), true).show(); | |||||
| } | |||||
| } | |||||
| @@ -1,92 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.NewProjectEvent; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| /** | |||||
| * Command for creating a new project. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class NewProjectCmd extends AbstractCommand { | |||||
| /** New project count for this session. Used to create default names, | |||||
| * numbered as a convenience. */ | |||||
| private static int _count = 1; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public NewProjectCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Create a new project and make it active. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| ACSProjectElement project = | |||||
| getContext().getProjectManager().createNew(); | |||||
| project.setName(getContext().getResources(). | |||||
| getString(getClass(), "defName") + " " + _count++); | |||||
| getContext().getEventBus().postEvent( | |||||
| new NewProjectEvent(getContext(), project)); | |||||
| } | |||||
| } | |||||
| @@ -1,93 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.NewPropertyEvent; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| /** | |||||
| * Command for creating a new propertyh. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class NewPropertyCmd extends AbstractCommand { | |||||
| /** New count for this session. Used to create default names, | |||||
| * numbered as a convenience. */ | |||||
| private static int _count = 1; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public NewPropertyCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Create a new property and make it active. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| ACSElement[] vals = getContext().getSelectionManager(). | |||||
| getSelectedElements(); | |||||
| if(vals != null && vals.length > 0) { | |||||
| ACSPropertyElement retval = | |||||
| ACSFactory.getInstance().createProperty(vals[vals.length - 1]); | |||||
| getContext().getEventBus().postEvent( | |||||
| new NewPropertyEvent(getContext(), retval)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,94 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.NewTargetEvent; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| /** | |||||
| * Command for creating a new target. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class NewTargetCmd extends AbstractCommand { | |||||
| /** New project count for this session. Used to create default names, | |||||
| * numbered as a convenience. */ | |||||
| private static int _count = 1; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public NewTargetCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Create a new target and make it active. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| ACSProjectElement project = getContext().getSelectionManager(). | |||||
| getSelectedProject(); | |||||
| ACSTargetElement retval = | |||||
| ACSFactory.getInstance().createTarget(project); | |||||
| retval.setName(getContext().getResources(). | |||||
| getString(getClass(), "defName") + " " + _count++); | |||||
| getContext().getEventBus().postEvent( | |||||
| new NewTargetEvent(getContext(), retval)); | |||||
| } | |||||
| } | |||||
| @@ -1,94 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.NewTaskEvent; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| /** | |||||
| * Command for creating a new task. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class NewTaskCmd extends AbstractCommand { | |||||
| /** New count for this session. Used to create default names, | |||||
| * numbered as a convenience. */ | |||||
| private static int _count = 1; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public NewTaskCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Create a new task and make it active. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| ACSTargetElement[] targets = getContext().getSelectionManager(). | |||||
| getSelectedTargets(); | |||||
| if(targets != null && targets.length > 0) { | |||||
| ACSTaskElement retval = | |||||
| ACSFactory.getInstance().createTask(targets[0]); | |||||
| retval.setTaskType("javac"); | |||||
| getContext().getEventBus().postEvent( | |||||
| new NewTaskEvent(getContext(), retval)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,78 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| /** | |||||
| * NoOp command. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class NoOpCmd extends AbstractCommand { | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public NoOpCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Successfully do nothing. | |||||
| * | |||||
| */ | |||||
| public void run() {} | |||||
| } | |||||
| @@ -1,98 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.OpenRequestEvent; | |||||
| import org.apache.tools.ant.gui.core.XMLFileFilter; | |||||
| import javax.swing.JFileChooser; | |||||
| import javax.swing.filechooser.FileFilter; | |||||
| import java.io.File; | |||||
| /** | |||||
| * Command to execute the opening of a file. A dialog is presented to the | |||||
| * user for selecting a build file to open. If a file is selected then an | |||||
| * OpenRequestEvent is posted. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class OpenCmd extends AbstractCommand { | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public OpenCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Display a dialog asking the user to select a file to open. | |||||
| * If one is selected then an event is posted requesting the open | |||||
| * operation be completed. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| FileFilter filter = new XMLFileFilter(getContext().getResources()); | |||||
| JFileChooser chooser = new JFileChooser(); | |||||
| chooser.addChoosableFileFilter(filter); | |||||
| int val = chooser.showOpenDialog(getContext().getParentFrame()); | |||||
| if(val == JFileChooser.APPROVE_OPTION) { | |||||
| File selected = chooser.getSelectedFile(); | |||||
| getContext().getEventBus().postEvent( | |||||
| new OpenRequestEvent(getContext(), selected)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,181 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.ErrorEvent; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| import java.io.*; | |||||
| import org.apache.tools.ant.gui.core.XMLFileFilter; | |||||
| import javax.swing.JFileChooser; | |||||
| import javax.swing.filechooser.FileFilter; | |||||
| import javax.swing.JOptionPane; | |||||
| import java.net.URL; | |||||
| import java.net.MalformedURLException; | |||||
| /** | |||||
| * Command for doing a "Save as" type of save. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class SaveAsCmd extends AbstractCommand { | |||||
| /** File to save to. */ | |||||
| private URL _location = null; | |||||
| /** Project to save. */ | |||||
| private ACSProjectElement _project = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public SaveAsCmd(AppContext context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Set the location to save to | |||||
| * | |||||
| * @param location location to save to. | |||||
| */ | |||||
| public void setLocation(URL location) { | |||||
| _location = location; | |||||
| } | |||||
| /** | |||||
| * Set the specific project to save (instead of the default). | |||||
| * | |||||
| * @param project Project to save. | |||||
| */ | |||||
| public void setProject(ACSProjectElement project) { | |||||
| _project = project; | |||||
| } | |||||
| /** | |||||
| * Save the project to the current file name. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| FileFilter filter = new XMLFileFilter(getContext().getResources()); | |||||
| if(_project == null) { | |||||
| _project = getContext().getSelectionManager().getSelectedProject(); | |||||
| } | |||||
| if(_project != null) { | |||||
| // If no location is specified, then this truly is a SaveAs | |||||
| // command. Provide the user the UI to select the output. | |||||
| if(_location == null) { | |||||
| JFileChooser chooser = new JFileChooser(); | |||||
| chooser.addChoosableFileFilter(filter); | |||||
| int val = chooser.showSaveDialog( | |||||
| getContext().getParentFrame()); | |||||
| if(val == JFileChooser.APPROVE_OPTION) { | |||||
| File file = chooser.getSelectedFile(); | |||||
| if(file.exists()) { | |||||
| String title = getContext().getResources(). | |||||
| getString(SaveCmd.class, "title"); | |||||
| String message = getContext().getResources(). | |||||
| getMessage(SaveCmd.class, "overwrite", | |||||
| new Object[] { file.toString()}); | |||||
| val = JOptionPane.showConfirmDialog( | |||||
| getContext().getParentFrame(), message, title, | |||||
| JOptionPane.YES_NO_OPTION); | |||||
| // If cancelled unset file. | |||||
| if(val != JOptionPane.YES_OPTION) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| try { | |||||
| _location = new URL( | |||||
| "file", null, file.getAbsolutePath()); | |||||
| } | |||||
| catch(MalformedURLException ex) { | |||||
| // Shouldn't happen. Save will just not | |||||
| // happen. | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| // If a location is now available, do the save operation. | |||||
| if(_location != null) { | |||||
| try { | |||||
| getContext().getProjectManager().saveAs( | |||||
| _project, _location); | |||||
| } | |||||
| catch(IOException ex) { | |||||
| String message = getContext().getResources().getMessage( | |||||
| SaveCmd.class, "saveError", | |||||
| new Object[] { _location.toString() }); | |||||
| getContext().getEventBus(). | |||||
| postEvent(new ErrorEvent(getContext(), message, ex)); | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| // We shouldn't ever get here. | |||||
| String message = getContext().getResources().getString( | |||||
| SaveCmd.class, "noProject"); | |||||
| getContext().getEventBus(). | |||||
| postEvent(new ErrorEvent(getContext(), message)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,79 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| /** | |||||
| * Command to execute the saving of the current build file. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class SaveCmd extends SaveAsCmd { | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public SaveCmd(AppContext context) { | |||||
| super(context); | |||||
| ACSProjectElement project = | |||||
| getContext().getSelectionManager().getSelectedProject(); | |||||
| if(project != null) { | |||||
| setLocation(project.getLocation()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,147 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.command; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import java.awt.*; | |||||
| import javax.swing.*; | |||||
| /** | |||||
| * Toggles the display of the console window | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | |||||
| */ | |||||
| public class ShowOrHideConsoleCmd extends AbstractCommand { | |||||
| /** Always show the console */ | |||||
| boolean _alwaysShow = false; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public ShowOrHideConsoleCmd(AppContext context) { | |||||
| super(context); | |||||
| _alwaysShow = false; | |||||
| } | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public ShowOrHideConsoleCmd(AppContext context, boolean alwaysShow) { | |||||
| super(context); | |||||
| _alwaysShow = alwaysShow; | |||||
| } | |||||
| /** | |||||
| * If the console pane is visible, hide it. | |||||
| * If the console pane is not visible, show it. | |||||
| */ | |||||
| public void run() { | |||||
| JComponent component = (JComponent) findComponent("Console"); | |||||
| JSplitPane pane = (JSplitPane) component.getParent(); | |||||
| if (_alwaysShow) { | |||||
| if (component.getHeight() == 0) { | |||||
| pane.setDividerLocation(pane.getLastDividerLocation()); | |||||
| } | |||||
| } else { | |||||
| if (component.getHeight() == 0) { | |||||
| pane.setDividerLocation(pane.getLastDividerLocation()); | |||||
| } else { | |||||
| pane.setDividerLocation(1.0); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Starting from the top Frame, find the | |||||
| * first child window with the input name. | |||||
| * | |||||
| * @param name The name of the <code>Component</code> | |||||
| */ | |||||
| private Component findComponent(String name) { | |||||
| JFrame frame = (JFrame) getContext().getParentFrame(); | |||||
| JRootPane root = frame.getRootPane(); | |||||
| return findChild(root.getContentPane(), name); | |||||
| } | |||||
| /** | |||||
| * Search the <code>Container</code> for a <code>Component</code> | |||||
| * with the input name. The search is recursive. | |||||
| * | |||||
| * @param container The <code>Container</code> to search | |||||
| * @param name The name of the <code>Component</code> | |||||
| */ | |||||
| private Component findChild(Container container, String name) { | |||||
| Component[] components = container.getComponents(); | |||||
| for (int i = 0; i < components.length; i++) { | |||||
| Component component = components[i]; | |||||
| if ( name.equals(component.getName()) ) { | |||||
| return component; | |||||
| } | |||||
| if (component instanceof java.awt.Container) { | |||||
| Component test = findChild( | |||||
| (java.awt.Container) component, name); | |||||
| if (test != null) { | |||||
| return test; | |||||
| } | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | |||||
| @@ -1,424 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import org.apache.tools.ant.gui.command.Command; | |||||
| import org.apache.tools.ant.gui.util.CheckableButtonModel; | |||||
| import javax.swing.*; | |||||
| import javax.accessibility.*; | |||||
| import java.util.*; | |||||
| import java.beans.*; | |||||
| import java.lang.reflect.Constructor; | |||||
| /** | |||||
| * Manager of antidote actions. Receives its configuration from the action | |||||
| * ResourceBundle. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ActionManager { | |||||
| /** Parameters for the Command constructor. */ | |||||
| private static final Class[] COMMAND_CTOR_PARAMS = { AppContext.class }; | |||||
| private static final Class[] COMMAND_CTOR_PARAMS_WITH_EVENT = | |||||
| { AppContext.class, EventObject.class }; | |||||
| /** Externalized resources. */ | |||||
| private ResourceManager _resources = null; | |||||
| /** Array of action identifiers. */ | |||||
| private String[] _actionIDs = null; | |||||
| /** Look table of all defined actions. */ | |||||
| private Map _actions = new HashMap(); | |||||
| /** Event bus. */ | |||||
| private EventBus _bus = null; | |||||
| /** Class for storing the event type to action type | |||||
| * mapping for setting enabled state. */ | |||||
| private EventToActionMapper _mapper = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param bus Event bus to post events to. | |||||
| * @param resources Location of resources. | |||||
| */ | |||||
| public ActionManager(EventBus bus, ResourceManager resources) { | |||||
| _bus = bus; | |||||
| _resources = resources; | |||||
| bus.addMember(EventBus.RESPONDING, new Enabler()); | |||||
| _mapper = new EventToActionMapper(); | |||||
| // Configure the set of actions. | |||||
| String[] names = _resources.getStringArray("actions"); | |||||
| _actionIDs = new String[names.length]; | |||||
| for(int i = 0; i < _actionIDs.length; i++) { | |||||
| _actionIDs[i] = names[i]; | |||||
| AntAction action = new AntAction(_resources, _bus, _actionIDs[i]); | |||||
| _actions.put(_actionIDs[i], action); | |||||
| // For each action we need to add the reverse event trigger | |||||
| // lookup. | |||||
| _mapper.addAction(action); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Create a menubar for the application based on the configuration file. | |||||
| * | |||||
| * @return Menubar. | |||||
| */ | |||||
| public JMenuBar createMenuBar() { | |||||
| JMenuBar retval = new JMenuBar(); | |||||
| Map menus = new HashMap(); | |||||
| String toTok = _resources.getString("menus"); | |||||
| StringTokenizer tok = new StringTokenizer(toTok, ", "); | |||||
| while(tok.hasMoreTokens()) { | |||||
| String name = tok.nextToken(); | |||||
| JMenu menu = new JMenu(name); | |||||
| // XXX should be in config file | |||||
| menu.setMnemonic(name.charAt(0)); | |||||
| // XXX need to i18n here... | |||||
| if(name.equalsIgnoreCase("help")) { | |||||
| try { | |||||
| retval.setHelpMenu(menu); | |||||
| } | |||||
| catch(Error err) { | |||||
| // Catch the "not implemented" error in | |||||
| // some (all?) Swing implementations | |||||
| retval.add(menu); | |||||
| } | |||||
| } | |||||
| else { | |||||
| retval.add(menu); | |||||
| } | |||||
| menus.put(name, menu); | |||||
| } | |||||
| for(int i = 0; i < _actionIDs.length; i++) { | |||||
| AntAction action = (AntAction) _actions.get(_actionIDs[i]); | |||||
| String parent = action.getParentMenuName(); | |||||
| if(parent != null) { | |||||
| JMenu menu = (JMenu) menus.get(parent); | |||||
| // A well configured file shouldn't cause this, | |||||
| // but be safe anyway. | |||||
| if(menu == null) { | |||||
| menu = new JMenu(parent); | |||||
| retval.add(menu); | |||||
| menus.put(parent, menu); | |||||
| } | |||||
| // See if we should add a separator. | |||||
| if(action.isPreceededBySeparator() && | |||||
| menu.getMenuComponentCount() > 0) { | |||||
| menu.addSeparator(); | |||||
| } | |||||
| if(!action.isToggle()) { | |||||
| JMenuItem item = menu.add(action); | |||||
| item.setAccelerator(action.getAccelerator()); | |||||
| addNiceStuff(item, action); | |||||
| } | |||||
| else { | |||||
| JCheckBoxMenuItem b = | |||||
| new JCheckBoxMenuItem(action.getName()); | |||||
| b.setActionCommand(action.getID()); | |||||
| b.addActionListener(action); | |||||
| action.addPropertyChangeListener( | |||||
| new PropertyWatcher(b)); | |||||
| // XXX eck. This is a 1.3 feature. Fix ME! | |||||
| // Need to provide binding between action and widget. | |||||
| // b.setAction(action); | |||||
| addNiceStuff(b, action); | |||||
| menu.add(b); | |||||
| } | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Create a tool bar based on the current configuration. | |||||
| * | |||||
| * @return Toolbar ready for action. | |||||
| */ | |||||
| public JToolBar createToolBar() { | |||||
| JToolBar retval = new JToolBar(); | |||||
| for(int i = 0; i < _actionIDs.length; i++) { | |||||
| AntAction action = (AntAction) _actions.get(_actionIDs[i]); | |||||
| // If the action is hidden do not display it. | |||||
| if(action.isHidden()) { | |||||
| continue; | |||||
| } | |||||
| // If it has an icon, then we add it to the toolbar. | |||||
| if(action.getIcon() != null) { | |||||
| if(action.isPreceededBySeparator()) { | |||||
| retval.addSeparator(); | |||||
| } | |||||
| JButton button = retval.add(action); | |||||
| button.setText(null); | |||||
| // Watch for CHECKED changes | |||||
| action.addPropertyChangeListener( | |||||
| new PropertyWatcher(button)); | |||||
| if(action.isToggle()) { | |||||
| ButtonModel model = new CheckableButtonModel(); | |||||
| button.setModel(model); | |||||
| } | |||||
| addNiceStuff(button, action); | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Create a popup menu with the given actionIDs. | |||||
| * XXX check this for object leak. Does the button | |||||
| * get added to the action as a listener? There are also some | |||||
| * changes to this behavior in 1.3. | |||||
| * | |||||
| * @param actionIDs List of action IDs for actions | |||||
| * to appear in popup menu. | |||||
| * @param defaultID Use this action ID if the item | |||||
| * from the list is not found. | |||||
| * @return Popup menu to display. | |||||
| */ | |||||
| public JPopupMenu createPopup(String[] actionIDs, String defaultID) { | |||||
| JPopupMenu retval = new JPopupMenu(); | |||||
| for(int i = 0; i < actionIDs.length; i++) { | |||||
| AntAction action = (AntAction) _actions.get(actionIDs[i]); | |||||
| // If the ID is not found, use the default. | |||||
| if (action == null && defaultID != null) { | |||||
| action = (AntAction) _actions.get(defaultID); | |||||
| AbstractButton button = retval.add(action); | |||||
| // Set the button text to the action ID. | |||||
| button.setText(actionIDs[i]); | |||||
| addNiceStuff(button, action); | |||||
| } else { | |||||
| if(action.isPopupPreceededBySeparator() && | |||||
| retval.getComponentCount() > 0) { | |||||
| retval.addSeparator(); | |||||
| } | |||||
| AbstractButton button = retval.add(action); | |||||
| addNiceStuff(button, action); | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Get the command assocaited with the Action with the given id. | |||||
| * | |||||
| * @param actionID Id of action to get command for. | |||||
| * @return Command associated with action, or null if none available. | |||||
| */ | |||||
| public Command getActionCommand(String actionID, | |||||
| AppContext context, | |||||
| EventObject event) { | |||||
| Command retval = null; | |||||
| AntAction action = (AntAction) _actions.get(actionID); | |||||
| if(action != null) { | |||||
| Class clazz = action.getCommandClass(); | |||||
| if(clazz != null) { | |||||
| try { | |||||
| Constructor ctor = | |||||
| clazz.getConstructor(COMMAND_CTOR_PARAMS); | |||||
| retval = (Command) ctor.newInstance( | |||||
| new Object[] { context }); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| try { | |||||
| Constructor ctor = clazz.getConstructor( | |||||
| COMMAND_CTOR_PARAMS_WITH_EVENT); | |||||
| retval = (Command) ctor.newInstance( | |||||
| new Object[] { context, event }); | |||||
| } | |||||
| catch (Exception ex2) { | |||||
| // XXX log me. | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Get the Action with the given id. | |||||
| * | |||||
| * @param actionID Id of action to get command for. | |||||
| * @return AntAction associated with the given id. | |||||
| */ | |||||
| public AntAction getAction(String actionID) { | |||||
| return (AntAction) _actions.get(actionID); | |||||
| } | |||||
| /** | |||||
| * Add tool tip, Mnemonic, etc. | |||||
| * | |||||
| * @param button Button to work on. | |||||
| * @param action Associated action. | |||||
| */ | |||||
| private void addNiceStuff(AbstractButton button, AntAction action) { | |||||
| // Set the action command so that it is consitent | |||||
| // no matter what language the display is in. | |||||
| button.setActionCommand(action.getID()); | |||||
| // XXX this should be moved to the config file. | |||||
| String label = button.getText(); | |||||
| if(label != null) { | |||||
| button.setMnemonic(label.charAt(0)); | |||||
| } | |||||
| String tip = action.getShortDescription(); | |||||
| if(tip != null) { | |||||
| button.setToolTipText(tip); | |||||
| } | |||||
| } | |||||
| /** Class for updating the enabled status of icons based | |||||
| * on the events seen. */ | |||||
| private class Enabler implements BusMember { | |||||
| private final Filter _filter = new Filter(); | |||||
| /** | |||||
| * Get the filter to that is used to determine if an event should | |||||
| * to to the member. | |||||
| * | |||||
| * @return Filter to use. | |||||
| */ | |||||
| public BusFilter getBusFilter() { | |||||
| return _filter; | |||||
| } | |||||
| /** | |||||
| * Receives all events. | |||||
| * | |||||
| * @param event Event to post. | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event) { | |||||
| _mapper.applyEvent(event); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| /** Class providing filtering for project events. */ | |||||
| private static class Filter implements BusFilter { | |||||
| /** | |||||
| * Determines if the given event should be accepted. | |||||
| * | |||||
| * @param event Event to test. | |||||
| * @return True if event should be given to BusMember, false otherwise. | |||||
| */ | |||||
| public boolean accept(EventObject event) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| /** Class which's hooks the action to toggle buttons. */ | |||||
| private static class PropertyWatcher implements PropertyChangeListener { | |||||
| private AbstractButton _target; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param target Button to update | |||||
| */ | |||||
| public PropertyWatcher(AbstractButton target) { | |||||
| _target = target; | |||||
| } | |||||
| /** | |||||
| * Change the Selected stated of the button if the CHECKED | |||||
| * property is set on the <code>action</code> | |||||
| * | |||||
| * @param event Event to test. | |||||
| */ | |||||
| public void propertyChange(PropertyChangeEvent e) { | |||||
| String propertyName = e.getPropertyName(); | |||||
| if (propertyName.equals(AccessibleState.CHECKED.toString())) { | |||||
| Boolean newValue = (Boolean) e.getNewValue(); | |||||
| _target.setSelected(newValue.booleanValue()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,369 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import javax.swing.*; | |||||
| import javax.accessibility.*; | |||||
| import java.net.URL; | |||||
| import java.awt.event.ActionEvent; | |||||
| import java.awt.event.ActionListener; | |||||
| import java.beans.*; | |||||
| import java.util.*; | |||||
| import org.apache.tools.ant.gui.event.EventBus; | |||||
| /** | |||||
| * Class representing an action in the Antidote application. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class AntAction extends AbstractAction { | |||||
| /** Property name for the parent menu item. */ | |||||
| public static final String PARENT_MENU_NAME = "parentMenuName"; | |||||
| public static final String SEPARATOR = "separator"; | |||||
| public static final String POPUP_SEPARATOR = "popupSeparator"; | |||||
| public static final String ACCELERATOR = "accelerator"; | |||||
| public static final String ENABLED = "enabled"; | |||||
| public static final String ENABLE_ON = "enableOn"; | |||||
| public static final String DISABLE_ON = "disableOn"; | |||||
| public static final String TOGGLE = "toggle"; | |||||
| public static final String CHECKED_TRUE_ON = "checkedTrueOn"; | |||||
| public static final String CHECKED_FALSE_ON = "checkedFalseOn"; | |||||
| public static final String COMMAND = "command"; | |||||
| public static final String HIDDEN = "hidden"; | |||||
| /** Property resources. */ | |||||
| private ResourceManager _resources = null; | |||||
| /** Event bus. */ | |||||
| private EventBus _bus = null; | |||||
| /** Unique id. */ | |||||
| private String _id = null; | |||||
| /** Events that the action should cause transition to the | |||||
| * enabled(true) state. */ | |||||
| private Class[] _enableOn = null; | |||||
| /** Events that the action should cause transition to the | |||||
| * enabled(false) state. */ | |||||
| private Class[] _disableOn = null; | |||||
| /** Events that the action should cause transition to the | |||||
| * checked state. */ | |||||
| private Class[] _checkedTrueOn = null; | |||||
| /** Events that the action should cause transition to the | |||||
| * not checked state. */ | |||||
| private Class[] _checkedFalseOn = null; | |||||
| /** Flag indicating toggle action. */ | |||||
| private boolean _toggle = false; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param id Unique id for the action | |||||
| */ | |||||
| public AntAction(ResourceManager resources, EventBus bus, String id) { | |||||
| _resources = resources; | |||||
| _bus = bus; | |||||
| _id = id; | |||||
| putValue(NAME, getString("name")); | |||||
| putValue(SHORT_DESCRIPTION, getString("shortDescription")); | |||||
| putValue(PARENT_MENU_NAME, getString(PARENT_MENU_NAME)); | |||||
| putValue(SEPARATOR, getString(SEPARATOR)); | |||||
| putValue(POPUP_SEPARATOR, getString(POPUP_SEPARATOR)); | |||||
| putValue(HIDDEN, getString(HIDDEN)); | |||||
| // Set the default enabled state. | |||||
| String enabled = getString(ENABLED); | |||||
| if(enabled != null) { | |||||
| setEnabled(Boolean.valueOf(enabled).booleanValue()); | |||||
| } | |||||
| // Set an accellerator if any. | |||||
| String accelerator = getString(ACCELERATOR); | |||||
| if(accelerator != null) { | |||||
| putValue(ACCELERATOR, KeyStroke.getKeyStroke(accelerator)); | |||||
| } | |||||
| // Check to see if action is a toggle action. | |||||
| String toggle = getString(TOGGLE); | |||||
| if(toggle != null) { | |||||
| _toggle = Boolean.valueOf(toggle).booleanValue(); | |||||
| } | |||||
| // See if there is a command associated with the action. | |||||
| String command = getString(COMMAND); | |||||
| if(command != null) { | |||||
| try { | |||||
| Class cmd = Class.forName(command); | |||||
| putValue(COMMAND, cmd); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| // XXX log me. | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| // Add an icon if any (which means it'll show up on the tool bar). | |||||
| String iconName = getString("icon"); | |||||
| if(iconName != null) { | |||||
| putValue(SMALL_ICON, _resources.loadImageIcon(iconName)); | |||||
| } | |||||
| _enableOn = resolveClasses(getString(ENABLE_ON)); | |||||
| _disableOn = resolveClasses(getString(DISABLE_ON)); | |||||
| _checkedTrueOn = resolveClasses(getString(CHECKED_TRUE_ON)); | |||||
| _checkedFalseOn = resolveClasses(getString(CHECKED_FALSE_ON)); | |||||
| } | |||||
| /** | |||||
| * Convenience method for looking put a resource with the name | |||||
| * "id.key". Will return null if the resource doesn't exist. | |||||
| * | |||||
| * @param key Key name for the action. | |||||
| * @return String resource for composite key, or null if not found. | |||||
| */ | |||||
| private String getString(String key) { | |||||
| String retval = null; | |||||
| try { | |||||
| retval = _resources.getString(_id + "." + key); | |||||
| } | |||||
| catch(MissingResourceException ex) { | |||||
| // Its ok to be missing a resource name... | |||||
| // Too bad the API throws an exception in this case. | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Parse out the list of classes from the given string and | |||||
| * resolve them into classes. | |||||
| * | |||||
| * @param classNames Comma delimited list of class names. | |||||
| */ | |||||
| private Class[] resolveClasses(String classNames) { | |||||
| if(classNames == null) return null; | |||||
| StringTokenizer tok = new StringTokenizer(classNames, ", "); | |||||
| Vector vals = new Vector(); | |||||
| while(tok.hasMoreTokens()) { | |||||
| String name = tok.nextToken(); | |||||
| try { | |||||
| vals.addElement(Class.forName(name)); | |||||
| } | |||||
| catch(ClassNotFoundException ex) { | |||||
| //XXX log me. | |||||
| System.err.println( | |||||
| "Warning: the event class " + name + | |||||
| " was not found. Please check config file."); | |||||
| } | |||||
| } | |||||
| Class[] retval = new Class[vals.size()]; | |||||
| vals.copyInto(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Unique id for the action. | |||||
| * | |||||
| * @return Action id. | |||||
| */ | |||||
| public String getID() { | |||||
| return _id; | |||||
| } | |||||
| /** | |||||
| * Get the name of the menu in the menu bar that this action shoul | |||||
| * appear under. | |||||
| * | |||||
| * @return Menu to appear under, or null if not a menu action. | |||||
| */ | |||||
| public String getParentMenuName() { | |||||
| return (String) getValue(PARENT_MENU_NAME); | |||||
| } | |||||
| /** | |||||
| * Get the localized name for the action. | |||||
| * | |||||
| * @return Name | |||||
| */ | |||||
| public String getName() { | |||||
| return (String) getValue(NAME); | |||||
| } | |||||
| /** | |||||
| * Get the short description. Used in tool tips. | |||||
| * | |||||
| * @return Short description. | |||||
| */ | |||||
| public String getShortDescription() { | |||||
| return (String) getValue(SHORT_DESCRIPTION); | |||||
| } | |||||
| /** | |||||
| * Determine if a separator should appear before the action. | |||||
| * | |||||
| * @return True if add separator, false otherwise. | |||||
| */ | |||||
| public boolean isPreceededBySeparator() { | |||||
| return Boolean.valueOf( | |||||
| String.valueOf(getValue(SEPARATOR))).booleanValue(); | |||||
| } | |||||
| /** | |||||
| * Get the icon. | |||||
| * | |||||
| * @return Icon for action, or null if none. | |||||
| */ | |||||
| public Icon getIcon() { | |||||
| return (Icon) getValue(SMALL_ICON); | |||||
| } | |||||
| /** | |||||
| * Determine if a separator should appear before the action | |||||
| * when the popup menu is created. | |||||
| * | |||||
| * @return True if add separator, false otherwise. | |||||
| */ | |||||
| public boolean isPopupPreceededBySeparator() { | |||||
| return Boolean.valueOf( | |||||
| String.valueOf(getValue(POPUP_SEPARATOR))).booleanValue(); | |||||
| } | |||||
| /** | |||||
| * Determine if the action is hidden and should not | |||||
| * be displayed from a button. | |||||
| * | |||||
| * @return True the action is hidden. | |||||
| */ | |||||
| public boolean isHidden() { | |||||
| return Boolean.valueOf( | |||||
| String.valueOf(getValue(HIDDEN))).booleanValue(); | |||||
| } | |||||
| /** | |||||
| * Get the accelerator keystroke. | |||||
| * | |||||
| * @return Accelerator | |||||
| */ | |||||
| public KeyStroke getAccelerator() { | |||||
| return (KeyStroke) getValue(ACCELERATOR); | |||||
| } | |||||
| /** | |||||
| * Get the event types which should cause this to go to the | |||||
| * enabled state. | |||||
| * | |||||
| */ | |||||
| public Class[] getEnableOnEvents() { | |||||
| return _enableOn; | |||||
| } | |||||
| /** | |||||
| * Get the event types which should cause this to go to | |||||
| * this disabled state. | |||||
| * | |||||
| */ | |||||
| public Class[] getDisableOnEvents() { | |||||
| return _disableOn; | |||||
| } | |||||
| /** | |||||
| * Get the event types which should cause this to go to the | |||||
| * checked state. | |||||
| */ | |||||
| public Class[] getCheckedTrueOnEvents() { | |||||
| return _checkedTrueOn; | |||||
| } | |||||
| /** | |||||
| * Get the event types which should cause this to go to the | |||||
| * not checked state. | |||||
| */ | |||||
| public Class[] getCheckedFalseOnEvents() { | |||||
| return _checkedFalseOn; | |||||
| } | |||||
| /** | |||||
| * True if this is a toggle action, false otherwise. | |||||
| * | |||||
| * @return True if this is a toggle action, false otherwise. | |||||
| */ | |||||
| public boolean isToggle() { | |||||
| return _toggle; | |||||
| } | |||||
| /** | |||||
| * Get the assciated command class. | |||||
| * | |||||
| * @return Command class. | |||||
| */ | |||||
| public Class getCommandClass() { | |||||
| return (Class) getValue(COMMAND); | |||||
| } | |||||
| /** | |||||
| * Pass the action on to the EventBus. | |||||
| * | |||||
| * @param e Event to forward. | |||||
| */ | |||||
| public void actionPerformed(ActionEvent e) { | |||||
| _bus.postEvent(e); | |||||
| } | |||||
| } | |||||
| @@ -1,122 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import javax.swing.JComponent; | |||||
| import javax.swing.BorderFactory; | |||||
| /** | |||||
| * Abstract base class for a "module", which is really anything that | |||||
| * can send or receive events, or edit or view the model. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public abstract class AntModule extends JComponent { | |||||
| /** The application context. */ | |||||
| private AppContext _context = null; | |||||
| /** | |||||
| * Default constructor. | |||||
| */ | |||||
| protected AntModule() { | |||||
| // Create a dummy border so that the widget will at least have a | |||||
| // minimal display in a bean environment. | |||||
| setBorder(BorderFactory.createTitledBorder(getClass().getName())); | |||||
| } | |||||
| /** | |||||
| * This method is called after instantiation when the application context | |||||
| * is available for constructing the class' display. Think of this in | |||||
| * a similar manner to Applet.init() or Servlet.init(). It should | |||||
| * immediately call #setContext() with the given parameter. | |||||
| * | |||||
| * @param context Valid application context providing | |||||
| * all required resources. | |||||
| */ | |||||
| public abstract void contextualize(AppContext context); | |||||
| /** | |||||
| * Set the application context. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| protected void setContext(AppContext context) { | |||||
| _context = context; | |||||
| setBorder(_context == null ? null : | |||||
| BorderFactory.createTitledBorder(getName())); | |||||
| } | |||||
| /** | |||||
| * Get the application context. | |||||
| * | |||||
| * @return Application context. | |||||
| */ | |||||
| public AppContext getContext() { | |||||
| if(_context == null) { | |||||
| throw new IllegalStateException( | |||||
| "The AppContext has not been set."); | |||||
| } | |||||
| return _context; | |||||
| } | |||||
| /** | |||||
| * Get the name of the editor. | |||||
| * | |||||
| * @return Editor's name. | |||||
| */ | |||||
| public String getName() { | |||||
| return getContext().getResources().getString(getClass(), "name"); | |||||
| } | |||||
| } | |||||
| @@ -1,164 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.BuildListener; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| import org.apache.tools.ant.gui.acs.ACSTargetElement; | |||||
| import java.awt.Frame; | |||||
| import java.util.*; | |||||
| /** | |||||
| * A container for the state information for the application. Provides | |||||
| * a centeralized place to gain access to resources and data. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class AppContext { | |||||
| /** Event bus. */ | |||||
| private EventBus _eventBus = new EventBus(); | |||||
| /** Application resources. */ | |||||
| private ResourceManager _resources = new ResourceManager(); | |||||
| /** The project manager. */ | |||||
| private ProjectManager _projectManager = new ProjectManager(); | |||||
| /** Thing that keeps track of the current selection state. */ | |||||
| private SelectionManager _selectionManager = new SelectionManager(); | |||||
| /** Application actions. */ | |||||
| private ActionManager _actions = | |||||
| new ActionManager(_eventBus, new ResourceManager( | |||||
| "org.apache.tools.ant.gui.resources.action")); | |||||
| /** Parent frame used in various operations. XXX what do we do | |||||
| * in the applet context. */ | |||||
| private Frame _parentFrame = null; | |||||
| /** | |||||
| * Constructor of apps that don't have a graphical | |||||
| * component (e.g. web based). | |||||
| * | |||||
| */ | |||||
| public AppContext() { | |||||
| this(null); | |||||
| } | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param parent Parent frame. XXX may go away. | |||||
| */ | |||||
| public AppContext(Frame parent) { | |||||
| _parentFrame = parent; | |||||
| BuildEventForwarder handler = new BuildEventForwarder(this); | |||||
| _projectManager.addBuildListener(handler); | |||||
| _eventBus.addMember(EventBus.MONITORING, _selectionManager); | |||||
| } | |||||
| /** | |||||
| * Get the parent frame. XXX may change... | |||||
| * | |||||
| * @return Parent frame. | |||||
| */ | |||||
| public Frame getParentFrame() { | |||||
| return _parentFrame; | |||||
| } | |||||
| /** | |||||
| * Get the localized resources. | |||||
| * | |||||
| * @return Resources. | |||||
| */ | |||||
| public ResourceManager getResources() { | |||||
| return _resources; | |||||
| } | |||||
| /** | |||||
| * Get the action manager. | |||||
| * | |||||
| * @return Action manager. | |||||
| */ | |||||
| public ActionManager getActions() { | |||||
| return _actions; | |||||
| } | |||||
| /** | |||||
| * Get the event bus. | |||||
| * | |||||
| * @return EventBus. | |||||
| */ | |||||
| public EventBus getEventBus() { | |||||
| return _eventBus; | |||||
| } | |||||
| /** | |||||
| * Get the project manager. | |||||
| * | |||||
| * @return Project manager. | |||||
| */ | |||||
| public ProjectManager getProjectManager() { | |||||
| return _projectManager; | |||||
| } | |||||
| /** | |||||
| * Get the selection manager. | |||||
| * | |||||
| * @return Selection manager. | |||||
| */ | |||||
| public SelectionManager getSelectionManager() { | |||||
| return _selectionManager; | |||||
| } | |||||
| } | |||||
| @@ -1,158 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import org.apache.tools.ant.BuildListener; | |||||
| import org.apache.tools.ant.BuildEvent; | |||||
| /** | |||||
| * BuildListener for forwarding events to the EventBus. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class BuildEventForwarder implements BuildListener { | |||||
| /** Application context. */ | |||||
| private AppContext _context = null; | |||||
| public BuildEventForwarder(AppContext context) { | |||||
| _context = context; | |||||
| } | |||||
| /** | |||||
| * Fired before any targets are started. | |||||
| */ | |||||
| public void buildStarted(BuildEvent event){ | |||||
| postEvent(event, BuildEventType.BUILD_STARTED); | |||||
| // We doubly post this event. | |||||
| _context.getEventBus().postEvent( | |||||
| new BuildStartedEvent(_context, event)); | |||||
| } | |||||
| /** | |||||
| * Fired after the last target has finished. This event | |||||
| * will still be thrown if an error occured during the build. | |||||
| * | |||||
| * @see BuildEvent#getException() | |||||
| */ | |||||
| public void buildFinished(BuildEvent event) { | |||||
| postEvent(event, BuildEventType.BUILD_FINISHED); | |||||
| // We doubly post this event. | |||||
| _context.getEventBus().postEvent( | |||||
| new BuildFinishedEvent(_context, event)); | |||||
| } | |||||
| /** | |||||
| * Fired when a target is started. | |||||
| * | |||||
| * @see BuildEvent#getTarget() | |||||
| */ | |||||
| public void targetStarted(BuildEvent event) { | |||||
| postEvent(event, BuildEventType.TARGET_STARTED); | |||||
| } | |||||
| /** | |||||
| * Fired when a target has finished. This event will | |||||
| * still be thrown if an error occured during the build. | |||||
| * | |||||
| * @see BuildEvent#getException() | |||||
| */ | |||||
| public void targetFinished(BuildEvent event) { | |||||
| postEvent(event, BuildEventType.TARGET_FINISHED); | |||||
| } | |||||
| /** | |||||
| * Fired when a task is started. | |||||
| * | |||||
| * @see BuildEvent#getTask() | |||||
| */ | |||||
| public void taskStarted(BuildEvent event) { | |||||
| postEvent(event, BuildEventType.TASK_STARTED); | |||||
| } | |||||
| /** | |||||
| * Fired when a task has finished. This event will still | |||||
| * be throw if an error occured during the build. | |||||
| * | |||||
| * @see BuildEvent#getException() | |||||
| */ | |||||
| public void taskFinished(BuildEvent event) { | |||||
| postEvent(event, BuildEventType.TASK_FINISHED); | |||||
| } | |||||
| /** | |||||
| * Fired whenever a message is logged. | |||||
| * | |||||
| * @see BuildEvent#getMessage() | |||||
| * @see BuildEvent#getPriority() | |||||
| */ | |||||
| public void messageLogged(BuildEvent event) { | |||||
| postEvent(event, BuildEventType.MESSAGE_LOGGED); | |||||
| } | |||||
| /** | |||||
| * Forward the event. | |||||
| * | |||||
| * @param event Event to forward. | |||||
| * @param type Description of how the event came in. | |||||
| */ | |||||
| private void postEvent(BuildEvent event, BuildEventType type) { | |||||
| _context.getEventBus().postEvent( | |||||
| new AntBuildEvent(_context, event, type)); | |||||
| } | |||||
| } | |||||
| @@ -1,106 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.gui.event.BusMember; | |||||
| import org.apache.tools.ant.gui.event.BusFilter; | |||||
| import java.util.EventObject; | |||||
| /** | |||||
| * Class that prints all events to stderr. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class EventDebugMonitor implements BusMember { | |||||
| /** Filter for all events. */ | |||||
| private final Filter _filter = new Filter(); | |||||
| /** | |||||
| * Defatult ctor. | |||||
| * | |||||
| */ | |||||
| public EventDebugMonitor() { | |||||
| } | |||||
| /** | |||||
| * Get the filter to that is used to determine if an event should | |||||
| * to to the member. | |||||
| * | |||||
| * @return Filter to use. | |||||
| */ | |||||
| public BusFilter getBusFilter() { | |||||
| return _filter; | |||||
| } | |||||
| /** | |||||
| * Called when an event is to be posed to the member. | |||||
| * | |||||
| * @param event Event to post. | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event) { | |||||
| System.err.println(event); | |||||
| return true; | |||||
| } | |||||
| /** Filter for all events. */ | |||||
| private static class Filter implements BusFilter { | |||||
| public boolean accept(EventObject event) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,178 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import org.apache.tools.ant.gui.command.*; | |||||
| import java.util.EventObject; | |||||
| import java.awt.event.ActionEvent; | |||||
| import javax.swing.*; | |||||
| /** | |||||
| * The purpose of this class is to watch for events that require some sort | |||||
| * of action, like opening a file. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class EventResponder { | |||||
| /** The application context. */ | |||||
| private AppContext _context = null; | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public EventResponder(AppContext context) { | |||||
| _context = context; | |||||
| // XXX This needs to be changed, along with the event bus, | |||||
| // to allow the EventResponder to be the last listener | |||||
| // to receive the event. This will allow the addition | |||||
| // of event filters to yank an event out of the bus, sort of | |||||
| // like an interrupt level. | |||||
| _context.getEventBus().addMember( | |||||
| EventBus.RESPONDING, new ActionResponder()); | |||||
| _context.getEventBus().addMember( | |||||
| EventBus.RESPONDING, new AntResponder()); | |||||
| } | |||||
| /** Handler for bus events. */ | |||||
| private class ActionResponder implements BusMember { | |||||
| private final ActionFilter _filter = new ActionFilter(); | |||||
| /** | |||||
| * Get the filter to that is used to determine if an event should | |||||
| * to to the member. | |||||
| * | |||||
| * @return Filter to use. | |||||
| */ | |||||
| public BusFilter getBusFilter() { | |||||
| return _filter; | |||||
| } | |||||
| /** | |||||
| * Called when an event is to be posed to the member. | |||||
| * | |||||
| * @param event Event to post. | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event) { | |||||
| String command = ((ActionEvent)event).getActionCommand(); | |||||
| Command cmd = | |||||
| _context.getActions().getActionCommand(command, _context, event); | |||||
| if(cmd != null) { | |||||
| cmd.run(); | |||||
| return false; | |||||
| } | |||||
| else { | |||||
| // XXX log me. | |||||
| System.err.println("Unhandled action: " + command); | |||||
| // XXX temporary. | |||||
| new DisplayErrorCmd( | |||||
| _context, | |||||
| "Sorry. \"" + command + | |||||
| "\" not implemented yet. Care to help out?").run(); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| } | |||||
| /** Filter for action events. */ | |||||
| private static class ActionFilter implements BusFilter { | |||||
| public boolean accept(EventObject event) { | |||||
| return event instanceof ActionEvent; | |||||
| } | |||||
| } | |||||
| /** Handler for bus events. */ | |||||
| private class AntResponder implements BusMember { | |||||
| private final AntFilter _filter = new AntFilter(); | |||||
| /** | |||||
| * Get the filter to that is used to determine if an event should | |||||
| * to to the member. | |||||
| * | |||||
| * @return Filter to use. | |||||
| */ | |||||
| public BusFilter getBusFilter() { | |||||
| return _filter; | |||||
| } | |||||
| /** | |||||
| * Called when an event is to be posed to the member. | |||||
| * | |||||
| * @param event Event to post. | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event) { | |||||
| AntEvent e = (AntEvent) event; | |||||
| Command cmd = e.createDefaultCmd(); | |||||
| cmd.run(); | |||||
| return cmd instanceof NoOpCmd; | |||||
| } | |||||
| } | |||||
| /** Filter for ant events. */ | |||||
| private static class AntFilter implements BusFilter { | |||||
| public boolean accept(EventObject event) { | |||||
| return event instanceof AntEvent; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,177 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import java.util.*; | |||||
| import javax.accessibility.AccessibleState; | |||||
| /** | |||||
| * The purpose of this class is to manage the | |||||
| * mappings between event type and action enabled state. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| class EventToActionMapper { | |||||
| /** Lookup for enable(true) events. Key is event type, value is | |||||
| * a list of actions that are changed by the event. */ | |||||
| private Map _enableOn = new HashMap(); | |||||
| /** Lookup for enable(false) events. Key is event type, value is | |||||
| * a list of actions that are changed by the event. */ | |||||
| private Map _disableOn = new HashMap(); | |||||
| /** Lookup for CHECK(true) events. Key is event type, value is | |||||
| * a list of actions that are changed by the event. */ | |||||
| private Map _checkedTrueOn = new HashMap(); | |||||
| /** Lookup for CHECK(false) events. Key is event type, value is | |||||
| * a list of actions that are changed by the event. */ | |||||
| private Map _checkedFalseOn = new HashMap(); | |||||
| /** | |||||
| * Defaul ctor. | |||||
| * | |||||
| */ | |||||
| public EventToActionMapper() { | |||||
| } | |||||
| /** | |||||
| * Add an action. | |||||
| * | |||||
| * @param action Action to add. | |||||
| */ | |||||
| public void addAction(AntAction action) { | |||||
| putAction(action, action.getEnableOnEvents(), _enableOn); | |||||
| putAction(action, action.getDisableOnEvents(), _disableOn); | |||||
| putAction(action, action.getCheckedTrueOnEvents(), _checkedTrueOn); | |||||
| putAction(action, action.getCheckedFalseOnEvents(), _checkedFalseOn); | |||||
| } | |||||
| /** | |||||
| * For the given action store it in the event type mapping | |||||
| * for each of the given types. | |||||
| * | |||||
| * @param action Action to store. | |||||
| * @param clazzes Array of types to store it under. | |||||
| * @param storage The place to store the association. | |||||
| */ | |||||
| private void putAction(AntAction action, Class[] clazzes, Map storage) { | |||||
| if(clazzes == null) return; | |||||
| for(int i = 0; i < clazzes.length; i++) { | |||||
| List values = (List) storage.get(clazzes[i]); | |||||
| if(values == null) { | |||||
| values = new ArrayList(1); | |||||
| storage.put(clazzes[i], values); | |||||
| } | |||||
| values.add(action); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * For the given event change the state of any actions that | |||||
| * have been registered as needing a transition as a result of | |||||
| * the event. | |||||
| * | |||||
| * @param event The event to apply. | |||||
| */ | |||||
| public void applyEvent(EventObject event) { | |||||
| if(event == null) return; | |||||
| List vals = null; | |||||
| vals = (List) _enableOn.get(event.getClass()); | |||||
| changeState(vals, true); | |||||
| vals = (List) _disableOn.get(event.getClass()); | |||||
| changeState(vals, false); | |||||
| vals = (List) _checkedTrueOn.get(event.getClass()); | |||||
| changeChecked(vals, true); | |||||
| vals = (List) _checkedFalseOn.get(event.getClass()); | |||||
| changeChecked(vals, false); | |||||
| } | |||||
| /** | |||||
| * Set the enabled state of the given actions. | |||||
| * | |||||
| * @param actions List of AntActions to set state for. | |||||
| * @param state The state to set them to. | |||||
| */ | |||||
| private void changeState(List actions, boolean state) { | |||||
| if(actions == null) return; | |||||
| for(int i = 0, len = actions.size(); i < len; i++) { | |||||
| AntAction action = (AntAction) actions.get(i); | |||||
| action.setEnabled(state); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Set the CHECKED property of the given actions. | |||||
| * | |||||
| * @param actions List of AntActions to set checked properties for. | |||||
| * @param checked The checked value to set them to. | |||||
| */ | |||||
| private void changeChecked(List actions, boolean checked) { | |||||
| if(actions == null) return; | |||||
| for(int i = 0, len = actions.size(); i < len; i++) { | |||||
| AntAction action = (AntAction) actions.get(i); | |||||
| action.putValue(AccessibleState.CHECKED.toString(), | |||||
| new Boolean(checked)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,384 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.BuildListener; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| import org.apache.tools.ant.BuildEvent; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| import org.apache.tools.ant.gui.event.BuildEventType; | |||||
| import java.io.*; | |||||
| import java.net.URL; | |||||
| import java.net.URLConnection; | |||||
| import java.util.*; | |||||
| /** | |||||
| * This class is responsible for managing the currently open projects, | |||||
| * and the loading of new projects. | |||||
| * | |||||
| * XXX need to add property change listeners support. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ProjectManager { | |||||
| /** Set of open projects. */ | |||||
| private List _projects = new ArrayList(1); | |||||
| /** List of build listeners to register when build starts. */ | |||||
| private List _buildListeners = new LinkedList(); | |||||
| /** The current thread executing a build. */ | |||||
| private Thread _buildThread = null; | |||||
| public ProjectManager() { | |||||
| } | |||||
| /** | |||||
| * Get all the open projects. | |||||
| * | |||||
| * @return an array of all open projects. | |||||
| */ | |||||
| public ACSProjectElement[] getOpen() { | |||||
| ACSProjectElement[] retval = new ACSProjectElement[_projects.size()]; | |||||
| _projects.toArray(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Save the given project. | |||||
| * | |||||
| * @param project Project to save. | |||||
| */ | |||||
| public void save(ACSProjectElement project) throws IOException { | |||||
| saveAs(project, null); | |||||
| } | |||||
| /** | |||||
| * Save the given project to the given location. | |||||
| * | |||||
| * @param project Project to save. | |||||
| * @param location Location to save to. | |||||
| */ | |||||
| public void saveAs(ACSProjectElement project, URL location) | |||||
| throws IOException { | |||||
| if(location == null) { | |||||
| location = project.getLocation(); | |||||
| } | |||||
| if(location == null) { | |||||
| // This shouldn't happen. | |||||
| throw new IOException("Logic error: Save location mising."); | |||||
| } | |||||
| Writer out = null; | |||||
| try { | |||||
| // XXX for some reason the URLConnection for protocol type "file" | |||||
| // doesn't support output (at least that is what the exception | |||||
| // says. I don't know if I'm doing something wrong or not, but | |||||
| // since we need to handle files differently (which is fine | |||||
| // right now since files are all we really support anyway. | |||||
| if(location.getProtocol().equals("file")) { | |||||
| out = new FileWriter(location.getFile()); | |||||
| } | |||||
| else { | |||||
| // XXX This is here for future support of FTP/HTTP and | |||||
| // the like. JDBC will have to be dealt with differently. | |||||
| URLConnection connection = location.openConnection(); | |||||
| connection.setDoInput(false); | |||||
| connection.setDoOutput(true); | |||||
| out = new OutputStreamWriter(connection.getOutputStream()); | |||||
| } | |||||
| // Persist the project. | |||||
| project.write(out); | |||||
| out.flush(); | |||||
| project.setLocation(location); | |||||
| } | |||||
| finally { | |||||
| try { out.close(); } catch(Exception ex) {} | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Open the project persisted at the given location | |||||
| * | |||||
| * @param location Location of project file. | |||||
| * @return Successfully loaded project. | |||||
| * @throws IOException thrown if there is a problem opening the project. | |||||
| */ | |||||
| public ACSProjectElement open(File location) throws IOException { | |||||
| return open(new URL("file", null, location.getPath())); | |||||
| } | |||||
| /** | |||||
| * Open the project persisted at the given location | |||||
| * | |||||
| * @param location Location of project file. | |||||
| * @return Successfully loaded project. | |||||
| * @throws IOException thrown if there is a problem opening the project. | |||||
| */ | |||||
| public ACSProjectElement open(URL location) throws IOException { | |||||
| ACSProjectElement retval = null; | |||||
| retval = ACSFactory.getInstance().load(location); | |||||
| retval.setLocation(location); | |||||
| _projects.add(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Create a new, unpopulated project. | |||||
| * | |||||
| * @return Unpopulated project. | |||||
| */ | |||||
| public ACSProjectElement createNew() { | |||||
| ACSProjectElement retval = ACSFactory.getInstance().createProject(); | |||||
| _projects.add(retval); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Remove the given project from the set of active projects. | |||||
| * | |||||
| * @param project Project to close. | |||||
| */ | |||||
| public void close(ACSProjectElement project) { | |||||
| _projects.remove(project); | |||||
| } | |||||
| /** | |||||
| * Build the project with the given target (or the default target | |||||
| * if none is selected. Build occurs on a separate thread, so method | |||||
| * returns immediately. | |||||
| * | |||||
| * @param project Project to build. | |||||
| * @param targets Targets to build in project. | |||||
| */ | |||||
| public void build(ACSProjectElement project, ACSTargetElement[] targets) | |||||
| throws BuildException { | |||||
| _buildThread = new Thread(new BuildRunner(project, targets)); | |||||
| _buildThread.start(); | |||||
| } | |||||
| /** | |||||
| * Add a build listener. | |||||
| * | |||||
| * @param l Listener to add. | |||||
| */ | |||||
| public void addBuildListener(BuildListener l) { | |||||
| synchronized(_buildListeners) { | |||||
| _buildListeners.add(l); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Remove a build listener. | |||||
| * | |||||
| * @param l Listener to remove. | |||||
| */ | |||||
| public void removeBuildListener(BuildListener l) { | |||||
| synchronized(_buildListeners) { | |||||
| _buildListeners.remove(l); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Determine if the given BuildListener is registered. | |||||
| * | |||||
| * @param l Listener to test for. | |||||
| * @return True if listener has been added, false if unknown. | |||||
| */ | |||||
| public boolean isRegisteredBuildListener(BuildListener l) { | |||||
| synchronized(_buildListeners) { | |||||
| return _buildListeners.contains(l); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the set of current build listeners. | |||||
| * | |||||
| * @return Set of current build listeners. | |||||
| */ | |||||
| public BuildListener[] getBuildListeners() { | |||||
| synchronized(_buildListeners) { | |||||
| BuildListener[] retval = new BuildListener[_buildListeners.size()]; | |||||
| _buildListeners.toArray(retval); | |||||
| return retval; | |||||
| } | |||||
| } | |||||
| /** Class for executing the build in a separate thread. */ | |||||
| private class BuildRunner implements Runnable { | |||||
| /** The project to execute build on. */ | |||||
| private ACSProjectElement _project = null; | |||||
| /** Targets to build. */ | |||||
| private ACSTargetElement[] _targets = null; | |||||
| /** The Ant core representation of a project. */ | |||||
| private Project _antProject = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param project Project to execute build on. | |||||
| * @param targets Targets to build. | |||||
| */ | |||||
| public BuildRunner(ACSProjectElement project, | |||||
| ACSTargetElement[] targets) throws BuildException { | |||||
| _project = project; | |||||
| _targets = targets; | |||||
| URL location = _project.getLocation(); | |||||
| if(location == null) { | |||||
| // XXX this needs to be changed so that if the project is | |||||
| // not saved, or the persistence mechanism is remote | |||||
| // then a temporary version is saved first. | |||||
| throw new BuildException("Project must be saved first"); | |||||
| } | |||||
| // XXX hopefully we will eventually be able to save | |||||
| // project files to any type of URL. Right now the Ant core | |||||
| // only supports Files. | |||||
| if(!location.getProtocol().equals("file")) { | |||||
| throw new IllegalArgumentException( | |||||
| "The Ant core only supports building from locally " + | |||||
| "stored build files."); | |||||
| } | |||||
| File f = new File(location.getFile()); | |||||
| _antProject = new Project(); | |||||
| _antProject.init(); | |||||
| // XXX there is a bunch of stuff in the class | |||||
| // org.apache.tools.ant.Main that needs to be | |||||
| // refactored out so that it doesn't have to be | |||||
| // replicated here. | |||||
| // XXX need to provide a way to pass in externally | |||||
| // defined properties. Perhaps define an external | |||||
| // Antidote properties file. JAVA_HOME may have to be set, | |||||
| // as well as checking the .ant.properties | |||||
| _antProject.setUserProperty( | |||||
| "ant.file" , f.getAbsolutePath()); | |||||
| ProjectHelper.configureProject(_antProject, f); | |||||
| } | |||||
| /** | |||||
| * Convenience method for causeing the project to fire a build event. | |||||
| * Implemented because the corresponding method in the Project class | |||||
| * is not publically accessible. | |||||
| * | |||||
| * @param event Event to fire. | |||||
| */ | |||||
| private void fireBuildEvent(BuildEvent event, BuildEventType type) { | |||||
| Enumeration enum = _antProject.getBuildListeners().elements(); | |||||
| while(enum.hasMoreElements()) { | |||||
| BuildListener l = (BuildListener) enum.nextElement(); | |||||
| type.fireEvent(event, l); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Run the build. | |||||
| * | |||||
| */ | |||||
| public void run() { | |||||
| synchronized(_antProject) { | |||||
| // Add the build listeners | |||||
| BuildListener[] listeners = getBuildListeners(); | |||||
| for(int i = 0; i < listeners.length; i++) { | |||||
| _antProject.addBuildListener(listeners[i]); | |||||
| } | |||||
| try { | |||||
| fireBuildEvent(new BuildEvent( | |||||
| _antProject), BuildEventType.BUILD_STARTED); | |||||
| Vector targetNames = new Vector(); | |||||
| if(_targets == null || _targets.length == 0) { | |||||
| targetNames.add(_antProject.getDefaultTarget()); | |||||
| } | |||||
| else { | |||||
| for(int i = 0; i < _targets.length; i++) { | |||||
| targetNames.add(_targets[i].getName()); | |||||
| } | |||||
| } | |||||
| // Execute build on selected targets. XXX It would be | |||||
| // nice if the Project API supported passing in target | |||||
| // objects rather than String names. | |||||
| _antProject.executeTargets(targetNames); | |||||
| } | |||||
| catch(BuildException ex) { | |||||
| BuildEvent errorEvent = new BuildEvent(_antProject); | |||||
| errorEvent.setException(ex); | |||||
| errorEvent.setMessage(ex.getMessage(), Project.MSG_ERR); | |||||
| fireBuildEvent(errorEvent, BuildEventType.MESSAGE_LOGGED); | |||||
| } | |||||
| finally { | |||||
| fireBuildEvent(new BuildEvent( | |||||
| _antProject), BuildEventType.BUILD_FINISHED); | |||||
| // Remove the build listeners. | |||||
| for(int i = 0; i < listeners.length; i++) { | |||||
| _antProject.removeBuildListener(listeners[i]); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,177 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import org.apache.tools.ant.gui.acs.ACSProjectElement; | |||||
| import javax.swing.*; | |||||
| import java.awt.event.ActionEvent; | |||||
| import java.awt.event.ActionListener; | |||||
| import java.util.*; | |||||
| import java.beans.PropertyChangeEvent; | |||||
| /** | |||||
| * Specialization of JMenu providing selectability of the currently | |||||
| * open projects. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ProjectSelectionMenu extends JMenu { | |||||
| /** Application context. */ | |||||
| private AppContext _context = null; | |||||
| /** Current set of menus. */ | |||||
| private Map _menus = new HashMap(); | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context Application context. | |||||
| */ | |||||
| public ProjectSelectionMenu(AppContext context) { | |||||
| super(context.getResources().getString( | |||||
| ProjectSelectionMenu.class, "name"), true); | |||||
| _context = context; | |||||
| _context.getEventBus().addMember( | |||||
| EventBus.MONITORING, new ProjectListener()); | |||||
| setMnemonic(getText().charAt(0)); | |||||
| } | |||||
| /** | |||||
| * Replace or add the JMenu called "Projects" with this. | |||||
| * | |||||
| * @param menuBar Menu bar to insert into. | |||||
| */ | |||||
| public void insertInto(JMenuBar menuBar) { | |||||
| // Iterate of the menu items looking for the one with the same name | |||||
| // as ours. | |||||
| int count = menuBar.getComponentCount(); | |||||
| for(int i = 0; i < count; i++) { | |||||
| JMenuItem menu = (JMenuItem) menuBar.getComponent(i); | |||||
| if(menu.getText().equals(getText())) { | |||||
| menuBar.remove(menu); | |||||
| menuBar.add(this, i); | |||||
| return; | |||||
| } | |||||
| } | |||||
| // Getting here we didn't find a menu with the same name. | |||||
| add(this); | |||||
| } | |||||
| /** Listener for updating the contents of the menu. */ | |||||
| private class ProjectListener implements BusMember { | |||||
| /** Event filter. */ | |||||
| private final Filter _filter = new Filter(); | |||||
| /** Action handler. */ | |||||
| private final ActionHandler _handler = new ActionHandler(); | |||||
| /** | |||||
| * Get the filter to that is used to determine if an event should | |||||
| * to to the member. | |||||
| * | |||||
| * @return Filter to use. | |||||
| */ | |||||
| public BusFilter getBusFilter() { | |||||
| return _filter; | |||||
| } | |||||
| /** | |||||
| * Called when an event is to be posed to the member. | |||||
| * | |||||
| * @param event Event to post. | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event) { | |||||
| // Clear out our existing members | |||||
| removeAll(); | |||||
| _menus.clear(); | |||||
| ACSProjectElement[] projects = | |||||
| _context.getProjectManager().getOpen(); | |||||
| for(int i = 0; i < projects.length; i++) { | |||||
| JMenuItem menu = new JMenuItem(projects[i].getName()); | |||||
| menu.addActionListener(_handler); | |||||
| _menus.put(menu, projects[i]); | |||||
| add(menu); | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } | |||||
| /** Filter for project related events. */ | |||||
| private static class Filter implements BusFilter { | |||||
| public boolean accept(EventObject event) { | |||||
| // We want events related to projects. | |||||
| return event instanceof ProjectSelectedEvent || | |||||
| event instanceof ProjectClosedEvent || | |||||
| (event instanceof PropertyChangeEvent && | |||||
| ((PropertyChangeEvent)event).getSource() | |||||
| instanceof ACSProjectElement); | |||||
| } | |||||
| } | |||||
| /** Handler for selecting the project. */ | |||||
| private class ActionHandler implements ActionListener { | |||||
| public void actionPerformed(ActionEvent e) { | |||||
| ACSProjectElement project = | |||||
| (ACSProjectElement) _menus.get(e.getSource()); | |||||
| _context.getEventBus().postEvent( | |||||
| new ProjectSelectedEvent(_context, project)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,322 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import java.util.*; | |||||
| import java.text.MessageFormat; | |||||
| import javax.swing.ImageIcon; | |||||
| import java.net.URL; | |||||
| import java.io.File; | |||||
| /** | |||||
| * Singleton class for accessing various resources by the application. | |||||
| * Relies on the resource bundles for resource values. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon H.K. Fitch | |||||
| */ | |||||
| public class ResourceManager { | |||||
| /** Path to default resources. */ | |||||
| private static final String RESOURCE_PKG = | |||||
| "org.apache.tools.ant.gui.resources"; | |||||
| /** Path to default resources. */ | |||||
| private static final String DEF_PROPERTIES = | |||||
| RESOURCE_PKG + ".antidote"; | |||||
| /** Image path. */ | |||||
| private static final String IMG_PATH = | |||||
| '/' + RESOURCE_PKG.replace('.', '/'); | |||||
| /** Resources to reference. */ | |||||
| private ResourceBundle _resources = null; | |||||
| /** | |||||
| * Default ctor. Uses the default properties file for antidote. | |||||
| * | |||||
| */ | |||||
| public ResourceManager() { | |||||
| this(DEF_PROPERTIES); | |||||
| } | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param propName Fully qualified name of the resources to use. | |||||
| */ | |||||
| public ResourceManager(String propName) { | |||||
| _resources = ResourceBundle.getBundle(propName); | |||||
| } | |||||
| /** | |||||
| * Generate a composit key from the given class and key name. | |||||
| * | |||||
| * @param clazz Class to find resource for. | |||||
| * @param name Name of the resource. | |||||
| * @return Composite key. | |||||
| */ | |||||
| private String getKey(Class clazz, String name) { | |||||
| name = name == null ? "" : name; | |||||
| return clazz == null ? name : clazz.getName() + "." + name; | |||||
| } | |||||
| /** | |||||
| * Get non-qualified String resource. | |||||
| * | |||||
| * @param name Name of the resource. | |||||
| * @return Value of the resource. | |||||
| */ | |||||
| public String getString(String name) { | |||||
| return getString(null, name); | |||||
| } | |||||
| /** | |||||
| * Get a string resource for the given class. | |||||
| * | |||||
| * @param clazz Class to get resource for. | |||||
| * @param name Name of the string resource. | |||||
| * @return String resource for the given class. | |||||
| */ | |||||
| public String getString(Class clazz, String name) { | |||||
| if(name == null) { | |||||
| return null; | |||||
| } | |||||
| try { | |||||
| return _resources.getString(getKey(clazz, name)); | |||||
| } | |||||
| catch(MissingResourceException ex) { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get a non-qualified array of string resources for the given class. | |||||
| * | |||||
| * @param name Name of the string resource. | |||||
| * @return Array of string resources for the given class. | |||||
| */ | |||||
| public String[] getStringArray(String name) { | |||||
| return getStringArray(null, name); | |||||
| } | |||||
| /** | |||||
| * Get an array of string resources for the given class. | |||||
| * | |||||
| * @param clazz Class to get resource for. | |||||
| * @param name Name of the string resource. | |||||
| * @return Array of string resources for the given class. | |||||
| */ | |||||
| public String[] getStringArray(Class clazz, String name) { | |||||
| if(name == null) { | |||||
| return null; | |||||
| } | |||||
| String key = getKey(clazz, name); | |||||
| String toTok = null; | |||||
| try { | |||||
| toTok = _resources.getString(key); | |||||
| } | |||||
| catch(MissingResourceException ex) { | |||||
| // Ignore as we are doing a cascading lookup. | |||||
| } | |||||
| if(toTok == null) { | |||||
| try { | |||||
| return _resources.getStringArray(key); | |||||
| } | |||||
| catch(MissingResourceException ex) { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| else { | |||||
| StringTokenizer tok = new StringTokenizer(toTok, ", "); | |||||
| String[] retval = new String[tok.countTokens()]; | |||||
| for(int i = 0; i < retval.length; i++) { | |||||
| retval[i] = tok.nextToken(); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the boolean resource for the given name. Case | |||||
| * insensitive values of "yes" or "true" evaluate to TRUE. | |||||
| * All others, including undefined resources evaluate to FALSE. | |||||
| * | |||||
| * @param name Name of the boolean resource. | |||||
| * @return True if defined as true, false otherwise. | |||||
| */ | |||||
| public boolean getBoolean(String name) { | |||||
| return getBoolean(null, name); | |||||
| } | |||||
| /** | |||||
| * Get the boolean resource for the given class. Case | |||||
| * insensitive values of "yes" or "true" evaluate to TRUE. | |||||
| * All others, including undefined resources evaluate to FALSE. | |||||
| * | |||||
| * @param clazz Class to get resource for. | |||||
| * @param name Name of the boolean resource. | |||||
| * @return True if defined as true, false otherwise. | |||||
| */ | |||||
| public boolean getBoolean(Class clazz, String name) { | |||||
| if(name == null) { | |||||
| return false; | |||||
| } | |||||
| String key = getKey(clazz, name); | |||||
| String value = ""; | |||||
| try { | |||||
| value = _resources.getString(key); | |||||
| } | |||||
| catch(MissingResourceException ex) { | |||||
| return false; | |||||
| } | |||||
| return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"); | |||||
| } | |||||
| /** | |||||
| * Get the non-qualified Class type resource for the given key. | |||||
| * | |||||
| * @param name Name of the resourdce. | |||||
| * @return Class associated with the key name. | |||||
| */ | |||||
| public Class getClass(String name) | |||||
| throws ClassNotFoundException { | |||||
| return getClass(null, name); | |||||
| } | |||||
| /** | |||||
| * Get the Class type resource for the given class and key name. | |||||
| * | |||||
| * @param clazz Class requesting the resource. | |||||
| * @param name Name of the resource. | |||||
| * @return Class associated with the key name. | |||||
| */ | |||||
| public Class getClass(Class clazz, String name) | |||||
| throws ClassNotFoundException { | |||||
| String key = getKey(clazz, name); | |||||
| try { | |||||
| String value = _resources.getString(key); | |||||
| return Class.forName(value); | |||||
| } | |||||
| catch(MissingResourceException ex) { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Generate a localized message using the given set of arguments to | |||||
| * format the message with. | |||||
| * | |||||
| * @param name Name of the message. | |||||
| * @param arguments Arguments to the message. | |||||
| * @return The formatted message. | |||||
| */ | |||||
| public String getMessage(String name, Object[] arguments) { | |||||
| return getMessage(null, name, arguments); | |||||
| } | |||||
| /** | |||||
| * Generate a localized message using the given set of arguments to | |||||
| * format the message with. | |||||
| * | |||||
| * @param clazz Class to get message resource for. | |||||
| * @param name Name of the message. | |||||
| * @param arguments Arguments to the message. | |||||
| * @return The formatted message. | |||||
| */ | |||||
| public String getMessage(Class clazz, String name, Object[] arguments) { | |||||
| String format = getString(clazz, name); | |||||
| return MessageFormat.format(format, arguments); | |||||
| } | |||||
| /** | |||||
| * Get the image as an ImageIcon assigned to the given class with the | |||||
| * given key. | |||||
| * | |||||
| * @param clazz The class to load icon for. | |||||
| * @param key The key for looking up the icon. | |||||
| * @return Image as an ImageIcon, or null if not found. | |||||
| */ | |||||
| public ImageIcon getImageIcon(Class clazz, String key) { | |||||
| return loadImageIcon(getString(clazz, key)); | |||||
| } | |||||
| /** | |||||
| * Get the image as an ImageIcon with the given file name. | |||||
| * For example "open.gif". The image is loaded from the resources package. | |||||
| * | |||||
| * @param fileName Image file to load. | |||||
| * @return Image as an ImageIcon, or null if not found. | |||||
| */ | |||||
| public ImageIcon loadImageIcon(String fileName) { | |||||
| if(fileName == null) return null; | |||||
| ImageIcon icon = null; | |||||
| URL location = getClass().getResource(IMG_PATH + "/" + fileName); | |||||
| if(location != null) { | |||||
| icon = new ImageIcon(location); | |||||
| } | |||||
| return icon; | |||||
| } | |||||
| } | |||||
| @@ -1,147 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import org.apache.tools.ant.gui.event.*; | |||||
| import org.apache.tools.ant.gui.command.*; | |||||
| import org.apache.tools.ant.gui.acs.*; | |||||
| import java.util.EventObject; | |||||
| import java.awt.event.ActionEvent; | |||||
| import javax.swing.*; | |||||
| /** | |||||
| * State management class for keeping track of what build file elements are | |||||
| * currently selected. It monitors the EventBus for selection events and | |||||
| * Records the current state. It should be registered with the EventBus | |||||
| * at the MONITORING level. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class SelectionManager implements BusMember { | |||||
| /** The filter for getting the correct events.*/ | |||||
| private final Filter _filter = new Filter(); | |||||
| /** The currently selected project. */ | |||||
| private ACSProjectElement _project = null; | |||||
| /** The current set of selected targets. */ | |||||
| private ACSTargetElement[] _targets = null; | |||||
| /** The current set of selected elements. */ | |||||
| private ACSElement[] _elements = null; | |||||
| public SelectionManager() { | |||||
| } | |||||
| /** | |||||
| * Get the filter to that is used to determine if an event should | |||||
| * to to the member. | |||||
| * | |||||
| * @return Filter to use. | |||||
| */ | |||||
| public BusFilter getBusFilter() { | |||||
| return _filter; | |||||
| } | |||||
| /** | |||||
| * Get the currently selected project. | |||||
| * | |||||
| * @return Current project. | |||||
| */ | |||||
| public ACSProjectElement getSelectedProject() { | |||||
| return _project; | |||||
| } | |||||
| /** | |||||
| * Get the selected elements that are targets. | |||||
| * | |||||
| */ | |||||
| public ACSTargetElement[] getSelectedTargets() { | |||||
| return _targets; | |||||
| } | |||||
| /** | |||||
| * Get the selected elements. | |||||
| * | |||||
| */ | |||||
| public ACSElement[] getSelectedElements() { | |||||
| return _elements; | |||||
| } | |||||
| /** | |||||
| * Called when an event is to be posed to the member. | |||||
| * | |||||
| * @param event Event to post. | |||||
| * @return true if event should be propogated, false if | |||||
| * it should be cancelled. | |||||
| */ | |||||
| public boolean eventPosted(EventObject event) { | |||||
| _elements = ((ElementSelectionEvent)event).getSelectedElements(); | |||||
| if(event instanceof TargetSelectionEvent) { | |||||
| _targets = ((TargetSelectionEvent)event).getSelectedTargets(); | |||||
| } | |||||
| else if(event instanceof ProjectSelectedEvent) { | |||||
| _project = ((ProjectSelectedEvent)event).getSelectedProject(); | |||||
| } | |||||
| return true; | |||||
| } | |||||
| /** Filter for ElementSelectionEvent objects. */ | |||||
| private static class Filter implements BusFilter { | |||||
| public boolean accept(EventObject event) { | |||||
| return event instanceof ElementSelectionEvent; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,102 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.core; | |||||
| import javax.swing.filechooser.FileFilter; | |||||
| import java.io.File; | |||||
| /** | |||||
| * FileFilter for showing only XML files. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class XMLFileFilter extends FileFilter { | |||||
| /** Text description of filter. */ | |||||
| private String _description = null; | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param resources Access to text resources. | |||||
| */ | |||||
| public XMLFileFilter(ResourceManager resources) { | |||||
| _description = resources.getString(getClass(), "description"); | |||||
| } | |||||
| /** | |||||
| * Accept files that end with ".xml". | |||||
| * | |||||
| * @param f File to test. | |||||
| * @return True if accepted, false otherwise. | |||||
| */ | |||||
| public boolean accept(File f) { | |||||
| if(f.isDirectory()) return true; | |||||
| String name = f.getName().toLowerCase(); | |||||
| return name.endsWith(".xml"); | |||||
| } | |||||
| /** | |||||
| * Human readable description of filter. | |||||
| * | |||||
| * @return Description. | |||||
| */ | |||||
| public String getDescription() { | |||||
| return _description; | |||||
| } | |||||
| } | |||||
| @@ -1,28 +0,0 @@ | |||||
| #!/bin/sh | |||||
| # Wrapper script for launching Java files without having to type the | |||||
| # package prefix. To use make a link to this file with the same name | |||||
| # as the class you want to run. | |||||
| # Edit this line to represent the package that your class belongs to. | |||||
| PACKAGE=org.apache.tools.ant.gui.customizer | |||||
| # Set your application's classpath here. | |||||
| CLASSPATH=$HOME/build/antidote/classes:$HOME/build/ant/lib/ant.jar | |||||
| # Compose the fully qualified class name. | |||||
| START=$PACKAGE.`basename $0` | |||||
| # Java runtime path. | |||||
| EXE=/usr/java1.3/bin/java | |||||
| # Set any runtime options here | |||||
| OPTS="-classpath $CLASSPATH" | |||||
| # Turn the JIT off if the variable "DEBUG" is set in the environment. | |||||
| if [ ! -z $DEBUG ]; then | |||||
| OPTS="$OPTS -Djava.compiler=NONE" | |||||
| fi | |||||
| # Launch the program. | |||||
| #echo $EXE $OPTS $START $* | |||||
| exec $EXE $OPTS $START $* | |||||
| @@ -1,246 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import java.beans.*; | |||||
| import java.awt.Graphics; | |||||
| import java.awt.Component; | |||||
| import java.awt.Rectangle; | |||||
| import java.awt.Dimension; | |||||
| import javax.swing.JComponent; | |||||
| import java.awt.event.FocusEvent; | |||||
| import java.awt.event.FocusAdapter; | |||||
| /** | |||||
| * Abstract base class for the custom type property editors. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public abstract class AbstractPropertyEditor implements PropertyEditor { | |||||
| /** Bean property change property name. */ | |||||
| public static final String BEAN_PROP = "BeanEditorProperty"; | |||||
| /** Event listener support. */ | |||||
| private PropertyChangeSupport _listeners = new PropertyChangeSupport(this); | |||||
| /** | |||||
| * Default constructor. | |||||
| * | |||||
| */ | |||||
| protected AbstractPropertyEditor() { | |||||
| } | |||||
| /** | |||||
| * Paint a representation of the value into a given area of screen | |||||
| * real estate. Note that the propertyEditor is responsible for doing | |||||
| * its own clipping so that it fits into the given rectangle. | |||||
| * <p> | |||||
| * If the PropertyEditor doesn't honor paint requests (see isPaintable) | |||||
| * this method should be a silent noop. | |||||
| * <p> | |||||
| * The given Graphics object will have the default font, color, etc of | |||||
| * the parent container. The PropertyEditor may change graphics attributes | |||||
| * such as font and color and doesn't need to restore the old values. | |||||
| * | |||||
| * @param gfx Graphics object to paint into. | |||||
| * @param box Rectangle within graphics object into which we should paint. | |||||
| */ | |||||
| public void paintValue(Graphics gfx, Rectangle box) { | |||||
| Object o = getValue(); | |||||
| String s = o == null ? "<null>" : o.toString(); | |||||
| gfx.drawString(s, box.x, box.y); | |||||
| } | |||||
| /** | |||||
| * Fire a property change event to listeners. | |||||
| * | |||||
| * @param oldValue Old value. | |||||
| * @param newValue New value. | |||||
| */ | |||||
| public void firePropertyChange(Object oldValue, Object newValue) { | |||||
| _listeners.firePropertyChange(BEAN_PROP, oldValue, newValue); | |||||
| } | |||||
| /** | |||||
| * Add a property change listener. XXX This may cause undesired | |||||
| * side affects with merging property changes with JPanel class. | |||||
| * Need to test for a while. | |||||
| * | |||||
| * @param l Change listener. | |||||
| */ | |||||
| public void addPropertyChangeListener(PropertyChangeListener l) { | |||||
| _listeners.addPropertyChangeListener(l); | |||||
| } | |||||
| /** | |||||
| * Remove a property change listener. | |||||
| * | |||||
| * @param l Change listener. | |||||
| */ | |||||
| public void removePropertyChangeListener(PropertyChangeListener l) { | |||||
| _listeners.removePropertyChangeListener(l); | |||||
| } | |||||
| /** | |||||
| * @return True if the class will honor the paintValue method. | |||||
| */ | |||||
| public boolean isPaintable() { | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * If the property value must be one of a set of known tagged values, | |||||
| * then this method should return an array of the tags. This can | |||||
| * be used to represent (for example) enum values. If a PropertyEditor | |||||
| * supports tags, then it should support the use of setAsText with | |||||
| * a tag value as a way of setting the value and the use of getAsText | |||||
| * to identify the current value. | |||||
| * | |||||
| * @return The tag values for this property. May be null if this | |||||
| * property cannot be represented as a tagged value. | |||||
| * | |||||
| */ | |||||
| public String[] getTags() { | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * A PropertyEditor may choose to make available a full custom Component | |||||
| * that edits its property value. It is the responsibility of the | |||||
| * PropertyEditor to hook itself up to its editor Component itself and | |||||
| * to report property value changes by firing a PropertyChange event. | |||||
| * <P> | |||||
| * The higher-level code that calls getCustomEditor may either embed | |||||
| * the Component in some larger property sheet, or it may put it in | |||||
| * its own individual dialog, or ... | |||||
| * | |||||
| * @return A java.awt.Component that will allow a human to directly | |||||
| * edit the current property value. May be null if this is | |||||
| * not supported. | |||||
| */ | |||||
| public Component getCustomEditor() { | |||||
| return getChild(); | |||||
| } | |||||
| /** | |||||
| * @return True if the propertyEditor can provide a custom editor. | |||||
| */ | |||||
| public boolean supportsCustomEditor() { | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return ""; | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected abstract Component getChild(); | |||||
| /** Helper class for detecting changes and generating change events | |||||
| * on a focus lost event. */ | |||||
| protected static class FocusHandler extends FocusAdapter { | |||||
| /** Last value of the editor. */ | |||||
| private Object _value = null; | |||||
| /** Editor of interest. */ | |||||
| private AbstractPropertyEditor _editor = null; | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param editor Editor of interest. | |||||
| */ | |||||
| public FocusHandler(AbstractPropertyEditor editor) { | |||||
| _editor = editor; | |||||
| } | |||||
| /** | |||||
| * Called when focus is gained. | |||||
| * | |||||
| * @param e Focus event. | |||||
| */ | |||||
| public void focusGained(FocusEvent e) { | |||||
| _value = _editor.getValue(); | |||||
| } | |||||
| /** | |||||
| * Called when focus is lost. Checks to see if value changed and | |||||
| * fires a change event if needed. | |||||
| * | |||||
| * @param e Focus event. | |||||
| */ | |||||
| public void focusLost(FocusEvent e) { | |||||
| if((_value != null && !_value.equals(_editor.getValue())) || | |||||
| (_value == null && _editor.getValue() != null)) { | |||||
| _editor.firePropertyChange(_value, _editor.getValue()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,170 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import java.awt.Component; | |||||
| /** | |||||
| * Custom property editor for editing double values. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class DoublePropertyEditor extends AbstractPropertyEditor { | |||||
| /** Editing widget. */ | |||||
| private JTextField _widget = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public DoublePropertyEditor() { | |||||
| _widget = new JTextField(); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _widget; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return "new Double(" + getAsText() + ")"; | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| Object old = _widget.getText(); | |||||
| if(!(value instanceof Double)) { | |||||
| value = new Double(0); | |||||
| } | |||||
| _widget.setText(value.toString()); | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types such as "int" will | |||||
| * be wrapped as the corresponding object type such as "java.lang.Integer". | |||||
| */ | |||||
| public Object getValue() { | |||||
| Double retval = null; | |||||
| try { | |||||
| retval = new Double(_widget.getText()); | |||||
| } | |||||
| catch(NumberFormatException ex) { | |||||
| retval = new Double(0); | |||||
| _widget.setText(retval.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) { | |||||
| Object old = _widget.getText(); | |||||
| Double val = null; | |||||
| try { | |||||
| val = new Double(text); | |||||
| } | |||||
| catch(NumberFormatException ex) { | |||||
| val = new Double(0); | |||||
| } | |||||
| text = val.toString(); | |||||
| _widget.setText(text); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return _widget.getText(); | |||||
| } | |||||
| } | |||||
| @@ -1,608 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import org.apache.tools.ant.gui.util.LabelFieldGBC; | |||||
| import java.lang.reflect.*; | |||||
| import java.beans.*; | |||||
| import javax.swing.*; | |||||
| import java.util.*; | |||||
| import java.io.File; | |||||
| import java.awt.*; | |||||
| /** | |||||
| * Widget for dynamically constructing a property editor based on the | |||||
| * an Object's BeanInfo. Essentially a property sheet. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class DynamicCustomizer extends JPanel implements Customizer, Scrollable { | |||||
| static { | |||||
| PropertyEditorManager.registerEditor( | |||||
| String.class, StringPropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| String[].class, StringArrayPropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| int.class, IntegerPropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| Integer.class, IntegerPropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| double.class, DoublePropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| Double.class, DoublePropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| Properties.class, PropertiesPropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| File.class, FilePropertyEditor.class); | |||||
| PropertyEditorManager.registerEditor( | |||||
| Object.class, ObjectPropertyEditor.class); | |||||
| } | |||||
| /** Property name that PropertyDescriptors can save in their property | |||||
| * dictionaries for for specifiying a display sorting order. The value | |||||
| * sould be of type Integer. */ | |||||
| public static final String SORT_ORDER = "sortOrder"; | |||||
| /** The type that this editor instance can handle. */ | |||||
| private Class _type = null; | |||||
| /** The value currently being edited. */ | |||||
| private Object _value = null; | |||||
| /** Mapping from PropertyDescriptor to PropertyEditor. */ | |||||
| private Map _prop2Editor = new HashMap(); | |||||
| /** Mapping from PropertyEditor to field PropertyDescriptor. */ | |||||
| private Map _editor2Prop = new HashMap(); | |||||
| /** Listener for receiving change events from the editors. */ | |||||
| private EditorChangeListener _eListener = new EditorChangeListener(); | |||||
| /** Read-only flag. */ | |||||
| private boolean _readOnly = false; | |||||
| /** List of property change listeners interested when the bean | |||||
| * being edited has been changed. */ | |||||
| private java.util.List _changeListeners = new LinkedList(); | |||||
| /** Flag to trun off event propogation. */ | |||||
| private boolean _squelchChangeEvents = false; | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param type Type that you are going to be creating and editor for. | |||||
| */ | |||||
| public DynamicCustomizer(Class type) { | |||||
| this(type, false); | |||||
| } | |||||
| /** | |||||
| * Standard constructor. | |||||
| * | |||||
| * @param type Type that you are going to be creating and editor for. | |||||
| * @param readOnly Set to true to create a read-only customizer. | |||||
| */ | |||||
| public DynamicCustomizer(Class type, boolean readOnly) { | |||||
| super(new GridBagLayout()); | |||||
| _readOnly = readOnly; | |||||
| _type = type; | |||||
| LabelFieldGBC gbc = new LabelFieldGBC(); | |||||
| try { | |||||
| BeanInfo info = Introspector.getBeanInfo(type); | |||||
| // Set up pretty display stuff. | |||||
| setBorder(BorderFactory.createTitledBorder( | |||||
| info.getBeanDescriptor().getDisplayName())); | |||||
| setToolTipText(info.getBeanDescriptor().getShortDescription()); | |||||
| // Get the properties and sort them. | |||||
| PropertyDescriptor[] props = info.getPropertyDescriptors(); | |||||
| Arrays.sort(props, new PropertyComparator()); | |||||
| for(int i = 0; i < props.length; i++) { | |||||
| // Ignore the "class" property, if it is provided. | |||||
| if(props[i].getName().equals("class")) continue; | |||||
| // Create a label for the field. | |||||
| JLabel label = new JLabel(props[i].getDisplayName() + ":"); | |||||
| // Lookup the editor. | |||||
| PropertyEditor editor = getEditorForProperty(props[i]); | |||||
| // Add a listener to the editor so we know when to update | |||||
| // the bean's fields. | |||||
| editor.addPropertyChangeListener(_eListener); | |||||
| // XXX What we need to do right here is provide a component | |||||
| // that makes use of the "paintable" capability of the editor. | |||||
| Component comp = editor.getCustomEditor(); | |||||
| if(comp == null) { | |||||
| comp = new JLabel("<No editor available.>"); | |||||
| ((JLabel)comp).setBorder(BorderFactory.createEtchedBorder()); | |||||
| } | |||||
| // See if it is a read-only property. If so, then just | |||||
| // display it. | |||||
| if(_readOnly || props[i].getWriteMethod() == null) { | |||||
| comp.setEnabled(false); | |||||
| } | |||||
| // Setup the accellerator key. | |||||
| label.setLabelFor(comp); | |||||
| label.setDisplayedMnemonic(label.getText().charAt(0)); | |||||
| // Set the tool tip text, if any. | |||||
| String tip = props[i].getShortDescription(); | |||||
| if(tip != null) { | |||||
| label.setToolTipText(tip); | |||||
| if(comp instanceof JComponent) { | |||||
| ((JComponent)comp).setToolTipText(tip); | |||||
| } | |||||
| } | |||||
| // Add the label and fields. | |||||
| add(label, gbc.forLabel()); | |||||
| add(comp, gbc.forField()); | |||||
| // Set the mappings between editor and property, etc. for | |||||
| // quick lookup later. | |||||
| _prop2Editor.put(props[i], editor); | |||||
| _editor2Prop.put(editor, props[i]); | |||||
| } | |||||
| // Filler... | |||||
| add(new JLabel(), gbc.forLastLabel()); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Set the object to be edited. | |||||
| * | |||||
| * @param value The object to be edited. | |||||
| */ | |||||
| public void setObject(Object value) { | |||||
| if(!(_type.isInstance(value))) { | |||||
| throw new IllegalArgumentException( | |||||
| value.getClass() + " is not of type " + _type); | |||||
| } | |||||
| _value = value; | |||||
| // Disable event generation. | |||||
| _squelchChangeEvents = true; | |||||
| // Iterate over each property, doing a lookup on the associated editor | |||||
| // and setting the editor's value to the value of the property. | |||||
| Iterator it = _prop2Editor.keySet().iterator(); | |||||
| while(it.hasNext()) { | |||||
| PropertyDescriptor desc = (PropertyDescriptor) it.next(); | |||||
| PropertyEditor editor = (PropertyEditor) _prop2Editor.get(desc); | |||||
| Method reader = desc.getReadMethod(); | |||||
| if(reader != null) { | |||||
| try { | |||||
| Object val = reader.invoke(_value, null); | |||||
| editor.setValue(val); | |||||
| } | |||||
| catch(IllegalAccessException ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| catch(InvocationTargetException ex) { | |||||
| ex.getTargetException().printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| // Enable event generation. | |||||
| _squelchChangeEvents = false; | |||||
| } | |||||
| /** | |||||
| * Get the appropriate editor for the given property. | |||||
| * | |||||
| * @param prop Property to get editor for. | |||||
| * @return Editor to use, or null if none found. | |||||
| */ | |||||
| private PropertyEditor getEditorForProperty(PropertyDescriptor prop) { | |||||
| PropertyEditor retval = null; | |||||
| Class type = prop.getPropertyEditorClass(); | |||||
| if(type != null) { | |||||
| try { | |||||
| retval = (PropertyEditor) type.newInstance(); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| // Handle case where there is no special editor | |||||
| // associated with the property. In that case we ask the | |||||
| // PropertyEditor manager for the editor registered for the | |||||
| // given property type. | |||||
| if(retval == null) { | |||||
| Class t = prop.getPropertyType(); | |||||
| if(t != null) { | |||||
| retval = PropertyEditorManager.findEditor(t); | |||||
| } | |||||
| } | |||||
| // In the worse case we resort to the generic editor for Object types. | |||||
| if(retval == null) { | |||||
| retval = PropertyEditorManager.findEditor(Object.class); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Add the given listener. Will receive a change event for | |||||
| * changes to the bean being edited. | |||||
| * | |||||
| * @param l Listner to add. | |||||
| */ | |||||
| public void addPropertyChangeListener(PropertyChangeListener l) { | |||||
| _changeListeners.add(l); | |||||
| } | |||||
| /** | |||||
| * Remove the given property change listener. | |||||
| * | |||||
| * @param l Listener to remove. | |||||
| */ | |||||
| public void removePropertyChangeListener(PropertyChangeListener l) { | |||||
| _changeListeners.remove(l); | |||||
| } | |||||
| /** | |||||
| * Fire a property change event to each listener. | |||||
| * | |||||
| * @param bean Bean being edited. | |||||
| * @param propName Name of the property. | |||||
| * @param oldValue Old value. | |||||
| * @param newValue New value. | |||||
| */ | |||||
| protected void firePropertyChange(Object bean, String propName, | |||||
| Object oldValue, Object newValue) { | |||||
| PropertyChangeEvent e = new PropertyChangeEvent( | |||||
| bean, propName, oldValue, newValue); | |||||
| Iterator it = _changeListeners.iterator(); | |||||
| while(it.hasNext()) { | |||||
| PropertyChangeListener l = (PropertyChangeListener) it.next(); | |||||
| l.propertyChange(e); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Returns the preferred size of the viewport for a view component. | |||||
| * For example the preferredSize of a JList component is the size | |||||
| * required to acommodate all of the cells in its list however the | |||||
| * value of preferredScrollableViewportSize is the size required for | |||||
| * JList.getVisibleRowCount() rows. A component without any properties | |||||
| * that would effect the viewport size should just return | |||||
| * getPreferredSize() here. | |||||
| * | |||||
| * @return The preferredSize of a JViewport whose view is this Scrollable. | |||||
| * @see JViewport#getPreferredSize | |||||
| */ | |||||
| public Dimension getPreferredScrollableViewportSize() { | |||||
| Dimension size = getPreferredSize(); | |||||
| Dimension retval = new Dimension(); | |||||
| retval.width = size.width > 600 ? 600 : size.width; | |||||
| retval.height = size.height > 400 ? 400 : size.height; | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Components that display logical rows or columns should compute | |||||
| * the scroll increment that will completely expose one new row | |||||
| * or column, depending on the value of orientation. Ideally, | |||||
| * components should handle a partially exposed row or column by | |||||
| * returning the distance required to completely expose the item. | |||||
| * <p> | |||||
| * Scrolling containers, like JScrollPane, will use this method | |||||
| * each time the user requests a unit scroll. | |||||
| * | |||||
| * @param visibleRect The view area visible within the viewport | |||||
| * @param orientation Either SwingConstants.VERTICAL or | |||||
| * SwingConstants.HORIZONTAL. | |||||
| * @param direction Less than zero to scroll up/left, | |||||
| * greater than zero for down/right. | |||||
| * @return The "unit" increment for scrolling in the specified direction | |||||
| * @see JScrollBar#setUnitIncrement | |||||
| */ | |||||
| public int getScrollableUnitIncrement(Rectangle visibleRect, | |||||
| int orientation, int direction) { | |||||
| return 1; | |||||
| } | |||||
| /** | |||||
| * Components that display logical rows or columns should compute | |||||
| * the scroll increment that will completely expose one block | |||||
| * of rows or columns, depending on the value of orientation. | |||||
| * <p> | |||||
| * Scrolling containers, like JScrollPane, will use this method | |||||
| * each time the user requests a block scroll. | |||||
| * | |||||
| * @param visibleRect The view area visible within the viewport | |||||
| * @param orientation Either SwingConstants.VERTICAL or | |||||
| * SwingConstants.HORIZONTAL. | |||||
| * @param direction Less than zero to scroll up/left, | |||||
| * greater than zero for down/right. | |||||
| * @return The "block" increment for scrolling in the specified direction. | |||||
| * @see JScrollBar#setBlockIncrement | |||||
| */ | |||||
| public int getScrollableBlockIncrement(Rectangle visibleRect, | |||||
| int orientation, int direction) { | |||||
| return orientation == SwingConstants.VERTICAL ? | |||||
| visibleRect.height / 2 : visibleRect.width / 2; | |||||
| } | |||||
| /** | |||||
| * Return true if a viewport should always force the width of this | |||||
| * Scrollable to match the width of the viewport. For example a noraml | |||||
| * text view that supported line wrapping would return true here, since it | |||||
| * would be undesirable for wrapped lines to disappear beyond the right | |||||
| * edge of the viewport. Note that returning true for a Scrollable | |||||
| * whose ancestor is a JScrollPane effectively disables horizontal | |||||
| * scrolling. | |||||
| * <p> | |||||
| * Scrolling containers, like JViewport, will use this method each | |||||
| * time they are validated. | |||||
| * | |||||
| * @return True if a viewport should force the Scrollables | |||||
| * width to match its own. | |||||
| */ | |||||
| public boolean getScrollableTracksViewportWidth() { | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * Return true if a viewport should always force the height of this | |||||
| * Scrollable to match the height of the viewport. For example a | |||||
| * columnar text view that flowed text in left to right columns | |||||
| * could effectively disable vertical scrolling by returning | |||||
| * true here. | |||||
| * <p> | |||||
| * Scrolling containers, like JViewport, will use this method each | |||||
| * time they are validated. | |||||
| * | |||||
| * @return True if a viewport should force the Scrollables | |||||
| * height to match its own. | |||||
| */ | |||||
| public boolean getScrollableTracksViewportHeight() { | |||||
| return false; | |||||
| } | |||||
| /** Class for receiving change events from the PropertyEditor objects. */ | |||||
| private class EditorChangeListener implements PropertyChangeListener { | |||||
| public void propertyChange(PropertyChangeEvent e) { | |||||
| if(_squelchChangeEvents) return; | |||||
| PropertyEditor editor = (PropertyEditor) e.getSource(); | |||||
| PropertyDescriptor prop = | |||||
| (PropertyDescriptor) _editor2Prop.get(editor); | |||||
| Method writer = prop.getWriteMethod(); | |||||
| if(writer != null) { | |||||
| try { | |||||
| Object[] params = { editor.getValue() }; | |||||
| writer.invoke(_value, params); | |||||
| setObject(_value); | |||||
| firePropertyChange( | |||||
| _value, prop.getName(), null, editor.getValue()); | |||||
| } | |||||
| catch(IllegalAccessException ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| catch(InvocationTargetException ex) { | |||||
| ex.getTargetException().printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /** Comparator for sorting PropertyDescriptor values. */ | |||||
| private static class PropertyComparator implements Comparator { | |||||
| public int compare(Object o1, Object o2) { | |||||
| PropertyDescriptor p1 = (PropertyDescriptor)o1; | |||||
| PropertyDescriptor p2 = (PropertyDescriptor)o2; | |||||
| Integer i1 = (Integer) p1.getValue(SORT_ORDER); | |||||
| Integer i2 = (Integer) p2.getValue(SORT_ORDER); | |||||
| if(i1 == null && i2 == null) { | |||||
| return p1.getName().compareTo(p2.getName()); | |||||
| } | |||||
| else if(i1 != null) { | |||||
| return i1.compareTo(i2); | |||||
| } | |||||
| else { | |||||
| return i2.compareTo(i1) * -1; | |||||
| } | |||||
| } | |||||
| } | |||||
| /*----------------------------------------------------------------------*/ | |||||
| /** Class for testing this. */ | |||||
| private static class TestClass implements Cloneable { | |||||
| private String _String = "This string is my name."; | |||||
| private String[] _StringArray = { "one", "two", "three" }; | |||||
| private int _int = Integer.MIN_VALUE; | |||||
| private Integer _Integer = new Integer(Integer.MAX_VALUE); | |||||
| private double _double = Double.MIN_VALUE; | |||||
| private Double _Double = new Double(Double.MAX_VALUE); | |||||
| private Properties _Properties = System.getProperties(); | |||||
| private File _File = new File("/"); | |||||
| private Object _Object = new Font("Monospaced", Font.PLAIN, 12); | |||||
| private JButton _button = new JButton("I'm a button!"); | |||||
| public void setName(String string) { | |||||
| _String = string; | |||||
| } | |||||
| public String getName() { | |||||
| return _String; | |||||
| } | |||||
| public void setStringArray(String[] array) { | |||||
| _StringArray = array; | |||||
| } | |||||
| public String[] getStringArray() { | |||||
| return _StringArray; | |||||
| } | |||||
| public void setInt(int val) { | |||||
| _int = val; | |||||
| } | |||||
| public int getInt() { | |||||
| return _int; | |||||
| } | |||||
| public void setInteger(Integer val) { | |||||
| _Integer = val; | |||||
| } | |||||
| public Integer getInteger() { | |||||
| return _Integer; | |||||
| } | |||||
| public void setDoub(double val) { | |||||
| _double = val; | |||||
| } | |||||
| public double getDoub() { | |||||
| return _double; | |||||
| } | |||||
| public void setDouble(Double val) { | |||||
| _Double = val; | |||||
| } | |||||
| public Double getDouble() { | |||||
| return _Double; | |||||
| } | |||||
| public void setProperties(Properties props) { | |||||
| _Properties = props; | |||||
| } | |||||
| public Properties getProperties() { | |||||
| return _Properties; | |||||
| } | |||||
| public void setFile(File f) { | |||||
| _File = f; | |||||
| } | |||||
| public File getFile() { | |||||
| return _File; | |||||
| } | |||||
| public void setButton(JButton button) { | |||||
| _button = button; | |||||
| } | |||||
| public JButton getButton() { | |||||
| return _button; | |||||
| } | |||||
| public void setObject(Object o) { | |||||
| _Object = o; | |||||
| } | |||||
| public Object getObject() { | |||||
| return _Object; | |||||
| } | |||||
| public Object clone() { | |||||
| try { | |||||
| return super.clone(); | |||||
| } | |||||
| catch(CloneNotSupportedException ex) { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Test code. | |||||
| * | |||||
| * @param args First arg is the class name to create | |||||
| */ | |||||
| public static void main(String[] args) { | |||||
| try { | |||||
| Class type = null; | |||||
| Object instance = null; | |||||
| if(args.length > 0) { | |||||
| type = Class.forName(args[0]); | |||||
| instance = type.newInstance(); | |||||
| } | |||||
| else { | |||||
| type = TestClass.class; | |||||
| instance = new TestClass(); | |||||
| ((TestClass)instance).setObject(new TestClass()); | |||||
| } | |||||
| JFrame f = new JFrame(type.getName()); | |||||
| DynamicCustomizer custom = new DynamicCustomizer(type); | |||||
| custom.setObject(instance); | |||||
| f.getContentPane().add(new JScrollPane(custom)); | |||||
| f.pack(); | |||||
| f.setVisible(true); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,215 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import javax.swing.filechooser.FileFilter; | |||||
| import java.awt.Component; | |||||
| import java.awt.BorderLayout; | |||||
| import java.awt.event.ActionListener; | |||||
| import java.awt.event.ActionEvent; | |||||
| import javax.swing.border.BevelBorder; | |||||
| import java.io.File; | |||||
| /** | |||||
| * Custom property editor for File types. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class FilePropertyEditor extends AbstractPropertyEditor { | |||||
| /** Area for typing in the file name. */ | |||||
| private JTextField _widget = null; | |||||
| /** Container for the editor. */ | |||||
| private JPanel _container = null; | |||||
| /** File filter to use. */ | |||||
| private FileFilter _filter = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public FilePropertyEditor() { | |||||
| _container = new JPanel(new BorderLayout()); | |||||
| _widget = new JTextField(); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| _container.add(_widget, BorderLayout.CENTER); | |||||
| JButton b = new JButton("Browse..."); | |||||
| b.addActionListener(new ActionHandler()); | |||||
| _container.add(b, BorderLayout.EAST); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _container; | |||||
| } | |||||
| /** | |||||
| * File filter to use with chooser. | |||||
| * | |||||
| * @param filter File filter. | |||||
| */ | |||||
| public void setFileFilter(FileFilter filter) { | |||||
| _filter = filter; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return "new File(" + getAsText() + ")"; | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| if(value == null) { | |||||
| value = new File(""); | |||||
| } | |||||
| if(!(value instanceof File)) { | |||||
| throw new IllegalArgumentException( | |||||
| value.getClass().getName() + " is not of type File"); | |||||
| } | |||||
| Object old = _widget.getText(); | |||||
| _widget.setText(((File)value).getPath()); | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types | |||||
| * such as "int" will be wrapped as the corresponding | |||||
| * object type such as "java.lang.Integer". */ | |||||
| public Object getValue() { | |||||
| File retval = null; | |||||
| retval = new File(_widget.getText()); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) throws IllegalArgumentException { | |||||
| File f = new File(text); | |||||
| _widget.setText(f.getPath()); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return new File(_widget.getText()).getAbsolutePath(); | |||||
| } | |||||
| /** Handler for presses of the browse button. */ | |||||
| private class ActionHandler implements ActionListener { | |||||
| public void actionPerformed(ActionEvent e) { | |||||
| JFileChooser chooser = null; | |||||
| chooser = new JFileChooser(); | |||||
| chooser.setSelectedFile((File) getValue()); | |||||
| _filter = (_filter == null ? | |||||
| chooser.getAcceptAllFileFilter() : _filter); | |||||
| chooser.setFileFilter(_filter); | |||||
| chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); | |||||
| if(chooser.showDialog(getChild(), "Select") == | |||||
| JFileChooser.APPROVE_OPTION) { | |||||
| Object oldValue = getValue(); | |||||
| Object newValue = chooser.getSelectedFile(); | |||||
| setValue(newValue); | |||||
| firePropertyChange(oldValue, newValue); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,172 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import java.awt.Component; | |||||
| /** | |||||
| * Custom property editor for integer types. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class IntegerPropertyEditor extends AbstractPropertyEditor { | |||||
| /** Editing widget. */ | |||||
| private JTextField _widget = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public IntegerPropertyEditor() { | |||||
| _widget = new JTextField(); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _widget; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return "new Integer(" + getAsText() + ")"; | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| Object old = _widget.getText(); | |||||
| if(!(value instanceof Integer)) { | |||||
| value = new Integer(0); | |||||
| } | |||||
| _widget.setText(value.toString()); | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types such as "int" will | |||||
| * be wrapped as the corresponding object type such as "java.lang.Integer". | |||||
| */ | |||||
| public Object getValue() { | |||||
| Integer retval = null; | |||||
| try { | |||||
| retval = new Integer(_widget.getText()); | |||||
| } | |||||
| catch(NumberFormatException ex) { | |||||
| retval = new Integer(0); | |||||
| _widget.setText(retval.toString()); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) { | |||||
| Object old = _widget.getText(); | |||||
| Integer val = null; | |||||
| try { | |||||
| val = new Integer(text); | |||||
| } | |||||
| catch(NumberFormatException ex) { | |||||
| val = new Integer(0); | |||||
| } | |||||
| text = val.toString(); | |||||
| _widget.setText(text); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return _widget.getText(); | |||||
| } | |||||
| } | |||||
| @@ -1,313 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import java.awt.*; | |||||
| import java.awt.event.ActionListener; | |||||
| import java.awt.event.ActionEvent; | |||||
| import java.lang.reflect.Method; | |||||
| import javax.swing.border.BevelBorder; | |||||
| /** | |||||
| * Custom property editor for generic Object types. Useful for | |||||
| * complex objects where using the DynamicCustomizer may be useful. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class ObjectPropertyEditor extends AbstractPropertyEditor { | |||||
| /** Area for typing in the file name. */ | |||||
| private JTextField _widget = null; | |||||
| /** Container for the editor. */ | |||||
| private JPanel _container = null; | |||||
| /** The current object value. */ | |||||
| private Object _value = null; | |||||
| /** The editing button. */ | |||||
| private JButton _button = null; | |||||
| /** Flag to indicate that cancellation of editing is supported. */ | |||||
| private boolean _supportCancel = true; | |||||
| /** Original value. Only used if _supportCancel is true. */ | |||||
| private Object _original = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public ObjectPropertyEditor() { | |||||
| _container = new JPanel(new BorderLayout()); | |||||
| _widget = new JTextField(25); | |||||
| _widget.setEditable(false); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| _widget.setBorder( | |||||
| BorderFactory.createBevelBorder(BevelBorder.LOWERED)); | |||||
| _container.add(_widget, BorderLayout.CENTER); | |||||
| _button = new JButton("Edit..."); | |||||
| _button.addActionListener(new ActionHandler()); | |||||
| _container.add(_button, BorderLayout.EAST); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _container; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| * @exception IllegalArgumentException thrown if value can't be cloned. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| if(_supportCancel && value != _value) { | |||||
| try { | |||||
| _value = makeClone(value); | |||||
| } | |||||
| catch(CloneNotSupportedException ex){ | |||||
| // If cloning doesn't work then we can't support a "cancel" | |||||
| // option on the editing dialog. | |||||
| _supportCancel = false; | |||||
| } | |||||
| _original = value; | |||||
| } | |||||
| _value = value; | |||||
| _button.setEnabled(_value != null); | |||||
| _widget.setText(getAsString(_value)); | |||||
| } | |||||
| /** | |||||
| * Convert the given value into some appropriate string. NB: This method | |||||
| * can be continually improved to be made more and more smart over time. | |||||
| * | |||||
| * @param value Value to convert. | |||||
| * @return String value to display. | |||||
| */ | |||||
| private String getAsString(Object value) { | |||||
| String retval = null; | |||||
| if(value == null) { | |||||
| retval = "<null>"; | |||||
| } | |||||
| // We try to be smart by querying for various, logical string | |||||
| // representation of the value. | |||||
| if(retval == null) { | |||||
| try { | |||||
| Method m = value.getClass().getMethod("getName", null); | |||||
| retval = (String) m.invoke(value, null); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| } | |||||
| } | |||||
| if(retval == null) { | |||||
| try { | |||||
| Method m = value.getClass().getMethod("getLabel", null); | |||||
| retval = (String) m.invoke(value, null); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| } | |||||
| } | |||||
| if(retval == null) { | |||||
| try { | |||||
| Method m = value.getClass().getMethod("getText", null); | |||||
| retval = (String) m.invoke(value, null); | |||||
| } | |||||
| catch(Exception ex) { | |||||
| } | |||||
| } | |||||
| if(retval == null) { | |||||
| retval = value.toString(); | |||||
| } | |||||
| if(retval.length() > 256) { | |||||
| retval = retval.substring(0, 253) + "..."; | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Attampt to make a clone of the given value. | |||||
| * | |||||
| * @param value Value to clone. | |||||
| * @return Cloned value, or null if value given was null. | |||||
| * @exception IllegalArgumentException thrown if value can't be cloned. | |||||
| */ | |||||
| private Object makeClone(Object value) throws CloneNotSupportedException { | |||||
| Object retval = null; | |||||
| if(value != null) { | |||||
| try { | |||||
| Method m = value.getClass().getMethod("clone", null); | |||||
| retval = m.invoke(value, null); | |||||
| } | |||||
| catch(Throwable ex) { | |||||
| throw new CloneNotSupportedException( | |||||
| "This editor only supports types that have publically " + | |||||
| "accessible clone() methods.\n" + | |||||
| value.getClass().getName() + | |||||
| " does not have such a method."); | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types | |||||
| * such as "int" will be wrapped as the corresponding | |||||
| * object type such as "java.lang.Integer". */ | |||||
| public Object getValue() { | |||||
| return _value; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) throws IllegalArgumentException { | |||||
| throw new IllegalArgumentException("String conversion not supported."); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return null; | |||||
| } | |||||
| /** Handler for presses of the edit button. */ | |||||
| private class ActionHandler implements ActionListener { | |||||
| public void actionPerformed(ActionEvent e) { | |||||
| if(_value == null) return; | |||||
| Class type = _value.getClass(); | |||||
| DynamicCustomizer c = new DynamicCustomizer(type); | |||||
| c.setObject(_value); | |||||
| int returnVal = JOptionPane.OK_OPTION; | |||||
| if(_supportCancel) { | |||||
| returnVal = JOptionPane.showConfirmDialog( | |||||
| getChild(), new JScrollPane(c), "Editing...", | |||||
| JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); | |||||
| } | |||||
| else { | |||||
| JOptionPane.showMessageDialog( | |||||
| getChild(), new JScrollPane(c), "Editing...", | |||||
| JOptionPane.PLAIN_MESSAGE); | |||||
| returnVal = JOptionPane.OK_OPTION; | |||||
| } | |||||
| if(returnVal == JOptionPane.OK_OPTION) { | |||||
| Object oldValue = _original; | |||||
| Object newValue = _value; | |||||
| setValue(newValue); | |||||
| firePropertyChange(oldValue, newValue); | |||||
| } | |||||
| else { | |||||
| try { | |||||
| _value = makeClone(_original); | |||||
| } | |||||
| catch(CloneNotSupportedException ex) { | |||||
| // XXX log me. Shouldn't have gotten here as | |||||
| // the test for cloneability should have already been done. | |||||
| ex.printStackTrace(); | |||||
| _supportCancel = false; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,308 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import javax.swing.table.AbstractTableModel; | |||||
| import java.awt.Component; | |||||
| import java.awt.Dimension; | |||||
| import java.awt.BorderLayout; | |||||
| import java.util.*; | |||||
| /** | |||||
| * Custom property editor for the Properties class. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class PropertiesPropertyEditor extends AbstractPropertyEditor { | |||||
| /** Recommended size for widgets inside a JScrollPane, as communicated | |||||
| * through the setPreferredScrollableViewportSize() method. */ | |||||
| protected static final Dimension VIEWPORT_SIZE = new Dimension(200, 50); | |||||
| /** Container. */ | |||||
| private JPanel _widget = null; | |||||
| /* The current properties being edited. */ | |||||
| private Properties _properties = null; | |||||
| /** The table editor for the properties. */ | |||||
| private JTable _table = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public PropertiesPropertyEditor() { | |||||
| _widget = new JPanel(new BorderLayout()); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| _table = new JTable(); | |||||
| _table.setPreferredScrollableViewportSize(VIEWPORT_SIZE); | |||||
| JScrollPane scroller = new JScrollPane(_table); | |||||
| _widget.add(BorderLayout.CENTER, scroller); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _widget; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return "new Properties()"; | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| if(value == null) { | |||||
| value = new Properties(); | |||||
| } | |||||
| if(!(value instanceof Properties)) { | |||||
| throw new IllegalArgumentException( | |||||
| value.getClass().getName() + " is not of type Properties."); | |||||
| } | |||||
| Object old = _properties; | |||||
| _properties = (Properties) ((Properties) value).clone(); | |||||
| PropertiesTableModel model = new PropertiesTableModel(); | |||||
| _table.setModel(model); | |||||
| _table.clearSelection(); | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types | |||||
| * such as "int" will be wrapped as the corresponding | |||||
| * object type such as "java.lang.Integer". | |||||
| */ | |||||
| public Object getValue() { | |||||
| return _properties; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) throws IllegalArgumentException { | |||||
| throw new IllegalArgumentException("Cannot be expressed as a String"); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return null; | |||||
| } | |||||
| /** Table model view of the Properties object. */ | |||||
| private class PropertiesTableModel extends AbstractTableModel { | |||||
| private static final int NAME = 0; | |||||
| private static final int VALUE = 1; | |||||
| private List _keys = null; | |||||
| public PropertiesTableModel() { | |||||
| // We need to store the property keys in an array | |||||
| // so that the ordering is preserved. | |||||
| _keys = new ArrayList(_properties.keySet()); | |||||
| Collections.sort(_keys); | |||||
| } | |||||
| /** | |||||
| * Get the number of rows. | |||||
| * | |||||
| * @return Number of rows. | |||||
| */ | |||||
| public int getRowCount() { | |||||
| return _properties.size() + 1; | |||||
| } | |||||
| /** | |||||
| * Get the number of columns. | |||||
| * | |||||
| * @return 2 | |||||
| */ | |||||
| public int getColumnCount() { | |||||
| return 2; | |||||
| } | |||||
| /** | |||||
| * Get the editing and display class of the given column. | |||||
| * | |||||
| * @return String.class | |||||
| */ | |||||
| public Class getColumnClass(int column) { | |||||
| return String.class; | |||||
| } | |||||
| /** | |||||
| * Get the header name of the column. | |||||
| * | |||||
| * @param column Column index. | |||||
| * @return Name of the column. | |||||
| */ | |||||
| public String getColumnName(int column) { | |||||
| // XXX fix me. | |||||
| return column == NAME ? "Name" : "Value"; | |||||
| } | |||||
| /** | |||||
| * Determine if the given cell is editable. | |||||
| * | |||||
| * @param row Cell row. | |||||
| * @param column Cell column. | |||||
| * @return true | |||||
| */ | |||||
| public boolean isCellEditable(int row, int column) { | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * Get the object at the given table coordinates. | |||||
| * | |||||
| * @param row Table row. | |||||
| * @param column Table column. | |||||
| * @return Object at location, or null if none. | |||||
| */ | |||||
| public Object getValueAt(int row, int column) { | |||||
| if(row < _properties.size()) { | |||||
| switch(column) { | |||||
| case NAME: | |||||
| return _keys.get(row); | |||||
| case VALUE: | |||||
| return _properties.getProperty((String)_keys.get(row)); | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * Set the table value at the given location. | |||||
| * | |||||
| * @param value Value to set. | |||||
| * @param row Row. | |||||
| * @param column Column. | |||||
| */ | |||||
| public void setValueAt(Object value, int row, int column) { | |||||
| String k = null; | |||||
| String v = null; | |||||
| String currKey = (String) getValueAt(row, NAME); | |||||
| switch(column) { | |||||
| case NAME: | |||||
| k = String.valueOf(value); | |||||
| if(row < _keys.size()) { | |||||
| _keys.set(row, k); | |||||
| } | |||||
| else { | |||||
| _keys.add(k); | |||||
| } | |||||
| String currValue = null; | |||||
| if(currKey != null) { | |||||
| currValue = _properties.getProperty(currKey); | |||||
| _properties.remove(currKey); | |||||
| } | |||||
| v = currValue == null ? "" : currValue; | |||||
| break; | |||||
| case VALUE: | |||||
| v = String.valueOf(value); | |||||
| k = currKey; | |||||
| if(k == null || k.length() == 0) { | |||||
| k = "key-for-" + v; | |||||
| } | |||||
| break; | |||||
| } | |||||
| if(k.length() > 0) { | |||||
| _properties.setProperty(k, v); | |||||
| } | |||||
| fireTableRowsUpdated(row, row); | |||||
| // Fire change in outer class. | |||||
| firePropertyChange(null, _properties); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,179 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import javax.swing.border.BevelBorder; | |||||
| import java.awt.Component; | |||||
| import java.util.StringTokenizer; | |||||
| /** | |||||
| * Custom property editor for String arrays. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class StringArrayPropertyEditor extends AbstractPropertyEditor { | |||||
| private JTextField _widget = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public StringArrayPropertyEditor() { | |||||
| _widget = new JTextField() ; | |||||
| _widget.setBorder( | |||||
| BorderFactory.createBevelBorder(BevelBorder.LOWERED)); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _widget; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return getAsText(); | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| if(value == null) { | |||||
| value = new String[0]; | |||||
| } | |||||
| if(!(value instanceof String[])) { | |||||
| throw new IllegalArgumentException( | |||||
| "Value must be of type String[]."); | |||||
| } | |||||
| String old = _widget.getText(); | |||||
| String[] vals = (String[]) value; | |||||
| StringBuffer buf = new StringBuffer(); | |||||
| for(int i = 0; i < vals.length; i++) { | |||||
| buf.append(vals[i]); | |||||
| if(i < vals.length - 1) { | |||||
| buf.append(", "); | |||||
| } | |||||
| } | |||||
| _widget.setText(buf.toString()); | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types such as "int" will | |||||
| * be wrapped as the corresponding object type such as "java.lang.Integer". | |||||
| */ | |||||
| public Object getValue() { | |||||
| String vals = _widget.getText(); | |||||
| StringTokenizer tok = new StringTokenizer(vals,","); | |||||
| String[] retval = new String[tok.countTokens()]; | |||||
| for(int i = 0; i < retval.length; i++) { | |||||
| retval[i] = tok.nextToken().trim(); | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) throws IllegalArgumentException { | |||||
| Object old = _widget.getText(); | |||||
| _widget.setText(text); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return _widget.getText(); | |||||
| } | |||||
| } | |||||
| @@ -1,165 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.customizer; | |||||
| import javax.swing.*; | |||||
| import java.awt.Component; | |||||
| import javax.swing.border.BevelBorder; | |||||
| /** | |||||
| * Custom property editor for string types. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class StringPropertyEditor extends AbstractPropertyEditor { | |||||
| private JTextArea _widget = null; | |||||
| /** | |||||
| * Default ctor. | |||||
| * | |||||
| */ | |||||
| public StringPropertyEditor() { | |||||
| _widget = new JTextArea() { | |||||
| public boolean isManagingFocus() { | |||||
| return false; | |||||
| } | |||||
| }; | |||||
| _widget.setLineWrap(true); | |||||
| _widget.addFocusListener(new FocusHandler(this)); | |||||
| _widget.setBorder( | |||||
| BorderFactory.createBevelBorder(BevelBorder.LOWERED)); | |||||
| } | |||||
| /** | |||||
| * Get the child editing component. Uses JComponent so we can have tool | |||||
| * tips, etc. | |||||
| * | |||||
| * @return Child editing component. | |||||
| */ | |||||
| protected Component getChild() { | |||||
| return _widget; | |||||
| } | |||||
| /** | |||||
| * This method is intended for use when generating Java code to set | |||||
| * the value of the property. It should return a fragment of Java code | |||||
| * that can be used to initialize a variable with the current property | |||||
| * value. | |||||
| * <p> | |||||
| * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. | |||||
| * | |||||
| * @return A fragment of Java code representing an initializer for the | |||||
| * current value. | |||||
| */ | |||||
| public String getJavaInitializationString() { | |||||
| return getAsText(); | |||||
| } | |||||
| /** | |||||
| * Set (or change) the object that is to be edited. Builtin types such | |||||
| * as "int" must be wrapped as the corresponding object type such as | |||||
| * "java.lang.Integer". | |||||
| * | |||||
| * @param value The new target object to be edited. Note that this | |||||
| * object should not be modified by the PropertyEditor, rather | |||||
| * the PropertyEditor should create a new object to hold any | |||||
| * modified value. | |||||
| */ | |||||
| public void setValue(Object value) { | |||||
| if(value == null) { | |||||
| value = ""; | |||||
| } | |||||
| Object old = _widget.getText(); | |||||
| _widget.setText(String.valueOf(value)); | |||||
| } | |||||
| /** | |||||
| * @return The value of the property. Builtin types | |||||
| * such as "int" will be wrapped as the corresponding | |||||
| * object type such as "java.lang.Integer". */ | |||||
| public Object getValue() { | |||||
| String retval = _widget.getText(); | |||||
| return retval; | |||||
| } | |||||
| /** | |||||
| * Set the property value by parsing a given String. May raise | |||||
| * java.lang.IllegalArgumentException if either the String is | |||||
| * badly formatted or if this kind of property can't be expressed | |||||
| * as text. | |||||
| * @param text The string to be parsed. | |||||
| */ | |||||
| public void setAsText(String text) throws IllegalArgumentException { | |||||
| Object old = _widget.getText(); | |||||
| _widget.setText(text); | |||||
| } | |||||
| /** | |||||
| * @return The property value as a human editable string. | |||||
| * <p> Returns null if the value can't be expressed | |||||
| * as an editable string. | |||||
| * <p> If a non-null value is returned, then the PropertyEditor should | |||||
| * be prepared to parse that string back in setAsText(). | |||||
| */ | |||||
| public String getAsText() { | |||||
| return _widget.getText(); | |||||
| } | |||||
| } | |||||
| @@ -1,129 +0,0 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.gui.event; | |||||
| import org.apache.tools.ant.BuildEvent; | |||||
| import org.apache.tools.ant.gui.util.StackFrame; | |||||
| import org.apache.tools.ant.gui.command.Command; | |||||
| import org.apache.tools.ant.gui.command.NoOpCmd; | |||||
| import org.apache.tools.ant.gui.core.AppContext; | |||||
| import java.util.EventObject; | |||||
| /** | |||||
| * Wrapper event for the events generated during an Ant build. | |||||
| * | |||||
| * @version $Revision$ | |||||
| * @author Simeon Fitch | |||||
| */ | |||||
| public class AntBuildEvent extends AntEvent { | |||||
| /** The original event we are wrapping. */ | |||||
| private BuildEvent _buildEvent = null; | |||||
| /** The type of event we are wrapping. */ | |||||
| private BuildEventType _type = null; | |||||
| /** | |||||
| * Standard ctor. | |||||
| * | |||||
| * @param context application context. | |||||
| */ | |||||
| public AntBuildEvent(AppContext context, | |||||
| BuildEvent buildEvent, BuildEventType type) { | |||||
| super(context); | |||||
| _buildEvent = buildEvent; | |||||
| _type = type; | |||||
| if(_buildEvent == null || _type == null) { | |||||
| throw new IllegalArgumentException("Null parameter passed"); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Get the wrapped build event. | |||||
| * | |||||
| * @return Build event. | |||||
| */ | |||||
| public BuildEvent getEvent() { | |||||
| return _buildEvent; | |||||
| } | |||||
| /** | |||||
| * Get the build event type. | |||||
| * | |||||
| * @return Event type. | |||||
| */ | |||||
| public BuildEventType getType() { | |||||
| return _type; | |||||
| } | |||||
| /** | |||||
| * Create a string representation of this. | |||||
| * | |||||
| * @return String representation. | |||||
| */ | |||||
| public String toString() { | |||||
| StringBuffer buf = new StringBuffer(); | |||||
| if(_buildEvent.getMessage() != null) { | |||||
| buf.append(_buildEvent.getMessage()); | |||||
| buf.append('\n'); | |||||
| } | |||||
| if(_buildEvent.getException() != null) { | |||||
| buf.append(StackFrame.toString(_buildEvent.getException())); | |||||
| } | |||||
| return buf.toString(); | |||||
| } | |||||
| } | |||||