Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-328

Create action without parent

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-4
    • 1.0-beta-6
    • None
    • None

    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 )
      }

      Attachments

        1. SwingBuilder.java.patch
          0.7 kB
          Rapheal Kaplan
        2. SwingDemo.groovy.patch
          0.9 kB
          Rapheal Kaplan

        Activity

          People

            guillaume Guillaume Sauthier
            slobberchops Rapheal Kaplan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: