mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-30 04:29:11 +00:00
Cooja: Allow setting a folder to search for projects
This commit is contained in:
parent
142fa4a9a5
commit
32aa70e5cf
@ -29,22 +29,63 @@
|
|||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COOJA Project.
|
* COOJA Project.
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
|
* @author Moritz Strübe
|
||||||
*/
|
*/
|
||||||
public class COOJAProject {
|
public class COOJAProject {
|
||||||
private static Logger logger = Logger.getLogger(COOJAProject.class);
|
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 dir = null;
|
||||||
public File configFile = null;
|
public File configFile = null;
|
||||||
public ProjectConfig config = null;
|
public ProjectConfig config = null;
|
||||||
|
|
||||||
|
|
||||||
public COOJAProject(File dir) {
|
public COOJAProject(File dir) {
|
||||||
try {
|
try {
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
|
@ -247,7 +247,8 @@ public class GUI extends Observable {
|
|||||||
public static Properties currentExternalToolsSettings;
|
public static Properties currentExternalToolsSettings;
|
||||||
|
|
||||||
private static final String externalToolsSettingNames[] = new String[] {
|
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_MAKE",
|
||||||
"PATH_SHELL",
|
"PATH_SHELL",
|
||||||
@ -427,6 +428,20 @@ public class GUI extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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 */
|
/* Parse current extension configuration */
|
||||||
try {
|
try {
|
||||||
reparseProjectConfig();
|
reparseProjectConfig();
|
||||||
|
Loading…
Reference in New Issue
Block a user