ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/edit ElementNavigator.java PropertyEditor.java
Date Thu, 11 Jan 2001 19:26:55 GMT
metasim     01/01/11 11:26:55

  Modified:    src/antidote/org/apache/tools/ant/gui/modules/edit
                        ElementNavigator.java PropertyEditor.java
  Log:
  Added support for updating display based on property change events in the data
  model.
  
  Revision  Changes    Path
  1.4       +34 -21    jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java
  
  Index: ElementNavigator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ElementNavigator.java	2001/01/08 19:43:55	1.3
  +++ ElementNavigator.java	2001/01/11 19:26:49	1.4
  @@ -58,6 +58,7 @@
   import org.apache.tools.ant.gui.acs.ElementTreeModel;
   import org.apache.tools.ant.gui.acs.ACSProjectElement;
   import javax.swing.*;
  +import javax.swing.tree.*;
   import javax.swing.event.TreeSelectionListener;
   import javax.swing.event.TreeSelectionEvent;
   import java.awt.GridLayout;
  @@ -65,11 +66,12 @@
   import java.awt.event.MouseAdapter;
   import java.awt.event.MouseEvent;
   import java.util.EventObject;
  +import java.beans.PropertyChangeEvent;
   
   /**
    * Module for navigating build file elemenets.
    * 
  - * @version $Revision: 1.3 $ 
  + * @version $Revision: 1.4 $ 
    * @author Simeon Fitch 
    */
   public class ElementNavigator extends AntModule {
  @@ -132,27 +134,37 @@
            * it should be cancelled.
            */
           public boolean eventPosted(EventObject event) {
  -            ACSProjectElement project = null;
  -            if(event instanceof ProjectSelectedEvent) {
  -                ProjectSelectedEvent e = (ProjectSelectedEvent) event;
  -                project = e.getSelectedProject();
  +            if(event instanceof PropertyChangeEvent) {
  +                // The project node has changed.
  +// XXX This won't work until ACSTreeNodeElement.getParent() is fixed
  +//                ElementTreeModel model = (ElementTreeModel)_tree.getModel();
  +//                model.nodeChanged((TreeNode)model.getRoot());
  +                
               }
  -
  -            if(project == null) {
  -                // The project has been closed.
  -                // XXX this needs to be tested against 
  -                // different version of Swing...
  -                _tree.setModel(null);
  -                _tree.setSelectionModel(null);
  -                // Send an empty selection event to notify others that
  -                // nothing is selected.
  -                ElementSelectionEvent.createEvent(getContext(), null);
  -            }
               else {
  -                _tree.setModel(new ElementTreeModel(project));
  -                _selections = new ElementTreeSelectionModel();
  -                _selections.addTreeSelectionListener(new SelectionForwarder());
  -                _tree.setSelectionModel(_selections);
  +                ACSProjectElement project = null;
  +                if(event instanceof ProjectSelectedEvent) {
  +                    ProjectSelectedEvent e = (ProjectSelectedEvent) event;
  +                    project = e.getSelectedProject();
  +                }
  +                
  +                if(project == null) {
  +                    // The project has been closed.
  +                    // XXX this needs to be tested against 
  +                    // different version of Swing...
  +                    _tree.setModel(null);
  +                    _tree.setSelectionModel(null);
  +                    // Send an empty selection event to notify others that
  +                    // nothing is selected.
  +                    ElementSelectionEvent.createEvent(getContext(), null);
  +                }
  +                else {
  +                    _tree.setModel(new ElementTreeModel(project));
  +                    _selections = new ElementTreeSelectionModel();
  +                    _selections.addTreeSelectionListener(
  +                        new SelectionForwarder());
  +                    _tree.setSelectionModel(_selections);
  +                }
               }
               return true;
           }
  @@ -177,7 +189,8 @@
            */
           public boolean accept(EventObject event) {
               return event instanceof ProjectSelectedEvent ||
  -                event instanceof ProjectClosedEvent;
  +                event instanceof ProjectClosedEvent ||
  +                event instanceof PropertyChangeEvent;
           }
       }
   
  
  
  
  1.5       +13 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/edit/PropertyEditor.java
  
  Index: PropertyEditor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/edit/PropertyEditor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PropertyEditor.java	2001/01/08 21:03:11	1.4
  +++ PropertyEditor.java	2001/01/11 19:26:50	1.5
  @@ -69,7 +69,7 @@
   /**
    * Stub for a property editor.
    *
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon H.K. Fitch 
    */
   public class PropertyEditor extends AntModule {
  @@ -80,6 +80,8 @@
       private JPanel _container = null;
       /** Scroll area containing contents. */
       private JScrollPane _scroller = null;
  +    /** Property change forwarder. */
  +    private PropertyChangeForwarder _forwarder = new PropertyChangeForwarder();
   
       /** 
        * Default ctor.
  @@ -108,6 +110,7 @@
        */
       private void updateDisplay(ACSElement[] items) {
           if(_customizer != null) {
  +            _customizer.removePropertyChangeListener(_forwarder);
               _container.remove((Component)_customizer);
               _customizer = null;
           }
  @@ -123,6 +126,7 @@
                       getCustomizerClass().newInstance();
                   _customizer.setObject(item);
                   _container.add(BorderLayout.CENTER, (Component) _customizer);
  +                _customizer.addPropertyChangeListener(_forwarder);
               }
               catch(Exception ex) {
                   // XXX log me.
  @@ -176,4 +180,12 @@
               return event instanceof ElementSelectionEvent;
           }
       }
  +
  +    /** Class for forwarding property change events to the event bus. */
  +    private class PropertyChangeForwarder implements PropertyChangeListener {
  +        public void propertyChange(PropertyChangeEvent e) {
  +            getContext().getEventBus().postEvent(e);
  +        }
  +    }
  +
   }
  
  
  

Mime
View raw message