[Sciviews-commits] r15 - komodo/SciViews-K/content/js
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 26 11:46:11 CEST 2008
Author: romain
Date: 2008-06-26 11:46:10 +0200 (Thu, 26 Jun 2008)
New Revision: 15
Modified:
komodo/SciViews-K/content/js/robjects.js
Log:
fixed bug #159
Modified: komodo/SciViews-K/content/js/robjects.js
===================================================================
--- komodo/SciViews-K/content/js/robjects.js 2008-06-25 21:50:46 UTC (rev 14)
+++ komodo/SciViews-K/content/js/robjects.js 2008-06-26 09:46:10 UTC (rev 15)
@@ -4,10 +4,14 @@
// Contribution from Philippe Grosjean
////////////////////////////////////////////////////////////////////////////////
+// data objects:
+//
// objectList // List of objects to display
-// searchPaths // List of serach paths in R
-// searchPathsSelected // List of currently selected search paths
+// searchPaths // List of search paths in R
//
+//==============================================================================
+// functions :
+//
// sv.r.objects.searchpath(); // Show/hide the search path listbox
// sv.r.objects.getPackageList(); // Query R for the search path
// sv.r.objects._processPackageList(data); // Callback to process this list
@@ -35,8 +39,7 @@
if (typeof(sv.r.objects) == 'undefined')
sv.r.objects = {
objectList: [],
- searchPaths: [],
- searchPathsSelected: []
+ searchPaths: []
}
// Show/hide the search path listbox
@@ -61,7 +64,7 @@
sv.r.objects._processPackageList = function(data) {
if (data == "") { return; } // No changes
sv.r.objects.searchPaths = data.replace(/[\n\r]/g, "").split(/,/);
- sv.r.objects.displayPackageList();
+ sv.r.objects.displayPackageList();
};
// Display the list of packages in the search path
@@ -73,8 +76,8 @@
var item;
var packs = sv.r.objects.searchPaths;
var k = 0;
- var checked = "false";
- for(var i = 0; i < packs.length; i++) {
+ var ischecked = "false";
+ for(var i = 0; i < packs.length; i++) {
pack = packs[i]
if (sv.r.objects.__isSelected(pack)) {
ischecked = "true";
@@ -88,42 +91,40 @@
/>;
sv.tools.e4x2dom.append(item, node, k);
k++;
- }
+ }
sv.r.objects.displayObjectList(false);
- // if(goback) tb.focus();
};
// Ask R for the list of objects in an environment
sv.r.objects.addObjectList = function(pack) {
var id = sv.prefs.getString("sciviews.client.id", "SciViewsK");
var cmd = 'cat(objList(id = "' + id + '_' + pack + '", envir = "' + pack +
- '", all.info = TRUE, sep = ","), sep = "\n")';
+ '", all.info = TRUE, sep = ",", compare = FALSE), sep = "\\n")';
sv.r.evalCallback(cmd, sv.r.objects._processObjectList);
};
// Callback to process the list of objects in an environment
sv.r.objects._processObjectList = function(data) {
- if (data == "") { return; } //no changes
- lines = data.split("\n");
+ if (data == "") { return; } //no changes
+ var lines = data.split("\n");
var rx = /,/;
var item, line;
var pack;
var idx;
for (var i = 0; i < lines.length; i++) {
- if (rx.test(lines[i])) {
- line = lines[i].split(",");
- pack = line[0];
-
- if (sv.r.objects.objectList[pack] == undefined) {
- sv.r.objects.objectList[pack] = [];
- idx = 0;
- } else {
- idx = sv.r.objects.objectList[pack].length;
- }
- sv.r.objects.objectList[pack][idx] =
- new Array(line[1], line[2], line[3], line[4], line[5]);
- }
+ if (rx.test(lines[i])) {
+ line = lines[i].split(",");
+ pack = line[0];
+ if (sv.r.objects.objectList[pack] == undefined) {
+ sv.r.objects.objectList[pack] = [];
+ idx = 0;
+ } else {
+ idx = sv.r.objects.objectList[pack].length;
+ }
+ sv.r.objects.objectList[pack][idx] =
+ new Array(line[1], line[2], line[3], line[4], line[5]);
+ }
}
sv.r.objects.displayObjectList();
};
@@ -134,14 +135,15 @@
var obRx = new RegExp(tb.value);
var node = document.getElementById("sciviews_robjects_objects_tree_main");
- var k = 0;
+ sv.tools.e4x2dom.clear(node);
+ // var k = 0;
var currentPack;
var currentFun;
for (var pack in sv.r.objects.objectList) {
- currentPack = sv.r.objects.objectList[pack];
- item =
- <treeitem container="true" open="true">
+ currentPack = sv.r.objects.objectList[pack];
+ item =
+ <treeitem container="true" open="true">
<treerow>
<treecell label={pack} properties="package" />
<treecell label="" />
@@ -149,25 +151,25 @@
<treecell label="" />
</treerow>
<treechildren />
- </treeitem>;
- item.treechildren.treeitem = new XMLList();
- for (var i = 0; i < currentPack.length; i++) {
- currentFun = currentPack[i];
- if (obRx.test(currentFun[0])) {
- item.treechildren.treeitem +=
- <treeitem >
- <treerow>
- <treecell label={currentFun[0]}
- properties={currentFun[3].replace(".", "-" )} />
- <treecell label={currentFun[1]} />
- <treecell label={currentFun[2]} />
- <treecell label={currentFun[3]} />
- </treerow>
- </treeitem>;
- }
+ </treeitem>;
+ item.treechildren.treeitem = new XMLList();
+ for (var i = 0; i < currentPack.length; i++) {
+ currentFun = currentPack[i];
+ if (obRx.test(currentFun[0])) {
+ item.treechildren.treeitem +=
+ <treeitem >
+ <treerow>
+ <treecell label={currentFun[0]}
+ properties={currentFun[3].replace(".", "-" )} />
+ <treecell label={currentFun[1]} />
+ <treecell label={currentFun[2]} />
+ <treecell label={currentFun[3]} />
+ </treerow>
+ </treeitem>;
}
- sv.tools.e4x2dom.append(item, node, k);
- k++;
+ }
+ sv.tools.e4x2dom.appendTo(item, node);
+ // k++;
}
if(goback) tb.focus();
};
@@ -183,35 +185,35 @@
// Process selection/deselection of packages
sv.r.objects.packageSelected = function(pack, status) {
if (status) {
- if (!sv.r.objects.__isSelected(pack)) {
- sv.r.objects.__addPackageToSelection(pack);
- }
+ sv.r.objects.__addPackageToSelection(pack);
} else {
- if (sv.r.objects.__isSelected(pack)) {
- sv.r.objects.__removePackageFromSelection(pack);
- }
+ sv.r.objects.__removePackageFromSelection(pack);
}
};
// Function that indicates whether a package is selected
sv.r.objects.__isSelected = function(p) {
- return(sv.tools.array.contains(sv.r.objects.searchPathsSelected, p));
+ for (var pack in sv.r.objects.objectList){
+ if(pack == p) return(true);
+ }
+ return(false);
};
// Add content of package to the tree
sv.r.objects.__addPackageToSelection = function(p) {
- sv.r.objects.searchPathsSelected[sv.r.objects.searchPathsSelected.length] = p;
+ if(sv.r.objects.debug) ko.statusBar.AddMessage("adding package" + p, "R", 5000, true)
sv.r.objects.addObjectList(p);
};
// Remove content of the package from the tree
sv.r.objects.__removePackageFromSelection = function(p) {
- sv.tools.array.remove(sv.r.objects.searchPathsSelected, p);
- sv.r.objects.objectList =
- sv.tools.array.removeItem(sv.r.objects.objectList, p);
+ if(sv.r.objects.debug) ko.statusBar.AddMessage("removing package" + p, "R", 5000, true)
+ sv.r.objects.objectList = sv.tools.array.removeItem(sv.r.objects.objectList, p);
sv.r.objects.displayObjectList();
};
// Make sure to check .GlobalEnv at the beginning
// TODO: persitently save user's selection using Komodo mechanism
sv.r.objects.packageSelected(".GlobalEnv", true);
+
+sv.r.objects.debug = false ;
More information about the Sciviews-commits
mailing list