changing startup MVC group in Application.groovy issue - groovy

I've created new Groffin module using IntelliJ. I was prompted for create-app command.
Creating a module was fine, and as you know, by default, when you ran an app, it shows applet with default content "Content goes here".
Next, I've added a second login MVC group in Application.groovy:
application {
title = 'Soms'
startupGroups = ['login']
// Should Griffon exit when no Griffon created frames are showing?
autoShutdown = true
// If you want some non-standard application class, apply it here
//frameClass = 'javax.swing.JFrame'
}
mvcGroups {
// MVC Group for "soms"
'soms' {
model = 'soms.SomsModel'
view = 'soms.SomsView'
controller = 'soms.SomsController'
}
// MVC Group for "login"
'login' {
model = 'soms.LoginModel'
view = 'soms.LoginView'
controller = 'soms.LoginController'
}
}
I've also created:
LoginModel.groovy (groovy class)
LoginController.groovy (groovy class)
LoginView.groovy (groovy script)
in the corresponding folders.
When I run project, it's giving errors:
Base Directory: D:\work\griffon\soms Running script
C:\Griffon-1.2.0\scripts\RunApp.groovy Resolving dependencies...
Dependencies resolved in 633ms. Environment set to development
Resolving framework plugin dependencies ... Framework plugin
dependencies resolved in 1114 ms. Resolving plugin dependencies ...
Plugin dependencies resolved in 741 ms. [griffonc] Compiling 1 source
file to d:\Users\akarasaev.griffon\1.2.0\projects\soms\classes\main
Launching application ... 2013-04-15 10:26:44,788 [main] INFO
griffon.swing.SwingApplication - Initializing all startup groups:
[login] 2013-04-15 10:26:46,311 [AWT-EventQueue-0] ERROR
org.codehaus.griffon.runtime.builder.UberBuilder - An error occurred
while building soms.LoginView#34a083f2
groovy.lang.MissingPropertyException: No such property: CENTER for
class: org.codehaus.griffon.runtime.builder.UberBuilder at
org.codehaus.griffon.runtime.builder.UberBuilder.getProperty(UberBuilder.groovy:187)
at
org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.getProperty(UberInterceptorMetaClass.groovy:210)
at soms.LoginView.run(LoginView.groovy:18) at
org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:152)
at
org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:160)
at
org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129)
2013-04-15 10:26:46,324 [main] ERROR
griffon.util.GriffonExceptionHandler - Uncaught Exception
groovy.lang.MissingPropertyException: No such property: CENTER for
class: org.codehaus.griffon.runtime.builder.UberBuilder at
org.codehaus.griffon.runtime.builder.UberBuilder.getProperty(UberBuilder.groovy:187)
at
org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.getProperty(UberInterceptorMetaClass.groovy:210)
at soms.LoginView.run(LoginView.groovy:18) at
org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:152)
at
org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:160)
at
org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129)
The same error happens when I try to run from command prompt.
Environment:
Win 7 Pro, 64-bit
IntelliJ IDEA ver 12.1
Griffon-1.2.0 JDK 1.6
LoginModel.groovy:
package soms
import groovy.beans.Bindable
import griffon.transform.PropertyListener
import static griffon.util.GriffonNameUtils.isBlank
#Bindable
#PropertyListener(enabler)
class LoginModel {
String login
String password
boolean submitEnabled
boolean resetEnabled
private enabler = { e ->
submitEnabled = !isBlank(login) && !isBlank(password)
resetEnabled = !isBlank(login) || !isBlank(password)
}
}
LoginView.groovy:
package soms
application(title: 'Login',
preferredSize: [320, 240],
pack: true,
locationByPlatform: true
)
borderLayout()
panel(constraints: CENTER, border: emptyBorder(6)) {
gridLayout(rows:3, columns:2, hgap:6, vgap:6)
label: 'login:'
textField columns: 20, text: bind(target: model, 'login', mutual: true)
label: 'password:'
textField columns: 20, text: bind(target: model, 'password', mutual: true)
}
panel(constraints: SOUTH){
gridLayout(rows:1, cols:2, hgap:6, vgap:6 )
button('reset', actionPerformed: controller.reset, enabled: bind{model.resetEnabled})
button('submit', actionPerformed: controller.reset, enabled: bind{model.submitEnabled})
}
LoginController.groovy:
package soms
class LoginController {
def model
def view
}

