Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/src/ise/antelope/common/

antelope
Discussion topic

Back to topic list

CVS update: /antelope/src/ise/antelope/common/

Author danson
Full name Dale Anson
Date 2004-03-23 20:38:15 PST
Message User: danson
Date: 04/03/23 20:38:15

Modified:
 /antelope/src/ise/an​telope/common/
  SAXNodeHandler.java, SAXPanel.java, SAXTreeCellRenderer.java, SAXTreeNode.java

Log:
 general commit
 

File Changes:

Directory: /antelope/src/ise/an​telope/common/
====================​====================​=====

File [changed]: SAXNodeHandler.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/SAXNod​eHandler.java?r1=1.4​&r2=1.5
Delta lines: +19 -1
--------------------
--- SAXNodeHandler.java 23 Mar 2004 16:28:09 -0000 1.4
+++ SAXNodeHandler.java 24 Mar 2004 04:38:13 -0000 1.5
@@ -5,6 +5,8 @@
 import java.io.FileReader;
 import java.io.Reader;
 import java.io.StringReader;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Stack;
 import javax.swing.tree.Def​aultTreeModel;
 import javax.xml.parsers.SAXParser;
@@ -23,7 +25,7 @@
  * Builds a tree of TreeNodes as a SAX parser reads an xml file.
  *
  * @author Dale Anson, danson at germane-software dot com
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
  */
 public class SAXNodeHandler extends DefaultHandler {
 
@@ -40,6 +42,10 @@
    
    private boolean isImported = false;
 
+ private List taskList = Arrays.asList(new String[]{"propertyfile", "importtypelib", "vsscheckin", "sql", "cvspass", "p4reopen", "csc", "dirname", "wlrun", "p4label", "p4revert", "replaceregexp", "get", "jjtree", "sleep", "jarlib-display", "dependset", "zip", "patch", "jspc", "style", "test", "tstamp", "unwar", "vsshistory", "icontract", "cvschangelog", "p4submit", "ccmcheckin", "p4change", "bzip2", "sync", "p4delete", "vssadd", "javadoc", "p4integrate", "translate", "signjar", "cclock", "chown", "vajload", "jarlib-available", "WsdlToDotnet", "buildnumber", "jpcovmerge", "ejbjar", "war", "rename", "sequential", "serverdeploy", "property", "subant", "move", "ildasm", "copydir", "cccheckin", "ccunlock", "wljspc", "fixcrlf", "sosget", "pathconvert", "record", "p4sync", "exec", "ccmklabel", "p4edit", "manifest", "maudit", "antlr", "netrexxc", "jpcovreport", "execon", "ccmcheckout", "ant", "xmlvalidate", "xslt", "p4resolve", "iplanet-ejbc", "ccmcheckintask", "gzip", "native2ascii", "ccrmtype", "starteam", "ear", "input", "presetdef", "rmic", "checksum", "mail", "loadfile", "vsscheckout", "stylebook", "soscheckin", "mimemail", "stlabel", "gunzip", "concat", "cab", "touch", "parallel", "splash", "antcall", "ccmkbl", "cccheckout", "typedef", "p4have", "filter", "xmlproperty", "import", "copy", "jsharpc", "symlink", "antstructure", "script", "ccmcreatetask", "rpm", "delete", "replace", "mmetrics", "attrib", "waitfor", "untar", "loadproperties", "available", "echoproperties", "chgrp", "vajexport", "bunzip2", "whichresource", "copyfile", "p4labelsync", "vsscreate", "macrodef", "ejbc", "unjar", "vbc", "wsdltodotnet", "mkdir", "condition", "cvs", "tempfile", "junitreport", "taskdef", "echo", "ccupdate", "java", "vsslabel", "renameext", "basename", "javadoc2", "tar", "vsscp", "vajimport", "p4fstat", "setproxy", "p4counter", "wlstop", "ilasm", "soscheckout", "apply", "ccuncheckout", "jarlib-resolve", "jlink", "cvstagdiff", "javacc", "chmod", "pvcs", "jarlib-manifest", "jar", "ccmklbtype", "sound", "scriptdef", "defaultexcludes", "mparse", "blgenclient", "uptodate", "jjdoc", "genkey", "javah", "ccmreconfigure", "fail", "unzip", "javac", "p4add", "jpcoverage", "soslabel", "depend", "vssget", "deltree", "ddcreator"});
+ private List typeList = Arrays.asList(new String[]{"patternset", "assertions", "propertyset", "filterset", "libfileset", "filterreader", "scriptfilter", "extension", "fileset", "dirset", "filelist", "filterchain", "path", "classfileset", "selector", "xmlcatalog", "description", "mapper", "zipfileset", "substitution", "extensionSet", "regexp"});
+
+
    /** Description of the Method */
    public SAXNodeHandler() {
       this( null );
@@ -93,6 +99,7 @@
       Locator l = new LocatorImpl( locator );
       SAXTreeNode child = new SAXTreeNode( qName, new Point( l.getLineNumber(), l.getColumnNumber() ), attributes );
       child.setImported(isImported);
+ setKind(qName, child);
       if ( infile != null )
          child.setFile( infile );
       
@@ -232,6 +239,17 @@
          }
       }
       return null;
