[Sciviews-commits] r88 - komodo/SciViews-K/content/js

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 12 10:49:58 CET 2009


Author: prezez
Date: 2009-01-12 10:49:58 +0100 (Mon, 12 Jan 2009)
New Revision: 88

Modified:
   komodo/SciViews-K/content/js/r.js
Log:
small changes to sv.r

Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js	2009-01-11 15:44:21 UTC (rev 87)
+++ komodo/SciViews-K/content/js/r.js	2009-01-12 09:49:58 UTC (rev 88)
@@ -332,7 +332,7 @@
 	var res = false;
 	if (typeof(topic) == "undefined" | topic == "") topic = sv.getText();
 	if (topic == "") {
-		alert("Nothing is selected!");
+		//alert("Nothing is selected!");
 	} else {
 		// Display data in different ways, depending on what
 		switch(what) {
@@ -385,8 +385,10 @@
 		cmd += pkg? ' package = "' + pkg + '", ' : "";
 		cmd += topic? ' topic = "' + topic + '", ' : "";
 
+		cmd = 'cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))';
+
 		// TODO: error handling when package does not exists
-		res = sv.r.evalCallback('cat(unclass(help(' + cmd + ' htmlhelp = TRUE)))', sv.browseURI);
+		res = sv.r.evalCallback(cmd, sv.browseURI);
 
 		ko.statusBar.AddMessage("R help asked for '" + topic + "'",
 			"R", 5000, true);
@@ -400,7 +402,7 @@
 	var res = false;
 	if (typeof(topic) == "undefined" | topic == "") topic = sv.getText();
 	if (topic == "") {
-		alert("Nothing is selected!");
+		//alert("Nothing is selected!");
 	} else {
 		res = sv.r.eval("example(" + topic + ")");
 		ko.statusBar.AddMessage("R example run for '" + topic + "'",
@@ -455,7 +457,7 @@
 	var res = false;
 	if (typeof(topic) == "undefined" | topic == "") topic = sv.getText();
 	if (topic == "") {
-		alert("Nothing is selected!");
+		//alert("Nothing is selected!");
 	} else {
 		res = sv.r.evalHidden('RSiteSearch("' + topic + '")', earlyExit = true);
 		ko.statusBar.AddMessage("R site search asked for '" + topic + "'",
@@ -528,13 +530,13 @@
   sv.r.eval('save.image("' + file + '")');
 }
 
+
 // Load the content of a .RData file into the workspace, or attach it
 sv.r.loadWorkspace = function(file, attach) {
   // Ask for the filename if not provided
   if (!file) {
 	//file = ko.filepicker.openFile("", ".RData", title);
-	file = sv.fileOpen("", ".RData", 'Load an .RData file', ['R workspace (*.RData)|*.RData'], true);
-	alert(typeof file)
+	file = sv.fileOpen("", ".RData", 'Load an .RData file', ['R workspace (*.RData)|*.RData'], true)[0];
 	if (!file)
 		return;	// User clicked cancel
   }
@@ -679,9 +681,9 @@
 				var topic = ko.dialogs.selectFromList("Load R package",
 					"Select R package(s) to load:", items);
 				if (topic != null) {
+					res = sv.r.evalCallback('cat(paste(lapply(c("' + topic.join('", "') + '"), function(pkg) {	res <- try(library(package = pkg, character.only = TRUE)); 	paste ("Package", sQuote(pkg), if (inherits(res, "try-error")) "could not be loaded"  else "loaded")	}), collapse = "\\n"), "\\n")',
+									sv.cmdout.append);
 
-					res = sv.r.eval('cat(paste(lapply(c("' + topic.join('", "') + '"), function(pkg) {	res <- try(library(package = pkg, character.only = TRUE)); 	paste ("Package", sQuote(pkg), if (inherits(res, "try-error")) "could not be loaded"  else "loaded")	}), collapse = "\\n"), "\\n")');
-
 				}
 			}
 			return(res);
@@ -797,7 +799,7 @@
 					ko.statusBar.AddMessage("", "R");
 					var res = false;
 					if (pkgs.trim() == "") {
-						alert("Error?");
+						alert("Error?"); // TODO: remove this later
 					} else {
 						var items = pkgs.split(sv.r.sep);
 						items = ko.dialogs.selectFromList("Install R package",



More information about the Sciviews-commits mailing list