I found out that my LoginController.groovy was incomplete.
Now it's working and the correct LoginController.groovy as follows:
package soms
import griffon.transform.Threading
class LoginController {
def model
def view
#Threading(Threading.Policy.SKIP)
def reset = {
model.login = ''
model.password = ''
}
def submit = {
println "Login: ${model.login}"
println "Password: ${model.password}"
}
}

Related

Jaxb generating Java from multiple .xsd Files failed

i'm having this error and have no idea how it comes to this: it worked the last time I checked and I havenĀ“t made any single change
Build file 'D:\getVersionSoap\build.gradle' line: 134
Execution failed for task ':genJaxb'.
unable to parse the schema. Error messages should have been provided
Here is the piece of code:
"Line 134" is the line "xjc(destdir: sourcesDir)"
task genJaxb {
ext.sourcesDir = "${buildDir}/generated_sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schemaDir = "${projectDir}/src/main/resources"
outputs.dir sourcesDir
doLast() {
project.ant {
taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
classpath: configurations.jaxb.asPath
mkdir(dir: sourcesDir)
mkdir(dir: classesDir)
xjc(destdir: sourcesDir) {
schema(dir: schemaDir, includes: "**/ /* *.xsd")
arg(value: "-wsdl")
produces(dir: sourcesDir, includes: "**/ /* *.java")
}
javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true,
debugLevel: "lines,vars,source",
classpath: configurations.jaxb.asPath,
includeantruntime: "false") {
src(path: sourcesDir)
include(name: "**/ /* *.java")
include(name: "*.java")
}
copy(todir: classesDir) {
fileset(dir: sourcesDir, erroronmissingdir: false) {
exclude(name: "**/ /* *.java")
}
}
}
}
}
Any idea? Thank you!

GStreamer; Unable to pause - ""; Error: "No URI set" - MediaPlayer QML Type

Tried the following from http://doc.qt.io/qt-5/qml-qtmultimedia-mediaplayer.html#details
import QtQuick 2.4
import QtQuick.Window 2.2
import QtMultimedia 5.0
Window
{
visible: true
height: 1000
width: 1000
MediaPlayer {
id: mediaplayer
source: "/home/****/template/v1.avi"
}
VideoOutput {
anchors.fill: parent
source: mediaplayer
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: mediaplayer.play();
}
}
on
Ubuntu 14.04.2 LTS \n \l
with
GStreamer Core Library version 0.10.36
This gives the error shown in title on click.
I have confirmed that the file exists.
What else can be done now?
The way to set the url in Linux is:
file:///home/***/template/v1.avi
So, source: "/home/****/template/v1.avi" should be replaced by:
source: "file:///home/***/template/v1.avi"

Failing scripts in groovy using Grab

The following groovy scripts fail using command line
#Grab("org.apache.poi:poi:3.9")
println "test"
Error:
unexpected token: println # line 2, column 1.
println "test"
^
1 error
Removing the Grab, it works!
Anything I missed?
$>groovy -v
Groovy Version: 2.1.7 JVM: 1.7.0_25 Vendor: Oracle Corporation OS: Linux
Annotations can only be applied to certain targets. See SO: Why can't I do a method call after a #Grab declaration in a Groovy script?
#Grab("org.apache.poi:poi:3.9")
dummy = null
println "test"
Alternatively you can use grab as a method call:
import static groovy.grape.Grape.grab
grab(group: "org.apache.poi", module: "poi", version: "3.9")
println "test"
For more information refer to Groovy Language Documentation > Dependency management with Grape.
File 'Grabber.groovy'
package org.taste
import groovy.grape.Grape
//List<List[]> artifacts => [[<group>,<module>,<version>,[<Maven-URL>]],..]
static def grab (List<List[]> artifacts) {
ClassLoader classLoader = new groovy.lang.GroovyClassLoader()
def eal = Grape.getEnableAutoDownload()
artifacts.each { artifact -> {
Map param = [
classLoader: classLoader,
group : artifact.get(0),
module : artifact.get(1),
version : artifact.get(2),
classifier : (artifact.size() < 4) ? null : artifact.get(3)
]
println param
Grape.grab(param)
}
}
Grape.setEnableAutoDownload(eal)
}
Usage :
package org.taste
import org.taste.Grabber
Grabber.grab([
[ "org.codehaus.groovy.modules.http-builder", "http-builder", '0.7.1'],
[ "org.postgresql", "postgresql", '42.3.1', null ],
[ "com.oracle.database.jdbc", "ojdbc8", '12.2.0.1', null]
])

