//<Script type="text/javascript">
+/**
+ * Project Object
+ *
+ * Projects can only contain one directory... - it can import other projects..(later)
+ *
+ * we need to sort out that - paths is currently a key/value array..
+ *
+ *
+ *
+ */
+
Gio = imports.gi.Gio;
GLib = imports.gi.GLib;
console = imports.console;
XObject = imports.XObject.XObject;
+File = imports.File.File;
ProjectManager = imports.Builder.Provider.ProjectManager.ProjectManager;
Observable = imports.Observable.Observable;
Observable,
{
id : false,
- fn: false,
+ fn: false, // the md5 sum for this one..
paths : false,
files : false,
tree : false,
xtype : false,
- load : function (o)
+ load : function (o) // is this used??
{
if (!this.fetchTree) {
console.log("Project.getTree tree called on base object?!?!");
{
var ret = { };
var _this = this;
- ['id', 'fn', 'paths', 'xtype', 'name'].forEach( function(k) {
+ for (var k in _this) {
+
+ if (['files', 'tree'].indexOf(k) > -1) {
+ continue;
+ }
+ if (k != 'paths') {
+ if ((typeof(_this[k]) == 'object') ||(typeof(_this[k]) == 'function')) {
+ continue;
+ }
+ }
+ print("Storing " + k);
ret[k] = _this[k];
- });
- ret.files = { };
- // deal with files..
- for (var f in this.files) {
- print(f);
- ret.files[f] = this.files[f].toJsonArray();
}
+ // deal with files..
+ //for (var f in this.files) {
+ // print(f);
+ // ret.files[f] = this.files[f].toJsonArray();
+ // }
+
+
return JSON.stringify(ret);
},
+ getName :function()
+ {
+ //returns the basename of the first path..
+ for (var i in this.paths) {
+ return GLib.basename(i);
+ }
+ },
+
toTree : function()
{
if (!f) {
continue;
}
- console.dump(f);
+ ///console.dump(f);
f.hasParent = false;
f.cn = [];
//console.log(f.name);
var cls = imports.Builder.Provider.File[xt][xt];
return new cls({
path : path,
- parent : ''
+ parent : '',
+ project : this
});
},
create : function(filename)
},
-
+
addFile: function(pfile) { // add a single file, and trigger changed.
this.files[pfile.path] = pfile
this.fireEvent('changed', this);
this.files[path] = this.loadFileOnly( path );
}
- console.dump(this.files);
+ // console.dump(this.files);
this.fireEvent('changed', this);
},
return;
}
// this should be done async -- but since we are getting the proto up ...
- var gdir = GLib.dir_open(dir,0);
+ var dirs = File.list(dir);
var subs = [];
var _this = this;
- while (true) {
- var fn = GLib.dir_read_name(gdir);
+ dirs.forEach(function( fn ){
+
console.log('trying ' + dir + '/' + fn);
if (!fn) {
- GLib.dir_close(gdir);
subs.forEach( function(s) {
_this.scanDir(s, dp+1);
});
return;
}
if (fn[0] == '.') { // skip hidden
- continue;
+ return;
}
if (GLib.file_test(dir + '/' + fn, GLib.FileTest.IS_DIR)) {
subs.push(dir + '/' + fn);
- continue;
+ return;
}
if (!fn.match(/\.bjs$/)) {
- continue;
+ return;
}
var parent = '';
//if (dp > 0 ) {
parent = sp.join('.');
- if (typeof(this.files[dir + '/' + fn]) != 'undefined') {
+ if (typeof(_this.files[dir + '/' + fn]) != 'undefined') {
// we already have it..
- this.files[dir + '/' + fn].parent = parent;
- continue;
+ _this.files[dir + '/' + fn].parent = parent;
+ return;
}
- var xt = this.xtype;
+ var xt = _this.xtype;
var cls = imports.Builder.Provider.File[xt][xt];
Seed.print("Adding file " + dir + '/' + fn);
- this.files[dir + '/' + fn] = new cls({
+ _this.files[dir + '/' + fn] = new cls({
path : dir + '/' + fn,
- parent : parent
+ parent : parent,
+ project : _this
});
- console.log(this.files[dir + '/' + fn] );
+ //console.log(this.files[dir + '/' + fn] );
/*
var f = Gio.file_new_for_path(dir + '/' + fn);
var inf = f.query_info('standard::*');
// fixme... time data is busted..
this.files[dir + '/' + fn] = '' + tv.tv_sec + '.' + tv.tv_usec;
*/
- }
+ });
}