O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
Griffon
Swing just got fun again
James Williams
Agenda
> What's un-fun about Swing?
> What is Griffon?
> Getting Started
> Builders
> Griffon MVC
> Lifecycle
> Plugins/Ad...
What's un-fun about Swing?
> not knowing where stuff is
> can be very repetitive
> unresponsive user interfaces
> configur...
What is Griffon?
> desktop framework leveraging Swing and Groovy
> Apache 2 Licensed
> very extensible with plugins and ad...
Griffon Application Structure
Getting Started
> griffon create-app
> griffon run-app
> griffon run-applet
> griffon run-webstart
> griffon package
> gri...
Builders
> DSLs to compose complex object graphs
> Can automatically perform some common conversions
> Yield much more rea...
Would you prefer this ...
public class JavaFrame extends JFrame {
    public JavaFrame() {
        setLayout(new GridLayou...
... or this?

def swing = new SwingBuilder()

swing.frame(size:[100,100], title:'Test', layout:new GridLayout(3,1))
{
    ...
30 sec Swing(X)Builder Quick Guide
> Take the class name (e.g. JFrame)
> Remove the J(X)
> Change the remaining node name ...
UberBuilder - Builders on steriods
> Allows you to mix and match components
> Avoids collisions by setting up namespaces
UberBuilder - Supported toolkits
> Swing
> SwingX
> JIDE
> Flamingo
> MacWidgets
> SwingXtras
> Fx (JavaFX)
> Gfx (Java2D)
Griffon MVC Groups
> Models
  - can use the @Bindable notation to provide data binding
  - store the data for the MVC Grou...
Binding
> general formats:
  - bind{model.property}
  - bind(target:model, targetProperty:'name')
  - bind(source:model, s...
Binding and SwingPad Demo
Griffon Lifecycle
> Initialize
  - run before any Swing code is started
> Startup
  - run after MVC Groups are initialized...
The Evil Event Dispatching Thread
> edt
  - runs on the EDT using invokeAndWait
> doLater
  - runs on the EDT using invoke...
Plugins
> are the delivery method to provide compile-time
functionality:
  - Builders
  - Other JVM Language Support
  - T...
Addons
> add functionality at run-time
> can add or respond to runtime events
> can decorate MVC Groups
Guice Add-on
> injects methods and fields using the @Inject annotation
> Groovy removes the need for binding interfaces to...
Guice Configuration
application {
    title='TestGuice'
    startupGroups = ['TestGuice']

   // Should Griffon exit when ...
GuiceController
class TestguiceController {
    // these will be injected by Griffon
    def model
    def view
    @Injec...
Griffon Links
> Download: http://griffon.codehaus.org/Download
> Plugins/Addons: http://griffon.codehaus.org/Plugins
> Use...
Griffon Team on Twitter
> James Williams (@ecspike)
> Danno Ferrin (@shemnon)
> Andres Almiray (@aalmiray)
> Josh Reed (@j...
Próximos SlideShares
Carregando em…5
×

Griffon: Swing just got fun again

Session slides from Griffon: Swing just got fun again

Presented at RuPy 2009

  • Entre para ver os comentários

Griffon: Swing just got fun again

  1. 1. Griffon Swing just got fun again James Williams
  2. 2. Agenda > What's un-fun about Swing? > What is Griffon? > Getting Started > Builders > Griffon MVC > Lifecycle > Plugins/Addons > Demos > Q&A
  3. 3. What's un-fun about Swing? > not knowing where stuff is > can be very repetitive > unresponsive user interfaces > configuring webstart apps is a nightmare > you're forced to choose between applets and desktop fairly early
  4. 4. What is Griffon? > desktop framework leveraging Swing and Groovy > Apache 2 Licensed > very extensible with plugins and addons > allows you to code without worrying about the destination platform
  5. 5. Griffon Application Structure
  6. 6. Getting Started > griffon create-app > griffon run-app > griffon run-applet > griffon run-webstart > griffon package > griffon list-plugins > griffon install-plugin
  7. 7. Builders > DSLs to compose complex object graphs > Can automatically perform some common conversions > Yield much more readable code than Java
  8. 8. Would you prefer this ... public class JavaFrame extends JFrame { public JavaFrame() { setLayout(new GridLayout(3,1)); setTitle("Test"); setSize(100,100); add(new JLabel("One")); add(new JLabel("Two")); add(new JLabel("Three")); } public static void main(String [ ] args) { new JavaFrame().setVisible(true); } }
  9. 9. ... or this? def swing = new SwingBuilder() swing.frame(size:[100,100], title:'Test', layout:new GridLayout(3,1)) { label("One") label("Two") label("Three") }.show()
  10. 10. 30 sec Swing(X)Builder Quick Guide > Take the class name (e.g. JFrame) > Remove the J(X) > Change the remaining node name to camel-case > Any fields that follow the JavaBean spec can be passed in a HashMap
  11. 11. UberBuilder - Builders on steriods > Allows you to mix and match components > Avoids collisions by setting up namespaces
  12. 12. UberBuilder - Supported toolkits > Swing > SwingX > JIDE > Flamingo > MacWidgets > SwingXtras > Fx (JavaFX) > Gfx (Java2D)
  13. 13. Griffon MVC Groups > Models - can use the @Bindable notation to provide data binding - store the data for the MVC Group > Views - represent a single display in your applications - can be written in Groovy OR Java > Controllers - the brains of the group - can be injected with services
  14. 14. Binding > general formats: - bind{model.property} - bind(target:model, targetProperty:'name') - bind(source:model, sourceProperty:'name') > one-way > mutual binding
  15. 15. Binding and SwingPad Demo
  16. 16. Griffon Lifecycle > Initialize - run before any Swing code is started > Startup - run after MVC Groups are initialized > Ready - run after all events have been processed by the EDT > Shutdown - all cleanup operations should run here > Stop - only used by applets
  17. 17. The Evil Event Dispatching Thread > edt - runs on the EDT using invokeAndWait > doLater - runs on the EDT using invokeLater > doOutside - spins up a thread to run if not already outside the EDT > withWorker (SwingWorker) - for long running tasks where the UI might periodically update
  18. 18. Plugins > are the delivery method to provide compile-time functionality: - Builders - Other JVM Language Support - Testing Frameworks - Addons
  19. 19. Addons > add functionality at run-time > can add or respond to runtime events > can decorate MVC Groups
  20. 20. Guice Add-on > injects methods and fields using the @Inject annotation > Groovy removes the need for binding interfaces to modules > smaller footprint and faster than Spring
  21. 21. Guice Configuration application { title='TestGuice' startupGroups = ['TestGuice'] // Should Griffon exit when no Griffon created frames are showing? autoShutdown = true // If you want some non-standard application class, apply it here //frameClass = 'javax.swing.JFrame' } /* truncated for brevity */ guice { injectInto = ["controller"] modules = ['NotifierModule'] }
  22. 22. GuiceController class TestguiceController { // these will be injected by Griffon def model def view @Inject Notifier notifier void mvcGroupInit(Map args) { // this method is called after model and view are injected injector.injectMembers(this) // related settings from Application.groovy are injected notifier.sendNotification("hi") } }
  23. 23. Griffon Links > Download: http://griffon.codehaus.org/Download > Plugins/Addons: http://griffon.codehaus.org/Plugins > User mailing list: user@griffon.codehaus.org > Dev mailing list: dev@griffon.codehaus.org
  24. 24. Griffon Team on Twitter > James Williams (@ecspike) > Danno Ferrin (@shemnon) > Andres Almiray (@aalmiray) > Josh Reed (@joshareed) > Jim Shingler (@jshingler) > Griffon News (@theaviary)

×