You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by me...@locus.apache.org on 2000/11/10 21:41:14 UTC

cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs ACSBeanDescriptor.java ACSNamedElement.java ACSProjectElementBeanInfo.java ACSTargetElementBeanInfo.java ACSTreeNodeElement.java BaseBeanInfo.java beaninfo.properties ACSElement.java ACSProjectElement.java ACSTargetElement.java

metasim     00/11/10 12:41:14

  Modified:    src/antidote/org/apache/tools/ant/gui/acs ACSElement.java
                        ACSProjectElement.java ACSTargetElement.java
  Added:       src/antidote/org/apache/tools/ant/gui/acs
                        ACSBeanDescriptor.java ACSNamedElement.java
                        ACSProjectElementBeanInfo.java
                        ACSTargetElementBeanInfo.java
                        ACSTreeNodeElement.java BaseBeanInfo.java
                        beaninfo.properties
  Log:
  Started addition of a generic Bean editor/property sheet and supporting
  infrastructure for Ant Elements.
  
  Revision  Changes    Path
  1.2       +36 -99    jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSElement.java
  
  Index: ACSElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSElement.java	2000/11/09 23:14:13	1.1
  +++ ACSElement.java	2000/11/10 20:41:12	1.2
  @@ -53,21 +53,21 @@
    */
   package org.apache.tools.ant.gui.acs;
   
  -
  -import org.w3c.dom.Node;
   import com.sun.xml.tree.ElementNode;
  -import javax.swing.tree.TreeNode;
  -import java.util.*;
  +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: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch */
  -public abstract class ACSElement extends ElementNode implements TreeNode {
  -    /** Cache of TreeNode only children. */
  -    private List _treeNodeCache = null;
  +public abstract class ACSElement extends ElementNode {
  +
  +    /** Event support. */
  +    private PropertyChangeSupport _propSupport = null;
   
   	/** 
   	 * Default ctor.
  @@ -87,105 +87,42 @@
       }
   
   	/** 
  -	 * Get the cache of TreeNode only children.
  +	 * Add a change listener.
   	 * 
  -	 * @return List of TreeNodes that are children.
  +	 * @param l Listener to add.
   	 */
  -    private List getCache() {
  -        if(_treeNodeCache == null) {
  -            _treeNodeCache = new ArrayList();
  -            
  -            for(int i = 0; i < getLength(); i++) {
  -                if(item(i) instanceof TreeNode) {
  -                    _treeNodeCache.add(item(i));
  -                }
  -            }
  +    public void addPropertyChangeListener(PropertyChangeListener l) {
  +        if(_propSupport == null) {
  +            _propSupport = new PropertyChangeSupport(this);
           }
  -
  -        return _treeNodeCache;
  -    }
  -    /**
  -     * Returns the child <code>TreeNode</code> at index 
  -     * <code>childIndex</code>.
  -     */
  -    public TreeNode getChildAt(int childIndex) {
  -        List nodes = getCache();
  -        return (TreeNode) nodes.get(childIndex);
  -    }
  -
  -    /**
  -     * Returns the number of children <code>TreeNode</code>s the receiver
  -     * contains.
  -     */
  -    public int getChildCount() {
  -        List nodes = getCache();
  -        return nodes.size();
  -    }
  -
  -    /**
  -     * Returns the parent <code>TreeNode</code> of the receiver.
  -     */
  -    public TreeNode getParent() {
  -        return (TreeNode) getParent();
  -    }
  -
  -    /**
  -     * Returns the index of <code>node</code> in the receivers children.
  -     * If the receiver does not contain <code>node</code>, -1 will be
  -     * returned.
  -     */
  -    public int getIndex(TreeNode node) {
  -        List nodes = getCache();
  -        return nodes.indexOf(node);
  -    }
  -
  -    /**
  -     * Returns true if the receiver allows children.
  -     */
  -    public boolean getAllowsChildren() {
  -        return true;
  +        _propSupport.addPropertyChangeListener(l);
       }
   
  -    /**
  -     * Returns true if the receiver is a leaf.
  -     */
  -    public boolean isLeaf() {
  -        List nodes = getCache();
  -        return nodes.size() <= 0;
  -    }
  -
  -    /**
  -     * Returns the children of the reciever as an Enumeration.
  -     */
  -    public Enumeration children() {
  -        return new NodeEnum();
  -    }
   
  -    /** Internal iterator for the child nodes. */
  -    private class NodeEnum implements Enumeration {
  -        /** Current child index. */
  -        private int _index = 0;
  -
  -        /** 
  -         * Determine if there are more elements to visit.
  -         * 
  -         * @return True if nextElement() can be called, false otherwise.
  -         */
  -        public boolean hasMoreElements() {
  -            List nodes = getCache();
  -            return _index < nodes.size();
  +	/** 
  +	 * Remove a change listener
  +	 * 
  +	 * @param l Listener to remove.
  +	 */
  +    public void removePropertyChangeListener(PropertyChangeListener l) {
  +        if(_propSupport == null) {
  +            _propSupport = new PropertyChangeSupport(this);
           }
  +        _propSupport.removePropertyChangeListener(l);
  +    }
   
  -        /** 
  -         * Get the next element. hasMoreElements() must currently return true.
  -         * 
  -         * @return Next element
  -         */
  -        public Object nextElement() {
  -            List nodes = getCache();
  -            return nodes.get(_index++);
  +	/** 
  +	 * 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.2       +6 -6      jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElement.java
  
  Index: ACSProjectElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSProjectElement.java	2000/11/09 23:14:14	1.1
  +++ ACSProjectElement.java	2000/11/10 20:41:12	1.2
  @@ -58,21 +58,21 @@
   /**
    * Class representing a project element in the build file.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
  -public class ACSProjectElement extends ACSElement {
  +public class ACSProjectElement extends ACSNamedElement {
       public ACSProjectElement() {
   
       }
   
   	/** 
  -	 * Get the project name.
  +	 * Get the type that this BeanInfo represents.
   	 * 
  -	 * @return Project name.
  +	 * @return Type.
   	 */
  -    public String getName() {
  -        return getAttribute("name");
  +    public Class getType() {
  +        return ACSProjectElement.class;
       }
   
   	/** 
  
  
  
  1.2       +3 -20     jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElement.java
  
  Index: ACSTargetElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSTargetElement.java	2000/11/09 23:14:14	1.1
  +++ ACSTargetElement.java	2000/11/10 20:41:12	1.2
  @@ -59,34 +59,17 @@
   /**
    * Class representing a build target.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
  -public class ACSTargetElement extends ACSElement {
  +public class ACSTargetElement extends ACSNamedElement {
  +
   	/** 
   	 * Default ctor.
   	 * 
   	 */
       public ACSTargetElement() {
   
  -    }
  -
  -	/** 
  -	 * Get the target name.
  -	 * 
  -	 * @return Target name.
  -	 */
  -    public String getName() {
  -        return getAttribute("name");
  -    }
  -
  -	/** 
  -	 * Get the long description of the target.
  -	 * 
  -	 * @return Target description.
  -	 */
  -    public String getDescription() {
  -        return getAttribute("description");
       }
   
   	/** 
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSBeanDescriptor.java
  
  Index: ACSBeanDescriptor.java
  ===================================================================
  /*
   * 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", "Tomcat", 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.ResourceManager;
  import java.beans.*;
  
  /**
   * Specialized BeanDescriptor for providing more descriptive information.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  class ACSBeanDescriptor extends BeanDescriptor {
      
      public ACSBeanDescriptor(BaseBeanInfo type) {
          super(type.getType());
          setDisplayName(
              type.getResources().getString(type.getClass(), "beanName"));
          setShortDescription(
              type.getResources().getString(type.getClass(), "beanDescription"));
      }
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSNamedElement.java
  
  Index: ACSNamedElement.java
  ===================================================================
  /*
   * 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", "Tomcat", 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: 1.1 $ 
   * @author Simeon Fitch 
   */
  public class ACSNamedElement extends ACSTreeNodeElement {
      /** 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 getTagName() + ": " + getName();
      }
  
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElementBeanInfo.java
  
  Index: ACSProjectElementBeanInfo.java
  ===================================================================
  /*
   * 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", "Tomcat", 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.beans.*;
  
  /**
   * BeanInfo for the ACSTargetElement class.
   * 
   * @version $Revision: 1.1 $ 
   * @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 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)
  
              };
          }
          catch(IntrospectionException ex) {
              ex.printStackTrace();
              throw new Error(ex.toString());
          }
  
          return retval;
      }
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElementBeanInfo.java
  
  Index: ACSTargetElementBeanInfo.java
  ===================================================================
  /*
   * 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", "Tomcat", 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.beans.*;
  
  /**
   * BeanInfo for the ACSTargetElement class.
   * 
   * @version $Revision: 1.1 $ 
   * @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 property descriptors.
  	 * 
       * @return Property descriptors.
  	 */
      public PropertyDescriptor[] getPropertyDescriptors() {
          PropertyDescriptor[] retval = null;
  
          try {
              retval = new PropertyDescriptor[] {
                  new PropertyDescriptor(getResources().getString(
                      getClass(),ACSTargetElement.NAME), 
                                         ACSTargetElement.class),
                  new PropertyDescriptor(getResources().getString(
                      getClass(),ACSTargetElement.DESCRIPTION),
                                         ACSTargetElement.class)
  
              };
          }
          catch(IntrospectionException ex) {
              ex.printStackTrace();
              throw new Error(ex.toString());
          }
  
          return retval;
      }
  
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTreeNodeElement.java
  
  Index: ACSTreeNodeElement.java
  ===================================================================
  /*
   * 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", "Tomcat", 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 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: 1.1 $ 
   * @author Simeon Fitch 
   */
  public abstract class ACSTreeNodeElement extends ACSElement 
      implements TreeNode {
  
      /** Cache of TreeNode only children. */
      private List _treeNodeCache = null;
  
  	/** 
  	 * Get the cache of TreeNode only children.
  	 * 
  	 * @return List of TreeNodes that are children.
  	 */
      private List getCache() {
          if(_treeNodeCache == null) {
              _treeNodeCache = new ArrayList();
              
              for(int i = 0; i < getLength(); i++) {
                  if(item(i) instanceof TreeNode) {
                      _treeNodeCache.add(item(i));
                  }
              }
          }
  
          return _treeNodeCache;
      }
      /**
       * Returns the child <code>TreeNode</code> at index 
       * <code>childIndex</code>.
       */
      public TreeNode getChildAt(int childIndex) {
          List nodes = getCache();
          return (TreeNode) nodes.get(childIndex);
      }
  
      /**
       * Returns the number of children <code>TreeNode</code>s the receiver
       * contains.
       */
      public int getChildCount() {
          List nodes = getCache();
          return nodes.size();
      }
  
      /**
       * Returns the parent <code>TreeNode</code> of the receiver.
       */
      public TreeNode getParent() {
          return (TreeNode) getParent();
      }
  
      /**
       * Returns the index of <code>node</code> in the receivers children.
       * If the receiver does not contain <code>node</code>, -1 will be
       * returned.
       */
      public int getIndex(TreeNode node) {
          List nodes = getCache();
          return nodes.indexOf(node);
      }
  
      /**
       * Returns true if the receiver allows children.
       */
      public boolean getAllowsChildren() {
          return true;
      }
  
      /**
       * Returns true if the receiver is a leaf.
       */
      public boolean isLeaf() {
          List nodes = getCache();
          return nodes.size() <= 0;
      }
  
      /**
       * Returns the children of the reciever as an Enumeration.
       */
      public Enumeration children() {
          return new NodeEnum();
      }
  
      /** Internal iterator for the child nodes. */
      private class NodeEnum implements Enumeration {
          /** Current child index. */
          private int _index = 0;
  
          /** 
           * Determine if there are more elements to visit.
           * 
           * @return True if nextElement() can be called, false otherwise.
           */
          public boolean hasMoreElements() {
              List nodes = getCache();
              return _index < nodes.size();
          }
  
          /** 
           * Get the next element. hasMoreElements() must currently return true.
           * 
           * @return Next element
           */
          public Object nextElement() {
              List nodes = getCache();
              return nodes.get(_index++);
          }
  
      }
  }
  
  
  
  1.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java
  
  Index: BaseBeanInfo.java
  ===================================================================
  /*
   * 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", "Tomcat", 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.ResourceManager;
  import java.beans.*;
  
  /**
   * Abstract base class for ACS BeanInfo classes.
   * 
   * @version $Revision: 1.1 $ 
   * @author Simeon Fitch 
   */
  abstract class BaseBeanInfo extends SimpleBeanInfo {
  
      /** Resource provider for bean info. */
      private static ResourceManager _resources = new ResourceManager(
          "org.apache.tools.ant.gui.acs.beaninfo");
  
  	/** 
  	 * Default ctor.
  	 * 
  	 */
      protected BaseBeanInfo() {
      }
  
  	/** 
  	 * 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 type that this BeanInfo represents.
  	 * 
  	 * @return Type.
  	 */
      public abstract Class getType();
  
      /**
       * 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.1                  jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/beaninfo.properties
  
  Index: beaninfo.properties
  ===================================================================
  # Properties file for BeanInfo strings
  
  org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.beanName=Target
  org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.beanDescription=\
      An executable target in the build.
  org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.name=Name
  org.apache.tools.ant.gui.acs.ACSTargetElementBeanInfo.description=Description
  
  org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.beanName=Project
  org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.beanDescription=\
      The top level project in the build definition.
  org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.name=Name
  org.apache.tools.ant.gui.acs.ACSProjectElementBeanInfo.description=Description