[rkward-cvs] SF.net SVN: rkward:[3829] trunk/rkward/rkward/rbackend/rpackages/rkwarddev

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Sun Sep 25 15:20:46 UTC 2011


Revision: 3829
          http://rkward.svn.sourceforge.net/rkward/?rev=3829&view=rev
Author:   m-eik
Date:     2011-09-25 15:20:46 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
rkwarddev: added rk.XML.set and rk.XML.external

Added Paths:
-----------
    trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.external.R
    trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.set.R
    trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.external.Rd
    trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.set.Rd

Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.external.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.external.R	                        (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.external.R	2011-09-25 15:20:46 UTC (rev 3829)
@@ -0,0 +1,23 @@
+#' Create XML node "external" for RKWard plugins
+#'
+#' @param id Character string, the ID of the new property.
+#' @param default Character string, initial value of the property if not connected.
+#' @return An object of class \code{XiMpLe.node}.
+#' @export
+#' @examples
+#' test.external <- rk.XML.external(id="ext_property", default="none")
+#' cat(pasteXMLNode(test.external, shine=1))
+
+rk.XML.external <- function(id, default=NULL){
+	attr.list <- list(id=id)
+
+	if(!is.null(default)){
+		attr.list[["default"]] <- as.character(default)
+	} else {}
+
+	node <- new("XiMpLe.node",
+			name="external",
+			attributes=attr.list)
+
+	return(node)
+}

Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.set.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.set.R	                        (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/R/rk.XML.set.R	2011-09-25 15:20:46 UTC (rev 3829)
@@ -0,0 +1,49 @@
+#' Create XML node "set" for RKWard plugins
+#'
+#' @param id Either a character string (the \code{id} of the property whose value should be set),
+#'		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{"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.}
+#'		}
+#' @param to Character string or logical, the value the property should be set to.
+#' @return A list of objects of class \code{XiMpLe.node}.
+#' @export
+#' @examples
+#' test.set <- rk.XML.set(id="input_foo", set="required", to=TRUE)
+#' cat(pasteXMLNode(test.set, shine=1))
+
+rk.XML.set <- function(id, set=NULL, to){
+
+	if(length(id) > 1 | length(to) > 1){
+		stop(simpleError("'id' and 'to' must be of length 1!"))
+	} else {}
+
+	# let's see if we need to extract IDs first
+	prop.id <- check.ID(id)
+
+	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="")))
+		} else {
+			prop.id <- paste(prop.id, set, sep=".")
+		}
+	} else {}
+
+	attr.list <- list(id=as.character(prop.id))
+
+	if(is.logical(to)){
+		attr.list[["to"]] <- ifelse(isTRUE(to), "true", "false")
+	} else {
+		attr.list[["to"]] <- as.character(to)
+	}
+
+	node <- new("XiMpLe.node",
+			name="set",
+			attributes=attr.list
+		)
+
+	return(node)
+}

Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.external.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.external.Rd	                        (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.external.Rd	2011-09-25 15:20:46 UTC (rev 3829)
@@ -0,0 +1,23 @@
+\name{rk.XML.external}
+\alias{rk.XML.external}
+\title{Create XML node "external" for RKWard plugins}
+\usage{
+  rk.XML.external(id, default = NULL)
+}
+\arguments{
+  \item{id}{Character string, the ID of the new property.}
+
+  \item{default}{Character string, initial value of the
+  property if not connected.}
+}
+\value{
+  An object of class \code{XiMpLe.node}.
+}
+\description{
+  Create XML node "external" for RKWard plugins
+}
+\examples{
+test.external <- rk.XML.external(id="ext_property", default="none")
+cat(pasteXMLNode(test.external, shine=1))
+}
+

Added: trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.set.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.set.Rd	                        (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkwarddev/man/rk.XML.set.Rd	2011-09-25 15:20:46 UTC (rev 3829)
@@ -0,0 +1,32 @@
+\name{rk.XML.set}
+\alias{rk.XML.set}
+\title{Create XML node "set" for RKWard plugins}
+\usage{
+  rk.XML.set(id, set = NULL, to)
+}
+\arguments{
+  \item{id}{Either a character string (the \code{id} of the
+  property whose value should be set), or an object of
+  class \code{XiMpLe.node} (whose \code{id} will be
+  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.} }}
+
+  \item{to}{Character string or logical, the value the
+  property should be set to.}
+}
+\value{
+  A list of objects of class \code{XiMpLe.node}.
+}
+\description{
+  Create XML node "set" for RKWard plugins
+}
+\examples{
+test.set <- rk.XML.set(id="input_foo", set="required", to=TRUE)
+cat(pasteXMLNode(test.set, shine=1))
+}
+

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