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

m-eik at users.sf.net m-eik at users.sf.net
Thu Feb 7 16:11:35 UTC 2013


Revision: 4528
          http://sourceforge.net/p/rkward/code/4528
Author:   m-eik
Date:     2013-02-07 16:11:32 +0000 (Thu, 07 Feb 2013)
Log Message:
-----------
rkwarddev: first steps towards implementing the recent changes in plugin XML structure

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/DESCRIPTION
    trunk/rkward/packages/rkwarddev/NAMESPACE
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.about.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.component.R
    trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
    trunk/rkward/packages/rkwarddev/R/rkwarddev-desc-internal.R
    trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
    trunk/rkward/packages/rkwarddev/man/rk.XML.component.Rd
    trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd
    trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd

Added Paths:
-----------
    trunk/rkward/packages/rkwarddev/R/rk.XML.dependencies.R
    trunk/rkward/packages/rkwarddev/R/zzz.rk.plot.opts-class.R
    trunk/rkward/packages/rkwarddev/man/rk.XML.dependencies.Rd

Removed Paths:
-------------
    trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2013-02-07 16:11:32 UTC (rev 4528)
@@ -1,5 +1,15 @@
 ChangeLog for package rkwarddev
 
+changes in version 0.06-2 (2013-02-07)
+changed:
+  - the structure of <about> nodes will change in RKWard 0.6.1, <dependencies> will become
+    a direct child of <document> or <component>, which explains several changes in this release
+  - for consistency, from now on <component> is never an empty node
+added:
+  - new function rk.XML.dependencies()
+  - added options "dependencies", "namespace" and "priority" to rk.XML.pluginmap()
+  - added option "dependencies" to rk.XML.component()
+
 changes in version 0.06-1 (2012-11-08)
 changed:
   - rk.plugin.skeleton(): "tests" will now ignore "overwrite" and not replace

Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION	2013-02-07 16:11:32 UTC (rev 4528)
@@ -4,18 +4,18 @@
 Author: m.eik michalke <meik.michalke at hhu.de>
 Maintainer: m.eik michalke <meik.michalke at hhu.de>
 Depends:
-    R (>= 2.9.0),methods,XiMpLe (>= 0.03-12),rkward (>= 0.5.6)
+    R (>= 2.9.0),methods,XiMpLe (>= 0.03-17),rkward (>= 0.5.6)
 Enhances: rkward
-Description: Provides functions to create plugin skeletons and XML
-    structures for RKWard.
+Description: Provides functions to create plugin skeletons and XML structures
+    for RKWard.
 License: GPL (>= 3)
 Encoding: UTF-8
 LazyLoad: yes
 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.06-1
-Date: 2012-11-08
+Version: 0.06-2
+Date: 2013-02-07
 Collate:
     'echo.R'
     'id.R'
@@ -37,8 +37,6 @@
     'rk.paste.JS.graph.R'
     'rk.paste.JS.R'
     'rk.plotOptions.R'
-    'rk.XML.embed.R'
-    'rk.plot.opts-class.R'
     'rk.rkh.doc.R'
     'rk.XML.plugin.R'
     'rk.plug.comp-class.R'
@@ -70,8 +68,10 @@
     'rk.XML.context.R'
     'rk.XML.convert.R'
     'rk.XML.copy.R'
+    'rk.XML.dependencies.R'
     'rk.XML.dialog.R'
     'rk.XML.dropdown.R'
+    'rk.XML.embed.R'
     'rk.XML.entry.R'
     'rk.XML.external.R'
     'rk.XML.formula.R'
@@ -103,3 +103,4 @@
     'rk.XML.wizard.R'
     'show-methods.R'
     'tf.R'
+    'zzz.rk.plot.opts-class.R'

Modified: trunk/rkward/packages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/packages/rkwarddev/NAMESPACE	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/NAMESPACE	2013-02-07 16:11:32 UTC (rev 4528)
@@ -48,6 +48,7 @@
 export(rk.XML.context)
 export(rk.XML.convert)
 export(rk.XML.copy)
+export(rk.XML.dependencies)
 export(rk.XML.dialog)
 export(rk.XML.dropdown)
 export(rk.XML.embed)

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -43,7 +43,7 @@
 # 'empty' can be used to make sure a tag is non-empty without actual value
 # this function also reduces rk.plot.opts objects to their XiMpLe.node slot
 child.list <- function(children, empty=TRUE){
-	if(inherits(children, "XiMpLe.node")){
+	if(is.XiMpLe.node(children)){
 		children <- list(children)
 	} else {
 		# if already a list, check if it's a list in a list and get it out
@@ -96,9 +96,9 @@
 ## function get.single.tags()
 get.single.tags <- function(XML.obj, drop=NULL){
 	# determine if we need to read a file or process an XiMpLe object
-	if(inherits(XML.obj, "XiMpLe.doc")){
+	if(is.XiMpLe.doc(XML.obj)){
 		single.tags <- trim(unlist(strsplit(pasteXMLTree(XML.obj, shine=1, indent.by=""), split="\n")))
-	} else if(inherits(XML.obj, "XiMpLe.node")){
+	} else if(is.XiMpLe.node(XML.obj)){
 		single.tags <- trim(unlist(strsplit(pasteXML(XML.obj, shine=1, indent.by=""), split="\n")))
 	} else {
 		xml.raw <- paste(readLines(XML.obj), collapse=" ")
@@ -119,7 +119,7 @@
 	# filter for relevant tags
 	cleaned.tags <- list()
 	for(this.tag in child.list(single.tags)){
-		if(inherits(this.tag, "XiMpLe.node")){
+		if(is.XiMpLe.node(this.tag)){
 			this.tag.name <- slot(this.tag, "name")
 			if(this.tag.name %in% relevant.tags & "id" %in% names(slot(this.tag, "attributes"))){
 				if(isTRUE(only.checkable) & this.tag.name %in% "frame"){
@@ -152,7 +152,7 @@
 	}
 
 	ids <- t(sapply(cleaned.tags, function(this.tag){
-				if(inherits(this.tag, "XiMpLe.node")){
+				if(is.XiMpLe.node(this.tag)){
 					this.tag.name <- slot(this.tag, "name")
 					this.tag.id <- slot(this.tag, "attributes")["id"]
 				} else {
@@ -219,7 +219,7 @@
 		# check validity of modifiers value
 		if(!is.null(modifiers)){
 			if(identical(modifiers, "all")){
-				if(inherits(XML.var, "XiMpLe.node")){
+				if(is.XiMpLe.node(XML.var)){
 					tag.name <- slot(XML.var, "name")
 				} else {
 					tag.name <- XML.var
@@ -230,7 +230,7 @@
 					modifiers <- NULL
 				}
 			} else {
-				if(inherits(XML.var, "XiMpLe.node")){
+				if(is.XiMpLe.node(XML.var)){
 					modif.tag.name <- slot(XML.var, "name")
 				} else {
 					modif.tag.name <- "all"
@@ -297,7 +297,7 @@
 # pastes the nodes as XML, only alphanumeric characters, e.g. to generate auto-IDs
 node.soup <- function(nodes){
 	the.soup <- paste(unlist(sapply(child.list(nodes), function(this.node){
-			if(inherits(this.node, "XiMpLe.node")){
+			if(is.XiMpLe.node(this.node)){
 				return(gsub("[^[:alnum:]]", "", pasteXML(this.node, shine=0)))
 			} else {
 				stop(simpleError("Nodes must be of class XiMpLe.node!"))
@@ -310,7 +310,7 @@
 ## function XML2person()
 # extracts the person/author info from XML "about" nodes
 XML2person <- function(node, eval=FALSE){
-		if(inherits(node, "XiMpLe.node")){
+		if(is.XiMpLe.node(node)){
 			# check if this is *really* a about section, otherwise die of boredom
 			if(!identical(slot(node, "name"), "about")){
 				stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
@@ -357,7 +357,7 @@
 	if(!isTRUE(suggest) & identical(mode, "suggest")){
 		return("")
 	} else {}
-	if(inherits(node, "XiMpLe.node")){
+	if(is.XiMpLe.node(node)){
 		# check if this is *really* a about section, otherwise die of boredom
 		if(!identical(slot(node, "name"), "about")){
 			stop(simpleError("I don't know what this is, but 'about' is not an about section!"))
@@ -424,7 +424,7 @@
 		return(sapply(node, check.ID))
 	} else {}
 
-	if(inherits(node, "XiMpLe.node")){
+	if(is.XiMpLe.node(node)){
 		node.ID <- slot(node, "attributes")[["id"]]
 	} else if(is.character(node)){
 		node.ID <- node
@@ -478,7 +478,7 @@
 		}
 	} else {}
 
-	if(inherits(source, "XiMpLe.node")){
+	if(is.XiMpLe.node(source)){
 		tag.name <- slot(source, "name")
 		# embedded plugins can have all sorts of modifiers
 		if(tag.name %in% c("embed", "external")){
@@ -538,6 +538,7 @@
 	as=c("browser", "checkbox", "column", "copy",
 		"dropdown", "formula", "frame", "input", "page", "radio", "row", "saveobject",
 		"spinbox", "stretch", "tabbook", "text", "varselector", "varslot"),
+	component=c("dependencies"),
 	components=c("component"),
 	context=c("menu", "!--"),
 	dialog=c("browser", "checkbox", "column", "copy",
@@ -573,7 +574,7 @@
 				# and discard the rest
 				this.child <- stripXML(this.child)
 
-				if(inherits(this.child, "XiMpLe.node")){
+				if(is.XiMpLe.node(this.child)){
 					return(slot(this.child, "name"))
 				} else {
 					stop(simpleError(paste("Invalid object for ", section, " section, must be of class XiMpLe.node, but got class ", class(this.child), "!", sep="")))
@@ -603,7 +604,7 @@
 # - warn: warning or stop?
 # - see: name of the function to check docs for
 valid.parent <- function(parent, node, warn=FALSE, see=NULL){
-	if(inherits(node, "XiMpLe.node")){
+	if(is.XiMpLe.node(node)){
 		node.name <- slot(node, "name")
 		if(identical(node.name, parent)){
 			return(TRUE)

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.about.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.about.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.about.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -118,100 +118,88 @@
 			return(result)
 		}))
 
-	## package
-	# - name
-	# - min="min_version",
-	# - max="max_version",
-	# - repository
-	# create example, if empty
-	if(is.null(package)){
-		xml.package.example <- XMLNode("package",
-			attrs=list(
-				name="CHANGE_ME_OR_DELETE_ME",
-				"min_version"="CHANGE_ME_OR_DELETE_ME",
-				"max_version"="CHANGE_ME_OR_DELETE_ME",
-				repository="CHANGE_ME_OR_DELETE_ME"
-			))
-		xml.package <- list(XMLNode("!--", xml.package.example))
-	} else {
-		xml.package <- sapply(package, function(this.package){
-				pck.options <- names(this.package)
-				pck.attributes <- list(name=this.package[["name"]])
-				for (this.option in c("min", "max","repository" )){
-					if(this.option %in% pck.options){
-						pck.attributes[[this.option]] <- this.package[[this.option]]
-					} else {}
-				}
-				result <- XMLNode("package", attrs=pck.attributes)
-				return(result)
-			})
-	}
+	###################
+	## the 'package' code is about to be removed in a future release
+	###################
+		## package
+		# - name
+		# - min="min_version",
+		# - max="max_version",
+		# - repository
+		# create example, if empty
+		if(is.null(package)){
+			xml.package <- list()
+		} else {
+			warning("<package> inside <about> is deprecated, use rk.XML.dependencies() instead!")
+			xml.package <- sapply(package, function(this.package){
+					pck.options <- names(this.package)
+					pck.attributes <- list(name=this.package[["name"]])
+					for (this.option in c("min", "max","repository" )){
+						if(this.option %in% pck.options){
+							pck.attributes[[this.option]] <- this.package[[this.option]]
+						} else {}
+					}
+					result <- XMLNode("package", attrs=pck.attributes)
+					return(result)
+				})
+		}
 
-	## pluginmap
-	# - name,
-	# - url
-	# create example, if empty
-	if(is.null(pluginmap)){
-		xml.pluginmap.text <- XMLNode("", "If this plugin depends on other pluginmaps, edit this part to your needs:")
-		xml.pluginmap.example <- XMLNode("pluginmap",
-			attrs=list(
-				name="CHANGE_ME_OR_DELETE_ME",
-				url="CHANGE_ME_OR_DELETE_ME"
-			))
-		xml.pluginmap <- list(XMLNode("!--", xml.pluginmap.text, xml.pluginmap.example))
-	} else {
-		xml.pluginmap <- sapply(pluginmap, function(this.pluginmap){
-				result <- XMLNode("pluginmap",
-					attrs=list(
-						name=this.pluginmap[["name"]],
-						url=this.pluginmap[["url"]]
-					))
-				return(result)
-			})
-	}
+	###################
+	## the 'pluginmap' code is about to be removed in a future release
+	###################
+		## pluginmap
+		# - name,
+		# - url
+		# create example, if empty
+		if(is.null(pluginmap)){
+			xml.pluginmap <- list()
+		} else {
+			warning("<pluginmap> inside <about> is deprecated, use rk.XML.dependencies() instead!")
+			xml.pluginmap <- sapply(pluginmap, function(this.pluginmap){
+					result <- XMLNode("pluginmap",
+						attrs=list(
+							name=this.pluginmap[["name"]],
+							url=this.pluginmap[["url"]]
+						))
+					return(result)
+				})
+		}
 
-	## dependencies
-	# - rkward.min="rkward_min_version",
-	# - rkward.max="rkward_max_version",
-	# - R.min="R_min_version",
-	# - R.max="R_max_version"
-	# + package
-	# + pluginmap
-	for (pmap in xml.pluginmap){
-		xml.package[[length(xml.package)+1]] <- pmap
-	}
-	# comment out an example dependency listing if it has no entries
-	if(is.null(dependencies)){
-		R.v <- R.Version()
-		xml.dependencies.text <- XMLNode("!--", "If this plugin has dependencies, edit this part to your needs:")
-		xml.authors[[length(xml.authors)+1]] <- xml.dependencies.text
-		xml.dependencies <- XMLNode("dependencies",
-			attrs=list(
-				"rkward_min_version"=.rk.app.version,
-				"rkward_max_version"="CHANGE_ME_OR_DELETE_ME",
-				"R_min_version"=paste(R.v$major, R.v$minor, sep="."),
-				"R_max_version"="CHANGE_ME_OR_DELETE_ME"
-			),
-			.children=child.list(xml.package, empty=FALSE))
-	} else {
-		dep.options <- names(dependencies)
-		dep.attributes <- list()
-		if("rkward.min" %in% dep.options){
-			dep.attributes[["rkward_min_version"]] <- dependencies[["rkward.min"]]
-		} else {}
-		if("rkward.max" %in% dep.options){
-			dep.attributes[["rkward_max_version"]] <- dependencies[["rkward.max"]]
-		} else {}
-		if("R.min" %in% dep.options){
-			dep.attributes[["R_min_version"]] <- dependencies[["R.min"]]
-		} else {}
-		if("R.max" %in% dep.options){
-			dep.attributes[["R_max_version"]] <- dependencies[["R.max"]]
-		} else {}
-		xml.dependencies <- XMLNode("dependencies",
-			attrs=dep.attributes,
-			.children=child.list(xml.package, empty=FALSE))
-	}
+	###################
+	## the 'dependencies' code is about to be removed in a future release
+	###################
+		## dependencies
+		# - rkward.min="rkward_min_version",
+		# - rkward.max="rkward_max_version",
+		# - R.min="R_min_version",
+		# - R.max="R_max_version"
+		# + package
+		# + pluginmap
+		for (pmap in xml.pluginmap){
+			xml.package[[length(xml.package)+1]] <- pmap
+		}
+		if(is.null(dependencies)){
+			xml.dependencies <- list()
+		} else {
+			warning("<dependencies> inside <about> is deprecated, use rk.XML.dependencies() instead!")
+			dep.options <- names(dependencies)
+			dep.attributes <- list()
+			if("rkward.min" %in% dep.options){
+				dep.attributes[["rkward_min_version"]] <- dependencies[["rkward.min"]]
+			} else {}
+			if("rkward.max" %in% dep.options){
+				dep.attributes[["rkward_max_version"]] <- dependencies[["rkward.max"]]
+			} else {}
+			if("R.min" %in% dep.options){
+				dep.attributes[["R_min_version"]] <- dependencies[["R.min"]]
+			} else {}
+			if("R.max" %in% dep.options){
+				dep.attributes[["R_max_version"]] <- dependencies[["R.max"]]
+			} else {}
+			xml.dependencies <- XMLNode("dependencies",
+				attrs=dep.attributes,
+				.children=child.list(xml.package, empty=FALSE))
+		}
 
 	## about
 	# - name

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.component.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.component.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.component.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -8,16 +8,18 @@
 #'		If \code{"auto"}, an ID will be generated automatically from the label.
 #' @param type Character string, type of component. As of now, only "standard" is supported. The option is
 #'		just implemented for completeness.
+#' @param dependencies An object of class \code{XiMpLe.node} to define \code{<dependencies>} for this component.
+#'		See \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.
 #' @return An object of class \code{XiMpLe.node}.
 #' @export
 #' @seealso
 #'		\code{\link[rkwarddev:rk.XML.components]{rk.XML.components}},
+#'		\code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}},
 #'		and the \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @examples
 #' test.component <- rk.XML.component("My GUI dialog", "plugins/MyGUIdialog.xml")
-#' cat(pasteXML(test.component))
 
-rk.XML.component <- function(label, file, id.name="auto", type="standard"){
+rk.XML.component <- function(label, file, id.name="auto", type="standard", dependencies=NULL){
 	if(identical(id.name, "auto")){
 		# try autogenerating some id
 		id.name <- auto.ids(label, prefix=ID.prefix("component"), chars=10)
@@ -36,7 +38,16 @@
 		attr.list[["file"]] <- file
 	} else {}
 
-	node <- XMLNode("component", attrs=attr.list)
+	# does this component hava additional dependencies?
+	if(!is.null(dependencies)){
+		# check if this is *really* a dependencies section
+		valid.parent("dependencies", node=dependencies, see="rk.XML.dependencies")
+		dependencies <- child.list(dependencies)
+	} else {
+		dependencies <- list("")
+	}
 
+	node <- XMLNode("component", attrs=attr.list, .children=dependencies)
+
 	return(node)
 }

Added: trunk/rkward/packages/rkwarddev/R/rk.XML.dependencies.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.dependencies.R	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.dependencies.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -0,0 +1,147 @@
+#' Create XML node "dependencies" for RKWard pluginmaps
+#'
+#' @param dependencies A named list with these elements:
+#'		\describe{
+#'			\item{rkward.min}{Minimum RKWard version needed for this plugin (optional)}
+#'			\item{rkward.max}{Maximum RKWard version needed for this plugin (optional)}
+#'			\item{R.min}{Minimum R version needed for this plugin (optional)}
+#'			\item{R.max}{Maximum R version needed for this plugin (optional)}
+#'		}
+#' @param package A list of named character vectors, each with these elements:
+#'		\describe{
+#'			\item{name}{Name of a package this plugin depends on (optional)}
+#'			\item{min}{Minimum version of the package (optional)}
+#'			\item{max}{Maximum version of the package (optional)}
+#'			\item{repository}{Repository to download the package (optional)}
+#'		}
+#' @param pluginmap A named list with these elements:
+#'		\describe{
+#'			\item{name}{Identifier of a pluginmap this plugin depends on (optional)}
+#'			\item{url}{URL to get the pluginmap (optional)}
+#'		}
+#' @param hints Logical, if \code{TRUE}, \code{NULL} values will be replaced with example text.
+#' @export
+#' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+#' @examples
+#' dependencies.node <- rk.XML.dependencies(
+#' 	dependencies=list(
+#' 		rkward.min="0.5.3",
+#' 		rkward.max="",
+#' 		R.min="2.10",
+#' 		R.max=""),
+#' 	package=list(
+#' 		c(name="heisenberg", min="0.11-2", max="",
+#' 			repository="http://rforge.r-project.org"),
+#' 		c(name="DreamsOfPi", min="0.2", max="", repository="")),
+#' 	pluginmap=list(
+#' 		c(name="heisenberg.pluginmap", url="http://eternalwondermaths.example.org/hsb"))
+#' )
+
+rk.XML.dependencies <- function(dependencies=NULL, package=NULL, pluginmap=NULL, hints=FALSE){
+	## package
+	# - name
+	# - min="min_version",
+	# - max="max_version",
+	# - repository
+	# create example, if empty
+	if(is.null(package)){
+		if(isTRUE(hints)){
+			xml.package.example <- XMLNode("package",
+				attrs=list(
+					name="CHANGE_ME_OR_DELETE_ME",
+					"min_version"="CHANGE_ME_OR_DELETE_ME",
+					"max_version"="CHANGE_ME_OR_DELETE_ME",
+					repository="CHANGE_ME_OR_DELETE_ME"
+				))
+			xml.package <- list(XMLNode("!--", xml.package.example))
+		} else {
+			xml.package <- list()
+		}
+	} else {
+		xml.package <- sapply(package, function(this.package){
+				pck.options <- names(this.package)
+				pck.attributes <- list(name=this.package[["name"]])
+				for (this.option in c("min", "max","repository" )){
+					if(this.option %in% pck.options){
+						pck.attributes[[this.option]] <- this.package[[this.option]]
+					} else {}
+				}
+				result <- XMLNode("package", attrs=pck.attributes)
+				return(result)
+			})
+	}
+
+	## pluginmap
+	# - name,
+	# - url
+	# create example, if empty
+	if(is.null(pluginmap)){
+		if(isTRUE(hints)){
+			xml.pluginmap.text <- XMLNode("", "If this plugin depends on other pluginmaps, edit this part to your needs:")
+			xml.pluginmap.example <- XMLNode("pluginmap",
+				attrs=list(
+					name="CHANGE_ME_OR_DELETE_ME",
+					url="CHANGE_ME_OR_DELETE_ME"
+				))
+			xml.pluginmap <- list(XMLNode("!--", xml.pluginmap.text, xml.pluginmap.example))
+		} else {
+			xml.pluginmap <- list()
+		}
+	} else {
+		xml.pluginmap <- sapply(pluginmap, function(this.pluginmap){
+				result <- XMLNode("pluginmap",
+					attrs=list(
+						name=this.pluginmap[["name"]],
+						url=this.pluginmap[["url"]]
+					))
+				return(result)
+			})
+	}
+
+	## dependencies
+	# - rkward.min="rkward_min_version",
+	# - rkward.max="rkward_max_version",
+	# - R.min="R_min_version",
+	# - R.max="R_max_version"
+	# + package
+	# + pluginmap
+	for (pmap in xml.pluginmap){
+		xml.package[[length(xml.package)+1]] <- pmap
+	}
+	# comment out an example dependency listing if it has no entries
+	if(is.null(dependencies)){
+		if(isTRUE(hints)){
+			R.v <- R.Version()
+			xml.dependencies <- XMLNode("dependencies",
+				attrs=list(
+					"rkward_min_version"=.rk.app.version,
+					"rkward_max_version"="CHANGE_ME_OR_DELETE_ME",
+					"R_min_version"=paste(R.v$major, R.v$minor, sep="."),
+					"R_max_version"="CHANGE_ME_OR_DELETE_ME"
+				),
+				.children=child.list(xml.package, empty=FALSE))
+		} else {
+			xml.dependencies <- XMLNode("dependencies", .children=child.list(xml.package, empty=FALSE))
+		}
+	} else {
+		dep.options <- names(dependencies)
+		dep.attributes <- list()
+		if("rkward.min" %in% dep.options){
+			dep.attributes[["rkward_min_version"]] <- dependencies[["rkward.min"]]
+		} else {}
+		if("rkward.max" %in% dep.options){
+			dep.attributes[["rkward_max_version"]] <- dependencies[["rkward.max"]]
+		} else {}
+		if("R.min" %in% dep.options){
+			dep.attributes[["R_min_version"]] <- dependencies[["R.min"]]
+		} else {}
+		if("R.max" %in% dep.options){
+			dep.attributes[["R_max_version"]] <- dependencies[["R.max"]]
+		} else {}
+		xml.dependencies <- XMLNode("dependencies",
+			attrs=dep.attributes,
+			.children=child.list(xml.package, empty=FALSE))
+	}
+
+	return(xml.dependencies)
+}

Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.pluginmap.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -23,12 +23,18 @@
 #' @param hints Logical, if \code{TRUE} and you leave out optional entries (like \code{about=NULL}), dummy sections will be added as comments.
 #' @param gen.info Logical, if \code{TRUE} a comment note will be written into the document,
 #'		that it was generated by \code{rkwarddev} and changes should be done to the script.
+#' @param dependencies An object of class \code{XiMpLe.node} to be pasted as the \code{<dependencies>} section,
+#'		See \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}} for details. Skipped if \code{NULL}.
+#' @param namespace Character string, the namespace attribute of the \code{<document>} node, defaults to the plugin name (which you probably shouldn't touch...)
+#' @param priority Character string, the priority attribute of the \code{<document>} node. Must be either "hidden", "low", "medium", or "high",
+#'		defaults to "medium".
 #' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
 #' @return An object of class \code{XiMpLe.node}.
 #' @export
 
 rk.XML.pluginmap <- function(name, about=NULL, components, hierarchy="test",
-	require=NULL, x11.context=NULL, import.context=NULL, clean.name=TRUE, hints=FALSE, gen.info=TRUE){
+	require=NULL, x11.context=NULL, import.context=NULL, clean.name=TRUE, hints=FALSE, gen.info=TRUE,
+	dependencies=NULL, namespace=name, priority="medium"){
 	name.orig <- name
 	if(isTRUE(clean.name)){
 		# to besure, remove all non-character symbols from name
@@ -36,6 +42,7 @@
 	} else {}
 
 	# .pluginmap has these children in <document>:
+	# - dependencies (optional)
 	# - about (optional)
 	# - require (optional, multiple)
 	# - components (once)
@@ -57,16 +64,29 @@
 		all.children[[length(all.children)+1]] <- generator.info
 	} else {}
 
+	## dependencies section
+	if(!is.null(dependencies)){
+		# check if this is *really* a dependencies section
+		valid.parent("dependencies", node=dependencies, see="rk.XML.dependencies")
+		# initialize all.children list
+		all.children[[length(all.children)+1]] <- dependencies
+	} else {
+		if(isTRUE(hints)){
+			dependencies.XML <- XMLNode("!--", XMLNode("dependencies", ""))
+			# initialize all.children list
+			all.children[[length(all.children)+1]] <- dependencies.XML
+		} else {}
+	}
+
 	## about section
 	if(!is.null(about)){
-		# check if this is *really* a about section, otherwise quit and go dancing
+		# check if this is *really* a about section
 		valid.parent("about", node=about, see="rk.XML.about")
 		# initialize all.children list
 		all.children[[length(all.children)+1]] <- about
 	} else {
 		if(isTRUE(hints)){
 			about.XML <- XMLNode("!--", XMLNode("about", ""))
-			# initialize all.children list
 			all.children[[length(all.children)+1]] <- about.XML
 		} else {}
 	}
@@ -252,8 +272,16 @@
 
 	# clean the ID of dots and append "_rkward"
 	doc.ID.name <- paste(gsub("[.]*", "", name), "_rkward", sep="")
+	# check for empty "namespace" value
+	if(is.null(namespace)){
+		namespace <- "rkward"
+	} else {}
+	# check for valid values of "priority"
+	if(!priority %in% c("hidden", "low", "medium", "high")){
+		stop(simpleError("'priority' must be one of 'hidden', 'low', 'medium' or 'high'!"))
+	} else {}
 	top.doc <- XMLNode("document",
-		attrs=list(base_prefix="", namespace="rkward", id=doc.ID.name),
+		attrs=list(base_prefix="", namespace=namespace, id=doc.ID.name, priority=priority),
 		.children=all.children
 	)
 

Deleted: trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -1,33 +0,0 @@
-#' @export
-
-# this simple class is for XML and JavaScript generation,
-# produced by rk.plotOptions()
-
-#' @include rk.JS.var-class.R
-#' @include rk.JS.vars.R
-#' @include rk.XML.embed.R
-
-setClass("rk.plot.opts",
-	representation=representation(
-		XML="XiMpLe.node",
-		preprocess="rk.JS.var",
-		printout="rk.JS.var",
-		calculate="rk.JS.var"
-	),
-	prototype(
-		XML=rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
-		preprocess=rk.JS.vars(
-			rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
-			modifiers="code.preprocess", check.modifiers=FALSE),
-		printout=rk.JS.vars(
-			rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
-			modifiers="code.printout", check.modifiers=FALSE),
-		calculate=rk.JS.vars(
-			rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
-			modifiers="code.calculate", check.modifiers=FALSE)
-	)
-)
-
-# setValidity("rk.plot.opts", function(object){
-# 	return(TRUE)
-# })

Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-desc-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-desc-internal.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-desc-internal.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -10,7 +10,7 @@
 			role=c(\"aut\", \"cre\")))",
 		Maintainer="m.eik michalke <meik.michalke at hhu.de>",
 		## revert to rkward (>= 0.5.7) later...
-		Depends="R (>= 2.9.0),methods,XiMpLe (>= 0.03-12),rkward (>= 0.5.6)",
+		Depends="R (>= 2.9.0),methods,XiMpLe (>= 0.03-17),rkward (>= 0.5.6)",
 		Enhances="rkward",
 		Description="Provides functions to create plugin skeletons and XML structures for RKWard.",
 		License="GPL (>= 3)",

Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -3,9 +3,9 @@
 #' \tabular{ll}{
 #' Package: \tab rkwarddev\cr
 #' Type: \tab Package\cr
-#' Version: \tab 0.06-1\cr
-#' Date: \tab 2012-11-08\cr
-#' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-12),rkward (>= 0.5.6)\cr
+#' Version: \tab 0.06-2\cr
+#' Date: \tab 2013-02-07\cr
+#' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-17),rkward (>= 0.5.6)\cr
 #' Enhances: \tab rkward\cr
 #' Encoding: \tab UTF-8\cr
 #' License: \tab GPL (>= 3)\cr

Added: trunk/rkward/packages/rkwarddev/R/zzz.rk.plot.opts-class.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/zzz.rk.plot.opts-class.R	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/zzz.rk.plot.opts-class.R	2013-02-07 16:11:32 UTC (rev 4528)
@@ -0,0 +1,35 @@
+# this simple class is for XML and JavaScript generation,
+# produced by rk.plotOptions()
+
+# it seems "@include" only works for classes, not for functions (rk.XML.embed()) :-/
+# so for the time being, this file is renamed to be parsed at the end
+
+#' @include rk.XML.embed.R
+#' @include rk.JS.var-class.R
+#' @include rk.JS.vars.R
+#' @export
+
+setClass("rk.plot.opts",
+	representation=representation(
+		XML="XiMpLe.node",
+		preprocess="rk.JS.var",
+		printout="rk.JS.var",
+		calculate="rk.JS.var"
+	),
+	prototype(
+		XML=rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+		preprocess=rk.JS.vars(
+			rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+			modifiers="code.preprocess", check.modifiers=FALSE),
+		printout=rk.JS.vars(
+			rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+			modifiers="code.printout", check.modifiers=FALSE),
+		calculate=rk.JS.vars(
+			rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+			modifiers="code.calculate", check.modifiers=FALSE)
+	)
+)
+
+# setValidity("rk.plot.opts", function(object){
+# 	return(TRUE)
+# })

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.component.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.component.Rd	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.component.Rd	2013-02-07 16:11:32 UTC (rev 4528)
@@ -3,7 +3,7 @@
 \title{Create XML "component" node for RKWard plugins}
 \usage{
   rk.XML.component(label, file, id.name = "auto",
-    type = "standard")
+    type = "standard", dependencies = NULL)
 }
 \arguments{
   \item{label}{Character string, a label for the
@@ -19,6 +19,11 @@
   \item{type}{Character string, type of component. As of
   now, only "standard" is supported. The option is just
   implemented for completeness.}
+
+  \item{dependencies}{An object of class \code{XiMpLe.node}
+  to define \code{<dependencies>} for this component.  See
+  \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}}
+  for details. Skipped if \code{NULL}.}
 }
 \value{
   An object of class \code{XiMpLe.node}.
@@ -29,10 +34,10 @@
 }
 \examples{
 test.component <- rk.XML.component("My GUI dialog", "plugins/MyGUIdialog.xml")
-cat(pasteXML(test.component))
 }
 \seealso{
   \code{\link[rkwarddev:rk.XML.components]{rk.XML.components}},
+  \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}},
   and the \href{help:rkwardplugins}{Introduction to Writing
   Plugins for RKWard}
 }

Added: trunk/rkward/packages/rkwarddev/man/rk.XML.dependencies.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.dependencies.Rd	                        (rev 0)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.dependencies.Rd	2013-02-07 16:11:32 UTC (rev 4528)
@@ -0,0 +1,55 @@
+\name{rk.XML.dependencies}
+\alias{rk.XML.dependencies}
+\title{Create XML node "dependencies" for RKWard pluginmaps}
+\usage{
+  rk.XML.dependencies(dependencies = NULL, package = NULL,
+    pluginmap = NULL, hints = FALSE)
+}
+\arguments{
+  \item{dependencies}{A named list with these elements:
+  \describe{ \item{rkward.min}{Minimum RKWard version
+  needed for this plugin (optional)}
+  \item{rkward.max}{Maximum RKWard version needed for this
+  plugin (optional)} \item{R.min}{Minimum R version needed
+  for this plugin (optional)} \item{R.max}{Maximum R
+  version needed for this plugin (optional)} }}
+
+  \item{package}{A list of named character vectors, each
+  with these elements: \describe{ \item{name}{Name of a
+  package this plugin depends on (optional)}
+  \item{min}{Minimum version of the package (optional)}
+  \item{max}{Maximum version of the package (optional)}
+  \item{repository}{Repository to download the package
+  (optional)} }}
+
+  \item{pluginmap}{A named list with these elements:
+  \describe{ \item{name}{Identifier of a pluginmap this
+  plugin depends on (optional)} \item{url}{URL to get the
+  pluginmap (optional)} }}
+
+  \item{hints}{Logical, if \code{TRUE}, \code{NULL} values
+  will be replaced with example text.}
+}
+\description{
+  Create XML node "dependencies" for RKWard pluginmaps
+}
+\examples{
+dependencies.node <- rk.XML.dependencies(
+	dependencies=list(
+		rkward.min="0.5.3",
+		rkward.max="",
+		R.min="2.10",
+		R.max=""),
+	package=list(
+		c(name="heisenberg", min="0.11-2", max="",
+			repository="http://rforge.r-project.org"),
+		c(name="DreamsOfPi", min="0.2", max="", repository="")),
+	pluginmap=list(
+		c(name="heisenberg.pluginmap", url="http://eternalwondermaths.example.org/hsb"))
+)
+}
+\seealso{
+  \href{help:rkwardplugins}{Introduction to Writing Plugins
+  for RKWard}
+}
+

Modified: trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/man/rk.XML.pluginmap.Rd	2013-02-07 16:11:32 UTC (rev 4528)
@@ -5,7 +5,8 @@
   rk.XML.pluginmap(name, about = NULL, components,
     hierarchy = "test", require = NULL, x11.context = NULL,
     import.context = NULL, clean.name = TRUE,
-    hints = FALSE, gen.info = TRUE)
+    hints = FALSE, gen.info = TRUE, dependencies = NULL,
+    namespace = name, priority = "medium")
 }
 \arguments{
   \item{name}{Character string, name of the plugin.}
@@ -68,6 +69,19 @@
   will be written into the document, that it was generated
   by \code{rkwarddev} and changes should be done to the
   script.}
+
+  \item{dependencies}{An object of class \code{XiMpLe.node}
+  to be pasted as the \code{<dependencies>} section, See
+  \code{\link[XiMpLe:rk.XML.dependencies]{rk.XML.dependencies}}
+  for details. Skipped if \code{NULL}.}
+
+  \item{namespace}{Character string, the namespace
+  attribute of the \code{<document>} node, defaults to the
+  plugin name (which you probably shouldn't touch...)}
+
+  \item{priority}{Character string, the priority attribute
+  of the \code{<document>} node. Must be either "hidden",
+  "low", "medium", or "high", defaults to "medium".}
 }
 \value{
   An object of class \code{XiMpLe.node}.

Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2013-02-06 15:48:42 UTC (rev 4527)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd	2013-02-07 16:11:32 UTC (rev 4528)
@@ -8,9 +8,9 @@
 }
 \details{
   \tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
-  Package\cr Version: \tab 0.06-1\cr Date: \tab
-  2012-11-08\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
-  (>= 0.03-12),rkward (>= 0.5.6)\cr Enhances: \tab
+  Package\cr Version: \tab 0.06-2\cr Date: \tab
+  2013-02-07\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
+  (>= 0.03-17),rkward (>= 0.5.6)\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 }





More information about the rkward-tracker mailing list