Griffon: Error when execute code for JInternalFrame - groovy

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.

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!

Trouble generating an Intent with delegateDirective from a TouchEvent handler (Alexa)

I need to confirm deleting a task from a button event. For this reason, I want Alexa to ask for confirmation, and therefore I need to generate a DeleteTaskIntent from my code.
I have tried this:
return handlerInput.responseBuilder.addDelegateDirective({
name: 'DeleteTaskIntent',
confirmationStatus: 'NONE',
slots: {
idTask:{
name: 'idTask',
value: idTask,
confirmationStatus: 'NONE'
}
}
}).getResponse();
In my TouchEventHandler, but after checking the request in the requestEnvelope, I see this:
request: {
type: 'System.ExceptionEncountered',
requestId: 'amzn1.echo-api.request.9c2cf5f4-2f2c-419c-898c-05bd5f096810',
timestamp: '2022-02-23T11:30:08Z',
locale: 'es-ES',
error: {
type: 'INVALID_RESPONSE',
message: 'Directive "Dialog.Delegate" cannot be used in response to an event'
},
cause: {
requestId: 'amzn1.echo-api.request.0494d80d-c6ac-41d6-b3a2-dffd97f427b5'
}
}
And the error
{
"name": "AskSdk.GenericRequestDispatcher Error"
}
also appears, which suggests that no handler can handle this case.
Any idea about what I'm doing wrong when trying to generate the Intent?

Receiving error within Smartthings Device Handler

