|
a/tool/run/plugins/spdx/show.java |
|
b/tool/run/plugins/spdx/show.java |
|
... |
|
... |
16 |
package spdx;
|
16 |
package spdx;
|
17 |
|
17 |
|
18 |
import GUI.swingUtils;
|
18 |
import GUI.swingUtils;
|
19 |
import definitions.Messages;
|
19 |
import definitions.Messages;
|
20 |
import definitions.is;
|
20 |
import definitions.is;
|
|
|
21 |
import java.awt.Desktop;
|
21 |
import java.io.File;
|
22 |
import java.io.File;
|
22 |
import www.Table;
|
23 |
import java.io.IOException;
|
23 |
import java.util.ArrayList;
|
24 |
import java.util.ArrayList;
|
24 |
import utils.Graphs;
|
25 |
import java.util.logging.Level;
|
|
|
26 |
import java.util.logging.Logger;
|
|
|
27 |
import main.core;
|
|
|
28 |
import main.param;
|
25 |
import script.Plugin;
|
29 |
import script.Plugin;
|
26 |
import spdxlib.tools;
|
30 |
import script.log;
|
27 |
import spdxlib.FileInfo;
|
31 |
import spdxlib.FileInfo;
|
28 |
import spdxlib.SPDXfile;
|
32 |
import spdxlib.SPDXfile;
|
29 |
import main.core;
|
33 |
import spdxlib.tools;
|
30 |
import main.param;
|
34 |
import utils.Graphs;
|
31 |
import script.log;
|
|
|
32 |
import utils.html;
|
35 |
import utils.html;
|
33 |
import www.RequestOrigin;
|
36 |
import www.RequestOrigin;
|
|
|
37 |
import www.Table;
|
34 |
import www.WebRequest;
|
38 |
import www.WebRequest;
|
35 |
|
39 |
|
36 |
|
40 |
|
37 |
/**
|
41 |
/**
|
38 |
*
|
42 |
*
|
|
... |
|
... |
383 |
"No licenses declared", 150)
|
387 |
"No licenses declared", 150)
|
384 |
;
|
388 |
;
|
385 |
}
|
389 |
}
|
386 |
|
390 |
|
387 |
|
391 |
|
|
|
392 |
// get the lines of code (LOC)
|
|
|
393 |
int countLOC = 0;
|
|
|
394 |
for(FileInfo fileInfo : spdx.fileSection.files){
|
|
|
395 |
countLOC += fileInfo.getLOC();
|
|
|
396 |
}
|
|
|
397 |
|
388 |
// the header when showing summary about a specific SPDX file
|
398 |
// the header when showing summary about a specific SPDX file
|
389 |
String summary =
|
399 |
String summary =
|
390 |
html.h2(
|
400 |
html.h2(
|
391 |
// html.getIcon("wooden-box-label.png", request)
|
401 |
// html.getIcon("wooden-box-label.png", request)
|
392 |
spdx.getId())
|
402 |
spdx.getId())
|
393 |
+ counterFiles + " files inside the package"
|
403 |
+ counterFiles + " files inside the package"
|
394 |
+ html.br
|
404 |
+ html.br
|
395 |
//+ html.getCommonFolderIcon("calculator.png")
|
405 |
//+ html.getCommonFolderIcon("calculator.png")
|
396 |
+ counterLicensesDeclared + " files with declared licenses"
|
406 |
+ counterLicensesDeclared + " files with declared licenses"
|
|
|
407 |
+ html.br
|
|
|
408 |
+ countLOC + " lines of code (LOC)"
|
397 |
//+ percentage
|
409 |
//+ percentage
|
398 |
+ warnings
|
410 |
+ warnings
|
399 |
+ evaluation
|
411 |
+ evaluation
|
400 |
+ html.br
|
412 |
+ html.br
|
401 |
;
|
413 |
;
|
|
... |
|
... |
412 |
+ html.getIcon("chart.png", request)};
|
424 |
+ html.getIcon("chart.png", request)};
|
413 |
values = new int[]{270, 180};
|
425 |
values = new int[]{270, 180};
|
414 |
|
426 |
|
415 |
summary = Table.alignedTable(header, values);
|
427 |
summary = Table.alignedTable(header, values);
|
416 |
|
428 |
|
|
|
429 |
// if we are on Windows, permit to open the folder
|
|
|
430 |
String openFolder = "";
|
|
|
431 |
if(isWindows()){
|
|
|
432 |
openFolder =
|
|
|
433 |
html.br
|
|
|
434 |
+ html.link("Open folder in Windows explorer",
|
|
|
435 |
"?x=openFolder&"
|
|
|
436 |
+ param.file + "=" + file.getAbsolutePath())
|
|
|
437 |
+ html.br
|
|
|
438 |
;
|
|
|
439 |
// try {
|
|
|
440 |
// Desktop.getDesktop().open(file);
|
|
|
441 |
// } catch (IOException ex) {
|
|
|
442 |
// }
|
417 |
|
443 |
}
|
418 |
|
444 |
|
419 |
// prepare the answer
|
445 |
// prepare the answer
|
420 |
String result = ""
|
446 |
String result = ""
|
421 |
//swingUtils.getBreadcrumb(node)
|
447 |
//swingUtils.getBreadcrumb(node)
|
422 |
+ html.div(20)
|
448 |
+ html.div(20)
|
423 |
+ summary
|
449 |
+ summary
|
424 |
+ html._div
|
450 |
+ html._div
|
425 |
|
451 |
|
426 |
|
452 |
|
427 |
+ html.div()
|
453 |
+ html.div()
|
|
|
454 |
+ openFolder
|
|
|
455 |
|
428 |
+ html.br
|
456 |
+ html.br
|
429 |
+ swingUtils.addIfNotEmpty(""
|
457 |
+ swingUtils.addIfNotEmpty(""
|
430 |
//html.getCommonFolderIcon("magnifier-zoom-fit.png")
|
458 |
//html.getCommonFolderIcon("magnifier-zoom-fit.png")
|
431 |
+ "Look around the web"
|
459 |
+ "Look around the web"
|
432 |
, searchEngines)
|
460 |
, searchEngines)
|
|
... |
|
... |
468 |
|
496 |
|
469 |
// write everything on our UI text area
|
497 |
// write everything on our UI text area
|
470 |
request.setAnswer(result);
|
498 |
request.setAnswer(result);
|
471 |
}
|
499 |
}
|
472 |
|
500 |
|
|
|
501 |
//
|
|
|
502 |
|
|
|
503 |
/**
|
|
|
504 |
* The web link to show the folder where the SPDX document is located.
|
|
|
505 |
* @param request
|
|
|
506 |
*/
|
|
|
507 |
public void openFolder(WebRequest request) {
|
|
|
508 |
String param = request.getParameter("file");
|
|
|
509 |
File file = new File(param);
|
|
|
510 |
try {
|
|
|
511 |
Desktop.getDesktop().open(file.getParentFile());
|
|
|
512 |
} catch (IOException ex) {
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
String output = "A window showing the folder where the SPDX documents"
|
|
|
516 |
+ "are placed should now be visible. "
|
|
|
517 |
+ html.br
|
|
|
518 |
+ "Press the back button "
|
|
|
519 |
+ "to return on the previous page.";
|
|
|
520 |
|
|
|
521 |
request.setAnswer(output);
|
|
|
522 |
}
|
473 |
|
523 |
|
474 |
/**
|
524 |
/**
|
475 |
* list some information according to a filter
|
525 |
* list some information according to a filter
|
476 |
* @param request
|
526 |
* @param request
|
477 |
*/
|
527 |
*/
|
|
... |
|
... |
611 |
}
|
661 |
}
|
612 |
|
662 |
|
613 |
return result;
|
663 |
return result;
|
614 |
}
|
664 |
}
|
615 |
|
665 |
|
|
|
666 |
|
|
|
667 |
/**
|
|
|
668 |
* Are we running under a Windows machine or not?
|
|
|
669 |
*/
|
|
|
670 |
public boolean isWindows(){
|
|
|
671 |
String os = System.getProperty("os.name").toLowerCase();
|
|
|
672 |
//windows
|
|
|
673 |
return (os.indexOf( "win" ) >= 0);
|
|
|
674 |
}
|
|
|
675 |
|
616 |
}
|
676 |
}
|