Child: [r7] (diff)

Download this file

TreeNodeSPDX.java    85 lines (69 with data), 2.1 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
/*
* SPDXVersion: SPDX-1.1
*
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
*
* Creator: Organization: TripleCheck (contact@triplecheck.de)
*
* Created: 2013-09-01T00:00:00Z
*
* LicenseName: NOASSERTION
*
* FileName: TreeNodeSPDX.java
*
* FileType: SOURCE
*
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
*
* FileComment: <text> A tree node object adapted for SPDX documents </text>
*/
package GUI;
import java.io.File;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.tree.DefaultMutableTreeNode;
import main.core;
public class TreeNodeSPDX extends DefaultMutableTreeNode{
public NodeType // define the type of node that we have here
nodeType = NodeType.none;
public String
id = "";
// in case we want to run a file with a script
public File
scriptFile = null,
scriptFolder = null;
// if a file with a script was added, which method should be run?
public String scriptMethod;
public Icon icon = null;
public TreeNodeSPDX(String library) {
super(library);
}
// @Override
// public String toString(){
// return "";
// }
public TreeNodeSPDX(TreeNodeSPDX root) {
super(root);
}
/**
* Given a specific tree node, generate a unique ID
* @param node the node from where start to calculate the ID string
* @return a unique ID based on the parent nodes of this entry
*/
public String getUID(){
String result = "";
TreeNodeSPDX currentNode = this;
while(currentNode.getParent() != null){
result = result + ">> " + currentNode.id + " ";
currentNode = (TreeNodeSPDX) currentNode.getParent();
}
return result;
}
/**
* Defines a new Icon for this node
* @param what the icon file name that is located under the "icons" folder
*/
public void setIcon(String what){
icon = new ImageIcon(core.getIcon(what).getAbsolutePath());
}
}