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

m-eik at users.sf.net m-eik at users.sf.net
Sat Oct 11 20:38:04 UTC 2014


Revision: 4893
          http://sourceforge.net/p/rkward/code/4893
Author:   m-eik
Date:     2014-10-11 20:38:02 +0000 (Sat, 11 Oct 2014)
Log Message:
-----------
rkwarddev: r.XML.options() should now work for rk.XML.radio(), even mixed with named vectors

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/DESCRIPTION
    trunk/rkward/packages/rkwarddev/NAMESPACE
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.radio.R
    trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
    trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
    trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd

Added Paths:
-----------
    trunk/rkward/packages/rkwarddev/man/rk.XML.option.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2014-10-11 20:38:02 UTC (rev 4893)
@@ -1,6 +1,6 @@
 ChangeLog for package rkwarddev
 
-changes in version 0.06-5 (2014-10-07)
+changes in version 0.06-5 (2014-10-11)
 fixed:
   - the "show" feature in rk.plugin.skeleton() was broken due to changes in the namespace defaults
   - scanning plugin XML code for JS and help related content didn't work as expected in rk.plugin.component()
@@ -12,6 +12,7 @@
     text set with rk.set.rkh.prompter() and use it to generate help files
   - all functions scanned by rk.rkh.scan() for setting nodes in .rkh files have gained two additional arguments,
     "help" and "component", to register the text to be used via rk.set.rkh.prompter()
+  - new function rk.XMLoption() to allow setting and accessing IDs for single options as well
 
 changes in version 0.06-4 (2014-09-14)
 added:

Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION	2014-10-11 20:38:02 UTC (rev 4893)
@@ -15,7 +15,7 @@
 Authors at R: c(person(given="Meik", family="Michalke",
     email="meik.michalke at hhu.de", role=c("aut", "cre")))
 Version: 0.06-5
-Date: 2014-10-07
+Date: 2014-10-11
 Collate:
     'echo.R'
     'i18n.R'
@@ -64,6 +64,7 @@
     'rk.XML.logic.R'
     'rk.XML.matrix.R'
     'rk.XML.menu.R'
+    'rk.XML.option.R'
     'rk.XML.optioncolumn.R'
     'rk.XML.optiondisplay.R'
     'rk.XML.optionset.R'

Modified: trunk/rkward/packages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/packages/rkwarddev/NAMESPACE	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/NAMESPACE	2014-10-11 20:38:02 UTC (rev 4893)
@@ -42,6 +42,7 @@
 export(rk.XML.logic)
 export(rk.XML.matrix)
 export(rk.XML.menu)
+export(rk.XML.option)
 export(rk.XML.optioncolumn)
 export(rk.XML.optiondisplay)
 export(rk.XML.optionset)

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2014-10-11 20:38:02 UTC (rev 4893)
@@ -741,6 +741,7 @@
     "dropdown", "embed", "formula", "frame", "include", "input", "insert", "matrix",
     "optionset", "preview", "radio", "row", "saveobject", "spinbox", "stretch", "tabbook",
     "text", "varselector", "varslot", "!--"),
+  dropdown=c("option"),
   hierarchy=c("menu", "!--"),
   logic=c("connect", "convert", "dependency_check", "external", "include", "insert",
     "script", "set", "switch"),
@@ -750,6 +751,7 @@
     "dropdown", "formula", "frame", "input", "matrix", "optionset", "page", "radio",
     "row", "saveobject", "spinbox", "stretch", "tabbook", "text", "varselector",
     "varslot", "!--"),
+  radio=c("option"),
   settings=c("setting", "caption", "!--"),
   wizard=c("browser", "checkbox", "column", "copy",
     "dropdown", "embed", "formula", "frame", "include", "input", "insert", "matrix",
@@ -1173,4 +1175,43 @@
     rkh.prompter <- list()
   }
   return(rkh.prompter)
+} ## end function get.rkh.prompter()
+
+
+## function rk.check.options()
+# options is a list, containig either named vectors in teh form of
+#   label=c(val=NULL, chk=FALSE)
+# or an "option" node of class XiMpLe.node
+rk.check.options <- function(options, parent){
+  num.opt <- length(options)
+  all.options <- sapply(1:num.opt, function(this.num){
+      if(is.XiMpLe.node(options[[this.num]])){
+        # check the node names and allow only valid ones
+        valid.child(parent, children=options[[this.num]])
+        return(options[[this.num]])
+      } else {
+        if("chk" %in% names(options[[this.num]])){
+          checked <- isTRUE(as.logical(options[[this.num]][["chk"]]))
+        } else {
+          checked <- FALSE
+        }
+        return(
+          rk.XML.option(
+            label=names(options)[[this.num]],
+            val=options[[this.num]][["val"]],
+            chk=checked,
+            id.name=NULL
+          )
+        )
+      }
+    })
+  # see to it that only one options is "checked"
+  is.checked <- sapply(all.options, function(this.opt){
+      return(!is.null(XMLScanDeep(this.opt, find="checked")))
+    })
+  if(sum(is.checked) > 1){
+    stop(simpleError("you defined options where more than one is 'checked' -- this is wrong!"))
+  } else {}
+  return(all.options)
 }
+## end function rk.check.options()

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.radio.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.radio.R	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.radio.R	2014-10-11 20:38:02 UTC (rev 4893)
@@ -39,18 +39,8 @@
 #' cat(pasteXML(test.radio))
 
 rk.XML.radio <- function(label, options=list(label=c(val=NULL, chk=FALSE)), id.name="auto", help=NULL, component=rk.get.comp()){
-  num.opt <- length(options)
-  rd.options <- sapply(1:num.opt, function(this.num){
-      this.element <- names(options)[[this.num]]
-      this.value <- options[[this.num]][["val"]]
-      attr.list <- list(label=this.element, value=this.value)
-      if("chk" %in% names(options[[this.num]])){
-        if(isTRUE(as.logical(options[[this.num]][["chk"]]))){
-          attr.list[["checked"]] <- "true"
-        } else {}
-      } else {}
-      return(XMLNode("option", attrs=attr.list))
-    })
+  # convert list elements into a list of XiMpLe nodes (if they aren't already)
+  rd.options <- rk.check.options(options, parent="radio")
 
   if(identical(id.name, "auto")){
     id <- auto.ids(label, prefix=ID.prefix("radio"))

Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2014-10-11 20:38:02 UTC (rev 4893)
@@ -4,7 +4,7 @@
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
 #' Version: \tab 0.06-5\cr
-#' Date: \tab 2014-10-07\cr
+#' Date: \tab 2014-10-11\cr
 #' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr

Modified: trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/inst/NEWS.Rd	2014-10-11 20:38:02 UTC (rev 4893)
@@ -1,7 +1,7 @@
 \name{NEWS}
 \title{News for Package 'rkwarddev'}
 \encoding{UTF-8}
-\section{Changes in rkwarddev version 0.06-5 (2014-10-07)}{
+\section{Changes in rkwarddev version 0.06-5 (2014-10-11)}{
   \subsection{fixed}{
     \itemize{
       \item the \code{"show"} feature in \code{rk.plugin.skeleton()} was broken due to changes in the namespace defaults
@@ -17,6 +17,7 @@
         text set with \code{rk.set.rkh.prompter()} and use it to generate help files
       \item all functions scanned by \code{rk.rkh.scan()} for setting nodes in .rkh files have gained two additional arguments,
         \code{"help"} and \code{"component"}, to register the text to be used via \code{rk.set.rkh.prompter()}
+      \item new function \code{rk.XMLoption()} to allow setting and accessing IDs for single options as well
     }
   }
 }

Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)

Added: trunk/rkward/packages/rkwarddev/man/rk.XML.option.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.option.Rd	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.option.Rd	2014-10-11 20:38:02 UTC (rev 4893)
@@ -0,0 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{rk.XML.option}
+\alias{rk.XML.option}
+\title{Create XML node "option" for RKWard plugins}
+\usage{
+rk.XML.option(label, val = NULL, chk = FALSE, id.name = NULL)
+}
+\arguments{
+\item{label}{Character string, a text label for this plugin element.}
+
+\item{val}{Character string, defines the value to submit if the option is checked.}
+
+\item{chk}{Logical,
+      should be set \code{TRUE} in the one option which is checked by default.}
+
+\item{id.name}{Character string, a unique ID for this plugin element.
+If \code{"auto"} and a label was provided,
+      an ID will be generated automatically from the label.}
+}
+\value{
+An object of class \code{XiMpLe.node}.
+}
+\description{
+Create XML node "option" for RKWard plugins
+}
+\examples{
+test.radio <- rk.XML.radio("Chose one",
+  options=list(
+    rk.XML.option("First Option", val="val1"),
+    rk.XML.option("Second Option", val="val2", chk=TRUE))
+cat(pasteXML(test.radio))
+}
+\seealso{
+\href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+}
+

Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2014-10-11 18:49:45 UTC (rev 4892)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2014-10-11 20:38:02 UTC (rev 4893)
@@ -11,7 +11,7 @@
 Package: \tab rkwarddev\cr
 Type: \tab Package\cr
 Version: \tab 0.06-5\cr
-Date: \tab 2014-10-07\cr
+Date: \tab 2014-10-11\cr
 Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-21),rkward (>= 0.5.7)\cr
 Enhances: \tab rkward\cr
 Encoding: \tab UTF-8\cr





More information about the rkward-tracker mailing list