ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickda...@apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/modules/edit ElementNavigator.java
Date Mon, 16 Apr 2001 01:52:06 GMT
nickdavis    01/04/15 18:52:06

  Modified:    src/antidote/org/apache/tools/ant/gui/modules/edit
                        ElementNavigator.java
  Log:
  changed the JTree to DragTree and added DragTreeListener
  
  Revision  Changes    Path
  1.7       +53 -3     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ElementNavigator.java	2001/03/28 12:26:03	1.6
  +++ ElementNavigator.java	2001/04/16 01:52:06	1.7
  @@ -64,17 +64,18 @@
   import java.awt.event.MouseEvent;
   import java.util.EventObject;
   import java.beans.PropertyChangeEvent;
  +import org.w3c.dom.Node;
   
   /**
    * Module for navigating build file elemenets.
    * 
  - * @version $Revision: 1.6 $ 
  + * @version $Revision: 1.7 $ 
    * @author Simeon Fitch 
    */
   public class ElementNavigator extends AntModule {
   
       /** Navigation via a tree widget. */
  -    private JTree _tree = null;
  +    private DragTree _tree = null;
       /** The selection model being used. */
       private ElementTreeSelectionModel _selections = null;
   
  @@ -96,7 +97,8 @@
   
           setLayout(new GridLayout(1,1));
   
  -        _tree = new JTree();
  +        _tree = new DragTree();
  +        _tree.addDragTreeListener(new DragHandler());
           _tree.setModel(null);
           _tree.setCellRenderer(new ElementTreeCellRenderer());
           _tree.addMouseListener(new PopupHandler());
  @@ -278,6 +280,54 @@
           }
           public void mouseClicked(MouseEvent e) {
               handle(e);
  +        }
  +    }
  +    
  +    /** Class for handling drag operation. */
  +    private static class DragHandler implements DragTreeListener {
  +        
  +        /**
  +         * Append the object to the end of the parent's child list.
  +         */
  +        public Object appendChild(Object parent, Object newChild) {
  +            
  +            ACSTreeNodeElement parentNode =
  +                (ACSTreeNodeElement) parent;
  +            ACSTreeNodeElement newChildNode =
  +                (ACSTreeNodeElement) newChild;
  +            ACSTreeNodeElement clone =
  +                (ACSTreeNodeElement) newChildNode.cloneNode(true);
  +            parentNode.appendChild(clone);
  +            return clone;
  +        }
  +
  +        /**
  +         * Append the object to the end of the parent's child list.
  +         */
  +        public Object insertBefore(Object parent, Object index, Object newChild) {
  +            
  +            ACSTreeNodeElement parentNode =
  +                (ACSTreeNodeElement) parent;
  +            ACSTreeNodeElement indexNode =
  +                (ACSTreeNodeElement) index;
  +            ACSTreeNodeElement newChildNode =
  +                (ACSTreeNodeElement) newChild;
  +            ACSTreeNodeElement clone =
  +                (ACSTreeNodeElement) newChildNode.cloneNode(true);
  +            parentNode.insertBefore(clone, indexNode);
  +            return clone;
  +        }
  +    
  +        /**
  +         * Append the object to the end of the parent's child list.
  +         */
  +        public void removeChild(Object child) {
  +            
  +            ACSTreeNodeElement childNode =
  +                (ACSTreeNodeElement) child;
  +            ACSTreeNodeElement parentNode =
  +                (ACSTreeNodeElement) childNode.getParentNode();
  +            parentNode.removeChild(childNode);
           }
       }
   }
  
  
  

Mime
View raw message