Griffon: Error when execute code for JInternalFrame

I just searching in google recently and want to try this code below to work in Griffon 1.2.0 but when i run it it give me error like this:
2013-03-23 12:13:01,877 [main] DEBUG griffon.plugins.i18n.I18nEnhancer - Enhancing org.codehaus.groovy.runtime.HandleMetaClass#b7ea5c[groovy.lang.ExpandoMetaClass#b7ea5c[class griffon.swing.SwingApplication]] with griffon.plugins.i18n.MessageSourceHolder#7b7bee
2013-03-23 12:13:01,909 [main] ERROR griffon.util.GriffonExceptionHandler - Uncaught Exception
groovy.lang.GroovyRuntimeException: Cannot add new method [getMessage] for arguments [[class java.lang.String, class java.util.Locale]]. It already exists!
at griffon.plugins.i18n.I18nEnhancer.enhance(I18nEnhancer.groovy:34)
at griffon.plugins.i18n.I18nEnhancer.enhance(I18nEnhancer.groovy)
at griffon.plugins.i18n.I18nEnhancer$enhance.call(Unknown Source)
at I18nSupportGriffonAddon.addonPostInit(I18nSupportGriffonAddon.groovy:40)
at griffon.core.GriffonAddon$addonPostInit.call(Unknown Source)
at griffon.core.GriffonAddon$addonPostInit.call(Unknown Source)
at org.codehaus.griffon.runtime.util.AddonHelper$_handleAddonsAtStartup_closure3.doCall(AddonHelper.groovy:110)
at org.codehaus.griffon.runtime.util.AddonHelper.handleAddonsAtStartup(AddonHelper.groovy:108)
at org.codehaus.griffon.runtime.core.DefaultAddonManager.doInitialize(DefaultAddonManager.java:33)
at org.codehaus.griffon.runtime.core.AbstractAddonManager.initialize(AbstractAddonManager.java:101)
at org.codehaus.griffon.runtime.util.GriffonApplicationHelper.initializeAddonManager(GriffonApplicationHelper.java:394)
at org.codehaus.griffon.runtime.util.GriffonApplicationHelper.prepare(GriffonApplicationHelper.java:149)
at org.codehaus.griffon.runtime.core.AbstractGriffonApplication.initialize(AbstractGriffonApplication.java:231)
at griffon.swing.AbstractSwingGriffonApplication.bootstrap(AbstractSwingGriffonApplication.java:75)
at griffon.swing.AbstractSwingGriffonApplication.run(AbstractSwingGriffonApplication.java:132)
at griffon.swing.SwingApplication.run(SwingApplication.java:45)
at griffon.swing.SwingApplication.main(SwingApplication.java:37)
[delete] Deleting directory G:\latihan\outer\staging\windows
Here's the code, this was originaly made by aalmiray
--- OuterController ---
package outer
class OuterController {
def model
def view
def builder
def newFrame = {
String id = 'inner-' + System.currentTimeMillis()
def (m, v, c) = createMVCGroup('inner', id, title: "Frame ${model.count++}")
builder.desktopPane(view.desktop) {
widget(v.innerFrame)
}
}
}
--- OuterModel ---
package outer
class OuterModel {
int count = 1
}
--- OuterView ---
package outer
application(title: 'outer',
preferredSize: [320, 240],
pack: true,
locationByPlatform:true,
iconImage: imageIcon('/griffon-icon-48x48.png').image,
iconImages: [imageIcon('/griffon-icon-48x48.png').image,
imageIcon('/griffon-icon-32x32.png').image,
imageIcon('/griffon-icon-16x16.png').image]) {
borderLayout()
button(newFrameAction, constraints: NORTH)
desktopPane(id: 'desktop', constraints: CENTER)
}
--- InnerController ---
package outer
class InnerController {
private String id
def view
void mvcGroupInit(Map args) {
id = args.mvcName
}
void mvcGroupDestroy() {
execAsync {
def desktop = view.innerFrame.parent
desktop.remove view.innerFrame
desktop.invalidate()
desktop.repaint()
}
}
def close = {
destroyMVCGroup id
}
}
--- InnerView ---
package outer
internalFrame(title: title, size: [200, 200], id: 'innerFrame',
visible: true, iconifiable: true, maximizable: true,
resizable: true, closable: true) {
gridLayout(cols: 1, rows: 2)
label 'Content goes here'
button closeAction
}
I need your help.
Regards,
Hendra
Gievn the error message I'd say you have the i18n and i18n-support plugins installed. These plugins are no longer required since Griffon 1.1.0. Uninstalling the plugins will solve your problem.
The reason is that the functionality provided by those plugins is now available in Griffon core since 1.1.0, so those plugins create a conflict.

How to run jetty 7+ with specified war with groovy/gradle?

I want to run Jetty 7+ with gradle build, but unlucky looks like there is no way to do this with jettyRun. So probably simplest idea to achieve what I want would be to use custom target:
task runJetty << {
def server = new Server()
// more code here
server.start()
server.join()
}
Unlucky I just started with gradle and I don't know groovy either, so it's hard for me to create proper target. I was looking over the internet but I wasn't able to find any solution.
Can anyone hit me with some sample groovy code which can run existing jar with jetty?
Ok, I found out how to run it using jetty directly from repository:
jettyVersion = "8.1.0.RC0"
configurations {
jetty8
}
dependencies {
jetty8 "org.mortbay.jetty:jetty-runner:$jettyVersion"
}
task runJetty8(type: JavaExec) {
main = "org.mortbay.jetty.runner.Runner"
args = [war.archivePath]
classpath configurations.jetty8
}
Here's a working version, using the jetty ant tasks. This finally enabled me the proper control with deamon=true.
configurations { jetty }
dependencies { jetty 'org.eclipse.jetty:jetty-ant:9.0.4.v20130625' }
task jetty(dependsOn: build) << {
ant.taskdef(name: 'jettyRun', classname: 'org.eclipse.jetty.ant.JettyRunTask', classpath: configurations.jetty.asPath, loaderref: "jetty.loader")
ant.typedef(name: "connector", classname: "org.eclipse.jetty.ant.types.Connector", classpath: configurations.jetty.asPath, loaderref: "jetty.loader")
ant.jettyRun(daemon:true, stopPort: 8999, stopKey: "STOP") {
webApp(war: THE_WAR_PRODUCING_TASK.archivePath, contextPath: '/context')
connectors { connector(port: 9000) }
systemProperties {
systemProperty(name: 'environment.type', value: 'development')
}
}
}
task jettyStop << {
ant.taskdef(name: 'jettyStop', classname: 'org.eclipse.jetty.ant.JettyStopTask', classpath: configurations.jetty.asPath)
ant.jettyStop(stopPort: 8999, stopKey: "STOP")
}
There is a jetty-eclipse-plugin that allows you to run newer versions of jetty
https://github.com/Khoulaiz/gradle-jetty-eclipse-plugin
jetty plugin supports jetty 6.1.25 at present
You can use something like this:
jettyRoot = '/path/to/your/jetty/root'
task runJetty7 << {
description = "Runs jetty 7"
ant.java(dir: jettyRoot, jar: jettyRoot + '/start.jar', failOnError: 'true', fork: 'true') {
classpath {
...
}
}
}

Resources