import groovy.swing.SwingBuilder import java.awt.FlowLayout import com.im.df.api.support.SelectionDescription def updateRow = { rs, field, value -> //variable initiation def rootVS = rs.rootVertexState def rowSelected = null def ety = field.getEntity() def edp = ety.schema.dataProvider.getEntityDataProvider(ety) // Find id of the row to update -- ie. selected row SelectionDescription sel = rootVS.getSelection() if (sel.isSingleRow()) { rowSelected = sel.getMaxSelectionIndex() } else { println "More than one row is selected. The rows have NOT been updated." return } def id = rootVS.ids[rowSelected] //create lock edp.lockable.withLock('Updating') { envRW -> // Assign value to field def vals = [:] vals[field.id] = value // Create the DFUpdateDescription and update the DFEntityDataProvider def ud = DFUpdateDescription.create(ety, id, vals) def submitList = Collections.singletonList(ud) edp.update(submitList, DFUndoConfig.OFF, envRW) } } onDoubleClick = { event -> def swing = new SwingBuilder() def gui = swing.frame(title:'DropDown', size:[200,120], locationRelativeTo: null) { //Create dialog and center position panel(layout:new FlowLayout()) { panel(layout:new FlowLayout()) { comboBox(id:'clinicalTrial', items:["Phase 1", "Phase 2", "Phase 3", "Phase 4"], selectedIndex:2) } panel(layout:new FlowLayout()) { button('OK',preferredSize:[80,24], actionPerformed:{ //An action performed - fetching variables def field = event.widget.boundFields[0] def rs = event.widget.form.resultSet def value = swing.variables.clinicalTrial.selectedItem //and use it as parameters for updateRow method updateRow(rs, field, value) println swing.variables.clinicalTrial.selectedItem // Close dialog dispose() }) button('Cancel',preferredSize:[80,24], actionPerformed:{ dispose() }) } } } gui.show() }
Versions: This script has been tested on IJC version 6.0.