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

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Tue Oct 11 20:54:15 UTC 2011


Revision: 3929
          http://rkward.svn.sourceforge.net/rkward/?rev=3929&view=rev
Author:   m-eik
Date:     2011-10-11 20:54:15 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
rkwarddev: simplified syntax for rk.XML.tabbook()

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk.XML.tabbook.R
    trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
    trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
    trunk/rkward/packages/rkwarddev/man/rk.XML.tabbook.Rd

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-11 20:04:23 UTC (rev 3928)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2011-10-11 20:54:15 UTC (rev 3929)
@@ -3,6 +3,7 @@
 ## 0.03-5 (2011-10-11)
   - rk.XML.tabbook() can now autogenerate IDs without a label
   - fixed bug in autogeneration of IDs in rk.XML.spinbox()
+  - shortened syntax of rk.XML.tabbook() tabs are now simply a named list
 
 ## 0.03-4 (2011-10-10)
   - added functions rk.XML.code() and rk.XML.help()

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.tabbook.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.tabbook.R	2011-10-11 20:04:23 UTC (rev 3928)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.tabbook.R	2011-10-11 20:54:15 UTC (rev 3929)
@@ -1,10 +1,8 @@
 #' Create XML node "tabbook" for RKWard plugins
 #'
 #' @param label Character string, a text label for this plugin element.
-#' @param tab.labels Character vector, where each string defines the name of one tab.
-#'		The number of \code{tab.labels} also defines the number of tabs.
-#' @param children An optional list with objects of class \code{XiMpLe.node} (or a list of these objects).
-#'		You must provide one element for each tab. Use \code{NULL} for tabs without predefined children.
+#' @param tabs An optional named list with objects of class \code{XiMpLe.node} (or a list of these objects).
+#'		You must provide one named element for each tab. Use \code{NULL} for tabs without predefined children.
 #' @param id.name Character vector, unique IDs for the tabbook (first entry) and all tabs.
 #'		If \code{"auto"}, IDs will be generated automatically from the labels.
 #'		If \code{NULL}, no IDs will be given.
@@ -14,27 +12,24 @@
 #'		\href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @examples
 #' test.checkboxes <- rk.XML.row(rk.XML.col(
-#'   list(
-#'     rk.XML.cbox(label="foo", val="foo1", chk=TRUE),
-#'     rk.XML.cbox(label="bar", val="bar2"))))
+#'   rk.XML.cbox(label="foo", val="foo1", chk=TRUE),
+#'   rk.XML.cbox(label="bar", val="bar2")))
 #' test.dropdown <- rk.XML.dropdown("mydrop",
-#'   opts=list("First Option"=c(val="val1"),
+#'   options=list("First Option"=c(val="val1"),
 #'   "Second Option"=c(val="val2", chk=TRUE)))
 #' # combine the above into a tabbook
-#' test.tabbook <- rk.XML.tabbook("My Tabbook", tab.labels=c("First Tab",
-#'   "Second Tab"), children=list(test.checkboxes, test.dropdown))
+#' test.tabbook <- rk.XML.tabbook("My Tabbook",
+#'   tabs=list("First Tab"=test.checkboxes, "Second Tab"=test.dropdown))
 #' cat(pasteXMLNode(test.tabbook))
 
-rk.XML.tabbook <- function(label=NULL, tab.labels, children=list(), id.name="auto"){
-	num.tabs <-  length(tab.labels)
+rk.XML.tabbook <- function(label=NULL, tabs=list(), id.name="auto"){
+	tab.labels <- names(tabs)
+	num.tabs <- length(tabs)
+
 	# check if number of children fits
-	if(length(children) > 0){
-		if(!identical(length(children), num.tabs)){
-			stop(simpleError("If you provide children, you must do so for each tab (use NULL for tabs without children)!"))
-		} else {}
-	} else {
-		children <- NULL
-	}
+	if("" %in% tab.labels & num.tabs > 0){
+		stop(simpleError("All tabs must have a label (named list)!"))
+	} else {}
 
 	if(identical(id.name, "auto")){
 		tab.ids <- auto.ids(tab.labels, prefix=ID.prefix("tab", length=3))
@@ -47,8 +42,8 @@
 			} else if(!is.null(id.name)){
 				attr.list[["id"]] <- id.name[[this.num + 1]]
 			} else {}
-			if(!is.null(children[[this.num]])){
-				child <- children[[this.num]]
+			if(!is.null(tabs[[this.num]])){
+				child <- tabs[[this.num]]
 			} else {
 				child <- list()
 			}

Modified: trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
===================================================================
--- trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2011-10-11 20:04:23 UTC (rev 3928)
+++ trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2011-10-11 20:54:15 UTC (rev 3929)
@@ -109,8 +109,8 @@
 # 	tab.labels=c("About the plugin", "Create options", "XML content"),
 # 	children=list(tab1.about, tab2.create, tab3.children)), label="RKWard Plugin Skeleton")
 sklt.tabbook <- rk.XML.dialog(rk.XML.tabbook("Plugin Skeleton",
-	tab.labels=c("About the plugin", "Create options"),
-	children=list(tab1.about, tab2.create)), label="RKWard Plugin Skeleton")
+	tabs=list("About the plugin"=tab1.about, "Create options"=tab2.create)),
+	label="RKWard Plugin Skeleton")
 
 ## some logic
 logic.section <- rk.XML.logic(

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

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.tabbook.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.tabbook.Rd	2011-10-11 20:04:23 UTC (rev 3928)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.tabbook.Rd	2011-10-11 20:54:15 UTC (rev 3929)
@@ -2,21 +2,17 @@
 \alias{rk.XML.tabbook}
 \title{Create XML node "tabbook" for RKWard plugins}
 \usage{
-  rk.XML.tabbook(label = NULL, tab.labels, children =
-  list(), id.name = "auto")
+  rk.XML.tabbook(label = NULL, tabs = list(), id.name =
+  "auto")
 }
 \arguments{
   \item{label}{Character string, a text label for this
   plugin element.}
 
-  \item{tab.labels}{Character vector, where each string
-  defines the name of one tab. The number of
-  \code{tab.labels} also defines the number of tabs.}
-
-  \item{children}{An optional list with objects of class
+  \item{tabs}{An optional named list with objects of class
   \code{XiMpLe.node} (or a list of these objects). You must
-  provide one element for each tab. Use \code{NULL} for
-  tabs without predefined children.}
+  provide one named element for each tab. Use \code{NULL}
+  for tabs without predefined children.}
 
   \item{id.name}{Character vector, unique IDs for the
   tabbook (first entry) and all tabs. If \code{"auto"}, IDs
@@ -31,15 +27,14 @@
 }
 \examples{
 test.checkboxes <- rk.XML.row(rk.XML.col(
-list(
 rk.XML.cbox(label="foo", val="foo1", chk=TRUE),
-rk.XML.cbox(label="bar", val="bar2"))))
+rk.XML.cbox(label="bar", val="bar2")))
 test.dropdown <- rk.XML.dropdown("mydrop",
-opts=list("First Option"=c(val="val1"),
+options=list("First Option"=c(val="val1"),
 "Second Option"=c(val="val2", chk=TRUE)))
 # combine the above into a tabbook
-test.tabbook <- rk.XML.tabbook("My Tabbook", tab.labels=c("First Tab",
-"Second Tab"), children=list(test.checkboxes, test.dropdown))
+test.tabbook <- rk.XML.tabbook("My Tabbook",
+tabs=list("First Tab"=test.checkboxes, "Second Tab"=test.dropdown))
 cat(pasteXMLNode(test.tabbook))
 }
 \seealso{

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