CSS Tools add-on

Good morning everyone,

Just wanted to start the official/mandatory forum thread for one of the new add-ons I created lately, called
CSS Tools
.

Go over to
the Directory page
to see what it’s all about. In brief, it contains utility classes that help you when creating new GWT widgets that require some detailed information from the CSS/layout.


Source code
is located in GitHub, as well as the
issue tracker
.

To see how to use this add-on, check out
SimpleLayout add-on
for instance.

Keep up coding,
Jouni

Hello,
I tried to create new css Rule, but i am getting some problems.

please take a look over my code,
CSSRule rule = CSSRule.create( “.v-selector” );
rule.setProperty( “float”, “left” );

and i am getting the following error
javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: org.vaadin.csstools.client.CSSRule.createRule(Ljava/lang/String;Lorg/vaadin/csstools/client/CSSRule;)

Thanks

Hi,

The CSS Tools add-on is only for client side use, meaning you can only use it inside GWT code. The add-on is only needed during the GWT compilation, if you don’t use the RenderInformation class in your code.

So you can’t create new CSS rules from the server side. Use the CSSInject add-on for that. I should probably combine these add-ons so that all CSS related things could be found from the same add-on. Also, it would be great if the CSSRule class worked on the server side as well, but that’s not on my priority list atm.

Maybe I’m blind, but I can’t find an example of you using CSS Tools in SimpleLayout. In particular, I’d like to know what the callback signature should be. Maybe if there were an Interface that it implements?

Hi!

I’m not sure which part of CSS Tools you’re trying to use, so here’s examples of all of them:


ComputedStyle (client side only)


VSimpleLayout.java#L202


CSSRule (client side only)


VSimpleLayout.java#L103


RenderInformation (server side only]


CssToolsTestApplication.java#L44

It’s RenderInfo. Works like a charm! Thanks!

[b]

[/b]If I do a ?debug on my Vaadin window, I see "
RenderInfoFetcher: NO CLIENT IMPLEMENTATION FOUND
". Is this something to be concerned about? I also see "
ClassCastException: null
" but I don’t know if it is related.

What Vaadin version are you using?

Hi, thank you for add-on.

I am using RenderInfo in server side with vaadin 6.8 inside Window.windowResized callback. This add-on only works in the debug mode (url?debug), any clue ?

Thank you.

Hi,

I had to add conditional guard in my code in order to make RenderInfo work inside a ResizeListener. Is there any way to avoid this workaround?

    this.addListener(new ResizeListener() {
        public void windowResized(ResizeEvent e) {
            Set<Window> windows = MyClass.this.getApplication().getMainWindow().getChildWindows();                
            int infoFetcherCount = 0;
            for (Window win : windows) {
                if (win.getClass().getName().contains("RenderInfoFetcher"))
                    infoFetcherCount++;
            }
            if (infoFetcherCount == 0) {
                RenderInfo.get(map, new Callback() {
                    public void infoReceived(RenderInfo info) {
                        String width = info.getProperty(CssProperty.width);
                        String height = info.getProperty(CssProperty.height);
                        MyClass.this.sizeLabel.setValue("W: " + width + " H: " + height);
                    }
                },CssProperty.height, CssProperty.width);
            }
        }
    });

Eduard