+ }
+
+ private void setKind(String qname, SAXTreeNode node) {
+ if (qname.equals("project"))
+ node.setProject(true);
+ else if (qname.equals("target"))
+ node.setTarget(true);
+ else if (taskList.contains(qname))
+ node.setTask(true);
+ else if (typeList.contains(qname))
+ node.setType(true);
    }
 }
 

File [changed]: SAXPanel.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/SAXPan​el.java?r1=1.4&r​2=1.5
Delta lines: +116 -32
----------------------
--- SAXPanel.java 23 Mar 2004 16:28:10 -0000 1.4
+++ SAXPanel.java 24 Mar 2004 04:38:13 -0000 1.5
@@ -7,6 +7,7 @@
 
 import java.awt.BorderLayout;
 import java.io.*;
+import java.util.*;
 import javax.swing.*;
 import java.beans.Beans;
 import java.awt.event.ActionListener;
@@ -70,9 +71,8 @@
                            Object object = path.getLastPathComponent();
                            if ( object instanceof SAXTreeNode ) {
                               SAXTreeNode node = ( SAXTreeNode ) object;
- System.out.println("node file = " + node.getFile());
- if (node.getFile() != null)
- _helper.openFile(nod​e.getFile());
+ if ( node.getFile() != null )
+ _helper.openFile( node.getFile() );
                               _helper.actionPerformed( new ActionEvent( node.getLocation(), CommonHelper.EDIT_EVENT, "" ) );
                               _nav.update( node.getLocation() );
                            }
