Commit 4c426291 authored by m.eik michalke's avatar m.eik michalke
Browse files

updated export plugin

  - added some of the new features to the generated code
  - fixed some layout and comma issues
parent 03c072b7
## create dialog to build a plugin skeleton
require(rkwarddev)
rkwarddev.required("0.07-4")
rkwarddev.required("0.08-1")
local({
rk.local({
# define where the plugin should write its files
output.dir <- tempdir()
# overwrite an existing plugin in output.dir?
......@@ -23,7 +23,7 @@ about.info <- rk.XML.about(
about=list(desc="GUI interface to create RKWard plugin skeletons",
# the version number should be in line with rkwarddev
# to reflect when the script code was changed
version="0.07-4", url="http://rkward.kde.org")
version="0.08-1", url="http://rkward.kde.org")
)
dependencies.info <- rk.XML.dependencies(dependencies=list(rkward.min="0.6.0"))
......@@ -105,6 +105,7 @@ aboutContact <- rk.XML.frame(
optcolAuthorCre <- rk.XML.optioncolumn(connect=authorCre, modifier="state", id.name="optcolAuthorCre"),
optcolAuthorCtb <- rk.XML.optioncolumn(connect=authorCtb, modifier="state", id.name="optcolAuthorCtb")
),
min_rows=1,
logic=rk.XML.logic(
rk.XML.connect(governor=authorCre, client=authorMail, set="required")
),
......@@ -130,6 +131,8 @@ createOptionsFrame <- rk.XML.frame(
help="If this is checked, a wizard section will be included in the skeleton."),
addTests <- rk.XML.cbox("Include plugin tests", chk=TRUE, id.name="addTests",
help="If this is checked, plugin tests will be included in the skeleton."),
showPlugin <- rk.XML.cbox("Show the plugin", chk=FALSE, id.name="showPlugin",
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.col(
editPlugin <- rk.XML.cbox("Open files for editing", chk=TRUE, id.name="editPlugin",
......@@ -137,15 +140,33 @@ createOptionsFrame <- rk.XML.frame(
addToConfig <- rk.XML.cbox("Add plugin to RKWard configuration", chk=TRUE, id.name="addToConfig",
help="If this is checkend, the generated plugin will automatically be registered in RKWard's configuration.
If you store it in a temporary directory and remove it before the next start of RKWard, the entry will removed again as well."),
showPlugin <- rk.XML.cbox("Show the plugin", chk=FALSE, id.name="showPlugin",
help="If this is checked, the generated plugin will be shown (opened) for you to see what it looks like."),
guessGetters <- rk.XML.cbox("Guess getter functions (RKWard >= 0.6.0)", chk=FALSE, id.name="guessGetters",
help="If this is checked, rkwarddev tries to select the optimal getter functions to get data from the dialog into the R code. The plugin then requires RKWard >= 0.6.0."),
emptyElse <- rk.XML.cbox("Keep empty 'else {}'",
id.name="emptyElse",
help="Some consider it an enhancement for code readability if every \"if\" condition has an \"else\" clause, even if it is empty.
If you check this option, the generated JS code will keep these empty \"else\" clauses."
),
rk.XML.stretch())
),
rk.XML.frame(
rk.XML.row(menuHier <- rk.XML.dropdown("Place in top menu",
options=list(
rk.XML.row(
codeIndent <- rk.XML.dropdown("Code indentation",
options=list(
"Tabs"=c(val="\\t", chk=TRUE),
"Single space"=c(val=" "),
"Two spaces"=c(val=" "),
"Four spaces"=c(val=" ")
),
id.name="codeIndent",
help="Define how the generated code should be indented (by tabs or space characters)."
)
)
),
rk.XML.frame(
rk.XML.row(
menuHier <- 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"),
......@@ -159,12 +180,13 @@ createOptionsFrame <- rk.XML.frame(
"Windows"=c(val="windows"),
"Settings"=c(val="settings"),
"Help"=c(val="help")
),
id.name="menuHier",
help="Specify where the plugin should appear in RKWard's top menus."
),
id.name="menuHier",
help="Specify where the plugin should appear in RKWard's top menus."
),
menuName <- rk.XML.input("Name in menu (plugin name if empty)", id.name="menuName",
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.")
menuName <- rk.XML.input("Name in menu (plugin name if empty)", id.name="menuName",
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."
)
)
),
id.name="createOptionsFrame"
......@@ -288,7 +310,7 @@ js.opt.about.about <- rk.JS.options("optAbout",
} else {},
keep.ite=TRUE
),
funct="list", option="about", collapse=",\\n\\t")
funct="list", option="about", collapse=",\\n\\t", opt.sep=",\\n\\t")
# dependencies section
js.frm.dependencyFrame <- rk.JS.vars(dependencyFrame, modifiers="checked") # see to it frame is checked
js.opt.about.dep <- rk.JS.options("optDependencies",
......@@ -363,8 +385,8 @@ js.opt.skeleton <- rk.JS.options("optSkeleton",
collapse="")
JS.prepare <- rk.paste.JS(
rk.JS.vars(outDir, overwrite, guessGetters),
echo("rkwarddev.required(\"0.07-4\")"),
rk.JS.vars(outDir, overwrite, guessGetters, codeIndent, emptyElse),
echo("rkwarddev.required(\"0.08-1\")"),
echo("\n\n# define where the plugin should write its files\noutput.dir <- "),
js(
if(outDir){
......@@ -383,8 +405,19 @@ JS.prepare <- rk.paste.JS(
echo("TRUE")
} else {
echo("FALSE")
},
echo("\n# define the indentation character for the generated code\nrk.set.indent(by=\"", codeIndent,"\")",
"\n# should empty \"else\" clauses be kept in the JavaScript code?\nrk.set.empty.e("),
if(emptyElse){
echo("TRUE)")
} else {
echo("FALSE)")
}
),
echo(
"\n# make your plugin translatable by setting this to TRUE",
"\nupdate.translations <- FALSE"
),
echo("\n\n"),
level=2)
......@@ -397,14 +430,14 @@ JS.calculate <- rk.paste.JS(
echo("aboutPlugin <- rk.XML.about("),
js(
if(pluginName){
echo("\n\tname=\"", pluginName, "\"")
echo("\n\tname=\"", pluginName, "\",\n")
} else {}
),
# author section
rk.JS.optionset(optionsetAuthors, vars=TRUE, guess.getter=TRUE),
ite(id(optcolAuthorGivenName, " != \"\""),
rk.paste.JS(
echo("\tauthor=c(\n\t\t\t"),
echo("\tauthor=c(\n\t\t"),
rk.JS.optionset(optionsetAuthors,
js.optionsetAuthors.role <- rk.JS.options("optAuthorRole",
.ite=js(
......@@ -435,9 +468,9 @@ JS.calculate <- rk.paste.JS(
level=3
),
echo(")"),
collapse=",\\n\\t\\t\\t"
collapse=",\\n\\t\\t"
),
echo("\n\t\t),\n")
echo("\n\t)")
)
),
echo(js.opt.about.about),
......@@ -533,6 +566,12 @@ JS.calculate <- rk.paste.JS(
echo("\n\t#components=list(),"),
echo(js.opt.skeleton),
echo("\n)\n\n"),
echo(
"\t# you can make your plugin translatable, see top of script",
"\n\tif(isTRUE(update.translations)){",
"\n\t\trk.updatePluginMessages(file.path(output.dir,\"", pluginName, "\",\"inst\",\"rkward\",\"", pluginName, ".pluginmap\"))",
"\n\t} else {}\n\n"
),
level=2)
############
......
......@@ -18,8 +18,8 @@
name="RKWard Plugin Skeleton"
shortinfo="GUI interface to create RKWard plugin skeletons"
longinfo="GUI interface to create RKWard plugin skeletons"
version="0.07-4"
releasedate="2015-11-24"
version="0.08-1"
releasedate="2015-12-05"
url="http://rkward.kde.org"
license="GPL (&gt;= 3)"
>
......
......@@ -12,7 +12,9 @@ function preprocess(){
var outDir = getValue("outDir");
var overwrite = getValue("overwrite");
var guessGetters = getValue("guessGetters");
echo("rkwarddev.required(\"0.07-4\")");
var codeIndent = getValue("codeIndent");
var emptyElse = getValue("emptyElse");
echo("rkwarddev.required(\"0.08-1\")");
echo("\n\n# define where the plugin should write its files\noutput.dir <- ");
if(outDir) {
echo("\"" + outDir + "\"");
......@@ -31,6 +33,13 @@ function preprocess(){
} else {
echo("FALSE");
}
echo("\n# define the indentation character for the generated code\nrk.set.indent(by=\"" + codeIndent + "\")" + "\n# should empty \"else\" clauses be kept in the JavaScript code?\nrk.set.empty.e(");
if(emptyElse) {
echo("TRUE)");
} else {
echo("FALSE)");
}
echo("\n# make your plugin translatable by setting this to TRUE" + "\nupdate.translations <- FALSE");
echo("\n\n");
}
......@@ -53,6 +62,7 @@ function calculate(){
var ocolOptcolAuthorCre = getList("optionsetAuthors.optcolAuthorCre");
var ocolOptcolAuthorCtb = getList("optionsetAuthors.optcolAuthorCtb");
var outDir = getString("outDir");
var codeIndent = getString("codeIndent");
var menuHier = getString("menuHier");
var menuName = getString("menuName");
var RKMin = getString("RKMin");
......@@ -75,77 +85,78 @@ function calculate(){
var overwrite = getBoolean("overwrite.state");
var addWizard = getBoolean("addWizard.state");
var addTests = getBoolean("addTests.state");
var showPlugin = getBoolean("showPlugin.state");
var editPlugin = getBoolean("editPlugin.state");
var addToConfig = getBoolean("addToConfig.state");
var showPlugin = getBoolean("showPlugin.state");
var guessGetters = getBoolean("guessGetters.state");
var emptyElse = getBoolean("emptyElse.state");
var dependencyFrameChecked = getBoolean("dependencyFrame.checked");
var helpTextChecked = getBoolean("helpText.checked");
// the R code to be evaluated
// define the array arrOptAbout for values of R option "about"
var arrOptAbout = new Array();
if(pluginDescription) {
arrOptAbout.push("desc=\"" + pluginDescription + "\"" );
} else {
arrOptAbout.push();
}
if(pluginVersion) {
arrOptAbout.push("version=\"" + pluginVersion + "\"" );
} else {
arrOptAbout.push();
}
if(pluginDate) {
arrOptAbout.push("date=\"" + pluginDate + "\"" );
} else {
arrOptAbout.push();
}
if(pluginHomepage) {
arrOptAbout.push("url=\"" + pluginHomepage + "\"" );
} else {
arrOptAbout.push();
}
if(pluginLicense) {
arrOptAbout.push("license=\"" + pluginLicense + "\"" );
} else {
arrOptAbout.push();
}
if(pluginCategory) {
arrOptAbout.push("category=\"" + pluginCategory + "\"" );
} else {
arrOptAbout.push();
}
if(pluginDescription) {
arrOptAbout.push("desc=\"" + pluginDescription + "\"" );
} else {
arrOptAbout.push();
}
if(pluginVersion) {
arrOptAbout.push("version=\"" + pluginVersion + "\"" );
} else {
arrOptAbout.push();
}
if(pluginDate) {
arrOptAbout.push("date=\"" + pluginDate + "\"" );
} else {
arrOptAbout.push();
}
if(pluginHomepage) {
arrOptAbout.push("url=\"" + pluginHomepage + "\"" );
} else {
arrOptAbout.push();
}
if(pluginLicense) {
arrOptAbout.push("license=\"" + pluginLicense + "\"" );
} else {
arrOptAbout.push();
}
if(pluginCategory) {
arrOptAbout.push("category=\"" + pluginCategory + "\"" );
} else {
arrOptAbout.push();
}
// clean array arrOptAbout from empty strings
arrOptAbout = arrOptAbout.filter(String);
// set the actual variable optAbout with all values for R option "about"
if(arrOptAbout.length > 0) {
var optAbout = ", about=list(" + arrOptAbout.join(", ") + ")";
var optAbout = ",\n\tabout=list(" + arrOptAbout.join(", ") + ")";
} else {
var optAbout = "";
}
// define the array arrOptDependencies for values of R option "dependencies"
var arrOptDependencies = new Array();
if(dependencyFrameChecked && RKMin) {
arrOptDependencies.push("rkward.min=\"" + RKMin + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RKMax) {
arrOptDependencies.push("rkward.max=\"" + RKMax + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RMin) {
arrOptDependencies.push("R.min=\"" + RMin + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RMax) {
arrOptDependencies.push("R.max=\"" + RMax + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RKMin) {
arrOptDependencies.push("rkward.min=\"" + RKMin + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RKMax) {
arrOptDependencies.push("rkward.max=\"" + RKMax + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RMin) {
arrOptDependencies.push("R.min=\"" + RMin + "\"" );
} else {
arrOptDependencies.push();
}
if(dependencyFrameChecked && RMax) {
arrOptDependencies.push("R.max=\"" + RMax + "\"" );
} else {
arrOptDependencies.push();
}
// clean array arrOptDependencies from empty strings
arrOptDependencies = arrOptDependencies.filter(String);
// set the actual variable optDependencies with all values for R option "dependencies"
......@@ -157,16 +168,16 @@ function calculate(){
// define the array arrOptPluginmap for values of R option "pluginmap"
var arrOptPluginmap = new Array();
if(menuName) {
arrOptPluginmap.push("name=\"" + menuName + "\"" );
} else {
arrOptPluginmap.push("name=\"" + pluginName + "\"" );
}
if(menuHier) {
arrOptPluginmap.push("hierarchy=\"" + menuHier + "\"" );
} else {
arrOptPluginmap.push();
}
if(menuName) {
arrOptPluginmap.push("name=\"" + menuName + "\"" );
} else {
arrOptPluginmap.push("name=\"" + pluginName + "\"" );
}
if(menuHier) {
arrOptPluginmap.push("hierarchy=\"" + menuHier + "\"" );
} else {
arrOptPluginmap.push();
}
// clean array arrOptPluginmap from empty strings
arrOptPluginmap = arrOptPluginmap.filter(String);
// set the actual variable optPluginmap with all values for R option "pluginmap"
......@@ -178,36 +189,36 @@ function calculate(){
// define the array arrOptSkeleton for values of R option ""
var arrOptSkeleton = new Array();
if(addWizard) {
arrOptSkeleton.push("\n\tprovides=c(\"logic\", \"dialog\", \"wizard\")" );
} else {
arrOptSkeleton.push("\n\t#provides=c(\"logic\", \"dialog\")" );
}
if(optPluginmap) {
arrOptSkeleton.push("\n\t" + optPluginmap );
} else {
arrOptSkeleton.push("\n\t#pluginmap=list(name=\"\", hierarchy=\"\", require=\"\")" );
}
if(addTests) {
arrOptSkeleton.push("\n\ttests=TRUE" );
} else {
arrOptSkeleton.push("\n\ttests=FALSE" );
}
if(editPlugin) {
arrOptSkeleton.push("\n\tedit=TRUE" );
} else {
arrOptSkeleton.push("\n\tedit=FALSE" );
}
if(addToConfig) {
arrOptSkeleton.push("\n\tload=TRUE" );
} else {
arrOptSkeleton.push("\n\tload=FALSE" );
}
if(showPlugin) {
arrOptSkeleton.push("\n\tshow=TRUE" );
} else {
arrOptSkeleton.push("\n\tshow=FALSE" );
}
if(addWizard) {
arrOptSkeleton.push("\n\tprovides=c(\"logic\", \"dialog\", \"wizard\")" );
} else {
arrOptSkeleton.push("\n\t#provides=c(\"logic\", \"dialog\")" );
}
if(optPluginmap) {
arrOptSkeleton.push("\n\t" + optPluginmap );
} else {
arrOptSkeleton.push("\n\t#pluginmap=list(name=\"\", hierarchy=\"\", require=\"\")" );
}
if(addTests) {
arrOptSkeleton.push("\n\ttests=TRUE" );
} else {
arrOptSkeleton.push("\n\ttests=FALSE" );
}
if(editPlugin) {
arrOptSkeleton.push("\n\tedit=TRUE" );
} else {
arrOptSkeleton.push("\n\tedit=FALSE" );
}
if(addToConfig) {
arrOptSkeleton.push("\n\tload=TRUE" );
} else {
arrOptSkeleton.push("\n\tload=FALSE" );
}
if(showPlugin) {
arrOptSkeleton.push("\n\tshow=TRUE" );
} else {
arrOptSkeleton.push("\n\tshow=FALSE" );
}
// clean array arrOptSkeleton from empty strings
arrOptSkeleton = arrOptSkeleton.filter(String);
// set the actual variable optSkeleton with all values for R option ""
......@@ -219,7 +230,7 @@ function calculate(){
echo("aboutPlugin <- rk.XML.about(");
if(pluginName) {
echo("\n\tname=\"" + pluginName + "\"");
echo("\n\tname=\"" + pluginName + "\",\n");
} else {}
var ocolOptcolAuthorGivenName = getList("optionsetAuthors.optcolAuthorGivenName");
var ocolOptcolAuthorFamiliyName = getList("optionsetAuthors.optcolAuthorFamiliyName");
......@@ -228,32 +239,32 @@ function calculate(){
var ocolOptcolAuthorCre = getList("optionsetAuthors.optcolAuthorCre");
var ocolOptcolAuthorCtb = getList("optionsetAuthors.optcolAuthorCtb");
if(ocolOptcolAuthorGivenName != "") {
echo("\tauthor=c(\n\t\t\t");
echo("\tauthor=c(\n\t\t");
for (var i = 0; i < ocolOptcolAuthorGivenName.length; ++i){
// define the array arrOptAuthorRole for values of R option "role"
var arrOptAuthorRole = new Array();
if(ocolOptcolAuthorAut[i] == 1) {
arrOptAuthorRole.push("\"aut\"" );
} else {
arrOptAuthorRole.push();
}
if(ocolOptcolAuthorCre[i] == 1) {
arrOptAuthorRole.push("\"cre\"" );
} else {
arrOptAuthorRole.push();
}
if(ocolOptcolAuthorCtb[i] == 1) {
arrOptAuthorRole.push("\"ctb\"" );
} else {
arrOptAuthorRole.push();
}
if(ocolOptcolAuthorAut[i] == 1) {
arrOptAuthorRole.push("\"aut\"" );
} else {
arrOptAuthorRole.push();
}
if(ocolOptcolAuthorCre[i] == 1) {
arrOptAuthorRole.push("\"cre\"" );
} else {
arrOptAuthorRole.push();
}
if(ocolOptcolAuthorCtb[i] == 1) {
arrOptAuthorRole.push("\"ctb\"" );
} else {
arrOptAuthorRole.push();
}
// clean array arrOptAuthorRole from empty strings
arrOptAuthorRole = arrOptAuthorRole.filter(String);
// set the actual variable optAuthorRole with all values for R option "role"
if(arrOptAuthorRole.length > 0) {
var optAuthorRole = ", role=c(" + arrOptAuthorRole.join(", ") + ")";
var optAuthorRole = ", role=c(" + arrOptAuthorRole.join(", ") + ")";
} else {
var optAuthorRole = "";
var optAuthorRole = "";
}
echo("person(");
......@@ -269,10 +280,10 @@ function calculate(){
} else {}
echo(")");
if(i + 1 < ocolOptcolAuthorGivenName.length) {
echo(",\n\t\t\t");
echo(",\n\t\t");
}
}
echo("\n\t\t),\n");
echo("\n\t)");
} else {}
echo(optAbout);
echo("\n)\n\n");
......@@ -287,9 +298,9 @@ function calculate(){
if(ocolOptcolPckgName!= "") {
echo("\n\tpackage=list(\n\t\t");
for (var i = 0; i < ocolOptcolPckgName.length; ++i){
echo("c(");
echo("name=\"" + ocolOptcolPckgName[i] + "\"");
if(ocolOptcolPckgMin[i]) {
echo("c(");
echo("name=\"" + ocolOptcolPckgName[i] + "\"");
if(ocolOptcolPckgMin[i]) {
echo(", min=\"" + ocolOptcolPckgMin[i] + "\"");
} else {}
if(ocolOptcolPckgMax[i]) {
......@@ -298,7 +309,7 @@ function calculate(){
if(ocolOptcolPckgRepo[i]) {
echo(", repository=\"" + ocolOptcolPckgRepo[i] + "\"");
} else {}
echo(")");
echo(")");
if(i + 1 < ocolOptcolPckgName.length) {
echo(",\n\t\t");
}
......@@ -339,6 +350,7 @@ function calculate(){
echo("\n\t#components=list(),");
echo(optSkeleton);
echo("\n)\n\n");
echo("\t# you can make your plugin translatable, see top of script" + "\n\tif(isTRUE(update.translations)){" + "\n\t\trk.updatePluginMessages(file.path(output.dir,\"" + pluginName + "\",\"inst\",\"rkward\",\"" + pluginName + ".pluginmap\"))" + "\n\t} else {}\n\n");
}
function printout(){
......
......@@ -77,6 +77,9 @@
<setting id="addTests">
If this is checked, plugin tests will be included in the skeleton.
</setting>
<setting id="showPlugin">
If this is checked, the generated plugin will be shown (opened) for you to see what it looks like.
</setting>
<setting id="editPlugin">
If this is checked, all generated files will be opened for editing instantly.
</setting>
......@@ -84,12 +87,17 @@
If this is checkend, the generated plugin will automatically be registered in RKWard's configuration.
If you store it in a temporary directory and remove it before the next start of RKWard, the entry will removed again as well.
</setting>
<setting id="showPlugin">
If this is checked, the generated plugin will be shown (opened) for you to see what it looks like.
</setting>
<setting id="guessGetters">
If this is checked, rkwarddev tries to select the optimal getter functions to get data from the dialog into the R code. The plugin then requires RKWard &gt;= 0.6.0.
</setting>
<setting id="emptyElse">
Some consider it an enhancement for code readability if every "if" condition has an "else" clause, even if it is empty.
If you check this option, the generated JS code will keep these empty "else" clauses.
</setting>
<caption id="frm_rICTSTFICT" />
<setting id="codeIndent">
Define how the generated code should be indented (by tabs or space characters).
</setting>
<caption id="frm_rHPTFEVWRD" />
<setting id="menuHier">
Specify where the plugin should appear in RKWard's top menus.
......
......@@ -34,8 +34,8 @@
</row>
</frame>
<frame label="Plugin author" id="aboutContact">
<row id="row_oACMPPPCFG">
<optionset id="optionsetAuthors">
<row id="row_oA1CMPPPCF">