[Sciviews-commits] r363 - in komodo/SciViews-K-dev: content content/js content/js/tools defaults locale/en-GB locale/fr-FR

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 9 03:10:29 CET 2011


Author: prezez
Date: 2011-03-09 03:10:28 +0100 (Wed, 09 Mar 2011)
New Revision: 363

Modified:
   komodo/SciViews-K-dev/content/RObjectsOverlay.xul
   komodo/SciViews-K-dev/content/js/commands.js
   komodo/SciViews-K-dev/content/js/r.js
   komodo/SciViews-K-dev/content/js/robjects.js
   komodo/SciViews-K-dev/content/js/tools/array.js
   komodo/SciViews-K-dev/content/overlayMain.xul
   komodo/SciViews-K-dev/defaults/svStart.R
   komodo/SciViews-K-dev/locale/en-GB/sciviewsk.dtd
   komodo/SciViews-K-dev/locale/fr-FR/sciviewsk.dtd
Log:
Added "Source into R" menu item in Places, + sv.command.sourcePlacesSelection
Replaced sv.r.objects with sv.rbrowser (up one level in object hierarchy), modified context menu, new command "save"
sv.r.pager - removes the file after displaying (previously R did it in svPager)
sv.r.setwd - support for Places
sv.tools.array - rewritten with new js 1.6 Array methods
R pager: falls back to displaying help in a browser if Komodo does not respond

Modified: komodo/SciViews-K-dev/content/RObjectsOverlay.xul
===================================================================
--- komodo/SciViews-K-dev/content/RObjectsOverlay.xul	2011-03-09 01:53:25 UTC (rev 362)
+++ komodo/SciViews-K-dev/content/RObjectsOverlay.xul	2011-03-09 02:10:28 UTC (rev 363)
@@ -54,101 +54,110 @@
 
 
 	<popupset id="extensionPopupSet">
-		<menupopup id="rObjectsContext"
-		onpopupshowing="sv.r.objects.contextOnShow();">
-			<menuitem class="primary_menu_item" id="menu_robjects_cmd_insertfullname"
-			command="robjects_cmd_insertfullname" acceltext="Ins"/>
-			<menuitem id="menu_robjects_cmd_insertname"
-			command="robjects_cmd_insertname" acceltext="Ctrl+Ins"/>
-			<menuitem id="menu_robjects_cmd_insertquoted"
-			command="robjects_cmd_insertquoted" acceltext="Shift+Ins"/>
+		<menupopup id="rObjectsContext" onpopupshowing="sv.rbrowser.contextOnShow(event);">
+			<menuitem id="menu_robjects_insertfullname"
+				class="primary_menu_item"
+				oncommand="sv.rbrowser.insertName(true)"
+				accesskey="F"
+				label="&sciviews.robjects.insFullName;"
+				acceltext="Ins" />
+			<menuitem id="menu_cmd_robjects_insertquoted"
+				label="&sciviews.robjects.insertQuoted;"
+				oncommand="sv.rbrowser.insertName(false, true);"
+				accesskey="&sciviews.robjects.insertQuoted.acc;"
+				acceltext="Shift+Ins" />
+			<menuitem id="menu_robjects_insertname"
+				label="&sciviews.robjects.insName;"
+				oncommand="sv.rbrowser.insertName(false)"
+				accesskey="I"
+				acceltext="Ctrl+Ins" />
 
 			<menuseparator keep="false" intoplevel="true"/>
+			<menuitem id="cmd_robjects_removeobj"
+				label="&sciviews.robjects.rmObj;"
+				oncommand="sv.rbrowser.removeSelected(event.shiftKey)"
+				accesskey="R"
+				acceltext="Del"
+				testDisableIf="t:noDelete"
+				key="key_cmd_delete" />
+			<menuitem id="menu_cmd_robjects_deletenow"
+				label="&sciviews.robjects.deleteNow;"
+				oncommand="sv.rbrowser.removeSelected(true);"
+				class="menuitem-iconic list-item-remove-icon"
+				acceltext="Shift+Del"
+				testDisableIf="t:noDelete"
+				accesskey="&sciviews.robjects.deleteNow.acc;" />
 
-			<menuitem id="menu_robjects_cmd_removeobj"
-			command="robjects_cmd_removeobj" acceltext="Del"
-			key="key_cmd_delete" />
-			<menuitem id="menu_robjects_cmd_deletenow"
-			command="robjects_cmd_deletenow" class="menuitem-iconic list-item-remove-icon"
-			acceltext="Shift+Del"/>
+			<menuseparator keep="false" intoplevel="true"/>
+			<menuitem id="cmd_robjects_summary"
+				label="&sciviews.robjects.summary;"
+				oncommand="sv.rbrowser.do('summary')"
+				testDisableIf="t:isFunction t:isEnvironment"
+				accesskey="S" />
+			<menuitem id="cmd_robjects_print"
+				label="&sciviews.robjects.print;"
+				oncommand="sv.rbrowser.do('print')"
+				testDisableIf="t:isPackage"
+				accesskey="P" />
+			<menuitem id="cmd_robjects_plot"
+				label="&sciviews.robjects.plot;"
+				oncommand="sv.rbrowser.do('plot')"
+				testDisableIf="t:isFunction t:isEnvironment"
+				accesskey="O"/>
+			<menuitem id="cmd_robjects_str"
+				label="&sciviews.robjects.str;"
+				oncommand="sv.rbrowser.do('str')"
+				testDisableIf="t:isPackage"
+				accesskey="T"/>
 
 			<menuseparator keep="false" intoplevel="true"/>
