ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@locus.apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/event TargetSelectionEvent.java
Date Sat, 11 Nov 2000 04:52:21 GMT
metasim     00/11/10 20:52:21

  Modified:    src/antidote/org/apache/tools/ant/gui LabelFieldGBC.java
                        ProjectProxy.java PropertyEditor.java
               src/antidote/org/apache/tools/ant/gui/acs ACSElement.java
                        ACSFactory.java ACSProjectElement.java
                        ACSProjectElementBeanInfo.java
                        ACSTargetElement.java ACSTargetElementBeanInfo.java
                        BaseBeanInfo.java acs-element.properties
               src/antidote/org/apache/tools/ant/gui/customizer
                        DynamicCustomizer.java
  Removed:     src/antidote/org/apache/tools/ant/gui
                        TargetSelectionModel.java
               src/antidote/org/apache/tools/ant/gui/acs
                        beaninfo.properties
               src/antidote/org/apache/tools/ant/gui/event
                        TargetSelectionEvent.java
  Log:
  Greatly enhanced the property editor, adding new bean info for the
  element types and an additional property editor. The navigator now shows
  project, property, target and task nodes.
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-ant/src/antidote/org/apache/tools/ant/gui/LabelFieldGBC.java
  
  Index: LabelFieldGBC.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/LabelFieldGBC.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LabelFieldGBC.java	2000/11/10 20:41:09	1.1
  +++ LabelFieldGBC.java	2000/11/11 04:52:20	1.2
  @@ -62,7 +62,7 @@
    * Convenience specialization of the GridBagConstraints for laying
    * out label:field pairs.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class LabelFieldGBC extends GridBagConstraints {
  @@ -92,7 +92,7 @@
   		// Set location to left side.
   		gridx = 0;
   		// Move it over to be as close to field as possible.
  -		anchor = EAST;
  +		anchor = NORTHEAST;
   		// Don't take up any extra.
   		weightx = 0.0;
   		return this;
  
  
  
  1.5       +10 -6     jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectProxy.java
  
  Index: ProjectProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectProxy.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProjectProxy.java	2000/11/09 23:14:10	1.4
  +++ ProjectProxy.java	2000/11/11 04:52:20	1.5
  @@ -71,7 +71,7 @@
    * (or other external datamodel) occurs. This class also provides various
    * views into the data model, such as TreeModel, Documenet, etc.
    * 
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon Fitch 
    */
   public class ProjectProxy {
  @@ -85,7 +85,7 @@
       /** The current thread executing a build. */
       private Thread _buildThread = null;
       /** The selection model for selected targets. */
  -    private TargetSelectionModel _selections = null;
  +    private ElementSelectionModel _selections = null;
   
   	/** 
   	 * File loading ctor.
  @@ -104,7 +104,7 @@
   	 */
       private void loadProject() throws IOException {
           _project = ACSFactory.getInstance().load(_file);
  -        _selections = new TargetSelectionModel();
  +        _selections = new ElementSelectionModel();
           _selections.addTreeSelectionListener(new SelectionForwarder());
       }
   
  @@ -169,7 +169,7 @@
   	 * 
   	 * @return Selection model.
   	 */
  -    public TreeSelectionModel getTreeSelectionModel() {
  +    public ElementSelectionModel getTreeSelectionModel() {
           return _selections;
       }
   
  @@ -209,6 +209,10 @@
               }
           }
   
  +        /** 
  +         * Run the build.
  +         * 
  +         */
           public void run() {
               // Add the build listener for
               // dispatching BuildEvent objects to the
  @@ -255,8 +259,8 @@
       /** Forwards selection events to the event bus. */
       private class SelectionForwarder implements TreeSelectionListener {
           public void valueChanged(TreeSelectionEvent e) {
  -            _context.getEventBus().postEvent(new TargetSelectionEvent(
  -                _context, _selections.getSelectedTargets()));
  +            _context.getEventBus().postEvent(new ElementSelectionEvent(
  +                _context, _selections.getSelectedElements()));
           }
       }
   
  
  
  
  1.5       +17 -13    jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java
  
  Index: PropertyEditor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PropertyEditor.java	2000/11/10 20:41:09	1.4
  +++ PropertyEditor.java	2000/11/11 04:52:20	1.5
  @@ -65,13 +65,15 @@
   /**
    * Stub for a property editor.
    *
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon H.K. Fitch 
    */
   class PropertyEditor extends AntEditor {
   
       /** The property sheet. */
       private DynamicCustomizer _customizer = null;
  +    /** Container for the customizer. */
  +    private JPanel _container = null;
   
   	/** 
   	 * Standard ctor.
  @@ -82,23 +84,25 @@
           super(context);
           context.getEventBus().addMember(EventBus.MONITORING, new Handler());
           setLayout(new BorderLayout());
  +        _container = new JPanel(new BorderLayout());
  +        add(new JScrollPane(_container));
   	}
   
   	/** 
  -	 * Update the display for the current item. 
  +	 * Update the display for the current items. 
   	 * 
  -	 * @param item Current item.
  +	 * @param items Current items to display.
   	 */
  -    private void updateDisplay(ACSElement item) {
  +    private void updateDisplay(ACSElement[] items) {
           if(_customizer != null) {
  -            remove(_customizer);
  +            _container.remove(_customizer);
               _customizer = null;
           }
   
  -        if(item != null) {
  -            _customizer = new DynamicCustomizer(item.getClass(), true);
  -            _customizer.setObject(item);
  -            add(BorderLayout.CENTER, _customizer);
  +        if(items != null) {
  +            _customizer = new DynamicCustomizer(items[0].getClass());
  +            _customizer.setObject(items[0]);
  +            _container.add(BorderLayout.CENTER, _customizer);
           }
           validate();
       }
  @@ -124,9 +128,9 @@
            * @param event Event to post.
            */
           public void eventPosted(EventObject event) {
  -            TargetSelectionEvent e = (TargetSelectionEvent) event;
  -            ACSTargetElement[] targets = e.getSelectedTargets();
  -            updateDisplay(targets.length == 0 ? null : targets[0]);
  +            ElementSelectionEvent e = (ElementSelectionEvent) event;
  +            ACSElement[] elements = e.getSelectedElements();
  +            updateDisplay(elements);
           }
   
       }
  @@ -139,7 +143,7 @@
            * @return True if event should be given to BusMember, false otherwise.
            */
           public boolean accept(EventObject event) {
  -            return event instanceof TargetSelectionEvent;
  +            return event instanceof ElementSelectionEvent;
           }
       }
   }
  
  
  
  1.3       +12 -2     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSElement.java	2000/11/10 20:41:12	1.2
  +++ ACSElement.java	2000/11/11 04:52:20	1.3
  @@ -62,9 +62,11 @@
    * Abstract base class for all Ant Construction Set
    * elements. Depends on the JAXP XML library from Sun.
    * 
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon Fitch */
   public abstract class ACSElement extends ElementNode {
  +    /** Name of the 'xmlString' property. */
  +    public static final String XML_STRING = "xmlString";
   
       /** Event support. */
       private PropertyChangeSupport _propSupport = null;
  @@ -74,7 +76,6 @@
   	 * 
   	 */
       protected ACSElement() {
  -
       }
   
   	/** 
  @@ -84,6 +85,15 @@
   	 */
       public String getDisplayName() {
           return getTagName();
  +    }
  +
  +	/** 
  +	 * Get the XML representation of this.
  +	 * 
  +	 * @return XML representation.
  +	 */
  +    public String getXMLString() {
  +        return toString();
       }
   
   	/** 
  
  
  
  1.2       +17 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSFactory.java
  
  Index: ACSFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSFactory.java	2000/11/09 23:14:14	1.1
  +++ ACSFactory.java	2000/11/11 04:52:20	1.2
  @@ -62,12 +62,13 @@
   import com.sun.xml.tree.XmlDocument;
   import com.sun.xml.tree.XmlDocumentBuilder;
   import java.util.Properties;
  +import java.util.Enumeration;
   import com.sun.xml.parser.Resolver;
   
   /**
    * Factory for loading Ant Construction set elements.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class ACSFactory {
  @@ -79,10 +80,25 @@
   
       static {
           try {
  +            // First we bootstrap our knowledge of the Ant tasks by reading
  +            // in the taskdef definitions and assigning them the default
  +            // task element class.
  +            _elementMap.load(org.apache.tools.ant.taskdefs.Ant.class.
  +                          getResourceAsStream("defaults.properties"));
  +            Enumeration enum = _elementMap.propertyNames();
  +            while(enum.hasMoreElements()) {
  +                String name = (String) enum.nextElement();
  +                // XXX the name of the class needs to be stored externally.
  +                _elementMap.setProperty(
  +                    name, "org.apache.tools.ant.gui.acs.ACSTaskElement");
  +            }
  +
  +            // Then we add/override the local definitions.
               _elementMap.load(ACSFactory.class.
                                getResourceAsStream("acs-element.properties"));
           }
           catch(Throwable ex) {
  +            // If something wrong happens here we can't do much more...
               ex.printStackTrace();
               System.exit(1);
           }
  
  
  
  1.3       +52 -2     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSProjectElement.java	2000/11/10 20:41:12	1.2
  +++ ACSProjectElement.java	2000/11/11 04:52:20	1.3
  @@ -58,12 +58,21 @@
   /**
    * Class representing a project element in the build file.
    * 
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon Fitch 
    */
   public class ACSProjectElement extends ACSNamedElement {
  -    public ACSProjectElement() {
  +    /** The 'default' property name. */
  +    public static final String DEFAULT = "default";
  +    /** The 'basdir' property name. */
  +    public static final String BASEDIR = "basedir";
  +
   
  +	/** 
  +	 * Default ctor.
  +	 * 
  +	 */
  +    public ACSProjectElement() {
       }
   
   	/** 
  @@ -83,4 +92,45 @@
       public String getDisplayName() {
           return getTagName() + ": " + getName();
       }
  +
  +	/** 
  +	 * Get the name of the default target.
  +	 * 
  +	 * @return Default target name.
  +	 */
  +    public String getDefault() {
  +        return getAttribute(DEFAULT);
  +    }
  +
  +	/** 
  +	 * Set the name of the default target.
  +	 * 
  +	 * @param def Name of the default target.
  +	 */
  +    public void setDefault(String def) {
  +        String old = getDefault();
  +        setAttribute(DEFAULT, def);
  +        firePropertyChange(DEFAULT, old, def);
  +    }
  +
  +	/** 
  +	 * Get the specified base directory for the build.
  +	 * 
  +	 * @return Base directory
  +	 */
  +    public String getBasedir() {
  +        return getAttribute(BASEDIR);
  +    }
  +
  +	/** 
  +	 * Set the base directory for builds.
  +	 * 
  +	 * @param baseDir Build base directory.
  +	 */
  +    public void setBasedir(String baseDir) {
  +        String old = getBasedir();
  +        setAttribute(BASEDIR, baseDir);
  +        firePropertyChange(BASEDIR, old, baseDir);
  +    }
  +
   }
  
  
  
  1.2       +16 -2     jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElementBeanInfo.java
  
  Index: ACSProjectElementBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSProjectElementBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ACSProjectElementBeanInfo.java	2000/11/10 20:41:12	1.1
  +++ ACSProjectElementBeanInfo.java	2000/11/11 04:52:20	1.2
  @@ -56,9 +56,9 @@
   import java.beans.*;
   
   /**
  - * BeanInfo for the ACSTargetElement class.
  + * BeanInfo for the ACSProjectElement class.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class ACSProjectElementBeanInfo extends BaseBeanInfo {
  @@ -91,9 +91,23 @@
                   new PropertyDescriptor(ACSProjectElement.NAME, 
                                          ACSProjectElement.class),
                   new PropertyDescriptor(ACSProjectElement.DESCRIPTION, 
  +                                       ACSProjectElement.class),
  +                new PropertyDescriptor(ACSProjectElement.DEFAULT, 
  +                                       ACSProjectElement.class),
  +                new PropertyDescriptor(ACSProjectElement.BASEDIR, 
                                          ACSProjectElement.class)
   
               };
  +            retval[0].setDisplayName(getResources().getString(
  +                getClass(),ACSProjectElement.NAME));
  +            retval[1].setDisplayName(getResources().getString(
  +                getClass(),ACSProjectElement.DESCRIPTION));
  +            retval[2].setDisplayName(getResources().getString(
  +                getClass(),ACSProjectElement.DEFAULT));
  +            retval[3].setDisplayName(getResources().getString(
  +                getClass(),ACSProjectElement.BASEDIR));
  +
  +            setSortingOrder(retval);
           }
           catch(IntrospectionException ex) {
               ex.printStackTrace();
  
  
  
  1.3       +72 -9     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ACSTargetElement.java	2000/11/10 20:41:12	1.2
  +++ ACSTargetElement.java	2000/11/11 04:52:20	1.3
  @@ -59,11 +59,18 @@
   /**
    * Class representing a build target.
    * 
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon Fitch 
    */
   public class ACSTargetElement extends ACSNamedElement {
   
  +    /** Dependency property name. */
  +    public static final String DEPENDS = "depends";
  +    /** 'if' clause property name. */
  +    public static final String IF = "if";
  +    /** 'unless' clause property name. */
  +    public static final String UNLESS = "unless";
  +
   	/** 
   	 * Default ctor.
   	 * 
  @@ -72,30 +79,86 @@
   
       }
   
  +	/** 
  +	 * Get the display name.
  +	 * 
  +	 * @return Display name.
  +	 */
  +    public String getDisplayName() {
  +        return getTagName() + ": " + getName();
  +    }
  +
   	/** 
  -	 * Set the set of dependency names. 
  +	 * Get the set of dependency names. 
   	 * 
   	 * @return Dependency names.
   	 */
  -    public String[] getDependencyNames() {
  -        String depends = getAttribute("depends");
  +    public String[] getDepends() {
  +        String depends = getAttribute(DEPENDS);
           StringTokenizer tok = new StringTokenizer(depends,",");
           String[] retval = new String[tok.countTokens()];
           for(int i = 0; i < retval.length; i++) {
  -            retval[i] = tok.nextToken();
  +            retval[i] = tok.nextToken().trim();
           }
           
           return retval;
       }
   
   	/** 
  -	 * Get the display name.
  +	 * Set the list of dependency names.
   	 * 
  -	 * @return Display name.
  +	 * @param depends Dependency names.
   	 */
  -    public String getDisplayName() {
  -        return getTagName() + ": " + getName();
  +    public void setDepends(String[] depends) {
  +        String old = getAttribute(DEPENDS);
  +        StringBuffer buf = new StringBuffer();
  +        for(int i = 0; depends != null && i < depends.length; i++) {
  +            buf.append(depends[i]);
  +            if(i < depends.length - 1) {
  +                buf.append(", ");
  +            }
  +        }
  +        setAttribute(DEPENDS, buf.toString());
  +        firePropertyChange(DEPENDS, old, buf.toString());
  +    }
  +
  +	/** 
  +	 * Get the 'if' clause.
  +	 * 
  +	 * @return 'if' clause.
  +	 */
  +    public String getIf() {
  +        return getAttribute(IF);
  +    }
  +    
  +	/** 
  +	 * Set the 'if' clause.
  +	 * 
  +	 * @param val 'if' clause value.
  +	 */
  +    public void setIf(String val) {
  +        String old = getIf();
  +        setAttribute(IF, val);
  +        firePropertyChange(IF, old, val);
       }
   
  +	/** 
  +	 * Get the 'unless' clause.
  +	 * 
  +	 * @return 'unless' clause.
  +	 */
  +    public String getUnless() {
  +        return getAttribute(UNLESS);
  +    }
   
  +	/** 
  +	 * Set the 'unless' clause.
  +	 * 
  +	 * @param val 'unless' clase value.
  +	 */
  +    public void setUnless(String val) {
  +        String old = getUnless();
  +        setAttribute(UNLESS, val);
  +        firePropertyChange(UNLESS, old, val);
  +    }
   }
  
  
  
  1.2       +29 -7     jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/ACSTargetElementBeanInfo.java
  
  Index: ACSTargetElementBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/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	2000/11/10 20:41:12	1.1
  +++ ACSTargetElementBeanInfo.java	2000/11/11 04:52:21	1.2
  @@ -58,7 +58,7 @@
   /**
    * BeanInfo for the ACSTargetElement class.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class ACSTargetElementBeanInfo extends BaseBeanInfo {
  @@ -88,14 +88,36 @@
   
           try {
               retval = new PropertyDescriptor[] {
  -                new PropertyDescriptor(getResources().getString(
  -                    getClass(),ACSTargetElement.NAME), 
  +                new PropertyDescriptor(ACSTargetElement.NAME, 
                                          ACSTargetElement.class),
  -                new PropertyDescriptor(getResources().getString(
  -                    getClass(),ACSTargetElement.DESCRIPTION),
  -                                       ACSTargetElement.class)
  -
  +                new PropertyDescriptor(ACSTargetElement.DESCRIPTION,
  +                                       ACSTargetElement.class),
  +                new PropertyDescriptor(ACSTargetElement.DEPENDS,
  +                                       ACSTargetElement.class),
  +                new PropertyDescriptor(ACSTargetElement.IF,
  +                                       ACSTargetElement.class),
  +                new PropertyDescriptor(ACSTargetElement.UNLESS,
  +                                       ACSTargetElement.class),
  +                new PropertyDescriptor(ACSTargetElement.XML_STRING, 
  +                                       ACSTargetElement.class,
  +                                       "getXMLString", null)
               };
  +
  +            // Set display names.
  +            retval[0].setDisplayName(getResources().getString(
  +                getClass(),ACSTargetElement.NAME));
  +            retval[1].setDisplayName(getResources().getString(
  +                getClass(),ACSTargetElement.DESCRIPTION));
  +            retval[2].setDisplayName(getResources().getString(
  +                getClass(),ACSTargetElement.DEPENDS));
  +            retval[3].setDisplayName(getResources().getString(
  +                getClass(),ACSTargetElement.IF));
  +            retval[4].setDisplayName(getResources().getString(
  +                getClass(),ACSTargetElement.UNLESS));
  +            retval[5].setDisplayName(getResources().getString(
  +                getClass(),ACSTargetElement.XML_STRING));
  +
  +            setSortingOrder(retval);
           }
           catch(IntrospectionException ex) {
               ex.printStackTrace();
  
  
  
  1.2       +17 -3     jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/BaseBeanInfo.java
  
  Index: BaseBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/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	2000/11/10 20:41:12	1.1
  +++ BaseBeanInfo.java	2000/11/11 04:52:21	1.2
  @@ -54,19 +54,21 @@
   package org.apache.tools.ant.gui.acs;
   
   import org.apache.tools.ant.gui.ResourceManager;
  +import org.apache.tools.ant.gui.customizer.DynamicCustomizer;
   import java.beans.*;
   
   /**
    * Abstract base class for ACS BeanInfo classes.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   abstract class BaseBeanInfo extends SimpleBeanInfo {
  +    /** Property name for specifiying a sorting order. */
  +    public static final String SORT_ORDER = DynamicCustomizer.SORT_ORDER;
   
       /** Resource provider for bean info. */
  -    private static ResourceManager _resources = new ResourceManager(
  -        "org.apache.tools.ant.gui.acs.beaninfo");
  +    private static ResourceManager _resources = new ResourceManager();
   
   	/** 
   	 * Default ctor.
  @@ -91,6 +93,18 @@
   	 */
       public BeanDescriptor getBeanDescriptor() {
           return new ACSBeanDescriptor(this);
  +    }
  +
  +	/** 
  +	 * Set the sorting order property of the given objects based
  +     * on the order that they appear in the array. 
  +	 * 
  +	 * @param vals FeatureDescriptors to set sorting order property for.
  +	 */
  +    protected void setSortingOrder(FeatureDescriptor[] vals) {
  +        for(int i = 0; i < vals.length; i++) {
  +            vals[i].setValue(SORT_ORDER, new Integer(i));
  +        }
       }
   
   	/** 
  
  
  
  1.2       +1 -0      jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/acs-element.properties
  
  Index: acs-element.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/acs/acs-element.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- acs-element.properties	2000/11/09 23:14:14	1.1
  +++ acs-element.properties	2000/11/11 04:52:21	1.2
  @@ -7,4 +7,5 @@
   
   # 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
  
  
  
  1.2       +52 -9     jakarta-ant/src/antidote/org/apache/tools/ant/gui/customizer/DynamicCustomizer.java
  
  Index: DynamicCustomizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/customizer/DynamicCustomizer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicCustomizer.java	2000/11/10 20:41:17	1.1
  +++ DynamicCustomizer.java	2000/11/11 04:52:21	1.2
  @@ -57,8 +57,7 @@
   import java.lang.reflect.*;
   import java.beans.*;
   import javax.swing.*;
  -import java.util.Hashtable;
  -import java.util.Enumeration;
  +import java.util.*;
   import java.awt.GridBagLayout;
   import java.awt.GridBagConstraints;
   import java.awt.Component;
  @@ -67,7 +66,7 @@
    * Widget for dynamically constructing a property editor based on the 
    * an Object's BeanInfo. Essentially a property sheet.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class DynamicCustomizer extends JPanel {
  @@ -75,6 +74,8 @@
   		PropertyEditorManager.registerEditor(
   			String.class, StringPropertyEditor.class);
   		PropertyEditorManager.registerEditor(
  +			String[].class, StringArrayPropertyEditor.class);
  +		PropertyEditorManager.registerEditor(
   			int.class, IntegerPropertyEditor.class);
   		PropertyEditorManager.registerEditor(
   			Integer.class, IntegerPropertyEditor.class);
  @@ -84,14 +85,19 @@
   			Double.class, DoublePropertyEditor.class);
   	}
   
  +    /** Property name that PropertyDescriptors can save in their property
  +     *  dictionaries for for specifiying a display sorting order. The value
  +     *  sould be of type Integer. */
  +    public static final String SORT_ORDER = "sortOrder";
  +
   	/** The type that this editor instance can handle. */
   	private Class _type = null;
   	/** The value currently being edited. */
   	private Object _value = null;
   	/** Mapping from PropertyDescriptor to PropertyEditor. */
  -	private Hashtable _prop2Editor = new Hashtable();
  +	private Map _prop2Editor = new HashMap();
   	/** Mapping from PropertyEditor to field PropertyDescriptor. */
  -	private Hashtable _editor2Prop = new Hashtable();
  +	private Map _editor2Prop = new HashMap();
   	/** Listener for receiving change events from the editors. */
   	private EditorChangeListener _eListener = new EditorChangeListener();
       /** Read-only flag. */
  @@ -121,11 +127,18 @@
           LabelFieldGBC gbc = new LabelFieldGBC();
           try {
               BeanInfo info = Introspector.getBeanInfo(type);
  +            // Set up pretty display stuff.
               setBorder(BorderFactory.createTitledBorder(
                   info.getBeanDescriptor().getDisplayName()));
  +            setToolTipText(info.getBeanDescriptor().getShortDescription());
  +
  +            // Get the properties and sort them.
               PropertyDescriptor[] props = info.getPropertyDescriptors();
  +            Arrays.sort(props, new PropertyComparator());
               for(int i = 0; i < props.length; i++) {
  +                // Ignore the "class" property, if it is provided.
                   if(props[i].getName().equals("class")) continue;
  +                // Create a label for the field.
                   JLabel label = new JLabel(props[i].getDisplayName() + ":");
                   
                   // Lookup the editor.
  @@ -195,9 +208,9 @@
           
           // Iterate over each property, doing a lookup on the associated editor
           // and setting the editor's value to the value of the property.
  -        Enumeration enum = _prop2Editor.keys();
  -        while(enum.hasMoreElements()) {
  -            PropertyDescriptor desc = (PropertyDescriptor) enum.nextElement();
  +        Iterator it = _prop2Editor.keySet().iterator();
  +        while(it.hasNext()) {
  +            PropertyDescriptor desc = (PropertyDescriptor) it.next();
               PropertyEditor editor = (PropertyEditor) _prop2Editor.get(desc);
               Method reader = desc.getReadMethod();
               if(reader != null) {
  @@ -215,6 +228,12 @@
           }
       }
   
  +	/** 
  +	 * Get the appropriate editor for the given property.
  +	 * 
  +	 * @param prop Property to get editor for.
  +	 * @return Editor to use, or null if none found.
  +	 */
       private PropertyEditor getEditorForProperty(PropertyDescriptor prop) {
           PropertyEditor retval = null;
           Class type = prop.getPropertyEditorClass();
  @@ -231,7 +250,10 @@
           // PropertyEditor manager for the editor registered for the
           // given property type.
           if(retval == null) {
  -            retval = PropertyEditorManager.findEditor(prop.getPropertyType());
  +            Class t = prop.getPropertyType();
  +            if(t != null) {
  +                retval = PropertyEditorManager.findEditor(t);
  +            }
           }
   
           return retval;
  @@ -261,6 +283,27 @@
           }
       }
   
  +
  +    /** Comparator for sorting PropertyDescriptor values. */
  +    private static class PropertyComparator implements Comparator {
  +        public int compare(Object o1, Object o2) {
  +            PropertyDescriptor p1 = (PropertyDescriptor)o1;
  +            PropertyDescriptor p2 = (PropertyDescriptor)o2;
  +
  +            Integer i1 = (Integer) p1.getValue(SORT_ORDER);
  +            Integer i2 = (Integer) p2.getValue(SORT_ORDER);
  +            
  +            if(i1 == null && i2 == null) {
  +                return 0;
  +            }
  +            else if(i1 != null) {
  +                return i1.compareTo(i2);
  +            }
  +            else {
  +                return i2.compareTo(i1) * -1;
  +            }
  +        }
  +    }
   
       /** 
        * Test code.
  
  
  

Mime
View raw message