Browse files

Refactoring menu entry modification to its own function.

  • Loading branch information...
1 parent 2579518 commit 5dec97cac9ca95abe83a782ccc684e76e7be2626 @sjp committed Feb 29, 2012
Showing with 106 additions and 272 deletions.
  1. +1 −0 DESCRIPTION
  2. +2 −46 R/gui-CI.R
  3. +2 −46 R/gui-bootstrap.R
  4. +1 −31 R/gui-functions.R
  5. +94 −0 R/gui-menus.R
  6. +2 −45 R/gui-permutation.R
  7. +2 −59 R/gui-permvar.R
  8. +2 −45 R/gui-sampvar.R
View
1 DESCRIPTION
@@ -41,6 +41,7 @@ Collate:
'gui-environment.R'
'gui-functions.R'
'gui-interface.R'
+ 'gui-menus.R'
'gui-permutation.R'
'gui-permvar.R'
'gui-sampvar.R'
View
48 R/gui-CI.R
@@ -1,52 +1,8 @@
CIGUIHandler <- function(e){
e$method <- "ci"
- tmp.g.menu <- e$g.menu[]
- # Setting GUI menu entries for when we want to change modules
- m1entry <- gaction("Randomisation tests", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Randomisation tests"
- setupGUI(e)
- permGUIHandler(e)
- dataGUI(e)
- })
- })
- m2entry <- gaction("Sampling variation", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Sampling variation"
- setupGUI(e)
- sampvarGUIHandler(e)
- dataGUI(e)
- })
- })
- m3entry <- gaction("Bootstrap confidence intervals", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Bootstrap confidence intervals"
- setupGUI(e)
- bootstrapGUIHandler(e)
- dataGUI(e)
- })
- })
-
- tmp.g.menu$File$"VIT Modules"$Module1 <- m1entry
- tmp.g.menu$File$"VIT Modules"$Module2 <- m2entry
- tmp.g.menu$File$"VIT Modules"$Module3 <- m3entry
- svalue(e$g.menu) <- tmp.g.menu
+ # Rewriting the menus to link only to other modules
+ svalue(e$g.menu) <- getModuleMenu(e)
e$data.boxes <- FALSE
e$replace <- FALSE
View
48 R/gui-bootstrap.R
@@ -1,52 +1,8 @@
bootstrapGUIHandler <- function(e){
e$method <- "bootstrap"
- tmp.g.menu <- e$g.menu[]
- # Setting GUI menu entries for when we want to change modules
- m1entry <- gaction("Randomisation tests", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Randomisation tests"
- setupGUI(e)
- permGUIHandler(e)
- dataGUI(e)
- })
- })
- m2entry <- gaction("Sampling variation", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Sampling variation"
- setupGUI(e)
- sampvarGUIHandler(e)
- dataGUI(e)
- })
- })
- m3entry <- gaction("Confidence interval coverage", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Confidence interval coverage"
- setupGUI(e)
- CIGUIHandler(e)
- dataGUI(e)
- })
- })
-
- tmp.g.menu$File$"VIT Modules"$Module1 <- m1entry
- tmp.g.menu$File$"VIT Modules"$Module2 <- m2entry
- tmp.g.menu$File$"VIT Modules"$Module3 <- m3entry
- svalue(e$g.menu) <- tmp.g.menu
+ # Rewriting the menus to link only to other modules
+ svalue(e$g.menu) <- getModuleMenu(e)
e$data.boxes <- TRUE
e$replace <- TRUE
View
32 R/gui-functions.R
@@ -84,40 +84,10 @@ setupGUI <- function(e){
}
})
- mModule1 <- gaction("Change To M1", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- e$homefun()
- })
- })
- mModule2 <- gaction("Change To M2", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- e$homefun()
- })
- })
- mModule3 <- gaction("Change To M3", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- e$homefun()
- })
- })
-
- mModules <- list(Module1 = mModule1, Module2 = mModule2)#, Module3 = mModule3)
-
# Compiling elements into a menu
e$g.menu <- gmenu(list(File = list(Save = mSave, Print = mPrint,
sep = sep,
- Home = mHome, Reload = mReload, "VIT Modules" = mModules,
+ Home = mHome, Reload = mReload, "VIT Modules" = list(),
qsep = sep,
Quit = mQuit)),
container = e$win)
View
94 R/gui-menus.R
@@ -0,0 +1,94 @@
+getModuleMenu <- function(e) {
+ tmp.g.menu <- e$g.menu[]
+
+ # Setting GUI menu entries for when we want to change modules
+ permvar.menu <- gaction("Randomisation variation", handler = function(...) {
+ e$confirmDialog("Do you wish to change modules?",
+ handler = function(...) {
+ dispose(e$win)
+ dispose(e$window)
+ dev.off()
+ dev.new(height = 50, width = 75)
+ e$title <- "Randomisation variation"
+ setupGUI(e)
+ permvarGUIHandler(e)
+ dataGUI(e)
+ })
+ })
+ perm.menu <- gaction("Randomisation tests", handler = function(...) {
+ e$confirmDialog("Do you wish to change modules?",
+ handler = function(...) {
+ dispose(e$win)
+ dispose(e$window)
+ dev.off()
+ dev.new(height = 50, width = 75)
+ e$title <- "Randomisation tests"
+ setupGUI(e)
+ permGUIHandler(e)
+ dataGUI(e)
+ })
+ })
+ sampvar.menu <- gaction("Sampling variation", handler = function(...) {
+ e$confirmDialog("Do you wish to change modules?",
+ handler = function(...) {
+ dispose(e$win)
+ dispose(e$window)
+ dev.off()
+ dev.new(height = 50, width = 50)
+ e$title <- "Sampling variation"
+ setupGUI(e)
+ sampvarGUIHandler(e)
+ dataGUI(e)
+ })
+ })
+ bootstrap.menu <- gaction("Bootstrap confidence intervals", handler = function(...) {
+ e$confirmDialog("Do you wish to change modules?",
+ handler = function(...) {
+ dispose(e$win)
+ dispose(e$window)
+ dev.off()
+ dev.new(height = 50, width = 75)
+ e$title <- "Bootstrap confidence intervals"
+ setupGUI(e)
+ bootstrapGUIHandler(e)
+ dataGUI(e)
+ })
+ })
+ ci.menu <- gaction("Confidence interval coverage", handler = function(...) {
+ e$confirmDialog("Do you wish to change modules?",
+ handler = function(...) {
+ dispose(e$win)
+ dispose(e$window)
+ dev.off()
+ dev.new(height = 50, width = 50)
+ e$title <- "Confidence interval coverage"
+ setupGUI(e)
+ CIGUIHandler(e)
+ dataGUI(e)
+ })
+ })
+
+ all.menus <- list(permvar.menu, perm.menu, sampvar.menu,
+ bootstrap.menu, ci.menu)
+ menu.names <- c("Randomisation variation",
+ "Randomisation tests",
+ "Sampling variation",
+ "Bootstrap confidence intervals",
+ "Confidence interval coverage")
+
+ if (e$method == "permvar")
+ ind <- 1
+ if (e$method == "permutation")
+ ind <- 2
+ if (e$method == "sampvar")
+ ind <- 3
+ if (e$method == "bootstrap")
+ ind <- 4
+ if (e$method == "ci")
+ ind <- 5
+
+ tmp.g.menu$File$"VIT Modules" <- all.menus[-ind]
+ names(tmp.g.menu$File$"VIT Modules") <- menu.names[-ind]
+
+ tmp.g.menu
+}
View
47 R/gui-permutation.R
@@ -1,51 +1,8 @@
permGUIHandler <- function(e){
e$method <- "permutation"
- tmp.g.menu <- e$g.menu[]
- # Setting GUI menu entries for when we want to change modules
- m1entry <- gaction("Sampling variation", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Sampling variation"
- setupGUI(e)
- sampvarGUIHandler(e)
- dataGUI(e)
- })
- })
- m2entry <- gaction("Bootstrap confidence intervals", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Bootstrap confidence intervals"
- setupGUI(e)
- bootstrapGUIHandler(e)
- dataGUI(e)
- })
- })
- m3entry <- gaction("Confidence interval coverage", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Confidence interval coverage"
- setupGUI(e)
- CIGUIHandler(e)
- dataGUI(e)
- })
- })
- tmp.g.menu$File$"VIT Modules"$Module1 <- m1entry
- tmp.g.menu$File$"VIT Modules"$Module2 <- m2entry
- tmp.g.menu$File$"VIT Modules"$Module3 <- m3entry
- svalue(e$g.menu) <- tmp.g.menu
+ # Rewriting the menus to link only to other modules
+ svalue(e$g.menu) <- getModuleMenu(e)
e$data.boxes <- TRUE
e$replace <- FALSE
View
61 R/gui-permvar.R
@@ -1,65 +1,8 @@
permvarGUIHandler <- function(e) {
e$method <- "permvar"
- tmp.g.menu <- e$g.menu[]
- # Setting GUI menu entries for when we want to change modules
- m1entry <- gaction("Randomisation tests", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Randomisation tests"
- setupGUI(e)
- permGUIHandler(e)
- dataGUI(e)
- })
- })
- m2entry <- gaction("Sampling variation", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Sampling variation"
- setupGUI(e)
- sampvarGUIHandler(e)
- dataGUI(e)
- })
- })
- m3entry <- gaction("Bootstrap confidence intervals", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Bootstrap confidence intervals"
- setupGUI(e)
- bootstrapGUIHandler(e)
- dataGUI(e)
- })
- })
- m4entry <- gaction("Confidence interval coverage", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Confidence interval coverage"
- setupGUI(e)
- CIGUIHandler(e)
- dataGUI(e)
- })
- })
- tmp.g.menu$File$"VIT Modules"$Module1 <- m1entry
- tmp.g.menu$File$"VIT Modules"$Module2 <- m2entry
- tmp.g.menu$File$"VIT Modules"$Module3 <- m3entry
- tmp.g.menu$File$"VIT Modules"$Module4 <- m4entry
- svalue(e$g.menu) <- tmp.g.menu
+ # Rewriting the menus to link only to other modules
+ svalue(e$g.menu) <- getModuleMenu(e)
e$data.boxes <- TRUE
e$replace <- FALSE
View
47 R/gui-sampvar.R
@@ -1,51 +1,8 @@
sampvarGUIHandler <- function(e){
e$method <- "sampvar"
- tmp.g.menu <- e$g.menu[]
- # Setting GUI menu entries for when we want to change modules
- m1entry <- gaction("Randomisation tests", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Randomisation tests"
- setupGUI(e)
- permGUIHandler(e)
- dataGUI(e)
- })
- })
- m2entry <- gaction("Bootstrap confidence intervals", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 75)
- e$title <- "Bootstrap confidence intervals"
- setupGUI(e)
- bootstrapGUIHandler(e)
- dataGUI(e)
- })
- })
- m3entry <- gaction("Confidence interval coverage", handler = function(...) {
- e$confirmDialog("Do you wish to change modules?",
- handler = function(...) {
- dispose(e$win)
- dispose(e$window)
- dev.off()
- dev.new(height = 50, width = 50)
- e$title <- "Confidence interval coverage"
- setupGUI(e)
- CIGUIHandler(e)
- dataGUI(e)
- })
- })
- tmp.g.menu$File$"VIT Modules"$Module1 <- m1entry
- tmp.g.menu$File$"VIT Modules"$Module2 <- m2entry
- tmp.g.menu$File$"VIT Modules"$Module3 <- m3entry
- svalue(e$g.menu) <- tmp.g.menu
+ # Rewriting the menus to link only to other modules
+ svalue(e$g.menu) <- getModuleMenu(e)
e$data.boxes <- FALSE
e$replace <- FALSE

0 comments on commit 5dec97c

Please sign in to comment.