pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1682370 - in /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools: PDFDebugger.java pdfdebugger/treestatus/TreeStatus.java pdfdebugger/treestatus/TreeStatusPane.java
Date Fri, 29 May 2015 06:33:40 GMT
Author: tilman
Date: Fri May 29 06:33:40 2015
New Revision: 1682370

URL: http://svn.apache.org/r1682370
Log:
PDFBOX-2530: refactoring of tree status code, as done by Khyrul Bashar in GSoC2015

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatus.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatusPane.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java?rev=1682370&r1=1682369&r2=1682370&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java Fri May 29 06:33:40
2015
@@ -415,10 +415,11 @@ public class PDFDebugger extends javax.s
         currentFilePath = file.getPath();
         recentFiles.removeFile(file.getPath());
         parseDocument( file, password );
-        statusPane.updateTreeStatus(new TreeStatus(document.getDocument().getTrailer()));
+        TreeStatus treeStatus = new TreeStatus(document.getDocument().getTrailer());
+        statusPane.updateTreeStatus(treeStatus);
         TreeModel model=new PDFTreeModel(document);
         jTree1.setModel(model);
-        jTree1.setSelectionRow(1);
+        jTree1.setSelectionPath(treeStatus.getPathForString("Root"));
         setTitle("PDFBox - " + file.getAbsolutePath());
         addRecentFileItems();
     }

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatus.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatus.java?rev=1682370&r1=1682369&r2=1682370&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatus.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatus.java
Fri May 29 06:33:40 2015
@@ -32,18 +32,11 @@ import org.apache.pdfbox.tools.gui.MapEn
  */
 public final class TreeStatus
 {
-    private TreePath path = null;
-    private String pathString;
     private Object rootNode;
    
     private TreeStatus()
     {
     }
-
-    public boolean isValid()
-    {
-        return path != null;
-    }
     
     /**
      * Constructor.
@@ -57,45 +50,13 @@ public final class TreeStatus
     }
 
     /**
-     * Return the treepath.
-     * @return the treepath.
-     */
-    public TreePath getPath()
-    {
-        return path;
-    }
-
-    /**
-     * Set the path and generate corresponding tree status string.
-     * @param path TreePath instance.
-     */
-    public void setPath(TreePath path)
-    {
-        this.path = path;
-        this.pathString = generatePathString(path);
-    }
-
-    /**
-     * Set the tree status string and try to generate TreePath. In case of success, the path
will be
-     * available for further uses. In case of failure path will be set to null.
-     *
-     * @param pathString String instance.
-     */
-    public void setPathString(String pathString)
-    {
-        this.pathString = pathString;
-        path = generatePath(pathString);
-    }
-
-    /**
      * Provides status string for a TreePath instance.
      * @param path TreePath instance.
      * @return pathString.
      */
     public String getStringForPath(TreePath path)
     {
-        setPath(path);
-        return pathString;
+        return generatePathString(path);
     }
 
     /**
@@ -105,8 +66,7 @@ public final class TreeStatus
      */
     public TreePath getPathForString(String statusString)
     {
-        setPathString(statusString);
-        return path;
+        return generatePath(statusString);
     }
 
     /**
@@ -144,6 +104,10 @@ public final class TreeStatus
         for (String node : nodes)
         {
             obj = searchNode(obj, node);
+            if (obj == null)
+            {
+                return null;
+            }
             treePath = treePath.pathByAddingChild(obj);
         }
         return treePath;

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatusPane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatusPane.java?rev=1682370&r1=1682369&r2=1682370&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatusPane.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/pdfdebugger/treestatus/TreeStatusPane.java
Fri May 29 06:33:40 2015
@@ -49,7 +49,7 @@ public class TreeStatusPane implements T
         public void actionPerformed(ActionEvent actionEvent)
         {
             TreePath path = statusObj.getPathForString(statusField.getText());
-            if (statusObj.isValid())
+            if (path != null)
             {
                 tree.setSelectionPath(path);
             }



Mime
View raw message