+			<menuitem id="menu_cmd_robjects_selectall"
+				label="&sciviews.robjects.selectAll;"
+				oncommand="sv.rbrowser.selection.selectAll();"
+				accesskey="&sciviews.robjects.selectAll.acc;"
+				acceltext="Ctrl+A" />
+			<menuitem id="menu_cmd_robjects_selectsiblings"
+				label="&sciviews.robjects.selectSiblings;"
+				oncommand="sv.rbrowser.selectAllSiblings(sv.rbrowser.selection.currentIndex);"
+				accesskey="&sciviews.robjects.selectSiblings.acc;"
+				acceltext="Ctrl+Shift+A" />
 
-			<menuitem id="menu_robjects_cmd_selectall"
-			command="robjects_cmd_selectall" acceltext="Ctrl+A"/>
-			<menuitem id="menu_robjects_cmd_selectsiblings"
-			command="robjects_cmd_selectsiblings" acceltext="Ctrl+Shift+A"/>
-
-			<!--<menuitem id="menu_robjects_cmd_attach" command="robjects_cmd_attach"/>
-			<menuitem id="menu_robjects_cmd_detach" command="robjects_cmd_detach"/>-->
 			<menuseparator keep="false" intoplevel="true"/>
-			<menuitem id="menu_robjects_cmd_print" command="robjects_cmd_print"/>
-			<menuitem id="menu_robjects_cmd_plot" command="robjects_cmd_plot"/>
-			<menuitem id="menu_robjects_cmd_summary" command="robjects_cmd_summary"/>
-			<menuitem id="menu_robjects_cmd_str" command="robjects_cmd_str"/>
-			<!--<menuitem id="menu_robjects_cmd_args" command="robjects_cmd_args"/>-->
-			<menuitem id="menu_robjects_cmd_names" command="robjects_cmd_names"/>
+			<menuitem id="menu_cmd_robjects_write_table"
+				class="menuitem-iconic save-buffer-icon"
+				label="&sciviews.robjects.write_table;"
+				oncommand="sv.rbrowser.do('write.table')"
+				testDisableIf="t:cannotSaveToFile"
+				accesskey="T"/>
 
-			<menuitem id="menu_robjects_cmd_write_table"
-			class="menuitem-iconic save-buffer-icon"
-			command="robjects_cmd_write_table"/>
+			<menuitem id="menu_cmd_robjects_save"
+				class="menuitem-iconic save-buffer-icon"
+				label="&sciviews.robjects.save;"
+				oncommand="sv.rbrowser.do('save')"
+				testDisableIf="t:cannotSave"
+				accesskey="S" />
 
 			<menuseparator keep="false" intoplevel="true"/>
-			<menuitem id="menu_robjects_cmd_help" command="robjects_cmd_help"/>
+			<menuitem id="menu_cmd_robjects_help"
+				label="&sciviews.robjects.help;"
+				oncommand="sv.rbrowser.do('help')"
+				class="menuitem-iconic help-icon"
+				testDisableIf="t:multipleSelection t:noHelp"
+				accesskey="H" />
+
 			</menupopup>
 		</popupset>
 
 	<broadcasterset id="broadcasterset_global">
 		<broadcaster id="cmd_robjects_viewSearchPath"
-		tooltiptext="&sciviews.robjects.tab;: &sciviews.robjects.showHide;"
-		label="&sciviews.robjects.showHide;" splitter="bottom_splitter"
-		box="robjects_searchpath_panel"
-		oncommand="sv.r.objects.toggleViewSearchPath(event);"
-		checked="true" state="open"/>
-		</broadcasterset>
+			tooltiptext="&sciviews.robjects.tab;: &sciviews.robjects.showHide;"
+			splitter="bottom_splitter"
+			box="robjects_searchpath_panel"
+			oncommand="sv.rbrowser.toggleViewSearchPath(event);"
+			checked="true" state="open"/>
+	</broadcasterset>
 
-	<commandset id="allcommands">
-		<commandset id="r-objects-commands">
-			<command id="robjects_cmd_insertfullname" label="&sciviews.robjects.insFullName;"
-			oncommand="sv.r.objects.insertName(true);" accesskey="F"/>
-			<command id="robjects_cmd_insertname" label="&sciviews.robjects.insName;"
-			oncommand="sv.r.objects.insertName(false);" accesskey="I"/>
-			<command id="robjects_cmd_removeobj" label="&sciviews.robjects.rmObj;"
-			oncommand="sv.r.objects.removeSelected(event.shiftKey);" accesskey="R"/>
-				<!--<command id="robjects_cmd_attach" label="&sciviews.robjects.loadPkg;"
-				oncommand="sv.r.objects.do('library');" accesskey="L" disabled="true"/>-->
-			<command id="robjects_cmd_summary" label="&sciviews.robjects.summary;"
-			oncommand="sv.r.objects.do('summary');" accesskey="S"/>
-			<command id="robjects_cmd_print" label="&sciviews.robjects.print;"
-			oncommand="sv.r.objects.do('print');" accesskey="P"/>
-			<command id="robjects_cmd_plot" label="&sciviews.robjects.plot;"
-			oncommand="sv.r.objects.do('plot');" accesskey="O"/>
-			<command id="robjects_cmd_str" label="&sciviews.robjects.str;"
-			oncommand="sv.r.objects.do('str');" accesskey="T"/>
-			<command id="robjects_cmd_names" label="&sciviews.robjects.names;"
-			oncommand="sv.r.objects.do('names');" accesskey="N"/>
 
