Permlink Replies: 9 - Pages: 1 - Last Post: 10-Sep-2020 15:55 Last Post By: RobM Threads: [ Previous | Next ]
AndreWolff

Posts: 1,652
Registered: 14-Dec-2007
Minimal skin with Groovy GUI
Posted: 08-Sep-2020 08:22
  Click to reply to this thread Reply
RobM wrote:
Posted some basic details at wiki Groovy Scripting
Please generate the Minimal skin with a Groovy GUI.

Edited by: RobM on 08-Sep-2020 11:10
Split from jAlbum 21.1 beta to new thread and moved to skin development
RobM

Posts: 3,099
Registered: 4-Aug-2006
Re: Minimal skin with Groovy GUI
Posted: 08-Sep-2020 12:30   in response to: AndreWolff in response to: AndreWolff
  Click to reply to this thread Reply
AndreWolff wrote:
RobM wrote:
Posted some basic details at wiki Groovy Scripting
Please generate the Minimal skin with a Groovy GUI.

Edited by: RobM on 08-Sep-2020 11:10
Split to new thread and moved to skin development

I might, if I am not busy with other projects. However, I only understand a fraction of what I’m doing, the code works but I need to understand more - such as gridbag layout

My interest was in the new work api and using groovy for external tools, not to make a skin with groovy. A Java compiled skin is better.

You could try using the gui code above, saved as onload.groovy, just remove the two lines
 processAlbum(skipUnrated, skipExcluded, excludeRating)
dispose()
Things I need to understand are positioning of the gui window, and a whole lot more to make a skin’s gui.

When David says we know as much about Groovy’s swingBuilder as he does, then you know we are more or less on our own, at least for now.
davidekholm

Posts: 3,136
Registered: 18-Oct-2002
Re: Minimal skin with Groovy GUI
Posted: 08-Sep-2020 15:37   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Here's Minimal with a Groovy UI. (Not using SwingBuilder though). Note that I haven't "Groovyfied" it much (used shorter syntax), this as plain Java is interpreted faster and it was faster to convert from BeanShell. The most notable change is perhaps this use of Groovy-style lambda expressions for actionlisteners:
b = new JButton("Snygg")
add(b);
b.addActionListener { b.text="Button works" };
(Note how sloppy you can be with the use of ; )
RobM

Posts: 3,099
Registered: 4-Aug-2006
Re: Minimal skin with Groovy GUI
Posted: 09-Sep-2020 21:19   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Just for completeness, no matter what variation of code below, I always get an error saying 'Skin not registered with repository'. Possibly I have missed something obvious, but I can only get a Groovy GUI to work as an external tool.

import se.datadosen.jalbum.JAlbumContext;
import se.datadosen.component.*;
import net.jalbum.component.*;
import se.datadosen.jalbum.*;
import se.datadosen.util.Item;
import groovy.swing.SwingBuilder
import javax.swing.*
import java.awt.Color
 
//Test GUI
panel(name:"ui") {
	label("jAlbum skin UI")
}
 
// Set the UI
window.setSkinUI(ui);

Results in
java.io.IOException: Skin not registered with repository
se.datadosen.util.ScriptException: groovy.lang.MissingMethodException: No signature of method: net.jalbum.script.GroovierScriptEngine.panel() is applicable for argument types: (LinkedHashMap, Script1$_run_closure1) values: [[name:ui], Script1$_run_closure1@f3ea85e]
Possible solutions: any(), wait(), println(), grep(), find(), any(groovy.lang.Closure) in onload.groovy
	at se.datadosen.util.ScriptException.of(ScriptException.java:59)
	at se.datadosen.jalbum.AlbumBean.processScript(AlbumBean.java:2570)
	at se.datadosen.jalbum.JAlbumFrame.executeScript(JAlbumFrame.java:1282)
	at se.datadosen.jalbum.JMainSettingsPanel$5$1.run(JMainSettingsPanel.java:313)
davidekholm

Posts: 3,136
Registered: 18-Oct-2002
Re: Minimal skin with Groovy GUI
Posted: 09-Sep-2020 22:24   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
I think it's the missing "groovy-swing-3.0.5.jar" that causes problems interpreting the "panel" statement
RobM

Posts: 3,099
Registered: 4-Aug-2006
Re: Minimal skin with Groovy GUI
Posted: 09-Sep-2020 23:42   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
I think it's the missing "groovy-swing-3.0.5.jar" that causes problems interpreting the "panel" statement
Not really worth pursuing, due to the load-times, but for info. having installed the groovy-swing-3.0.5.jar I now get
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-swing is loaded in version 3.0.5 and you are trying to load version 3.0.0-alpha-3


Edited by: RobM on 09-Sep-2020 22:43
davidekholm

Posts: 3,136
Registered: 18-Oct-2002
Re: Minimal skin with Groovy GUI
Posted: 10-Sep-2020 10:40   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
RobM wrote:
davidekholm wrote:
I think it's the missing "groovy-swing-3.0.5.jar" that causes problems interpreting the "panel" statement
Not really worth pursuing, due to the load-times, but for info. having installed the groovy-swing-3.0.5.jar I now get
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-swing is loaded in version 3.0.5 and you are trying to load version 3.0.0-alpha-3

Edited by: RobM on 09-Sep-2020 22:43


Did you try that on v22? It should be shipped with v3.0.5 of Groovy?
RobM

Posts: 3,099
Registered: 4-Aug-2006
Re: Minimal skin with Groovy GUI
Posted: 10-Sep-2020 11:32   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
RobM wrote:
davidekholm wrote:
I think it's the missing "groovy-swing-3.0.5.jar" that causes problems interpreting the "panel" statement
Not really worth pursuing, due to the load-times, but for info. having installed the groovy-swing-3.0.5.jar I now get
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-swing is loaded in version 3.0.5 and you are trying to load version 3.0.0-alpha-3

Edited by: RobM on 09-Sep-2020 22:43

Did you try that on v22? It should be shipped with v3.0.5 of Groovy?

Yes, and I downloaded the complete Groovy 3.0.5 and copied the swing jar to jAlbum. But as we both agree that a Groovy scripted gui would be too slow to load, I don’t see it as a problem. I just wanted to document that, as it stands, you can’t use it as such. I’ll either delete the groovy wiki page contents, or spell out that it can’t be used to script an onload.groovy gui.

A Groovy GUI could be made using Eclipse, but they only support version 3.0 as a direct plugin.
ctwist

Posts: 559
Registered: 27-Sep-2003
Re: Minimal skin with Groovy GUI
Posted: 10-Sep-2020 15:49   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
RobM wrote:
A Groovy GUI could be made using Eclipse, but they only support version 3.0 as a direct plugin.
Eclipse supports Groovy 3.0.4 https://github.com/groovy/groovy-eclipse/wiki/3.8.0-Release-Notes. I don't know whether or not this helps (I am not really following this thread).
RobM

Posts: 3,099
Registered: 4-Aug-2006
Re: Minimal skin with Groovy GUI
Posted: 10-Sep-2020 15:55   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
ctwist wrote:
RobM wrote:
A Groovy GUI could be made using Eclipse, but they only support version 3.0 as a direct plugin.
Eclipse supports Groovy 3.0.4 https://github.com/groovy/groovy-eclipse/wiki/3.8.0-Release-Notes. I don't know whether or not this helps (I am not really following this thread).
Unfortunately, I find the Eclipse interface baffling, but I doubt I would want to build a full skin interface with Groovy. Maybe Andre would like to try?
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums