GWT: how to access one constant of a stylesheet defined in another stylesheet from the same ClientBundle

This problem is best described in the example.

I have the following ClientBundle in my GWT application:

interface Resources extends ClientBundle {
    public static final Resources INSTANCE = GWT.create(Resources.class);

    @Source("defines.css")
    Defines defines();

    @Source("appStyle.css")
    @CssResource.NotStrict
    Style style();

    interface Style extends CssResource {
        String appLogo();
        (...)
    }

    interface Defines extends CssResource {
        String formInputBackgroundColor();
        String formInputBorderColor();
        (...)
    }
}

appStyle.css- this is the main style sheet used by the application, and defines.css- a style sheet containing only such constants as:

@def formInputBackgroundColor #D8ECFD;
@def formInputBorderColor #7FAAFF;
(...)

Now I can use the constants in the stylesheet defines.cssinside the UIBinder templates and in the application code without problems, but I can not use these constants in my own appStyle.css.

I already tried replacing interface Style extends CssResourcewith interface Style extends Defines, hoping that inheriting from the stylesheet Defineswould give me access to the constants in the "child" stylesheet Style, but then the GWT compiler complains about errors like:

Rebinding my.project.client.resources.Resources
    Creating assignment for style()
        Replacing CSS class names
            The following obfuscated style classes were missing from the source CSS file:
                formInputBorderColor: Fix by adding .formInputBorderColor{}
                formInputBackgroundColor: Fix by adding .formInputBackgroundColor{}
                (...)

?

+3
2

, , , , - , .

, , - @eval , defines.css appStyle.css, , mantain.

@eval formInputBackgroundColor Resources.INSTANCE.defines().formInputBackgroundColor();
@eval formInputBorderColor Resources.INSTANCE.defines().formInputBorderColor();

, .

+1

@Source("appStyle.css")

@Source({"defines.css", "appStyle.css"})

. css, style() .

+1

Source: https://habr.com/ru/post/1753618/


All Articles