-			<command id="robjects_cmd_write_table" label="&sciviews.robjects.write_table;"
-			oncommand="sv.r.objects.do('write.table');" accesskey="T"/>
-
-
-			<command id="robjects_cmd_help" label="&sciviews.robjects.help;"
-			oncommand="sv.r.objects.do('help');" accesskey="H"/>
-
-			<command id="robjects_cmd_deletenow" label="&sciviews.robjects.deleteNow;"
-			oncommand="sv.r.objects.removeSelected(true);" accesskey="&sciviews.robjects.deleteNow.acc;"/>
-			<command id="robjects_cmd_insertquoted" label="&sciviews.robjects.insertQuoted;"
-			oncommand="sv.r.objects.insertName(false, true);" accesskey="&sciviews.robjects.insertQuoted.acc;"/>
-			<command id="robjects_cmd_selectall" label="&sciviews.robjects.selectAll;"
-			oncommand="sv.r.objects.selection.selectAll();" accesskey="&sciviews.robjects.selectAll.acc;"/>
-			<command id="robjects_cmd_selectsiblings" label="&sciviews.robjects.selectSiblings;"
-			oncommand="sv.r.objects.selectAllSiblings(sv.r.objects.selection.currentIndex);"
-			accesskey="&sciviews.robjects.selectSiblings.acc;"/>
-
-
-		</commandset>
-	</commandset>
-
 	<menupopup id="tabPicker_popup">
 		<menuitem id="show_robjects_tab"
 		insertafter="show_runoutput_tab,show_codebrowser_tab"
@@ -168,7 +177,7 @@
 			<tab id="sciviews_robjects_tab" label="&sciviews.robjects.tab;"
 			insertafter="project_tab,codebrowser_tab"
 			tooltiptext="&sciviews.robjects.tip;"
-			onclick="sv.r.objects.getPackageList(false);"/>
+			onclick="sv.rbrowser.getPackageList(false);"/>
 		</tabs>
 		<tabpanels id="project_toolbox_tabpanels">
 			<tabpanel flex="1" id="sciviews_robjects_tabpanel"
@@ -179,7 +188,7 @@
 						tooltiptext="&sciviews.robjects.refresh.tip;"
 						buttonstyle="pictures"
 						label="&sciviews.robjects.refresh;" class="refresh-icon"
-						oncommand="sv.r.objects.refreshAll();"/>
+						oncommand="sv.rbrowser.refreshAll();"/>
 						<toolbarbutton id="sciviews_robjects_searchpath_button"
 						observes="cmd_robjects_viewSearchPath"
 						buttonstyle="pictures" class="searchPath-icon"
@@ -217,38 +226,38 @@
 								<menuitem id="sciviews_robjects_context_filterByName"
 								label="&sciviews.robjects.filterByName;"
 								checked="true" accesskey="n" type="checkbox"
-								oncommand="sv.r.objects.setFilterBy(this, 'name')"/>
+								oncommand="sv.rbrowser.setFilterBy(this, 'name')"/>
 								<menuitem id="sciviews_robjects_context_filterByClass"
 								label="&sciviews.robjects.filterByClass;"
 								accesskey="c" type="checkbox"
-								oncommand="sv.r.objects.setFilterBy(this, 'class')"/>
+								oncommand="sv.rbrowser.setFilterBy(this, 'class')"/>
 								<menuitem id="sciviews_robjects_context_filterByGroup"
 								label="&sciviews.robjects.filterByGroup;"
 								accesskey="g" type="checkbox"
-								oncommand="sv.r.objects.setFilterBy(this, 'group')"/>
+								oncommand="sv.rbrowser.setFilterBy(this, 'group')"/>
 								<menuseparator/>
 								<menuitem id="sciviews_robjects_context_clrFilter"
 								label="&sciviews.robjects.clrFilter;" accesskey="l"
-								oncommand="document.getElementById('sciviews_robjects_filterbox').value = ''; sv.r.objects.applyFilter();"/>
+								oncommand="document.getElementById('sciviews_robjects_filterbox').value = ''; sv.rbrowser.applyFilter();"/>
 							</menupopup>
 						</toolbarbutton>
 						<textbox id="sciviews_robjects_filterbox" flex="1"
-							type="search" timeout="500"
-							tooltiptext="&sciviews.robjects.filter.tip;"
-							style="min-width: 40px; max-width: 200px; margin-right: 0px;"
+						type="search" timeout="500"
+						tooltiptext="&sciviews.robjects.filter.tip;"
+						style="min-width: 40px; max-width: 200px; margin-right: 0px;"
 							class="search-box"
-							oncommand="sv.r.objects.applyFilter();"
+							oncommand="sv.rbrowser.applyFilter();"
 							emptytext="&sciviews.robjects.filterEmptyText;"
 						/>
 					</hbox>
 					<vbox id="robjects_searchpath_panel"
 					persist="height collapsed" state="collapsed" flex="1">
 						<listbox flex="1" id="sciviews_robjects_searchpath_listbox"
