[rkward-cvs] SF.net SVN: rkward:[3061] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Sep 22 12:26:25 UTC 2010


Revision: 3061
          http://rkward.svn.sourceforge.net/rkward/?rev=3061&view=rev
Author:   tfry
Date:     2010-09-22 12:26:24 +0000 (Wed, 22 Sep 2010)

Log Message:
-----------
Add basic error handling to GUI scripting.

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugins/data/sort.js
    trunk/rkward/rkward/plugins/data/sort.xml
    trunk/rkward/rkward/plugins/data/sort2.xml
    trunk/rkward/rkward/scriptbackends/rkcomponentscripting.cpp
    trunk/rkward/rkward/scriptbackends/rkcomponentscripting.h

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2010-09-22 10:38:45 UTC (rev 3060)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2010-09-22 12:26:24 UTC (rev 3061)
@@ -186,6 +186,7 @@
 
 	if (!scripting) {
 		scripting = new RKComponentScriptingProxy (this);
+		connect (scripting, SIGNAL (haveError ()), this, SLOT (kill ()));
 	}
 	return scripting;
 }

Modified: trunk/rkward/rkward/plugins/data/sort.js
===================================================================
--- trunk/rkward/rkward/plugins/data/sort.js	2010-09-22 10:38:45 UTC (rev 3060)
+++ trunk/rkward/rkward/plugins/data/sort.js	2010-09-22 12:26:24 UTC (rev 3061)
@@ -1,11 +1,13 @@
 function calculate () {
 	var object = getValue ("object");
-	var is_data_frame = getValue ("sortby_frame.enabled");
+	var is_data_frame = (getValue ("sortby_frame.enabled") == "true");
 
 	var saveto = object;
 	if (getValue ("saveto_select") == "other") saveto = getValue ("saveto");
+	var sortby = getValue ("sortby");
+	if (!is_data_frame) sortby = object;
 
-	echo (".GlobalEnv$" + saveto + " <- " + object + "[order (" + getValue ("sortby") + getValue ("order") + ")");
+	echo (".GlobalEnv$" + saveto + " <- " + object + "[order (" + sortby + getValue ("order") + ")");
 	if (is_data_frame) echo (",");
 	echo ("]\n");
 }

Modified: trunk/rkward/rkward/plugins/data/sort.xml
===================================================================
--- trunk/rkward/rkward/plugins/data/sort.xml	2010-09-22 10:38:45 UTC (rev 3060)
+++ trunk/rkward/rkward/plugins/data/sort.xml	2010-09-22 12:26:24 UTC (rev 3061)
@@ -2,6 +2,7 @@
 <document>
 	<code file="sort.js"/>
 	<logic>
+		<set id="vectormode" to="0"/>
 		<connect governor="current_object" client="object.available"/>
 		<connect governor="object.available" client="sortby_selector.root"/>
 		<convert id="isok" mode="equals" sources="notice.text" standard="" require_true="true"/>
@@ -19,11 +20,11 @@
 				gui.setValue ("sortby_frame.enabled", object.isDataFrame ());
 				gui.setValue ("sortby.required", object.isDataFrame ());
 
-				if (!(object.dimensions().length == 1 || object.isDataFrame())) {
-					// Not very elegant, but...
-					gui.setValue ("notice.text", "This type of object is not supported in this plugin");
+				if (!object.exists() || object.isDataFrame() || object.dimensions().length == 1) {
+					gui.setValue ("notice.text", "");
 				} else {
-					gui.setValue ("notice.text", "");
+					// Not very elegant, but does the trick
+					gui.setValue ("notice.text", "Sorting this type of object is not supported in this plugin");
 				}
 			}
 			]]></script>

Modified: trunk/rkward/rkward/plugins/data/sort2.xml
===================================================================
--- trunk/rkward/rkward/plugins/data/sort2.xml	2010-09-22 10:38:45 UTC (rev 3060)
+++ trunk/rkward/rkward/plugins/data/sort2.xml	2010-09-22 12:26:24 UTC (rev 3061)
@@ -21,11 +21,11 @@
 				gui.setValue ("sortby_frame.enabled", object.isDataFrame ());
 				gui.setValue ("sortby.required", object.isDataFrame ());
 
-				if (!(object.dimensions().length == 1 || object.isDataFrame())) {
-					// Not very elegant, but...
-					gui.setValue ("notice.text", "This type of object is not supported in this plugin");
+				if (!object.exists() || object.isDataFrame() || object.dimensions().length == 1) {
+					gui.setValue ("notice.text", "");
 				} else {
-					gui.setValue ("notice.text", "");
+					// Not very elegant, but does the trick
+					gui.setValue ("notice.text", "Sorting this type of object is not supported in this plugin");
 				}
 			}
 			]]></script>

Modified: trunk/rkward/rkward/scriptbackends/rkcomponentscripting.cpp
===================================================================
--- trunk/rkward/rkward/scriptbackends/rkcomponentscripting.cpp	2010-09-22 10:38:45 UTC (rev 3060)
+++ trunk/rkward/rkward/scriptbackends/rkcomponentscripting.cpp	2010-09-22 12:26:24 UTC (rev 3061)
@@ -19,6 +19,7 @@
 
 #include <klocale.h>
 #include <kdeversion.h>
+#include <kmessagebox.h>
 
 #include "../plugin/rkcomponent.h"
 #include "../core/robjectlist.h"
@@ -66,8 +67,9 @@
 	QString file = current_file;
 	if (file.isEmpty ()) file = _scriptfile;
 	if (script->hadError ()) {
-#warning TODO: refine error messages (file/context), and display them in a dialog
-qDebug ("line %d: %s", script->errorLineNo (), qPrintable (script->errorMessage ()));
+		QString message = i18n ("There was an error while evaluating script code.\nFile: %1\nLine: %2\nMessage: %3.", file, script->errorLineNo(), script->errorMessage());
+		KMessageBox::detailedError (0, message, script->errorTrace ());
+		emit (haveError());
 	}
 }
 
@@ -99,6 +101,7 @@
 #else
 	script->callFunction ("_rk_eval", QVariantList() << QString (code));
 #endif
+	handleScriptError ();
 }
 
 void RKComponentScriptingProxy::addScriptableWidget (const QString& name, QWidget *widget) {

Modified: trunk/rkward/rkward/scriptbackends/rkcomponentscripting.h
===================================================================
--- trunk/rkward/rkward/scriptbackends/rkcomponentscripting.h	2010-09-22 10:38:45 UTC (rev 3060)
+++ trunk/rkward/rkward/scriptbackends/rkcomponentscripting.h	2010-09-22 12:26:24 UTC (rev 3061)
@@ -55,6 +55,8 @@
 	QVariantList getObjectInfo (const QString &name);
 	QString getObjectParent (const QString &name);
 	QString getObjectChild (const QString &name);
+signals:
+	void haveError ();
 private:
 	RKComponent* component;
 	Kross::Action* script;


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