[rkward-cvs] SF.net SVN: rkward:[3890] trunk/rkward/packages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Wed Oct 5 17:23:57 UTC 2011
Revision: 3890
http://rkward.svn.sourceforge.net/rkward/?rev=3890&view=rev
Author: m-eik
Date: 2011-10-05 17:23:56 +0000 (Wed, 05 Oct 2011)
Log Message:
-----------
rkwarddev: id() and echo() now also substitute rk.JS.arr objects
Modified Paths:
--------------
trunk/rkward/packages/rkwarddev/ChangeLog
trunk/rkward/packages/rkwarddev/R/echo.R
trunk/rkward/packages/rkwarddev/R/id.R
trunk/rkward/packages/rkwarddev/R/ite.R
trunk/rkward/packages/rkwarddev/R/rk-internal.R
trunk/rkward/packages/rkwarddev/R/rk.JS.array.R
trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R
trunk/rkward/packages/rkwarddev/R/rk.JS.options.R
trunk/rkward/packages/rkwarddev/man/echo.Rd
trunk/rkward/packages/rkwarddev/man/id.Rd
trunk/rkward/packages/rkwarddev/man/ite.Rd
trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd
trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd
Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/ChangeLog 2011-10-05 17:23:56 UTC (rev 3890)
@@ -4,6 +4,7 @@
- added support for properties to rk.JS.vars()
- added function rk.JS.options() to generate code for JS variables holding multiple options
- added class rk.JS.opt and a show method for it (use rk.paste.JS() on that)
+ - id() and echo() now also replace objects of classes rk.JS.opt and rk.JS.arr with their relevant ID
- linked "Introduction to Writing Plugins for RKWard" locally to the manual pages
## 0.02-4 (2011-10-03)
Modified: trunk/rkward/packages/rkwarddev/R/echo.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/echo.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/echo.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -1,11 +1,11 @@
#' Generate JavaScript echo command call
#'
#' This function will take several elements, either character strings, or objects of class \code{XiMpLe.node}
-#' which hold an XML node of some plugin GUI definition, or objects of class \code{rk.JS.opt},
-#' and generate a ready-to-run JavaScript \code{echo();} call from it.
+#' which hold an XML node of some plugin GUI definition, or objects of classes \code{rk.JS.arr} or \code{rk.JS.opt}.
+#' From those, it will generate a ready-to-run JavaScript \code{echo();} call from it.
#'
#' @param ... One or several character strings and/or \code{XiMpLe.node} objects with plugin nodes,
-#' and/or objects of class \code{rk.JS.opt}, simply separated by comma.
+#' and/or objects of classes \code{rk.JS.arr} or \code{rk.JS.opt}, simply separated by comma.
#' @param newline Character string, can be set to e.g. \code{"\n"} to force a newline after the call.
#' @return A character string.
#' @seealso \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
Modified: trunk/rkward/packages/rkwarddev/R/id.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/id.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/id.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -2,11 +2,11 @@
#'
#' This function is intended to be used for generating JavaScript code for
#' RKWard plugins. Its sole purpose is to replace objects of class \code{XiMpLe.node}
-#' which hold an XML node of some plugin GUI definition, and objects of class \code{rk.JS.opt}
-#' with their \code{id/options} value, and combine these replacements with character strings.
+#' which hold an XML node of some plugin GUI definition, and objects of classes \code{rk.JS.arr} or \code{rk.JS.opt}
+#' with their ID, and combine these replacements with character strings.
#'
#' @param ... One or several character strings and/or \code{XiMpLe.node} objects with plugin nodes,
-#' and/or objects of class \code{rk.JS.opt}, simply separated by comma.
+#' and/or objects of classes \code{rk.JS.arr} or \code{rk.JS.opt}, simply separated by comma.
#' @param quote Logical, it the character strings sould be deparsed, so they come out "as-is" when
#' written to files, e.g. by \code{cat}.
#' @param collapse Character string, defining if and how the individual elements should be glued together.
@@ -28,10 +28,10 @@
if(inherits(this.part, "XiMpLe.node")){
node.id <- this.part at attributes$id
return(node.id)
- } else if(inherits(this.part, "rk.JS.opt")){
- node.id <- this.part at option
+ } else if(inherits(this.part, "rk.JS.arr") | inherits(this.part, "rk.JS.opt")){
+ node.id <- this.part at opt.name
return(node.id)
- } else {
+ }else {
if(isTRUE(quote)){
text.part <- deparse(this.part)
} else {
Modified: trunk/rkward/packages/rkwarddev/R/ite.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/ite.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/ite.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -16,7 +16,7 @@
#' # first create an example checkbox XML node
#' cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
#' # now some JavaScript generation
-#' ite(id(cbox1), echo("bar <- \"", cbox1, "\""), echo("bar <- NULL"))
+#' ite(cbox1, echo("bar <- \"", cbox1, "\""), echo("bar <- NULL"))
ite <- function(ifjs, thenjs, elsejs=NULL){
#check for recursion
@@ -30,7 +30,7 @@
} else {}
}
result <- new("rk.JS.ite",
- ifJS=ifjs,
+ ifJS=id(ifjs),
thenJS=thenjs,
elseJS=elsejs,
elifJS=elifJS
Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -410,12 +410,14 @@
main.indent <- indent(level, by=indent.by)
scnd.indent <- indent(level+1, by=indent.by)
- option <- object at option
+ option <- object at opt.name
ifs <- object at ifs
# a function to add the object stuff to ite objects
add.opts <- function(this.ite){
- this.ite at thenJS <- paste(option, " += \", ", this.ite at thenJS,"\";", sep="")
+ # remove quotes, we'll add them ourselves where needed
+ to.add <- gsub("(.*)(\")$", "\\1", gsub("(^\")(.*)", "\\2", this.ite at thenJS, perl=TRUE), perl=TRUE)
+ this.ite at thenJS <- paste(option, " += \"", to.add,"\";", sep="")
if(length(this.ite at elifJS) == 1){
this.ite at elifJS <- list(add.opts(this.ite at elifJS[[1]]))
} else {}
Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.array.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.array.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.array.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -14,6 +14,7 @@
#' @return An object of class \code{rk.JS.arr}.
#' @export
#' @seealso \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}},
+#' \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
#' \code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
#' \code{\link[rkwarddev:echo]{echo}},
#' \code{\link[rkwarddev:id]{id}},
Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.opt-class.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -5,11 +5,11 @@
setClass("rk.JS.opt",
representation=representation(
- option="character",
+ opt.name="character",
ifs="list"
),
prototype(
- option=character(),
+ opt.name=character(),
ifs=list()
)
)
Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.options.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.options.R 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.options.R 2011-10-05 17:23:56 UTC (rev 3890)
@@ -1,18 +1,29 @@
#' Combine several options in one JavaScript variable
#'
-#' @param opt.name Character string, name of the JavaScript variable to use in the script code.
+#' @param var Character string, name of the JavaScript variable to use in the script code.
#' @param ... A list of objects of class \code{rk.JS.ite} (see \code{\link[rkwarddev:ite]{ite}}).
-#' Use the \code{thenjs} element only to define the value to add to the option, without commas
-#' or similar (e.g., \code{"paired=TRUE"} or \code{id("conf.level=", conflevel)}.
+#' Use the \code{thenjs} element only to define the value to add to the option
+#' (e.g., \code{", paired=TRUE"} or \code{id(", conf.level=\"", conflevel, "\"", quote=TRUE, collapse= " + ")}.
#' @return An object of class \code{rk.JS.opt}, use \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}
#' on that.
-#' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+#' @seealso
+#' \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
+#' and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
#' @export
+#' @examples
+#' # create two checkboxes for independent options
+#' checkA <- rk.XML.cbox(label="Run Test A", value="A")
+#' checkB <- rk.XML.cbox(label="Run it fast", value="true")
+#' # combine them into one JavaScript options variable
+#' rk.JS.options("optionsTestA",
+#' ite(checkA, id("test=\"", checkA, "\"", quote=TRUE, collapse= " + ")),
+#' ite(checkB, "fast=TRUE")
+#' )
-rk.JS.options <- function(opt.name, ...){
+rk.JS.options <- function(var, ...){
all.opts <- list(...)
result <- new("rk.JS.opt",
- option=opt.name,
+ opt.name=var,
ifs=all.opts)
return(result)
Modified: trunk/rkward/packages/rkwarddev/man/echo.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/echo.Rd 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/man/echo.Rd 2011-10-05 17:23:56 UTC (rev 3890)
@@ -7,8 +7,8 @@
\arguments{
\item{...}{One or several character strings and/or
\code{XiMpLe.node} objects with plugin nodes, and/or
- objects of class \code{rk.JS.opt}, simply separated by
- comma.}
+ objects of classes \code{rk.JS.arr} or \code{rk.JS.opt},
+ simply separated by comma.}
\item{newline}{Character string, can be set to e.g.
\code{"\n"} to force a newline after the call.}
@@ -20,8 +20,9 @@
This function will take several elements, either
character strings, or objects of class \code{XiMpLe.node}
which hold an XML node of some plugin GUI definition, or
- objects of class \code{rk.JS.opt}, and generate a
- ready-to-run JavaScript \code{echo();} call from it.
+ objects of classes \code{rk.JS.arr} or \code{rk.JS.opt}.
+ From those, it will generate a ready-to-run JavaScript
+ \code{echo();} call from it.
}
\examples{
cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
Modified: trunk/rkward/packages/rkwarddev/man/id.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/id.Rd 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/man/id.Rd 2011-10-05 17:23:56 UTC (rev 3890)
@@ -7,8 +7,8 @@
\arguments{
\item{...}{One or several character strings and/or
\code{XiMpLe.node} objects with plugin nodes, and/or
- objects of class \code{rk.JS.opt}, simply separated by
- comma.}
+ objects of classes \code{rk.JS.arr} or \code{rk.JS.opt},
+ simply separated by comma.}
\item{quote}{Logical, it the character strings sould be
deparsed, so they come out "as-is" when written to files,
@@ -25,8 +25,8 @@
JavaScript code for RKWard plugins. Its sole purpose is
to replace objects of class \code{XiMpLe.node} which hold
an XML node of some plugin GUI definition, and objects of
- class \code{rk.JS.opt} with their \code{id/options}
- value, and combine these replacements with character
+ classes \code{rk.JS.arr} or \code{rk.JS.opt} with their
+ ID, and combine these replacements with character
strings.
}
\examples{
Modified: trunk/rkward/packages/rkwarddev/man/ite.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/ite.Rd 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/man/ite.Rd 2011-10-05 17:23:56 UTC (rev 3890)
@@ -24,7 +24,7 @@
# first create an example checkbox XML node
cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="CheckboxFoo.ID")
# now some JavaScript generation
-ite(id(cbox1), echo("bar <- \\"", cbox1, "\\""), echo("bar <- NULL"))
+ite(cbox1, echo("bar <- \\"", cbox1, "\\""), echo("bar <- NULL"))
}
\seealso{
\code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}},
Modified: trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/man/rk.JS.array.Rd 2011-10-05 17:23:56 UTC (rev 3890)
@@ -42,6 +42,7 @@
}
\seealso{
\code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}},
+ \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},
\code{\link[rkwarddev:rk.JS.vars]{rk.JS.vars}},
\code{\link[rkwarddev:echo]{echo}},
\code{\link[rkwarddev:id]{id}}, and the
Modified: trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd 2011-10-05 17:05:07 UTC (rev 3889)
+++ trunk/rkward/packages/rkwarddev/man/rk.JS.options.Rd 2011-10-05 17:23:56 UTC (rev 3890)
@@ -2,18 +2,18 @@
\alias{rk.JS.options}
\title{Combine several options in one JavaScript variable}
\usage{
- rk.JS.options(opt.name, ...)
+ rk.JS.options(var, ...)
}
\arguments{
- \item{opt.name}{Character string, name of the JavaScript
+ \item{var}{Character string, name of the JavaScript
variable to use in the script code.}
\item{...}{A list of objects of class \code{rk.JS.ite}
(see \code{\link[rkwarddev:ite]{ite}}). Use the
\code{thenjs} element only to define the value to add to
- the option, without commas or similar (e.g.,
- \code{"paired=TRUE"} or \code{id("conf.level=",
- conflevel)}.}
+ the option (e.g., \code{", paired=TRUE"} or \code{id(",
+ conf.level=\"", conflevel, "\"", quote=TRUE, collapse= "
+ + ")}.}
}
\value{
An object of class \code{rk.JS.opt}, use
@@ -22,7 +22,18 @@
\description{
Combine several options in one JavaScript variable
}
+\examples{
+# create two checkboxes for independent options
+checkA <- rk.XML.cbox(label="Run Test A", value="A")
+checkB <- rk.XML.cbox(label="Run it fast", value="true")
+# combine them into one JavaScript options variable
+rk.JS.options("optionsTestA",
+ite(checkA, id("test=\\"", checkA, "\\"", quote=TRUE, collapse= " + ")),
+ite(checkB, "fast=TRUE")
+)
+}
\seealso{
+ \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}}, and the
\href{help:rkwardplugins}{Introduction to Writing Plugins
for RKWard}
}
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