-						ondragdrop="nsDragAndDrop.drop(event, sv.r.objects.packageListObserver);"
-						ondragover="nsDragAndDrop.dragOver(event, sv.r.objects.packageListObserver);"
-						ondraggesture="nsDragAndDrop.startDrag(event, sv.r.objects.packageListObserver);"
-						onkeypress="sv.r.objects.packageListKeyEvent(event);"
-						oncommand="sv.r.objects.packageSelectedEvent(event);"/>
+						ondragdrop="nsDragAndDrop.drop(event, sv.rbrowser.packageListObserver);"
+						ondragover="nsDragAndDrop.dragOver(event, sv.rbrowser.packageListObserver);"
+						ondraggesture="nsDragAndDrop.startDrag(event, sv.rbrowser.packageListObserver);"
+						onkeypress="sv.rbrowser.packageListKeyEvent(event);"
+						oncommand="sv.rbrowser.packageSelectedEvent(event);"/>
 					</vbox>
 					<splitter id="sciviews_robjects_splitter" collapse="before"
 					resizeafter="closest" resizebefore="closest" persist="state"
@@ -260,35 +269,35 @@
 						persist="sortDirection sortResource"
 						sortDirection="ascending" sortResource="r-name"
 						enableColumnDrag="true"
-						onselect="sv.r.objects.onEvent(event);"
-						onkeypress="sv.r.objects.onEvent(event);">
+						onselect="sv.rbrowser.onEvent(event);"
+						onkeypress="sv.rbrowser.onEvent(event);">
 							<treecols>
 								<treecol id="r-name" label="&sciviews.robjects.Name;"
 								primary="true" sortActive="true"
 								persist="width ordinal hidden"
-								onclick="sv.r.objects.sort(this);" ordinal="1" flex="4"/>
+								onclick="sv.rbrowser.sort(this);" ordinal="1" flex="4"/>
 								<splitter class="tree-splitter" ordinal="2"/>
 								<treecol id="r-dims" label="&sciviews.robjects.Dims;"
 								persist="width ordinal hidden"
-								onclick="sv.r.objects.sort(this);" flex="1" ordinal="3"/>
+								onclick="sv.rbrowser.sort(this);" flex="1" ordinal="3"/>
 								<splitter class="tree-splitter" ordinal="4"/>
 								<treecol id="r-group" label="&sciviews.robjects.Group;"
 								flex="2" hidden="true" persist="width ordinal hidden"
-								onclick="sv.r.objects.sort(this);" ordinal="5"/>
+								onclick="sv.rbrowser.sort(this);" ordinal="5"/>
 								<splitter class="tree-splitter" ordinal="6"/>
 								<treecol id="r-class" label="&sciviews.robjects.Class;"
 								flex="2" hidden="true" persist="width ordinal hidden"
-								onclick="sv.r.objects.sort(this);" ordinal="7"/>
+								onclick="sv.rbrowser.sort(this);" ordinal="7"/>
 								<splitter class="tree-splitter" ordinal="8"/>
 								<treecol id="r-fullName" label="&sciviews.robjects.FullName;"
 								persist="width ordinal hidden" flex="1" hidden="true" ordinal="9"/>
 							</treecols>
 							<treechildren id="sciviews_robjects_objects_tree_main"
-							ondraggesture="nsDragAndDrop.startDrag(event, sv.r.objects.listObserver);"
-							ondragdrop="nsDragAndDrop.drop(event, sv.r.objects.listObserver);"
-							ondragover="nsDragAndDrop.dragOver(event, sv.r.objects.listObserver);"
-							onclick="sv.r.objects.onEvent(event);"
-							ondblclick="sv.r.objects.onEvent(event);"
+							ondraggesture="nsDragAndDrop.startDrag(event, sv.rbrowser.listObserver);"
+							ondragdrop="nsDragAndDrop.drop(event, sv.rbrowser.listObserver);"
+							ondragover="nsDragAndDrop.dragOver(event, sv.rbrowser.listObserver);"
+							onclick="sv.rbrowser.onEvent(event);"
+							ondblclick="sv.rbrowser.onEvent(event);"
 							context="rObjectsContext">
 							</treechildren>
 						</tree>
@@ -298,15 +307,13 @@
 							<toolbarbutton id="sciviews_robjects_foldAll_button"
 							label="Fold All" buttonstyle="pictures"
 							class="robjects-fold-all-icon"
-							oncommand="sv.r.objects.foldAll(true);"
+							oncommand="sv.rbrowser.foldAll(true);"
 							tooltiptext="&sciviews.robjects.foldAll;"/>
 							<toolbarbutton id="sciviews_robjects_ExpandAll_button"
 							label="Expand All" buttonstyle="pictures"
 							class="robjects-expand-all-icon"
-							oncommand="sv.r.objects.foldAll(false);"
+							oncommand="sv.rbrowser.foldAll(false);"
 							tooltiptext="&sciviews.robjects.unfoldAll;"/>
-								<!--<toolbarbutton id="sciviews_robjects_tmpInitialize_button"
-								label="Init!" oncommand="sv.r.objectsInit();"/>-->
 						</hbox>
 					</vbox>
 				</vbox>

