chrisw      2003/01/13 05:31:17

  Modified:    src/java/org/apache/tools/ant/gui/acs ACSFactory.java
                        ACSNamedElement.java ACSProjectElement.java
                        ACSPropertyElement.java
                        ACSPropertyElementBeanInfo.java
                        ACSTargetElementBeanInfo.java
                        acs-element.properties
               src/java/org/apache/tools/ant/gui/command NewElementCmd.java
                        NewElementDlg.java
  Added:       src/java/org/apache/tools/ant/gui/acs
                        ACSIntrospectedElement.java
                        ACSIntrospectedElementBeanInfo.java
  Log:
  Introducing Introspection.
  
  Revision  Changes    Path
  1.3       +134 -10   
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSFactory.java
  
  Index: ACSFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSFactory.java   4 May 2001 18:48:11 -0000       1.2
  +++ ACSFactory.java   13 Jan 2003 13:31:17 -0000      1.3
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -62,9 +62,17 @@
   
   import java.util.Enumeration;
   import java.util.Properties;
  +import java.util.Collections;
  +import java.util.Map;
  +import java.util.HashMap;
   
   import javax.xml.parsers.ParserConfigurationException;
   
  +import org.apache.tools.ant.IntrospectionHelper;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.Target;
  +import org.apache.tools.ant.taskdefs.Property;
  +
   import org.apache.tools.ant.gui.xml.DOMDocument;
   import org.apache.tools.ant.gui.xml.DOMNodeManager;
   
  @@ -74,33 +82,77 @@
    * Factory for loading Ant Construction set elements.
    * 
    * @version $Revision$ 
  - * @author Simeon Fitch 
  + * @author Simeon Fitch, Christoph Wilhelms<a href="mailto:[EMAIL 
