jastrachan | 15 Apr 09:34 2004
Picon

Re: Builders :- CDATA / plain text / escape mechanism ?

On 15 Apr 2004, at 08:13, Paul Hammant wrote:
> Folks,
>
> Thicky uses builders to make form based GUIs. Those forms can contain 
> any JComponent (or one day SWT equivs) derived components. In order 
> for Thicky to get closer to the feature list of HTML, it would be 
> great to see some way of having plain paragraphs in groovy source.  
> Thus this in HTML ....
>
>  <body>
>    <p>Mary had a little lamb</p>
>  </body>
>
> .... could be encoded as ....
>
>  body {
>    p { # Mary had a little lamb # }
>  }
>
> .. or even ..
>
>  body {
>    p {
>      # Mary had a little lamb #
>      font( blah blah)
>    }
>  }
>
> .. or some such.  The escaped characters, used in context of a builder 
> could be handed via some registered method like setText().
>
> Thoughts? Or am I asking for a feature that has been done already? :-)

I guess there's no reason why we couldn't extend SwingBuilder (maybe a 
custom derivation) to add HTML-ish tags.

body {
     p("Mary had a little lamb")
}

we're not great at mixed content as yet. So we might need to use a 
magic 'text' method to be able to do mixed content...

body {
     p {
	text("Mary had a ")
	b("little")
	text(" lamb")
     }
}

Though I dunno how you'd implement that in Swing anyways.

All thats required is implementing these methods in the builder.

I think you can typically set the font on a Swing component separately 
to the text content so you could do something like

body {
     p("fooo")
     font(whatever)
}

James
-------
http://radio.weblogs.com/0112098/

Gmane