Modified: komodo/SciViews-K-dev/content/js/commands.js
===================================================================
--- komodo/SciViews-K-dev/content/js/commands.js	2011-03-09 01:53:25 UTC (rev 362)
+++ komodo/SciViews-K-dev/content/js/commands.js	2011-03-09 02:10:28 UTC (rev 363)
@@ -133,8 +133,6 @@
 
 	// Start R
 
-
-
 	this.startR = function () {
 		var exitCode;
 		if (_this.RProcess && _this.RProcess.uuid) try {
@@ -577,9 +575,21 @@
 	//_this.getRProc().
 //}, false);
 
+this.sourcePlacesSelection = function sv_sourcePlacesSelection() {
+	var files = ko.places.manager.getSelectedItems()
+		.filter(function(x)(x.name.search(/\.[Rr]$/) != -1))
+		.map(function(x) x.file.path);
+	if (!files.length) return;
+	var cmd = files.map(function(x) "source('" + sv.tools.string.addslashes(x) +"')" ).join("\n");
+	sv.rconn.eval(cmd, null, false);
+}
 
 
 addEventListener("load", function() setTimeout(_setControllers, 600), false);
 addEventListener("load", _setKeybindings, false);
 
 }).apply(sv.command);
+
+
+sv.getScimoz = function sv_getScimoz ()
+ko.views.manager.currentView? ko.views.manager.currentView.scimoz : null;

Modified: komodo/SciViews-K-dev/content/js/r.js
===================================================================
--- komodo/SciViews-K-dev/content/js/r.js	2011-03-09 01:53:25 UTC (rev 362)
+++ komodo/SciViews-K-dev/content/js/r.js	2011-03-09 02:10:28 UTC (rev 363)
@@ -58,7 +58,7 @@
 // sv.r.kpfTranslate(kpfFile); // Translate a project
 // sv.r.kpzTranslate(kpzFile); // Translate a package
 //
-// Note: sv.r.objects is implemented in robjects.js
+// Note: sv.rbrowser is implemented in robjects.js
 //       sv.r.console functions are implemented in rconsole.js
 //
 // sv.r.pkg namespace: /////////////////////////////////////////////////////////
@@ -79,17 +79,6 @@
 // sv.r.pkg.remove_select(pkgs); // Callback function for sv.r.pkg.remove()
 // sv.r.pkg.install(pkgs, repos); // Install R package(s) from local files or repositories
 
-
-/// REMOVED! replaced by sv.r.pkg.install
-// sv.r.pkg.installLocal(); // Install one or more R packages from local files
-// sv.r.pkg.installSV(); // Install the SciViews-R packages from CRAN
-// sv.r.pkg.installSVrforge(); // Install development versions of SciViews-R
-// from R-Forge
-// sv.r.pkg.CRANmirror();   // Select preferred CRAN mirror
-
-/// REMOVED! use sv.command.openHelp instead
-// sv.r.helpStart(start); // Start R help in the browser, unless start is false
-
 ////////////////////////////////////////////////////////////////////////////////
 //
 // TODO:
@@ -161,9 +150,9 @@
 	args.splice(2,  0, true, null, false)
 	sv.rconn.eval.apply(sv.rconn, args)
 }
+
 sv.r.eval = function(cmd) sv.rconn.eval.call(sv.rconn, cmd)
 sv.r.evalHidden = function(cmd, earlyExit) sv.rconn.eval.call(sv.rconn, cmd)
-// Escape R calculation
 sv.r.escape = function (cmd) sv.rconn.escape(cmd);
 
 // Set the current working directory (to current buffer dir, or ask for it)
@@ -199,10 +188,11 @@
 					view.setFocus();
 					if (!view.koDoc.isUntitled) dir = view.koDoc.file.dirName;
 					break;
-				}
+				} // Fallback: project directory
 			case "project":
 				try {
-					dir = ko.places.manager.getSelectedItem().file.dirName;
+					var file = ko.places.manager.getSelectedItem().file;
+					dir = file.isDirectory? file.path : file.dirName;
 				} catch(e) {
 					dir = sv.tools.file.pathFromURI(ko.places.manager.currentPlace);
 				}
@@ -302,9 +292,8 @@
 			// Save all or part in the temporary file and source that file.
 			// After executing, tell R to delete it.
 			var code = sv.getTextRange(what);
