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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sat Sep 25 09:16:52 UTC 2010


Revision: 3074
          http://rkward.svn.sourceforge.net/rkward/?rev=3074&view=rev
Author:   tfry
Date:     2010-09-25 09:16:52 +0000 (Sat, 25 Sep 2010)

Log Message:
-----------
Make rk.list.plugins() use the effective list of plugins from the front-end. More documentation.

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkcomponentmap.h
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
    trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.call.plugin.Rd

Modified: trunk/rkward/rkward/plugin/rkcomponentmap.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.h	2010-09-25 06:12:49 UTC (rev 3073)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.h	2010-09-25 09:16:52 UTC (rev 3074)
@@ -2,7 +2,7 @@
                           rkcomponentmap.h  -  description
                              -------------------
     begin                : Thu May 12 2005
-    copyright            : (C) 2005, 2006, 2007, 2009 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -179,6 +179,8 @@
 /** invokes the specified component as toplevel
 @param message If a non-null pointer to QString is given, error messages are written into this string *instead* of being displayed */
 	static bool invokeComponent (const QString &component_id, const QStringList &serialized_settings, ComponentInvocationMode submit_mode = ManualSubmit, QString *message=0, RCommandChain *in_chain = 0);
+/** @returns a list of all currently registered component ids */
+	QStringList allComponentIds () { return components.keys(); };
 private:
 /** typedef for easy reference to iterator */
 	typedef QMap<QString, RKComponentHandle*> ComponentMap;

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2010-09-25 06:12:49 UTC (rev 3073)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2010-09-25 09:16:52 UTC (rev 3074)
@@ -419,6 +419,13 @@
 		} else {
 			RK_ASSERT (false);
 		}
