This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scala and SWT

16 replies
mailleux
Joined: 2008-08-23,
User offline. Last seen 4 years 7 weeks ago.
I have been using Scala Swing and outside of some memory leaking, it works fine and elegantly. However I have been looking into SWT for some reasons, and I wonder if any one has experience with it? Also any one considering doing a wrapper for SWT like the scala.swing? Any considerations on this path?

Thomas
Jesse Eichar
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala and SWT

I have 5 years of SWT experience and have also considered a scala-SWT
wrapper. Only problem is time :(. But I would be willing to do what
I can to help and provide assistance if you are interested.

Jesse

On 7-Jan-09, at 3:01 PM, Thomas Sant Ana wrote:

> I have been using Scala Swing and outside of some memory leaking, it
> works fine and elegantly. However I have been looking into SWT for
> some reasons, and I wonder if any one has experience with it? Also
> any one considering doing a wrapper for SWT like the scala.swing?
> Any considerations on this path?
>
> Thomas

James Iry
Joined: 2008-08-19,
User offline. Last seen 1 year 23 weeks ago.
Re: Scala and SWT
Not a fully blown library yet, but worth a look: http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

On Wed, Jan 7, 2009 at 6:01 AM, Thomas Sant Ana <mailleux [at] gmail [dot] com> wrote:
I have been using Scala Swing and outside of some memory leaking, it works fine and elegantly. However I have been looking into SWT for some reasons, and I wonder if any one has experience with it? Also any one considering doing a wrapper for SWT like the scala.swing? Any considerations on this path?

Thomas

mailleux
Joined: 2008-08-23,
User offline. Last seen 4 years 7 weeks ago.
Re: Scala and SWT


On Wed, Jan 7, 2009 at 1:43 PM, James Iry <jamesiry [at] gmail [dot] com> wrote:
Not a fully blown library yet, but worth a look: http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/


It's a nice approach to building the controls, but what I really like is the scala.swing way of handling events. However there is a catch in the design: it tends to generate memory leaks. That said I think it can be done in a way that does not generates leak, an still keep the clean approach of:

reaction += {
  case SomeEvent(s) => // do ti
}

I think a nice build DSL and the reactions/proxy approach would be great. The real catch is getting experience in SWT from people like Jesse Eichar to avoid creating something that will endup throwing SWT out of resource exceptions.


One thing I ran into which is really cool is the MigLayoutManager. I like it's approach.

Thomas
Stefan Zeiger
Joined: 2008-12-21,
User offline. Last seen 27 weeks 3 days ago.
Re: Scala and SWT

Thomas Sant Ana wrote:

> I have been using Scala Swing and outside of some memory leaking, it
> works fine and elegantly. However I have been looking into SWT for some
> reasons, and I wonder if any one has experience with it? Also any one
> considering doing a wrapper for SWT like the scala.swing? Any
> considerations on this path?

I'm considering a better Scala integration for http://novocode.com/naf/
(or even porting it to Scala entirely). Something similar to the
JavaScript bindings (inspired by JavaFX) which I added in the latest
release should work for Scala, too.

My main problem is a mismatch of available ideas and available time :)

rodant
Joined: 2009-04-10,
User offline. Last seen 3 years 5 weeks ago.
Re: Re: Scala and SWT
Hello,

well I had some time the last weeks for this topic and I started some work towards an Scala SWT wrapper. I took as starting point the mentioned work in

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, may version isn't as functional in the link above. I was inspired by the builder approach found in Groovy's Swing builder or JavaFX. This means, the builder has a state tracking the current position in the component tree. The API handle attributes of nodes in a different way as the declaration of child nodes, also as in Groovy's Swing builder and in XML documents. I think, in this way the tree structure can be recognized easily.

Another design goals:
  • enable an easy use in the RCP context. The builder has a secondary constructor taking a composite as parameter.
  • make the use of Java models as easy as with Scala, specially for data binding
  • use compiler type checking as much as possible to avoid errors
  • the DSL should be intuitive and declarative, but not as normal language, the target users are programmers

