• Fixed defects all around the software
  • SPDX create doesn't include extraneous size detail when below 1000 bytes (redundant info)
  • Added a simplified HTML table to keep two elements of data centered
  • Moved around functions to more central locations

nunobrito 2014-01-20

added /tool/run/plugins/spdx/exclamation.png
changed /tool/run/plugins/spdx/chart.png
changed /tool/src/spdxlib/FileInfo.java
changed /tool/src/utils/html.java
changed /tool/src/spdxlib/tools.java
changed /tool/src/spdxlib/DocumentCreate.java
changed /tool/run/plugins/basic/TreeNodeDetails.java
changed /tool/src/www/Table.java
changed /tool/run/plugins/spdx/show.java
copied /tool/run/plugins/basic/showFileDetails.java -> /tool/run/plugins/spdx/showFileDetails.java
copied /tool/run/plugins/basic/showProductDetails.java -> /tool/run/plugins/spdx/showProductDetails.java
/tool/run/plugins/spdx/exclamation.png Diff Switch to side-by-side view
Loading...
/tool/run/plugins/spdx/chart.png Diff Switch to side-by-side view
Loading...
/tool/src/spdxlib/FileInfo.java Diff Switch to side-by-side view
Loading...
/tool/src/utils/html.java Diff Switch to side-by-side view
Loading...
/tool/src/spdxlib/tools.java Diff Switch to side-by-side view
Loading...
/tool/src/spdxlib/DocumentCreate.java Diff Switch to side-by-side view
Loading...
/tool/run/plugins/basic/TreeNodeDetails.java Diff Switch to side-by-side view
Loading...
/tool/src/www/Table.java Diff Switch to side-by-side view
Loading...
/tool/run/plugins/spdx/show.java Diff Switch to side-by-side view
Loading...
/tool/run/plugins/basic/showFileDetails.java to /tool/run/plugins/spdx/showFileDetails.java
--- a/tool/run/plugins/basic/showFileDetails.java
+++ b/tool/run/plugins/spdx/showFileDetails.java
@@ -11,18 +11,23 @@
  * has been selected on the treeview or throught some similar manner </text> 
  */
 
-package basic;
+package spdx;
 
 import GUI.NodeType;
 import GUI.TreeNodeSPDX;
 import GUI.swingUtils;
 import definitions.Messages;
 import definitions.is;
+import java.io.File;
 import script.Plugin;
 import script.log;
 import spdxlib.FileInfo;
 import main.core;
+import main.param;
+import spdxlib.SPDXfile;
+import spdxlib.tools;
 import utils.html;
+import www.WebRequest;
 
 
 /**
@@ -37,6 +42,40 @@
         log.hooks.addAction(Messages.TreeNodeChanged, thisFile, "processFile");
     }
     
+    
+     /**
+     * list some information according to a filter
+     * @param request
+     */
+    public void specific(WebRequest request) {
+        // we need the "file" parameter to tell us what to detail
+        String spdxTarget = request.getParameter(param.spdx);
+        // does this file exists?
+        File spdxFile = tools.getFile(spdxTarget, request);
+        if(spdxFile == null){
+            return;
+        }
+        // get what we want to show
+        String targetFile = request.getParameter(param.file);
+        // value can't be empty
+        if(targetFile == null){
+            request.setAnswer("No filter specified");
+            return;
+        }
+        // start the processing
+        SPDXfile spdx = new SPDXfile(spdxFile);
+        // go through all files inside the document
+        for(FileInfo file : spdx.fileSection.files){
+            // have we (finally) found a match?
+            if(targetFile.equals(file.getName())){
+                String result = showFileDetails(file);
+                request.setAnswer(result);
+                return;
+            }
+        }
+        request.setAnswer("Didn't found " + targetFile);
+    }
+    
     /**
      * Checks if the node of a file has been selected. If this is the case then
      * show as much details as possible about the file
@@ -50,9 +89,18 @@
         }
         
         // process files
-        if(node.nodeType == NodeType.file){
-            showFileDetails(node);
-        }
+        if(node.nodeType != NodeType.file){
+            return;
+        }
+
+        // we're talking about tree nodes, get the respective information
+        FileInfo file = (FileInfo) node.getUserObject();
+        
+        // create the summary for the requested file
+        String output = showFileDetails(file);
+        // this only applies to calls from the treeview
+        core.studio.editorPane(is.contentHTML, Boolean.FALSE, 0, output);
+        
     }
 
     
@@ -79,22 +127,24 @@
      * Do the actual part of showing the details for this file
      * @param node 
      */
-    private void showFileDetails(TreeNodeSPDX node) {
+    private String showFileDetails(FileInfo file) {
         // where we store the end result
-        FileInfo file = (FileInfo) node.getUserObject();
+//        FileInfo file = (FileInfo) node.getUserObject();
         
         String googleTerm = "";
-        String filename = file.tagFileName.toString();
+        String filename = file.getName();
         // get the file extension if available
         //String extension = getFileExtension(filename);
             
         try{
             // get the package name to narrow down the results
-            TreeNodeSPDX parent = (TreeNodeSPDX) node.getParent();
-            TreeNodeSPDX root = (TreeNodeSPDX) parent.getParent();
+//            TreeNodeSPDX parent = (TreeNodeSPDX) node.getParent();
+//            TreeNodeSPDX root = (TreeNodeSPDX) parent.getParent();
             
             // we need to remove misleading terms from the filename
-            String filteredName = root.id.toLowerCase();
+            String filteredName = file.getName();
+                   // root.id.toLowerCase();
+            
                 filteredName = filteredName.replace(".tar.gz", "");
                 filteredName = filteredName.replace(".zip", "");
                 filteredName = filteredName.replace(".jar", "");
@@ -116,26 +166,29 @@
         }
         
         // do the introduction of this file with a breadcrumb
-        String[] fields = node.getUID().split(">>");
-        String breadCrumb = 
-                  fields[4]
-                + ">"
-                + fields[3]
-                + ">"
-                + fields[1]
-                ;
+//        String[] fields = node.getUID().split(">>");
+//        String breadCrumb = 
+//                  fields[4]
+//                + ">"
+//                + fields[3]
+//                + ">"
+//                + fields[1]
+//                ;
         // add a short summary about the file
         String summary = "";
         if(file.tagFileSize != null){
             summary += "This file is sized in " + file.tagFileSize.toString();
         }
         if(file.tagFileLOC != null){
-            summary += " and has " + file.tagFileLOC + " lines of code" 
-                    + html.br;
-        }
-        
-        if(spdxlib.tools.hasLicense(file)){
-            summary += "Applicable license(s): " + spdxlib.tools.getLicense(file);
+            summary += " with " + file.tagFileLOC + " lines of code" 
+                    ;
+        }
+        
+        if(file.hasLicense()){
+            summary += 
+                    html.br 
+                    + html.br 
+                    + "Applicable license(s): " + file.getLicense();
         }
         
         // do the date creation
@@ -145,7 +198,8 @@
         
         String resultIntroduction = ""
                 + "<h2>"
-                + breadCrumb
+                + filename
+//                + breadCrumb
                 + "</h2>"
                 + html.div()
                 + summary
@@ -184,6 +238,7 @@
                         + html.div()
                         // only possible when we have SHA256 hashes available
                         + html.linkToSearchVirusTotal(file.tagFileChecksumSHA256.toString())
+                        + html.linkToSearchVirusTotal(file.tagFileChecksumSHA256.toString())
                         + html._div;
         }
         
@@ -215,11 +270,13 @@
         String result = html.div()
                     + resultIntroduction
                     + html.br
+                    + html.br
                     + swingUtils.addIfNotEmpty("SHA1", resultSHA1)
                     + swingUtils.addIfNotEmpty("SHA256", resultSHA256)
                     + swingUtils.addIfNotEmpty("MD5",resultMD5)
                     //+ html.br
                     + swingUtils.addIfNotEmpty("SSDEEP", resultSSDEEP)
+                    + html.br
                     + swingUtils.addIfNotEmpty("Look for \""
                         +filename
                         +"\" in search engines"
@@ -233,8 +290,7 @@
         * - File path
         * - Applicable licenses (when available)
         */
-        core.studio.editorPane(is.contentHTML, Boolean.FALSE, 0, result);
-        
+        return result;
     }
 
 }
/tool/run/plugins/basic/showProductDetails.java to /tool/run/plugins/spdx/showProductDetails.java
--- a/tool/run/plugins/basic/showProductDetails.java
+++ b/tool/run/plugins/spdx/showProductDetails.java
@@ -12,7 +12,7 @@
  * </text> 
  */
 
-package basic;
+package spdx;
 
 import GUI.NodeType;
 import GUI.TreeNodeSPDX;
@@ -297,7 +297,7 @@
         for(FileInfo file : spdx.fileSection.files){
 
             // if there is a license, no need to continue
-            if(tools.hasLicense(file)){
+            if(file.hasLicense()){
                 continue;
             }
             
@@ -349,7 +349,7 @@
         for(FileInfo file : spdx.fileSection.files){
 
             // if there is a license, no need to continue
-            if(tools.hasLicense(file) == false){
+            if(file.hasLicense() == false){
                 continue;
             }
             
@@ -409,7 +409,7 @@
             for(Object fileObject : spdx.fileSection.files){
                 FileInfo file = (FileInfo) fileObject;
                 // go deep into the license information
-                if(tools.hasLicense(file)){
+                if(file.hasLicense()){
                     counterLicensesDeclared++;
                 }
             }