transferring list of selected variables to a subdialog

15 views
Skip to first unread message

Vincent

unread,
Nov 10, 2012, 4:56:20 AM11/10/12
to ded...@googlegroups.com
I made a dialog where independent variables get selected from a variableSelectorWidget.

variableSelector <-new(VariableSelectorWidget)
variableSelector$setTitle("data")
variableList <- new(VariableListWidget, variableSelector)
addComponent(dialog, variableSelector,1,450,850,10)

indep <- new(VariableListWidget, "Independent Variables", variableSelector)
indep$setTitle("indep")
addComponent(dialog, indep, 120 ,1000, 400, 500)

Using the example on the Deducer website I was able to make a subdialog. In that subdialog I would like user to make a further selection out of the previously selected independent variables.

VariableSelectorWidgets seem to have a getSelectedVariables() function. However, I couldn't find a similar method for a VariableListWidget.

Any suggestions (examples) on how to do this? Thanks.

Ian Fellows

unread,
Nov 10, 2012, 2:17:25 PM11/10/12
to ded...@googlegroups.com
indep$getVariables()

will get you the variables in the VariableListWidget. Is That what you
are looking for?

best,
ian

Vincent

unread,
Nov 13, 2012, 4:39:24 AM11/13/12
to ded...@googlegroups.com
Yes! That worked great. In case it might be useful to others trying the same things I pasted what I came up with below. The dialog for the restrictions to test is not (fully) created and sized until it is known how many independent variables were selected the user (indep). 

This does seem to work pretty nicely but if there is a better way to do this I would luv to hear about it.

JButton <- J("javax.swing.JButton")
button <- new(JButton,"Coeffient test")
addComponent(dialog,button,780,980,870,640)

subDialog <- new(SimpleRSubDialog,dialog,"Coeffient test")

ActionListener <- J("org.rosuda.deducer.widgets.event.RActionListener")
actionFunction <- function(cmd,ActionEvent){

nr.indep <- length(indep$getVariables())
if(nr.indep > 0) {
subDialog <- new(SimpleRSubDialog,dialog,"Coeffient test")

size <- nr.indep * 80
if(nr.indep == 1) 
size <- size + 50

setSize(subDialog,260,size)
coeft <- new(CheckBoxesWidget,"Coefficient test", .jarray(indep$getVariables())
coeft$setTitle("coeft")
addComponent(subDialog, coeft,10,950,600,50)

subDialog$setLocationRelativeTo(button)
subDialog$run()
}

}

listener <- new(ActionListener)
listener$setFunction(toJava(actionFunction))
button$addActionListener(listener)
Reply all
Reply to author
Forward
0 new messages