@@ -102,8 +102,8 @@
                               SAXTreeNode node = ( SAXTreeNode ) object;
                               TreeModel tm = getDependencyModel( node );
                               if ( tm != null ) {
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(new JLabel("Dependency Tree"), BorderLayout.NORTH);
+ JPanel panel = new JPanel( new BorderLayout() );
+ panel.add( new JLabel( "Dependency Tree" ), BorderLayout.NORTH );
                                  JTree dt = new JTree( tm );
                                  dt.addMouseListener( this );
                                  dt.setCellRenderer( new SAXTreeCellRenderer() );
@@ -140,7 +140,7 @@
     * target. Returns null if the target is not found.
     */
    public TreeModel getDependencyModel( String target_name ) {
- SAXTreeNode initial_target = getTargetNode( target_name );
+ SAXTreeNode initial_target = getTargetNode( target_name, ( SAXTreeNode ) tree.getModel().getRoot() );
       return getDependencyModel( initial_target );
    }
 
@@ -151,53 +151,136 @@
    public TreeModel getDependencyModel( SAXTreeNode node ) {
       if ( node == null )
          return null;
- SAXTreeNode root = new SAXTreeNode( node.getName(), node.getLocation(), node.getAttributes() );
- root.setFile(node.getFile());
+ SAXTreeNode root = (SAXTreeNode)node.clone();//new SAXTreeNode( node.getName(), node.getLocation(), node.getAttributes() );
+ root.setFile( node.getFile() );
       addDependentTargetNodes( root );
+ addCalledTargetNodes( node, root );
       return new DefaultTreeModel( root );
    }
 
+ private void addCalledTargetNodes( SAXTreeNode src, SAXTreeNode dest ) {
+ SAXTreeNode[] called_targets = getCalledTargetNodes(src);
+ if (called_targets.length > 0) {
+ SAXTreeNode called_root = new SAXTreeNode( "Calls", dest.getLocation(), null, dest.getFile() );
+ for (int i = 0; i < called_targets.length; i++) {
+ called_root.add(call​ed_targets[i]);
+ }
+ dest.add(called_root);
+ }
+ }
+
+ /**
+ * Looks through the given node for ant and antcall (and call, runtarget, and antcallback) tasks.
+ * @return an array of child nodes representing ant and/or antcall tasks.
+ * The array may be empty, but won't be null.
+ */
+ private SAXTreeNode[] getCalledTargetNodes( SAXTreeNode node ) {
+ int child_count = node.getChildCount();
+ ArrayList children = new ArrayList();
+ for ( int i = 0; i < child_count; i++ ) {
+ SAXTreeNode child_node = ( SAXTreeNode ) node.getChildAt( i );
+ String child_name = child_node.getName();
+ if ( child_name.equals( "antcall" ) || child_name.equals("call") || child_name.equals("runtarget") || child_name.equals("a​ntcallback")) {
+ Attributes attrs = child_node.getAttributes();
+ int index = attrs.getIndex( "target" );
+ if ( index == -1 )
+ continue;
+ String called_target = attrs.getValue( "target" );
+ SAXTreeNode called_node = getTargetNode( called_target, ( SAXTreeNode ) tree.getModel().getRoot() );
+ if ( called_node != null ) {
+ called_node.setCalled( true );
+ children.add( called_node );
+ }
+ }
+ if ( child_name.equals( "ant" ) ) {
+ // get the build file name, default is build.xml
+ String antfile = "build.xml";
+ int index = attrs.getIndex("antfile");
+ if (index > -1)
+ antfile = attrs.getValue("antfile");
+
+ // get the directory, default is the basedir of the current project
+ String dir = node.getFile() != null ? node.getFile().getPa​rent().getAbsolutePa​th() : "";
+ index = attrs.getIndex("dir");
+ if (index > -1)
+ dir = attrs.getValue("dir");
+
+ // make sure the build file exists
+ File build_file = new File(dir, antfile);
+ if (!build_file.exists())
+ continue;
+
+ // load the build file using the SAXNodeHandler, get a project node
+
+ // get the target name, default is the default target in the build file
+
+ // get the target dependencies and called targets
+
+ // add some nodes
+ }
+ }
+ SAXTreeNode[] nodes = new SAXTreeNode[children.size()];
+ Iterator it = children.iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ nodes[i] = (SAXTreeNode)it.next();
+ }
+ return nodes;
+ }
+
    private void addDependentTargetNodes( SAXTreeNode node ) {
+ SAXTreeNode depends_root = new SAXTreeNode( "Depends on", node.getLocation(), null, node.getFile() );
       SAXTreeNode[] depends = getDependentTargetNodes( node );
       for ( int i = 0; i < depends.length; i++ ) {
          if ( depends[ i ] != null ) {
- node.add( depends[ i ] );
- addDependentTargetNodes( depends[ i ] );
+ depends_root.add( depends[ i ] );
+ //addDependentTargetNodes( depends[ i ] );
          }
       }
+ if ( depends_root.getChildCount() > 0 )
+ node.add( depends_root );
    }
 
    /**
+ * @param target_name the name of the target to find
+ * @param root the root node of the tree to look for the target. The target
+ * may be a child of this node, or in the case of imported files, may be in
+ * any depth of imported projects.
     * @return a clone of the SAXTreeNode corresponding to the given target name or
     * null if no target with that name is found. Note that in the case of
     * duplicate target names, the first one found will be returned.
     */
