Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is the extract from the groovy code (63 61 lines):

No Format
	         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) ''Ctrl+X', closure:{ handleCutCopy(); text.cut() } )
	                 		action ( text:"'Copy"', accelerator: SWT.MOD1 + (int) ''Ctrl+C',closure:{ handleCutCopy(); text.copy() } )
	                 		action ( text:"'Paste"', accelerator: SWT.MOD1 + (int) ''Ctrl+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:			onEvent('Selection') {setStyle(it.widget)})
                		}
                		italicButton = toolItem(style:"'check"', toolTipText:"'Italic"') {
                    			image( src:"src/examples/groovy/swt/examples/TextEditor/'italic.png"' )
                    onEvent(type:"Selection", closure:			onEvent('Selection') {setStyle(it.widget)})
                		}
                		underlineButton = toolItem(style:"'check"', toolTipText:"'Underline"') {
                    			image( src:"src/examples/groovy/swt/examples/TextEditor/'underline.png"' )
                    onEvent(type:"Selection", closure:			onEvent('Selection'){setStyle(it.widget)})
                		}
                		strikeoutButton = toolItem(style:"'check"', toolTipText:"'Strikeout"') {
                    			image( src:"src/examples/groovy/swt/examples/TextEditor/'strikeout.png"' )
                    onEvent(type:"Selection", closure:			onEvent('Selection') {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:			onEvent('Selection') {fgColor(RED)})
                		}
                		toolItem(style:"'push"', toolTipText:"'Blue text"') {
                    			image( src:"src/examples/groovy/swt/examples/TextEditor/'blue.png"' )
                    onEvent(type:"Selection", closure:			onEvent('Selection'){fgColor(BLUE)})
                		}
                		toolItem(style:"'push"', toolTipText:"'Green text"') {
                    			image( src:"src/examples/groovy/swt/examples/TextEditor/'green.png"' )
                    onEvent(type:"Selection", closure:			onEvent('Selection'){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:			onEvent('Selection') {clear()})
                		}
	             	}

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

	             	text.addExtendedModifyListener(this)
        }
         mainapp.menuBarManager.updateAll( true )
        mainapp.	}
	mainapp.open()

   }

And here is the extract from the java code (175 lines)

...