-
 			if (what == "function") {
-				var rx = /(([`'"])(.+)\2|([\w\u00c0-\uFFFF\.]+))(?=\s*<-\s*function)/;
+				var rx = /(([`'"])(.+)\2|([\w\u0100-\uFFFF\.]+))(?=\s*<-\s*function)/;
 				var match = code.match(rx);
 				what += " \"" + (match? match[3] || match[4] : '') + "\"";
 				//.replace(/^(['"`])(.*)\1/, "$2")
@@ -376,6 +365,8 @@
 //	}
 //}
 
+
+
 // Get help in R (HTML format)
 sv.r.help = function (topic, pkg) {
 	var res = false;
@@ -419,16 +410,18 @@
 }
 
 // Display some text from a file
-sv.r.pager = function(file, title) {
+sv.r.pager = function(file, title, cleanUp) {
 	var rSearchUrl = "chrome://sciviewsk/content/rsearch.html";
 	var content = sv.tools.file.read(file);
 	content = content.replace(/([\w\.\-]+)::([\w\.\-\[]+)/ig,
-	'<a href="' + rSearchUrl + '?$1::$2">$1::$2</a>');
+		'<a href="' + rSearchUrl + '?$1::$2">$1::$2</a>');
 	content = "<pre id=\"rPagerTextContent\" title=\"" + title + "\">" +
-	content + "</div>";
-	var charset = sv.socket.charset;
-	sv.tools.file.write(file, content, charset);
+		content + "</div>";
+	//var charset = sv.socket.charset;
+	sv.tools.file.write(file, content, 'utf-8');
 	sv.command.openHelp(rSearchUrl + "?file:" + file);
+	if(cleanUp || cleanUp === undefined)
+		window.setTimeout("try { sv.tools.file.getfile('"+file+"').remove(false); } catch(e) {}", 10000);
 }
 
 // Search R help for topic
@@ -721,7 +714,7 @@
 	if (loadNew === undefined) loadNew = true;
 
 	// cmd is the command executed in R to switch session (done asynchronously)
-	var cmd = "";
+	var cmd = [];
 
 	// If dir is the same as current session dir, do nothing
 	if (typeof(dir) != "undefined" && sv.tools.file.path(dir) ==
@@ -733,15 +726,12 @@
 	if (saveOld) {
 		// Save .RData & .Rhistory in the the session directory and clean WS
 		// We need also to restore .required variable (only if it exists)
-		cmd += 'if (exists(".required")) assignTemp(".required", .required)\n' +
-			'TempEnv()$.Last.sys()\n' +
-			'save.image()\nsavehistory()\nrm(list = ls())\n' +
-			'.required <- getTemp(".required")\n';
-	} else {
-		// Clear workspace (hint, we don't clear hidden objects!)
-		cmd += 'rm(list = ls())\n'
+		cmd.push('if (exists(".required")) assignTemp(".required", .required)',
+				 'TempEnv()$.Last.sys()',
+				 'save.image(); savehistory()',
+				 'rm(list = ls())');
 	}
-	// TODO: possibly close the associated Komodo project
+	cmd.push('rm(list = ls())', '.required <- getTemp(".required")');
 
 	// Initialize the session
 	dir = sv.r.initSession(dir, datadir, scriptdir, reportdir);
@@ -773,6 +763,7 @@
 			}
 		}
 	}
+TODO ///
 
 	// Execute the command in R (TODO: check for possible error here!)
 	// TODO: run first in R; make dirs in R; then change in Komodo!
@@ -788,12 +779,9 @@
 		// TODO: report if we load something or not
 		sv.r.evalCallback('cat("Session directory is now", dQuote("' + dir.addslashes() +
 		'"), "\\n", file = stderr())', null);
-		// Refresh active objects support and object explorer, ...
-		// KB: on Win, Komodo socket server gets stuck constantly, and below causes problems
-		//     so temporarily commented out
-		//sv.r.evalHidden("try(guiRefresh(force = TRUE), silent = TRUE)");
+		// Refresh object explorer, ...
+		sv.rconn.eval('koCmd("sv.rbrowser.smartRefresh()")', null, true);
 	});
-	// TODO: possibly open the Komodo project associated with this session
 	return(true);
 }
 
@@ -932,7 +920,7 @@
 	// Clear the R-relative statusbar message
 	ko.statusBar.AddMessage("", "SciViews-K");
 	// Clear the objects browser
-	sv.r.objects.clearPackageList();
+	sv.rbrowser.clearPackageList();
 }
 
 //// Define the 'sv.r.pkg' namespace ///////////////////////////////////////////

Modified: komodo/SciViews-K-dev/content/js/robjects.js
===================================================================
--- komodo/SciViews-K-dev/content/js/robjects.js	2011-03-09 01:53:25 UTC (rev 362)
+++ komodo/SciViews-K-dev/content/js/robjects.js	2011-03-09 02:10:28 UTC (rev 363)
@@ -1,10 +1,9 @@
-//{
-// SciViews-K R objects explorer functions
-// Define the 'sv.r.objects' tree and implement RObjectsOverlay functions
-// Copyright (c) 2009, Kamil Barton & Ph. Grosjean (phgrosjean at sciviews.org)
-// License: MPL 1.1/GPL 2.0/LGPL 2.1
+//{ SciViews-K R objects explorer functions
+//  Define the 'sv.rbrowser' tree and implement RObjectsOverlay functions
+//  Copyright (c) 2009, Kamil Barton & Ph. Grosjean (phgrosjean at sciviews.org)
+//  License: MPL 1.1/GPL 2.0/LGPL 2.1
 ////////////////////////////////////////////////////////////////////////////////
-// sv.r.objects properties and methods
+// sv.rbrowser properties and methods
 //TODO: complete this documentation, clean up the code
 //
 ///// These variables store all the information ////////////////////////////////
@@ -95,21 +94,16 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 //TODO: identify packages by pos rather than name (allow for non-unique names)
-//TODO: sort inserted child nodes (3-state sorting), restoring natural order of
-//      sub-elements (add orderIndex property to inserted elements)
-//TODO: resolve filtering modes: should sub-object be filtered too?
 //TODO: context menu for search-paths list
 //TODO: renaming objects on the list - editable names
 //TODO: add context menu item for environments: remove all objects
 //TODO: add a checkbutton to show also hidden objects (starting with a dot)
