Your SlideShare is downloading. ×
0
www.devoxx.com
Griffon: Re-imaging Desktop Java Technology <ul><li>James Williams </li></ul><ul><li>Griffon Co-creator </li></ul>
Overall Presentation Goal <ul><li>Learn how to create Java apps with ease </li></ul>
Speaker’s qualifications <ul><li>James is the creator of SwingXBuilder </li></ul><ul><li>James is a co-creator of the Grif...
<ul><li>What's been said about Griffon: </li></ul><ul><li>Grails for the Desktop. </li></ul><ul><li>Griffon is agility for...
<ul><li>A Brief History of Desktop Java </li></ul><ul><li>What is Griffon ? </li></ul><ul><li>Griffon Lifecycle </li></ul>...
<ul><li>Java 1.0 </li></ul><ul><li>Java 1.1 </li></ul><ul><li>Java 1.2 </li></ul><ul><li>Java 1.4 </li></ul><ul><li>Java 5...
<ul><li>Closures(no more waiting for JDK7) </li></ul><ul><li>Concise syntax </li></ul><ul><li>Less ceremonial code </li></...
<ul><li>Meta Object Protocol (MOP) </li></ul><ul><ul><ul><li>Allows methods to be intercepted </li></ul></ul></ul><ul><ul>...
<ul><li>Instead of this: </li></ul><ul><li>public class HelloWorld extends JFrame { </li></ul><ul><li>JLabel label = new J...
<ul><li>Is a desktop framework for Swing leveraging Groovy </li></ul><ul><li>Heavily influenced by Grails </li></ul><ul><l...
Griffon and Grails <ul><li>Griffon </li></ul><ul><li>Uses MVC </li></ul><ul><li>Uses scripts for lifecycle events </li></u...
<ul><li>%PROJECT_HOME% </li></ul><ul><li>+ griffon-app </li></ul><ul><li>+ conf ---> location of configuration artifacts  ...
<ul><li>Initialize </li></ul><ul><li>Startup </li></ul><ul><li>Ready </li></ul><ul><li>Stop </li></ul><ul><li>Shutdown </l...
<ul><li>Navigate to  http://griffon.codehaus.org </li></ul><ul><li>Download zip (deb, izpack, and dmg will be available so...
DEMO <ul><li>Creating a Griffon app </li></ul>
<ul><li>Are DSLs to compose complex structures </li></ul><ul><li>Exist for UI components and structured documents </li></u...
<ul><li>The granddad of all the Swing-based builders </li></ul><ul><li>Wraps all J2SE components </li></ul><ul><li>Sample ...
<ul><li>Wraps most SwingLabs components </li></ul><ul><li>The first UI builder to be implemented in Groovy </li></ul><ul><...
<ul><li>Wraps JIDE Common Layer components </li></ul><ul><li>List of components available at http://groovy.codehaus.org/Ji...
<ul><li>Added in Groovy 1.5 (with Groovy's annotation support) </li></ul><ul><li>Provides one-way binding between a variab...
<ul><li>General form: bind(< map >) </li></ul><ul><ul><li>source </li></ul></ul><ul><ul><li>sourceProperty </li></ul></ul>...
<ul><li>swing.frame() { </li></ul><ul><li>panel { </li></ul><ul><li>textField('Change Me!', id:'tf') </li></ul><ul><li>but...
DEMO <ul><li>SwingBuilder Sample </li></ul><ul><li>FontPicker  </li></ul>
<ul><li>Store variables referenced by the controller and views </li></ul><ul><li>Can use the @Bindable annotation to autom...
<ul><li>Represent specific components in your app </li></ul><ul><li>Can be written in Groovy or Java </li></ul><ul><li>Ref...
<ul><li>application(title:'HelloWorld',  size: [300, 500],  defaultCloseOperation:WC.EXIT_ON_CLOSE ) { </li></ul><ul><li>l...
<ul><li>Contain most UI-based application logic </li></ul><ul><li>Injected with the model and view at run-time </li></ul>G...
<ul><li>Wrapper for J2SE SwingWorker to run long tasks </li></ul><ul><li>Unlike in Java, a Groovy SwingWorker can be reuse...
<ul><li>def doImageLoad = {evt = null -> </li></ul><ul><li>withWorker(start:true) { </li></ul><ul><ul><ul><ul><ul><ul><ul>...
<ul><li>Provide fine grained separation of concerns </li></ul><ul><li>Can be used to inject complex objects at runtime </l...
<ul><li>Provide extensibility for Griffon  </li></ul><ul><li>Can be project-specific or global </li></ul><ul><li>Current p...
<ul><li>Experimental Netbeans plugin for 6.5 </li></ul><ul><li>Generates Ant and Eclipse files automatically </li></ul><ul...
<ul><li>Scripts for desktop, applet, and webstart deployment </li></ul><ul><li>Automates JNLP generation and jar signing <...
DEMO <ul><li>Griffon Flubber </li></ul><ul><li>Various deploy targets </li></ul>
Griffon Roadmap <ul><li>0.1-BETA ( Releasing Soon ) Plugin support Built-in testing support Support for pack200 Ability to...
<ul><li>Introducing SwingPad </li></ul>
Summary <ul><li>Griffon separates Model, View and Controller </li></ul><ul><li>Griffon apps share the same structure </li>...
Concluding statement <ul><li>Griffon is simplified, sensibly structured Swing. </li></ul>
Q&A
Thanks for your attention! <ul><li>Web links : </li></ul><ul><li>http://griffon.codehaus.org </li></ul><ul><li>[email_addr...
Upcoming SlideShare
Loading in...5
×

Griffon: Re-imaging Desktop Java Technology

8,700

Published on

Griffon is a desktop framework for Java Swing leveraging the dynamic language Groovy and values convention over configuration.

Presented at Devoxx 2008

Published in: Technology, Art & Photos
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,700
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
116
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide
  • Transcript of "Griffon: Re-imaging Desktop Java Technology"

    1. 1. www.devoxx.com
    2. 2. Griffon: Re-imaging Desktop Java Technology <ul><li>James Williams </li></ul><ul><li>Griffon Co-creator </li></ul>
    3. 3. Overall Presentation Goal <ul><li>Learn how to create Java apps with ease </li></ul>
    4. 4. Speaker’s qualifications <ul><li>James is the creator of SwingXBuilder </li></ul><ul><li>James is a co-creator of the Griffon framework </li></ul><ul><li>James speaks frequently on Groovy technology </li></ul>
    5. 5. <ul><li>What's been said about Griffon: </li></ul><ul><li>Grails for the Desktop. </li></ul><ul><li>Griffon is agility for Swing application development. </li></ul><ul><li>The case for Groovy has been made a whole lot stronger via Griffon. </li></ul>
    6. 6. <ul><li>A Brief History of Desktop Java </li></ul><ul><li>What is Griffon ? </li></ul><ul><li>Griffon Lifecycle </li></ul><ul><li>Builders / @Bindable </li></ul><ul><li>Griffon MVC </li></ul><ul><li>SwingWorker </li></ul><ul><li>Plugins </li></ul><ul><li>App Deployment </li></ul><ul><li>Tool Support </li></ul>Agenda
    7. 7. <ul><li>Java 1.0 </li></ul><ul><li>Java 1.1 </li></ul><ul><li>Java 1.2 </li></ul><ul><li>Java 1.4 </li></ul><ul><li>Java 5 </li></ul><ul><li>Java 6 </li></ul><ul><li>JavaFX ??? </li></ul>History of Desktop Java
    8. 8. <ul><li>Closures(no more waiting for JDK7) </li></ul><ul><li>Concise syntax </li></ul><ul><li>Less ceremonial code </li></ul><ul><li>Lots of useful closures already added to core classes </li></ul>What Groovy adds to Java
    9. 9. <ul><li>Meta Object Protocol (MOP) </li></ul><ul><ul><ul><li>Allows methods to be intercepted </li></ul></ul></ul><ul><ul><ul><li>Allows methods to be added to objects at run-time </li></ul></ul></ul><ul><ul><ul><li>Allows missing methods to be handled </li></ul></ul></ul><ul><ul><ul><li>Magic </li></ul></ul></ul>What Groovy adds to Java
    10. 10. <ul><li>Instead of this: </li></ul><ul><li>public class HelloWorld extends JFrame { </li></ul><ul><li>JLabel label = new JLabel(“Your name:”); </li></ul><ul><li>JTextField field = new JTextField(20); </li></ul><ul><li>JButton button = new Button(“Click”); </li></ul><ul><li>button.addActionListener(new ActionListener() { </li></ul><ul><li>public void actionPerformed(ActionEvent evt) { </li></ul><ul><li>JOptionPane.showMessageDialog(....) </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>setLayout(new FlowLayout()) </li></ul><ul><li>add(label) </li></ul><ul><li>add(field) </li></ul><ul><li>add(button) </li></ul><ul><li>} </li></ul><ul><li>You can type this: </li></ul><ul><li>frame (size:[200,200], title:'Hello World', layout:new FlowLayout()) { </li></ul><ul><li>label('Your name:') </li></ul><ul><li>textField(id:'nameField', cols:20) </li></ul><ul><li>button(text:'Click', actionPerformed:{JOptionPane.showMessageDialog(....) } </li></ul><ul><li>} </li></ul>Groovy Magic
    11. 11. <ul><li>Is a desktop framework for Swing leveraging Groovy </li></ul><ul><li>Heavily influenced by Grails </li></ul><ul><li>Apache Licensed (ASL 2) </li></ul><ul><li>Values convention over configuration </li></ul><ul><li>Strongly adheres to a MVC directory structure </li></ul>Griffon ...
    12. 12. Griffon and Grails <ul><li>Griffon </li></ul><ul><li>Uses MVC </li></ul><ul><li>Uses scripts for lifecycle events </li></ul><ul><li>No persistence story (gotta wire your own) </li></ul><ul><li>Under 10 plugins </li></ul><ul><li>Grails </li></ul><ul><li>Uses MVC </li></ul><ul><li>Uses scripts for lifecycle events </li></ul><ul><li>Persistence via Hibernate </li></ul><ul><li>Over 100 plugins </li></ul>
    13. 13. <ul><li>%PROJECT_HOME% </li></ul><ul><li>+ griffon-app </li></ul><ul><li>+ conf ---> location of configuration artifacts </li></ul><ul><li>+ keys ---> keys for code signing </li></ul><ul><li>+ webstart ---> webstart and applet config </li></ul><ul><li>+ controllers ---> location of controller classes </li></ul><ul><li>+ i18n ---> location of message bundles for i18n </li></ul><ul><li>+ lifecycle ---> location of lifecycle scripts </li></ul><ul><li>+ models ---> location of model classes </li></ul><ul><li>+ resources ---> location of non code resources (images, etc) </li></ul><ul><li>+ views ---> location of view classes </li></ul><ul><li>+ lib </li></ul><ul><li>+ scripts ---> scripts </li></ul><ul><li>+ src </li></ul><ul><li>+ main ---> optional; location for Groovy and Java source files </li></ul><ul><li>(of types other than those in griffon-app/*) </li></ul>Structure of a Griffon app
    14. 14. <ul><li>Initialize </li></ul><ul><li>Startup </li></ul><ul><li>Ready </li></ul><ul><li>Stop </li></ul><ul><li>Shutdown </li></ul>Griffon Lifecycle
    15. 15. <ul><li>Navigate to http://griffon.codehaus.org </li></ul><ul><li>Download zip (deb, izpack, and dmg will be available soon) and unzip it somewhere </li></ul><ul><li>If not set by the installer, add GRIFFON_HOME to your path. </li></ul><ul><li>You're all set. </li></ul>Griffon Quickstart
    16. 16. DEMO <ul><li>Creating a Griffon app </li></ul>
    17. 17. <ul><li>Are DSLs to compose complex structures </li></ul><ul><li>Exist for UI components and structured documents </li></ul><ul><li>Additional builders can be provided via plugins </li></ul><ul><li>Allow components to be intermingled </li></ul><ul><li>Much more readable than conventional code </li></ul><ul><li>Can be declared in namespaces to avoid clashes </li></ul>Builders
    18. 18. <ul><li>The granddad of all the Swing-based builders </li></ul><ul><li>Wraps all J2SE components </li></ul><ul><li>Sample SwingBuilder code: frame (size:[200,200], title:'Hello World', layout:new FlowLayout()) { </li></ul><ul><li>label('Your name:') </li></ul><ul><li>textField(id:'nameField', columnss:20) </li></ul><ul><li>button(text:'Click', actionPerformed:{JOptionPane.showMessageDialog(....) } </li></ul><ul><li>} </li></ul>SwingBuilder
    19. 19. <ul><li>Wraps most SwingLabs components </li></ul><ul><li>The first UI builder to be implemented in Groovy </li></ul><ul><li>Provides aliases for long properties names </li></ul><ul><li>Provides support for painters and effects </li></ul>SwingXBuilder
    20. 20. <ul><li>Wraps JIDE Common Layer components </li></ul><ul><li>List of components available at http://groovy.codehaus.org/JideBuilder </li></ul>JIDEBuilder
    21. 21. <ul><li>Added in Groovy 1.5 (with Groovy's annotation support) </li></ul><ul><li>Provides one-way binding between a variable and a component </li></ul><ul><li>Automagically wraps the target in a PropertyChangeListener </li></ul>@Bindable Annotation
    22. 22. <ul><li>General form: bind(< map >) </li></ul><ul><ul><li>source </li></ul></ul><ul><ul><li>sourceProperty </li></ul></ul><ul><ul><li>sourceValue </li></ul></ul><ul><ul><li>target </li></ul></ul><ul><ul><li>targetProperty </li></ul></ul><ul><ul><li>validator </li></ul></ul><ul><ul><li>converter </li></ul></ul>@Bindable Annotation
    23. 23. <ul><li>swing.frame() { </li></ul><ul><li>panel { </li></ul><ul><li>textField('Change Me!', id:'tf') </li></ul><ul><li>button(text: bind(source:tf, sourceProperty:'text')) </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>swing.frame() { </li></ul><ul><li>panel </li></ul><ul><li>{ </li></ul><ul><li>textField('Change Me!', id:'tf') </li></ul><ul><li>button(text: bind(source:tf, sourceProperty:'text', </li></ul><ul><li>validator: { tf.text.length() >= 1}, converter: { it.toLowerCase() } )) </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>@Bindable Annotation
    24. 24. DEMO <ul><li>SwingBuilder Sample </li></ul><ul><li>FontPicker </li></ul>
    25. 25. <ul><li>Store variables referenced by the controller and views </li></ul><ul><li>Can use the @Bindable annotation to automagically notify via PropertyChangeListeners </li></ul><ul><li>Injected into the controller and view at run-time </li></ul>Models
    26. 26. <ul><li>Represent specific components in your app </li></ul><ul><li>Can be written in Groovy or Java </li></ul><ul><li>Referenced in code with build(NameOfView)* </li></ul><ul><li>Can mix and match code from all the builders </li></ul>Views
    27. 27. <ul><li>application(title:'HelloWorld', size: [300, 500], defaultCloseOperation:WC.EXIT_ON_CLOSE ) { </li></ul><ul><li>label(model.greeting) </li></ul><ul><li>} </li></ul><ul><li>class HelloWorldModel { </li></ul><ul><ul><ul><ul><ul><ul><ul><li>@Bindable greeting </li></ul></ul></ul></ul></ul></ul></ul><ul><li>} </li></ul>HelloWorldModel.groovy HelloWorldView.groovy Sample View/Model
    28. 28. <ul><li>Contain most UI-based application logic </li></ul><ul><li>Injected with the model and view at run-time </li></ul>Griffon Controllers
    29. 29. <ul><li>Wrapper for J2SE SwingWorker to run long tasks </li></ul><ul><li>Unlike in Java, a Groovy SwingWorker can be reused </li></ul><ul><li>Uses the appropriate version if using < Java1.6 </li></ul><ul><li>SwingWorker closures </li></ul><ul><li>onInit – the initialization work </li></ul><ul><li>work – the work to be done </li></ul><ul><li>onUpdate – for incremental updates (optional) </li></ul><ul><li>onDone – what to do when finished </li></ul>Groovy SwingWorker
    30. 30. <ul><li>def doImageLoad = {evt = null -> </li></ul><ul><li>withWorker(start:true) { </li></ul><ul><ul><ul><ul><ul><ul><ul><ul><ul><li>onInit { /* Init stuff here */ } </li></ul></ul></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><ul><ul><li>work { /* load images here */} </li></ul></ul></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><ul><ul><li>onUpdate { /* draw loaded image */ } </li></ul></ul></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><ul><ul><li>onDone { /* finish and do cleanup */ } </li></ul></ul></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul></ul></ul></ul></ul></ul><ul><li>} </li></ul>Sample SwingWorker
    31. 31. <ul><li>Provide fine grained separation of concerns </li></ul><ul><li>Can be used to inject complex objects at runtime </li></ul><ul><li>Encourages code reuse </li></ul><ul><li>Not covered in this BOF </li></ul>Multiple MVC Groups
    32. 32. <ul><li>Provide extensibility for Griffon </li></ul><ul><li>Can be project-specific or global </li></ul><ul><li>Current plugins: </li></ul><ul><ul><ul><li>easyb </li></ul></ul></ul><ul><ul><ul><li>fest </li></ul></ul></ul><ul><ul><ul><li>Installer (izpack, dmg, rpm) </li></ul></ul></ul><ul><ul><ul><li>JideBuilder </li></ul></ul></ul><ul><ul><ul><li>SwingXBuilder </li></ul></ul></ul>Plugins
    33. 33. <ul><li>Experimental Netbeans plugin for 6.5 </li></ul><ul><li>Generates Ant and Eclipse files automatically </li></ul><ul><li>Close relationship to Grails should make it easy to adapt existing Grails plugins (for IDEs) </li></ul>Tool Support
    34. 34. <ul><li>Scripts for desktop, applet, and webstart deployment </li></ul><ul><li>Automates JNLP generation and jar signing </li></ul><ul><li>Can generate applet host page </li></ul>Deploying your App
    35. 35. DEMO <ul><li>Griffon Flubber </li></ul><ul><li>Various deploy targets </li></ul>
    36. 36. Griffon Roadmap <ul><li>0.1-BETA ( Releasing Soon ) Plugin support Built-in testing support Support for pack200 Ability to opt out of code signing and packaging </li></ul><ul><li>0.2 Planned Features (No release date set) Addon support (runtime plugins) GORM from Grails 1.1 </li></ul><ul><li>Wish List/Items not tied to a version Flamingo/Substance, GraphicsBuilder, JavaFX Scene Graph, JavaFX Interop, IDE interop, NB Matisse </li></ul>
    37. 37. <ul><li>Introducing SwingPad </li></ul>
    38. 38. Summary <ul><li>Griffon separates Model, View and Controller </li></ul><ul><li>Griffon apps share the same structure </li></ul><ul><li>Builders make UI code more readable </li></ul><ul><li>Deploy to desktop, webstart, and applets with no changes </li></ul><ul><li>Plugins provide extensibility </li></ul>
    39. 39. Concluding statement <ul><li>Griffon is simplified, sensibly structured Swing. </li></ul>
    40. 40. Q&A
    41. 41. Thanks for your attention! <ul><li>Web links : </li></ul><ul><li>http://griffon.codehaus.org </li></ul><ul><li>[email_address] </li></ul><ul><li>Creators' blogs : </li></ul><ul><li>Danno Ferrin http://shemnon.com/speling </li></ul><ul><li>Andres Almiray http://jroller.com/aalmiray </li></ul><ul><li>James Williams http://jameswilliams.be/blog </li></ul>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×