+	} else if (call == "listPlugins") {
+		if (request->call.count () == 1) {
+			QStringList list = RKComponentMap::getMap ()->allComponentIds ();
+			issueCommand (".rk.set.reply (c (\"" + list.join ("\", \"") + "\"))\n", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain);
+		} else {
+			RK_ASSERT (false);
+		}
 	} else if (call == "showHTML") {
 		if (request->call.count () == 2) {
 			RKWorkplace::mainWorkplace ()->openHelpWindow (request->call[1]);

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R	2010-09-25 06:12:49 UTC (rev 3073)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R	2010-09-25 09:16:52 UTC (rev 3074)
@@ -373,24 +373,8 @@
 
 # list all available plugins in RKWard; this is a companion function for rk.call.plugin:
 # the output provides possible strings for "plugin" argument in rk.call.plugin
-rk.list.plugins <- function (path, type = "all") {
-	# Need a better way to get path and not have the user provide it
-	# path = /usr/share/kde4/apps/rkward, ~/.kde/share/apps/rkward, ...
-	if (missing (path) || !file.exists (path)) stop ("Wrong path")
-	
-	if (type == "all") type <- "*"
-	
-	pnm <- NULL
-	for (fname in list.files (path, paste (type, "pluginmap", sep = "."))) {
-		con <- file (file.path (path, fname), "r", blocking = FALSE)
-		.L. <- readLines (con)
-		close (con)
-		.L. <- .L.[grepl ("<component ", .L., fixed = TRUE)]
-		.L. <- .L.[grepl ("id=", .L., fixed = TRUE)]
-		if (length (.L.) > 0)
-			pnm <- c(pnm, sapply (strsplit (sapply (strsplit(.L., "id=\"", fixed = TRUE), "[[",2), "\" "), "[[", 1))
-	}
-	pnm
+rk.list.plugins <- function () {
+	.rk.do.call ("listPlugins")
 }
 
 # a wrapper around chooseCRANmirror() without changing options ("repos"), permanently

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.call.plugin.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.call.plugin.Rd	2010-09-25 06:12:49 UTC (rev 3073)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.call.plugin.Rd	2010-09-25 09:16:52 UTC (rev 3074)
@@ -13,23 +13,23 @@
 }
 
 \arguments{
-\item{plugin}{character string, giving the name of the plugin to call. This is of the form "\code{rkward::}\emph{plugin_name}". See Details.}
+\item{plugin}{character string, giving the name of the plugin to call. See Details.}
 \item{\dots}{arguments passed to the \code{plugin}}
-\item{submit.mode}{character string, specifying the submission mode: \code{"manual"} will open the plugin GUI and wait for the user to submit it manually, \code{"submit"} will submit the plugin to the output, or \bold{TODO: _check me_} \code{"auto"} will use the built-in default of the plugin (which in most cases will be same as \code{"submit"}).}
-\item{path}{character string, giving the directory to search for various pluginmap files. This is the directory where the KDE application, "RKWard," is installed (and not the R package, "rkward"). For example, on most Debian based Linux systems this is generally \code{/usr/share/kde4/apps/rkward} or \code{~/.kde/share/apps/rkward}.}
-\item{type}{character string, giving the specific pluginmap file to scan. Currently suported strings are \code{"all"}, \code{"analysis"}, \code{"data"}, \code{"distributions"}, \code{"import_export"}, \code{"irt"}, \code{"plots"}, and \code{"x11device"}. The default value of \code{"all"} scans all pluginmap files.}
+\item{submit.mode}{character string, specifying the submission mode: \code{"manual"} will open the plugin GUI and wait for the user to submit it manually, \code{"auto"} will try to submit the plugin, if it can be submitted with the current settings (i.e. if the "Submit"-button is enabled after applying all specified parameters). If the plugin cannot be submitted, with the current settings, it will behave like \code{"manual"}. \code{"submit"} is like \code{"auot"}, but will  close the plugin, and generate an error, if it cannot be submitted..}
 }
 
 \details{
-\code{rk.call.plugin} provides a high level wrapper to call any plugin available in RKWard. The exact string to be used as \code{plugin} is generally not transparent to the user. Use \code{rk.list.plugins} to list these. A particular character string (\emph{plugin_name}) thus obtained needs to be prefixed by \code{"rkward::"} for a valid \code{plugin} argument. See example.
+\code{rk.call.plugin} provides a high level wrapper to call any plugin available in RKWard. The exact string to be used as \code{plugin}, and the list of arguments available for a particular plugin, are generally not transparent to the user.\code{rk.list.plugins} can be used to obtain a list of current plugins. For plugin arguments, it is recommended to run the plugin, and inspect the "Run again" link that is generated on the output.
 
-\code{rk.list.plugins} scans the given pluginmap file and lists all the available plugins under it. 
+\bold{Warning}: Using \code{rk.call.plugin}, especially with submit.modes \code{"auto"} or \code{"submit"} to program a sequence of analyses has important drawbacks. First, the semantics of plugins are not guaranteed to remain unchanged across different versions of RKWard, thus your code may stop working after an upgrade. Second, your code will not be usable outside of an RKWard session. Consider copying the generated code for each plugin, instead. The primary use-cases for \code{rk.call.plugin} are automated tests, cross-references, and scripted tutorials.
+
+\code{rk.list.plugins} returns the list of the names of all currently registered plugins.
 }
 
 \value{
 \code{rk.call.plugin} returns \code{TRUE} invisibly.
 
-\code{rk.list.plugins} returns a character vector of plugin names. If none found, \code{NULL} is returned. 
+\code{rk.list.plugins} returns a character vector of plugin names. If none found, \code{NULL} is returned.
 }
 
 \author{Thomas Friedrichsmeier \email{rkward-devel at lists.sourceforge.net}}
@@ -39,8 +39,8 @@
 }
 
 \examples{
-## list all analysis related plugins
-rk.list.plugins ("~/.kde/share/apps/rkward", "analysis")
+## list all current plugins
+rk.list.plugins ()
 
 ## "t_test_two_vars" plugin:
 ## see the output: Windows->Show Output


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