|
a/tool/run/plugins/basic/TreeNodeDetails.java |
|
b/tool/run/plugins/basic/TreeNodeDetails.java |
|
... |
|
... |
20 |
import definitions.definition;
|
20 |
import definitions.definition;
|
21 |
import definitions.is;
|
21 |
import definitions.is;
|
22 |
import java.awt.Cursor;
|
22 |
import java.awt.Cursor;
|
23 |
import java.io.File;
|
23 |
import java.io.File;
|
24 |
import java.util.Enumeration;
|
24 |
import java.util.Enumeration;
|
|
|
25 |
import java.util.HashMap;
|
25 |
import main.core;
|
26 |
import main.core;
|
26 |
import main.param;
|
27 |
import main.param;
|
27 |
import script.Plugin;
|
28 |
import script.Plugin;
|
28 |
import script.log;
|
29 |
import script.log;
|
29 |
import spdxlib.FileInfo;
|
30 |
import spdxlib.FileInfo;
|
|
... |
|
... |
144 |
* Creates a tree of folders and respective files
|
145 |
* Creates a tree of folders and respective files
|
145 |
* @param root
|
146 |
* @param root
|
146 |
* @param spdx
|
147 |
* @param spdx
|
147 |
*/
|
148 |
*/
|
148 |
private void doTreeStructure(TreeNodeSPDX root, SPDXfile spdx){
|
149 |
private void doTreeStructure(TreeNodeSPDX root, SPDXfile spdx){
|
|
|
150 |
|
|
|
151 |
HashMap nodeList = new HashMap();
|
|
|
152 |
|
149 |
// go through all the files inside the SPDX
|
153 |
// go through all the files inside the SPDX
|
150 |
for(FileInfo fileInfo : spdx.fileSection.files){
|
154 |
for(FileInfo fileInfo : spdx.fileSection.files){
|
151 |
// get the path for this file bit
|
155 |
// get the path for this file bit
|
152 |
String path = getFilePath(fileInfo);
|
156 |
String path = getFilePath(fileInfo);
|
153 |
//String parentFolder = getParentFolder(path);
|
157 |
//String parentFolder = getParentFolder(path);
|
154 |
// add it up to our list
|
158 |
// add it up to our list
|
155 |
TreeNodeSPDX pathNode = addNodeFolder(root, path);
|
159 |
TreeNodeSPDX folderNode = addNodeFolder(root, path);
|
156 |
}
|
160 |
// put in our cached list
|
|
|
161 |
path = path.substring(0, path.length() -1);
|
|
|
162 |
nodeList.put(path, folderNode);
|
|
|
163 |
// ./jfreechart-1.0.17/lib/
|
|
|
164 |
//System.err.println(path);
|
157 |
|
165 |
}
|
158 |
|
166 |
|
|
|
167 |
// now add only the files
|
159 |
for(FileInfo fileInfo : spdx.fileSection.files){
|
168 |
for(FileInfo fileInfo : spdx.fileSection.files){
|
160 |
// get the path for this file bit
|
169 |
// get the path for this file bit
|
161 |
String path = getFilePath(fileInfo);
|
170 |
String path = getFilePath(fileInfo);
|
|
|
171 |
|
|
|
172 |
// get the cached location of its parent node
|
162 |
//String parentFolder = getParentFolder(path);
|
173 |
String parentFolder = getParentFolder(path);
|
163 |
// add it up to our list
|
174 |
// ./jfreechart-1.0.17/lib
|
164 |
TreeNodeSPDX pathNode = addNodeFolder(root, path);
|
175 |
TreeNodeSPDX pathNode = (TreeNodeSPDX) nodeList.get(parentFolder);
|
|
|
176 |
|
165 |
|
177 |
|
166 |
TreeNodeSPDX nodeFile = new TreeNodeSPDX(fileInfo.toString());
|
178 |
TreeNodeSPDX nodeFile = new TreeNodeSPDX(fileInfo.toString());
|
167 |
nodeFile.id = fileInfo.getName();
|
179 |
nodeFile.id = fileInfo.getName();
|
168 |
nodeFile.nodeType = NodeType.file;
|
180 |
nodeFile.nodeType = NodeType.file;
|
169 |
nodeFile.setUserObject(fileInfo);
|
181 |
nodeFile.setUserObject(fileInfo);
|
|
... |
|
... |
171 |
pathNode.add(nodeFile);
|
183 |
pathNode.add(nodeFile);
|
172 |
}
|
184 |
}
|
173 |
|
185 |
|
174 |
|
186 |
|
175 |
}
|
187 |
}
|
176 |
|
188 |
|
177 |
//
|
|
|
178 |
// /**
|
|
|
179 |
// * Provides a pretty name to place on the tree view
|
|
|
180 |
// * @param fileInfo
|
|
|
181 |
// * @return
|
|
|
182 |
// */
|
|
|
183 |
// private String getSimpleName(FileInfo fileInfo){
|
|
|
184 |
// String result = fileInfo.tagFileName.getValue();
|
|
|
185 |
// if(result.contains("/")){
|
|
|
186 |
// return result.substring(result.lastIndexOf("/")+1);
|
|
|
187 |
// }
|
|
|
188 |
// return result;
|
|
|
189 |
// }
|
|
|
190 |
|
|
|
191 |
|
189 |
|
192 |
/**
|
190 |
/**
|
193 |
* Adds a given folder as child from a specific folder
|
191 |
* Adds a given folder as child from a specific folder
|
194 |
*/
|
192 |
*/
|
195 |
private TreeNodeSPDX addNodeFolder(TreeNodeSPDX root, String newFolder){
|
193 |
private TreeNodeSPDX addNodeFolder(TreeNodeSPDX root, String newFolder){
|
|
... |
|
... |
290 |
}
|
288 |
}
|
291 |
return null;
|
289 |
return null;
|
292 |
}
|
290 |
}
|
293 |
|
291 |
|
294 |
|
292 |
|
295 |
// /**
|
293 |
/**
|
296 |
// * Returns the parent path (if available)
|
294 |
* Returns the parent path (if available)
|
297 |
// */
|
295 |
*/
|
298 |
// private String getParentFolder(String path){
|
296 |
private String getParentFolder(String path){
|
299 |
// // we need to count the number of slashes
|
297 |
// we need to count the number of slashes
|
300 |
// int lengthOriginal = path.length();
|
298 |
int lengthOriginal = path.length();
|
301 |
// String temp = path.replace("/", "");
|
299 |
String temp = path.replace("/", "");
|
302 |
// // do we have at least two slashes?
|
300 |
// do we have at least two slashes?
|
303 |
// if(lengthOriginal > (temp.length() + 1)){
|
301 |
if(lengthOriginal > (temp.length() + 1)){
|
304 |
// // get everything up to last slash
|
302 |
// get everything up to last slash
|
305 |
// return path.substring(0, path.lastIndexOf("/"));
|
303 |
return path.substring(0, path.lastIndexOf("/"));
|
306 |
// }
|
304 |
}
|
307 |
// // we have nothing, return the root folder
|
305 |
// we have nothing, return the root folder
|
308 |
// return "./";
|
306 |
return "./";
|
309 |
// }
|
307 |
}
|
310 |
|
308 |
|
311 |
|
309 |
|
312 |
/**
|
310 |
/**
|
313 |
* Returns the path portion from a given FileInfo object
|
311 |
* Returns the path portion from a given FileInfo object
|
314 |
* @return
|
312 |
* @return
|