On Dec 29, 1:12 pm, swap_i <[email protected]> wrote:
> Hello! I'm new in GWT development and need some help. I use GWT 2.0
> and want define once some constant. For example, I need to define
> mainColor = #rrggbb and want use it in various places, like CSS,
> MyWidget, MyWidget.ui.xml, etc.
>
> I read about CssResource, read about working with CSS docs, but can't
> understand, what rule is the best.
>
> Now my idea realized like this:
>
> GlobalRes.java:
> ---------------------------------------------------------------------------
> --------------
> public class GlobalRes {
>
> static public int gap = 10;
>
> static public String getGap() {
> return gap + "px";
> }
>
> static public String getDoubleGap() {
> return (gap * 2) + "px";
> }
>
> static public String mainColor() {
> return "#e6dbcf";
> }}
>
> ---------------------------------------------------------------------------
> --------------
>
> ControlPanel.css:
> ---------------------------------------------------------------------------
> --------------
> @eval gap admin.client.GlobalRes.getGap();
> @eval gap2 admin.client.GlobalRes.getDoubleGap();
> @eval mainColor admin.client.GlobalRes.mainColor();
>
> body {
> padding: gap;
>
> }
>
> .header {
> background: mainColor;
> margin-bottom: gap2;}
>
> ---------------------------------------------------------------------------
> --------------
>
> I can use variables like 'gap' and 'gap2' in many places. If I prefer,
> I can change this gap in 1 place (GlobalRes.java) and value changed in
> 100 places. But it has bottleneck. First lines in ControlPanel.css I
> must repeat in other CSS-files.
>
> There is my question: I miss some docs and my code is little stupid?
> Anyone can help me?
You can use multiple CSS files in @Source annotations in ClientBundle
interfaces (and src="" on <ui:style> in UiBinder's ui.xml files), so
you can put your "variables" in a "global.css" that you "load" any
time you need it:
@Source({ "global.css", "ControlPanel.css" })
ControlPanelStyle controlPanel();
or
<ui:style src="global.css">
.cls { color: mainColor; }
</ui:style>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.