// Draw background
gc.fillRectangle(bounds);
groupByCellBounds.clear();
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
gc.setBackground(cellStyle
.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
gc.setForeground(cellStyle
.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
gc.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
gc.setAntialias(GUIHelper.DEFAULT_ANTIALIAS);
gc.setTextAntialias(GUIHelper.DEFAULT_TEXT_ANTIALIAS);
List<Integer> groupByColumnIndexes = groupByModel
.getGroupByColumnIndexes();
if (groupByColumnIndexes.size() > 0) {
int textHeight = gc.textExtent("X").y; //$NON-NLS-1$
int x0 = bounds.x + LEFT_INDENT;
int y0 = bounds.y + bounds.height / 2 - textHeight / 2 - Y_PADDING;
int y_height = Y_PADDING + textHeight + Y_PADDING;
// Draw leftmost edge
gc.drawLine(x0, y0, x0, y0 + y_height);
x0++;
// Draw group by columns
int lastColumnIndex = groupByColumnIndexes.size() - 1;
for (int i = 0; i <= lastColumnIndex; i++) {
int columnIndex = groupByColumnIndexes.get(i);
String columnName = (String) columnHeaderDataProvider
.getDataValue(columnIndex, 0);
int textWidth = gc.textExtent(columnName).x;
groupByCellBounds.add(new Rectangle(x0, y0, X_PADDING
+ textWidth + X_PADDING, y_height));
gc.fillRectangle(x0, y0, X_PADDING + textWidth + X_PADDING,
y_height);
gc.drawLine(x0, y0, x0 + X_PADDING + textWidth + X_PADDING, y0);
gc.drawLine(x0, y0 + y_height, x0 + X_PADDING + textWidth
+ X_PADDING, y0 + y_height);
gc.drawText(columnName, x0 + X_PADDING, y0 + Y_PADDING);
x0 += X_PADDING + textWidth + X_PADDING;
// Draw end cap
if (i < lastColumnIndex) {
gc.fillRectangle(x0, y0, ENDCAP_WIDTH, y_height);
gc.drawLine(x0, y0, x0 + ENDCAP_WIDTH, y0);
gc.drawLine(x0, y0 + y_height, x0 + ENDCAP_WIDTH, y0
+ y_height);
} else {
gc.fillPolygon(new int[] { x0, y0, x0 + ENDCAP_WIDTH,
y0 + y_height / 2, x0, y0 + y_height });
}
gc.drawLine(x0, y0, x0 + ENDCAP_WIDTH - 1, y0 + y_height / 2);
gc.drawLine(x0, y0 + y_height, x0 + ENDCAP_WIDTH - 1, y0
+ y_height / 2);
x0 += ENDCAP_WIDTH;
}
} else {
// if no grouping is applied and a hint is specified via
// configuration, the hint is rendered
String hint = configRegistry.getConfigAttribute(
GroupByConfigAttributes.GROUP_BY_HINT, DisplayMode.NORMAL);
if (hint != null) {
// check if there is a separate styling configured for the hint
IStyle hintStyle = configRegistry.getConfigAttribute(
GroupByConfigAttributes.GROUP_BY_HINT_STYLE,
DisplayMode.NORMAL);
if (hintStyle != null) {
Color hintBackground = hintStyle
.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR);
gc.setBackground(hintBackground != null ? hintBackground
: originalBackground);
Color hintForeground = hintStyle
.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR);
if (hintForeground != null)
gc.setForeground(hintForeground);
Font hintFont = hintStyle
.getAttributeValue(CellStyleAttributes.FONT);
if (hintFont != null)
gc.setFont(hintFont);
} else {
// ensure the background is the same as the background of