I'm not completely happy with it yet, but I wanted to get some feed back from the community before to invest more work on it. Specially data binding could be more concise. I wish, i could write "bind(user.firstName)" instead of accessor functions, but I don't know how to get it, my Scala skills are still modest. Also would be nice to have more flexibility in the API, for example if no binding is wished, to leaved left and not to be forced of using an empty binding.

I implemented the same example as in the refereed link with the DSL and in pure Java to compare and have a feeling of the potential win. The Java code is larger of course, but more relevant from my point of view is the readability aspect. I compared using "wc" the method buildGui() in the Java version with the equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
  77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
  35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and ideas. The Eclipse project containing the whole code is attached. If having the Scala plug-in 2.7.4 is all you need.

Cheers,
Antonio R. Rodríguez S.

2009/1/15 Stefan Zeiger <szeiger [at] novocode [dot] com>
Thomas Sant Ana wrote:

> I have been using Scala Swing and outside of some memory leaking, it
> works fine and elegantly. However I have been looking into SWT for some
> reasons, and I wonder if any one has experience with it? Also any one
> considering doing a wrapper for SWT like the scala.swing? Any
> considerations on this path?

I'm considering a better Scala integration for http://novocode.com/naf/
(or even porting it to Scala entirely). Something similar to the
JavaScript bindings (inspired by JavaFX) which I added in the latest
release should work for Scala, too.

My main problem is a mismatch of available ideas and available time :)

--
Stefan Zeiger | http://szeiger.de | http://novocode.com




--
Antonio R. Rodríguez Santiesteban

E-Mail: rodant68 [at] googlemail [dot] com
rodant
Joined: 2009-04-10,
User offline. Last seen 3 years 5 weeks ago.
Re: Re: Scala and SWT
Hello,

I'm sending my message (see below) again because I can't see it in the mailing list. Maybe it is a problem with the attachment. Now I send the link to the Github repository instead:

http://github.com/rodant/ScalaSWT/tree/master

Cheers,
Antonio Rodríguez S.

2009/6/4 Antonio Rodríguez S. <rodant68 [at] googlemail [dot] com>
Hello,

well I had some time the last weeks for this topic and I started some work towards an Scala SWT wrapper. I took as starting point the mentioned work in

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, may version isn't as functional in the link above. I was inspired by the builder approach found in Groovy's Swing builder or JavaFX. This means, the builder has a state tracking the current position in the component tree. The API handle attributes of nodes in a different way as the declaration of child nodes, also as in Groovy's Swing builder and in XML documents. I think, in this way the tree structure can be recognized easily.

Another design goals:
  • enable an easy use in the RCP context. The builder has a secondary constructor taking a composite as parameter.
  • make the use of Java models as easy as with Scala, specially for data binding
  • use compiler type checking as much as possible to avoid errors
  • the DSL should be intuitive and declarative, but not as normal language, the target users are programmers

I'm not completely happy with it yet, but I wanted to get some feed back from the community before to invest more work on it. Specially data binding could be more concise. I wish, i could write "bind(user.firstName)" instead of accessor functions, but I don't know how to get it, my Scala skills are still modest. Also would be nice to have more flexibility in the API, for example if no binding is wished, to leaved left and not to be forced of using an empty binding.

I implemented the same example as in the refereed link with the DSL and in pure Java to compare and have a feeling of the potential win. The Java code is larger of course, but more relevant from my point of view is the readability aspect. I compared using "wc" the method buildGui() in the Java version with the equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
  77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
  35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and ideas. The Eclipse project containing the whole code is attached. If having the Scala plug-in 2.7.4 is all you need.

Cheers,
Antonio R. Rodríguez S.

2009/1/15 Stefan Zeiger <szeiger [at] novocode [dot] com>
Thomas Sant Ana wrote:

