Griffon: Re-imaging Desktop Java Technology
Upcoming SlideShare
Loading in...5
×
 

Griffon: Re-imaging Desktop Java Technology

on

  • 8,799 views

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

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

Presented at Devoxx 2008

Statistics

Views

Total Views
8,799
Views on SlideShare
8,566
Embed Views
233

Actions

Likes
10
Downloads
111
Comments
0

7 Embeds 233

http://jameswilliams.be 197
http://www.slideshare.net 20
http://www.jameswilliams.be 9
https://www.linkedin.com 4
http://www.lmodules.com 1
http://localhost 1
http://www.linkedin.com 1
More...

Accessibility

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Griffon: Re-imaging Desktop Java Technology Griffon: Re-imaging Desktop Java Technology Presentation Transcript

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