Saturday, 12 December 2009

Griffon Bytes: Application Version at runtime

Griffon is a Grails like application framework for developing desktop applications in Groovy. See my earlier post for links.
'Griffon bytes' are/will be quick tips and notes about Griffon development. I'm just a dabbler, so these tips are definitely not authoritative ...

Application Version at runtime
It's useful to know an app's version number during runtime, for example, in an 'About' message box. The version number is stored in a file called application.properties, and sure enough all the entries in application.properties are available within every MVC component.

Here's the short version:
def versionString = 'version '+app.applicationProperties.'app.version'

Here's an example of using app.version in a View script.
See also app.name, using the same technique.

application(title: app.applicationProperties.'app.name',
size:[320,480],
pack:false,
//location:[50,50],
locationByPlatform:true,
) {
menuBar()
{
menu(text:'Help')
{
menuItem (text:'About '+app.applicationProperties.'app.name', actionPerformed: {
optionPane(message: app.applicationProperties.'app.name' + ', version '+app.applicationProperties.'app.version'+"\n\nCopywrong 2009.\n")
.createDialog('About '+app.applicationProperties.'app.name')
.show()
})
}

}
label('content ...')
}


Note: I found this out by looking at Griffon 0.2 source code (see griffon.application.SwingApplication.groovy).


0 comments:

Blogger Syntax Highliter

Followers