-//TODO: delegate context menu calculation to R
-//TODO: smart refresh: keep opened nodes, preserve scrolling
 //TODO: automatic refresh of the browser from R
 ////////////////////////////////////////////////////////////////////////////////
 // TODO: make this a sv.robjects.tree instead!
 //}}
 
-sv.r.objects = {};
+sv.rbrowser = {};
 
 ////DEBUG///
 var print = sv.cmdout.append;	/// XXX DEBUG
@@ -124,8 +118,6 @@
 function _callerStr(fun) fun? fun.caller.toString().match(/^[^\)]*\)[.\s]{0,15}/) : '?'; // XXX
 //function _funStr(fun) (fun? fun : _funStr.caller).toString().match(/^[^\)]*\)/) ;
 //function _funStr2(fun) (fun? fun : _funStr.caller.caller).toString().match(/^[^\)]*\)/) ;
-
-
 //function _funStr(fun) {
 //	if (!fun) fun = _funStr.caller;
 //	return fun.toString().match(/^[^\)]*\)/) + " <- " +
@@ -144,7 +136,7 @@
 
 //{ }
 
-// sv.r.objects constructor
+// sv.rbrowser constructor
 (function () {
 //{
 
@@ -205,9 +197,8 @@
 
 		if (rowsChanged) _this.treeBox.rowCountChanged(0, rowsChanged);
 
-		if(_this.treeBox.view.rowCount > _this.visibleData.length) {
+		if(_this.treeBox.view.rowCount > _this.visibleData.length)
 			throw new Error("Whoops....");
-		}
 
 		if(firstVisibleRow < _this.visibleData.length)
 			_this.treeBox.scrollToRow(firstVisibleRow);
@@ -218,13 +209,12 @@
 	};
 
 	function RObjectLeaf(env, obj, arr, index, parentElement) {
-		//print("RObjectLeaf: " + Array.apply(null, arguments));
 		var type = parentElement? ((parentElement.type == "environment")? 'object' :
 			(parentElement.group == "function" ? "args" : "sub-object")) :
 			'environment';
 
 		dimNumeric = 1;
-		pos = index;//policz tutaj????
+		pos = index; // XXX ????
 		//this.index = index;
 		this.type = type;
 		if (obj) { /// Objects
@@ -1142,11 +1132,11 @@
 	var length = scimoz.length;
 
 	if (scimoz.getWCharAt(scimoz.selectionStart - 1)
-	.search(/^[\w\.\u0100-\uFFFF"'`,\.;:=]$/) != -1)
-	text = " " + text;
+		.search(/^[\w\.\u0100-\uFFFF"'`,\.;:=]$/) != -1)
+		text = " " + text;
 	if (scimoz.getWCharAt(scimoz.selectionEnd)
-	.search(/^[\w\.\u0100-\uFFFF"'`]$/) != -1)
-	text += " ";
+		.search(/^[\w\.\u0100-\uFFFF"'`]$/) != -1)
+		text += " ";
 
 	scimoz.insertText(scimoz.currentPos, text);
 	scimoz.currentPos += scimoz.length - length;
@@ -1181,87 +1171,119 @@
 	return;
 }
 
-this.contextOnShow = function () {
+this.contextOnShow = function (event) {
 	var currentIndex = _this.selection.currentIndex;
-	if (currentIndex != -1) {
-		var isEnvironment, isPackage, isInPackage, noDelete, isFunction;
-		var item, type, name;
-		item = _this.visibleData[currentIndex].origItem;
-		type = item.class;
-		name = item.fullName;
+	if (currentIndex == -1) return;
 
-		isEnvironment = item.type == "environment";
-		isPackage = isEnvironment && (item.name.indexOf("package:") == 0);
-		isInPackage = !isPackage && item.env &&
-				(item.env.indexOf("package:") == 0);
+	var isEnvironment, isPackage, isInPackage, noDelete, isFunction;
+	var item, type, name;
+	item = _this.visibleData[currentIndex].origItem;
+	type = item.class;
+	name = item.fullName;
 
-		noDelete = (isEnvironment && (nonDetachable.indexOf(name) != -1))
+	isEnvironment = item.type == "environment";
+	isPackage = isEnvironment && (item.name.indexOf("package:") == 0);
+	isInPackage = !isPackage && item.env &&
+			(item.env.indexOf("package:") == 0);
+
+	noDelete = (isEnvironment && (nonDetachable.indexOf(name) != -1))
 		|| isInPackage;
-		isFunction = type == "function";
+	isFunction = type == "function";
 
-		var canSaveToFile = ["data.frame", "matrix", "table"]
-		.indexOf(item.class) > -1;
+	var cannotSaveToFile = ["data.frame", "matrix", "table"].indexOf(item.class) == -1;
+	var cannotSave = _this.selectedItemsOrd.filter(function(x)
+		x.type == 'object' && x.group != 'function').length == 0;
 
-		var selItemCount = _this.selection.count;
+	var multipleSelection = _this.selection.count > 1;
 
-		// Help can be shown only for one object:
-		var hasHelp = (selItemCount == 1)
-		&& (isPackage || isInPackage);
+	// Help can be shown only for one object:
+	var noHelp = !isPackage || !isInPackage;
 
-		//print (name
-		//	+ "; isPackage:" + isPackage
-		//	+ "; isEnvironment:" + isEnvironment
-		//	+ "; noDelete:" + noDelete
-		//	+ "; isInPackage:" + isEnvironment
-		//	+ "; isFunction:" + isFunction
-		//	+ "; hasHelp:" + hasHelp
-		//)
+	//var menuNode = document.getElementById("rObjectsContext");
+	var menuItems = event.target.childNodes;
+	var testDisableIf, disable = false;
 
-		document.getElementById("robjects_cmd_removeobj")
-		.setAttribute("disabled", noDelete);
-		document.getElementById("robjects_cmd_deletenow")
-		.setAttribute("disabled", noDelete);
-		//document.getElementById("robjects_cmd_attach")
-		//	.setAttribute("disabled", noDelete || !isPackage);
-		document.getElementById("robjects_cmd_summary")
-		.setAttribute("disabled", isFunction || isEnvironment);
-		document.getElementById("robjects_cmd_print")
-		.setAttribute("disabled", isPackage);
-		document.getElementById("robjects_cmd_plot")
-		.setAttribute("disabled", isFunction || isEnvironment);
-		document.getElementById("robjects_cmd_names")
-		.setAttribute("disabled", isFunction);
-		document.getElementById("robjects_cmd_str")
-		.setAttribute("disabled", isPackage);
-		document.getElementById("robjects_cmd_write_table")
-		.setAttribute("disabled", !canSaveToFile);
 
-		// Disable help option for non-package objects,
-		// because usually there is none
-		document.getElementById("robjects_cmd_help")
-		.setAttribute("disabled", !hasHelp);
+	for(var i = 0; i < menuItems.length; i++) {
+		if (!menuItems[i].hasAttribute('testDisableIf')) continue;
+		testDisableIf = menuItems[i].getAttribute('testDisableIf').split(/\s+/);
+		disable = false;
+
+		for(var j = 0; j < testDisableIf.length && !disable; j++) {
+			switch(testDisableIf[j]){
+				case 't:multipleSelection':
+					disable = multipleSelection;
+					break;
+				case 't:noHelp':
+					disable = noHelp;
+					break;
+				case 't:isFunction':
+					disable = isFunction;
+					break;
+				case 't:isEnvironment':
+					disable = isEnvironment;
+					break;
+				case 't:isPackage':
+					disable = isPackage;
+					break;
+				case 't:cannotSaveToFile':
+					disable = cannotSaveToFile;
+					break;
+				case 't:cannotSave':
+					disable = cannotSave;
+					break;
+				case 't:noDelete':
+					disable = noDelete;
+					break;
+				default: ;
+			}
+		}
+		//print( menuItems[i].id + ": " + testDisableIf + " = " + disable);
+		menuItems[i].setAttribute('disabled', disable);
 	}
+
 }
 
 this.do = function (action) {
-	var obj = [];
-	var rows = _this.getSelectedRows();
+	var obj = _this.selectedItemsOrd;
+	var command;
+	switch(action) {
+		case 'save':
+			// Select only objects:
+			obj = obj.filter(function(x) { if(x.type != "object") {
+				_this.selection.toggleSelect(x.index); return false }
+				else return true});
 
-	for (i in rows)
-	obj.push(_this.visibleData[rows[i]].origItem);
+			var dup = sv.tools.array.duplicates(obj.map(function(x) x.name));
+			if(dup.length &&
+			   ko.dialogs.okCancel("Objects with the same names from different" +
+				"environments selected. Following object will be taken from the " +
+				"foremost location in the search path: " + dup.join(', '),
+				"Cancel") == "Cancel") return;
 
-	var command;
+			var fileName = (obj.length == 1)? obj[0].name
+				.replace(/[\/\\:\*\?"<>\|]/g, '_') : '';
 
-	switch(action) {
+			var dir = sv.tools.file.path(sv.rconn.evalAtOnce("cat(getwd())"));
+
+			fileName = sv.fileOpen(dir, fileName + '.RData', '',
+				["R data (*.RData)|*.RData"], false, true, oFilterIdx = {});
+
+			if (!fileName) return;
+			command = 'save(list=c(' + obj.map(function(x) '"' + x.name + '"')
+				.join(',')	+ '), file="' + fileName.addslashes() + '")';
+
+			sv.r.eval(command);
+		break;
 		// Special handling for help
 		case 'help':
 		for (i in obj) {
 			// Help only for packages and objects inside a package
-			if (obj[i].env.indexOf("package:") == 0) {
+			if (obj[i].fullName.indexOf("package:") == 0) {
+				sv.r.help("", obj[i].fullName.replace(/^package:/, ''));
+			} else if (obj[i].env.indexOf("package:") == 0) {
 				sv.r.help(obj[i].fullName, obj[i].env.replace(/^package:/, ''));
-			} else if (obj[i].fullName.indexOf("package:") == 0) {
-				sv.r.help("", obj[i].fullName.replace(/^package:/, ''));
-			} else {
+			} else  {
 				sv.r.help(obj[i].fullName);
 			}
 		}
@@ -1273,9 +1295,8 @@
 		var cmd = [], expr;
 
 		for (i in obj) {
-			expr = "evalq(" + obj[i].fullName +
-			", envir = as.environment(\"" +
-			obj[i].env.addslashes() + "\"))";
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sciviews -r 363


More information about the Sciviews-commits mailing list