Child: [r18] (diff)

Download this file

ToolsLog.java    59 lines (49 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* SPDXVersion: SPDX-1.1
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
* Creator: Organization: TripleCheck (contact@triplecheck.de)
* Created: 2013-11-17T00:00:00Z
* LicenseName: NOASSERTION
* FileName: pluginLog.java
* FileType: SOURCE
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
* FileComment: <text> Shows to the end-user a log of what is happening </text>
*/
package basic;
import definitions.Messages;
import script.Plugin;
import script.log;
import utils.html;
import www.WebRequest;
/**
*
* @author Nuno Brito, 17th of November 2013 in Darmstadt, Germany.
* nuno.brito@triplecheck.de | http://nunobrito.eu
*/
public class ToolsLog extends Plugin{
@Override
public void startup(){
// add our node to the tree right after the "Tools" node is added
log.hooks.addAction(Messages.AddingTools, thisFile, "addNode");
}
/**
* Add our toolbox node to the treeview.
*/
public void addNode(){
addTreeNode("Log", "book-open-text.png", "showPage");
}
/**
* Displays a basic log of what has been happening
* @param request The request from the end-user
*/
public void showPage(WebRequest request){
// get all the messages since the beginning
String result = log.getMessagesSince(0);
// replace the break lines with an HTML break line
result = "<html><body>"
+ result.replace("\n", html.br)
+ "</body></html>";
// write everything for the user to read
request.setAnswer(result);
}
}