Does gwt have a built in parser for converting css based strings to java constructs?
IE I'm interested in writing my own widget that takes for instance height/width:
public class MyWidget extends Composite{
private double width;
private Style.Unit widthUnit;
private double height;
private Style.Unit heightUnit;
/**
* @width - width of my widget in CSS dimensions (ie. "10px", "1em" ...)
* @height - height of my widget in CSS dimensions (ie. "10px", "1em" ...)
*/
public MyWidget(String width, String height){
// Parse out strings and set dimensions / units
}
}
I could easily do some regex on this but I thought I'd see if there was some sort of built in mechanism for this, I'd hate to re-invent...
Also, I of course thought about just accepting double width, Style.Unit widthUnit
in the constructor, but UiObject's setWidth
takes a CSS string, so I still have to do some String munging, albeit the other way around. Ideally I'd have 2 constructors to achieve both possibilities with a simple mechanism to parse the Strings / dimensions and Units properly.
EDIT:
Forgot to mention the REASON that i'd like to parse out these values:
I'm trying to write a simple scroll panel (think iphone nav) so when a user clicks a button, a new 'item' scrolls in from the right.
On the backend this would be:
1) Fetch new scroll item
2) Extend scroll wrapper to accompany new item (this is where i need actual widths)
2) Append to item scroll wrapper
3) Animate scroll wrapper (by sliding left the width of 1 item) to expose newly added item to visible section of panel wrapper
The reason I need original widths is because I'd like to extend my scroller panel by the width of the item added to it. If I'm just getting strings, I can't exactly say setWidth( currentWidth + itemWidth)
Basically I'm trying to mimic JQuery Tools Scroller