|
a/tool/src/main/actions.java |
|
b/tool/src/main/actions.java |
|
... |
|
... |
19 |
import static GUI.swingUtils.nodeCreate;
|
19 |
import static GUI.swingUtils.nodeCreate;
|
20 |
import definitions.is;
|
20 |
import definitions.is;
|
21 |
import java.io.File;
|
21 |
import java.io.File;
|
22 |
import java.io.IOException;
|
22 |
import java.io.IOException;
|
23 |
import java.util.ArrayList;
|
23 |
import java.util.ArrayList;
|
24 |
import java.util.HashMap;
|
|
|
25 |
import java.util.logging.Level;
|
24 |
import java.util.logging.Level;
|
26 |
import java.util.logging.Logger;
|
25 |
import java.util.logging.Logger;
|
27 |
import javax.swing.JTree;
|
26 |
import javax.swing.JTree;
|
28 |
import script.log;
|
27 |
import script.log;
|
29 |
import spdxlib.SPDXfile;
|
28 |
import spdxlib.SPDXfile;
|
30 |
import static utils.files.findFilesFiltered;
|
|
|
31 |
|
29 |
|
32 |
|
30 |
|
33 |
public class actions {
|
31 |
public class actions {
|
34 |
|
32 |
|
35 |
/**
|
33 |
/**
|
|
... |
|
... |
197 |
// how many files were found here?
|
195 |
// how many files were found here?
|
198 |
rootNode.setCounter(count);
|
196 |
rootNode.setCounter(count);
|
199 |
return count;
|
197 |
return count;
|
200 |
}
|
198 |
}
|
201 |
|
199 |
|
202 |
/**
|
200 |
// /**
|
203 |
* This is a critical method. It will look for all SPDX files inside a given
|
201 |
// * This is a critical method. It will look for all SPDX files inside a given
|
204 |
* folder and them as tree nodes
|
202 |
// * folder and them as tree nodes
|
205 |
* @param tree
|
203 |
// * @param tree
|
206 |
*/
|
204 |
// */
|
207 |
public static void addTreeSPDXOld(JTree tree) {
|
205 |
// public static void addTreeSPDXOld(JTree tree) {
|
208 |
// only find the SPDX documents with .SPDX extension
|
206 |
// // only find the SPDX documents with .SPDX extension
|
209 |
ArrayList<File> initialFileList = utils.files
|
207 |
// ArrayList<File> initialFileList = utils.files
|
210 |
.findFilesFiltered(core.getProductsFolder(), ".spdx", 25);
|
208 |
// .findFilesFiltered(core.getProductsFolder(), ".spdx", 25);
|
211 |
|
209 |
//
|
212 |
if(initialFileList.isEmpty()){
|
210 |
// if(initialFileList.isEmpty()){
|
213 |
// no need to continue, just leave here
|
211 |
// // no need to continue, just leave here
|
214 |
return;
|
212 |
// return;
|
215 |
}
|
213 |
// }
|
216 |
|
214 |
//
|
217 |
// this is used for filtering duplicate folders in the initial indexing
|
215 |
// // this is used for filtering duplicate folders in the initial indexing
|
218 |
ArrayList<File> tempFolderList = new ArrayList();
|
216 |
// ArrayList<File> tempFolderList = new ArrayList();
|
219 |
// where are our spdx files stored?
|
217 |
// // where are our spdx files stored?
|
220 |
String baseFolder = core.getProductsFolder().getAbsolutePath();
|
218 |
// String baseFolder = core.getProductsFolder().getAbsolutePath();
|
221 |
// get the root node where we have our treeview
|
219 |
// // get the root node where we have our treeview
|
222 |
TreeNodeSPDX rootNode = swingUtils.getRootNode(tree);
|
220 |
// TreeNodeSPDX rootNode = swingUtils.getRootNode(tree);
|
223 |
|
221 |
//
|
224 |
// where we place all results after being filtered
|
222 |
// // where we place all results after being filtered
|
225 |
ArrayList<File> fileList = new ArrayList();
|
223 |
// ArrayList<File> fileList = new ArrayList();
|
226 |
// iterate all files in our array that were found as products
|
224 |
// // iterate all files in our array that were found as products
|
227 |
for(File file: initialFileList){
|
225 |
// for(File file: initialFileList){
|
228 |
// now we need to filter what we don't want to have in our array
|
226 |
// // now we need to filter what we don't want to have in our array
|
229 |
String filename = file.getName();
|
227 |
// String filename = file.getName();
|
230 |
// we don't need SVN files, ignore them completely
|
228 |
// // we don't need SVN files, ignore them completely
|
231 |
if(filename.endsWith(".svn-base")){
|
229 |
// if(filename.endsWith(".svn-base")){
|
232 |
continue;
|
230 |
// continue;
|
233 |
}
|
231 |
// }
|
234 |
// add this file to our final list
|
232 |
// // add this file to our final list
|
235 |
fileList.add(file);
|
233 |
// fileList.add(file);
|
236 |
// now take care of the folder where this file was placed
|
234 |
// // now take care of the folder where this file was placed
|
237 |
// get only the folder base, be careful with path separators here
|
235 |
// // get only the folder base, be careful with path separators here
|
238 |
String folderName = file.getParent().replace(baseFolder, "");
|
236 |
// String folderName = file.getParent().replace(baseFolder, "");
|
239 |
// no need to add in case the folder is the root
|
237 |
// // no need to add in case the folder is the root
|
240 |
if(folderName.isEmpty()){
|
238 |
// if(folderName.isEmpty()){
|
241 |
continue;
|
239 |
// continue;
|
242 |
}
|
240 |
// }
|
243 |
File folder = file.getParentFile();
|
241 |
// File folder = file.getParentFile();
|
244 |
// no need to continue in case this folder was already added before
|
242 |
// // no need to continue in case this folder was already added before
|
245 |
if(tempFolderList.contains(folder)){
|
243 |
// if(tempFolderList.contains(folder)){
|
246 |
continue;
|
244 |
// continue;
|
247 |
}
|
245 |
// }
|
248 |
// add it up
|
246 |
// // add it up
|
249 |
tempFolderList.add(folder);
|
247 |
// tempFolderList.add(folder);
|
250 |
}
|
248 |
// }
|
251 |
|
249 |
//
|
252 |
// create the node for hosting our list of SPDX documents
|
250 |
// // create the node for hosting our list of SPDX documents
|
253 |
TreeNodeSPDX softwareNode = nodeCreate(
|
251 |
// TreeNodeSPDX softwareNode = nodeCreate(
|
254 |
"Software (" + fileList.size() + ")"
|
252 |
// "Software (" + fileList.size() + ")"
|
255 |
, NodeType.other, rootNode);
|
253 |
// , NodeType.other, rootNode);
|
256 |
// add the identification to this tag
|
254 |
// // add the identification to this tag
|
257 |
softwareNode.id = "Software";
|
255 |
// softwareNode.id = "Software";
|
258 |
softwareNode.setIcon("box.png");
|
256 |
// softwareNode.setIcon("box.png");
|
259 |
|
257 |
//
|
260 |
// we need to map a list of spdx folders and files
|
258 |
// // we need to map a list of spdx folders and files
|
261 |
HashMap<File, TreeNodeSPDX> folderList = new HashMap();
|
259 |
// HashMap<File, TreeNodeSPDX> folderList = new HashMap();
|
262 |
// first pass to add up all nodes and folders
|
260 |
// // first pass to add up all nodes and folders
|
263 |
for(File folder : tempFolderList){
|
261 |
// for(File folder : tempFolderList){
|
264 |
TreeNodeSPDX node = new TreeNodeSPDX(folder.getName());
|
262 |
// TreeNodeSPDX node = new TreeNodeSPDX(folder.getName());
|
265 |
node.setIcon("envelope.png");
|
263 |
// node.setIcon("envelope.png");
|
266 |
folderList.put(folder, node);
|
264 |
// folderList.put(folder, node);
|
267 |
}
|
265 |
// }
|
268 |
|
266 |
//
|
269 |
|
267 |
//
|
270 |
|
268 |
//
|
271 |
// second pass to add them all up on the tree view
|
269 |
// // second pass to add them all up on the tree view
|
272 |
for(File folder : folderList.keySet()){
|
270 |
// for(File folder : folderList.keySet()){
|
273 |
TreeNodeSPDX node = folderList.get(folder);
|
271 |
// TreeNodeSPDX node = folderList.get(folder);
|
274 |
softwareNode.add(node);
|
272 |
// softwareNode.add(node);
|
275 |
}
|
273 |
// }
|
276 |
|
274 |
//
|
277 |
|
275 |
//
|
278 |
|
276 |
//
|
279 |
//System.exit(-1981);
|
277 |
// //System.exit(-1981);
|
280 |
}
|
278 |
// }
|
281 |
|
279 |
//
|
282 |
|
280 |
|
283 |
//
|
281 |
//
|
284 |
// // iterate through the final list, build the folder list, add tree nodes
|
282 |
// // iterate through the final list, build the folder list, add tree nodes
|
285 |
// for(File file: fileList){
|
283 |
// for(File file: fileList){
|
286 |
// // get only the folder base, be careful with path separators here
|
284 |
// // get only the folder base, be careful with path separators here
|