[rkward-cvs] SF.net SVN: rkward-code:[4883] trunk/rkward/packages/rkwarddev/R

m-eik at users.sf.net m-eik at users.sf.net
Tue Oct 7 15:03:03 UTC 2014


Revision: 4883
          http://sourceforge.net/p/rkward/code/4883
Author:   m-eik
Date:     2014-10-07 15:03:02 +0000 (Tue, 07 Oct 2014)
Log Message:
-----------
rkwarddev: getting there... slowly. the last part missing seems to be finding the correct component name. if that works, you can already write your .rkh file while designing the dialog.

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/R/rk.XML.cbox.R
    trunk/rkward/packages/rkwarddev/R/rk.get.rkh.prompter.R
    trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R
    trunk/rkward/packages/rkwarddev/R/rk.rkh.scan.R
    trunk/rkward/packages/rkwarddev/R/rk.set.rkh.prompter.R

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.cbox.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.cbox.R	2014-10-06 21:27:24 UTC (rev 4882)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.cbox.R	2014-10-07 15:03:02 UTC (rev 4883)
@@ -24,6 +24,11 @@
 #' @param chk Logical, whether this element should be checked by default.
 #' @param id.name Character string, a unique ID for this plugin element.
 #'    If \code{"auto"}, an ID will be generated automatically from the label.
+#' @param help Character string, will be used as the \code{text} value for a setting node in the .rkh file.
+#'    Also needs \code{component} to be set accordingly!
+#' @param component Character string, name of the component this node belongs to. Only needed if you
+#'    want to use the scan features for automatic help file generation; needs \code{help} to be set
+#'    accordingly, too!
 #' @return An object of class \code{XiMpLe.node}.
 #' @note There's also a simple wrapper function \code{rk.XML.checkbox}.
 #' @export
@@ -36,7 +41,7 @@
 #'     rk.XML.cbox(label="bar", value="bar2"))))
 #' cat(pasteXML(test.checkboxes))
 
