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

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

on

  • 2,591 views

 

Statistics

Views

Total Views
2,591
Views on SlideShare
2,477
Embed Views
114

Actions

Likes
0
Downloads
3
Comments
0

5 Embeds 114

http://d.hatena.ne.jp 88
http://localhost 17
http://orangeclover.hatenablog.com 6
http://coderwall.com 2
http://paper.li 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

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不定期便〜G*ワークショップ編〜 Griffon不定期便〜G*ワークショップ編〜 Presentation Transcript

    • Griffon G*2011 9 23
    • id:kiy0taka @kiy0taka JGGUG G*Magazine Griffon Griffon (?)2011 9 23
    • create-command-alias $ griffon create-command-alias hoge > test-app unit: foo.BarTests $ griffon hoge Grails Griffon (ry2011 9 23
    • Griffon Grails2011 9 23
    • 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
    • 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
    • Java button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ... } }); SwingUtilities.invokeLater(new Runnable() { public void run() { ... } });2011 9 23
    • & export GRIFFON_HOME=/path/to/griffon export PATH=$GRIFFON_HOME/bin:$PATH2011 9 23
    • griffon [ ] griffon create-app myApp griffon run-app griffon test-app griffon package2011 9 23
    • Grails2011 9 23
    • Griffon Wrapper griffonw / griffonw.bat Griffon gradlew CI2011 9 23
    • View2011 9 23
    • View SwingBuilder2011 9 23
    • SwingBuilder groovy.swing.SwingBuilder Groovy javax.swing.JXxx -> xxx() JButton -> button() JLabel -> label()2011 9 23
    • 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
    • View // MyMenuBar.groovy menuBar { menu(File) { menuItem(Open) menuItem(Save) } } // MyAppView.groovy application(...) { build(MyMenuBar) }2011 9 23
    • View Java // MyPanel.java class MyPanel extends JPanel { ... } // MyAppView.groovy application(...) { widget(new MyPanel()) }2011 9 23
    • SwingPad2011 9 23
    • SwingPad2011 9 23
    • View SwingPad GroovyConsole2011 9 23
    • SwingBuilder View SwingPad2011 9 23
    • generate-view-script NetBeans View Griffon NetBeans Griffon2011 9 23
    • Model2011 9 23
    • Model package sample class SampleModel { String username String password }2011 9 23
    • View Model Model View2011 9 23
    • Model package sample import groovy.beans.Bindable class SampleModel { @Bindable String username @Bindable String password }2011 9 23
    • Model package sample import groovy.beans.Bindable @Bindable class SampleModel { String username String password }2011 9 23
    • View -> Model textField(text:bind(target:model, targetProperty:‘username’)) textField(text:bind(target:model, ‘username’))2011 9 23
    • Model -> View textField(text:bind(source:model, sourceProperty:‘username’)) textField(text:bind(source:model, ‘username’)) textField(text:bind { model.username })2011 9 23
    • 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
    • // Model class Model { Date now = new Date() } // View label(text:bind(‘now’, source:model, converter:{it.format(‘yyyy-MM-dd’)}))2011 9 23
    • // Model class Model { int num } // View textField(text:bind(‘num’, target:model, validator:{ it?.isInteger() }))2011 9 23
    • 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
    • Validation Grails constraints Model model.validate() model.errors net.sourceforge.gvalidation.swing.ErrorMessagePanel2011 9 23
    • ErrorMessagePanel // View widget(new ErrorMessagePanel(messageSource), errors: bind(source: model, errors))2011 9 23
    • Controller2011 9 23
    • Controller class SampleController { def model def view void mvcGroupInit(Map args) { ... } void mvcGroupDestroy() { ... } def fooAction = { evt -> ... } def barAction = { evt -> ... } }2011 9 23
    • View button(‘Click!’, actionPerformed:controller.fooAction)2011 9 23
    • Model View Controller Model View2011 9 23
    • Controller ( < 0.9.2 ) 0.9.2 UI2011 9 23
    • @Threading griffon.transform.Threading2011 9 23
    • class MyController { @Threading(Threading.Policy.INSIDE_UITHREAD_SYNC) def myAction = { } }2011 9 23
    • Threading.Policy OUTSIDE_UITHREAD ( ) INSIDE_UITHREAD_SYNC UI INSIDE_UITHREAD_ASYNC UI SKIP2011 9 23
    • class MyController { def myAction = { // execSync { // UI execOutside { // } } } }2011 9 23
    • exec execSync UI execAsync UI execOutside2011 9 23
    • Java/Groovy/Griffon Java Groovy Griffon new Thread() doOutside execOutside invokeLater doLater execAsync invokeAndWait edt execSync2011 9 23
    • MVC Model View Controller MVC griffon create-mvc myNewGroup2011 9 23
    • create-mvc -skip(View|Model|Controller) View/Model/Controller MVC -fileType=(groovy|java|etc) Java2011 9 23
    • createMvcGroup MVC createMvcGroup(groupType, groupName, args)2011 9 23
    • MVC SplitPane MVC TabbedPane MVC View MVC2011 9 23
    • 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
    • Group2 // View tabbedPane(tabGroup, selectedIndex:tabGroup.tabCount) { panel(title: tabName) { label(tabName) } }2011 9 23
    • Spock + FEST2011 9 23
    • 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
    • WebStart/Applet/Jar/Zip griffon package [webstart|applet|jar|zip] izpack|mac|rpm|deb|jsmooth2011 9 23
    • 0.9.3 Griffon 0.9.32011 9 23