groovy

Create action without parent

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-beta-4
  • Fix Version/s: 1.0-beta-6
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    2

Description

Currently in SwingBuilder it is not possible to create an action object in SwingBuilder without assigning it to a parent. This make it more difficult to create an action and assign it to multiple widgets. Currently, it can somewhat awkwardly like this:

builder.frame() {
actions = [:]

menuBar() {
menu( text: "File" ) {
actions.exit = menuItem( action(name: "Exit",
closure: { System.exit(0) } )
)
}
}

button( action: actions.exit )
}

The problem is the form is less clear and requires you to create this map object. It might be nicer to have a section in the builder where actions are declared seperately and stored referred to by variable names:

builder.frame() {
// Action Section
exit = action( name:"Exit", closure: {System.exit(0)} )

// Menu Section
menuBar() {
menu( text:"File" ) { menuItem( action:exit ) }
}

// Content
button( action: exit )
}

  1. SwingBuilder.java.patch
    29/Mar/04 2:17 PM
    0.7 kB
    Rapheal Kaplan
  2. SwingDemo.groovy.patch
    29/Mar/04 2:18 PM
    0.9 kB
    Rapheal Kaplan

Activity

Hide
Rapheal Kaplan added a comment -

Patch for groovy.swing.SwingBuilder

Show
Rapheal Kaplan added a comment - Patch for groovy.swing.SwingBuilder
Hide
Rapheal Kaplan added a comment -

Patch for testing SwingBuilder to use detached actions.

Show
Rapheal Kaplan added a comment - Patch for testing SwingBuilder to use detached actions.
Hide
Chris Poirier added a comment -

Hi James: there's a patch waiting with this one.

Show
Chris Poirier added a comment - Hi James: there's a patch waiting with this one.
Hide
Danno Ferrin added a comment -

A similar patch for SwingBuilder is in GROOVY-333, but RuntimeException is caught. SwingDemo is not addressed in GROOVY-333.

Show
Danno Ferrin added a comment - A similar patch for SwingBuilder is in GROOVY-333, but RuntimeException is caught. SwingDemo is not addressed in GROOVY-333.
Hide
Guillaume Laforge added a comment -

Fixed by GROOVY-501

Show
Guillaume Laforge added a comment - Fixed by GROOVY-501

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: