Parent: [r5] (diff)

Child: [r10] (diff)

Download this file

nodeTools.java    121 lines (106 with data), 3.8 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
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* SPDXVersion: SPDX-1.1
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
* Creator: Organization: TripleCheck (contact@triplecheck.de)
* Created: 2013-11-13T00:00:00Z
* LicenseName: NOASSERTION
* FileName: nodeTools.java
* FileType: SOURCE
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
* FileComment: <text> Add the node of tools inside the tree view. </text>
*/
package basic;
import GUI.NodeType;
import GUI.TreeNodeSPDX;
import GUI.swingUtils;
import definitions.Messages;
import definitions.is;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeModel;
import script.Plugin;
import script.log;
import main.core;
import utils.html;
/**
*
* @author Nuno Brito, 13th of November 2013 in Darmstadt, Germany.
* nuno.brito@triplecheck.de | http://nunobrito.eu
*/
public class nodeTools extends Plugin{
final String LastFolderNewSPDX = "LastFolderNewSPDX";
int interval = 3;
@Override
public void startup(){
// react whenever a tree node is changed
log.hooks.addAction(Messages.ReadyToUse, thisFile, "addNode");
log.hooks.addAction(Messages.TreeNodeChanged, thisFile, "showTools");
}
/**
* Add our toolbox node to the treeview.
*/
public void addNode(){
JTree tree = core.studio.getTree();
// avoid empty null objects when there is nothing on the tree
if(tree.getModel().getRoot()==null){
return;
}
TreeNodeSPDX nodeRoot = (TreeNodeSPDX) tree.getModel().getRoot();
TreeNodeSPDX node = swingUtils.nodeCreate("Tools", NodeType.none, nodeRoot);
node.setIcon("toolbox.png");
// all finished, write this data on GUI tree list
DefaultTreeModel treeModel = new DefaultTreeModel(nodeRoot);
tree.setModel(treeModel);
// store the tools node for future use
core.temp.put("nodeTree", node);
// all done. Signal that other plugins can now add their own tooling
log.write(is.INSTALLING, Messages.AddingTools);
}
/**
* Displays a basic list of tools that are supported
*/
public void showTools(){ // ensure we get to know which node is selected
TreeNodeSPDX node = swingUtils.getSelectedNode();
// no need to continue if there is nothing selected
if(node == null){
return;
}
// get the unique identifier
String nodeUID = node.getUID();
// are we clicking on the root of our intended node?
if(nodeUID.equals(">> Tools ") == false){
return;
}
String content = getContent();
core.studio.editorPane(is.contentHTML, false, 0, content);
}
/**
* Get the initial screen with the tools
* @return
*/
private String getContent() {
String result = ""
+ html.div()
+ "<h2>"
+ "Tools"
+ "</h2>"
+ html._div
+ html.div()
+ "The initial plan was to have a tool that would create SPDX "
+ "documents. It is now available. If you have any ideas for "
+ "other features to add up here, "
+ html.link("let us know!", "http://triplecheck.de")
+" :-)"
+ html.br
+ html.br
+ "<h3>"
+ "Version"
+ "</h3>"
+ html._div
+ html.div(20)
+ "You are using version " + core.version + " of TripleCheck"
+ html.br
+ html._div
+ "";
return result;
}
}