[rkward-cvs] SF.net SVN: rkward:[3825] trunk/rkward/rkward/rbackend/rpackages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sat Sep 24 23:50:00 UTC 2011
Revision: 3825
http://rkward.svn.sourceforge.net/rkward/?rev=3825&view=rev
Author: m-eik
Date: 2011-09-24 23:50:00 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
rkwarddev: added initial logic XML functions
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.browser.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd
Added Paths:
-----------
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog 2011-09-24 18:33:43 UTC (rev 3824)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog 2011-09-24 23:50:00 UTC (rev 3825)
@@ -1,9 +1,10 @@
ChangeLog for package rkwarddev
## 0.01-5 (2011-09-23)
- - added function rk.XML.formula()
+ - added functions rk.XML.formula(), rk.XML.convert(), rk.XML.connect() and rk.XML.logic()
- added possibility to add custom XML code to the logic section with rk.XML.plugin()
and rk.plugin.skeleton()
+ - fixed id setting in rk.XML.browser()
## 0.01-4 (2011-09-22)
- fixed wrong doc link and one wrong object name in rk.plugin.skeleton()
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION 2011-09-24 18:33:43 UTC (rev 3824)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION 2011-09-24 23:50:00 UTC (rev 3825)
@@ -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.01-5
-Date: 2011-09-23
+Date: 2011-09-24
Collate:
'rk-internal.R'
'rk.JS.array.R'
@@ -31,10 +31,13 @@
'rk.XML.browser.R'
'rk.XML.cbox.R'
'rk.XML.col.R'
+ 'rk.XML.connect.R'
+ 'rk.XML.convert.R'
'rk.XML.dropdown.R'
'rk.XML.formula.R'
'rk.XML.frame.R'
'rk.XML.input.R'
+ 'rk.XML.logic.R'
'rk.XML.pluginmap.R'
'rk.XML.plugin.R'
'rk.XML.radio.R'
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE 2011-09-24 18:33:43 UTC (rev 3824)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE 2011-09-24 23:50:00 UTC (rev 3825)
@@ -9,10 +9,13 @@
export(rk.XML.browser)
export(rk.XML.cbox)
export(rk.XML.col)
+export(rk.XML.connect)
+export(rk.XML.convert)
export(rk.XML.dropdown)
export(rk.XML.formula)
export(rk.XML.frame)
export(rk.XML.input)
+export(rk.XML.logic)
export(rk.XML.plugin)
export(rk.XML.pluginmap)
export(rk.XML.radio)
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.browser.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.browser.R 2011-09-24 18:33:43 UTC (rev 3824)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.browser.R 2011-09-24 23:50:00 UTC (rev 3825)
@@ -26,7 +26,7 @@
}
if(identical(id.name, "auto")){
- attr.list[["id"]] <- list(id=auto.ids(label, prefix=ID.prefix("browser")))
+ attr.list[["id"]] <- auto.ids(label, prefix=ID.prefix("browser"))
} else if(!is.null(id.name)){
attr.list[["id"]] <- id.name
} else {}
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R 2011-09-24 23:50:00 UTC (rev 3825)
@@ -0,0 +1,47 @@
+#' Create XML node "connect" for RKWard plugins
+#'
+#' @param governor Character string, the \code{id} if the property whose state should control
+#' the \code{client}. Usually a \code{<convert>} node defined earlier (see
+#' \code{\link[rkwarddev:rk.XML.convert]{rk.XML.convert}}), or the ".state" value of some
+#' apropriate node.
+#' @param client Character string, the \code{id} if the element to be controlled by \code{governor}.
+#' @param set Character string, one of the following values:
+#' \itemize{
+#' \item{\code{"enabled"}}{If \code{governor} becomes true, \code{client} is enabled.}
+#' \item{\code{"visible"}}{If \code{governor} becomes true, \code{client} is visible.}
+#' \item{\code{"required"}}{If \code{governor} becomes true, \code{client} is required.}
+#' }
+#' @param reconcile Logical, forces the \code{governor} to only accept values which are valid for
+#' the \code{client} as well.
+#' @return A list of objects of class \code{XiMpLe.node}.
+#' @export
+#' @examples
+#' test.connect <- rk.XML.connect(governor="lgc_foobar", client="frame_bar")
+#' cat(pasteXMLNode(test.connect, shine=1))
+
+rk.XML.connect <- function(governor, client, set="enabled", reconcile=FALSE){
+
+ if(length(governor) > 1 | length(client) > 1){
+ stop(simpleError("'governor' and 'client' must be of length 1!"))
+ } else {}
+
+ attr.list <- list(governor=as.character(governor))
+
+ invalid.sets <- !set %in% c("enabled", "visible", "required")
+ if(length(set) > 1 | any(invalid.sets)){
+ stop(simpleError(paste("Invalid value for 'set': ", set, sep="")))
+ } else {
+ attr.list[["client"]] <- paste(client, set, sep=".")
+ }
+
+ if(isTRUE(reconcile)){
+ attr.list[["reconcile"]] <- "true"
+ } else {}
+
+ node <- new("XiMpLe.node",
+ name="connect",
+ attributes=attr.list
+ )
+
+ return(node)
+}
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R 2011-09-24 23:50:00 UTC (rev 3825)
@@ -0,0 +1,108 @@
+#' Create XML node convert for RKWard plugins
+#'
+#' @param sources A character vector with at least one value, resembling the \code{id} of
+#' an existing element to be queried. If you want to examine the state or string value
+#' specificly, just name the value accoringly, e.g.,
+#' \code{sources=c("vars0", string="input1", state="chkbx2")}.
+#' @param mode A named vector with either exactly one of the following elements:
+#' \itemize{
+#' \item{\code{equals}}{True if \code{sources} equals this value.}
+#' \item{\code{notequals}}{True if \code{sources} differs from this value.}
+#' \item{\code{and}}{True if all \code{sources} are true. The sources must be boolean,
+#' and the actual value here is irrelevant, so \code{mode=c(and="")} is valid.}
+#' \item{\code{or}}{True if any of the \code{sources} is true. The sources must be boolean,
+#' and the actual value here is irrelevant, so \code{mode=c(or="")} is valid.}
+#' }
+#' or at least one of these elemets:
+#' \itemize{
+#' \item{\code{min}}{True if \code{sources} is at least this value. They must be numeric.}
+#' \item{\code{max}}{True if \code{sources} is below this value. They must be numeric.}
+#' }
+#' @param required Logical, sets the state of the \code{required\_true} attribute. If \code{TRUE},
+#' the plugin submit button is only enabled if this property is true.
+#' @param id.name Character string, a unique ID for this plugin element.
+#' If \code{"auto"}, an ID will be generated automatically from the sources and mode value.
+#' @return A list of objects of class \code{XiMpLe.node}.
+#' @export
+#' @examples
+#' test.convert <- rk.XML.convert(c(string="foo"), mode=c(notequals="bar"))
+#' cat(pasteXMLNode(test.convert, shine=1))
+
+rk.XML.convert <- function(sources, mode=c(), required=FALSE, id.name="auto"){
+
+ # check the mode element
+ mode.name <- names(mode)
+ if(length(mode) < 1 | length(mode.name) < 1 | length(mode) > 2 | length(mode.name) > 2){
+ stop(simpleError("'mode' must have one (or two, if its a range) named element!"))
+ } else {}
+ if(!all(mode.name %in% c("equals","notequals","and","or","min","max"))){
+ stop(simpleError(paste("The mode you provided is invalid: ", mode.name, sep="")))
+ } else {}
+ if(length(mode) == 2 & !all(mode.name %in% c("min","max"))){
+ stop(simpleError("If 'mode' has two elements, they can only be \"min\" and \"max\"!"))
+ } else {}
+
+ if(identical(id.name, "auto")){
+ attr.list <- list(id=auto.ids(paste(paste(sources, collapse=""), mode, sep=""), prefix=ID.prefix("logic")))
+ } else if(!is.null(id.name)){
+ attr.list <- list(id=id.name)
+ } else {
+ stop(simpleError("'id.name' must have a value!"))
+ }
+
+ # firstly, check the sources. if some are named, contruct proper values
+ # for RKWard, like string="foo" should actually be "foo.string"
+ src.names <- names(sources)
+ if(!is.null(src.names)){
+ # check these names if they're valid here
+ invalid.names <- !src.names %in% c("", "string", "state")
+ if(any(invalid.names)){
+ warning(paste("Some of the names you provided are invalid and were ignored: ",
+ paste(src.names[invalid.names], collapse=", "), sep=""))
+ src.names[invalid.names] <- ""
+ } else {}
+ sources <- as.character(sapply(1:length(src.names), function(src.no){
+ this.modifier <- src.names[src.no]
+ if(nchar(this.modifier) > 0){
+ new.value <- paste(sources[src.no], this.modifier, sep=".")
+ } else {
+ new.value <- sources[src.no]
+ }
+ return(new.value)
+ }))
+ } else {}
+
+ attr.list[["sources"]] <- paste(sources, collapse=";")
+
+ if(identical(mode.name,"equals")){
+ attr.list[["mode"]] <- mode.name
+ attr.list[["standard"]] <- as.character(mode)
+ } else if(identical(mode.name,"notequals")){
+ attr.list[["mode"]] <- mode.name
+ attr.list[["standard"]] <- as.character(mode)
+ } else if(identical(mode.name,"and")){
+ attr.list[["mode"]] <- mode.name
+ } else if(identical(mode.name,"or")){
+ attr.list[["mode"]] <- mode.name
+ } else {
+ if("min" %in% mode.name){
+ attr.list[["mode"]] <- "range"
+ attr.list[["min"]] <- as.numeric(mode["min"])
+ } else {}
+ if("max" %in% mode.name){
+ attr.list[["mode"]] <- "range"
+ attr.list[["max"]] <- as.numeric(mode["max"])
+ } else {}
+ }
+
+ if(isTRUE(required)){
+ attr.list[["required_true"]] <- "true"
+ } else {}
+
+ node <- new("XiMpLe.node",
+ name="convert",
+ attributes=attr.list
+ )
+
+ return(node)
+}
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R 2011-09-24 23:50:00 UTC (rev 3825)
@@ -0,0 +1,31 @@
+#' Create XML logic section for RKWard plugins
+#'
+#' This function will create a logic section with "convert" and "connect" nodes.
+#'
+#' @param nodes A list of objects of class \code{XiMpLe.node}.
+#' @return A list of objects of class \code{XiMpLe.node}.
+#' @export
+#' @examples
+#' test.convert <- rk.XML.convert(c(string="foo"), mode=c(notequals="bar"), id.name="lgc_foobar")
+#' test.connect <- rk.XML.connect(governor="lgc_foobar", client="frame_bar")
+#' test.logic <- rk.XML.logic(nodes=list(test.convert, test.connect))
+#' cat(pasteXMLNode(test.logic, shine=1))
+
+rk.XML.logic <- function(nodes){
+ # check the node names and allow only valid ones
+ node.names <- sapply(nodes, function(this.node){
+ this.node at name
+ })
+
+ invalid.sets <- !node.names %in% c("connect", "convert")
+ if(any(invalid.sets)){
+ stop(simpleError(paste("Invalid XML nodes for logic section: ", paste(invalid.nodes, collapse=", "), sep="")))
+ } else {}
+
+ node <- new("XiMpLe.node",
+ name="logic",
+ children=child.list(nodes)
+ )
+
+ return(node)
+}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R 2011-09-24 18:33:43 UTC (rev 3824)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R 2011-09-24 23:50:00 UTC (rev 3825)
@@ -4,7 +4,7 @@
#' Package: \tab rkwarddev\cr
#' Type: \tab Package\cr
#' Version: \tab 0.01-5\cr
-#' Date: \tab 2011-09-23\cr
+#' Date: \tab 2011-09-24\cr
#' Depends: \tab R (>= 2.9.0),XiMpLe,rkward\cr
#' Enhances: \tab rkward\cr
#' Encoding: \tab UTF-8\cr
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd 2011-09-24 23:50:00 UTC (rev 3825)
@@ -0,0 +1,40 @@
+\name{rk.XML.connect}
+\alias{rk.XML.connect}
+\title{Create XML node "connect" for RKWard plugins}
+\usage{
+ rk.XML.connect(governor, client, set = "enabled",
+ reconcile = FALSE)
+}
+\arguments{
+ \item{governor}{Character string, the \code{id} if the
+ property whose state should control the \code{client}.
+ Usually a \code{<convert>} node defined earlier (see
+ \code{\link[rkwarddev:rk.XML.convert]{rk.XML.convert}}),
+ or the ".state" value of some apropriate node.}
+
+ \item{client}{Character string, the \code{id} if the
+ element to be controlled by \code{governor}.}
+
+ \item{set}{Character string, one of the following values:
+ \itemize{ \item{\code{"enabled"}}{If \code{governor}
+ becomes true, \code{client} is enabled.}
+ \item{\code{"visible"}}{If \code{governor} becomes true,
+ \code{client} is visible.} \item{\code{"required"}}{If
+ \code{governor} becomes true, \code{client} is required.}
+ }}
+
+ \item{reconcile}{Logical, forces the \code{governor} to
+ only accept values which are valid for the \code{client}
+ as well.}
+}
+\value{
+ A list of objects of class \code{XiMpLe.node}.
+}
+\description{
+ Create XML node "connect" for RKWard plugins
+}
+\examples{
+test.connect <- rk.XML.connect(governor="lgc_foobar", client="frame_bar")
+cat(pasteXMLNode(test.connect, shine=1))
+}
+
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd 2011-09-24 23:50:00 UTC (rev 3825)
@@ -0,0 +1,51 @@
+\name{rk.XML.convert}
+\alias{rk.XML.convert}
+\title{Create XML node convert for RKWard plugins}
+\usage{
+ rk.XML.convert(sources, mode = c(), required = FALSE,
+ id.name = "auto")
+}
+\arguments{
+ \item{sources}{A character vector with at least one
+ value, resembling the \code{id} of an existing element to
+ be queried. If you want to examine the state or string
+ value specificly, just name the value accoringly, e.g.,
+ \code{sources=c("vars0", string="input1",
+ state="chkbx2")}.}
+
+ \item{mode}{A named vector with either exactly one of the
+ following elements: \itemize{ \item{\code{equals}}{True
+ if \code{sources} equals this value.}
+ \item{\code{notequals}}{True if \code{sources} differs
+ from this value.} \item{\code{and}}{True if all
+ \code{sources} are true. The sources must be boolean, and
+ the actual value here is irrelevant, so
+ \code{mode=c(and="")} is valid.} \item{\code{or}}{True if
+ any of the \code{sources} is true. The sources must be
+ boolean, and the actual value here is irrelevant, so
+ \code{mode=c(or="")} is valid.} } or at least one of
+ these elemets: \itemize{ \item{\code{min}}{True if
+ \code{sources} is at least this value. They must be
+ numeric.} \item{\code{max}}{True if \code{sources} is
+ below this value. They must be numeric.} }}
+
+ \item{required}{Logical, sets the state of the
+ \code{required\_true} attribute. If \code{TRUE}, the
+ plugin submit button is only enabled if this property is
+ true.}
+
+ \item{id.name}{Character string, a unique ID for this
+ plugin element. If \code{"auto"}, an ID will be generated
+ automatically from the sources and mode value.}
+}
+\value{
+ A list of objects of class \code{XiMpLe.node}.
+}
+\description{
+ Create XML node convert for RKWard plugins
+}
+\examples{
+test.convert <- rk.XML.convert(c(string="foo"), mode=c(notequals="bar"))
+cat(pasteXMLNode(test.convert, shine=1))
+}
+
Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd 2011-09-24 23:50:00 UTC (rev 3825)
@@ -0,0 +1,24 @@
+\name{rk.XML.logic}
+\alias{rk.XML.logic}
+\title{Create XML logic section for RKWard plugins}
+\usage{
+ rk.XML.logic(nodes)
+}
+\arguments{
+ \item{nodes}{A list of objects of class
+ \code{XiMpLe.node}.}
+}
+\value{
+ A list of objects of class \code{XiMpLe.node}.
+}
+\description{
+ This function will create a logic section with "convert"
+ and "connect" nodes.
+}
+\examples{
+test.convert <- rk.XML.convert(c(string="foo"), mode=c(notequals="bar"), id.name="lgc_foobar")
+test.connect <- rk.XML.connect(governor="lgc_foobar", client="frame_bar")
+test.logic <- rk.XML.logic(nodes=list(test.convert, test.connect))
+cat(pasteXMLNode(test.logic, shine=1))
+}
+
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd 2011-09-24 18:33:43 UTC (rev 3824)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd 2011-09-24 23:50:00 UTC (rev 3825)
@@ -9,7 +9,7 @@
\details{
\tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
Package\cr Version: \tab 0.01-5\cr Date: \tab
- 2011-09-23\cr Depends: \tab R (>= 2.9.0),XiMpLe,rkward\cr
+ 2011-09-24\cr Depends: \tab R (>= 2.9.0),XiMpLe,rkward\cr
Enhances: \tab rkward\cr Encoding: \tab UTF-8\cr License:
\tab GPL (>= 3)\cr LazyLoad: \tab yes\cr URL: \tab
http://rkward.sourceforge.net\cr }
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