pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calathus <calat...@gmail.com>
Subject Re: [pivot] are there any tools to convert bxml to Java?
Date Tue, 21 Dec 2010 19:06:00 GMT
Greg,
There were a few questions, and I did not have investigated these lines
much, so I searched the similar projects.

For the CRUD stuff, I will answer later.

For the Scala Pivot builder approach, as you and Clint suggested, I was
thinking something similar o Gvoovy's SwingBuilder approach.
Right now, Scala 2.8.1's scala.swing library is not taking this type of
builder approach. So I looked for some other library.
I found squib project:
http://code.google.com/p/scala-squib/


Unfortunately, Scala is still evolving language, this squid project could
not be compiled in the latest 2.8.1, but with a few code changes, I could
resolved these errors. (but somehow how, running demo did not work with ant)

So If we change Swing API to Pivot API, we will be able to have similar
builder.
Here is a sample code from the squib project:

import java.awt.GridBagConstraints._
import java.beans.{PropertyChangeListener, PropertyChangeEvent}
import java.lang.reflect.Method
import javax.swing._
import javax.swing.event._

import scala.reflect.BeanProperty

import net.miginfocom.swing.MigLayout

package tfd.scala.squib.demo {

import tfd.scala.squib._
import tfd.scala.squib.event._

 object RGBSliders extends Application {
    class RGBCanvasComponent extends JComponent {
        private var red:Int = 0
        private var green:Int = 0
        private var blue:Int = 0

        def setRed(value:Int) = {
            if (value != red) {
                red = value
                repaint()
            }
        }

        def setGreen(value:Int) = {
            if (value != green) {
                green = value
                repaint()
            }
        }

        def setBlue(value:Int) = {
            if (value != blue) {
                blue = value
                repaint()
            }
        }

        override def paint(g: Graphics):Unit = {
            g.setColor(new Color(red, green, blue))
            val d = getSize()
            g.fillRect(0,0, d.width, d.height)
        }
    }

    object rgbcanvas extends BuiltComponent[RGBCanvasComponent] {
        def newComponent = new RGBCanvasComponent()
    }

    lazy val rgb = rgbcanvas.id("rgbcanvas")

    frame(
            'title->"RGB Selector",
            'visible -> true,
            'defaultCloseOperation -> JFrame.EXIT_ON_CLOSE,
            'layout -> new MigLayout("fill, wrap 3", "align right, grow",
"align top, grow"),
            contents(
                 label("Red:"),
                 slider("red", 'maximum -> 255, 'minimum-> 0, 'value->0,
sliderValueChanged(&rgb.setRed)),
                 rgbcanvas("rgbcanvas",
                               'preferredSize -> new Dimension(100,100),
                               'red -> 0,
                               'green -> 0,
                               'blue -> 0
                 ) -> "spany 3",
                 label("Green:"),
                 slider("green", 'maximum -> 255, 'minimum-> 0, 'value->0,
sliderValueChanged(&rgb.setGreen)),
                 label("Blue:"),
                 slider("blue", 'maximum -> 255, 'minimum-> 0, 'value->0,
sliderValueChanged(&rgb.setBlue))
            )
    ).pack
 }
}


On Mon, Dec 20, 2010 at 6:04 AM, Greg Brown <gk_brown@verizon.net> wrote:

> As Chris mentioned, Pivot does not currently provide a BXML to Java
> compiler. We actually prototyped one a while back, but it was never
> completed due to other priorities.
>
> Generating byte code from BXML might be tough, but converting it to a Java
> source file would probably be pretty easy. Let me know if you are interested
> in trying to write something like this - I would be happy to try to help
> when I can.
>
> G
>
> On Dec 19, 2010, at 10:26 PM, calathus wrote:
>
> > Hi,
> > I'm looking for a tool to convert bxml file to equivalent Java source
> program.
> > Are there such tools?
> >
> > I just started using pivot, but many of sample is based on bxml.
> > I think in order to develop a UI library with Java generic class, XML
> file based approach is not appropriate.
> >
> > And xml based approach will reduce static error detection capability.
> > I liked to see  more examples using  Java classes to define GUI without
> relying on bxml files.
> >
> > --
> > Cheers,
> > calathus
> >
> >
> >
>
>


-- 
Cheers,
calathus

Mime
View raw message