-rk.XML.cbox <- function(label, value="true", un.value=NULL, chk=FALSE, id.name="auto"){
+rk.XML.cbox <- function(label, value="true", un.value=NULL, chk=FALSE, id.name="auto", help=NULL, component=NULL){
   if(identical(id.name, "auto")){
     id <- auto.ids(label, prefix=ID.prefix("checkbox"))
   } else {
@@ -53,11 +58,16 @@
 
   checkbox <- XMLNode("checkbox", attrs=attr.list)
 
+  # check for .rkh content
+  if(!is.null(help) && !is.null(component)){
+    rk.set.rkh.prompter(component=component, id=id, help=help)
+  } else {}
+  
   return(checkbox)
 }
 
 ## wrapper for name scheme consistency
 #' @export
-rk.XML.checkbox <- function(label, value="true", un.value=NULL, chk=FALSE, id.name="auto"){
-  rk.XML.cbox(label=label, value=value, un.value=un.value, chk=chk, id.name=id.name)
+rk.XML.checkbox <- function(label, value="true", un.value=NULL, chk=FALSE, id.name="auto", help=NULL, component=NULL){
+  rk.XML.cbox(label=label, value=value, un.value=un.value, chk=chk, id.name=id.name, help=help, component=component)
 }

Modified: trunk/rkward/packages/rkwarddev/R/rk.get.rkh.prompter.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.get.rkh.prompter.R	2014-10-06 21:27:24 UTC (rev 4882)
+++ trunk/rkward/packages/rkwarddev/R/rk.get.rkh.prompter.R	2014-10-07 15:03:02 UTC (rev 4883)
@@ -17,21 +17,21 @@
 
 #' Get .rkh related information stored internally
 #' 
-#' @param plugin Character string, the name under which you stored information. If \code{NULL},
+#' @param component Character string, the name under which you stored information. If \code{NULL},
 #'    returns all information stored in the internal \code{rkh.prompter} list.
-#' @param id Character string, the node ID if a given plugin to search for.  If \code{NULL}, returns
-#'    the full list of the given plugin, otherwise only the help information for the requested node.
+#' @param id Character string, the node ID if a given component to search for.  If \code{NULL}, returns
+#'    the full list of the given component, otherwise only the help information for the requested node.
 #' @export
 #' @examples
 #' rk.get.rkh.prompter("rk.myPlugin", "someID")
 
-rk.get.rkh.prompter <- function(plugin=NULL, id=NULL){
+rk.get.rkh.prompter <- function(component=NULL, id=NULL){
   rkh.prompter <- get.rkh.prompter()
 
-  if(is.null(plugin)){
+  if(is.null(component)){
     return(rkh.prompter)
   } else {
-    rkh.prompter <- rkh.prompter[[plugin]]
+    rkh.prompter <- rkh.prompter[[component]]
     if(is.null(id)){
       return(rkh.prompter)
     } else {

Modified: trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R	2014-10-06 21:27:24 UTC (rev 4882)
+++ trunk/rkward/packages/rkwarddev/R/rk.plugin.component.R	2014-10-07 15:03:02 UTC (rev 4883)
@@ -208,7 +208,7 @@
     # if settings were defined manually, this overwrites the scan
     if(!"settings" %in% got.rkh.options){
       if("settings" %in% scan){
-        rkh[["settings"]] <- rk.rkh.settings(rk.rkh.scan(XML.plugin))
+        rkh[["settings"]] <- rk.rkh.settings(rk.rkh.scan(XML.plugin, component=name.orig))
       } else {
         rkh[["settings"]] <- eval(formals(rk.rkh.doc)[["settings"]])
       }

Modified: trunk/rkward/packages/rkwarddev/R/rk.rkh.scan.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.rkh.scan.R	2014-10-06 21:27:24 UTC (rev 4882)
+++ trunk/rkward/packages/rkwarddev/R/rk.rkh.scan.R	2014-10-07 15:03:02 UTC (rev 4883)
@@ -22,11 +22,13 @@
 #' @param help Logical, if \code{TRUE} a list of XiMpLe.node objects will be returned, otherwise a character
 #'    vector with only the relevant ID names.
 #' @param captions Logical, if \code{TRUE} captions will be generated for all "page", "tab" and "frame" nodes.
+#' @param component Character string, name of the scanned component. Only needed if you want to search for
+#'    help text provided by \code{\link[rkwarddev:rk.set.rkh.prompter]{rk.set.rkh.prompter}}.
 #' @return A character vector or a list of XiMpLe.node objects.
 #' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @export
 
-rk.rkh.scan <- function(pXML, help=TRUE, captions=TRUE){
+rk.rkh.scan <- function(pXML, help=TRUE, captions=TRUE, component=NULL){
 
   settings.tags <- c("radio", "varslot", "browser", "dropdown",
     "checkbox", "saveobject", "input", "spinbox", "optioncolumn", "matrix")
@@ -47,7 +49,16 @@
           if(help.id[this.id,"tag"] %in% caption.tags){
             return(rk.rkh.caption(id=help.id[this.id,"id"]))
           } else {
-            return(rk.rkh.setting(id=help.id[this.id,"id"]))
+            if(!is.null(component)){
+              rkh.text <- rk.get.rkh.prompter(component=component, id=this.id)
+              # check if the component is to be omitted
+              if(is.logical(rkh.text[["help"]]) & !isTRUE(rkh.text[["help"]])){
+                return(NULL)
+              } else {}
+            } else {
+              rkh.text <- NULL
+            }
+            return(rk.rkh.setting(id=help.id[this.id,"id"], text=rkh.text))
           }
         }))
     } else {

Modified: trunk/rkward/packages/rkwarddev/R/rk.set.rkh.prompter.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.set.rkh.prompter.R	2014-10-06 21:27:24 UTC (rev 4882)
+++ trunk/rkward/packages/rkwarddev/R/rk.set.rkh.prompter.R	2014-10-07 15:03:02 UTC (rev 4883)
@@ -20,23 +20,24 @@
 #' By using an environment like this, you are able to write information for RKWard help files
 #' directly into your script code of certrain functions, like for radio buttons or checkboxes.
 #' 
-#' The information is temporarily stored in an internal environment, using the plugin name
+#' The information is temporarily stored in an internal environment, using the plugin/component name
 #' you specify. Each entry is named after the ID of its respective node. If you later call
 #' \code{\link[rkwarddev:rk.plugin.component]{rk.plugin.component}} (or it is called by other
 #' functions) and you activate the \code{scan} option for rkh files, the scanning process
 #' will try to find a match for each relevant XML node. That is, the info which is stored in the
 #' environment will magically be written into the help file.
 #' 
-#' @param plugin Character string, should be a unique name to identify the current plugin.
+#' @param component Character string, should be a unique name to identify the current plugin/component.
 #' @param id Either a character string (the \code{id} of the node to store the help information for),
 #'    or an object of class \code{XiMpLe.node} (whose \code{id} will be extracted and used).
-#' @param rm Logical, If \code{TRUE} will remove all information stored by the name of \code{plugin} (if
+#' @param help Character string, will be used as the \code{text} value for a setting node in the .rkh file.
+#' @param rm Logical, If \code{TRUE} will remove all information stored by the name of \code{component} (if
 #'    \code{id=NULL}) or of the given \code{id=NULL}, respectively.
 #' @export
 #' @examples
 #' rk.set.rkh.prompter("rk.myPlugin", "someID", "CLick this to feel funny.")
 
-rk.set.rkh.prompter <- function(plugin, id, help=NULL, rm=FALSE){
+rk.set.rkh.prompter <- function(component, id, help=NULL, rm=FALSE){
   rkh.prompter <- get.rkh.prompter()
 
   if(!is.null(id)){
@@ -45,20 +46,20 @@
   } else {}
   if(isTRUE(rm)){
     if(is.null(id)){
-      rkh.prompter[[plugin]] <- NULL
-      message(paste0("removed ", plugin, " from rkh.prompter!"))
+      rkh.prompter[[component]] <- NULL
+      message(paste0("removed ", component, " from rkh.prompter!"))
     } else {
-      rkh.prompter[[plugin]][[id]] <- NULL
-      message(paste0("removed ", plugin, "[[\"", id, "\"]] from rkh.prompter!"))
+      rkh.prompter[[component]][[id]] <- NULL
+      message(paste0("removed ", component, "[[\"", id, "\"]] from rkh.prompter!"))
     }
   } else {
-    if(is.null(rkh.prompter[[plugin]])){
-      rkh.prompter[[plugin]] <- list()
+    if(is.null(rkh.prompter[[component]])){
+      rkh.prompter[[component]] <- list()
     } else {}
-    if(is.null(rkh.prompter[[plugin]][[id]])){
-      rkh.prompter[[plugin]][[id]] <- list()
+    if(is.null(rkh.prompter[[component]][[id]])){
+      rkh.prompter[[component]][[id]] <- list()
     } else {}
-   rkh.prompter[[plugin]][[id]][["help"]] <- help
+   rkh.prompter[[component]][[id]][["help"]] <- help
   }
 
   assign("rkh.prompter", rkh.prompter, envir=.rkdev.env)





More information about the rkward-tracker mailing list