[rkward-cvs] SF.net SVN: rkward:[4161] trunk/rkward/rkward/plugins/00saveload/save/save

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Sat Mar 3 15:45:38 UTC 2012


Revision: 4161
          http://rkward.svn.sourceforge.net/rkward/?rev=4161&view=rev
Author:   m-eik
Date:     2012-03-03 15:45:38 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
partly rewrote the save R objects plugin, adding more compression options.

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/00saveload/save/save/code.js
    trunk/rkward/rkward/plugins/00saveload/save/save/description.xml

Modified: trunk/rkward/rkward/plugins/00saveload/save/save/code.js
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save/code.js	2012-02-23 15:59:14 UTC (rev 4160)
+++ trunk/rkward/rkward/plugins/00saveload/save/save/code.js	2012-03-03 15:45:38 UTC (rev 4161)
@@ -1,23 +1,36 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Warning: please check correctness of conversion of '=>' in arrays by hand
-Warning: please check correctness of conversion of '=>' in arrays by hand
-
----------------------------- */
-
 // globals
-var vars;
-var undefined;
+var data;
+var file;
 
+function calculate(){
+	file = getValue("file");
+	// read in variables from dialog
+	var ascii = getValue("ascii");
+	var compress = getValue("compress");
+	var complevel = getValue("complevel");
+	var xzextreme = getValue("xzextreme");
 
-function calculate () {
-	vars = trim (getValue ("data")).replace (/\n/g, ",");
-
-	echo ('save (' + vars + ', file="' + getValue("file") + '", ascii=' + getValue("ascii") + ', compress=' + getValue("compress") + ')\n');
+	// the R code to be evaluated
+	data = getValue("data").split("\n").join(", ");
+	echo("save(" + data);
+	if(file) {
+		echo(",\n\tfile=\"" + file + "\"");
+	}
+	if(ascii) {
+		echo(",\n\tascii=TRUE");
+	}
+	if(compress) {
+		if(compress != "xz" | xzextreme != "true") {
+			echo(",\n\tcompress=\"" + compress + "\",\n\tcompression_level=" + complevel);
+		} else if(xzextreme) {
+			echo(",\n\tcompress=\"" + compress + "\",\n\tcompression_level=-" + complevel);
+		}
+	}
+	echo(")\n\n");
 }
 
-function printout () {
-	makeHeaderCode ("Save R objects", new Array("File", getValue ("file"), "Variables", vars));
+function printout(){
+	// printout the results
+	makeHeaderCode ("Save R objects", new Array("File", file, "Variables", data));
 }
 

Modified: trunk/rkward/rkward/plugins/00saveload/save/save/description.xml
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save/description.xml	2012-02-23 15:59:14 UTC (rev 4160)
+++ trunk/rkward/rkward/plugins/00saveload/save/save/description.xml	2012-03-03 15:45:38 UTC (rev 4161)
@@ -2,22 +2,52 @@
 <document>
 	<code file="code.js"/>
 
-	<dialog label="Save R objects" >
+	<logic>
+		<convert id="lgc_compress" sources="compress.string" mode="notequals" />
+		<convert id="lgc_cmprssxz" sources="compress.string" mode="equals" standard="xz" />
+		<connect governor="lgc_compress" client="complevel.enabled" />
+		<connect governor="lgc_cmprssxz" client="xzextreme.enabled" />
+		<script>
+			<![CDATA[ gui.addChangeCommand("compress.string", "compressionChanged()");
+					// try to set compression level dynamically
+					// run each time the compression method is changed
+					compressionChanged = function(){
+							var thisObject = gui.getValue("compress.string");
+							 if(thisObject == "bzip2" | thisObject == "xz"){
+								gui.setValue("complevel.int", 9);
+							} else {
+								gui.setValue("complevel.int", 6);
+							}
+						} ]]>
+		</script>
+	</logic>
+	<dialog label="Save R objects">
 		<tabbook>
-			<tab label="Select variables" >
+			<tab label="Select variables">
 				<column>
 					<row>
 						<varselector id="vars" />
-						<varslot multi="true" id="data" source="vars" label="Object" required="true" />
+						<varslot id="data" label="Object" source="vars" required="true" multi="true" />
 					</row>
 				</column>
-				<frame label="Options" >
-					<row>
-						<browser type="savefile" size="small" initial="my.RData" id="file" label="File name" />
-						<checkbox value_unchecked="FALSE" checked="false" value="TRUE" id="ascii" label="Ascii" />
-						<checkbox value_unchecked="FALSE" checked="false" value="TRUE" id="compress" label="Compress" />
-					</row>
-				</frame>
+				<row>
+					<frame label="Save to" id="frm_Saveto">
+						<browser label="File name" type="savefile" id="file" initial="my.RData" />
+						<stretch />
+					</frame>
+					<frame label="Options" id="frm_Options">
+						<checkbox id="ascii" label="Ascii" value="true" />
+						<dropdown id="compress" label="Compression">
+							<option label="None" checked="true" />
+							<option label="gzip" value="gzip" />
+							<option label="bzip2" value="bzip2" />
+							<option label="xz" value="xz" />
+						</dropdown>
+						<spinbox label="Compression level" id="complevel" initial="6" min="1" max="9" type="integer" />
+						<checkbox id="xzextreme" label="Enable xz extreme compression" value="true" />
+						<stretch />
+					</frame>
+				</row>
 			</tab>
 		</tabbook>
 	</dialog>

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list