Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Make sure you are in the root directory of your project (for argument sake "DemoConsole", a simple script evaluator) by typing

Code Block
cd my-projectDemoConsole

The "create-app" target created a Griffon MVC Triad for you in the models, views, and controllers directory named after the application. hence you already have a model class DemoConsoleModel in the models directory.

...

Code Block
titleDemoConsoleView.groovy
mainPanel = application(title:'DemoConsole', pack:true, locationByPlatform:true) {
  panel(border:emptyBorder(6)) {
    borderLayout()

    scrollPane(constraints:CENTER) {
      textArea(text:bind(target:model, targetProperty:'scriptSource'),
        enabled: bind {model.enabled},
        columns:40, rows:10)
    }

    hbox(constraints:SOUTH) {
      button("Execute", actionPerformed:controller.&executeScript, 
        enabled: bind {model.enabled})
      hstrut(5)
      label("Result:")
      hstrut(5)
      label(text:bind {model.scriptResult})
    }
  }
}

The view script is a fairly straightforward SwingBuilder script. Griffon will execute these groovy scripts in context of it's UberBuilder (a composit of the SwingBuilder and whatever else is thrown in).

...