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 Mon, 08 Jan 2001 19:43:57 GMT
metasim     01/01/08 11:43:57

  Modified:    src/antidote/org/apache/tools/ant/gui/modules/edit
                        ElementNavigator.java PropertyEditor.java
  Log:
  Added *internal* support multiple projects, and generalized the selection
  state mechanism.
  
  Revision  Changes    Path
  1.3       +33 -5     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElementNavigator.java	2001/01/03 14:18:25	1.2
  +++ ElementNavigator.java	2001/01/08 19:43:55	1.3
  @@ -54,7 +54,12 @@
   package org.apache.tools.ant.gui.modules.edit;
   import org.apache.tools.ant.gui.core.*;
   import org.apache.tools.ant.gui.event.*;
  +import org.apache.tools.ant.gui.acs.ElementTreeSelectionModel;
  +import org.apache.tools.ant.gui.acs.ElementTreeModel;
  +import org.apache.tools.ant.gui.acs.ACSProjectElement;
   import javax.swing.*;
  +import javax.swing.event.TreeSelectionListener;
  +import javax.swing.event.TreeSelectionEvent;
   import java.awt.GridLayout;
   import java.awt.Dimension;
   import java.awt.event.MouseAdapter;
  @@ -64,13 +69,15 @@
   /**
    * Module for navigating build file elemenets.
    * 
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon Fitch 
    */
   public class ElementNavigator extends AntModule {
   
       /** Navigation via a tree widget. */
       private JTree _tree = null;
  +    /** The selection model being used. */
  +    private ElementTreeSelectionModel _selections = null;
   
   	/** 
   	 * Default ctor.
  @@ -94,11 +101,13 @@
           _tree.setModel(null);
           _tree.setCellRenderer(new ElementTreeCellRenderer());
           _tree.addMouseListener(new PopupHandler());
  +        _tree.putClientProperty("JTree.lineStyle", "Angled");
           JScrollPane scroller = new JScrollPane(_tree);
           add(scroller);
   
           setPreferredSize(new Dimension(200, 100));
           setMinimumSize(new Dimension(200, 100));
  +
   	}
   
       /** Class for handling project events. */
  @@ -123,7 +132,11 @@
            * it should be cancelled.
            */
           public boolean eventPosted(EventObject event) {
  -            ProjectProxy project = getContext().getProject();
  +            ACSProjectElement project = null;
  +            if(event instanceof ProjectSelectedEvent) {
  +                ProjectSelectedEvent e = (ProjectSelectedEvent) event;
  +                project = e.getSelectedProject();
  +            }
   
               if(project == null) {
                   // The project has been closed.
  @@ -131,15 +144,29 @@
                   // 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(project.getTreeModel());
  -                _tree.setSelectionModel(project.getTreeSelectionModel());
  +                _tree.setModel(new ElementTreeModel(project));
  +                _selections = new ElementTreeSelectionModel();
  +                _selections.addTreeSelectionListener(new SelectionForwarder());
  +                _tree.setSelectionModel(_selections);
               }
               return true;
           }
       }
   
  +    /** Forwards selection events to the event bus. */
  +    private class SelectionForwarder implements TreeSelectionListener {
  +        public void valueChanged(TreeSelectionEvent e) {
  +            getContext().getEventBus().postEvent(
  +                ElementSelectionEvent.createEvent(
  +                    getContext(), _selections.getSelectedElements()));
  +        }
  +    }
  +
       /** Class providing filtering for project events. */
       private static class Filter implements BusFilter {
           /** 
  @@ -149,7 +176,8 @@
            * @return True if event should be given to BusMember, false otherwise.
            */
           public boolean accept(EventObject event) {
  -            return event instanceof NewProjectEvent;
  +            return event instanceof ProjectSelectedEvent ||
  +                event instanceof ProjectClosedEvent;
           }
       }
   
  
  
  
  1.3       +9 -5      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PropertyEditor.java	2001/01/03 14:18:25	1.2
  +++ PropertyEditor.java	2001/01/08 19:43:56	1.3
  @@ -69,7 +69,7 @@
   /**
    * Stub for a property editor.
    *
  - * @version $Revision: 1.2 $ 
  + * @version $Revision: 1.3 $ 
    * @author Simeon H.K. Fitch 
    */
   public class PropertyEditor extends AntModule {
  @@ -112,12 +112,16 @@
               _customizer = null;
           }
   
  -        if(items != null && items.length == 1) {
  +        if(items != null && items.length > 0) {
  +            // The last selection element is the the one the
  +            // user most recently selected.
  +            ACSElement item = items[items.length - 1];
  +
               try {
  -                BeanInfo info = Introspector.getBeanInfo(items[0].getClass());
  +                BeanInfo info = Introspector.getBeanInfo(item.getClass());
                   _customizer = (Customizer) info.getBeanDescriptor().
                       getCustomizerClass().newInstance();
  -                _customizer.setObject(items[0]);
  +                _customizer.setObject(item);
                   _container.add(BorderLayout.CENTER, (Component) _customizer);
               }
               catch(Exception ex) {
  @@ -126,7 +130,7 @@
               }
           }
   
  -        _container.revalidate();
  +        _container.repaint();
       }
   
   
  
  
  

Mime
View raw message