Your SlideShare is downloading. ×
Griffon不定期便〜G*ワークショップ編〜
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Griffon不定期便〜G*ワークショップ編〜

2,168
views

Published on

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,168
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Griffon G*2011 9 23
  • 2. id:kiy0taka @kiy0taka JGGUG G*Magazine Griffon Griffon (?)2011 9 23
  • 3. create-command-alias $ griffon create-command-alias hoge > test-app unit: foo.BarTests $ griffon hoge Grails Griffon (ry2011 9 23
  • 4. Griffon Grails2011 9 23
  • 5. Java package sample; contentPane.add(button); import java.awt.Container; setDefaultCloseOperation(EXIT_ON_CLOSE); import java.awt.GridLayout; pack(); import java.awt.event.ActionEvent; setVisible(true); import java.awt.event.ActionListener; } import javax.swing.JButton; public static void main(String[] args) { import javax.swing.JFrame; SwingUtilities.invokeLater(new Runnable() { import javax.swing.JLabel; public void run() { import javax.swing.JTextArea; new Hello(); import javax.swing.SwingUtilities; } }); public class Hello extends JFrame { } } public Hello() { super("Hello"); Container contentPane = getContentPane(); contentPane.setLayout(new GridLayout(3, 1)); JLabel label = new JLabel("Label"); contentPane.add(label); JTextArea textArea = new JTextArea("Text Area"); textArea.setColumns(20); textArea.setRows(2); contentPane.add(textArea); JButton button = new JButton("Button"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { } });2011 9 23
  • 6. Groovy import groovy.swing.SwingBuilder new SwingBuilder().edt { frame(title:Hello, show:true, pack:true) { gridLayout(cols:1, rows:3) label Label textArea(Text Area, rows:2, columns:20) button(Button, actionPerformed:{ evt -> ... }) } }2011 9 23
  • 7. Java button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ... } }); SwingUtilities.invokeLater(new Runnable() { public void run() { ... } });2011 9 23
  • 8. & export GRIFFON_HOME=/path/to/griffon export PATH=$GRIFFON_HOME/bin:$PATH2011 9 23
  • 9. griffon [ ] griffon create-app myApp griffon run-app griffon test-app griffon package2011 9 23
  • 10. Grails2011 9 23
  • 11. Griffon Wrapper griffonw / griffonw.bat Griffon gradlew CI2011 9 23
  • 12. View2011 9 23
  • 13. View SwingBuilder2011 9 23
  • 14. SwingBuilder groovy.swing.SwingBuilder Groovy javax.swing.JXxx -> xxx() JButton -> button() JLabel -> label()2011 9 23
  • 15. View application(title:Sample, pack:true, ...) { tableLayout { tr { td { label(User Name) } td { textField(columns:20) } } tr { td { label(Password) } td { passwordField(columns:20) } } tr { td(colspan:2, align:right) { button(Submit) } } } }2011 9 23
  • 16. View // MyMenuBar.groovy menuBar { menu(File) { menuItem(Open) menuItem(Save) } } // MyAppView.groovy application(...) { build(MyMenuBar) }2011 9 23
  • 17. View Java // MyPanel.java class MyPanel extends JPanel { ... } // MyAppView.groovy application(...) { widget(new MyPanel()) }2011 9 23
  • 18. SwingPad2011 9 23
  • 19. SwingPad2011 9 23
  • 20. View SwingPad GroovyConsole2011 9 23
  • 21. SwingBuilder View SwingPad2011 9 23
  • 22. generate-view-script NetBeans View Griffon NetBeans Griffon2011 9 23
  • 23. Model2011 9 23
  • 24. Model package sample class SampleModel { String username String password }2011 9 23
  • 25. View Model Model View2011 9 23
  • 26. Model package sample import groovy.beans.Bindable class SampleModel { @Bindable String username @Bindable String password }2011 9 23
  • 27. Model package sample import groovy.beans.Bindable @Bindable class SampleModel { String username String password }2011 9 23
  • 28. View -> Model textField(text:bind(target:model, targetProperty:‘username’)) textField(text:bind(target:model, ‘username’))2011 9 23
  • 29. Model -> View textField(text:bind(source:model, sourceProperty:‘username’)) textField(text:bind(source:model, ‘username’)) textField(text:bind { model.username })2011 9 23
  • 30. View -> View buttonGroup(id:group1) radioButton(id:‘radio1’, ‘ ’, buttonGroup:group1) radioButton(id:‘radio2’, ‘ ’, buttonGroup:group1) textField(editable:bind(source:radio1, sourceEvent:‘itemStateChanged’, sourceValue:{radio1.selected}))2011 9 23
  • 31. // Model class Model { Date now = new Date() } // View label(text:bind(‘now’, source:model, converter:{it.format(‘yyyy-MM-dd’)}))2011 9 23
  • 32. // Model class Model { int num } // View textField(text:bind(‘num’, target:model, validator:{ it?.isInteger() }))2011 9 23
  • 33. constraints? class MyModel { @Bindable String requiredText @Bindable String url @Bindable String email static constraints = { requiredText(blank:false) url(url:true) email(email:true) } }2011 9 23
  • 34. Validation Grails constraints Model model.validate() model.errors net.sourceforge.gvalidation.swing.ErrorMessagePanel2011 9 23
  • 35. ErrorMessagePanel // View widget(new ErrorMessagePanel(messageSource), errors: bind(source: model, errors))2011 9 23
  • 36. Controller2011 9 23
  • 37. Controller class SampleController { def model def view void mvcGroupInit(Map args) { ... } void mvcGroupDestroy() { ... } def fooAction = { evt -> ... } def barAction = { evt -> ... } }2011 9 23
  • 38. View button(‘Click!’, actionPerformed:controller.fooAction)2011 9 23
  • 39. Model View Controller Model View2011 9 23
  • 40. Controller ( < 0.9.2 ) 0.9.2 UI2011 9 23
  • 41. @Threading griffon.transform.Threading2011 9 23
  • 42. class MyController { @Threading(Threading.Policy.INSIDE_UITHREAD_SYNC) def myAction = { } }2011 9 23
  • 43. Threading.Policy OUTSIDE_UITHREAD ( ) INSIDE_UITHREAD_SYNC UI INSIDE_UITHREAD_ASYNC UI SKIP2011 9 23
  • 44. class MyController { def myAction = { // execSync { // UI execOutside { // } } } }2011 9 23
  • 45. exec execSync UI execAsync UI execOutside2011 9 23
  • 46. Java/Groovy/Griffon Java Groovy Griffon new Thread() doOutside execOutside invokeLater doLater execAsync invokeAndWait edt execSync2011 9 23
  • 47. MVC Model View Controller MVC griffon create-mvc myNewGroup2011 9 23
  • 48. create-mvc -skip(View|Model|Controller) View/Model/Controller MVC -fileType=(groovy|java|etc) Java2011 9 23
  • 49. createMvcGroup MVC createMvcGroup(groupType, groupName, args)2011 9 23
  • 50. MVC SplitPane MVC TabbedPane MVC View MVC2011 9 23
  • 51. Group1 // View button(Add tab, actionPerformed:controller.addTab) tabbedPane id: tabGroup // Controller def addTab = { def name = new Date().format(yyyy-MM-dd HH:mm:ss) createMVCGroup("tab", name [tabGroup: view.tabGroup, tabName: name]) }2011 9 23
  • 52. Group2 // View tabbedPane(tabGroup, selectedIndex:tabGroup.tabCount) { panel(title: tabName) { label(tabName) } }2011 9 23
  • 53. Spock + FEST2011 9 23
  • 54. Spock + FEST class CalcSpec extends FestSpec { def my first FEST spec() { when: window.textBox(arg1).enterText(arg1) window.textBox(arg2).enterText(arg2) window.button(calculate).click() then: window.label(result).requireText(result) where: arg1 | arg2 | result 1 | 1 | 2 1 | 2 | 3 } }2011 9 23
  • 55. WebStart/Applet/Jar/Zip griffon package [webstart|applet|jar|zip] izpack|mac|rpm|deb|jsmooth2011 9 23
  • 56. 0.9.3 Griffon 0.9.32011 9 23