[rkward-cvs] SF.net SVN: rkward:[3828] trunk/rkward/rkward/rbackend/rpackages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sun Sep 25 15:19:52 UTC 2011
Revision: 3828
http://rkward.svn.sourceforge.net/rkward/?rev=3828&view=rev
Author: m-eik
Date: 2011-09-25 15:19:52 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
rkwarddev: logic should now be fully scriptable, too
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-internal.R
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/R/rk.XML.plugin.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.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
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.plugin.Rd
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd
trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/ChangeLog 2011-09-25 15:19:52 UTC (rev 3828)
@@ -1,7 +1,8 @@
ChangeLog for package rkwarddev
## 0.01-5 (2011-09-23)
- - added functions rk.XML.formula(), rk.XML.convert(), rk.XML.connect() and rk.XML.logic()
+ - added functions rk.XML.formula(), rk.XML.convert(), rk.XML.connect(), rk.XML.logic(),
+ rk.XML.set() and rk.XML.external()
- 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()
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/DESCRIPTION 2011-09-25 15:19:52 UTC (rev 3828)
@@ -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-24
+Date: 2011-09-25
Collate:
'rk-internal.R'
'rk.JS.array.R'
@@ -34,6 +34,7 @@
'rk.XML.connect.R'
'rk.XML.convert.R'
'rk.XML.dropdown.R'
+ 'rk.XML.external.R'
'rk.XML.formula.R'
'rk.XML.frame.R'
'rk.XML.input.R'
@@ -43,6 +44,7 @@
'rk.XML.radio.R'
'rk.XML.row.R'
'rk.XML.saveobj.R'
+ 'rk.XML.set.R'
'rk.XML.spinbox.R'
'rk.XML.stretch.R'
'rk.XML.tabbook.R'
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/NAMESPACE 2011-09-25 15:19:52 UTC (rev 3828)
@@ -12,6 +12,7 @@
export(rk.XML.connect)
export(rk.XML.convert)
export(rk.XML.dropdown)
+export(rk.XML.external)
export(rk.XML.formula)
export(rk.XML.frame)
export(rk.XML.input)
@@ -21,6 +22,7 @@
export(rk.XML.radio)
export(rk.XML.row)
export(rk.XML.saveobj)
+export(rk.XML.set)
export(rk.XML.spinbox)
export(rk.XML.stretch)
export(rk.XML.tabbook)
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk-internal.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk-internal.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -139,3 +139,25 @@
filtered.persons <- Filter(role.filter, persons)
return(filtered.persons)
} ## end function get.by.role()
+
+## function check.ID()
+check.ID <- function(node){
+ if(is.list(node)){
+ return(sapply(node, check.ID))
+ } else {}
+
+ if(inherits(node, "XiMpLe.node")){
+ node.ID <- node at attributes[["id"]]
+ } else if(is.character(node)){
+ node.ID <- node
+ } else {
+ stop(simpleError("Can't find an ID!"))
+ }
+
+ if(is.null(node.ID)){
+ warning("ID is NULL!")
+ } else {}
+
+ return(node.ID)
+}
+## end function check.ID()
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.connect.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -1,7 +1,8 @@
#' 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
+#' @param governor Either a character string (the \code{id} of the property whose state should control
+#' the \code{client}), or an object of class \code{XiMpLe.node} (whose \code{id} will be extracted
+#' and used). 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}.
@@ -25,13 +26,23 @@
stop(simpleError("'governor' and 'client' must be of length 1!"))
} else {}
- attr.list <- list(governor=as.character(governor))
+ # let's see if we need to extract IDs first
+ client.id <- check.ID(client)
+ governor.id <- check.ID(governor)
+ # if governor is an XML node but not <convert>, append ".state"
+ if(inherits(governor, "XiMpLe.node")){
+ if(!identical(governor at name, "convert")){
+ governor.id <- paste(governor.id, "state", sep=".")
+ } else {}
+ } else {}
+ attr.list <- list(governor=as.character(governor.id))
+
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=".")
+ attr.list[["client"]] <- paste(client.id, set, sep=".")
}
if(isTRUE(reconcile)){
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.convert.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -1,9 +1,10 @@
#' 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 sources A list with at least one value, either resembling the \code{id} of
+#' an existing element to be queried as a character string, or a previously defined object
+#' of class \code{XiMpLe.node} (whose \code{id} will be extracted and used). If you want
+#' to examine the state or string value specificly, just name the value accoringly, e.g.,
+#' \code{sources=list("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.}
@@ -64,9 +65,9 @@
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=".")
+ new.value <- paste(check.ID(sources[[src.no]]), this.modifier, sep=".")
} else {
- new.value <- sources[src.no]
+ new.value <- check.ID(sources[[src.no]])
}
return(new.value)
}))
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.logic.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -1,6 +1,6 @@
#' Create XML logic section for RKWard plugins
#'
-#' This function will create a logic section with "convert" and "connect" nodes.
+#' This function will create a logic section with "convert", "connect" ,"external" and "set" nodes.
#'
#' @param nodes A list of objects of class \code{XiMpLe.node}.
#' @return A list of objects of class \code{XiMpLe.node}.
@@ -8,7 +8,8 @@
#' @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))
+#' test.external <- rk.XML.external(id="ext_property", default="none")
+#' test.logic <- rk.XML.logic(nodes=list(test.convert, test.connect, test.external))
#' cat(pasteXMLNode(test.logic, shine=1))
rk.XML.logic <- function(nodes){
@@ -17,9 +18,9 @@
this.node at name
})
- invalid.sets <- !node.names %in% c("connect", "convert")
+ invalid.sets <- !node.names %in% c("connect", "convert","external","set")
if(any(invalid.sets)){
- stop(simpleError(paste("Invalid XML nodes for logic section: ", paste(invalid.nodes, collapse=", "), sep="")))
+ stop(simpleError(paste("Invalid XML nodes for logic section: ", paste(invalid.sets, collapse=", "), sep="")))
} else {}
node <- new("XiMpLe.node",
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.plugin.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.plugin.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.plugin.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -6,7 +6,9 @@
#' @param wiz.children An optional list with objects of class \code{XiMpLe.node}. Will be included inside the top level node as the wizard code
#' (but only if \code{provides} includes \code{"wizard"} as well).
#' @param help Logical, if \code{TRUE} an include tag for a help file named \emph{"<name>.rkh"} will be added to the header.
-#' @param logic Character string, will be pasted as-is inside the \code{<logic>} section (but only if \code{provides} includes \code{"logic"} as well).
+#' @param logic An object of class \code{XiMpLe.node} to be pasted as the \code{<logic>} section
+#' (but only if \code{provides} includes \code{"logic"} as well). See
+#' \code{\link[rkwarddev:rk.XML.logic]{rk.XML.logic}} for details.
#' @param provides Character vector with at least one entry of \code{"logic"}, \code{"dialog"} or \code{"wizard"}, defining what the document provides.
#' If \code{"logic"} is specified, a logic section will be added to the document. If \code{logic=NULL}, must be edited manually and is therefore commented out.
#' @param pluginmap Character string, relative path to the pluginmap file, which will then be included in the head of this document.
@@ -64,17 +66,22 @@
name="!--",
value="<connect client=\"!edit!\", governor=\"!edit!\" />")
)
+ all.children[[length(all.children)+1]] <- new("XiMpLe.node",
+ name="logic",
+ children=lgc.children
+ )
} else {
- lgc.children <- list(
- new("XiMpLe.node",
- name="",
- value=logic)
- )
+ # check if this is *really* a logic section, otherwise quit and go dancing
+ if(inherits(logic, "XiMpLe.node")){
+ logic.node.name <- logic at name
+ } else {
+ logic.node.name <- "yougottabekiddingme"
+ }
+ if(!identical(logic.node.name, "logic")){
+ stop(simpleError("I don't know what this is, but 'logic' is not a logic section!"))
+ } else {}
+ all.children[[length(all.children)+1]] <- logic
}
- all.children[[length(all.children)+1]] <- new("XiMpLe.node",
- name="logic",
- children=lgc.children
- )
} else {}
if("dialog" %in% provides){
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.plugin.skeleton.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -16,7 +16,8 @@
#' Defaults to \code{TRUE}.
#' @param lazyLoad Logical, whether the package should be prepared for lazy loading or not. Should be left \code{TRUE},
#' unless you have very good reasons not to.
-#' @param logic A character string with logic XML code, will be pasted as-is inside the \code{<logic>} section.
+#' @param logic An object of class \code{XiMpLe.node} to be pasted as the \code{<logic>} section (see
+#' \code{\link[rkwarddev:rk.XML.logic]{rk.XML.logic}}.
#' @param JS.prep A character string with JavaScript code to be included in the \code{preprocess()} function. This string will be
#' pasted as-is, see \code{\link[rkwarddev:rk.JS.doc]{rk.JS.doc}}.
#' @param JS.calc A character string with JavaScript code to be included in the \code{calculate()} function. This string will be
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rkwarddev-package.R 2011-09-25 15:19:52 UTC (rev 3828)
@@ -4,7 +4,7 @@
#' Package: \tab rkwarddev\cr
#' Type: \tab Package\cr
#' Version: \tab 0.01-5\cr
-#' Date: \tab 2011-09-24\cr
+#' Date: \tab 2011-09-25\cr
#' Depends: \tab R (>= 2.9.0),XiMpLe,rkward\cr
#' Enhances: \tab rkward\cr
#' Encoding: \tab UTF-8\cr
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.connect.Rd 2011-09-25 15:19:52 UTC (rev 3828)
@@ -6,9 +6,11 @@
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
+ \item{governor}{Either a character string (the \code{id}
+ of the property whose state should control the
+ \code{client}), or an object of class \code{XiMpLe.node}
+ (whose \code{id} will be extracted and used). 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.}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.convert.Rd 2011-09-25 15:19:52 UTC (rev 3828)
@@ -6,12 +6,14 @@
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{sources}{A list with at least one value, either
+ resembling the \code{id} of an existing element to be
+ queried as a character string, or a previously defined
+ object of class \code{XiMpLe.node} (whose \code{id} will
+ be extracted and used). If you want to examine the state
+ or string value specificly, just name the value
+ accoringly, e.g., \code{sources=list("vars0",
+ string="input1", state="chkbx2")}.}
\item{mode}{A named vector with either exactly one of the
following elements: \itemize{ \item{\code{equals}}{True
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.logic.Rd 2011-09-25 15:19:52 UTC (rev 3828)
@@ -12,13 +12,14 @@
A list of objects of class \code{XiMpLe.node}.
}
\description{
- This function will create a logic section with "convert"
- and "connect" nodes.
+ This function will create a logic section with "convert",
+ "connect" ,"external" and "set" 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))
+test.external <- rk.XML.external(id="ext_property", default="none")
+test.logic <- rk.XML.logic(nodes=list(test.convert, test.connect, test.external))
cat(pasteXMLNode(test.logic, shine=1))
}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.plugin.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.plugin.Rd 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.plugin.Rd 2011-09-25 15:19:52 UTC (rev 3828)
@@ -25,9 +25,11 @@
help file named \emph{"<name>.rkh"} will be added to the
header.}
- \item{logic}{Character string, will be pasted as-is
- inside the \code{<logic>} section (but only if
- \code{provides} includes \code{"logic"} as well).}
+ \item{logic}{An object of class \code{XiMpLe.node} to be
+ pasted as the \code{<logic>} section (but only if
+ \code{provides} includes \code{"logic"} as well). See
+ \code{\link[rkwarddev:rk.XML.logic]{rk.XML.logic}} for
+ details.}
\item{provides}{Character vector with at least one entry
of \code{"logic"}, \code{"dialog"} or \code{"wizard"},
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.plugin.skeleton.Rd 2011-09-25 15:19:52 UTC (rev 3828)
@@ -46,8 +46,9 @@
prepared for lazy loading or not. Should be left
\code{TRUE}, unless you have very good reasons not to.}
- \item{logic}{A character string with logic XML code, will
- be pasted as-is inside the \code{<logic>} section.}
+ \item{logic}{An object of class \code{XiMpLe.node} to be
+ pasted as the \code{<logic>} section (see
+ \code{\link[rkwarddev:rk.XML.logic]{rk.XML.logic}}.}
\item{JS.prep}{A character string with JavaScript code to
be included in the \code{preprocess()} function. This
Modified: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd 2011-09-25 12:40:12 UTC (rev 3827)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rkwarddev-package.Rd 2011-09-25 15:19:52 UTC (rev 3828)
@@ -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-24\cr Depends: \tab R (>= 2.9.0),XiMpLe,rkward\cr
+ 2011-09-25\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