- private SAXTreeNode getTargetNode( String target_name ) {
+ private SAXTreeNode getTargetNode( String target_name, SAXTreeNode root ) {
       if ( target_name == null )
          return null;
       try {
- DefaultTreeModel model = ( DefaultTreeModel ) tree.getModel();
- SAXTreeNode root = ( SAXTreeNode ) model.getRoot();
- int child_count = model.getChildCount( root );
+ int child_count = root.getChildCount( );
          SAXTreeNode candidate = null;
          for ( int i = 0; i < child_count; i++ ) {
- SAXTreeNode node = ( SAXTreeNode ) model.getChild( root, i );
+ SAXTreeNode node = ( SAXTreeNode ) root.getChildAt( i );
 
             // check targets in imported projects
             if ( node.getName().equals( "project" ) && candidate == null ) {
- int sub_child_count = model.getChildCount( node );
+ Attributes attrs = node.getAttributes();
+ int index = attrs.getIndex( "name" );
+ if ( index > -1 ) {
+ String subproject_name = attrs.getValue( index );
+ int sub_child_count = node.getChildCount();
                for ( int j = 0; j < sub_child_count; j++ ) {
- SAXTreeNode sub_node = ( SAXTreeNode ) model.getChild( node, j );
+ SAXTreeNode sub_node = ( SAXTreeNode ) node.getChildAt( j );
                   if ( !sub_node.getName().equals( "target" ) )
                      continue;
- Attributes attrs = sub_node.getAttributes();
- int index = attrs.getIndex( "name" );
+ attrs = sub_node.getAttributes();
+ index = attrs.getIndex( "name" );
                   if ( index == -1 )
                      continue;
                   String name = attrs.getValue( index );
- if ( target_name.equals( name ) ){
- candidate = new SAXTreeNode( sub_node.getName(), sub_node.getLocation(), sub_node.getAttributes(), sub_node.getFile() );
- candidate.setImporte​d(sub_node.isImporte​d());
+ if ( target_name.startsWith( subproject_name ) ) {
+ String tn = target_name.substring( subproject_name.length() + 1 ); // +1 for the dot
+ if ( tn.equals( name ) ) {
+ candidate = (SAXTreeNode)sub_node.clone();
+ candidate.setImported( sub_node.isImported() );
+ }
+ }
                   }
                }
             }
@@ -210,9 +293,10 @@
             if ( index == -1 )
                continue;
             String name = attrs.getValue( index );
- if ( target_name.equals( name ) ){
- candidate = new SAXTreeNode( node.getName(), node.getLocation(), node.getAttributes(), node.getFile() );
- candidate.setImporte​d(node.isImported())​;
+ if ( target_name.equals( name ) ) {
+ candidate = (SAXTreeNode)node.clone();
+ addDependentTargetNo​des(candidate);
+ addCalledTargetNodes(node, candidate);
                return candidate;
             }
          }
@@ -242,7 +326,7 @@
          return new SAXTreeNode[ 0 ];
       SAXTreeNode[] nodes = new SAXTreeNode[ size ];
       for ( int i = 0; st.hasMoreTokens(); i++ ) {
- SAXTreeNode node = getTargetNode( st.nextToken().trim() );
+ SAXTreeNode node = getTargetNode( st.nextToken().trim(), ( SAXTreeNode ) tree.getModel().getRoot() );
          nodes[ i ] = node;
       }
       return nodes;

File [changed]: SAXTreeCellRenderer.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/SAXTre​eCellRenderer.java?r​1=1.4&r2=1.5
Delta lines: +7 -1
-------------------
--- SAXTreeCellRenderer.java 23 Mar 2004 16:28:10 -0000 1.4
+++ SAXTreeCellRenderer.java 24 Mar 2004 04:38:13 -0000 1.5
@@ -123,12 +123,18 @@
             if ( url != null )
                icon = new ImageIcon( url );
          }
- if ( node.getName().equals( "target" ) ) {
+ else if ( node.getName().equals( "target" ) ) {
             String image_src = "";
             if (node.isImported())
                image_src = "images/RedTarget16.gif";
             else
                image_src = "images/Target16.gif";
+ java.net.URL url = getClass().getClassL​oader().getResource(​ image_src );
+ if ( url != null )
+ icon = new ImageIcon( url );
+ }
+ else if (node.isTask()) {
+ String image_src = "images/wrench.jpg";
             java.net.URL url = getClass().getClassL​oader().getResource(​ image_src );
             if ( url != null )
                icon = new ImageIcon( url );

File [changed]: SAXTreeNode.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/common/SAXTre​eNode.java?r1=1.3​&r2=1.4
Delta lines: +82 -12
---------------------
--- SAXTreeNode.java 23 Mar 2004 06:42:20 -0000 1.3
+++ SAXTreeNode.java 24 Mar 2004 04:38:13 -0000 1.4
@@ -13,19 +13,24 @@
  * the original xml document.
  * @author Dale Anson, danson at germane-software dot com
  */
-public class SAXTreeNode extends DefaultMutableTreeNode implements Cloneable{
+public class SAXTreeNode extends DefaultMutableTreeNode implements Cloneable {
 
    private String name;
    private Point location;
    private Attributes attributes;
    private File file = null;
    private boolean isImported = false;
+ private boolean isCalled = false;
+ private boolean isTask = false;
+ private boolean isType = false;
+ private boolean isTarget = false;
+ private boolean isProject = false;
 
    public SAXTreeNode( String name, Point location, Attributes attr ) {
- this(name, location, attr, null);
+ this( name, location, attr, null );
    }
    
- public SAXTreeNode( String name, Point location, Attributes attr, File f) {
+ public SAXTreeNode( String name, Point location, Attributes attr, File f ) {
       super( name );
       this.name = name;
       this.location = location;
@@ -46,7 +51,7 @@
       return name;
    }
    
- public void setFile(File file) {
+ public void setFile( File file ) {
       this.file = file;
    }
    
@@ -54,12 +59,77 @@
       return file;
    }
    
- public void setImported(boolean b) {
+ /**
+ * Set to true if this node has been imported by the &lt;import&gt; task.
+ */
+ public void setImported( boolean b ) {
       isImported = b;
    }
    
+ /**
+ * @return true if this node was imported by an &lt;import&gt; task.
+ */
    public boolean isImported() {
       return isImported;
    }
    
+ /**
+ * Set to true if this node was called by either the &lt;ant&gt;
+ * or &lt;antcall&gt; tasks.
+ */
+ public void setCalled( boolean b ) {
+ isCalled = b;
+ }
+
+ /**
+ * @return true if this node is the target node for an &lt;ant&gt;
+ * or &lt;antcall&gt; task
+ */
+ public boolean isCalled() {
+ return isCalled;
+ }
+
+ public void setType(boolean b) {
+ isType = b;
+ }
+
+ public boolean isType() {
+ return isType;
+ }
+
+ public void setTask(boolean b) {
+ isTask = b;
+ }
+
+ public boolean isTask() {
+ return isTask;
+ }
+
+ public void setTarget(boolean b) {
+ isTarget = b;
+ }
+
+ public boolean isTarget() {
+ return isTarget;
+ }
+
+ public void setProject(boolean b) {
+ isProject = b;
+ }
+
+ public boolean isProject() {
+ return isProject;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "[" ).append( getName() ).append( ";" );
+ if ( getAttributes() != null )
+ sb.append( getAttributes().toString() ).append( ";" );
+ if ( getFile() != null )
+ sb.append( getFile().toString() ).append( ";" );
+ sb.append(isImported() ? "imported;" : "not imported;");
+ sb.append(isCalled() ? "called]" : "not called]");
+ return sb.toString();
+ }
 }




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@ante​lope.tigris.org
For additional commands, e-mail: cvs-help at antelope dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /antelope/src/ise/antelope/common/ danson Dale Anson 2004-03-23 20:38:15 PST
Messages per page: