//Gets the selected project
// TODO: remember the project selection
IProject project = FuseboxPlugin.getWorkspace().getRoot().getProject(this.project);
//Convert this to a factory. so you would have a base class FBXParser
FBX4parser parser4 = new FBX4parser();
FBX3parser parser3 = new FBX3parser();
invisibleRoot = new FBXRoot("");
FBXApplication app = null;
boolean version3 = true;
boolean version4 = false;
//Get the root of the project
//This also happens within the parser, so we might want to send it
String rootpath = "/"; //default root of the fusebox application
QualifiedName qname = new QualifiedName("", FuseboxPreferenceConstants.P_FUSEBOX_PATH);
try
{
String thispath = project.getPersistentProperty(qname);
if(thispath != null){
if(!thispath.equals(rootpath)){
rootpath = thispath + "/";
}
}
} catch (CoreException e) {
e.printStackTrace();
}
/**
* TODO: Make this into a factory. That is how we find out what version of Fusebox
* we are running
*/
//Here we shall get either fbx_circuits.cfm or fusebox.xml.cfm
//Lets try first version 3
IFile cirFile = project.getFile(rootpath + fbx3circuitroot);
Utils.println("fusebox 3 root" + rootpath + fbx3circuitroot);
Utils.println("does the fb3 exist?" + cirFile.exists());
if(!cirFile.exists()){ /* if we dont have an upper case */
cirFile = project.getFile(rootpath + fbx3circuitroot.toLowerCase());
if(!cirFile.exists()){
cirFile = null;
version3 = false;
} else {
version4 = false;
version3 = true;
}
}
FileReader fb4reader = new FileReader(rootpath, project);
IFile fuseboxFile = fb4reader.getFilePath(this.fbx4circuitroot, this.fbx4altcirciutroot);
if(!version3){
if((fuseboxFile !=null) && fuseboxFile.exists()){
/* if we dont find it (lowercase) */
version4 = true;
}
}
if(version4){
app = parser4.parse(project, fuseboxFile);
}
else{
app = parser3.parse(project, cirFile);
}
//An FBXApplication is a a tree, the parser returns this tree from a project (drop down right?)