I am receiving the below error when trying to compile the device_handler code for the Sylvania Smart+ Plug. The code comes from https://images-na.ssl-images-amazon.com/images/I/71PrgM-PamL.pdf
The error:
Org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script_dth_metadata_0631e407_ffd8_4ceb_b49a_877fd47635df: 94: expecting ''', found '\r' # line 94, column 55. nalResult.value == "on" ? '{{ ^ 1 error
Line 94:
def descriptionText = finalResult.value == "on" ? '{{
metadata {
definition (name: "SYLVANIA Smart Plug", namespace: "ledvanceDH", author:
"Ledvance") {
capability "Actuator"
capability "Switch"
capability "Power Meter"
capability "Configuration"
capability "Refresh"
capability "Sensor"
capability "Health Check"
fingerprint profileId: "C05E", inClusters:
"1000,0000,0003,0004,0005,0006,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM",
model: "Plug 01", deviceJoinName: "SYLVANIA Smart Plug"
fingerprint profileId: "0104", inClusters:
"0000,0003,0004,0005,0006,0B05,FC01,FC08", outClusters: "0003,0019", manufacturer:
"LEDVACE", model: "PLUG", deviceJoinName: "SYLVANIA Smart Plug"
}
// simulator metadata
simulator {
// status messages
status "on": "on/off: 1"
status "off": "on/off: 0"
// reply messages
reply "zcl on-off on": "on/off: 1"
reply "zcl on-off off": "on/off: 0"
}
preferences {
section {
image(name: 'educationalcontent', multiple: true, images: [
"http://cdn.devicegse.smartthings.com/Outlet/US/OutletUS1.jpg",
"http://cdn.devicegse.smartthings.com/Outlet/US/OutletUS2.jpg"
])
}
}
// UI tile definitions
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4,
canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label: 'On', action: "switch.off",
icon: "st.Appliances.appliances17", backgroundColor: "#79b821", nextState: "turningOff"
attributeState "off", label: 'Off', action: "switch.on",
icon: "st.Appliances.appliances17", backgroundColor: "#565C51", nextState: "turningOn"
attributeState "turningOn", label: 'Turning On', action:
"switch.off", icon: "st.Appliances.appliances17", backgroundColor: "#60903A", nextState:
"turningOff"
attributeState "turningOff", label: 'Turning Off', action:
"switch.on", icon: "st.Appliances.appliances17", backgroundColor: "#CACACA", nextState:
"turningOn"
}
tileAttribute ("power", key: "SECONDARY_CONTROL") {
attributeState "power", label:'${currentValue} W'
}
}
standardTile("refresh", "device.power", inactiveLabel: false, decoration:
"flat", width: 2, height: 2) {
state "default", label:'', action:"refresh.refresh",
icon:"st.secondary.refresh"
}
main "switch"
details(["switch","refresh"])
}
}
// Parse incoming device messages to generate events
def parse(String description) {
log.debug "description is $description"
def finalResult = zigbee.getKnownDescription(description)
def event = [:]
//TODO: Remove this after getKnownDescription can parse it automatically
if (!finalResult && description!="updated")
finalResult =
getPowerDescription(zigbee.parseDescriptionAsMap(description))
if (finalResult) {
log.info "final result = $finalResult"
if (finalResult.type == "update") {
log.info "$device updates: ${finalResult.value}"
event = null
}
else if (finalResult.type == "power") {
def powerValue = (finalResult.value as Integer)/10
event = createEvent(name: "power", value: powerValue,
descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable:
true)
/*
Dividing by 10 as the Divisor is 10000 and unit is kW for
the device. AttrId: 0302 and 0300. Simplifying to 10
power level is an integer. The exact power level with
correct units needs to be handled in the device type
to account for the different Divisor value (AttrId: 0302)
and POWER Unit (AttrId: 0300). CLUSTER for simple metering is 0702
*/
}
else {
def descriptionText = finalResult.value == "on" ? '{{
device.displayName }} is On' : '{{ device.displayName }} is Off'
event = createEvent(name: finalResult.type, value:
finalResult.value, descriptionText: descriptionText, translatable: true)
}
}
else {
def cluster = zigbee.parse(description)
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07){
if (cluster.data[0] == 0x00) {
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
event = createEvent(name: "checkInterval", value: 60 * 12,
displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "ON/OFF REPORTING CONFIG FAILED- error
code:${cluster.data[0]}"
event = null
}
}
else {
log.warn "DID NOT PARSE MESSAGE for description : $description"
log.debug "${cluster}"
}
}
return event
}
def off() {
zigbee.off()
}
def on() {
zigbee.on()
}
/**
* PING is used by Device-Watch in attempt to reach the Device
* */
def ping() {
return zigbee.onOffRefresh()
}
def refresh() {
zigbee.onOffRefresh() + zigbee.electricMeasurementPowerRefresh()
}
def configure() {
// Device-Watch allows 2 check-in misses from device + ping (plus 1 min lag time)
// enrolls with default periodic reporting until newer 5 min interval is confirmed
sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false,
data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no
activity
refresh() + zigbee.onOffConfig(0, 300) + powerConfig()
}
//power config for devices with min reporting interval as 1 seconds and reporting
interval if no activity as 10min (600s)
//min change in value is 01
def powerConfig() {
[
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04
{${device.zigbeeId}} {}", "delay 2000",
"zcl global send-me-a-report 0x0B04 0x050B 0x29 1 600 {05 00}",
//The send-me-a-report is custom to the attribute type for CentraLite
"delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
]
}
private getEndpointId() {
new BigInteger(device.endpointId, 16).toString()
}
//TODO: Remove this after getKnownDescription can parse it automatically
def getPowerDescription(descMap) {
def powerValue = "undefined"
if (descMap.cluster == "0B04") {
if (descMap.attrId == "050b") {
if(descMap.value!="ffff")
powerValue = zigbee.convertHexToInt(descMap.value)
}
}
else if (descMap.clusterId == "0B04") {
if(descMap.command=="07"){
return [type: "update", value : "power (0B04) capability configured
successfully"]
}
}
if (powerValue != "undefined"){
return [type: "power", value : powerValue]
}
else {
return [:]
}
}
I should have thought of it sooner... The problem is with the copy/paste. The long lines were broken by a "return". I removed the returns and the script compiled.

Query CUstom Record using Custom Field in Mulesoft

I want to query a custom record based on the custom field in the custom record in Anypoint Studio. I tried using Search operation in Netsuite but it seems that I unable to write the dataweave code accordingly.
I used the code below
%dw 2.0
output application/java
---
{
customFieldList: {
customField: [{
internalId: "8",
scriptId: "abc"
} as Object {
class : "org.mule.module.netsuite.extension.api.ListOrRecordRef"
} ]
} as Object {
class : "org.mule.module.netsuite.extension.api.CustomFieldList"
},
recType: {
internalId: "10078"
}
} as Object {
class : "org.mule.module.netsuite.extension.api.CustomRecordSearchBasic"
}
I used basic Custom record search.I am getting below error
Message : null
Element : testFlow2/processors/0 # test:test.xml:18 (Transform Message)
Element DSL : <ee:transform doc:name="Transform Message" doc:id="c6dbb0ee-4979-4667-bab1-e0b5d72a6b2b">
<ee:message>
<ee:set-payload>%dw 2.0
output application/java
---
{
customFieldList: {
customField: [{
internalId: "8",
scriptId: "abc"
} as Object {
class : "org.mule.module.netsuite.extension.api.ListOrRecordRef"
} ]
} as Object {
class : "org.mule.module.netsuite.extension.api.CustomFieldList"
},
recType: {
internalId: "10078"
}
} as Object {
class : "org.mule.module.netsuite.extension.api.CustomRecordSearchBasic"
}</ee:set-payload>
</ee:message>
</ee:transform>
Error type : MULE:UNKNOWN
FlowStack : at testFlow2(testFlow2/processors/0 # test:test.xml:18 (Transform Message))
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.weave.v2.module.pojo.exception.CannotInstantiateException.message(CannotInstantiateException.scala:7)
at org.mule.weave.v2.parser.exception.LocatableException.getMessage(LocatableException.scala:18)
at org.mule.weave.v2.parser.exception.LocatableException.getMessage$(LocatableException.scala:15)
at org.mule.weave.v2.module.pojo.exception.CannotInstantiateException.getMessage(CannotInstantiateException.scala:6)
at org.mule.runtime.core.internal.el.dataweave.DataWeaveExpressionLanguageAdaptor$1.handledException(DataWeaveExpressionLanguageAdaptor.java:298)
at org.mule.runtime.core.internal.el.dataweave.DataWeaveExpressionLanguageAdaptor$1.evaluate(DataWeaveExpressionLanguageAdaptor.java:309)
at org.mule.runtime.core.internal.el.DefaultExpressionManagerSession.evaluate(DefaultExpressionManagerSession.java:105)
at com.mulesoft.mule.runtime.core.internal.processor.SetPayloadTransformationTarget.process(SetPayloadTransformationTarget.java:32)
at com.mulesoft.mule.runtime.core.internal.processor.TransformMessageProcessor.lambda$0(TransformMessageProcessor.java:92)
at java.util.Optional.ifPresent(Optional.java:159)
at com.mulesoft.mule.runtime.core.internal.processor.TransformMessageProcessor.process(TransformMessageProcessor.java:92)
at org.mule.runtime.core.api.util.func.CheckedFunction.apply(CheckedFunction.java:25)
at org.mule.runtime.core.api.rx.Exceptions.lambda$checkedFunction$2(Exceptions.java:84)
at org.mule.runtime.core.internal.util.rx.Operators.lambda$nullSafeMap$0(Operators.java:47)
at reactor.core.* (1 elements filtered from stack; set debug level logging or '-Dmule.verbose.exceptions=true' for everything)(Unknown Source)
at org.mule.runtime.core.privileged.processor.chain.* (2 elements filtered from stack; set debug level logging or '-Dmule.verbose.exceptions=true' for everything)(Unknown Source)
at reactor.core.* (6 elements filtered from stack; set debug level logging or '-Dmule.verbose.exceptions=true' for everything)(Unknown Source)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I don't know where I am doing wrong.
Any help is appreciated.
Thank you so much. But I figured it some how. I got the solution to it. But I can accept other solutions too. I just added a class and it worked.
Thank you again.

changing startup MVC group in Application.groovy issue

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}"
}
}

Resources