#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Porting legacy apps to Griffon
1. Porting your legacy
apps to Griffon
James Williams
@ecspike
Software Engineer, BT/Ribbit
2. Goals
•The basics of Griffon
•Griffon tenets
•Respect the EDT's authority
•SwingWorker is your friend
•Embrace simpler layout managers
•MVC does a codebase good
•Go modular
•Deploy, deploy, deploy!
3. What is Griffon?
•desktop framework
•inspired by Grails and the SAF
•leverages Swing and Groovy
•Apache 2 Licensed
•extensible with plugins and addons
4. Griffon Tenets
•Convention over Configuration
•Don't Repeat Yourself
•Pervasive MVC
•Use Data Binding
•Write Good Tests
•Automate Tasks
9. Would you prefer this ...
public class JavaFrame extends JFrame {
public JavaFrame {
setLayout(new GridLayout(3,1));
setTitle("JavaFrame");
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);
}
}
10. ... or this?
def swing = new SwingBuilder()
swing.frame(size:[100,100],
title:'JavaFrame',
layout:new GridLayout(3,1)) {
label('One')
label('Two')
label('Three')
}.show()
11. Griffon Builders
•DSLs for UI components
•allows nesting
•takes parameters as a HashMap
•can be mixed and matched
14. Respect the EDT
•Event Dispatching thread
•the cause of 94% of speed
problems*
•only UI updates should run on it*
•first-in/first out
•Griffon EDT helpers
•edt
•doOutside/Later/Inside
•withWorker
15. Swingworker
•designed for long tasks
•can periodically update the UI or
notify processes outside the worker
•Swing Worker closures:
•onInit
•work
•publish
•onUpdate
•onDone
23. MVC
•Models
•store data for the MVC Group
•can mark properties as
@Bindable
•Views
•represent a single UI in your app
•can be written in Groovy OR
Java
•Controllers
24. A sample model
import groovy.beans.Bindable
class SampleModel {
@Bindable String name
def age
def location
}
38. What if you can't move to Griffon?
•JavaBuilders
•http://code.google.com/p/javabuilders
•Guts-Gui
•http://kenai.com/projects/guts
•Netbeans Platform
•http://platform.netbeans.org/