Child: [r4] (diff)

Download this file

Plugin.java    70 lines (59 with data), 2.3 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
59
60
61
62
63
64
65
66
67
68
69
/*
* SPDXVersion: SPDX-1.1
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
* Creator: Organization: TripleCheck (contact@triplecheck.de)
* Created: 2013-11-01T00:00:00Z
* LicenseName: NOASSERTION
* FileName: Plugin.java
* FileType: SOURCE
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
* FileComment: <text> Used as the skeleton for beanshell/java hybrid
* plugins. This part is what beanshell is actually running, albeit in the
* NetBeans IDE and code of each script we are declaring each plugin
* to implement Plugin.java
*
* This trick was necessary to overcome some differences between Java and
* the Beanshell scripting" </text>
*/
package script;
import GUI.TreeNodeSPDX;
import GUI.swingUtils;
import definitions.is;
import java.io.File;
import main.core;
import www.WebRequest;
/**
*
* @author Nuno Brito, 8th of November 2013 in Darmstadt, Germany.
*/
public class Plugin {
public File
thisFile = null, // pointer to this beanshell file being executed
thisFolder = null; // pointer to the beanshell directory on disk
public void startup(){
}
public void main(WebRequest request){
request.setAnswer("<h1>In construction</h1>"
+ "There is nothing (yet) to be displayed on this page.");
}
/**
* Adds a tree node on the default User Interface when desired by the
* plugin
* @param title Title for the tree node that is shown to user
* @param iconName Icon from our archive that is used for the node
* @param methodName The method that is called when the node is clicked
*/
protected void addTreeNode(String title, String iconName,
String methodName){
// get the saved node on our temporary storage
TreeNodeSPDX nodeRoot = (TreeNodeSPDX) core.temp.get("nodeTree");
// add it up to our tree
TreeNodeSPDX node = swingUtils.addNode(title, iconName, nodeRoot);
// set the associated script that we want to run
node.scriptFile = thisFile;
node.scriptFolder = thisFolder;
node.scriptMethod = methodName;
// all done
log.write(is.COMPLETED, "Added tool: %1", title);
}
}