XObject = imports.XObject.XObject;
Observable = imports.Observable.Observable;
-
+File = imports['../../File.js'].File;
/**
*
* /home/alan/.BuilderConfig/*
this.saveConfig();
}
- },
-
+ },
+ palete : { },
projects : [],
filename : false,
dir.make_directory();
return;
}
-
-
-
+
this.projects = [];
- var gdir = GLib.dir_open(this.dirname,0);
- while (true) {
-
- var fn = GLib.dir_read_name(gdir);
- if (!fn) {
- GLib.dir_close(gdir);
- return;
- }
+ var files = File.list(this.dirname);
+ for (var i =0 ; i < files.length;i++) {
+ var fn = files[i];
+
if (!fn.match(/.json$/)) {
continue;
}
- var file = Gio.file_new_for_path(this.dirname + '/' + fn);
- Seed.print(this.dirname + '/' + fn);
- var stream = file.read();
- var dstream = new Gio.DataInputStream.c_new(stream);
- Seed.print(dstream);
-
- str = dstream.read_until("");
+ var str = File.read(this.dirname + '/' + fn);
if (!str || !str.length) {
continue; // empty file.
}
Seed.print(ar.xtype);
// construct...
-
- this.projects.push( new Builder.Provider.Project[ar.xtype](ar));
+ var cls = imports.Builder.Provider.Project[ar.xtype][ar.xtype];
+ this.projects.push( new cls(ar));
}
+ this.projects.sort(function(a,b) {
+ if (a.getName() == b.getName()) {
+ return 0;
+ }
+ return a.getName() > b.getName() ? 1 : -1;
+
+
+ });
+
+
saveConfig : function()
{
- Roo.each(this.projects, function(p) {
+ var _this = this;
+ this.projects.forEach( function(p) {
if (!p.fn) {
// make the filename..
}
- var file = Gio.file_new_for_path(this.dirname + '/' + p.fn + '.json');
+ var file = Gio.file_new_for_path(_this.dirname + '/' + p.fn + '.json');
var stream = file.replace(null,false,0);
+ //console.dump(p);
var s = p.toJSON();
stream.write(s, s.length);
stream.close();
- }, this);
+ });
Seed.print(JSON.stringify(proj));
var found = false;
- Roo.each(this.projects , function(p) {
+ this.projects.forEach( function(p) {
if (proj == p) {
found = true;
return true;
return proj;
return;
}
- var pr = new Builder.Provider.Project[proj.xtype](proj);
+ var cls = imports.Builder.Provider.Project[proj.xtype][proj.xtype];
+ var pr = new cls(proj);
this.projects.push(pr );
this.fireEvent('changed', this);
return pr;
},
+
+ deleteProject : function (fn)
+ {
+ var newplist = [];
+ var _this = this;
+ this.projects.forEach(function(p) {
+ if (p.fn != fn) {
+ newplist.push(p);
+ return;
+ }
+ var file = _this.dirname + '/' + p.fn + '.json';
+ if (File.exists(file)) {
+ File.remove(file);
+ }
+
+ });
+ this.projects = newplist;
+ this.fireEvent('changed', this);
+ },
+
+
getByFn : function (fn) {
var ret = false;
- Roo.each(this.projects, function(p) {
+ this.projects.forEach(function(p) {
if (p.fn == fn) {
ret = p;
return true;
});
return ret;
+ },
+ getPalete: function(type) {
+ if (typeof(ProjectManager.palete[type]) != 'undefined') {
+ print ("ALREADY GOT " + type);
+ return ProjectManager.palete[type];
+ }
+ var cls = imports.Builder.Provider.Palete[type][type];
+
+ ProjectManager.palete[type] = new cls();
+ print (typeof(ProjectManager.palete[type]));
+ return ProjectManager.palete[type];
}