PROTECTED]">[EMAIL PROTECTED]</a>
    */
   public class ACSFactory {
       /** Singleton instance of the factory. */
       private static ACSFactory _instance = null;
   
       /** Element maping. */
  -    private static final Properties _elementMap = new Properties();
  +    private Properties _elementMap = new Properties();                       
 //(name -> ACSClassName)        Probably deprecated soon...
  +
  +    private Properties _taskClassMap = new Properties();                     
 // (name -> source className)
  +    private Properties _elementClassMap = new Properties();                  
 // (name -> source className)
  +    private Map _classInfoMap = Collections.synchronizedMap (new HashMap 
()); // (className -> attributes/subElements) 
   
  -    static {
  +    
  +    /**
  +     * The Main introspection happens here! Ofcourse there is a lot of 
"cleaning up" to do... 
  +     * Additionally: handling more default properties, custom Tasks, etc.
  +     */
  +    private void init() {
           try {
  +            String antProjectName = Project.class.getName();
  +            String antTargetName = Target.class.getName();
  +            String antPropertyName = Property.class.getName();
  +            analyzeClass(antProjectName);
  +            analyzeClass(antTargetName);
  +
               // 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.
  +            _taskClassMap.load(org.apache.tools.ant.taskdefs.Ant.class.
                             getResourceAsStream("defaults.properties"));
  -            Enumeration enum = _elementMap.propertyNames();
  +            _taskClassMap.setProperty("property", antPropertyName);
  +            Enumeration enum = _taskClassMap.propertyNames();
               while(enum.hasMoreElements()) {
                   String name = (String) enum.nextElement();
  +
  +                // Directly collect Introspection Info for nown types
  +                analyzeClass(_taskClassMap.getProperty(name));
  +
                   // XXX the name of the class needs to be stored externally.
  +                _elementMap.setProperty(name, 
"org.apache.tools.ant.gui.acs.ACSTaskElement");
  +            }
  +            _elementMap.setProperty("property", 
"org.apache.tools.ant.gui.acs.ACSPropertyElement");
  +            
  +            Properties tempElementClassMap = new Properties();
  +            
tempElementClassMap.load(org.apache.tools.ant.types.FileSet.class.
  +                         getResourceAsStream("defaults.properties"));
  +            _elementClassMap.putAll(tempElementClassMap);
  +            
((ClassInfo)_classInfoMap.get(antTargetName))._subelements.putAll(tempElementClassMap);
  +            
((ClassInfo)_classInfoMap.get(antProjectName))._subelements.putAll(tempElementClassMap);
  +            
((ClassInfo)_classInfoMap.get(antTargetName))._subelements.put("property",antPropertyName);
  +            
((ClassInfo)_classInfoMap.get(antProjectName))._subelements.put("property",antPropertyName);
  +            enum = _elementClassMap.propertyNames();
  +            while(enum.hasMoreElements()) {
  +                String name = (String) enum.nextElement();
  +
  +                // Directly collect Introspection Info for nown types
  +                analyzeClass(_elementClassMap.getProperty(name));
                   _elementMap.setProperty(
  -                    name, 
"org.apache.tools.ant.gui.acs.ACSDtdDefinedElement");
  +                    name, 
"org.apache.tools.ant.gui.acs.ACSIntrospectedElement");
               }
   
               // Then we add/override the local definitions.
               _elementMap.load(ACSFactory.class.
                                getResourceAsStream("acs-element.properties"));
  +
  +            _elementClassMap.setProperty("project", antProjectName);
  +            _elementClassMap.setProperty("target", antTargetName);
  +
  +            System.out.println(_taskClassMap.toString());
  +            // Finally we scan the entire classpath for additional classes 
and custom Tasks.
           }
           catch(Throwable ex) {
               // If something wrong happens here we can't do much more...
  @@ -109,14 +161,77 @@
           }
       }
   
  +    public void analyzeClass(String qualifiedClassName) {
  +        // Check if info already has been introspected.
  +        if (_classInfoMap.containsKey(qualifiedClassName)) return;
  +        try {
  +            // Create ClassInfo and insert in classInfoMap
  +            ClassInfo info = new ClassInfo();
  +            _classInfoMap.put(qualifiedClassName, "");
  +            // Create and introspect Class
  +            Class clazz = Class.forName(qualifiedClassName);
  +            IntrospectionHelper helper = 
IntrospectionHelper.getHelper(clazz);
  +            info._isContainer = helper.supportsCharacters();
  +            // Lookup Attributes
  +            Enumeration e = helper.getAttributes();
  +            if (e.hasMoreElements()) {
  +                info._attributes = new HashMap();
  +                while (e.hasMoreElements()) {
  +                    String name = (String) e.nextElement();
  +                    String type = helper.getAttributeType(name).getName();
  +                    if 
((org.apache.tools.ant.Task.class.isAssignableFrom(clazz)) &&
  +                        ((name.equals ("location") && type.equals 
("org.apache.tools.ant.Location"))/* || 
  +                         (name.equals ("taskname") && type.equals 
("java.lang.String")) || 
  +                         (name.equals ("description") && type.equals 
("java.lang.String"))*/)) { 
  +                        continue;
  +                    }
  +//                    info._attributes.put(name, type);  // for debug 
purpose only
  +                    info._attributes.put(name, "");
  +                }
  +            }
  +            else info._attributes = null;
  +            // Lookup Subelements
  +            e = helper.getNestedElements();
  +            info._subelements = new HashMap();
  +            while (e.hasMoreElements()) {
  +                try {
  +                    String name = (String) e.nextElement();
  +                    Class subClazz = helper.getElementType(name);
  +                    info._subelements.put(name, subClazz.getName());
  +                    _elementClassMap.setProperty(name, subClazz.getName());
  +                    // ... and analyze that class!
  +                    analyzeClass(subClazz.getName());
  +                } catch (RuntimeException re) {}
  +            }
  +            _classInfoMap.remove(qualifiedClassName);
  +            _classInfoMap.put(qualifiedClassName, info);
  +        }
  +        catch (Throwable e) {}
  +    }
  +        
       /** 
        * Default ctor.
        * 
        */
       private ACSFactory() {
  -
  +        init();
       }
  -
  +    
  +    public ClassInfo getClassInfo(String key, boolean forTarget) {
  +        if (!_elementMap.containsKey(key))
  +            return null; // We have no clue how to optain this information!
  +        String className = null;
  +        if (forTarget) className = (String)_taskClassMap.get(key);
  +        if (className == null) className = (String)_elementClassMap.get(key);
  +        if (className == null) className = (String)_taskClassMap.get(key);
  +        if (className == null) return null;
  +        return (ClassInfo)_classInfoMap.get(className);
  +    }
  +    
  +    public Map getTasks() {
  +        return _taskClassMap;
  +    }
  +    
       /** 
        * Get an instance of the factory.
        * 
  @@ -276,4 +391,13 @@
           }
       }
   
  +    public class ClassInfo {
  +        public Map _attributes; 
  +        public Map _subelements; 
  +        public boolean _isContainer;
  +        
  +        public String toString () {
  +            return "ClassInfo[attributes=" + _attributes + ",subs=" + 
_subelements + "]";
  +        }
  +    }
   }
  
  
  
  1.3       +4 -4      
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSNamedElement.java
  
  Index: ACSNamedElement.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSNamedElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSNamedElement.java      26 Jul 2001 07:07:40 -0000      1.2
  +++ ACSNamedElement.java      13 Jan 2003 13:31:17 -0000      1.3
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -59,9 +59,9 @@
    * Class representing an element with a name and description.
    * 
    * @version $Revision$ 
  - * @author Simeon Fitch 
  + * @author Simeon Fitch, Christoph Wilhelms
    */
  -public class ACSNamedElement extends ACSDtdDefinedElement {
  +public class ACSNamedElement extends ACSIntrospectedElement {
       /** The 'name' property name. */
       public static final String NAME = "name";
       /** The discription property name. */
  
  
  
  1.4       +50 -51    
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSProjectElement.java
  
  Index: ACSProjectElement.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSProjectElement.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ACSProjectElement.java    4 Jun 2001 18:49:21 -0000       1.3
  +++ ACSProjectElement.java    13 Jan 2003 13:31:17 -0000      1.4
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -58,9 +58,9 @@
   
   /**
    * Class representing a project element in the build file.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @version $Revision$
  + * @author Simeon Fitch, Christoph Wilhelms
    */
   public class ACSProjectElement extends ACSNamedElement {
       /** The 'default' property name. */
  @@ -71,75 +71,75 @@
       public static final String LOCATION = "location";
       /** The location where this project is persisted. */
       private URL _location = null;
  -
  -     /** 
  -      * Default ctor.
  -      * 
  -      */
  +    
  +    /**
  +     * Default ctor.
  +     *
  +     */
       public ACSProjectElement() {
       }
  -
  -     /** 
  -      * Get the type that this BeanInfo represents.
  -      * 
  -      * @return Type.
  -      */
  +    
  +    /**
  +     * 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.
  -      */
  +    
  +    /**
  +     * 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.
  -      */
  +    
  +    /**
  +     * 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
  -      */
  +    
  +    /**
  +     * 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.
  -      */
  +    
  +    /**
  +     * 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) {
  @@ -147,10 +147,10 @@
           _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) {
  @@ -164,14 +164,14 @@
           }
       }
       
  -    /** 
  +    /**
        * @return true if the project has been modified,
        */
       public boolean isModified() {
           return getOwnerDocument().isModified();
       }
       
  -    /** 
  +    /**
        * Sets the modified flag.
        *
        * @param modified the new value
  @@ -179,5 +179,4 @@
       public void setModified(boolean modified) {
           getOwnerDocument().setModified(modified);
       }
  -   
   }
  
  
  
  1.3       +78 -52    
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSPropertyElement.java
  
  Index: ACSPropertyElement.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSPropertyElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSPropertyElement.java   26 Jul 2001 07:07:40 -0000      1.2
  +++ ACSPropertyElement.java   13 Jan 2003 13:31:17 -0000      1.3
  @@ -53,35 +53,37 @@
    */
   package org.apache.tools.ant.gui.acs;
   
  +import org.apache.tools.ant.gui.xml.DOMAttributes;
  +
   /**
    * Element containing a property definition.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @version $Revision$
  + * @author Simeon Fitch
    */
  -public class ACSPropertyElement extends ACSDtdDefinedElement {
  +public class ACSPropertyElement extends ACSIntrospectedElement {
       /** 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.
  -      * 
  -      */
  +    
  +    /**
  +     * Default ctor.
  +     *
  +     */
       public ACSPropertyElement() {
       }
  -
  -     /** 
  -      * Get the display name of this.
  -      * 
  -      * @return Display name.
  -      */
  +    
  +    /**
  +     * Get the display name of this.
  +     *
  +     * @return Display name.
  +     */
       public String getDisplayName() {
           String file = getFile();
  -
  +        
           if(file == null || file.trim().length() == 0) {
               return getName();
           }
  @@ -89,64 +91,88 @@
               return "file: " + file;
           }
       }
  -
  -     /** 
  -      * Get the property name.
  -      * 
  -      * @return Property name.
  -      */
  +    
  +    /**
  +     * Get the property name.
  +     *
  +     * @return Property name.
  +     */
       public String getName() {
           return getAttribute(NAME);
       }
  -
  -     /** 
  -      * Set the property name.
  -      * 
  -      * @param name Property 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.
  -      */
  +    
  +    /**
  +     * Get the property value.
  +     *
  +     * @return Property value.
  +     */
       public String getValue() {
           return getAttribute(VALUE);
       }
  -
  -     /** 
  -      * Set the property value.
  -      * 
  -      * @param name Property 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.
  -      */
  +    
  +    /**
  +     * Get the external property file.
  +     *
  +     * @return Property file.
  +     */
       public String getFile() {
           return getAttribute(FILE);
       }
  -
  -     /** 
  -      * Set the external property file.
  -      * 
  -      * @param name Property 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);
  +    }
  +
  +    /**
  +     * Overridden to handle the default Attributes
  +     *
  +     * @return Name-value mappings.
  +     */
  +    public DOMAttributes getNamedValues() {
  +        DOMAttributes d = super.getNamedValues();
  +
  +        d.remove("file"); d.remove("value"); d.remove("name");
  +        
  +        String a[] = d.getAttributes();
  +        String b[] = new String[a.length-3];
  +        int j = 0;
  +        for (int i=0; i<a.length;i++) {
  +            if (!(a[i].equals("file") || a[i].equals("value") || 
a[i].equals("name"))) {
  +                b[j] = a[i];
  +                j++;
  +            }
  +        }
  +        d.setAttributes(b);
  +        
  +        return d;
       }
   }
  
  
  
  1.2       +59 -40    
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSPropertyElementBeanInfo.java
  
  Index: ACSPropertyElementBeanInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSPropertyElementBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSPropertyElementBeanInfo.java   8 Apr 2001 23:42:09 -0000       1.1
  +++ ACSPropertyElementBeanInfo.java   13 Jan 2003 13:31:17 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -53,78 +53,97 @@
    */
   package org.apache.tools.ant.gui.acs;
   
  +import java.beans.IntrospectionException;
  +import java.beans.PropertyDescriptor;
  +import java.beans.PropertyEditorManager;
  +
   import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
  -import java.beans.*;
  +import org.apache.tools.ant.gui.xml.DOMAttributes;
  +import org.apache.tools.ant.gui.modules.edit.AttributePropertyEditor;
   
   /**
    * BeanInfo for the ACSPropertyElement class.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @version $Revision$
  + * @author Simeon Fitch, Christoph Wilhelms<a href="mailto:[EMAIL 
PROTECTED]">Christoph Wilhelms</a>
    */
   public class ACSPropertyElementBeanInfo extends BaseBeanInfo {
  -     /** 
  -      * Default ctor.
  -      * 
  -      */
  +    /**
  +     * Default ctor.
  +     *
  +     */
       public ACSPropertyElementBeanInfo() {
       }
  -
  -     /** 
  -      * Get the type that this BeanInfo represents.
  -      * 
  -      * @return Type.
  -      */
  +    
  +    /**
  +     * Get the type that this BeanInfo represents.
  +     *
  +     * @return Type.
  +     */
       public Class getType() {
           return ACSPropertyElement.class;
       }
  -
  -     /** 
  -      * Get the customizer type.
  -      * 
  -      * @return Customizer type.
  -      */
  +    
  +    /**
  +     * Get the customizer type.
  +     *
  +     * @return Customizer type.
  +     */
       public Class getCustomizerType() {
           return Customizer.class;
       }
  -
  -     /** 
  -      * Get the property descriptors.
  -      * 
  +    
  +    /**
  +     * 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)
  +                new PropertyDescriptor(ACSPropertyElement.FILE,
  +                ACSPropertyElement.class),
  +                new PropertyDescriptor(ACSPropertyElement.NAME,
  +                ACSPropertyElement.class),
  +                new PropertyDescriptor(ACSPropertyElement.VALUE,
  +                ACSPropertyElement.class),
  +                new PropertyDescriptor(ACSPropertyElement.NAMED_VALUES,
  +                ACSPropertyElement.class),
  +                new PropertyDescriptor(ACSPropertyElement.XML_STRING,
  +                ACSPropertyElement.class,
  +                "getXMLString", null)
               };
  -
  +            
               retval[0].setDisplayName(getResources().getString(
  -                getClass(),ACSPropertyElement.FILE));
  +            getClass(),ACSPropertyElement.FILE));
               retval[1].setDisplayName(getResources().getString(
  -                getClass(),ACSPropertyElement.NAME));
  +            getClass(),ACSPropertyElement.NAME));
               retval[2].setDisplayName(getResources().getString(
  -                getClass(),ACSPropertyElement.VALUE));
  -
  +            getClass(),ACSPropertyElement.VALUE));
  +            retval[3].setDisplayName(getResources().getString(
  +            getClass(),ACSPropertyElement.NAMED_VALUES));
  +            retval[4].setDisplayName(getResources().getString(
  +            getClass(),ACSPropertyElement.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(
  +            DOMAttributes.class, AttributePropertyEditor.class);
  +        }
  +        
           public Customizer() {
               super(ACSPropertyElement.class);
           }
  
  
  
  1.2       +59 -49    
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSTargetElementBeanInfo.java
  
  Index: ACSTargetElementBeanInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSTargetElementBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSTargetElementBeanInfo.java     8 Apr 2001 23:42:09 -0000       1.1
  +++ ACSTargetElementBeanInfo.java     13 Jan 2003 13:31:17 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -54,96 +54,106 @@
   package org.apache.tools.ant.gui.acs;
   import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
   
  -import java.beans.*;
  +import java.beans.IntrospectionException;
  +import java.beans.PropertyDescriptor;
  +import java.beans.PropertyEditorManager;
  +
  +import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
  +import org.apache.tools.ant.gui.xml.DOMAttributes;
  +import org.apache.tools.ant.gui.modules.edit.AttributePropertyEditor;
   
   /**
    * BeanInfo for the ACSTargetElement class.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @version $Revision$
  + * @author Simeon Fitch, Christoph Wilhelms<a href="mailto:[EMAIL 
PROTECTED]">Christoph Wilhelms</a>
    */
   public class ACSTargetElementBeanInfo extends BaseBeanInfo {
  -     /** 
  -      * Default ctor.
  -      * 
  -      */
  +    /**
  +     * Default ctor.
  +     *
  +     */
       public ACSTargetElementBeanInfo() {
       }
  -
  -     /** 
  -      * Get the type that this BeanInfo represents.
  -      * 
  -      * @return Type.
  -      */
  +    
  +    /**
  +     * Get the type that this BeanInfo represents.
  +     *
  +     * @return Type.
  +     */
       public Class getType() {
           return ACSTargetElement.class;
       }
  -
  -     /** 
  -      * Get the customizer type.
  -      * 
  -      * @return Customizer type.
  -      */
  +    
  +    /**
  +     * Get the customizer type.
  +     *
  +     * @return Customizer type.
  +     */
       public Class getCustomizerType() {
           return Customizer.class;
       }
  -
  -     /** 
  -      * Get the property descriptors.
  -      * 
  +    
  +    /**
  +     * 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.NAME,
  +                ACSTargetElement.class),
                   new PropertyDescriptor(ACSTargetElement.DESCRIPTION,
  -                                       ACSTargetElement.class),
  +                ACSTargetElement.class),
                   new PropertyDescriptor(ACSTargetElement.DEPENDS,
  -                                       ACSTargetElement.class,
  -                                       "getClone", "copyDependsFromTarget"),
  +                ACSTargetElement.class,
  +                "getClone", "copyDependsFromTarget"),
                   new PropertyDescriptor(ACSTargetElement.IF,
  -                                       ACSTargetElement.class),
  +                ACSTargetElement.class),
                   new PropertyDescriptor(ACSTargetElement.UNLESS,
  -                                       ACSTargetElement.class),
  -                new PropertyDescriptor(ACSTargetElement.XML_STRING, 
  -                                       ACSTargetElement.class,
  -                                       "getXMLString", null)
  +                ACSTargetElement.class),
  +/*                new PropertyDescriptor(ACSPropertyElement.NAMED_VALUES,    
    // Prepared for future named values
  +                ACSPropertyElement.class), */
  +                new PropertyDescriptor(ACSTargetElement.XML_STRING,
  +                ACSTargetElement.class,
  +                "getXMLString", null)
               };
  -
  +            
               // Set display names.
               retval[0].setDisplayName(getResources().getString(
  -                getClass(),ACSTargetElement.NAME));
  +            getClass(),ACSTargetElement.NAME));
               retval[1].setDisplayName(getResources().getString(
  -                getClass(),ACSTargetElement.DESCRIPTION));
  +            getClass(),ACSTargetElement.DESCRIPTION));
               retval[2].setDisplayName(getResources().getString(
  -                getClass(),ACSTargetElement.DEPENDS));
  +            getClass(),ACSTargetElement.DEPENDS));
               retval[3].setDisplayName(getResources().getString(
  -                getClass(),ACSTargetElement.IF));
  +            getClass(),ACSTargetElement.IF));
               retval[4].setDisplayName(getResources().getString(
  -                getClass(),ACSTargetElement.UNLESS));
  +            getClass(),ACSTargetElement.UNLESS));
  +/*            retval[5].setDisplayName(getResources().getString(             
    // Prepared for future named values
  +            getClass(),ACSPropertyElement.NAMED_VALUES));*/
               retval[5].setDisplayName(getResources().getString(
  -                getClass(),ACSTargetElement.XML_STRING));
  -
  +            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);
  +            org.apache.tools.ant.gui.acs.ACSTargetElement.class, 
