private void addCellRules(
StyleSheet styleSheet, Grid grid, Row row, int column,
Format child) {
Rule rule = ThemeFactory.getDefaultInstance().createRule();
SelectorSequence context = createContextualSelectorSequence(row);
Subject subject = createNthChildSelector(column);
CombinedSelector selector = factory.createCombinedSelector();
selector.setCombinator(CombinatorEnum.CHILD);
selector.setContext(context);
selector.setSubject(subject);
List selectors = new ArrayList();
selectors.add(selector);
rule.setSelectors(selectors);
MutableStyleProperties styleProperties =
ThemeFactory.getDefaultInstance().createMutableStyleProperties();
// A grid cell is equivalent to a CSS table cell.
styleProperties.setStyleValue(StylePropertyDetails.DISPLAY,
DisplayKeywords.TABLE_CELL);
StyleValue value;
if (child != null) {
value = converter.getHorizontalAlign(child.getHorizontalAlignment());
if (value != null) {
styleProperties.setStyleValue(StylePropertyDetails.TEXT_ALIGN,
value);
}
value = converter.getVerticalAlign(child.getVerticalAlignment());
if (value != null) {
styleProperties.setStyleValue(StylePropertyDetails.VERTICAL_ALIGN,
value);
}
}
// Apply the cell padding from the grid as padding on the cells.
setPadding(styleProperties, grid);
rule.setProperties(styleProperties);
styleSheet.addRule(rule);
}