[Sciviews-commits] r232 - in komodo/SciViews-K: . content content/js content/js/tools defaults
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 27 00:58:46 CET 2009
Author: prezez
Date: 2009-11-27 00:58:46 +0100 (Fri, 27 Nov 2009)
New Revision: 232
Modified:
komodo/SciViews-K/
komodo/SciViews-K/content/RHelpWindow.xul
komodo/SciViews-K/content/js/commands.js
komodo/SciViews-K/content/js/pref-R.js
komodo/SciViews-K/content/js/prefs.js
komodo/SciViews-K/content/js/r.js
komodo/SciViews-K/content/js/tools/file.js
komodo/SciViews-K/content/overlayMain.xul
komodo/SciViews-K/content/pref-R.xul
komodo/SciViews-K/defaults/svStart.R
komodo/SciViews-K/install.rdf
Log:
Preferences panel reworked (not yet finished, needs testing on Mac).
Property changes on: komodo/SciViews-K
___________________________________________________________________
Name: svn:ignore
- !*
*-dev.*
build
+ !*
*-dev.*
build
*.xpi
*.xpi
Modified: komodo/SciViews-K/content/RHelpWindow.xul
===================================================================
--- komodo/SciViews-K/content/RHelpWindow.xul 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/RHelpWindow.xul 2009-11-26 23:58:46 UTC (rev 232)
@@ -336,24 +336,6 @@
}).apply(browserUtils);
-function _getWindowByURI(uri) {
- var wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
- .getService(Components.interfaces.nsIWindowMediator);
- en = wm.getEnumerator("");
-
- if (uri) {
- var win;
- while (en.hasMoreElements()) {
- win = en.getNext();
- if ((win.location.href == uri) ||
- (win.location.href.lastIndexOf(uri) == win.location.href.length - uri.length))
- return win;
- }
- }
- return null;
-}
-
-
function windowOnLoad (event) {
// DOMContentLoaded is fired also for HTML content
if (event.target != self.document)
@@ -366,8 +348,13 @@
sv = args[0];
if (typeof(args[1]) != "undefined") page = args[1];
} else {
- var mainWindow = _getWindowByURI("chrome://komodo/content/komodo.xul");
- sv = mainWindow.sv;
+ var p = parent;
+ while (p = p.opener) {
+ if (p.sv) {
+ sv = p.sv;
+ break;
+ }
+ }
}
rHelpTopic = document.getElementById("rhelp-topic");
Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/js/commands.js 2009-11-26 23:58:46 UTC (rev 232)
@@ -47,6 +47,7 @@
sv.r.testInterval = window.setInterval(sv.r.test, 5000);
}
setTimeout(window.updateCommands, 1000, 'r_app_started_closed');
+ //xtk.domutils.fireEvent(window, 'r_app_started_closed');
}
function _isRRunning () {
@@ -72,107 +73,68 @@
currentView.scimoz.selectionStart) != 0);
}
- // Start R, if not already running
- this.startR = function () {
- // runIn = "command-output-window", "new-console",
- // env strings: "ENV1=fooJ\nENV2=bar"
- // gPrefSvc.prefs.getStringPref("runEnv");
- var isWin = navigator.platform.indexOf("Win") === 0;
- // Default preferredRApp on Windows is r-gui
- var preferredRApp = sv.prefs.getString("sciviews.preferredRApp",
- isWin? "r-gui" : "r-terminal");
- var env = ["koId=" + sv.prefs.getString("sciviews.client.id",
- "SciViewsK"),
- "koHost=localhost",
- "koActivate=FALSE",
- "Rinitdir=" + sv.prefs.getString("sciviews.session.dir", "~"),
- "koServe=" + sv.prefs.getString("sciviews.client.socket", "8888"),
- "koPort=" + sv.prefs.getString("sciviews.server.socket", "7052"),
- "koDebug=" + String(sv.socket.debug).toUpperCase(),
- "koAppFile=" + sv.tools.file.path("binDir", "komodo" + (isWin? ".exe" : ""))
- ];
- var cwd = sv.tools.file.path("ProfD", "extensions",
- "sciviewsk at sciviews.org", "defaults");
- var command, runIn = "no-console";
+// Start R
+this.startR = function () {
+ var os = Components.classes['@activestate.com/koOs;1']
+ .getService(Components.interfaces.koIOs);
+ var cwd = sv.tools.file.path("ProfD", "extensions",
+ "sciviewsk at sciviews.org", "defaults");
+ var cmd = sv.prefs.getString("svRApplication");
+ var path = os.path.dirname(sv.prefs.getString("svRDefaultInterpreter"));
+ if (path) path += os.sep;
+ cmd = cmd.replace("%Path%", path).replace("%cwd%", cwd)
+ .replace("%title%", "SciViews-K");
- sv.cmdout.message(sv.translate("Starting R... please wait"), 10000, true);
- switch (preferredRApp) {
- case "r-gui":
- env.push("Rid=Rgui");
- command = "Rgui --sdi";
- break;
- case "r-xfce4-term":
- env.push("Rid=R-xfce4-term");
- command = "xfce4-terminal --title \"SciViews-R\" -x R --quiet";
- break;
- case "r-gnome-term":
- env.push("Rid=R-gnome-term");
- command = "gnome-terminal --hide-menubar --title=SciViews-R -x R --quiet";
- break;
- case "r-kde-term":
- env.push("Rid=R-kde-term");
- command = "konsole --nomenubar --notabbar --noframe -T SciViews-R -e R --quiet";
- break;
- case "r-tk":
- env.push("Rid=R-tk");
- // Set DISPLAY only when not set:
- var XEnv = Components.classes["@activestate.com/koEnviron;1"]
- .createInstance(Components.interfaces.koIEnviron);
- if (!XEnv.has("DISPLAY"))
- env.push("DISPLAY=:0");
- delete XEnv;
- // without forced --interactive R-tk halts on any error!
- command = "R --interactive --gui=Tk";
- // runIn = "no-console";
- break;
- case "r-app":
- env.push("Rid=R.app");
- command = "open -a /Applications/R.app \"" + cwd + "\"";
- break;
- case "r64-app":
- env.push("Rid=R64.app");
- command = "open -a /Applications/R64.app \"" + cwd + "\"";
- break;
- case "svr-app":
- env.push("Rid=svR.app");
- command = "open -a \"/Applications/SciViews R.app\" \"" +
- cwd + "\"";
- break;
- case "svr64-app":
- env.push("Rid=svR64.app");
- command = "open -a \"/Applications/SciViews R64.app\" \"" +
- cwd + "\"";
- break;
- // This does start, but ignore initial dir and thus SciViews is
- // not initialized
- case "jgrmac-app": // TODO: JGR on other platforms too!
- env.push("Rid=JGR.app");
- command = "open -a /Applications/JGR.app \"" +
- cwd + "\"";
- break;
- default:
- env.push("Rid=R");
- command = "R --quiet";
- runIn = "new-console";
- }
- sv.log.debug("Running: " + command);
+ var id = sv.prefs.getString("svRApplicationId");
- // Debugging garbage...
- //var command = "CMD /C \"SET\" > c:\\env.txt & notepad c:\\env.txt";
- //ko.run.runCommand(window,
- // "CMD /C \"SET\" > c:\\env.txt & notepad c:\\env.txt", cwd, {});
- //var runSvc = Components.classes["@activestate.com/koRunService;1"]
- // .getService(Components.interfaces.koIRunService);
- //var Rapp = runSvc.RunAndNotify(command, cwd, env.join("\n"), null);
- //ko.run.runCommand(window, command, cwd, env.join("\n"), false,
+ // runIn = "command-output-window", "new-console",
+ // env strings: "ENV1=fooJ\nENV2=bar"
+ // gPrefSvc.prefs.getStringPref("runEnv");
+ var isWin = navigator.platform.indexOf("Win") === 0;
+ // Default preferredRApp on Windows is r-gui
+ var preferredRApp = sv.prefs.getString("svRApplicationId", isWin?
+ "r-gui" : "r-terminal");
+ var env = ["koId=" + sv.prefs.getString("sciviews.client.id",
+ "SciViewsK"),
+ "koHost=localhost",
+ "koActivate=FALSE",
+ "Rinitdir=" + sv.prefs.getString("sciviews.session.dir", "~"),
+ "koServe=" + sv.prefs.getString("sciviews.client.socket", "8888"),
+ "koPort=" + sv.prefs.getString("sciviews.server.socket", "7052"),
+ "koDebug=" + String(sv.socket.debug).toUpperCase(),
+ "koAppFile=" + sv.tools.file.path("binDir", "komodo" + (isWin? ".exe" : ""))
+ ];
+ var cwd = sv.tools.file.path("ProfD", "extensions",
+ "sciviewsk at sciviews.org", "defaults");
+ var runIn = "no-console";
- ko.run.runCommand(window, command, cwd, env.join("\n"), false,
- false, false, runIn, false, false, false);
+ env.push("Rid=" + preferredRApp);
- // Register observer of application termination.
- this.rObserver = new AppTerminateObserver(command);
- };
+ switch (preferredRApp) {
+ case "r-tk":
+ env.push("Rid=R-tk");
+ // Set DISPLAY only when not set:
+ var XEnv = Components.classes["@activestate.com/koEnviron;1"]
+ .createInstance(Components.interfaces.koIEnviron);
+ if (!XEnv.has("DISPLAY")) env.push("DISPLAY=:0");
+ delete XEnv;
+ break;
+ case "r-terminal":
+ runIn = "new-console";
+ break;
+ default:
+ }
+ ko.run.runCommand(window, cmd, cwd, env.join("\n"), false,
+ false, false, runIn, false, false, false);
+
+ //return cmd + "\n" + runIn;
+
+ // Register observer of application termination.
+ this.rObserver = new AppTerminateObserver(cmd);
+}
+
+
// This will observe status message notification to be informed about
// application being terminated. A more straightforward way would be to use
// runService.RunAndNotify but this wouldn't allow to start app in a console
@@ -276,8 +238,8 @@
var res = true;
for (var k in appName)
res = res && !!sv.tools.file.whereIs(appName[k]);
-
-
+
+
if (res) {
showItem = true;
break;
Modified: komodo/SciViews-K/content/js/pref-R.js
===================================================================
--- komodo/SciViews-K/content/js/pref-R.js 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/js/pref-R.js 2009-11-26 23:58:46 UTC (rev 232)
@@ -3,59 +3,276 @@
// License: MPL 1.1/GPL 2.0/LGPL 2.1
////////////////////////////////////////////////////////////////////////////////
// svPrefR_OnPreferencePageOK(prefset); // User click OK
-// svPrefR_OnLoad(); // R preference widow loaded
+// PrefR_OnLoad(); // R preference widow loaded
// svPrefR_loadRExecutable(); // Select R executable
// svPrefR_finishSpecifyingExecutable(path); // Set R executable
////////////////////////////////////////////////////////////////////////////////
//
// TODO: use 'R' simply as default R (terminal on Win/Mac, or ? on Linux)
-function svPrefR_OnPreferencePageOK (prefset) {
- var ok = true;
+/* TODO: prefs to include:
+ * session directory ??? (dir, datadir, scriptdir, reportdir)
+ * address for remote R (sv.socket.host)? (if not localhost - disable source* commands)
+ * default CRAN mirror updated also by sv.r.pkg.chooseCRANMirror
+ * R help: show in tab (sidebar - another TODO) or in separate window
+ * R Site search url (%S replaced by topic)
+ */
- // Ensure that the interpreter is valid
- var defaultInterp = prefset.getStringPref("RDefaultInterpreter");
- if (defaultInterp != "") {
- var koSysUtils = Components.classes["@activestate.com/koSysUtils;1"].
- getService(Components.interfaces.koISysUtils);
- // If the interpreter's name ends with '.app', it is a Mac application
- // meaning it is a directory instead of a file!
- if (!koSysUtils.IsFile(defaultInterp) &
- !koSysUtils.IsDir(defaultInterp)) {
- dialog_alert("No R interpreter could be found at '" + defaultInterp +
- "'. You must make another selection for the default " +
- "R interpreter.\n");
- ok = false;
- document.getElementById("R_interpreterPath").focus();
- }
- }
- return ok;
+// TODO: rework R applications list, include "Find in path" item, similar to other
+// languages' interpeters in Komodo. Add new function to find installed R's and
+// populate the interpreter list (depending on the platform).
+
+var sv;
+
+function PrefR_menulistSetValue(menuList, value, attr, vdefault) {
+ var n = menuList.itemCount;
+ var item;
+ for (var i = 0; i <= n; i++) {
+ item = menuList.getItemAtIndex(i);
+ if (item) {
+ var attr1 = item.hasAttribute(attr)? item.getAttribute(attr) : vdefault;
+ if (attr1 == value) {
+ menuList.selectedIndex = i;
+ break;
+ }
+ }
+ }
}
-function svPrefR_OnLoad () {
- var prefExecutable;
- var prefName = 'RDefaultInterpreter';
- // If there is no pref, create it, otherwise trying to save a new pref
- // will fail, because it tries to get an existing one to see if the
- // pref needs updating.
- if (!parent.hPrefWindow.prefset.hasStringPref(prefName)) {
- parent.hPrefWindow.prefset.setStringPref(prefName, "");
- prefExecutable = '';
- } else {
- prefExecutable = parent.hPrefWindow.prefset.getStringPref(prefName);
- if (prefExecutable == null) {
- prefExecutable = '';
- }
- }
- svPrefR_finishSpecifyingExecutable(prefExecutable);
+function PrefR_OnLoad() {
+ // Get the sv object:
+ var p = parent;
+ while (p.opener && (p = p.opener) && !sv) if (p.sv) sv = p.sv;
+
+ var prefExecutable;
+ var prefset = parent.hPrefWindow.prefset;
+ var prefName = 'svRDefaultInterpreter';
+ if (!prefset.hasStringPref(prefName) || !prefset.getStringPref(prefName)) {
+ prefExecutable = sv.tools.file.whereIs("R");
+ prefset.setStringPref(prefName, prefExecutable);
+ }
+ PrefR_setRAppMenu(document.getElementById("svRApplication"));
+
+ //PrefR_InterfaceUpdate();
+ if (!PrefR_UpdateCranMirrors(true))
+ PrefR_UpdateCranMirrors(false);
+
+ parent.hPrefWindow.onpageload();
}
-function svPrefR_loadRExecutable () {
- svPrefR_finishSpecifyingExecutable(filepicker_openExeFile());
+function OnPreferencePageLoading(prefset) {
+ PrefR_svRApplicationOnSelect(null);
}
-function svPrefR_finishSpecifyingExecutable (path) {
- if (path != null) {
- document.getElementById("R_interpreterPath").value = path;
- }
+function OnPreferencePageOK(prefset) {
+ prefset = parent.hPrefWindow.prefset;
+ //prefset.setStringPref("svRDefaultInterpreter",
+ // document.getElementById("svRDefaultInterpreter")
+ // .value);
+ //prefset.setStringPref("svRApplication",
+ // document.getElementById('svRApplication')
+ // .selectedItem.getAttribute("data"));
+ prefset.setStringPref("svRApplicationId",
+ document.getElementById('svRApplication')
+ .selectedItem.id);
+ return true;
}
+
+function PrefR_svRApplicationOnSelect(event) {
+ var el = document.getElementById("svRApplication");
+ var prefattribute = el.getAttribute("prefattribute");
+ var sel = el.selectedItem;
+ var data = sel.getAttribute(prefattribute);
+ var app = sel.hasAttribute("app")? sel.getAttribute("app") : "R";
+
+ var os = Components.classes['@activestate.com/koOs;1']
+ .getService(Components.interfaces.koIOs);
+
+ var path = os.path.normpath(os.path.dirname(
+ document.getElementById("svRDefaultInterpreter").value));
+ if (path) path += os.sep;
+
+ var svRDefaultInterpreter = path + app;
+
+ document.getElementById("svRDefaultInterpreter").value
+ = svRDefaultInterpreter;
+
+ data = data.replace("%Path%", path).replace("%title%", "SciViews-K")
+ .replace("%cwd%", os.getcwd());
+
+ document.getElementById('R_command').value = data;
+ return true;
+}
+
+function PrefR_setExecutable(path) {
+ if (!path || !sv.tools.file.exists(path)) {
+ var os = Components.classes['@activestate.com/koOs;1']
+ .getService(Components.interfaces.koIOs);
+
+ path = document.getElementById("svRDefaultInterpreter").value;
+ path = ko.filepicker.openExeFile(path);
+ }
+
+ PrefR_menulistSetValue(document.getElementById("svRApplication"),
+ os.path.basename(path), "app", "R");
+ document.getElementById("svRDefaultInterpreter").value = os.path.abspath(path);
+ PrefR_svRApplicationOnSelect(null);
+}
+
+function PrefR_setRAppMenu(menuList) {
+ var isLinux = navigator.platform.toLowerCase().indexOf("linux") > -1;
+ var isMac = navigator.platform.toLowerCase().indexOf("mac") > -1;
+ var isWin = navigator.platform.toLowerCase().indexOf("win") == 0;
+
+ var validPlatforms, showItem;
+ var platform = navigator.platform;
+
+ for (var i = menuList.itemCount; i >= 0; i--) {
+ var item = menuList.getItemAtIndex(i);
+ try {
+ validPlatforms = item.getAttribute("platform").
+ split(/[,\s]+/);
+ showItem = false;
+ for (var j in validPlatforms) {
+ if (platform.indexOf(validPlatforms[j]) > -1) {
+ var appName = item.getAttribute("which");
+ if (isLinux || isWin) {
+ appName = appName.split(/[, ]+/);
+ var res = true;
+ for (var k in appName)
+ res = res && !!sv.tools.file.whereIs(appName[k]);
+
+ if (res) {
+ showItem = true;
+ break;
+ }
+ } else if (isMac) {
+ // Check that we find the application
+ if (appName == "R" || sv.tools.file.exists(appName)) {
+ showItem = true;
+ break;
+ }
+ }
+ }
+ }
+ if (!showItem)
+ menuList.removeItemAt(i);
+ } catch(e) { }
+ }
+
+}
+
+// Get CRAN mirrors list - independently of R
+function PrefR_UpdateCranMirrors(localOnly) {
+ var sv_file = sv.tools.file;
+
+ // Get data in as CSV:
+ var csvName = "CRAN_mirrors.csv";
+ var localDir = sv_file.path("PrefD", "extensions", "sciviewsk at sciviews.org");
+ var path, csvContent;
+ var arrData;
+ if (!localOnly) {
+ try {
+ csvContent = sv_file.readURI("http://cran.r-project.org/" + csvName);
+ //sv_file.write(localCopy, csvContent, 'utf-8');
+ } catch(e) {}
+ }
+
+ var nativeJSON = Components.classes["@mozilla.org/dom/json;1"]
+ .createInstance(Components.interfaces.nsIJSON);
+
+ var jsonFile = sv_file.path(localDir, "CRAN_mirrors.json");
+ var alreadyCached = false;
+ if (!csvContent) {
+ // First, check if there is serialized version:
+ if (alreadyCached = sv_file.exists(jsonFile)) {
+ arrData = nativeJSON.decode(sv_file.read(jsonFile));
+ //sv.cmdout.append("Read from: JSON");
+ } else {
+ var localPaths = [ ];
+
+ var platform = navigator.platform.toLowerCase().substr(0,3);
+ if (platform == "win") // TODO: what is the pref is not set??
+ localPaths.push(sv_file.path(sv.prefs.getString("svRDefaultInterpreter"),
+ "../../doc", csvName));
+ else { // if (platform == "lin")
+ localPaths.push('/usr/share/R/doc'); // try other paths: // mac: ????
+ localPaths.push('/usr/local/share/R/doc');
+ }
+ for (i in localPaths) {
+ if (sv_file.exists(localPaths[i])) {
+ csvContent = sv_file.read(localPaths[i]);
+ //sv.cmdout.append("Read from: " + localPaths[i]);
+ break;
+ }
+ }
+ }
+ }
+ if (!csvContent && !arrData) return false;
+ // TODO: Add error message when mirrors list cannot be obtained.
+
+ if (!arrData) {
+ // Convert CSV string to Array:
+ arrData = CSVToArray(csvContent);
+ var colNames = arrData.shift(1);
+ var colName = colNames.indexOf("Name");
+ var colURL = colNames.indexOf("URL");
+ var colOK = colNames.indexOf("OK");
+ var name, url, item;
+ for (i in arrData) {
+ item = arrData[i];
+ if (item[colOK] == "1") {
+ arrData[i] = [item[colName], item[colURL]];
+ }
+ }
+ //sv.cmdout.append("New arrData");
+ }
+ if (!arrData) return false;
+
+ if (!localOnly || !alreadyCached) {
+ // If updated from web, or not cached yet,
+ // serialize and save to file for faster later use:
+ sv_file.write(jsonFile, nativeJSON.encode(arrData), 'utf-8');
+ //sv.cmdout.append("Cached now.");
+ }
+
+ // Put arrData into MenuList:
+ var menuList = document.getElementById("CRANMirror");
+ var value = menuList.value? menuList.value : sv.prefs.getString("CRANMirror");
+ menuList.removeAllItems();
+ for (i in arrData) {
+ menuList.appendItem(arrData[i][0], arrData[i][1], arrData[i][1]);
+ }
+ menuList.value = value;
+ return true;
+}
+
+// From: http://www.bennadel.com/index.cfm?dax=blog:1504.view
+function CSVToArray( strData, strDelimiter ){
+ strDelimiter = (strDelimiter || ",");
+ var objPattern = new RegExp((
+ // Delimiters.
+ "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +
+ // Quoted fields.
+ "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +
+ // Standard fields.
+ "([^\"\\" + strDelimiter + "\\r\\n]*))"
+ ), "gi");
+ var arrData = [[]];
+ var arrMatches = null;
+ while (arrMatches = objPattern.exec( strData )) {
+ var strMatchedDelimiter = arrMatches[ 1 ];
+ if (strMatchedDelimiter.length &&
+ (strMatchedDelimiter != strDelimiter)) {
+ arrData.push( [] );
+ }
+ if (arrMatches[ 2 ]){
+ var strMatchedValue = arrMatches[ 2 ].replace(
+ new RegExp( "\"\"", "g" ), "\"");
+ } else {
+ var strMatchedValue = arrMatches[ 3 ];
+ }
+ arrData[ arrData.length - 1 ].push( strMatchedValue );
+ }
+ return( arrData );
+}
Modified: komodo/SciViews-K/content/js/prefs.js
===================================================================
--- komodo/SciViews-K/content/js/prefs.js 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/js/prefs.js 2009-11-26 23:58:46 UTC (rev 232)
@@ -69,7 +69,16 @@
sv.prefs.setString("sciviews.server.socket", "7052", false);
sv.prefs.setString("sciviews.client.socket", "8888", false);
sv.prefs.setString("sciviews.client.id", "SciViewsK", false);
+sv.prefs.setString("sciviews.server.host", "127.0.0.1", false);
+// R interpreter
+sv.prefs.setString("svRDefaultInterpreter", "", false);
+sv.prefs.setString("svRApplication", "", false);
+sv.prefs.setString("svRApplicationId", "", false);
+sv.prefs.setString("CRANMirror", "", false);
+
+
+
// This is required by sv.helpContext() for attaching help to snippets (hack!)
// Create empty preference sets to be used with snippet help system hack
// [[%pref:R-help:value]] which displays nothing when the snippet is used
@@ -132,7 +141,7 @@
sv.prefs.mru("header", true, 'TRUE|FALSE', "|");
// Various examples of pkgdata (indeed, data frames in datatasets 2.9.1) /////
-sv.prefs.mru("pkgdata", false,
+sv.prefs.mru("pkgdata", false,
'airquality|anscombe|attenu|attitude|beaver1|beaver2|BOD|cars|' +
'ChickWeight|chickwts|CO2|DNase|esoph|faithful|Formaldehyde|freeny|' +
'Indometh|infert|InsectSprays|iris|LifeCycleSavings|Loblolly|longley|' +
Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/js/r.js 2009-11-26 23:58:46 UTC (rev 232)
@@ -1425,6 +1425,8 @@
" the session directory first?", ["Yes", "No", "Cancel"], "No",
null, "Exiting R");
if (response == "Cancel") { return; }
+ } else {
+ response = save? "yes" : "no";
}
// Quit R
sv.r.eval('q("' + response.toLowerCase() + '")');
@@ -1476,8 +1478,7 @@
'repos["CRAN"] <- "' + repos + '"; ' +
'options(repos = repos) } )');
sv.r.pkg.repos = repos;
- if (callback)
- callback();
+ if (callback) callback(repos);
}
return(res);
Modified: komodo/SciViews-K/content/js/tools/file.js
===================================================================
--- komodo/SciViews-K/content/js/tools/file.js 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/js/tools/file.js 2009-11-26 23:58:46 UTC (rev 232)
@@ -26,6 +26,9 @@
// returns null if not found
////////////////////////////////////////////////////////////////////////////////
+if (typeof(sv) == 'undefined')
+ var sv = {};
+
// Define the 'sv.tools' namespace
if (typeof(sv.tools) == 'undefined')
sv.tools = {};
@@ -327,7 +330,9 @@
var err = {}, out = {};
var res = runSvc.RunAndCaptureOutput("which " + appName,
null, null, null, out, err);
- var path = out.value.trim();
+
+ var path = sv.tools.strings.trim(out.value);
+
if (!path) return null;
return path.split(" ");
}
Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/overlayMain.xul 2009-11-26 23:58:46 UTC (rev 232)
@@ -184,37 +184,6 @@
<menuitem id="r_start_console_menu" observes="cmd_sv_start_R"
class="menuitem-iconic r-run-command-icon"/>
- <menu label="&svSelectRApp;" accesskey="&svSelectRApp.key;">
- <menupopup id="sciviews_menu_select_r_application"
- oncommand="sv.command.getRApp(event);"
- selected="r-terminal" persist="selected"
- onpopupshowing="sv.command.setMenuRApp(this);">
- <menuitem id="r-app" type="checkbox" checked="false" label="R app"
- app="/Applications/R.app" platform="Mac"/>
- <menuitem id="r64-app" type="checkbox" checked="false" label="R64 app"
- app="/Applications/R64.app" platform="Mac"/>
- <menuitem id="svr-app" type="checkbox" checked="false" label="SciViews R app"
- app="/Applications/SciViews R.app" platform="Mac"/>
- <menuitem id="svr64-app" type="checkbox" checked="false" label="SciViews R64 app"
- app="/Applications/SciViews R64.app" platform="Mac"/>
- <!--<menuitem id="jgrmac-app" type="checkbox" checked="false" label="JGR"
- app="/Applications/JGR.app" platform="Mac"/>-->
- <menuitem id="r-gnome-term" type="checkbox" checked="false"
- label="R Gnome terminal"
- app="gnome-terminal,R" platform="Linux"/>
- <menuitem id="r-kde-term" type="checkbox" checked="false" label="R KDE terminal"
- app="konsole,R" platform="Linux"/>
- <menuitem id="r-xfce4-term" type="checkbox" checked="false" label="R XFCE terminal"
- app="xfce4-terminal,R" platform="Linux"/>
- <menuitem id="r-gui" type="checkbox" checked="false" label="R GUI"
- app="Rgui" platform="Win"/>
- <menuitem id="r-terminal" type="checkbox" checked="false" label="R terminal"
- app="R" platform="Linux,Mac,Win"/>
- <menuitem id="r-tk" type="checkbox" checked="false" label="R tk"
- app="R" platform="Linux,Mac"/>
- </menupopup>
- </menu>
-
<menuitem id="r_quit_console_menu" observes="cmd_sv_quit_R"
class="menuitem-iconic r-quit-command-icon"/>
<!--<menuitem id="r_update_charset" observes="cmd_sv_update_charset"
Modified: komodo/SciViews-K/content/pref-R.xul
===================================================================
--- komodo/SciViews-K/content/pref-R.xul 2009-11-20 20:52:48 UTC (rev 231)
+++ komodo/SciViews-K/content/pref-R.xul 2009-11-26 23:58:46 UTC (rev 232)
@@ -33,47 +33,166 @@
***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://komodo/skin/global/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://komodo/skin/bindings/buttons.css" type="text/css"?>
<?xml-stylesheet href="chrome://komodo/skin/bindings/widgets.css" type="text/css"?>
<?xml-stylesheet href="chrome://komodo/skin/bindings/listbox.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/tree.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/prefs/prefs.css" type="text/css"?>
+
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- class="kodialog" orient="vertical" onload="svPrefR_OnLoad();">
+ class="kodialog" orient="vertical" onload="PrefR_OnLoad(event);">
- <script src="chrome://komodo/content/library/trace.js" type="application/x-javascript"/>
- <script src="chrome://komodo/content/library/logging.js" type="application/x-javascript"/>
- <script src="chrome://komodo/content/library/dialogs.js" type="application/x-javascript"/>
- <script src="chrome://komodo/content/library/filepickers.js" type="application/x-javascript"/>
- <script src="chrome://komodo/content/library/windowManager.js" type="application/x-javascript"/>
- <script src="chrome://sciviewsk/content/js/pref-R.js" type="application/x-javascript"/>
+<script src="chrome://komodo/content/library/trace.js" type="application/x-javascript"/>
+<script src="chrome://komodo/content/library/logging.js" type="application/x-javascript"/>
+<script src="chrome://komodo/content/library/dialogs.js" type="application/x-javascript"/>
+<script src="chrome://komodo/content/library/filepickers.js" type="application/x-javascript"/>
+<script src="chrome://komodo/content/library/windowManager.js" type="application/x-javascript"/>
+<script src="chrome://sciviewsk/content/js/pref-R.js" type="application/x-javascript"/>
- <box class="kobox-smallheader" title="R interpreter configuration"/>
+<box class="kobox-smallheader" title="R interpreter configuration"/>
+<vbox flex="1" class="autoscroll">
<groupbox orient="vertical">
<caption label="Default R Interpreter"/>
- <text value="Use this R application:" style="padding: 2px 6px 2px 6px"/>
- <hbox align="center">
- <textbox id="R_interpreterPath" pref="true"
- prefstring="RDefaultInterpreter" flex="1"/>
- <button label="Browse..." oncommand="svPrefR_loadRExecutable();"/>
- </hbox>
+ <label value="Use this R application:" control="svRDefaultInterpreter" />
+ <hbox>
+ <textbox id="svRDefaultInterpreter" pref="true"
+ emptytext="No R installation found on the system!"
+ editable="false" flex="1"/>
+ <button label="Browse..." oncommand="PrefR_setExecutable();"/>
+ </hbox>
<vbox flex="1" align="center">
<description>
- For these changes to take effect, you have to close R first.
- </description>
- <separator class="thin"/>
- <description>
- SciViews-K currently needs a valid R installation on the
+ SciViews-K needs a valid installation of R on the
local machine. If you have not installed R yet, you can
- find it at the CRAN website (Comprehensive R Archive Network):
+ download it at the CRAN website:
</description>
<separator class="thin"/>
- <button label="http://cran.r-project.org" class="button-link"
- style="margin: -10px; color: #0000FF;
- text-decoration: underline !important; cursor: pointer;"
- onclick="parent.opener.ko.browse.openUrlInDefaultBrowser('http://cran.r-project.org/');"/>
+ <button label="<http://cran.r-project.org/>" class="button-link"
+ style="margin-top: -10px; color: rgb(184, 38, 25);"
+ onclick="parent.opener.ko.browse.openUrlInDefaultBrowser('http://cran.r-project.org/');"/>
<separator class="thin"/>
</vbox>
+ <hbox align="center">
+ <label class="label" control="svRApplication" value="Preferred way to run R:"/>
+ <menulist
+ id="svRApplication" oncommand="PrefR_svRApplicationOnSelect(event);"
+ pref="true" prefattribute="value"
+ >
+ <menupopup id="sciviews_menu_select_r_application">
+ <menuitem id="r-none" label=""
+ value="" app="?" which="" platform="Linux,Mac,Win"/>
+ <menuitem id="r-terminal" label="in default terminal"
+ value=""%Path%R" --quiet" which="R"
+ platform="Linux,Mac"/>
+ <menuitem id="r-terminal" label="in console window"
+ value=""%Path%R.exe" --quiet" app="R.exe"
+ which="R" platform="Win"/>
+ <menuitem id="r-gnome-term" label="in Gnome terminal"
+ value="gnome-terminal --hide-menubar --title=%title% -x "%Path%R" --quiet"
+ which="gnome-terminal,R" platform="Linux"/>
+ <menuitem id="r-kde-term" label="in Konsole"
+ value="konsole --workdir "%cwd%" --title %title% -e "%Path%R" --quiet"
+ which="konsole,R" platform="Linux"/>
+ <menuitem id="r-xfce4-term" label="in XFCE terminal"
+ value="xfce4-terminal --title "%title%" -x "%Path%R" --quiet"
+ which="xfce4-terminal,R" platform="Linux"/>
+ <menuitem id="r-app" label="R app"
+ value="open -a "/Applications/SciViews R.app" "%cwd%""
+ app="R.app"
+ which="/Applications/R.app" platform="Mac"/>
+ <menuitem id="r64-app" label="R64 app"
+ value="open -a /Applications/R64.app "%cwd%""
+ app="R64.app"
+ which="/Applications/R64.app" platform="Mac"/>
+ <menuitem id="svr-app" label="SciViews R app"
+ value="open -a "/Applications/SciViews R.app" "%cwd%""
+ app="SciViews R.app"
+ which="/Applications/SciViews R.app" platform="Mac"/>
+ <menuitem id="svr64-app" label="SciViews R64 app"
+ value="open -a "/Applications/SciViews R64.app" "%cwd%""
+ app="SciViews R64.app"
+ which="/Applications/SciViews R64.app" platform="Mac"/>
+ <menuitem id="r-gui" label="R GUI"
+ app="Rgui.exe"
+ value=""%Path%Rgui.exe" --sdi"
+ which="Rgui" platform="Win"/>
+ <menuitem id="r-tk" label="R Tk GUI"
+ value=""%Path%R" --interactive --gui=Tk"
+ which="R" platform="Linux,Mac"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+ <hbox align="center">
+ <checkbox id="sciviews.run.r.quiet" disabled="true" />
+ <label value="Run R quietly (no initial messages)"
+ control="sciviews.run.r.quiet" disabled="true"
+ pref="false" />
+ </hbox>
+ <separator class="thin"/>
+ <vbox>
+<label class="label" control="R_command" crop="end"
+ value="This command will be used to start R (R -> Start R):"/>
+ <textbox id="R_command" value="" class="plain"
+ style="background: none; padding-top: 1px !important; margin-left: 10px !important;" />
+ </vbox>
</groupbox>
+ <groupbox orient="vertical">
+ <caption label="R configuration"/>
+ <vbox>
+ <hbox align="center">
+ <label value="Default CRAN mirror:" control="CRANMirror" />
+ <menulist id="CRANMirror" sizetopopup="none" width="200"
+ pref="true" prefattribute="value">
+ <menupopup maxheight="200" />
+ </menulist>
+ <button label="Refresh list" oncommand="PrefR_UpdateCranMirrors(false);" />
+ </hbox>
+ </vbox>
+ </groupbox>
+ <groupbox orient="vertical">
+ <caption label="Miscellanous"/>
+ <hbox align="top">
+ <label value="Show R help in:" />
+ <radiogroup id="sciviews.rhelp.open_in" disabled="true"
+ pref="false">
+ <radio value="window" label="new window" accesskey="E"
+ selected="true" />
+ <radio value="pane" label="right pane" accesskey="P" />
+ </radiogroup>
+ </hbox>
+ <separator class="thin"/>
+ <hbox align="center">
+ <checkbox id="sciviews.r.auto-start" disabled="true" />
+ <label value="Start R automatically"
+ control="sciviews.r.auto-start" disabled="true"
+ pref="false" />
+ </hbox>
+ </groupbox>
+ <groupbox orient="vertical">
+ <caption label="Socket connection"/>
+ <grid>
+ <columns>
+ <column flex="1"/> <column flex="2"/> <column flex="1"/> <column
+ flex="2"/>
+ </columns> <rows>
+ <row align="center">
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/sciviews -r 232
More information about the Sciviews-commits
mailing list