org.apache.tools.ant.gui.modules.edit.DependentTargetPropertyEditor.class);
           }
           
           public Customizer() {
  
  
  
  1.4       +2 -51     
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- acs-element.properties    30 Dec 2002 07:41:21 -0000      1.3
  +++ acs-element.properties    13 Jan 2003 13:31:17 -0000      1.4
  @@ -5,59 +5,10 @@
   # The default node
   *Node=org.apache.tools.ant.gui.acs.ACSDefaultElement
   # The default element
  -*Element=org.apache.tools.ant.gui.acs.ACSDtdDefinedElement
  +*Element=org.apache.tools.ant.gui.acs.ACSIntrospectedElement
   
   # 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 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
  +task=org.apache.tools.ant.gui.acs.ACSTaskElement
  
  
  
  1.1                  
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSIntrospectedElement.java
  
  Index: ACSIntrospectedElement.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 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 [EMAIL PROTECTED]
   *
   * 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.util.Enumeration;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.tools.ant.gui.command.NewElementCmd;
  
  import org.apache.tools.ant.gui.util.Collections;
  
  import org.apache.tools.ant.gui.xml.DOMNode;
  import org.apache.tools.ant.gui.xml.DOMAttributes;
  import org.apache.tools.ant.gui.xml.NamedDOMNodeMap;
  
  /**
   * An Introspected element.
   *
   * @version $Revision: 1.1 $
   * @author Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>
   */
  public class ACSIntrospectedElement 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";
      
      /** Our menu string */
      private String[] _menuString = null;
      
      /**
       * Default ctor.
       *
       */
      public ACSIntrospectedElement() {
      }
      
      /**
       * 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) {
              DOMNode 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++) {
                  DOMNode testNode =
                  getAttributes().getNamedItem(DISPLAY_ATTRIBUTES[i]);
                  if (testNode != null) {
                      name += ": " + testNode.getNodeValue();
                      break;
                  }
              }
          }
          
          return name;
      }
      
      /**
       * 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 DOMAttributes getNamedValues() {
          Map m = ACSFactory.getInstance().getClassInfo(getTagName(), (this 
instanceof ACSTargetElement))._attributes;
          DOMAttributes d = new DOMAttributes(m);
  
          NamedDOMNodeMap attribs = getAttributes();
          for(int i = 0, len = attribs.getLength(); i < len; i++) {
              DOMNode n = attribs.item(i);
              d.setProperty(n.getNodeName(), n.getNodeValue());
          }
          return d;
      }
      
      
      /**
       * 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(DOMAttributes 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.
          
          DOMAttributes old = (DOMAttributes) 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;
          }
          
          if (isProject) {
              _menuString = new String[1];
              _menuString[_menuString.length-1] = "newElement";
          } else {
              // Add the delete and generic create commands
              _menuString = new String[(2)];
              _menuString[_menuString.length-1] = "deleteElement";
              _menuString[_menuString.length-2] = "newElement";
          }
          
          String[] possibleChildren = getPossibleChildren(TYPE_ELEMENTS);
          int dim = possibleChildren.length;
          if (dim > 0) dim++;
          if (!isProject) dim++;
          
          int j = 0;
          _menuString = new String[dim];
          if (possibleChildren.length > 0) {
              _menuString[j] = "newElement";
              j++;
          }
          if (!isProject) {
              _menuString[j] = "deleteElement";
              j++;
          }
          for (int i=0; i< possibleChildren.length;i++) {
              _menuString[j] = possibleChildren[i];
              j++;
          }
          
          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";
      }
      
      public final static int ALL_ELEMENTS = 3;
      public final static int TASK_ELEMENTS = 1;
      public final static int TYPE_ELEMENTS = 2;
      
      /**
       * Returns a string array which contains this elements
       * possible children.
       *
       * @param childType ACSIntrospectedElement.ALL_ELEMENTS or
       * ACSIntrospectedElement.TASK_ELEMENTS
       * ACSIntrospectedElement.TYPE_ELEMENTS
       */
      public String[] getPossibleChildren(int type) {
          Map m = new java.util.HashMap();
          switch (type) {
              case ALL_ELEMENTS:  m = 
ACSFactory.getInstance().getClassInfo(getTagName(), (this instanceof 
ACSTargetElement))._subelements;
                                  if (this instanceof ACSTargetElement) 
m.putAll(ACSFactory.getInstance().getTasks());
                                  break;
              case TASK_ELEMENTS: if (this instanceof ACSTargetElement) m = 
ACSFactory.getInstance().getTasks();
                                  else m = new java.util.HashMap();
                                  break;
              case TYPE_ELEMENTS: m = 
ACSFactory.getInstance().getClassInfo(getTagName(), (this instanceof 
ACSTargetElement))._subelements;
                                  break;
          }
  
          String a[] = new String[m.keySet().size()];
          int i = 0;
          java.util.Iterator it = m.keySet().iterator();
          while (it.hasNext()) {
              a[i] = (String)it.next();
              i++;
          }
          java.util.Arrays.sort(a);
          return a;
      }
  }
  
  
  
  
  1.1                  
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/acs/ACSIntrospectedElementBeanInfo.java
  
  Index: ACSIntrospectedElementBeanInfo.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 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 [EMAIL PROTECTED]
   *
   * 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.IntrospectionException;
  import java.beans.PropertyDescriptor;
  import java.beans.PropertyEditorManager;
  
  import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
  import org.apache.tools.ant.gui.xml.DOMAttributes;
  import org.apache.tools.ant.gui.modules.edit.AttributePropertyEditor;
  
  /**
   * BeanInfo for the ACSIntrospectedElementBeanInfo class.
   *
   * @version $Revision: 1.1 $
   * @author Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">Christoph 
Wilhelms</a>
   */
  public class ACSIntrospectedElementBeanInfo extends BaseBeanInfo {
      /**
       * Default ctor.
       *
       */
      public ACSIntrospectedElementBeanInfo() {
      }
      
      /**
       * Get the type that this BeanInfo represents.
       *
       * @return Type.
       */
      public Class getType() {
          return ACSIntrospectedElement.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(ACSIntrospectedElement.TASK_TYPE,
                  ACSIntrospectedElement.class,
                  "getTaskType", null),
                  new PropertyDescriptor(ACSIntrospectedElement.NAMED_VALUES,
                  ACSIntrospectedElement.class),
                  new PropertyDescriptor(ACSIntrospectedElement.XML_STRING,
                  ACSIntrospectedElement.class,
                  "getXMLString", null)
              };
              int pos = 0;
              retval[pos++].setDisplayName(getResources().getString(
              getClass(),ACSIntrospectedElement.TASK_TYPE));
              retval[pos++].setDisplayName(getResources().getString(
              getClass(),ACSIntrospectedElement.NAMED_VALUES));
              retval[pos++].setDisplayName(getResources().getString(
              getClass(),ACSIntrospectedElement.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(
              DOMAttributes.class, AttributePropertyEditor.class);
          }
          
          public Customizer() {
              super(ACSIntrospectedElement.class);
          }
      }
  }
  
  
  
  
  1.4       +31 -34    
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/command/NewElementCmd.java
  
  Index: NewElementCmd.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/command/NewElementCmd.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NewElementCmd.java        4 May 2001 18:50:13 -0000       1.3
  +++ NewElementCmd.java        13 Jan 2003 13:31:17 -0000      1.4
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -57,7 +57,7 @@
   
   import java.util.EventObject;
   
  -import org.apache.tools.ant.gui.acs.ACSDtdDefinedElement;
  +import org.apache.tools.ant.gui.acs.ACSIntrospectedElement;
   import org.apache.tools.ant.gui.acs.ACSElement;
   import org.apache.tools.ant.gui.acs.ACSFactory;
   
  @@ -73,41 +73,41 @@
   
   /**
    * Command for creating a new propertyh.
  - * 
  - * @version $Revision$ 
  - * @author Simeon Fitch 
  + *
  + * @version $Revision$
  + * @author Simeon Fitch, Christoph Wilhelms
    */
   public class NewElementCmd extends AbstractCommand {
  -    /** New count for this session. Used to create default names, 
  +    /** 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.
  -      */ 
  +    /**
  +     * 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();
  +        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();
  @@ -116,53 +116,50 @@
           }
           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;
  +            ACSIntrospectedElement dtde = (ACSIntrospectedElement) e;
               NewElementDlg dlg = new NewElementDlg(
  -                getContext().getParentFrame(), true);
  +            getContext().getParentFrame(), true);
               dlg.setLists(
  -                dtde.getPossibleChildren(ANTDocumentType.CORE_ELEMENT),
  -                dtde.getPossibleChildren(ANTDocumentType.OPTIONAL_ELEMENT) );
  +            dtde.getPossibleChildren(ACSIntrospectedElement.TASK_ELEMENTS),
  +            dtde.getPossibleChildren(ACSIntrospectedElement.TYPE_ELEMENTS) );
               dlg.pack();
               WindowUtils.centerWindow(dlg);
               dlg.setTitle("Select the new element type");
               dlg.setVisible(true);
  -        
  -            // Get the element type 
  +            
  +            // 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);
  +            ACSElement retval =
  +            ACSFactory.getInstance().createElement(e, name);
               getContext().getEventBus().postEvent(
  -                new NewBaseElementEvent(getContext(),  retval));
  +            new NewBaseElementEvent(getContext(),  retval));
           } else {
  -            // Request a refresh so the popup menu is removed 
  +            // Request a refresh so the popup menu is removed
               // from the display.
               getContext().getEventBus().postEvent(
  -                new RefreshDisplayEvent(getContext()));
  +            new RefreshDisplayEvent(getContext()));
           }
       }
  -}
  -
  -
  -
  +}
  \ No newline at end of file
  
  
  
  1.3       +4 -4      
jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/command/NewElementDlg.java
  
  Index: NewElementDlg.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant-antidote/src/java/org/apache/tools/ant/gui/command/NewElementDlg.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NewElementDlg.java        17 Apr 2001 00:24:28 -0000      1.2
  +++ NewElementDlg.java        13 Jan 2003 13:31:17 -0000      1.3
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000 - 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -62,7 +62,7 @@
    * A Dialog which asks for a new xml element's type.
    * 
    * @version $Revision$
  - * @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
  + * @author Nick Davis<a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>, Christoph Wilhelms<a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>
    */
   public class NewElementDlg extends javax.swing.JDialog {
       // Dialog's components
  @@ -263,7 +263,7 @@
           _listScrollPane = new javax.swing.JScrollPane();
           _elementList = new javax.swing.JList();
           _optionalButton = new javax.swing.JCheckBox(
  -            "show optional elements", false);
  +            "show type elements", false);
           getContentPane().setLayout(new java.awt.BorderLayout(10, 10));
           addWindowListener(new java.awt.event.WindowAdapter() {
               public void windowClosing(java.awt.event.WindowEvent evt) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to