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/customizer DynamicCustomizer.java
Date Thu, 16 Nov 2000 22:38:43 GMT
metasim     00/11/16 14:38:43

  Modified:    src/antidote/org/apache/tools/ant/gui/customizer
                        DynamicCustomizer.java
  Log:
  Changed mechanism by which the PropertyEditor editor is instantiated so that it
  uses whatever class is retured by BeanDescriptor.getCustomizerClass() rather
  than assuming DynamicCustomizer. This will allow BeanSpecific customizers to be
  used in leu of the DynamicCustomizer.
  
  Also finally figured out the IllegalAccessException problem with calling the
  NodeList methods in the ACSTreeNodeElement classes, which turned out only to
  happen when jikes was used for compiling. Implemented a work around.
  
  Revision  Changes    Path
  1.4       +48 -4     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DynamicCustomizer.java	2000/11/14 19:48:08	1.3
  +++ DynamicCustomizer.java	2000/11/16 22:38:43	1.4
  @@ -66,10 +66,10 @@
    * Widget for dynamically constructing a property editor based on the 
    * an Object's BeanInfo. Essentially a property sheet.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
  -public class DynamicCustomizer extends JPanel {
  +public class DynamicCustomizer extends JPanel implements Customizer {
   	static {
   		PropertyEditorManager.registerEditor(
   			String.class, StringPropertyEditor.class);
  @@ -102,6 +102,9 @@
   	private EditorChangeListener _eListener = new EditorChangeListener();
       /** Read-only flag. */
       private boolean _readOnly = false;
  +    /** List of property change listeners interested when the bean
  +     *  being edited has been changed. */
  +    private List _changeListeners = new LinkedList();
   
   
   	/** 
  @@ -259,6 +262,47 @@
           return retval;
       }
   
  +	/** 
  +	 * Add the given listener. Will receive a change event for 
  +     * changes to the bean being edited.
  +	 * 
  +	 * @param l Listner to add.
  +	 */
  +    public void addPropertyChangeListener(PropertyChangeListener l) {
  +        _changeListeners.add(l);
  +    }
  +
  +
  +	/** 
  +	 * Remove the given property change listener.
  +	 * 
  +	 * @param l Listener to remove.
  +	 */
  +    public void removePropertyChangeListener(PropertyChangeListener l) {
  +        _changeListeners.remove(l);
  +    }
  +
  +	/** 
  +	 * Fire a property change event to each listener.
  +	 * 
  +	 * @param bean Bean being edited. 
  +	 * @param propName Name of the property.
  +	 * @param oldValue Old value.
  +	 * @param newValue New value.
  +	 */
  +    protected void firePropertyChange(Object bean, String propName, 
  +                                      Object oldValue, Object newValue) {
  +
  +        PropertyChangeEvent e = new PropertyChangeEvent(
  +            bean, propName, oldValue, newValue);
  +
  +        Iterator it = _changeListeners.iterator();
  +        while(it.hasNext()) {
  +            PropertyChangeListener l = (PropertyChangeListener) it.next();
  +            l.propertyChange(e);
  +        }
  +    }
  +
       /** Class for receiving change events from the PropertyEditor objects. */
       private class EditorChangeListener implements PropertyChangeListener {
           public void propertyChange(PropertyChangeEvent e) {
  @@ -271,8 +315,8 @@
                       Object[] params = { editor.getValue() };
                       writer.invoke(_value, params);
                       setObject(_value);
  -                    //firePropertyChange(
  -                    //prop.getName(), null, editor.getValue());
  +                    firePropertyChange(
  +                        _value, prop.getName(), null, editor.getValue());
                   }
                   catch(IllegalAccessException ex) {
                       ex.printStackTrace();
  
  
  

Mime
View raw message