[Sciviews-commits] r119 - komodo/SciViews-K komodo/SciViews-K/content komodo/SciViews-K/content/js komodo/SciViews-K/locale/en-GB komodo/SciViews-K/locale/fr-FR komodo/SciViews-K/skin/images pkg/svMisc/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 2 19:37:30 CET 2009
Author: prezez
Date: 2009-03-02 19:37:29 +0100 (Mon, 02 Mar 2009)
New Revision: 119
Added:
komodo/SciViews-K/sciviewsk-0.7.1-beta-ko.xpi
komodo/SciViews-K/skin/images/itemEnabledFader.png
Modified:
komodo/SciViews-K/content/
komodo/SciViews-K/content/js/
komodo/SciViews-K/content/js/commands.js
komodo/SciViews-K/content/js/robjects.js
komodo/SciViews-K/content/js/sciviews.js
komodo/SciViews-K/content/overlayMain.xul
komodo/SciViews-K/content/pkgManager.xul
komodo/SciViews-K/locale/en-GB/main.properties
komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
komodo/SciViews-K/locale/fr-FR/main.properties
komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
pkg/svMisc/R/Args.R
pkg/svMisc/R/objList.R
Log:
Main overlay: added "start R" menu options allowing to choose preferred R application
Several bugs on Linux/komodo4 fixed
Typo in svMisc:Args corrected
Added an xpi of current version
Property changes on: komodo/SciViews-K/content
___________________________________________________________________
Name: svn:ignore
+ !*
*-dev.*
pkgManager2.xul
Property changes on: komodo/SciViews-K/content/js
___________________________________________________________________
Name: svn:ignore
+ !*
*-dev.*
_robjects-old.js
Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/content/js/commands.js 2009-03-02 18:37:29 UTC (rev 119)
@@ -31,6 +31,67 @@
return(currentView.document.language == "R" && anythingSelected);
}
+
+// selects the checkbox on selected element, while deselecting others
+this.getRApp = function(event) {
+ var el = event.originalTarget;
+ var siblings = el.parentNode.childNodes;
+ for (var i = 0; i < siblings.length; i++) {
+ try {
+ siblings[i].setAttribute("checked", siblings[i] == el);
+ } catch(e) {}
+ }
+ // this will preserve the selection:
+ el.parentNode.setAttribute('selected', el.id);
+ // set the preference string:
+ sv.prefs.setString("sciviews.preferredRApp", el.id, true);
+
+ document.getElementById("cmd_svStartR").setAttribute("label",
+ sv.translate("StartR") + " (" + el.getAttribute('label') + ")");
+
+}
+
+
+// Selects checkbox on the 'preferred R application' menu on its first display
+// and hides unsupported commands
+// It is triggered on popupshowing event, onload would be better,
+// but it is for compatibility with komodo 4 which doesn't seem to support onload
+this.setMenuRApp = function (el) {
+ var selected = el.getAttribute('selected');
+ var siblings = el.childNodes;
+
+ var validPlatforms, showItem;
+ var platform = navigator.platform;
+ for (var i = 0; i < siblings.length; i++) {
+ try {
+ validPlatforms = siblings[i].getAttribute("platform").split(/\s*[,\s]\s*/);
+ showItem = false;
+ for (var j in validPlatforms) {
+ if (platform.indexOf(validPlatforms[j]) == 0) {
+ showItem = true;
+ break;
+ }}
+
+ if (!showItem) {
+ siblings[i].style.display = "none";
+ } else {
+ siblings[i].setAttribute("checked", siblings[i].id == selected);
+ }
+
+ } catch(e) {}
+ }
+
+ // set the preference string:
+ sv.prefs.setString("sciviews.preferredRApp", selected, false);
+
+ document.getElementById("cmd_svStartR").setAttribute("label",
+ sv.translate("StartR") + " (" + document.getElementById(selected).getAttribute('label') + ")"
+ );
+
+ // we do not need to run it anymore:
+ el.removeAttribute("onpopupshowing");
+}
+
this.openPkgManager = function() {
window.openDialog(
"chrome://sciviewsk/content/pkgManager.xul",
@@ -39,7 +100,6 @@
sv);
}
-
this.setControllers = function() {
// make these commands active only when current document language is R
var cmdNames = ["RunAll", "SourceAll", "RunBlock", "RunFunction", "RunLine", "RunPara",
@@ -79,17 +139,55 @@
// TODO: submenu with checkboxes to select preferred way to start R
viewManager.prototype.do_cmd_svStartR = function() {
- // runIn = "command-output-window", "new-console", "no-console"
+ // runIn = "command-output-window", "new-console",
//env strings: "ENV1=fooJ\nENV2=bar"
//gPrefSvc.prefs.getStringPref("runEnv");
+ var preferredRApp = sv.prefs.getString("sciviews.preferredRApp", "r-terminal");
+
+
var env = ["koPort=%(pref:sciviews.server.socket)", "koId=%(pref:sciviews.client.id)", "koHost=localhost",
- "koActivate=FALSE", "Rinitdir=~", "koServe=%(pref:sciviews.client.socket)", "Rid=Rgui"];
+ "koActivate=FALSE", "Rinitdir=~", "koServe=%(pref:sciviews.client.socket)"];
var cwd = "%(path:hostUserDataDir)/XRE/extensions/sciviewsk at sciviews.org/templates";
-
cwd = ko.interpolate.interpolateStrings(cwd);
+
+ var command, mode = "no-console";
+
+ 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 \"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");
+ env.push("DISPLAY=:0");
+ command = "R --quiet --gui=Tk";
+ mode = "new-console";
+ break;
+ case "r-app":
+ env.push("Rid=R.app");
+ command = "open -a /Applications/R.app \"" + cwd + "\"";
+ break;
+ default:
+ env.push("Rid=R");
+ command = "R --quiet";
+ mode = "new-console";
+
+ }
for (i in env) {
try {
env[i] = ko.interpolate.interpolateStrings(env[i]);
@@ -98,15 +196,14 @@
return;
}
}
- ko.run.runCommand(window, "Rgui --sdi", cwd, env.join("\n"), false, false, false, "no-console", false, false, false)
+ ko.run.runCommand(window, command, cwd, env.join("\n"), false,
+ false, false, mode, false, false, false);
};
}
}).apply(sv.command);
-
-
//sv.cmdsSetControllers();
addEventListener("load", sv.command.setControllers, false);
Modified: komodo/SciViews-K/content/js/robjects.js
===================================================================
--- komodo/SciViews-K/content/js/robjects.js 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/content/js/robjects.js 2009-03-02 18:37:29 UTC (rev 119)
@@ -899,11 +899,10 @@
// so, replace it with "onclick". This causes issue with selection by key-press
var listBox = document.getElementById("sciviews_robjects_searchpath_listbox");
- listBox.oncommand = this.packageSelectedEvent;
+ //listBox.oncommand = this.packageSelectedEvent;
- if ((typeof listBox.oncommand == "undefined")
- && (typeof listBox.getAttribute("oncommand") == "string")) {
- listBox.setAttribute("onclick", listBox.getAttribute("oncommand"));
+ if ((typeof listBox.oncommand == "undefined")) {
+ listBox.onclick = this.packageSelectedEvent;
listBox.removeAttribute("oncommand");
}
isInitialized = true;
Modified: komodo/SciViews-K/content/js/sciviews.js
===================================================================
--- komodo/SciViews-K/content/js/sciviews.js 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/content/js/sciviews.js 2009-03-02 18:37:29 UTC (rev 119)
@@ -516,9 +516,21 @@
// Help page on the R Wiki
sv.prefs.setString("RWiki-help", "", true);
+
// translate messages using data from chrome://sciviewsk/locale/main.properties
sv.translate = function(textId) {
var strbundle = document.getElementById("svBundle");
+ if (strbundle == null) {
+ // bug on Komodo 4 and/or Linux: cannot get stringbundle by id:
+ var strbundles = document.getElementsByTagName("stringbundle");
+ for (var i = 0; i < strbundles.length; i++) {
+ if (strbundles[i].id == "svBundle") {
+ strbundle = strbundles[i];
+ break;
+ }
+ }
+ }
+
try {
if (arguments.length > 1) {
var param = [];
@@ -533,6 +545,7 @@
}
}
+
// Control the command output tab //////////////////////////////////////////////
if (typeof(sv.cmdout) == 'undefined') sv.cmdout = {};
Modified: komodo/SciViews-K/content/overlayMain.xul
===================================================================
--- komodo/SciViews-K/content/overlayMain.xul 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/content/overlayMain.xul 2009-03-02 18:37:29 UTC (rev 119)
@@ -64,7 +64,7 @@
<script type="application/x-javascript" src="chrome://sciviewsk/content/js/commands.js"/>
<script type="application/x-javascript" src="chrome://sciviewsk/content/js/r-help.js"/>
-<stringbundleset>
+<stringbundleset id="svStringBundles">
<stringbundle id="svBundle" src="chrome://sciviewsk/locale/main.properties" />
</stringbundleset>
@@ -74,7 +74,7 @@
<command id="cmd_svStartR" key="key_cmd_svStartR"
oncommand="ko.commands.doCommand('cmd_svStartR');"
- desc="R: &startRConsole; (windows)" label="&startRConsole; (windows)" accesskey="&startRConsole.key;" />
+ desc="R: &startR;" label="&startR;" accesskey="&startR.key;" />
<command id="cmd_svOpenPkgManager" key="key_cmd_svOpenPkgManager"
oncommand="sv.command.openPkgManager();"
@@ -129,8 +129,22 @@
<menubar id="menubar_main">
<menu id="sciviews_menu" label="R Control" accesskey="R" insertbefore="menu_window,help_menu">
<menupopup id="popup_sciviews_main">
+
<menuitem id="r_start_console_menu" observes="cmd_svStartR" class="menuitem-iconic r-run-command-icon" />
- <menuitem id="r_start_pkg_manager" observes="cmd_svOpenPkgManager" class="menuitem" />
+ <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" platform="Mac" />
+ <menuitem id="r-gnome-term" type="checkbox" checked="false" label="R Gnome terminal" platform="Linux" />
+ <menuitem id="r-kde-term" type="checkbox" checked="false" label="R KDE terminal" platform="Linux" />
+ <menuitem id="r-xfce4-term" type="checkbox" checked="false" label="R XFCE terminal" platform="Linux" />
+ <menuitem id="r-gui" type="checkbox" checked="false" label="R GUI" platform="Win" />
+ <menuitem id="r-terminal" type="checkbox" checked="false" label="R terminal" platform="Linux,Mac,Win" />
+ <menuitem id="r-tk" type="checkbox" checked="false" label="R tk" platform="Linux,Mac" />
+ </menupopup>
+ </menu>
+ <!--<menuitem id="r_start_pkg_manager" observes="cmd_svOpenPkgManager" class="menuitem" />-->
<menuitem id="r_browse_wd" observes="cmd_svBrowseWD" class="menuitem-iconic r-working-dir-icon" />
<menuseparator/>
Modified: komodo/SciViews-K/content/pkgManager.xul
===================================================================
--- komodo/SciViews-K/content/pkgManager.xul 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/content/pkgManager.xul 2009-03-02 18:37:29 UTC (rev 119)
@@ -18,6 +18,13 @@
<script type="text/javascript">
<![CDATA[
+//TODO: use xbl bindings
+// list of available packages at CRAN
+// repository selection + custom repositories
+// installing packages - to be finished
+// add pkgManager() common function for svMisc - wrap commands into it
+
+
var sv;
var packages = {};
Modified: komodo/SciViews-K/locale/en-GB/main.properties
===================================================================
--- komodo/SciViews-K/locale/en-GB/main.properties 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/locale/en-GB/main.properties 2009-03-02 18:37:29 UTC (rev 119)
@@ -29,3 +29,4 @@
No_item_found_in_R_help=No item found in R help!
Browse_for_workspace=Browse for workspace
R_workspace=R workspace
+StartR=Start R
Modified: komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-03-02 18:37:29 UTC (rev 119)
@@ -71,8 +71,11 @@
<!ENTITY rSrcPara.key "A">
<!ENTITY rSrcSel "Source selection">
<!ENTITY rSrcSel.key "E">
-<!ENTITY startRConsole "Start R Console">
-<!ENTITY startRConsole.key "C">
+<!ENTITY startR "Start R">
+<!ENTITY startR.key "R">
<!ENTITY svBrowseWD "Browse for working directory">
<!ENTITY svBrowseWD.key "D">
+
+<!ENTITY svSelectRApp "Preferred R application">
+<!ENTITY svSelectRApp.key "E">
Modified: komodo/SciViews-K/locale/fr-FR/main.properties
===================================================================
--- komodo/SciViews-K/locale/fr-FR/main.properties 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/locale/fr-FR/main.properties 2009-03-02 18:37:29 UTC (rev 119)
@@ -29,3 +29,4 @@
No_item_found_in_R_help=No item found in R help!
Browse_for_workspace=Browse for workspace
R_workspace=R workspace
+StartR=Start R
Modified: komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-02-26 13:06:16 UTC (rev 118)
+++ komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-03-02 18:37:29 UTC (rev 119)
@@ -75,4 +75,7 @@
<!ENTITY startRConsole.key "C">
<!ENTITY svBrowseWD "Browse for working directory">
-<!ENTITY svBrowseWD.key "D">
\ No newline at end of file
+<!ENTITY svBrowseWD.key "D">
+
+<!ENTITY svSelectRApp "Preferred R application">
+<!ENTITY svSelectRApp.key "E">
Added: komodo/SciViews-K/sciviewsk-0.7.1-beta-ko.xpi
===================================================================
(Binary files differ)
Property changes on: komodo/SciViews-K/sciviewsk-0.7.1-beta-ko.xpi
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: komodo/SciViews-K/skin/images/itemEnabledFader.png
===================================================================
(Binary files differ)
Property changes on: komodo/SciViews-K/skin/images/itemEnabledFader.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: pkg/svMisc/R/Args.R
===================================================================
--- pkg/svMisc/R/Args.R 2009-02-26 13:06:16 UTC (rev 118)
+++ pkg/svMisc/R/Args.R 2009-03-02 18:37:29 UTC (rev 119)
@@ -1,5 +1,5 @@
"Args" <-
-function (name, only.args = FALSE
+function (name, only.args = FALSE)
{
#### TODO: handle primitives and S3/S4 methods for generic functions
ret <- try(res <- eval(parse(text = paste("argsAnywhere(", name, ")",
Modified: pkg/svMisc/R/objList.R
===================================================================
--- pkg/svMisc/R/objList.R 2009-02-26 13:06:16 UTC (rev 118)
+++ pkg/svMisc/R/objList.R 2009-03-02 18:37:29 UTC (rev 119)
@@ -152,30 +152,30 @@
{
if (!inherits(x, "objList"))
stop("x must be an 'objList' object")
- if (NROW(x) > 0) {
- if (!raw.output)
- cat("Objects list:\n")
- if (header) {
- header.fmt <- if (raw.output) "Env=%s\nObj=%s\n" else
- "\tEnvironment: %s\n\tObject: %s\n"
+ empty <- NROW(x) == 0
- objname <- if (is.null(attr(x, "object"))) {
- if (raw.output) "" else "<All>"
- } else attr(x, "object")
+ if (!raw.output)
+ cat(if (empty) "An empty objects list\n" else "Objects list:\n")
- cat(sprintf(header.fmt, attr(x, "envir"), objname))
+ if (header) {
+ header.fmt <- if (raw.output) "Env=%s\nObj=%s\n" else
+ "\tEnvironment: %s\n\tObject: %s\n"
- }
+ objname <- if (is.null(attr(x, "object"))) {
+ if (raw.output) "" else "<All>"
+ } else attr(x, "object")
+ cat(sprintf(header.fmt, attr(x, "envir"), objname))
+ }
+
+ if (!empty) {
if (is.na(sep)) {
print(as.data.frame(x))
} else if (!is.null(nrow(x)) && nrow(x) > 0) {
write.table(x, row.names = FALSE, col.names = FALSE, sep = sep,
eol = eol, quote = FALSE)
}
- } else if (!raw.output) {
- cat("An empty objects list\n")
}
return(invisible(x))
}
More information about the Sciviews-commits
mailing list