mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-12 18:06:40 +00:00
Cooja: Allow setting a folder to search for projects
This commit is contained in:
parent
142fa4a9a5
commit
32aa70e5cf
@ -29,21 +29,62 @@
|
||||
package se.sics.cooja;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.util.Collections;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* COOJA Project.
|
||||
*
|
||||
* @author Fredrik Osterlind
|
||||
* @author Moritz Strübe
|
||||
*/
|
||||
public class COOJAProject {
|
||||
private static Logger logger = Logger.getLogger(COOJAProject.class);
|
||||
|
||||
|
||||
public static File[] sarchProjects(File folder){
|
||||
return sarchProjects(folder, 3);
|
||||
}
|
||||
|
||||
public static File[] sarchProjects(File folder, int depth){
|
||||
if(depth == 0){
|
||||
return null;
|
||||
}
|
||||
depth--;
|
||||
ArrayList<File> dirs = new ArrayList<File>();
|
||||
|
||||
if(!folder.isDirectory()){
|
||||
logger.warn("Project directorys: " + folder.getPath() + "is not a Folder" );
|
||||
return null;
|
||||
}
|
||||
File[] files = folder.listFiles();
|
||||
for(File subf : files){
|
||||
if(subf.getName().charAt(0) == '.') continue;
|
||||
if(subf.isDirectory()){
|
||||
File[] newf = sarchProjects(subf, depth);
|
||||
if(newf != null){
|
||||
Collections.addAll(dirs, newf);
|
||||
}
|
||||
}
|
||||
if(subf.getName().equals(GUI.PROJECT_CONFIG_FILENAME)){
|
||||
try{
|
||||
dirs.add(folder);
|
||||
} catch(Exception e){
|
||||
logger.error("Somthing odd happend", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dirs.toArray(new File[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public File dir = null;
|
||||
public File configFile = null;
|
||||
public ProjectConfig config = null;
|
||||
|
||||
|
||||
public COOJAProject(File dir) {
|
||||
try {
|
||||
|
@ -247,7 +247,8 @@ public class GUI extends Observable {
|
||||
public static Properties currentExternalToolsSettings;
|
||||
|
||||
private static final String externalToolsSettingNames[] = new String[] {
|
||||
"PATH_CONTIKI", "PATH_COOJA_CORE_RELATIVE", "PATH_COOJA", "PATH_APPS",
|
||||
"PATH_CONTIKI", "PATH_COOJA_CORE_RELATIVE","PATH_COOJA","PATH_APPS",
|
||||
"PATH_APPSEARCH",
|
||||
|
||||
"PATH_MAKE",
|
||||
"PATH_SHELL",
|
||||
@ -426,6 +427,20 @@ public class GUI extends Observable {
|
||||
currentProjects.add(new COOJAProject(projectDir));
|
||||
}
|
||||
}
|
||||
|
||||
//Scan for projects
|
||||
String searchProjectDirs = getExternalToolsSetting("PATH_APPSEARCH", null);
|
||||
if (searchProjectDirs != null && searchProjectDirs.length() > 0) {
|
||||
String[] arr = searchProjectDirs.split(";");
|
||||
for (String d : arr) {
|
||||
File searchDir = restorePortablePath(new File(d));
|
||||
File[] projects = COOJAProject.sarchProjects(searchDir, 3);
|
||||
if(projects == null) continue;
|
||||
for(File p : projects){
|
||||
currentProjects.add(new COOJAProject(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse current extension configuration */
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user