• Save
Griffon Presentation
Upcoming SlideShare
Loading in...5
×
 

Griffon Presentation

on

  • 3,445 views

A presentation for the Vancouver Island Java User's Group showcasing how Groovy and the Griffon application framework can ease the pain of coding Swing applications.

A presentation for the Vancouver Island Java User's Group showcasing how Groovy and the Griffon application framework can ease the pain of coding Swing applications.

Statistics

Views

Total Views
3,445
Views on SlideShare
3,275
Embed Views
170

Actions

Likes
4
Downloads
0
Comments
1

3 Embeds 170

http://www.kellyrob99.com 161
http://www.slideshare.net 7
http://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Source code to go along with this presentation is available here: http://tinyurl.com/m29b4r
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • developers on Griffon are contributors to Groovy and have provided handy AST transformations
  • What makes it “hard” to program Swing? VERBOSITY, boilerplate
  • 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
  • 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()
  • 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
  • After this slide, show the files in IDE and explain they’re nothing more than properties files consumed by ConfigSlurper
  • show L&F change? build a new app from scratch, change from label to button, run, change L&F and rerun
  • 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
  • No framework would be complete without testing support Show FEST test after this slide
  • Polyglot programming made easy
  • Wrappers for SwingUtilities methods Demo Binding example
  • SwingWorker DSL Demo EDT example and Animation example
  • Here’s how you work with it at the lowest level. Demo loading up the application in a console
  • 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

Griffon Presentation Griffon Presentation Presentation Transcript

  • 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
    • ???