--- a/tool/run/plugins/spdx/show.java
+++ b/tool/run/plugins/spdx/show.java
@@ -18,19 +18,23 @@
import GUI.swingUtils;
import definitions.Messages;
import definitions.is;
+import java.awt.Desktop;
import java.io.File;
-import www.Table;
+import java.io.IOException;
import java.util.ArrayList;
-import utils.Graphs;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import main.core;
+import main.param;
import script.Plugin;
-import spdxlib.tools;
+import script.log;
import spdxlib.FileInfo;
import spdxlib.SPDXfile;
-import main.core;
-import main.param;
-import script.log;
+import spdxlib.tools;
+import utils.Graphs;
import utils.html;
import www.RequestOrigin;
+import www.Table;
import www.WebRequest;
@@ -385,6 +389,12 @@
}
+ // get the lines of code (LOC)
+ int countLOC = 0;
+ for(FileInfo fileInfo : spdx.fileSection.files){
+ countLOC += fileInfo.getLOC();
+ }
+
// the header when showing summary about a specific SPDX file
String summary =
html.h2(
@@ -393,7 +403,9 @@
+ counterFiles + " files inside the package"
+ html.br
//+ html.getCommonFolderIcon("calculator.png")
- + counterLicensesDeclared + " files with declared licenses"
+ + counterLicensesDeclared + " files with declared licenses"
+ + html.br
+ + countLOC + " lines of code (LOC)"
//+ percentage
+ warnings
+ evaluation
@@ -414,7 +426,21 @@
summary = Table.alignedTable(header, values);
-
+ // if we are on Windows, permit to open the folder
+ String openFolder = "";
+ if(isWindows()){
+ openFolder =
+ html.br
+ + html.link("Open folder in Windows explorer",
+ "?x=openFolder&"
+ + param.file + "=" + file.getAbsolutePath())
+ + html.br
+ ;
+// try {
+// Desktop.getDesktop().open(file);
+// } catch (IOException ex) {
+// }
+ }
// prepare the answer
String result = ""
@@ -425,6 +451,8 @@
+ html.div()
+ + openFolder
+
+ html.br
+ swingUtils.addIfNotEmpty(""
//html.getCommonFolderIcon("magnifier-zoom-fit.png")
@@ -470,6 +498,28 @@
request.setAnswer(result);
}
+ //
+
+ /**
+ * The web link to show the folder where the SPDX document is located.
+ * @param request
+ */
+ public void openFolder(WebRequest request) {
+ String param = request.getParameter("file");
+ File file = new File(param);
+ try {
+ Desktop.getDesktop().open(file.getParentFile());
+ } catch (IOException ex) {
+ }
+
+ String output = "A window showing the folder where the SPDX documents"
+ + "are placed should now be visible. "
+ + html.br
+ + "Press the back button "
+ + "to return on the previous page.";
+
+ request.setAnswer(output);
+ }
/**
* list some information according to a filter
@@ -613,4 +663,14 @@
return result;
}
+
+ /**
+ * Are we running under a Windows machine or not?
+ */
+ public boolean isWindows(){
+ String os = System.getProperty("os.name").toLowerCase();
+ //windows
+ return (os.indexOf( "win" ) >= 0);
+ }
+
}