jvanzyl     02/04/18 21:35:35

  Modified:    src/java/org/apache/maven/jxr DirectoryIndexer.java
  Log:
  Applying patch supplied by Brian Leonard <[EMAIL PROTECTED]> that
  fixes image duplication in the JXR task.
  
  Revision  Changes    Path
  1.10      +31 -13    
jakarta-turbine-maven/src/java/org/apache/maven/jxr/DirectoryIndexer.java
  
  Index: DirectoryIndexer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jxr/DirectoryIndexer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DirectoryIndexer.java     28 Mar 2002 04:59:29 -0000      1.9
  +++ DirectoryIndexer.java     19 Apr 2002 04:35:35 -0000      1.10
  @@ -73,7 +73,7 @@
    * Handles building a directory index of files and directories.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin A. Burton</a>
  - * @version $Id: DirectoryIndexer.java,v 1.9 2002/03/28 04:59:29 jvanzyl Exp $
  + * @version $Id: DirectoryIndexer.java,v 1.10 2002/04/19 04:35:35 jvanzyl Exp $
    */
   public class DirectoryIndexer
   {
  @@ -101,7 +101,7 @@
       /**
        * Description of the Field
        */
  -    public final static String IMAGE_DIRECTORY = "./folder.gif";
  +    public final static String IMAGE_FOLDER = "./folder.gif";
       
       /**
        * Description of the Field
  @@ -125,6 +125,12 @@
        */
       private String root = null;
   
  +    /**
  +     * Relative link to the (optional) root xref directory
  +     */
  +    private StringBuffer rootLink = new StringBuffer();
  +
  +
       private int mode = MODE_DEFAULT;
   
   
  @@ -185,15 +191,25 @@
   
           this.root = root;
   
  -        this.directory = new File(directory);
  +        this.directory = new File(new File(directory).getCanonicalPath());
           this.image_folder = image_folder;
           this.image_file = image_file;
   
  -        copy(image_folder, directory + System.getProperty("file.separator") + 
  -            DirectoryIndexer.IMAGE_DIRECTORY);
  +        // copy image files to the root directory only, or
  +        // to each subdirectory if no root is specified
  +        if ((root != null &&
  +            new File(root).getCanonicalPath()
  +             .equals(this.directory.getCanonicalPath())) ||
  +            root == null)
  +        {
  +            copy(image_folder,
  +                 directory + System.getProperty("file.separator") + 
  +                 DirectoryIndexer.IMAGE_FOLDER);
           
  -        copy(image_file, directory + System.getProperty("file.separator") + 
  -            DirectoryIndexer.IMAGE_FILE);
  +            copy(image_file,
  +                 directory + System.getProperty("file.separator") + 
  +                 DirectoryIndexer.IMAGE_FILE);
  +        }
   
           this.process();
       }
  @@ -237,7 +253,8 @@
                   end != -1 &&
                   start < end)
               {
  -
  +                rootLink.append("../");
  +                
                   String pkg = dir.substring(start, end);
   
                   out.print("<br><p><b>Package:  ");
  @@ -245,10 +262,11 @@
                   while (toke.hasMoreElements())
                   {
                       String subpkg = (String) toke.nextElement();
  -
                       if (toke.hasMoreTokens())
                       {
                           out.print("<a href=\"");
  +                        rootLink.append("../");
  +
                           for (int i = 0; i < toke.countTokens(); i++)
                           {
                               out.print("../");
  @@ -269,7 +287,7 @@
   
           }
           
  -        out.println("<a href=\"../\">[parent]</a>");
  +        out.println("<a href=\"../" + INDEX + "\">[parent]</a>");
           out.println("<hr>");
           out.println("<table width=\"100%\">");
   
  @@ -330,7 +348,7 @@
   
               href = item.getName() + "/" + INDEX;
   
  -            image = IMAGE_DIRECTORY;
  +            image = rootLink + IMAGE_FOLDER;
           }
   
           //potentially rip off.html links on names
  @@ -345,7 +363,7 @@
                   name = item.getName().substring(start, end) + ".java";
               }
   
  -            image = IMAGE_FILE;
  +            image = rootLink + IMAGE_FILE;
           }
   
           //"<td width=\"" + IMAGE_WIDTH + "\"><img src=\"" + image + "\" 
border=\"0\"></td>" +
  @@ -423,7 +441,7 @@
               }
               else if (this.getMode() == MODE_DEFAULT &&
                   filename.equals(INDEX) == false &&
  -                filename.equals(new File(IMAGE_DIRECTORY).getName()) == false &&
  +                filename.equals(new File(IMAGE_FOLDER).getName()) == false &&
                   filename.equals(new File(IMAGE_FILE).getName()) == false &&
                   new File(item).isFile())
               {
  
  
  


Reply via email to