Skip to end of metadata
Go to start of metadata

I have added a couple of applications in the example directory that can be used as a template for building other applications.

Here is an extract from a basic TextEditor that shows how to use the JFace builder:

         mainapp = jface.applicationWindow( title:"Groovy Text Editor", location:[100,100], size:[500, 300] ) {
             gridLayout(numColumns:1)
             menuManager( text:"File" ) {
                 action ( text:"Exit", closure:{ mainapp.close() } )
             }

             menuManager( text:"Edit" ) {
                 action ( text:"Cut", accelerator: SWT.MOD1 + (int) 'X', closure:{ handleCutCopy(); text.cut() } )
                 action ( text:"Copy", accelerator: SWT.MOD1 + (int) 'C',closure:{ handleCutCopy(); text.copy() } )
                 action ( text:"Paste", accelerator: SWT.MOD1 + (int) 'P',closure:{ text.paste() } )
                 separator()
                 action ( text:"Set Font", closure:{ setFont() } )
             }
             toolBar( style:"none" ) {
                boldButton = toolItem(style:"check", toolTipText:"Bold") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/bold.png" )
                    onEvent(type:"Selection", closure:{setStyle(it.widget)})
                }
                italicButton = toolItem(style:"check", toolTipText:"Italic") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/italic.png" )
                    onEvent(type:"Selection", closure:{setStyle(it.widget)})
                }
                underlineButton = toolItem(style:"check", toolTipText:"Underline") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/underline.png" )
                    onEvent(type:"Selection", closure:{setStyle(it.widget)})
                }
                strikeoutButton = toolItem(style:"check", toolTipText:"Strikeout") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/strikeout.png" )
                    onEvent(type:"Selection", closure:{setStyle(it.widget)})
                }
                toolItem(style:"separator")
                toolItem(style:"push", toolTipText:"Red text") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/red.png" )
                    onEvent(type:"Selection", closure:{fgColor(RED)})
                }
                toolItem(style:"push", toolTipText:"Blue text") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/blue.png" )
                    onEvent(type:"Selection", closure:{fgColor(BLUE)})
                }
                toolItem(style:"push", toolTipText:"Green text") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/green.png" )
                    onEvent(type:"Selection", closure:{fgColor(GREEN)})
                }
                toolItem(style:"separator")
                toolItem(style:"push", toolTipText:"Clear formatting") {
                    image( src:"src/examples/groovy/swt/examples/TextEditor/erase.png" )
                    onEvent(type:"Selection", closure:{clear()})
                }
             }

             text = styledText ( style: "Border, Multi, V_Scroll, H_Scroll") {
                 gridData(horizontalAlignment: GridData.FILL,
                          verticalAlignment: GridData.FILL,
                          grabExcessHorizontalSpace: true,
                          grabExcessVerticalSpace: true
                          )
             }

             text.addExtendedModifyListener(this)
        }


Simple isn't it? (smile)

For the complete code see subversion or the attached snapshot.

1 Comment

  1. Great!!!!!

     I had almost given up on this, as it seemed to be dead for Good and all the action was going on in Groovy Swing...

    Seems like a major take-off in activity (smile)

    http://fisheye.codehaus.org/browse/groovy/trunk/groovy/modules/groovy-swt

     Good work!