Griffon 1.0.2发布

[复制链接]
查看11 | 回复5 | 2014-2-19 11:55:14 | 显示全部楼层 |阅读模式
Location:
http://griffon.codehaus.org
The Griffon team is happy to announce Griffon 1.0.2, the second maintenance release of the 1.0.x series.
Griffon is an application framework for developing desktop applications in the JVM, with Groovy as the primary language of choice.
This is mostly a bug-fix release with only two minor features added. The new features are the ability to specify additional source and resources paths. These paths may contain sources/resources that are of private nature are may be excluded from SCM. Also plugins like the mybatis plugin make use of this feature to specify mapping classes.
There were reports of applications behaving weirdly or not working at all on Windows platforms, specially when directory paths contained white space characters. We have finally plugged the hole on this one. A bug that prevented the --env option from being honored by griffonsh was also resolved.
Full listing of bugs fixed in this release can be found at [http://jira.codehaus.org/secure/ ... 3&version=18661]
Full release notes are located here.
You can download the Griffon distribution from the download page.
Thanks to all who contributed to this release!

回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Create a Griffon project
Once you have installed Griffon you can use the built-in target for creating new projects:griffon create-app复制代码The target will prompt you for the name of your project and create the project structure below:
%PROJECT_HOME%
+ griffon-app
+ conf ---> location of configuration artifacts like builder configuration
+ keys ---> keys for code signing
+ webstart ---> webstart and applet config
+ controllers ---> location of controller classes
+ i18n ---> location of message bundles for i18n
+ lifecycle ---> location of lifecycle scripts
+ models ---> location of model classes
+ resources ---> location of non code resources (images, etc)
+ views ---> location of view classes
+ lib
+ scripts ---> scripts
+ src
+ main ---> optional; location for Groovy and Java source files
(of types other than those in griffon-app/*)复制代码
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Create an Application Model
Make sure you are in the root directory of your project (for argument sake "DemoConsole", a simple script evaluator) by typingcd DemoConsole复制代码The "create-app" target created a Griffon MVC Triad for you in the models, views, and controllers directory named after the application. Hence you already have a model class DemoConsoleModel in the models directory.
The application model for the quick start is simple: the script to be evaluated and the results of the evaluation. Make sure to paste the following code into your copy of DemoConsoleModel.
DemoConsoleModel.groovyimport groovy.beans.Bindable
class DemoConsoleModel {
String scriptSource
@Bindable def scriptResult
@Bindable boolean enabled = true
}复制代码
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Create the Controller Logic
The controller for our quick start app is also simple: throw the contents of the script from the model at a groovy shell. Copy the following code into your controller.
DemoConsoleController.groovyimport java.awt.event.ActionEvent
class DemoConsoleController {
GroovyShell shell = new GroovyShell()
// these will be injected by Griffon
def model
def view
def executeScript(ActionEvent evt = null) {
model.enabled = false
doOutside {

def result

try {

result = shell.evaluate(model.scriptSource)

} finally {

edt {

model.enabled = true

model.scriptResult = result

}

}
}
}
}复制代码The Griffon framework will inject references to the other portions of the MVC triad if fields named model, view, and controller are present in the model or controller. This allows us to access the view widgets and the model data if needed
The executeScript method will be used in the view for the button action. Hence the ActionEvent parameter, and the default value so it can be called without an action event.
Finally, the Griffon framework can be configured to inject portions of the builders it uses. By default, the Threading classes are injected into the controller, allowing the use of the edt, doOutside and doLater methods from the SwingBuilder.
Also, the threading may look a bit obsessive. But good thread management is essential to a well functioning Swing application.
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Add Content to the View
The view classes contain the visual components for your application. As with the previous artifacts, copy the contents of the following snippet into its corresponding file: DemoConsoleView.
DemoConsoleView.groovy
application(title:'DemoConsole', pack:true, locationByPlatform:true) {
panel(border:emptyBorder(6)) {
borderLayout()
scrollPane(constraints:CENTER) {

textArea(text:bind(target:model, targetProperty:'scriptSource'),

enabled: bind {model.enabled},

columns:40, rows:10)
}
hbox(constraints:SOUTH) {

button("Execute", actionPerformed:controller.&executeScript,

enabled: bind {model.enabled})

hstrut(5)

label("Result:")

hstrut(5)

label(text:bind {model.scriptResult})
}
}
}复制代码The view script is a fairly straightforward SwingBuilder script. Griffon will execute these groovy scripts in context of it's UberBuilder (a composite of the SwingBuilder and whatever else is thrown in).
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Run the Application
To start your Griffon app run the following targetgriffon run-app复制代码This will run the application as a Java application. You can also use the run-webstart target to run the application from a WebStart/JNLP file.
The run-app script implies the execution of the package script. The package script creates file artifacts suitable for a Java application, a WebStart application, and an Applet, with code signed by a self-signed certificate. All from the same source tree. By default they go in the 'staging' directory.ls staging复制代码Try out the applet by bringing up the applet.html file in a browser. Or you can try them out directly by running the following commandsgriffon run-applet
griffon run-webstart复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行