> I have been using Scala Swing and outside of some memory leaking, it
> works fine and elegantly. However I have been looking into SWT for some
> reasons, and I wonder if any one has experience with it? Also any one
> considering doing a wrapper for SWT like the scala.swing? Any
> considerations on this path?

I'm considering a better Scala integration for http://novocode.com/naf/
(or even porting it to Scala entirely). Something similar to the
JavaScript bindings (inspired by JavaFX) which I added in the latest
release should work for Scala, too.

My main problem is a mismatch of available ideas and available time :)

--
Stefan Zeiger | http://szeiger.de | http://novocode.com




--
Antonio R. Rodríguez Santiesteban

E-Mail: rodant68 [at] googlemail [dot] com



--
Dr. Antonio R. Rodríguez Santiesteban
Java-Platform-Developer

E-Mail: rodant68 [at] googlemail [dot] com
rodant
Joined: 2009-04-10,
User offline. Last seen 3 years 5 weeks ago.
Scala and SWT

Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

* enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
* make the use of Java models as easy as Scala ones, specially for data binding
* use compiler type checking as much as possible to avoid errors and obtain
better IDE support
* the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers

I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
77 220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
35 96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:

http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.

Mason Green
Joined: 2009-06-07,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala and SWT
Excellent! 

Is it possible to use ScalaSWT with LWJGL or JORL?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.


rodant
Joined: 2009-04-10,
User offline. Last seen 3 years 5 weeks ago.
Re: Scala and SWT
Hello Mason,

thanks for your feedback. My primary goal is the development of conventional user interfaces. Nevertheless animation, 3D and game programming could be a future issue for ScalaSWT as it is also in the case for JavaFX. Did you take a look at the animation features of last? I don't know it in detail, but it seams to be very promising.

Cheers,
Antonio R. Rodríguez S.

2009/6/7 Mason Green <mason [dot] green [at] gmail [dot] com>
Excellent! 

