ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chr...@apache.org
Subject cvs commit: jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs ACSTaskElement.java BaseBeanInfo.java acs-element.properties
Date Mon, 30 Dec 2002 07:41:21 GMT
chrisw      2002/12/29 23:41:21

  Modified:    src/java/org/apache/tools/ant/gui/modules/edit
                        ElementTreeCellRenderer.java
               src/java/org/apache/tools/ant/gui/xml/dtd DOMAttributes.java
               src/java/org/apache/tools/ant/gui/acs ACSTaskElement.java
                        BaseBeanInfo.java acs-element.properties
  Log:
  [Antidote] Animated Nodes and Task Icons
  
  Revision  Changes    Path
  1.2       +4 -2      jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/modules/edit/ElementTreeCellRenderer.java
  
  Index: ElementTreeCellRenderer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/modules/edit/ElementTreeCellRenderer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ElementTreeCellRenderer.java	8 Apr 2001 23:42:14 -0000	1.1
  +++ ElementTreeCellRenderer.java	30 Dec 2002 07:41:21 -0000	1.2
  @@ -54,6 +54,7 @@
   package org.apache.tools.ant.gui.modules.edit;
   
   import org.apache.tools.ant.gui.acs.ACSElement;
  +import org.apache.tools.ant.gui.acs.BaseBeanInfo;
   import javax.swing.tree.DefaultTreeCellRenderer;
   import javax.swing.JTree;
   import javax.swing.ImageIcon;
  @@ -81,7 +82,8 @@
   
           try {
               BeanInfo info = Introspector.getBeanInfo(value.getClass());
  -            Image icon = info.getIcon(BeanInfo.ICON_COLOR_16x16);
  +            Image icon = info.getIcon((expanded?BaseBeanInfo.ICON_COLOR_16x16_OPEN:BeanInfo.ICON_COLOR_16x16));
  +
               setIcon(icon == null ? null : new ImageIcon(icon));
   
               if(value instanceof ACSElement) {
  
  
  
  1.2       +59 -1     jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/xml/dtd/DOMAttributes.java
  
  Index: DOMAttributes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/xml/dtd/DOMAttributes.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DOMAttributes.java	4 May 2001 18:57:32 -0000	1.1
  +++ DOMAttributes.java	30 Dec 2002 07:41:21 -0000	1.2
  @@ -54,7 +54,10 @@
   
   package org.apache.tools.ant.gui.xml.dtd;
   
  +import java.io.IOException;
  +
   import java.util.Properties;
  +import java.util.Enumeration;
   
   /**
    * Represents the attributes defined by the DTD.
  @@ -100,4 +103,59 @@
           }
           return _element.getAttributes().getOptionalAttributes();
       }
  -}
  +    /**
  +     * Retrun the class associated with the tag
  +     *
  +     * @return Class
  +     */
  +    public Class getTagClass()  {
  +        return lookupByName(_element.getName());
  +    }
  +
  +    /**
  +     * Lookup the associated class name for dynamic editor creation.
  +     *
  +     * @param tag name
  +     * @return Class class of the tag
  +     */
  +    private Class lookupByName(String name) {
  +        Class retval = null;
  +        try {
  +            Properties tasks = new Properties();
  +            tasks.load(
  +                    org.apache.tools.ant.taskdefs.Ant.class.getResourceAsStream(
  +                    "defaults.properties"));
  +
  +            retval = lookup(name, tasks);
  +
  +            if(retval == null)  {
  +
  +                Properties types = new Properties();
  +                types.load(
  +                        org.apache.tools.ant.types.DataType.class.getResourceAsStream(
  +                        "defaults.properties"));
  +
  +                retval = lookup(name, types);
  +            }
  +        }
  +        catch(IOException exp)  {
  +            exp.printStackTrace();
  +        }
  +
  +        return retval;
  +    }
  +
  +    private Class lookup(String name, Properties defaults)  {
  +
  +        Class retval = null;
  +        try {
  +            retval = Class.forName(defaults.getProperty(name));
  +        }
  +        catch(ClassNotFoundException exp)   {
  +        }
  +        catch(NoClassDefFoundError err)   {
  +        }
  +
  +        return retval;
  +    }
  +}
  \ No newline at end of file
  
  
  
  1.3       +10 -83    jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSTaskElement.java
  
  Index: ACSTaskElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSTaskElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSTaskElement.java	4 May 2001 18:48:09 -0000	1.2
  +++ ACSTaskElement.java	30 Dec 2002 07:41:21 -0000	1.3
  @@ -53,94 +53,21 @@
    */
   package org.apache.tools.ant.gui.acs;
   
  -import java.util.Enumeration;
  -import java.util.Properties;
  -
  -import org.apache.tools.ant.gui.xml.DOMNode;
  -import org.apache.tools.ant.gui.xml.NamedDOMNodeMap;
  -
   /**
    * Element containing a property definition.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @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 class ACSTaskElement extends ACSNamedElement {
  +    /**
  +     * Default ctor.
  +     *
  +     */
       public ACSTaskElement() {
       }
  -
  -	/** 
  -	 * Get the task type.
  -	 * 
  -	 * @return Task type.
  -	 */
  -    public String getTaskType() {
  +    
  +    public String getDisplayName() {
           return getTagName();
       }
  -
  -	/** 
  -	 * 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();
  -
  -        NamedDOMNodeMap attribs = getAttributes();
  -        for(int i = 0, len = attribs.getLength(); i < len; i++) {
  -            DOMNode 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.2       +36 -29    jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/BaseBeanInfo.java
  
  Index: BaseBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/BaseBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseBeanInfo.java	8 Apr 2001 23:42:09 -0000	1.1
  +++ BaseBeanInfo.java	30 Dec 2002 07:41:21 -0000	1.2
  @@ -65,62 +65,71 @@
    * @version $Revision$ 
    * @author Simeon Fitch 
    */
  -abstract class BaseBeanInfo extends SimpleBeanInfo {
  +public abstract class BaseBeanInfo extends SimpleBeanInfo {
       /** Property name for specifiying a sorting order. */
       public static final String SORT_ORDER = DynamicCustomizer.SORT_ORDER;
  +    public static final int ICON_COLOR_16x16_OPEN = 128;
  +    
       /** Resource provider for bean info. */
       private static ResourceManager _resources = new ResourceManager();
   
       /** Icon for this. */
       private Image _icon = null;
  +    private Image _icon_open = null;
   
  -	/** 
  -	 * Default ctor.
  -	 * 
  -	 */
  +    /** 
  +     * Default ctor.
  +     * 
  +     */
       protected BaseBeanInfo() {
           // Load the icon.
           ImageIcon img = _resources.getImageIcon(getClass(), "icon");
           if(img != null) {
               _icon = img.getImage();
           }
  +        img = _resources.loadImageIcon(_resources.getString(getClass(), "icon_open"));
  +        if(img != null) {
  +            _icon_open = img.getImage();
  +        }
       }
   
  -	/** 
  -	 * Get the local resources.
  -	 * 
  -	 * @return Resources.
  -	 */
  +    /** 
  +     * Get the local resources.
  +     * 
  +     * @return Resources.
  +     */
       ResourceManager getResources() {
           return _resources;
       }
   
  -	/** 
  -	 * Get the bean descriptor.
  -	 * 
  -	 * @return Bean descriptor.
  -	 */
  +    /** 
  +     * 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.
  -	 */
  +    /** 
  +     * 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.
  +        if (kind == ICON_COLOR_16x16_OPEN && _icon_open != null)
  +            return _icon_open;
           return _icon;
       }
   
  -	/** 
  -	 * Set the sorting order property of the given objects based
  +    /** 
  +     * 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.
  -	 */
  +     * 
  +     * @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));
  @@ -154,6 +163,4 @@
        * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
        */
       public abstract PropertyDescriptor[] getPropertyDescriptors();
  -
  -
   }
  
  
  
  1.3       +48 -1     jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/acs-element.properties
  
  Index: acs-element.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/acs-element.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- acs-element.properties	4 May 2001 18:48:20 -0000	1.2
  +++ acs-element.properties	30 Dec 2002 07:41:21 -0000	1.3
  @@ -11,6 +11,53 @@
   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
   
  +# Task elements
  +ant=org.apache.tools.ant.gui.acs.ACSTaskElement
  +antcall=org.apache.tools.ant.gui.acs.ACSTaskElement
  +available=org.apache.tools.ant.gui.acs.ACSTaskElement
  +chmod=org.apache.tools.ant.gui.acs.ACSTaskElement
  +copy=org.apache.tools.ant.gui.acs.ACSTaskElement
  +cvs=org.apache.tools.ant.gui.acs.ACSTaskElement
  +delete=org.apache.tools.ant.gui.acs.ACSTaskElement
  +deltree=org.apache.tools.ant.gui.acs.ACSTaskElement
  +echo=org.apache.tools.ant.gui.acs.ACSTaskElement
  +exec=org.apache.tools.ant.gui.acs.ACSTaskElement
  +expand=org.apache.tools.ant.gui.acs.ACSTaskElement
  +fail=org.apache.tools.ant.gui.acs.ACSTaskElement
  +filter=org.apache.tools.ant.gui.acs.ACSTaskElement
  +get=org.apache.tools.ant.gui.acs.ACSTaskElement
  +gzip=org.apache.tools.ant.gui.acs.ACSTaskElement
  +fixcrlf=org.apache.tools.ant.gui.acs.ACSTaskElement
  +jar=org.apache.tools.ant.gui.acs.ACSTaskElement
  +java=org.apache.tools.ant.gui.acs.ACSTaskElement
  +javac=org.apache.tools.ant.gui.acs.ACSTaskElement
  +javadoc=org.apache.tools.ant.gui.acs.ACSTaskElement
  +keysubst=org.apache.tools.ant.gui.acs.ACSTaskElement
  +mail=org.apache.tools.ant.gui.acs.ACSTaskElement
  +mkdir=org.apache.tools.ant.gui.acs.ACSTaskElement
  +recorder=org.apache.tools.ant.gui.acs.ACSTaskElement
  +rename=org.apache.tools.ant.gui.acs.ACSTaskElement
  +replace=org.apache.tools.ant.gui.acs.ACSTaskElement
  +rmic=org.apache.tools.ant.gui.acs.ACSTaskElement
  +tar=org.apache.tools.ant.gui.acs.ACSTaskElement
  +taskdef=org.apache.tools.ant.gui.acs.ACSTaskElement
  +tstamp=org.apache.tools.ant.gui.acs.ACSTaskElement
  +uptodate=org.apache.tools.ant.gui.acs.ACSTaskElement
  +zip=org.apache.tools.ant.gui.acs.ACSTaskElement
   
  +# More task elements
  +p4sync=org.apache.tools.ant.gui.acs.ACSTaskElement
  +p4label=org.apache.tools.ant.gui.acs.ACSTaskElement
  +p4have=org.apache.tools.ant.gui.acs.ACSTaskElement
  +p4submit=org.apache.tools.ant.gui.acs.ACSTaskElement
  +p4edit=org.apache.tools.ant.gui.acs.ACSTaskElement
  +p4change=org.apache.tools.ant.gui.acs.ACSTaskElement
  +junit=org.apache.tools.ant.gui.acs.ACSTaskElement
  +ddcreator=org.apache.tools.ant.gui.acs.ACSTaskElement
  +ejbc=org.apache.tools.ant.gui.acs.ACSTaskElement
  +wlrun=org.apache.tools.ant.gui.acs.ACSTaskElement
  +wlstop=org.apache.tools.ant.gui.acs.ACSTaskElement
  +ejbjar=org.apache.tools.ant.gui.acs.ACSTaskElement
  +weblogic=org.apache.tools.ant.gui.acs.ACSTaskElement
  +TOPLink=org.apache.tools.ant.gui.acs.ACSTaskElement
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message