Basically I want to implement something similar to the the cell-coloring which is defined in the GWT documentation
However I don't want to specify the style directly on the DIV element but want to assign an obfuscated stylename from my custom CSSResource
which I defined for my CellTable.
Here is some code:
I defined a custom Resources
interface for my CellTable:
public interface CellTableResources extends Resources {
@Source({CellTable.Style.DEFAULT_CSS,CellTableStyle.STYLE})
CellTableStyle cellTableStyle();
public interface CellTableStyle extends Style {
String STYLE = "CellTable.css";
public Sring coloredCell();
}
}
I pass it to the constructor of my CellTable:
CellTable<XY> table = new CellTable<XY>(15,cellTableResources);
This is how my custom cell looks like.
public class ColorCell extends AbstractCell<String> {
interface Templates extends SafeHtmlTemplates {
@SafeHtmlTemplates.Template("<div class=\"{0}\">{1}</div>")
SafeHtml cell(String classname, SafeHtml value);
}
private static Templates templates = GWT.create(Templates.class);
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
if (value == null) {
return;
}
// how can I access the CSSResources which I pass to the CellTable
CellTableResources ressources = ?
String className = ressources.cellTableStyle().coloredCell();
SafeHtml safeValue = SafeHtmlUtils.fromString(value);
SafeHtml rendered = templates.cell(className, safeValue);
sb.append(rendered);
}
}
How can I access my CellTableRessources
that I passed to my CellTable in my custom cell?
Here is the important part:
// how can I access the CSSResources which I pass to the CellTable
CellTableResources ressources = ?
String className = ressources.cellTableStyle().coloredCell();
The only solution I come up with is to pass the CellTableRessources
to the constructor of my AbstractCell
.
Isn't there a more elegant way (I already have passed it to the CellTable).
I think the main question is:
"How can I access CellTable variables from a Cell or Column?"