Is it possible to use ScalaSWT with LWJGL or JORL?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Gilles SCOUVART
Joined: 2009-03-06,
User offline. Last seen 42 years 45 weeks ago.
RE: Scala and SWT
Are you aware of the project named 'XScalaWT' (http://bitbucket.org/djo/xscalawt/)? It seems pretty advanced too. It would be awesome to take advantage of your combined efforts!   Cheers, Gilles.
From: Antonio Rodríguez S. [mailto:rodant68 [at] googlemail [dot] com]
Sent: lundi 8 juin 2009 11:46
To: Mason Green
Cc: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Scala and SWT

Hello Mason,

thanks for your feedback. My primary goal is the development of conventional user interfaces. Nevertheless animation, 3D and game programming could be a future issue for ScalaSWT as it is also in the case for JavaFX. Did you take a look at the animation features of last? I don't know it in detail, but it seams to be very promising.

Cheers,
Antonio R. Rodríguez S.

2009/6/7 Mason Green <mason [dot] green [at] gmail [dot] com>
Excellent! 

Is it possible to use ScalaSWT with LWJGL or JORL?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
rodant
Joined: 2009-04-10,
User offline. Last seen 3 years 5 weeks ago.
Re: Scala and SWT
Thanks for the hint. I didn't know about XScalaWT, but I'll take a look at it. Are you involved in XScalaWT?

Cheers,
Antonio Rodríguez S.

2009/6/9 Gilles SCOUVART <Gilles [dot] SCOUVART [at] n-side [dot] be>
Are you aware of the project named 'XScalaWT' (http://bitbucket.org/djo/xscalawt/)? It seems pretty advanced too. It would be awesome to take advantage of your combined efforts!   Cheers, Gilles.
From: Antonio Rodríguez S. [mailto:rodant68 [at] googlemail [dot] com]
Sent: lundi 8 juin 2009 11:46
To: Mason Green
Cc: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Scala and SWT

Hello Mason,

thanks for your feedback. My primary goal is the development of conventional user interfaces. Nevertheless animation, 3D and game programming could be a future issue for ScalaSWT as it is also in the case for JavaFX. Did you take a look at the animation features of last? I don't know it in detail, but it seams to be very promising.

Cheers,
Antonio R. Rodríguez S.

2009/6/7 Mason Green <mason [dot] green [at] gmail [dot] com>
Excellent! 

Is it possible to use ScalaSWT with LWJGL or JORL?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com



--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Gilles SCOUVART
Joined: 2009-03-06,
User offline. Last seen 42 years 45 weeks ago.
RE: Scala and SWT
Not at all, but I carefully follow anything that could be leading to an Eclipse PDE taking advantage of Scala, since we have a framework based on RAP, the web version of RCP. Thanks already for your work!   Gilles.
From: Antonio Rodríguez S. [mailto:rodant68 [at] googlemail [dot] com]
Sent: mardi 9 juin 2009 22:42
To: Gilles SCOUVART
Cc: Mason Green; scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Scala and SWT

Thanks for the hint. I didn't know about XScalaWT, but I'll take a look at it. Are you involved in XScalaWT?

Cheers,
Antonio Rodríguez S.

2009/6/9 Gilles SCOUVART <Gilles [dot] SCOUVART [at] n-side [dot] be>
Are you aware of the project named 'XScalaWT' (http://bitbucket.org/djo/xscalawt/)? It seems pretty advanced too. It would be awesome to take advantage of your combined efforts!   Cheers, Gilles.
From: Antonio Rodríguez S. [mailto:rodant68 [at] googlemail [dot] com]
Sent: lundi 8 juin 2009 11:46
To: Mason Green
Cc: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Scala and SWT

Hello Mason,

thanks for your feedback. My primary goal is the development of conventional user interfaces. Nevertheless animation, 3D and game programming could be a future issue for ScalaSWT as it is also in the case for JavaFX. Did you take a look at the animation features of last? I don't know it in detail, but it seams to be very promising.

Cheers,
Antonio R. Rodríguez S.

2009/6/7 Mason Green <mason [dot] green [at] gmail [dot] com>
Excellent! 

Is it possible to use ScalaSWT with LWJGL or JORL?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com



--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala and SWT
Looks real neat! I'm trying to see if I could make a real application based on it!I made some updates, mainly to a derived class. The changes I made to the original file are noted with a comment. I'm attaching my version of the files. Feel free to fold my subclass into the parent. By the way, is binding one way or bidirectional? How can I get controls to update based on changes to a model?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.


rodant
Joined: 2009-04-10,
User offline. Last seen 3 years 5 weeks ago.
Re: Scala and SWT
Hello Naftoli,

thanks for your contribution! I included your changes in SWTBuilder, but with one change in the signature of your shell method's version. I wanted to keep both variants by overloading the method and the change was required to make the simpler version also available. This would be easier using Scala 2.8's default parameters.

The changes are now on Github, well at least I have committed, but I don't see it on the Web interface yet. Next time you want to contribute, you can also make a fork if you like.

Concerning real applications. Despite support for a lot of features is still missing, I think it could be used. In the areas where no support is available, it is possible to program against the Java APIs directly and apply a kind of hybrid approach, maybe.

Data binding is currently implemented to support the widget to model direction only. But eclipse data binding is very flexible and supports both. I was trying to make it work, but it is not trivial, if we don't want to impose strong requirements on the beans to be bound; they must fulfil an informal contract based on BeanPropertyChangeSupport. But if you need the bidirectional sync, I would continue working on it.

It was really great with your support and thanks again for that, that's the strength of open source!

Cheers.

2009/6/12 Naftoli Gugenheim <naftoligug [at] gmail [dot] com>
Looks real neat! I'm trying to see if I could make a real application based on it!I made some updates, mainly to a derived class. The changes I made to the original file are noted with a comment. I'm attaching my version of the files. Feel free to fold my subclass into the parent. By the way, is binding one way or bidirectional? How can I get controls to update based on changes to a model?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala and SWT
I got bidirectional binding working, I'll send it soon.

2009/6/15 Antonio Rodríguez S. <rodant68 [at] googlemail [dot] com>
Hello Naftoli,

thanks for your contribution! I included your changes in SWTBuilder, but with one change in the signature of your shell method's version. I wanted to keep both variants by overloading the method and the change was required to make the simpler version also available. This would be easier using Scala 2.8's default parameters.

The changes are now on Github, well at least I have committed, but I don't see it on the Web interface yet. Next time you want to contribute, you can also make a fork if you like.

Concerning real applications. Despite support for a lot of features is still missing, I think it could be used. In the areas where no support is available, it is possible to program against the Java APIs directly and apply a kind of hybrid approach, maybe.

Data binding is currently implemented to support the widget to model direction only. But eclipse data binding is very flexible and supports both. I was trying to make it work, but it is not trivial, if we don't want to impose strong requirements on the beans to be bound; they must fulfil an informal contract based on BeanPropertyChangeSupport. But if you need the bidirectional sync, I would continue working on it.

It was really great with your support and thanks again for that, that's the strength of open source!

Cheers.

2009/6/12 Naftoli Gugenheim <naftoligug [at] gmail [dot] com>
Looks real neat! I'm trying to see if I could make a real application based on it!I made some updates, mainly to a derived class. The changes I made to the original file are noted with a comment. I'm attaching my version of the files. Feel free to fold my subclass into the parent. By the way, is binding one way or bidirectional? How can I get controls to update based on changes to a model?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com

Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala and SWT
So far I have a little screen that lets you edit records in a database. They are saved automatically when you switch records. New and delete are not yet implemented. It uses lift-mapper.I'm not too familiar with git.

2009/6/15 Naftoli Gugenheim <naftoligug [at] gmail [dot] com>
I got bidirectional binding working, I'll send it soon.

2009/6/15 Antonio Rodríguez S. <rodant68 [at] googlemail [dot] com>
Hello Naftoli,

thanks for your contribution! I included your changes in SWTBuilder, but with one change in the signature of your shell method's version. I wanted to keep both variants by overloading the method and the change was required to make the simpler version also available. This would be easier using Scala 2.8's default parameters.

The changes are now on Github, well at least I have committed, but I don't see it on the Web interface yet. Next time you want to contribute, you can also make a fork if you like.

Concerning real applications. Despite support for a lot of features is still missing, I think it could be used. In the areas where no support is available, it is possible to program against the Java APIs directly and apply a kind of hybrid approach, maybe.

Data binding is currently implemented to support the widget to model direction only. But eclipse data binding is very flexible and supports both. I was trying to make it work, but it is not trivial, if we don't want to impose strong requirements on the beans to be bound; they must fulfil an informal contract based on BeanPropertyChangeSupport. But if you need the bidirectional sync, I would continue working on it.

It was really great with your support and thanks again for that, that's the strength of open source!

Cheers.

2009/6/12 Naftoli Gugenheim <naftoligug [at] gmail [dot] com>
Looks real neat! I'm trying to see if I could make a real application based on it!I made some updates, mainly to a derived class. The changes I made to the original file are noted with a comment. I'm attaching my version of the files. Feel free to fold my subclass into the parent. By the way, is binding one way or bidirectional? How can I get controls to update based on changes to a model?

On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Hello,

well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)

http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/

but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.

Another design goals:

   * enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
   * make the use of Java models as easy as Scala ones, specially for data binding
   * use compiler type checking as much as possible to avoid errors and obtain
better IDE support
   * the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers


I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.

I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:

antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
 77  220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
 35   96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$

The numbers represents lines, words and chars.

Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:


http://github.com/rodant/ScalaSWT/tree/master

In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.

Cheers,
Antonio R. Rodríguez S.





--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler

Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland