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

m-eik at users.sf.net m-eik at users.sf.net
Tue Oct 14 14:12:59 UTC 2014


Revision: 4901
          http://sourceforge.net/p/rkward/code/4901
Author:   m-eik
Date:     2014-10-14 14:12:57 +0000 (Tue, 14 Oct 2014)
Log Message:
-----------
rkwarddev: fixed a JS bug and further enhanced the skeleton script to make the generated R code a good start for own scripts

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/ChangeLog
    trunk/rkward/packages/rkwarddev/R/rk-internal.R
    trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R

Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog	2014-10-13 19:17:20 UTC (rev 4900)
+++ trunk/rkward/packages/rkwarddev/ChangeLog	2014-10-14 14:12:57 UTC (rev 4901)
@@ -6,6 +6,8 @@
   - scanning plugin XML code for JS and help related content didn't work as expected in rk.plugin.component()
   - rk.rkh.scan() now also recognises <optioncolumn> and <matrix> nodes
   - a logical bug prevented rk.plugin.component() to run with default values for XML
+  - internal function paste.JS.options(), used by rk.JS.options(), was only working correctly for the "then"
+    part if ite() statements in arrays; now also produces usable code for an "else" part, if available
 added:
   - new functions rk.set.rkh.prompter() and rk.get.rkh.prompter() to make it easier to generate help files
     (later...)

Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R	2014-10-13 19:17:20 UTC (rev 4900)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R	2014-10-14 14:12:57 UTC (rev 4901)
@@ -1005,12 +1005,21 @@
   add.opts <- function(this.ite, collapse, array){
     if(isTRUE(array)){
       slot(this.ite, "thenJS") <- paste0(arr.name, ".push(", slot(this.ite, "thenJS"),");")
+      if(length(slot(this.ite, "elseJS")) == 1){
+        slot(this.ite, "elseJS") <- paste0(arr.name, ".push(", slot(this.ite, "elseJS"),");")
+      } else {}
     } else {
       slot(this.ite, "thenJS") <- paste0(variable, " += ", collapse, slot(this.ite, "thenJS"),";")
+      if(length(slot(this.ite, "elseJS")) == 1){
+        slot(this.ite, "elseJS") <- paste0(variable, " += ", collapse, slot(this.ite, "elseJS"),";")
+      } else {}
     }
     if(length(slot(this.ite, "elifJS")) == 1){
-      slot(this.ite, "elifJS") <- list(add.opts(slot(this.ite, "elifJS")[[1]]))
+      slot(this.ite, "elifJS") <- list(add.opts(slot(this.ite, "elifJS")[[1]], collapse=collapse, array=array))
     } else {}
+    if(length(slot(this.ite, "thenifJS")) == 1){
+      slot(this.ite, "thenifJS") <- list(add.opts(slot(this.ite, "thenifJS")[[1]], collapse=collapse, array=array))
+    } else {}
     return(this.ite)
   }
 

Modified: trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
===================================================================
--- trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2014-10-13 19:17:20 UTC (rev 4900)
+++ trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2014-10-14 14:12:57 UTC (rev 4901)
@@ -85,24 +85,29 @@
           help="If this is checked, the generated plugin will be shown (opened) for you to see what it looks like."),
         rk.XML.stretch())
     ),
-    rk.XML.row(pl.hier <- rk.XML.dropdown("Place in top menu",
-      options=list(
-          "Test (created if needed)"=c(val="test", chk=TRUE),
-          "File"=c(val="file"),
-          "Edit"=c(val="edit"),
-          "View"=c(val="view"),
-          "Workspace"=c(val="workspace"),
-          "Run"=c(val="run"),
-          "Data"=c(val="data"),
-          "Analysis"=c(val="analysis"),
-          "Plots"=c(val="plots"),
-          "Distributions"=c(val="distributions"),
-          "Windows"=c(val="windows"),
-          "Settings"=c(val="settings"),
-          "Help"=c(val="help")
+    rk.XML.frame(
+      rk.XML.row(pl.hier <- rk.XML.dropdown("Place in top menu",
+        options=list(
+            "Test (created if needed)"=c(val="test", chk=TRUE),
+            "File"=c(val="file"),
+            "Edit"=c(val="edit"),
+            "View"=c(val="view"),
+            "Workspace"=c(val="workspace"),
+            "Run"=c(val="run"),
+            "Data"=c(val="data"),
+            "Analysis"=c(val="analysis"),
+            "Plots"=c(val="plots"),
+            "Distributions"=c(val="distributions"),
+            "Windows"=c(val="windows"),
+            "Settings"=c(val="settings"),
+            "Help"=c(val="help")
+        ),
+        help="Specify where the plugin should appear in RKWard's top menus."
       ),
-      help="Specify where the plugin should appear in RKWard's top menus."
-    ))
+      pl.hier.name <- rk.XML.input("Name in menu (plugin name if empty)",
+        help="You can set the exact entry name of your main component in the menu here. If left empty, the plugin name will be used as default.")
+      )
+    )
   )
 dep.opts <- rk.XML.frame(
   rk.XML.row(
@@ -217,15 +222,22 @@
   funct="list", option="dependencies", collapse=",\\n\\t")
 
 js.opt.skel.pluginmap <- rk.JS.options("optPluginmap",
-  ite(id(pl.hier, "!= \"test\""), qp("hierarchy=\"", pl.hier, "\"")),
+  ite(pl.hier.name,
+    qp("name=\"", pl.hier.name, "\""),
+    qp("name=\"", pl.name, "\"")
+  ),
+  ite(pl.hier,  qp("hierarchy=\"", pl.hier, "\"")),
   funct="list", option="pluginmap", collapse="")
 js.opt.skeleton <- rk.JS.options("optSkeleton",
-  ite(pl.wiz, qp("\n\tprovides=c(\"logic\", \"dialog\", \"wizard\")")),
-  ite(js.opt.skel.pluginmap, qp("\n\t", js.opt.skel.pluginmap)),
-  ite(pl.tests, qp("\n\ttests=TRUE")),
-  ite(pl.edit, qp("\n\tedit=TRUE")),
-  ite(pl.add, qp("\n\tload=TRUE")),
-  ite(pl.show, qp("\n\tshow=TRUE")),
+  ite(pl.wiz, qp("\n\tprovides=c(\"logic\", \"dialog\", \"wizard\")"), qp("\n\t#provides=c(\"logic\", \"dialog\")")),
+  ite(js.opt.skel.pluginmap,
+    qp("\n\t", js.opt.skel.pluginmap),
+    qp("\n\t#pluginmap=list(name=\"\", hierarchy=\"\", require=\"\")")
+  ),
+  ite(pl.tests, qp("\n\ttests=TRUE"), qp("\n\ttests=FALSE")),
+  ite(pl.edit, qp("\n\tedit=TRUE"), qp("\n\tedit=FALSE")),
+  ite(pl.add, qp("\n\tload=TRUE"), qp("\n\tload=FALSE")),
+  ite(pl.show, qp("\n\tshow=TRUE"), qp("\n\tshow=FALSE")),
   collapse="")
 
 JS.prepare <- rk.paste.JS(
@@ -273,15 +285,24 @@
     "# this is where things get serious, that is, here all of the above is put together into one plugin\n",
     "plugin.dir <- rk.plugin.skeleton(\n\tabout=about.plugin,"),
   ite(id(js.frm.dep.opts, " && ", js.opt.about.dep), echo("\n\tdependencies=plugin.dependencies,")),
-  echo("\n\tpath=output.dir,"),
-  echo("\n\toverwrite=overwrite,"),
+  echo("\n\tpath=output.dir,",
+    "\n\tscan=c(\"var\", \"saveobj\", \"settings\"),",
+    "\n\txml=list(\n\t\t#dialog=,\n\t\t#wizard=,\n\t\t#logic=,\n\t\t#snippets=\n\t),",
+    "\n\tjs=list(\n\t\t#results.header=FALSE,\n\t\t#load.silencer=,\n\t\t#require=,\n\t\t#variables=,",
+      "\n\t\t#globals=,\n\t\t#preprocess=,\n\t\t#calculate=,\n\t\t#printout=,\n\t\t#doPrintout=\n\t),"
+  ),
   ite(js.frm.help.text,
     echo(
-      "\n\trkh=list(\n\t\tsummary=plugin.summary,\n\t\tusage=plugin.usage\n\t),",
+      "\n\trkh=list(\n\t\tsummary=plugin.summary,\n\t\tusage=plugin.usage#,",
+      "\n\t\t#sections=,\n\t\t#settings=,\n\t\t#related=,\n\t\t#technical=\n\t),",
       "\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\", \"rkh\"),"
     ),
-    echo("\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\"),")
+    echo("\n\trkh=list(","\n\t\t#summary=,\n\t\t#usage=,",
+      "\n\t\t#sections=,\n\t\t#settings=,\n\t\t#related=,\n\t\t#technical=\n\t),",
+      "\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\"),"
+    )
   ),
+  echo("\n\toverwrite=overwrite,"),
   echo(js.opt.skeleton),
   echo("\n)\n\n"),
   level=2)
@@ -308,9 +329,11 @@
     dialog=sklt.tabbook,
     logic=logic.section),
   js=list(
+    results.header=FALSE,
     require="rkwarddev",
     preprocess=JS.prepare,
-    calculate=JS.calculate),
+    calculate=JS.calculate,
+    printout=""),
   rkh=list(
     summary=rkh.summary,
     usage=rkh.usage





More information about the rkward-tracker mailing list