Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Griffon “Griffon is a Grails like application framework for developing desktop applications in Groovy.”
What is Griffon? framework for developing Swing apps Groovy based, Grails inspired extensible by plugins MVC convention over configuration aims to make build Swing apps easy!
State of Swing very verbose to get it right public void actionPerformed(ActionEvent e) {      (new Thread(new Runnable() {          public void run() {              final String result = longRunningOperation();              SwingUtilities.invokeLater(new Runnable() {                  public void run() {                      label.setText(result);                  }              });          }      }).start(); } final JLabel label = ... ; class MeaningOfLifeFinder extends SwingWorker<String, Object> { @Override public String doInBackground() { return findTheMeaningOfLife(); } @Override protected void done() { try {  label.setText(get()); } catch (Exception ignore) { } } } (new MeaningOfLifeFinder()).execute(); SwingWorker helps with the pattern
Groovy helps a lot SwingBuilder DSL for fluent syntax shortened forms and simplified configuration Java: JPanel panel = new JPanel();  new BoxLayout(panel, BoxLayout.X_AXIS) Groovy: panel { boxLayout() } map coercion VS constructors huge reduction in boilerplate simple Binding
Griffon helps even more CompositeBuilder: combines numerous builders into one common dsl IGriffonApplication: provides a common infrastructure  meta-enhancement: additional methods added to Swing components at run-time makes publishing and launching easy
Builders SwingXBuilder - Swing component extensions FxBuilder - JavaFX script support JideBuilder - Swing component extensions SwingXtrasBuilder - aggregate of 3 smaller Swing component extensions(I2fprod, BalloonTip, xswingx) CSSBuilder - Swing Clarity: adds cssClass property to all Swing nodes TridentBuilder - animation library GfxBuilder - Java 2D(without pulling your hair out)
App Configuration Your A, B, C’s Application.groovy- title, root MVC group to initialize on startup, all MVC groups registered in the app Builder.groovy - CompositeBuilder configuration Config.groovy - logging, dev/test/prod environments, additional build script or lifecycle event configuration
App Lifecycle Initialize - before any Swing code is realized; used for L&F and setup Startup - after startup MVC groups are initialized Ready - all events sent to EDT queue have been processed Shutdown - opportunity to free resources before exit Stop - Applet specific
Distribution and Installation stand-alone, webstart and applet support  create launchers for Windows(.exe), Linux(shell script), Mac(.app) and as executable jar create installers using IzPack, RPM and DMG  ‘big jar’ support for those lucky people in the US who can use the Java Store can create all installers and launchers in one step
Testing and Analysis FEST - framework for Swing integration testing; equivalent of Selenium for Web testing EasyB - scenario based testing Cobertura - code coverage metrics JDepend - static analysis
Language support Scala - plugin available Clojure - plugin available Java - if you REALLY want :)
The EDT in Groovy doOutside{ //long running operations in a new thread edt { //jump back to the EDT if needed } doLater{ //update the UI when we’re done } }
EDT With SwingWorker in Griffon in Griffon jxwithWorker {onInit {  //setup  }  work { //do long running work and publish intermediate results publish(...)  } onUpdate {  //respond to intermediate results  }  onDone { //update UI with final results  }} //update UI with final results  }} //update UI with final results  }} //update UI with final results  }} //update UI with final results  }} //update UI with final results  }}
How to get Griffon? download the izpack installer macports install from source - set $GRIFFON_HOME and put $GRIFFON_HOME/bin in your path, there’s an ant target to install tonite’s demo was 0.2-SNAPSHOT built from source
How to use Griffon? On the command line create/run/test Applications create MVC groups or their individual components create tests install/uninstall plugins create your own plugins run a shell/console with your Application on the classpath ...
Tool support Netbeans - Geertjan Wielenga crafted an alpha version plugin for Java One this year Intellij - Maia (version 9, in EAP now) parallels existing Grails support  Eclipse - Groovy plugin, no specific support for Griffon; yet Griffon in Action has instructions for each of these IDE’s without plugins, based on ant
IntelliJ Maia Closeup Project view showing libraries/plugins Griffon MVC plugin view
What’s to come? Spring plugin Maven Gradle Grails plugin ports Griffon In Action from Manning Books
How much code does it take? +----------------------+-------+-------+  | Name  | Files |  LOC  |  +----------------------+-------+-------+  | Controllers  |  4 |  112 |  | Models  |  4 |  26 |  | Views  |  4 |  122 |  | Lifecycle  |  5 |  76 |  | Integration Tests  |  1 |  4 |  +----------------------+-------+-------+  | Totals  |  18 |  340 |  +----------------------+-------+-------+
Questions ???

More Related Content

Griffon Presentation

  • 1. Griffon “Griffon is a Grails like application framework for developing desktop applications in Groovy.”
  • 2. What is Griffon? framework for developing Swing apps Groovy based, Grails inspired extensible by plugins MVC convention over configuration aims to make build Swing apps easy!
  • 3. State of Swing very verbose to get it right public void actionPerformed(ActionEvent e) {      (new Thread(new Runnable() {          public void run() {              final String result = longRunningOperation();              SwingUtilities.invokeLater(new Runnable() {                  public void run() {                      label.setText(result);                  }              });          }      }).start(); } final JLabel label = ... ; class MeaningOfLifeFinder extends SwingWorker<String, Object> { @Override public String doInBackground() { return findTheMeaningOfLife(); } @Override protected void done() { try { label.setText(get()); } catch (Exception ignore) { } } } (new MeaningOfLifeFinder()).execute(); SwingWorker helps with the pattern
  • 4. Groovy helps a lot SwingBuilder DSL for fluent syntax shortened forms and simplified configuration Java: JPanel panel = new JPanel(); new BoxLayout(panel, BoxLayout.X_AXIS) Groovy: panel { boxLayout() } map coercion VS constructors huge reduction in boilerplate simple Binding
  • 5. Griffon helps even more CompositeBuilder: combines numerous builders into one common dsl IGriffonApplication: provides a common infrastructure meta-enhancement: additional methods added to Swing components at run-time makes publishing and launching easy
  • 6. Builders SwingXBuilder - Swing component extensions FxBuilder - JavaFX script support JideBuilder - Swing component extensions SwingXtrasBuilder - aggregate of 3 smaller Swing component extensions(I2fprod, BalloonTip, xswingx) CSSBuilder - Swing Clarity: adds cssClass property to all Swing nodes TridentBuilder - animation library GfxBuilder - Java 2D(without pulling your hair out)
  • 7. App Configuration Your A, B, C’s Application.groovy- title, root MVC group to initialize on startup, all MVC groups registered in the app Builder.groovy - CompositeBuilder configuration Config.groovy - logging, dev/test/prod environments, additional build script or lifecycle event configuration
  • 8. App Lifecycle Initialize - before any Swing code is realized; used for L&F and setup Startup - after startup MVC groups are initialized Ready - all events sent to EDT queue have been processed Shutdown - opportunity to free resources before exit Stop - Applet specific
  • 9. Distribution and Installation stand-alone, webstart and applet support create launchers for Windows(.exe), Linux(shell script), Mac(.app) and as executable jar create installers using IzPack, RPM and DMG ‘big jar’ support for those lucky people in the US who can use the Java Store can create all installers and launchers in one step
  • 10. Testing and Analysis FEST - framework for Swing integration testing; equivalent of Selenium for Web testing EasyB - scenario based testing Cobertura - code coverage metrics JDepend - static analysis
  • 11. Language support Scala - plugin available Clojure - plugin available Java - if you REALLY want :)
  • 12. The EDT in Groovy doOutside{ //long running operations in a new thread edt { //jump back to the EDT if needed } doLater{ //update the UI when we’re done } }
  • 13. EDT With SwingWorker in Griffon in Griffon jxwithWorker {onInit { //setup } work { //do long running work and publish intermediate results publish(...) } onUpdate { //respond to intermediate results } onDone { //update UI with final results }} //update UI with final results }} //update UI with final results }} //update UI with final results }} //update UI with final results }} //update UI with final results }}
  • 14. How to get Griffon? download the izpack installer macports install from source - set $GRIFFON_HOME and put $GRIFFON_HOME/bin in your path, there’s an ant target to install tonite’s demo was 0.2-SNAPSHOT built from source
  • 15. How to use Griffon? On the command line create/run/test Applications create MVC groups or their individual components create tests install/uninstall plugins create your own plugins run a shell/console with your Application on the classpath ...
  • 16. Tool support Netbeans - Geertjan Wielenga crafted an alpha version plugin for Java One this year Intellij - Maia (version 9, in EAP now) parallels existing Grails support Eclipse - Groovy plugin, no specific support for Griffon; yet Griffon in Action has instructions for each of these IDE’s without plugins, based on ant
  • 17. IntelliJ Maia Closeup Project view showing libraries/plugins Griffon MVC plugin view
  • 18. What’s to come? Spring plugin Maven Gradle Grails plugin ports Griffon In Action from Manning Books
  • 19. How much code does it take? +----------------------+-------+-------+ | Name | Files | LOC | +----------------------+-------+-------+ | Controllers | 4 | 112 | | Models | 4 | 26 | | Views | 4 | 122 | | Lifecycle | 5 | 76 | | Integration Tests | 1 | 4 | +----------------------+-------+-------+ | Totals | 18 | 340 | +----------------------+-------+-------+

Editor's Notes

  1. developers on Griffon are contributors to Groovy and have provided handy AST transformations
  2. What makes it “hard” to program Swing? VERBOSITY, boilerplate
  3. What things does Groovy do to help? Builder pattern is great at building tree structures Helpful abstractions one line initialization, no need to call get/set
  4. What does Griffon add to the mix to make it even easier? no need to remember which builder you are calling; conflicts can be resolved using namespaces standardization/delegation of methods: size(), getAt(), putAt(), iterator()
  5. After this slide, demo CSSBuilder and some of the Swingpad samples Swingpad can be used to prototype UI elements in isolation, Mockfor and Stubfor can be used to mock dependencies
  6. After this slide, show the files in IDE and explain they’re nothing more than properties files consumed by ConfigSlurper
  7. show L&amp;F change? build a new app from scratch, change from label to button, run, change L&amp;F and rerun
  8. Getting your application built and published is important - you do want people to use these things after all Point out that demos are all .app files
  9. No framework would be complete without testing support Show FEST test after this slide
  10. Polyglot programming made easy
  11. Wrappers for SwingUtilities methods Demo Binding example
  12. SwingWorker DSL Demo EDT example and Animation example
  13. Here’s how you work with it at the lowest level. Demo loading up the application in a console
  14. Just out of interest, the demo application created to go along with this talk comes in pretty lean. Lifecycle and Integration Tests are defaults And all of these LOC measures include comments, to be fixed in a release soon