Thursday, November 24, 2011

Re: ClientBundle use case issues

Hence, found only one solution by my own means:

I. Have different stylesheet files logically separated.

tables.css:
.old-fashion-table { }
 
lists.css:
.lovely-list { }

II. For each stylesheet define one CssResource descendant interface with predefined @ImportedWithPrefix annotation.

@ImportedWithPrefix("tables")
interface TablesStyles extends CssResource {
    @ClassName("old-fashion-table")
    String oldFashionTable();
}
 
@ImportedWithPrefix("lists")
interface ListsStyles extends CssResource {
    @ClassName("lovely-list")
    String lovelyList();
}

III. For each MyStyles interface define a strict accessor

@Source("tables.css")
TablesStyles tablesCss();
 
@Source("lists.css")
ListsStyles listsCss();

IV. When you need to refer to some class from tables.css or from lists.css from inside your other.css, just import MyStyles and refer to classes within them using appropriate prefixes 

other.css:
.some-wierd-widget .tables-old-fashion-table { }
.some-wierd-widget .lists-lovely-list { }

java:
@ImportedWithPrefix("other")
interface OtherStyles extends CssResource {
    @ClassName("some-wierd-widget")
    String someWierdWidget();
}

@Source("other.css")
@Import({TablesStyles.class, ListsStyles.class})
OtherStyles otherCss();

V. Run-time. Inject all the accessors and refer to imported classes by an according base class accessor

MyResources.INSTANCE = GWT.create(MyResources.class);
 
MyResources.INSTANCE.tablesCss().ensureInjected();
MyResources.INSTANCE.listsCss().ensureInjected();
MyResources.INSTANCE.otherCss().ensureInjected();
...
myLovelyWidget.addStyleName(MyResources.INSTANCE.otherCss().someWierdWidget());
descendantOfMyLovelyWidget.addStyleName(MyResources.INSTANCE.tablesCss().oldFashionTable());
descendantOfMyLovelyWidget.addStyleName(MyResources.INSTANCE.listsCss().lovelyList());

It's just my vision of how it works. Correct me if I'm misspaterning or do some even more crazy stuff =\

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/umNTIm0yPqwJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment