[Sciviews-commits] r233 - in komodo/SciViews-K: content content/js content/js/tools locale/en-GB locale/fr-FR skin skin/images templates
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Dec 1 00:46:48 CET 2009
Author: prezez
Date: 2009-12-01 00:46:47 +0100 (Tue, 01 Dec 2009)
New Revision: 233
Added:
komodo/SciViews-K/content/sessions.xul
komodo/SciViews-K/skin/images/folder_wrench.png
Removed:
komodo/SciViews-K/templates/.Rprofile
Modified:
komodo/SciViews-K/content/RHelpWindow.xul
komodo/SciViews-K/content/default-keybindings.kkf
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/locale/en-GB/sciviewsk.dtd
komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
komodo/SciViews-K/skin/sciviewsk.css
Log:
Added: R session manager window
+ many other small changes
Modified: komodo/SciViews-K/content/RHelpWindow.xul
===================================================================
--- komodo/SciViews-K/content/RHelpWindow.xul 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/RHelpWindow.xul 2009-11-30 23:46:47 UTC (rev 233)
@@ -66,10 +66,18 @@
// so define them here:
rHelpBrowser = document.getElementById("rhelp-browser");
- if (uri === "" || uri == "@home@") {
- rHelpBrowser.goHome();
- return;
+
+ switch (uri) {
+ case "":
+ case "@home@":
+ rHelpBrowser.goHome();
+ return;
+ case "@CRAN@":
+ uri = sv.prefs.getString("CRANMirror");
+ if (!uri || uri.indexOf("ftp:/") === 0)
+ uri = "http://cran.r-project.org/";
}
+
rHelpTopic = document.getElementById("rhelp-topic");
// In case the window was not yet fully loaded.
if (!rHelpTopic) {
@@ -129,20 +137,18 @@
}
}
-
-function find(next) {
+function find(next, backwards) {
//rHelpTopic.select();
//findInDoc(rHelpTopic.value);
var findToolbar = document.getElementById("FindToolbar");
if (!next) {
- //var isShown = findToolbar.getAttribute("hidden") != "true";
- findToolbar.open();
+ findToolbar.open(0); // aMode = 0 : full search
findToolbar._findField.value = rHelpBrowser.contentWindow.getSelection();
findToolbar._find(findToolbar._findField.value);
findToolbar._findField.focus();
} else {
- findToolbar._findAgain(event.shiftKey);
+ findToolbar._findAgain(backwards);
}
}
@@ -336,7 +342,7 @@
}).apply(browserUtils);
-function windowOnLoad (event) {
+function OnLoad (event) {
// DOMContentLoaded is fired also for HTML content
if (event.target != self.document)
return;
@@ -382,7 +388,7 @@
// this is fired earlier than load event, so all required variables
// will be defined
-self.addEventListener("DOMContentLoaded", windowOnLoad, false);
+self.addEventListener("DOMContentLoaded", OnLoad, false);
// required by PrintUtils.printPreview()
function getWebNavigation() rHelpBrowser.webNavigation;
@@ -439,7 +445,7 @@
<commandset id="commandset_main">
<command id="cmd_find" oncommand="find(false);" />
- <command id="cmd_find_next" oncommand="find(true);" />
+ <command id="cmd_find_next" oncommand="find(true, event.shiftKey);" />
<command id="cmd_go" oncommand="go();" disabled="false"
label="Go" tooltiptext="Show topic or web page" />
<command id="cmd_search" oncommand="rHelpSearch(document.getElementById('rhelp-topic').value);"
@@ -506,7 +512,7 @@
<!-- TODO: if CRAN mirror was set in R, go directly there, eg. go('@CRAN@') -->
<menuitem id="rhelp-menu-cran" label="CRAN"
accesskey="c"
- oncommand="go('http://cran.r-project.org/');"/>
+ oncommand="go('@CRAN@');"/>
<menuitem id="rhelp-menu-wiki" label="R wiki"
accesskey="w"
oncommand="go('http://wiki.r-project.org/');"/>
Modified: komodo/SciViews-K/content/default-keybindings.kkf
===================================================================
--- komodo/SciViews-K/content/default-keybindings.kkf 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/default-keybindings.kkf 2009-11-30 23:46:47 UTC (rev 233)
@@ -1,4 +1,4 @@
-version 15
+version 17
# SciViews-K default keybindings
# will be applied if no other key has been assigned by user, and if a key
Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/js/commands.js 2009-11-30 23:46:47 UTC (rev 233)
@@ -26,7 +26,7 @@
function _getWindowByURI(uri) {
var wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator);
- en = wm.getEnumerator("");
+ var en = wm.getEnumerator("");
if (uri) {
var win;
@@ -39,6 +39,27 @@
return null;
}
+ //Get reference to a window, opening it if is closed
+ function _getWindowRef(uri, name, features, focus) {//, ...
+ var win = _getWindowByURI(uri);
+ if (!win || win.closed) {
+ try {
+ var args = Array.apply(null, arguments);
+ args = args.slice(0,3).concat(args.slice(4));
+ //return(args);
+
+ if (!features)
+ args[2] = "chrome,modal,titlebar";
+
+ win = window.openDialog.apply(null, args);
+ } catch (e) {
+ alert(e);
+ sv.log.exception(e, "Error opening window: " + uri);
+ }
+ }
+ if (focus) win.focus();
+ }
+
// private methods
function _keepCheckingR (stopMe) {
clearInterval(sv.r.testInterval);
@@ -279,22 +300,24 @@
}
this.openPkgManager = function () {
- var rPkgMgrXulUri = "chrome://sciviewsk/content/RPkgManager.xul";
+ var win = _getWindowRef("chrome://sciviewsk/content/RPkgManager.xul",
+ "RPkgMgr",
+ "chrome=yes,dependent" +
+ "scrollbars=yes,status=no,close,dialog=no",
+ true,
+ sv);
+ return win;
+ }
- var rPkgMgr = _getWindowByURI(rPkgMgrXulUri);
- if (!rPkgMgr || rPkgMgr.closed) {
- try {
- rPkgMgr = window.openDialog(rPkgMgrXulUri, "RPkgMgr",
- "chrome=yes,dependent,resizable=yes," +
- "scrollbars=yes,status=no,close,dialog=no", sv);
-
- } catch (e) {
- sv.log.exception(e, "Error opening package manager window");
- }
- }
- rPkgMgr.focus();
+ this.openSessionMgr = function() {
+ var win = _getWindowRef("chrome://sciviewsk/content/sessions.xul",
+ "RSessionMgr",
+ "chrome,modal,titlebar,close,centerscreen",
+ true);
+ return win;
}
+
// sv.command.openHelp - returns reference to the RHelpWindow
//FIXME: help in tab still buggy
this.openHelp = function (uri) {
@@ -382,7 +405,6 @@
//_this.RHelpWin.closed = true;
}
-
this.setControllers = function () {
//sv.log.debug("this.setControllers");
// Allow some commands only when R is running...
@@ -392,7 +414,7 @@
var vmProto = ko.views.viewManager.prototype;
var cmdsIfRRunning = ['OpenPkgManager', 'BrowseWD', 'quit_R',
- 'OpenHelp']; //'update_charset',
+ 'OpenHelp', 'sessionMgr']; //'update_charset',
var cmdsIfRNotRunning = ['start_R'];
// Make these commands active only when current document language is R
@@ -520,8 +542,12 @@
.classes["@activestate.com/koKeybindingSchemeService;1"]
.getService(Components.interfaces.koIKeybindingSchemeService);
+ //gKeybindingMgr.keybindingSchemeService
+
var svSchemeDefault = sv.tools.file
.readURI("chrome://sciviewsk/content/default-keybindings.kkf");
+
+ //gKeybindingMgr.currentScheme.name
var currentSchemeName = sv.prefs.getString("keybinding-scheme");
// Perhaps this should be redone for each scheme?
@@ -531,6 +557,8 @@
//schemeNames = schemeNames.value;
var sch = keybindingSvc.getScheme(currentSchemeName);
+ //gKeybindingMgr.parseConfiguration
+
var bindingRx = /[\r\n]+(# *SciViews|binding cmd_sv_.*)/g;
if (clearOnly != true) {
function _getSvKeys (data, pattern) {
@@ -552,6 +580,8 @@
// Temporarily delete SciViews keybindings
sch.data = sch.data.replace(bindingRx, "");
+
+ //var usedbys = this.usedBy([keysequence]);
// Check for key conflicts
var svKeysCurrentOther = _getSvKeys (sch.data, "");
var currKeyArr = [];
@@ -580,13 +610,17 @@
"SciViews keybindings have been updated in \"" +
currentSchemeName + "\" scheme.");
} else {
+ //gKeybindingMgr.removeCommandsWithPrefix("cmd_sv_");
sch.data = sch.data.replace(bindingRx, "");
sv.log.debug("SciViews keybindings have been cleared in \"" +
currentSchemeName + "\" scheme.");
}
sch.save();
- sv.log.debug("You may need to restart Komodo.");
+ //gKeybindingMgr.saveAndApply();
+ //gKeybindingMgr.saveCurrentConfiguration();
+ //sv.log.debug("You may need to restart Komodo.");
+
// A (temporary) hack to allow for R autocompletion/calltips to be
// triggered with the same key-shortcut as for other languages.
// cmd_sv_RTriggerCompletion will exit for files other than R
Modified: komodo/SciViews-K/content/js/pref-R.js
===================================================================
--- komodo/SciViews-K/content/js/pref-R.js 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/js/pref-R.js 2009-11-30 23:46:47 UTC (rev 233)
@@ -241,7 +241,8 @@
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]);
+ if (arrData[i][0])
+ menuList.appendItem(arrData[i][0], arrData[i][1], arrData[i][1]);
}
menuList.value = value;
return true;
Modified: komodo/SciViews-K/content/js/prefs.js
===================================================================
--- komodo/SciViews-K/content/js/prefs.js 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/js/prefs.js 2009-11-30 23:46:47 UTC (rev 233)
@@ -75,7 +75,7 @@
sv.prefs.setString("svRDefaultInterpreter", "", false);
sv.prefs.setString("svRApplication", "", false);
sv.prefs.setString("svRApplicationId", "", false);
-sv.prefs.setString("CRANMirror", "", false);
+sv.prefs.setString("CRANMirror", "http://cran.r-project.org/", false);
Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/js/r.js 2009-11-30 23:46:47 UTC (rev 233)
@@ -1445,6 +1445,9 @@
sv.r.pkg.repositories = function () {
var res = sv.r.eval('setRepositories(TRUE)');
return(res);
+
+//on Linux, try reading data from: "<HOME>/.R/repositories", "/usr/lib/R/etc/repositories", "usr/local/lib/R/etc/repositories"
+//on Windows, "<HOME>/.R/repositories", "<R_installPath>/etc/repositories"
}
// Select CRAN mirror, with optional callback
@@ -1477,7 +1480,7 @@
sv.r.eval('with(TempEnv(), { repos <- getOption("repos");' +
'repos["CRAN"] <- "' + repos + '"; ' +
'options(repos = repos) } )');
- sv.r.pkg.repos = repos;
+ cran = sv.prefs.setString("CRANMirror", repos);
if (callback) callback(repos);
}
@@ -1673,12 +1676,14 @@
var res = false;
var reset = repos === true;
+ var defaultRepos = sv.prefs.getString("CRANMirror", "http://cran.r-project.org/");
+
function _installCallback() {
- sv.r.pkg.install(pkgs, sv.r.pkg.repos, true);
+ sv.r.pkg.install(pkgs, defaultRepos, true);
};
- if (!repos && sv.r.pkg.repos) {
- repos = sv.r.pkg.repos;
+ if (!repos && defaultRepos) {
+ repos = defaultRepos;
} else if (reset && allowCCM) {
res = sv.r.pkg.chooseCRANMirror(_installCallback);
return;
@@ -1690,8 +1695,8 @@
if (cran == "@CRAN@") {
res = sv.r.pkg.chooseCRANMirror(_installCallback);
} else {
- sv.r.pkg.repos = cran;
- res = sv.r.pkg.install(pkgs, sv.r.pkg.repos, true);
+ sv.prefs.setString("CRANMirror", cran);
+ res = sv.r.pkg.install(pkgs, cran, true);
}
return;
}
Modified: komodo/SciViews-K/content/js/tools/file.js
===================================================================
--- komodo/SciViews-K/content/js/tools/file.js 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/js/tools/file.js 2009-11-30 23:46:47 UTC (rev 233)
@@ -60,7 +60,7 @@
fis.init(file, -1, -1, 0);
is.init(fis, encoding, 1024, 0xFFFD);
- ret = "";
+ var ret = "";
if (is instanceof Components.interfaces.nsIUnicharLineInputStream) {
var str = {};
var cont;
@@ -206,7 +206,7 @@
var res = [];
for(i in path) res = res.concat(path[i]);
path = res;
- path = path.join(sep).replace(/[\\\/]+/g, sep);
+ path = os.path.normpath(path.join(sep));
var dir0 = path.split(sep, 1)[0];
path = sv.tools.file.specDir(dir0) + path.substring(dir0.length);
path = os.path.abspath(path);
@@ -330,9 +330,9 @@
var err = {}, out = {};
var res = runSvc.RunAndCaptureOutput("which " + appName,
null, null, null, out, err);
-
+
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-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/overlayMain.xul 2009-11-30 23:46:47 UTC (rev 233)
@@ -95,6 +95,9 @@
<command id="cmd_sv_BrowseWD" key="key_cmd_sv_BrowseWD"
oncommand="sv.r.setwd('current', true);"
desc="R: &svBrowseWD;" label="&svBrowseWD;" accesskey="&svBrowseWD.key;"/>
+ <command id="cmd_sv_sessionMgr" key="key_cmd_sv_sessionMgr"
+ oncommand="sv.command.openSessionMgr();"
+ desc="R: &svOpenSessMgr;" label="&svOpenSessMgr;" accesskey="&svOpenSessMgr.key;"/>
</commandset>
<commandset id="cmdset_r_control" commandupdater="true"
@@ -183,7 +186,6 @@
<menupopup id="popup_sciviews_main">
<menuitem id="r_start_console_menu" observes="cmd_sv_start_R"
class="menuitem-iconic r-run-command-icon"/>
-
<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"
@@ -191,9 +193,12 @@
<menuitem id="r_start_pkg_manager" observes="cmd_sv_OpenPkgManager"
class="menuitem"/>
<menuitem id="r_start_help" observes="cmd_sv_OpenHelp"
- class="menuitem"/>
+ class="menuitem-iconic help-icon"/>
<menuitem id="r_browse_wd" observes="cmd_sv_BrowseWD"
class="menuitem-iconic r-working-dir-icon"/>
+ <menuitem id="r_session_mgr" observes="cmd_sv_sessionMgr"
+ class="menuitem-iconic r-session-dir-icon"/>
+
<menuseparator/>
<!--<menuitem id="r_send_line_menu" observes="cmd_sv_RRunLine"-->
<!-- class="menuitem-iconic r-run-line-icon"/>-->
Modified: komodo/SciViews-K/content/pref-R.xul
===================================================================
--- komodo/SciViews-K/content/pref-R.xul 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/content/pref-R.xul 2009-11-30 23:46:47 UTC (rev 233)
@@ -178,18 +178,20 @@
<columns>
<column flex="1"/> <column flex="2"/> <column flex="1"/> <column
flex="2"/>
- </columns> <rows>
+ </columns>
+ <rows>
<row align="center">
<label value="Server port #:" control="sciviews.client.socket" />
<textbox id="sciviews.client.socket" pref="true" width="50" />
<label value="Host to connect to:" control="sciviews.server.host" />
<textbox id="sciviews.server.host" pref="true" width="150"
disabled="true"/>
- </row> <row align="center">
+ </row>
+ <row align="center">
<label value="Client port #:" control="sciviews.server.socket" />
<textbox id="sciviews.server.socket" pref="true" width="50" />
- <label value="Client Id:" control="sciviews.client.id" /> <textbox
- id="sciviews.client.id" pref="true" width="150" />
+ <label value="Client Id:" control="sciviews.client.id" />
+ <textbox id="sciviews.client.id" pref="true" width="150" />
</row>
</rows>
</grid>
Added: komodo/SciViews-K/content/sessions.xul
===================================================================
--- komodo/SciViews-K/content/sessions.xul (rev 0)
+++ komodo/SciViews-K/content/sessions.xul 2009-11-30 23:46:47 UTC (rev 233)
@@ -0,0 +1,307 @@
+<?xml version="1.0"?>
+<!DOCTYPE dialog SYSTEM "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" [
+ <!ENTITY % dialogsDTD SYSTEM "chrome://komodo/locale/dialogs.dtd">
+ %dialogsDTD;
+]>
+<!ENTITY % sciviewskDTD SYSTEM "chrome://sciviewsk/locale/sciviewsk.dtd">
+ %sciviewskDTD;
+]>
+
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="chrome://komodo/skin/global/global.css" type="text/css"?>
+
+<dialog id="dialog-svsetsession"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="OnLoad(event)"
+ orient="vertical"
+ flex="1"
+ buttons="accept,extra1,cancel"
+ buttonlabelextra1="Apply"
+ ondialoghelp="return false;"
+ ondialogaccept="return OK();"
+ ondialogcancel="return true;"
+ ondialogextra1="OK();"
+ title="R Session manager"
+ persist="screenX screenY width height"
+ >
+<script type="text/javascript">
+<![CDATA[
+
+
+// Create references to main window objects:
+var mainWin, sv, ko;
+var os = Components.classes['@activestate.com/koOs;1'].getService(Components.interfaces.koIOs);
+
+
+// Populate session directory list, insert preference values into corresponding textboxes
+function OnLoad(event) {
+ var p = parent;
+ while (p = p.opener) {
+ if (!sv && p.sv) sv = p.sv;
+ if (!ko && p.ko) ko = p.ko;
+ if (sv && ko) break;
+ }
+ mainWin = p;
+
+ prefName = "sciviews.session.dir";
+ var values = sv.prefs.getString(prefName + ".mru");
+ var prefVal = sv.prefs.getString(prefName);
+ if (values) {
+ values = values.split(os.pathsep);
+ var i = values.indexOf(prefVal);
+ if (i != -1) { // Move current value onto top of list:
+ values.splice(i, 1);
+ values = Array.concat(prefVal, values);
+ }
+ if (values.length > 10)
+ values.splice(10);
+
+ var el = document.getElementById(prefName);
+ var value;
+ for (var j = 0; j < values.length; j++) {
+ value = sv.tools.file.path(values[j]);
+ el.insertItemAt(j, value, value, null);
+ }
+ }
+
+ var prefEls = document.getElementsByAttribute("pref", "true");
+ var prefName, prefVal, el;
+ for (var i = 0; i < prefEls.length; i++) {
+ el = prefEls[i];
+ prefName = el.id;
+ prefVal = sv.prefs.getString(prefName);
+
+ if (el.getAttribute("homesubst") == "true")
+ prefVal = sv.tools.file.path(prefVal);
+
+ if (el.tagName == "menulist") {
+ var mi, values = [];
+ for (var j = 0; j < el.itemCount; j++) {
+ values.push(el.getItemAtIndex(j).value);
+ }
+ if (values.indexOf(prefVal) == -1) {
+ el.insertItemAt(0, prefVal, prefVal, null);
+ }
+ }
+ el.value = prefVal;
+ }
+ selectSessionDir();
+}
+
+
+// Save values as preferences:
+function OK() {
+ var el = document.getElementById("sciviews.session.dir");
+ var mi, values = [];
+ for (var j = 0; j < el.itemCount; j++) {
+ values.push(homeSubst(el.getItemAtIndex(j).value));
+ }
+ sv.prefs.setString("sciviews.session.dir.mru", values.join(os.pathsep));
+
+ var prefEls = document.getElementsByAttribute("pref", "true");
+ var prefIds = [], prefName, prefVal, el;
+ for (var i = 0; i < prefEls.length; i++) {
+ el = prefEls[i];
+ prefVal = el.value;
+ if (el.getAttribute("homesubst") == "true")
+ prefVal = homeSubst(prefVal);
+ sv.prefs.setString(el.id, prefVal);
+ }
+
+ sv.r.setSession (document.getElementById("sciviews.session.dir").value,
+ document.getElementById("sciviews.session.data").value,
+ document.getElementById("sciviews.session.scripts").value,
+ document.getElementById("sciviews.session.reports").value);
+
+ //alert(values.join(os.pathsep));
+ return true;
+}
+
+// Substitute real home path for "~"
+// use sv.tools.file.path for opposite action
+function homeSubst(dir) {
+ var homeMacro = "~";
+ var homedir = sv.tools.file.path(homeMacro);
+ dir = os.path.normpath(dir);
+ var platform = navigator.platform.substring(0,3).toLowerCase();
+
+ if ((platform == "win"
+ && dir.substr(0, homedir.length).toLowerCase() == homedir.toLowerCase())
+ || dir.substr(0, homedir.length) == homedir) {
+
+ dir = homeMacro + dir.substr(homedir.length);
+ }
+ return dir;
+}
+
+// Add a directory item into list
+function setDir(id) {
+ var el = document.getElementById(id);
+ var dir = ko.filepicker.getFolder(el.value, "Choose directory for: " + id);
+
+ if (!dir) return false;
+
+
+ var mi;
+ for (var j = 0; j < el.itemCount; j++) {
+ if (el.getItemAtIndex(j).value == dir) {
+ el.removeItemAt(j);
+ break;
+ }
+ }
+ el.insertItemAt(0, dir, dir, null);
+ el.value = dir;
+ selectSessionDir();
+ return true;
+}
+
+function remCurItemFromList() {
+ var el = document.getElementById("sciviews.session.dir");
+ if (!el.itemCount) return;
+ var selInd = el.selectedIndex;
+ el.selectedIndex = (selInd + 1) % el.itemCount;
+ el.removeItemAt(selInd);
+ if (!el.itemCount) {
+ el.value = null;
+ }
+ selectSessionDir();
+}
+
+
+// Select current session directory and read config files, check for existing workspace
+function selectSessionDir(noReadConfig) {
+ var dir = document.getElementById("sciviews.session.dir").value;
+ var cfgFile = sv.tools.file.path(dir, ".svData");
+ // Look if this directory already exists and contains a .svData file
+ var config = {};
+ var hasConfig, hasWorkspace = false;
+
+ hasConfig = sv.tools.file.exists(dir) == 2 &&
+ sv.tools.file.exists(cfgFile) == 1;
+
+ hasWorkspace = sv.tools.file.exists(sv.tools.file.path(dir, ".RData"));
+
+ if (!noReadConfig) {
+ if (hasConfig) {
+ var key, value, cfgName, cfgValue, cfgEls;
+ hasConfig = true;
+
+ var cfg = sv.tools.file.read(cfgFile, "utf-8").split(/\r?\n+/);
+ for (var i in cfg) {
+ key = cfg[i].split(/\s*=\s*/);
+ config[key[0]] = key[1];
+ }
+ }
+
+ cfgEls = document.getElementsByAttribute("config", "*");
+ for (var i= 0; i < cfgEls.length; i++) {
+ cfgName = cfgEls[i].getAttribute("config");
+ if (config.hasOwnProperty(cfgName)) {
+ cfgEls[i].value = config[cfgName];
+ } else {
+ cfgEls[i].value = sv.prefs.getString(cfgEls[i].id);
+ }
+ }
+ }
+
+ printInfo("In this directory: " + (hasConfig? "config file exists" : "no config file") +
+ ", " + (hasWorkspace? "saved workspace exists": "no workspace") + ".");
+
+ document.getElementById("delete-config-button").disabled = !hasConfig;
+ document.getElementById("delete-workspace-button").disabled = !hasWorkspace;
+}
+
+function printInfo(str) {
+ document.getElementById("info").value = str;
+}
+
+// Save configuration files
+function saveConfig() {
+ var el = document.getElementById("sciviews.session.dir");
+ var dir = el.value;
+ var cfg = [];
+ var cfgEls = document.getElementsByAttribute("config", "*");
+ for (var i= 0; i < cfgEls.length; i++) {
+ cfg.push(cfgEls[i].getAttribute("config") + " = " + sv.tools.strings.trim(cfgEls[i].value));
+ }
+ var cfgFile = sv.tools.file.path(dir, ".svData");
+ sv.tools.file.write(cfgFile, cfg.join("\n"), "utf-8");
+
+ selectSessionDir(true);
+ return false;
+}
+
+function clearFiles(which) {
+ var dir = document.getElementById("sciviews.session.dir").value;
+ var files;
+ switch (which) {
+ case "config":
+ files = [".svData"];
+ break;
+ case "workspace":
+ files = [".RData", ".Rhistory"];
+ break;
+ default:
+ }
+
+ var file;
+ for (i in files) {
+ try {
+ file = sv.tools.file.getfile(dir, files[i]);
+ file.remove(true);
+ } catch(e) {
+ printInfo("Cannot remove file: " + e);
+ }
+ }
+ selectSessionDir();
+ return false;
+}
+
+]]>
+</script>
+<vbox>
+ <!--<description>Session directory is: TODO description here</description>-->
+ <groupbox orient="vertical">
+ <caption label="Session directory:"/>
+ <vbox>
+ <hbox align="center">
+ <menulist id="sciviews.session.dir" oncommand="selectSessionDir();"
+ pref="true" prefattribute="value" flex="1"
+ homesubst="true">
+ <menupopup id="sciviews_menu_select_r_application" />
+ </menulist>
+ <button label="Browse..."
+ oncommand="setDir('sciviews.session.dir');"/>
+ <button label="Remove" oncommand="remCurItemFromList('sciviews.session.dir');"/>
+ </hbox>
+ <separator class="thin"/>
+ <label id="info" value="" />
+ <separator class="groove"/>
+ <label value="Subdirectories (relative to session dir)"/>
+ <hbox align="center">
+ <label value="Data:" control="sciviews.session.data" />
+ <textbox id="sciviews.session.data" config="datadir" pref="true"
+ editable="false" flex="1"/>
+ <label value="Scripts:" control="sciviews.session.scripts" />
+ <textbox id="sciviews.session.scripts" config="scriptdir"
+ pref="true" flex="1"/>
+ <label value="Reports:" control="sciviews.session.reports" />
+ <textbox id="sciviews.session.reports" config="reportdir"
+ pref="true" flex="1"/>
+ </hbox>
+ <vbox align="right">
+ <hbox align="center">
+ <button id="save-config-button" label="Save config"
+ oncommand="saveConfig();"/>
+ <button id="delete-config-button"
+ label="Delete config"
+ oncommand="clearFiles('config');"/>
+ <button id="delete-workspace-button"
+ label="Delete R workspace"
+ oncommand="clearFiles('workspace');"/>
+ </hbox>
+ </vbox>
+ </vbox>
+ </groupbox>
+ </vbox>
+</dialog>
Modified: komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/locale/en-GB/sciviewsk.dtd 2009-11-30 23:46:47 UTC (rev 233)
@@ -95,3 +95,6 @@
<!ENTITY helpStart "R Help start">
<!ENTITY helpStart.key "h">
+
+<!ENTITY svOpenSessMgr "Choose session directory">
+<!ENTITY svOpenSessMgr.key "C">
Modified: komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd
===================================================================
--- komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/locale/fr-FR/sciviewsk.dtd 2009-11-30 23:46:47 UTC (rev 233)
@@ -95,3 +95,6 @@
<!ENTITY helpStart "R Help start">
<!ENTITY helpStart.key "h">
+
+<!ENTITY svOpenSessMgr "Choose session directory">
+<!ENTITY svOpenSessMgr.key "C">
Added: komodo/SciViews-K/skin/images/folder_wrench.png
===================================================================
(Binary files differ)
Property changes on: komodo/SciViews-K/skin/images/folder_wrench.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: komodo/SciViews-K/skin/sciviewsk.css
===================================================================
--- komodo/SciViews-K/skin/sciviewsk.css 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/skin/sciviewsk.css 2009-11-30 23:46:47 UTC (rev 233)
@@ -6,6 +6,10 @@
list-style-image: url("chrome://sciviewsk/skin/images/folder_home.png");
}
+.r-session-dir-icon {
+ list-style-image: url("chrome://sciviewsk/skin/images/folder_wrench.png");
+}
+
.r-run-all-icon {
list-style-image: url("chrome://sciviewsk/skin/images/run_all.png");
}
Deleted: komodo/SciViews-K/templates/.Rprofile
===================================================================
--- komodo/SciViews-K/templates/.Rprofile 2009-11-26 23:58:46 UTC (rev 232)
+++ komodo/SciViews-K/templates/.Rprofile 2009-11-30 23:46:47 UTC (rev 233)
@@ -1,5 +0,0 @@
-source("svStart.R")
-
-svStart(trace = TRUE, pkg.dir=".")
-
-rm(svStart)
More information about the Sciviews-commits
mailing list