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

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Wed Oct 19 21:09:36 UTC 2011


Revision: 3974
          http://rkward.svn.sourceforge.net/rkward/?rev=3974&view=rev
Author:   m-eik
Date:     2011-10-19 21:09:36 +0000 (Wed, 19 Oct 2011)
Log Message:
-----------
rkwarddev: a lot of changes regarding JS generation (defining variables), and further support for modifiers

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/DESCRIPTION
    trunk/rkward/packages/rkwarddev/R/id.R
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.saveobj.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.scan.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.var-class.R
    trunk/rkward/packages/rkwarddev/R/rk.JS.vars.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.convert.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.set.R
    trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
    trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
    trunk/rkward/packages/rkwarddev/inst/CITATION
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
    trunk/rkward/packages/rkwarddev/man/rk.JS.vars.Rd
    trunk/rkward/packages/rkwarddev/man/rk.XML.connect.Rd
    trunk/rkward/packages/rkwarddev/man/rk.XML.convert.Rd
    trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd
    trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd
    trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-19 21:09:36 UTC (rev 3974)
@@ -1,9 +1,12 @@
 ChangeLog for package rkwarddev
 
-## 0.03-8 (2011-10-19)
+## 0.04-0 (2011-10-19)
+  - for accurcy and consistency with the docs, the "properties" option changed to "modifiers" in rk.JS.vars()
+  - added further property modifiers to the internal validation
   - added class rk.JS.var, including show method
   - added support for class rk.JS.var in rk.paste.JS() an id()
   - rk.JS.vars() now returns a list of class rk.JS.var
+  - added support for all valid modifiers to rk.XML.convert() and rk.XML.connect()
 
 ## 0.03-7 (2011-10-18)
   - added "checkable" and "checked" options to rk.XML.frame()

Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION	2011-10-19 21:09:36 UTC (rev 3974)
@@ -14,7 +14,7 @@
 URL: http://rkward.sourceforge.net
 Authors at R: c(person(given="Meik", family="Michalke",
     email="meik.michalke at hhu.de", role=c("aut", "cre")))
-Version: 0.03-8
+Version: 0.04-0
 Date: 2011-10-19
 Collate:
     'echo.R'

Modified: trunk/rkward/packages/rkwarddev/R/id.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/id.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/id.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -43,19 +43,11 @@
 				return(node.id)
 			} else if(inherits(this.part, "rk.JS.var")){
 				# can hold multiple IDs, but we'll only return the first valid one
-				node.id <- this.part at JS.var
-				if(length(node.id) > 0){
-					if(length(this.part at vars) > 0){
-						warning(paste("Object contained more than one ID, only the first one was used: ", node.id, sep=""), call.=FALSE)
-					} else {}
-				} else {
-					if(length(this.part at vars) > 0){
-							node.id <- this.part at vars[[1]]@JS.var
-						if(length(this.part at vars) > 1){
-							warning(paste("Object contained more than one ID, only the first one was used: ", node.id, sep=""), call.=FALSE)
-						} else {}
-					} else {}
-				}
+				node.id <- paste.JS.var(this.part, names.only=TRUE)
+				if(length(node.id) > 1){
+					node.id <- node.id[1]
+					warning(paste("Object contained more than one ID, only the first one was used: ", node.id, sep=""), call.=FALSE)
+				} else {}
 				return(node.id)
 			} else {
 				if(isTRUE(quote)){

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -143,58 +143,60 @@
 #   <tag id="my.id" ...>
 # in XML will become
 #   var my.id = getValue("my.id");
-get.JS.vars <- function(JS.var, XML.var=NULL, JS.prefix="", names.only=FALSE, properties=NULL, default=FALSE, join=""){
+get.JS.vars <- function(JS.var, XML.var=NULL, JS.prefix="", names.only=FALSE, modifiers=NULL, default=FALSE, join=""){
 	# check for XiMpLe nodes
 	JS.var <- check.ID(JS.var)
 	if(!is.null(XML.var)){
-		# check validity of properties value
-		if(!is.null(properties)){
-			if(identical(properties, "all")){
+		# check validity of modifiers value
+		if(!is.null(modifiers)){
+			if(identical(modifiers, "all")){
 				if(inherits(XML.var, "XiMpLe.node")){
 					tag.name <- XML.var at name
 				} else {
 					tag.name <- XML.var
 				}
-				if(tag.name %in% names(all.valid.props)){
-					properties <- all.valid.props[[tag.name]]
+				if(tag.name %in% names(all.valid.modifiers)){
+					modifiers <- all.valid.modifiers[[tag.name]]
 				} else {
-					properties <- NULL
+					modifiers <- NULL
 				}
 			} else {
 				if(inherits(XML.var, "XiMpLe.node")){
-					prop.tag.name <- tag.name
+					modif.tag.name <- XML.var at name
 				} else {
-					prop.tag.name <- "all"
+					modif.tag.name <- "all"
 				}
-				properties <- properties[prop.validity(prop.tag.name, property=child.list(properties), warn.only=TRUE, bool=TRUE)]
+				modifiers <- modifiers[modif.validity(modif.tag.name, modifier=child.list(modifiers), warn.only=TRUE, bool=TRUE)]
 			}
 		} else {}
 		XML.var <- check.ID(XML.var)
-	} else {}
+	} else {
+		XML.var <- check.ID(JS.var)
+	}
 
 	if(is.null(JS.prefix)){
 		JS.prefix <- ""
 	} else {}
-	if(is.null(properties)){
-		properties <- list()
-	} else {}
 
 	if(isTRUE(names.only)){
 		results <- c()
-		if(is.null(properties) | isTRUE(default)){
+		if(is.null(modifiers) | isTRUE(default)){
 			results <- camelCode(c(JS.prefix, JS.var))
 		} else {}
-		if(!is.null(properties)){
+		if(!is.null(modifiers)){
 			results <- c(results,
-				sapply(properties, function(this.prop){camelCode(c(JS.prefix, JS.var, this.prop))})
+				sapply(modifiers, function(this.modif){camelCode(c(JS.prefix, JS.var, this.modif))})
 			)
 		} else {}
 	} else {
+		if(is.null(modifiers)){
+			 modifiers <- list()
+		} else {}
 		results <- new("rk.JS.var",
 			JS.var=JS.var,
 			XML.var=XML.var,
 			prefix=JS.prefix,
-			properties=child.list(properties),
+			modifiers=as.list(modifiers),
 			default=default,
 			join=join)
 	}
@@ -302,9 +304,10 @@
 	return(node.ID)
 } ## end function check.ID()
 
-## list with valid properties
-all.valid.props <- list(
-	all=c("visible", "enabled", "required"),
+## list with valid modifiers
+all.valid.modifiers <- list(
+	all=c("visible", "enabled", "required", "true", "false", "not", "numeric",
+	"preprocess", "calculate", "printout", "preview"),
 	text=c("text"),
 	varselector=c("selected", "root"),
 	varslot=c("available", "selected", "source", "shortname", "label"),
@@ -320,17 +323,17 @@
 	formula=c("model", "table", "labels", "fixed_factors", "dependent"),
 	embed=c("code"),
 	preview=c("state")
-) ## end list with valid properties
+) ## end list with valid modifiers
 
-## function prop.validity()
-# checks if a property is valid for an XML node, if source is XiMpLe.node
-# if bool=FALSE, returns the property or ""
-prop.validity <- function(source, property, ignore.empty=TRUE, warn.only=TRUE, bool=TRUE){
-	if(identical(property, "") & isTRUE(ignore.empty)){
+## function modif.validity()
+# checks if a modifier is valid for an XML node, if source is XiMpLe.node
+# if bool=FALSE, returns the modifier or ""
+modif.validity <- function(source, modifier, ignore.empty=TRUE, warn.only=TRUE, bool=TRUE){
+	if(identical(modifier, "") & isTRUE(ignore.empty)){
 		if(isTRUE(bool)){
 			return(TRUE)
 		} else {
-			return(property)
+			return(modifier)
 		}
 	} else {}
 
@@ -342,40 +345,40 @@
 		if(isTRUE(bool)){
 			return(TRUE)
 		} else {
-			return(property)
+			return(modifier)
 		}
 	}
 
-	if(tag.name %in% names(all.valid.props)){
-		valid.props <- c(all.valid.props[["all"]], all.valid.props[[tag.name]])
+	if(tag.name %in% names(all.valid.modifiers)){
+		valid.modifs <- c(all.valid.modifiers[["all"]], all.valid.modifiers[[tag.name]])
 	} else if(identical(tag.name, "<any tag>")){
-		valid.props <- unique(unlist(all.valid.props))
+		valid.modifs <- unique(unlist(all.valid.modifiers))
 	} else {
-		valid.props <- c(all.valid.props[["all"]])
+		valid.modifs <- c(all.valid.modifiers[["all"]])
 	}
 
-	invalid.prop <- !unlist(property) %in% valid.props
-	if(any(invalid.prop)){
+	invalid.modif <- !unlist(modifier) %in% valid.modifs
+	if(any(invalid.modif)){
 		if(isTRUE(warn.only)){
-			warning(paste("Some property you provided is invalid for '",tag.name,"' and was ignored: ",
-				paste(property[invalid.prop], collapse=", "), sep=""), call.=FALSE)
+			warning(paste("Some modifier you provided is invalid for '",tag.name,"' and was ignored: ",
+				paste(modifier[invalid.modif], collapse=", "), sep=""), call.=FALSE)
 			if(isTRUE(bool)){
-				return(!invalid.prop)
+				return(!invalid.modif)
 			} else {
 				return("")
 			}
 		} else {
-			stop(simpleError(paste("Some property you provided is invalid for '",tag.name,"' and was ignored: ",
-				paste(property[invalid.prop], collapse=", "), sep="")))
+			stop(simpleError(paste("Some modifier you provided is invalid for '",tag.name,"' and was ignored: ",
+				paste(modifier[invalid.modif], collapse=", "), sep="")))
 		}
 	} else {
 		if(isTRUE(bool)){
-			return(!invalid.prop)
+			return(!invalid.modif)
 		} else {
-			return(property)
+			return(modifier)
 		}
 	}
-} ## end function prop.validity()
+} ## end function modif.validity()
 
 ## function check.type()
 check.type <- function(value, type, var.name, warn.only=TRUE){
@@ -563,17 +566,20 @@
 } ## end function paste.JS.options()
 
 ## function paste.JS.var()
-paste.JS.var <- function(object, level=2, indent.by="\t", JS.prefix=NULL, properties=NULL, default=NULL, join=NULL){
+paste.JS.var <- function(object, level=2, indent.by="\t", JS.prefix=NULL, modifiers=NULL, default=NULL, join=NULL, names.only=FALSE){
 	# paste several objects
-	results <- paste(unlist(sapply(object at vars, function(this.obj){
+	results <- unlist(sapply(object at vars, function(this.obj){
 			paste.JS.var(this.obj,
 					level=level,
 					indent.by=indent.by,
 					JS.prefix=JS.prefix,
-					properties=properties,
+					modifiers=modifiers,
 					default=default,
-					join=join)})),
-	collapse="")
+					join=join,
+					names.only=names.only)}))
+	if(!isTRUE(names.only)){
+		results <- paste(results, collapse="")
+	} else {}
 
 	stopifnot(inherits(object, "rk.JS.var"))
 	# check indentation
@@ -584,8 +590,8 @@
 	if(is.null(JS.prefix)){
 		JS.prefix  <- object at prefix
 	} else {}
-	if(is.null(properties)){
-		properties  <- object at properties
+	if(is.null(modifiers)){
+		modifiers  <- object at modifiers
 	} else {}
 	if(is.null(default)){
 		default     <- object at default
@@ -602,20 +608,34 @@
 
 	# only paste something if there's variables outside the 'vars' slot
 	if(length(nchar(JS.var)) > 0 & length(nchar(XML.var)) > 0){
-		if(length(properties) == 0 | isTRUE(default)){
-			results <- paste(results, main.indent, "var ", camelCode(c(JS.prefix, JS.var)), " = getValue(\"", XML.var, "\")", join.code, ";\n", sep="")
+		if(length(modifiers) == 0 | isTRUE(default)){
+			if(isTRUE(names.only)){
+				results <- c(results, camelCode(c(JS.prefix, JS.var)))
+			} else {
+				results <- paste(results, main.indent, "var ", camelCode(c(JS.prefix, JS.var)), " = getValue(\"", XML.var, "\")", join.code, ";", sep="")
+			}
 		} else {}
-		if(length(properties) > 0){
-			# check properties
-			properties <- properties[prop.validity(source="all", property=properties, ignore.empty=TRUE, warn.only=TRUE, bool=TRUE)]
+		if(length(modifiers) > 0){
+			# check modifiers
+			modifiers <- modifiers[modif.validity(source="all", modifier=modifiers, ignore.empty=TRUE, warn.only=TRUE, bool=TRUE)]
 			results <- c(results,
-				sapply(properties, function(this.prop){
-					paste(main.indent, "var ", camelCode(c(JS.prefix, JS.var, this.prop)), " = getValue(\"", XML.var, ".", this.prop, "\")", join.code, ";\n", sep="")
+				sapply(modifiers, function(this.modif){
+					if(isTRUE(names.only)){
+						return(camelCode(c(JS.prefix, JS.var, this.modif)))
+					} else {
+						return(paste(main.indent, "var ", camelCode(c(JS.prefix, JS.var, this.modif)),
+							" = getValue(\"", XML.var, ".", this.modif, "\")", join.code, ";", sep=""))
+					}
 				})
 			)
 		}
 	} else {}
 
-	results <- paste(results, collapse="")
+	if(isTRUE(names.only)){
+		results <- c(results)
+	} else {
+		results <- paste(results, collapse="")
+	}
+	
 	return(results)
-} ## end function paste.JS.options()
+} ## end function paste.JS.var()

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.saveobj.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.saveobj.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.saveobj.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -44,16 +44,17 @@
 			JS.vars <- paste(unlist(sapply(1:num.tags, function(this.tagnum){
 					this.tag <- cleaned.tags[this.tagnum]
 					if(XiMpLe:::parseXMLAttr(this.tag)[["checkable"]] %in% c("T", "true", "TRUE", "1")){
-						properties=c("active", "parent")
+						modifiers=c("active", "parent")
 					} else {
-						properties="parent"
+						modifiers="parent"
 					}
 					JS.id <- get.IDs(single.tags=this.tag, relevant.tags="saveobject", add.abbrev=add.abbrev)
-					return(get.JS.vars(
+					return(rk.paste.JS(get.JS.vars(
 						JS.var=JS.id[1,"abbrev"],
 						XML.var=JS.id[1,"id"],
-						properties=properties,
-						default=TRUE,
+						modifiers=as.list(modifiers),
+						default=TRUE),
+						level=2,
 						indent.by=indent.by))
 				})), collapse="")
 		} else {

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.scan.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.scan.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.scan.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -27,11 +27,11 @@
 			# will become
 			#   var my.id = getValue("my.id");
 			JS.lines <- paste(unlist(sapply(1:nrow(JS.id), function(this.id){
-					return(get.JS.vars(
+					return(rk.paste.JS(get.JS.vars(
 						JS.var=JS.id[this.id,"abbrev"],
-						XML.var=JS.id[this.id,"id"],
-						indent.by=indent.by))
-				})), collapse="")
+						XML.var=JS.id[this.id,"id"]),
+						level=2, indent.by=indent.by))
+				})), collapse="\n")
 		} else {
 			JS.lines <- JS.id[,"id"]
 			names(JS.lines) <- NULL

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.var-class.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.var-class.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.var-class.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -8,7 +8,7 @@
 		JS.var="character",
 		XML.var="character",
 		prefix="character",
-		properties="list",
+		modifiers="list",
 		default="logical",
 		join="character",
 		vars="list"
@@ -17,7 +17,7 @@
 		JS.var=character(),
 		XML.var=character(),
 		prefix=character(),
-		properties=list(),
+		modifiers=list(),
 		default=FALSE,
 		join="",
 		vars=list()

Modified: trunk/rkward/packages/rkwarddev/R/rk.JS.vars.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.JS.vars.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.JS.vars.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -1,11 +1,13 @@
 #' Define variables in JavaScript code
 #' 
+#' @note To get a list of the implemented modifiers in this package, call \code{rkwarddev:::all.valid.modifiers}.
+#'
 #' @param ... Either one or more character strings (the names of the variables to define),
 #'		or objects of class \code{XiMpLe.node} with plugin XML nodes (whose ID will be extracted and used).
 #' @param var.prefix A character string. will be used as a prefix for the JS variable names.
-#' @param properties A character vector with properties you'd like to get of the XML node.
-#' @param default Logical, if \code{TRUE} the default value (no special property) of the node will
-#'		also be defined. Does nothing if \code{properties=NULL}.
+#' @param modifiers A character vector with modifiers you'd like to apply to the XML node property.
+#' @param default Logical, if \code{TRUE} the default value (no special modifier) of the node will
+#'		also be defined. Does nothing if \code{modifiers=NULL}.
 #' @param join A character string, useful for GUI elements which accept multiple objects (i.e., multi-varslots).
 #'		If \code{join} is something other than \code{""}, these objects will be collapsed into one string when pasted,
 #'		joined by this string.
@@ -23,7 +25,7 @@
 #' # define them by their ID in JavaScript
 #' cat(rk.paste.JS(rk.JS.vars(list(checkA, checkB, checkC))))
 
-rk.JS.vars <- function(..., var.prefix=NULL, properties=NULL, default=FALSE, join=""){
+rk.JS.vars <- function(..., var.prefix=NULL, modifiers=NULL, default=FALSE, join=""){
 	variables <- list(...)
 
 	JS.vars <- new("rk.JS.var",
@@ -31,7 +33,7 @@
 						JS.var=this.var,
 						XML.var=this.var,
 						JS.prefix=var.prefix,
-						properties=properties,
+						modifiers=modifiers,
 						default=default,
 						join=join)
 				}))

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -1,21 +1,20 @@
 #' Create XML node "connect" for RKWard plugins
 #'
 #' If you define a \code{XiMpLe.node} object as \code{governor} which is not a \code{<convert>} node
-#' and \code{not=FALSE}, the function will automatically append ".state" to its \code{id}.
+#' and \code{not=FALSE}, the function will automatically append  to its \code{id}.
+#' 
+#' @note To get a list of the implemented modifiers in this package, call \code{rkwarddev:::all.valid.modifiers}.
 #'
 #' @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.
+#'		\code{\link[rkwarddev:rk.XML.convert]{rk.XML.convert}}).
 #' @param client Character string, the \code{id} if the element to be controlled by \code{governor}.
+#' @param get Character string, a valid modifier for the node property of \code{governor}, often
+#'		the ".state" value of some apropriate node.
+#' @param set Character string, a valid modifier for the node property of \code{client}, usually
+#'		one of \code{"enabled"}, \code{"visible"} or \code{"required"}.
 #' @param not Logical, if \code{TRUE}, the state of \code{governor} (\code{TRUE/FALSE}) will be inversed.
-#' @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 An object of class \code{XiMpLe.node}.
@@ -30,7 +29,7 @@
 #' test.connect <- rk.XML.connect(governor="lgc_foobar", client="frame_bar")
 #' cat(pasteXMLNode(test.connect))
 
-rk.XML.connect <- function(governor, client, set="enabled", not=FALSE, reconcile=FALSE){
+rk.XML.connect <- function(governor, client, get="state", set="enabled", not=FALSE, reconcile=FALSE){
 
 	if(length(governor) > 1 | length(client) > 1){
 		stop(simpleError("'governor' and 'client' must be of length 1!"))
@@ -41,8 +40,12 @@
 	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") & !isTRUE(not)){
-			governor.id <- paste(governor.id, "state", sep=".")
+		node.name <- governor at name
+		if(!identical(node.name, "convert") & !isTRUE(not)){
+			# validate get modifier
+			if(modif.validity(governor, modifier=get)){
+				governor.id <- paste(governor.id, get, sep=".")
+			} else {}
 		} else {}
 	} else {}
 	if(isTRUE(not)){
@@ -51,12 +54,10 @@
 
 	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 {
+	# validate set modifier
+	if(modif.validity(client, modifier=set, warn.only=FALSE)){
 		attr.list[["client"]] <- paste(client.id, set, sep=".")
-	}
+	} else {}
 
 	if(isTRUE(reconcile)){
 			attr.list[["reconcile"]] <- "true"

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.convert.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.convert.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.convert.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -1,14 +1,9 @@
 #' Create XML node convert for RKWard plugins
 #'
-#' The recognized property names for \code{sources} are the following:
-#' \code{string}, \code{state}, \code{text}, \code{selected}, \code{root},
-#' \code{available}, \code{source}, \code{number}, \code{enabled}, \code{checked}, \code{selection},
-#' \code{parent}, \code{objectname}, \code{active}, \code{int}, \code{real}, \code{model},
-#' \code{table}, \code{labels}, \code{fixed_factors}, \code{dependent} and \code{code}.
-#' They are not globally valid for all XML elements, see the section on "Properties of plugin elements"
-#' to see which is useful for what tag. If \code{sources} holds \code{XiMpLe.node}
-#' objects, the validity of properties is automatically checked for that tag.
+#' If \code{sources} holds \code{XiMpLe.node} objects, the validity of modifiers is automatically checked for that tag.
 #'
+#' @note To get a list of the implemented modifiers for \code{sources} in this package, call \code{rkwarddev:::all.valid.modifiers}.
+#'
 #' @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
@@ -74,21 +69,18 @@
 	# 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 properties here
-		invalid.names <- !src.names %in% c("", "string", "state", "text", "selected", "root",
-			"available", "source", "number", "enabled", "checked", "selection", "parent",
-			"objectname", "active", "int", "real", "model", "table", "labels",
-			"fixed_factors", "dependent", "code")
+		# check these names if they're valid modifiers here
+		invalid.names <- !src.names %in% unique(unlist(all.valid.modifiers))
 		if(any(invalid.names)){
-			warning(paste("Some of the property names you provided are invalid and were ignored: ",
+			warning(paste("Some of the modifier 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.prop <- src.names[src.no]
-				valid.prop <- prop.validity(source=sources[[src.no]], property=this.prop, bool=FALSE)
-				if(nchar(valid.prop) > 0){
-					new.value <- paste(check.ID(sources[[src.no]]), this.prop, sep=".")
+				this.modif <- src.names[src.no]
+				valid.modif <- modif.validity(source=sources[[src.no]], modifier=this.modif, bool=FALSE)
+				if(nchar(valid.modif) > 0){
+					new.value <- paste(check.ID(sources[[src.no]]), this.modif, sep=".")
 				} else {
 					new.value <- check.ID(sources[[src.no]])
 				}

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.set.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.set.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.set.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -4,6 +4,8 @@
 #'		or an object of class \code{XiMpLe.node} (whose \code{id} will be extracted and used).
 #' @param set Character string, can be one of the following values:
 #'		\itemize{
+#'			\item{\code{"state"}}{Set the \code{id} boolean state.}
+#'			\item{\code{"string"}}{Set the \code{id} string value.}
 #'			\item{\code{"enabled"}}{Set the \code{id} enabled state.}
 #'			\item{\code{"visible"}}{Set the \code{id} visibility state.}
 #'			\item{\code{"required"}}{Set the \code{id} requirement state.}
@@ -32,7 +34,7 @@
 
 	if(!is.null(set)){
 		if(!set %in% c("state","string","enabled","required","visible")){
-			stop(simpleError(paste("The 'set' property you provided is invalid: ", set, sep="")))
+			stop(simpleError(paste("The 'set' modifier you provided is invalid: ", set, sep="")))
 		} else {
 			prop.id <- paste(prop.id, set, sep=".")
 		}

Modified: trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -1,5 +1,7 @@
 #' Paste JavaScript objects and character strings
 #'
+#' @note To get a list of the implemented modifiers in this package, call \code{rkwarddev:::all.valid.modifiers}.
+#'
 #' @param ... Objects of class \code{rk.JS.ite}, \code{rk.JS.arr}, \code{rk.JS.opt} or character.
 #' @param level Integer, which indentation level to use, minimum is 1.
 #' @param indent.by A character string defining the indentation string to use.
@@ -9,9 +11,9 @@
 #'		in an array or a concatenated character string.
 #' @param var.prefix For \code{rk.JS.var} objects only: A character string. will be used as a prefix
 #'		for the JS variable names.
-#' @param properties For \code{rk.JS.var} objects only: A character vector with properties you'd like to get of the XML node.
-#' @param default For \code{rk.JS.var} objects only: Logical, if \code{TRUE} the default value (no special property) of the node will
-#'		also be defined. Does nothing if \code{properties=NULL}.
+#' @param modifiers For \code{rk.JS.var} objects only: A character vector with modifiers you'd like to apply the XML node's property.
+#' @param default For \code{rk.JS.var} objects only: Logical, if \code{TRUE} the default value (no special modifier) of the node will
+#'		also be defined. Does nothing if \code{modifiers=NULL}.
 #' @param join For \code{rk.JS.var} objects only: A character string, useful for GUI elements which accept multiple objects
 #'		(i.e., multi-varslots). If \code{join} is something other than \code{""}, these objects will be collapsed into one string
 #'		when pasted, joined by this string.
@@ -29,7 +31,7 @@
 #' @export
 
 rk.paste.JS <- function(..., level=2, indent.by="\t", funct=NULL, array=NULL,
-	var.prefix=NULL, properties=NULL, default=NULL, join=NULL){
+	var.prefix=NULL, modifiers=NULL, default=NULL, join=NULL){
 	stopifnot(level > 0)
 	all.objects <- list(...)
 
@@ -44,7 +46,7 @@
 			result <- paste.JS.options(this.object, level=level, indent.by=indent.by, array=array, funct=funct)
 		} else if(inherits(this.object, "rk.JS.var")){
 			result <- paste.JS.var(this.object, level=level, indent.by=indent.by, JS.prefix=var.prefix,
-				properties=properties, default=default, join=join)
+				modifiers=modifiers, default=default, join=join)
 		} else {
 			result <- paste(indent(level, by=indent.by), this.object, sep="")
 		}

Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2011-10-19 21:09:36 UTC (rev 3974)
@@ -3,7 +3,7 @@
 #' \tabular{ll}{
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
-#' Version: \tab 0.03-8\cr
+#' Version: \tab 0.04-0\cr
 #' Date: \tab 2011-10-19\cr
 #' Depends: \tab R (>= 2.9.0),XiMpLe,rkward (>= 0.5.7)\cr
 #' Enhances: \tab rkward\cr

Modified: trunk/rkward/packages/rkwarddev/inst/CITATION
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/CITATION	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/inst/CITATION	2011-10-19 21:09:36 UTC (rev 3974)
@@ -2,12 +2,12 @@
 		title="rkwarddev: A collection of tools for RKWard plugin development",
 		author="Meik Michalke",
 		year="2011",
-		note="(Version 0.03-8)",
+		note="(Version 0.04-0)",
 		url="http://rkward.sourceforge.net",
 
 		textVersion =
 		paste("Michalke, M. (2011). ",
-				"rkwarddev: A collection of tools for RKWard plugin development (Version 0.03-8). ",
+				"rkwarddev: A collection of tools for RKWard plugin development (Version 0.04-0). ",
 				"Available from http://rkward.sourceforge.net",
 				sep=""),
 

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

Modified: trunk/rkward/packages/rkwarddev/man/rk.JS.vars.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.JS.vars.Rd	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/man/rk.JS.vars.Rd	2011-10-19 21:09:36 UTC (rev 3974)
@@ -2,7 +2,7 @@
 \alias{rk.JS.vars}
 \title{Define variables in JavaScript code}
 \usage{
-  rk.JS.vars(..., var.prefix = NULL, properties = NULL,
+  rk.JS.vars(..., var.prefix = NULL, modifiers = NULL,
   default = FALSE, join = "")
 }
 \arguments{
@@ -14,12 +14,12 @@
   \item{var.prefix}{A character string. will be used as a
   prefix for the JS variable names.}
 
-  \item{properties}{A character vector with properties
-  you'd like to get of the XML node.}
+  \item{modifiers}{A character vector with modifiers you'd
+  like to apply to the XML node property.}
 
   \item{default}{Logical, if \code{TRUE} the default value
-  (no special property) of the node will also be defined.
-  Does nothing if \code{properties=NULL}.}
+  (no special modifier) of the node will also be defined.
+  Does nothing if \code{modifiers=NULL}.}
 
   \item{join}{A character string, useful for GUI elements
   which accept multiple objects (i.e., multi-varslots). If
@@ -33,6 +33,10 @@
 \description{
   Define variables in JavaScript code
 }
+\note{
+  To get a list of the implemented modifiers in this
+  package, call \code{rkwarddev:::all.valid.modifiers}.
+}
 \examples{
 # create three checkboxes
 checkA <- rk.XML.cbox(label="Run Test A", value="A")

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.connect.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.connect.Rd	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.connect.Rd	2011-10-19 21:09:36 UTC (rev 3974)
@@ -2,8 +2,8 @@
 \alias{rk.XML.connect}
 \title{Create XML node "connect" for RKWard plugins}
 \usage{
-  rk.XML.connect(governor, client, set = "enabled", not =
-  FALSE, reconcile = FALSE)
+  rk.XML.connect(governor, client, get = "state", set =
+  "enabled", not = FALSE, reconcile = FALSE)
 }
 \arguments{
   \item{governor}{Either a character string (the \code{id}
@@ -11,23 +11,22 @@
   \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.}
+  \code{\link[rkwarddev:rk.XML.convert]{rk.XML.convert}}).}
 
   \item{client}{Character string, the \code{id} if the
   element to be controlled by \code{governor}.}
 
+  \item{get}{Character string, a valid modifier for the
+  node property of \code{governor}, often the ".state"
+  value of some apropriate node.}
+
+  \item{set}{Character string, a valid modifier for the
+  node property of \code{client}, usually one of
+  \code{"enabled"}, \code{"visible"} or \code{"required"}.}
+
   \item{not}{Logical, if \code{TRUE}, the state of
   \code{governor} (\code{TRUE/FALSE}) will be inversed.}
 
-  \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.}
@@ -39,8 +38,12 @@
   If you define a \code{XiMpLe.node} object as
   \code{governor} which is not a \code{<convert>} node and
   \code{not=FALSE}, the function will automatically append
-  ".state" to its \code{id}.
+  to its \code{id}.
 }
+\note{
+  To get a list of the implemented modifiers in this
+  package, call \code{rkwarddev:::all.valid.modifiers}.
+}
 \examples{
 test.connect <- rk.XML.connect(governor="lgc_foobar", client="frame_bar")
 cat(pasteXMLNode(test.connect))

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.convert.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.convert.Rd	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.convert.Rd	2011-10-19 21:09:36 UTC (rev 3974)
@@ -45,20 +45,15 @@
   An object of class \code{XiMpLe.node}.
 }
 \description{
-  The recognized property names for \code{sources} are the
-  following: \code{string}, \code{state}, \code{text},
-  \code{selected}, \code{root}, \code{available},
-  \code{source}, \code{number}, \code{enabled},
-  \code{checked}, \code{selection}, \code{parent},
-  \code{objectname}, \code{active}, \code{int},
-  \code{real}, \code{model}, \code{table}, \code{labels},
-  \code{fixed_factors}, \code{dependent} and \code{code}.
-  They are not globally valid for all XML elements, see the
-  section on "Properties of plugin elements" to see which
-  is useful for what tag. If \code{sources} holds
-  \code{XiMpLe.node} objects, the validity of properties is
-  automatically checked for that tag.
+  If \code{sources} holds \code{XiMpLe.node} objects, the
+  validity of modifiers is automatically checked for that
+  tag.
 }
+\note{
+  To get a list of the implemented modifiers for
+  \code{sources} in this package, call
+  \code{rkwarddev:::all.valid.modifiers}.
+}
 \examples{
 test.convert <- rk.XML.convert(list(string="foo"), mode=c(notequals="bar"))
 cat(pasteXMLNode(test.convert))

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.set.Rd	2011-10-19 21:09:36 UTC (rev 3974)
@@ -11,10 +11,12 @@
   extracted and used).}
 
   \item{set}{Character string, can be one of the following
-  values: \itemize{ \item{\code{"enabled"}}{Set the
-  \code{id} enabled state.} \item{\code{"visible"}}{Set the
-  \code{id} visibility state.} \item{\code{"required"}}{Set
-  the \code{id} requirement state.} }}
+  values: \itemize{ \item{\code{"state"}}{Set the \code{id}
+  boolean state.} \item{\code{"string"}}{Set the \code{id}
+  string value.} \item{\code{"enabled"}}{Set the \code{id}
+  enabled state.} \item{\code{"visible"}}{Set the \code{id}
+  visibility state.} \item{\code{"required"}}{Set the
+  \code{id} requirement state.} }}
 
   \item{to}{Character string or logical, the value the
   property should be set to.}

Modified: trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/man/rk.paste.JS.Rd	2011-10-19 21:09:36 UTC (rev 3974)
@@ -3,7 +3,7 @@
 \title{Paste JavaScript objects and character strings}
 \usage{
   rk.paste.JS(..., level = 2, indent.by = "\t", funct =
-  NULL, array = NULL, var.prefix = NULL, properties = NULL,
+  NULL, array = NULL, var.prefix = NULL, modifiers = NULL,
   default = NULL, join = NULL)
 }
 \arguments{
@@ -29,14 +29,14 @@
   character string. will be used as a prefix for the JS
   variable names.}
 
-  \item{properties}{For \code{rk.JS.var} objects only: A
-  character vector with properties you'd like to get of the
-  XML node.}
+  \item{modifiers}{For \code{rk.JS.var} objects only: A
+  character vector with modifiers you'd like to apply the
+  XML node's property.}
 
   \item{default}{For \code{rk.JS.var} objects only:
   Logical, if \code{TRUE} the default value (no special
-  property) of the node will also be defined. Does nothing
-  if \code{properties=NULL}.}
+  modifier) of the node will also be defined. Does nothing
+  if \code{modifiers=NULL}.}
 
   \item{join}{For \code{rk.JS.var} objects only: A
   character string, useful for GUI elements which accept
@@ -51,6 +51,10 @@
 \description{
   Paste JavaScript objects and character strings
 }
+\note{
+  To get a list of the implemented modifiers in this
+  package, call \code{rkwarddev:::all.valid.modifiers}.
+}
 \seealso{
   \code{\link[rkwarddev:rk.JS.array]{rk.JS.array}},
   \code{\link[rkwarddev:rk.JS.options]{rk.JS.options}},

Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2011-10-19 16:03:47 UTC (rev 3973)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2011-10-19 21:09:36 UTC (rev 3974)
@@ -8,7 +8,7 @@
 }
 \details{
   \tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
-  Package\cr Version: \tab 0.03-8\cr Date: \tab
+  Package\cr Version: \tab 0.04-0\cr Date: \tab
   2011-10-19\cr Depends: \tab R (>= 2.9.0),XiMpLe,rkward
   (>= 0.5.7)\cr Enhances: \tab rkward\cr Encoding: \tab
   UTF-8\cr License: \tab GPL (>= 3)\cr LazyLoad: \tab

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