List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
RowNumberer rowNumberer = new RowNumberer();
configs.add(rowNumberer);
ColumnConfig column = new ColumnConfig();
column.setId("type");
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(40);
column.setRenderer(new GridCellRenderer<WCAGViolation>() {
public Object render(WCAGViolation model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<WCAGViolation> store,
Grid<WCAGViolation> grid) {
Html html = null;
if ("warning".equalsIgnoreCase(model.getType())) {
html = new Html(StandardIconsProvider.STANDARD_ICONS.warning().getHTML());
html.setToolTip(Messages.get("label.warning", "Warning"));
} else if ("information".equalsIgnoreCase(model.getType())) {
html = new Html(StandardIconsProvider.STANDARD_ICONS.information().getHTML());
html.setToolTip(Messages.get("label.information", "Information"));
} else {
html = new Html(StandardIconsProvider.STANDARD_ICONS.error().getHTML());
html.setToolTip(Messages.get("label.error", "Error"));
}
return html;
}
});
configs.add(column);
column = new ColumnConfig();
column.setId("line");
column.setHeader(Messages.get("label.line", "Line"));
column.setWidth(50);
configs.add(column);
column = new ColumnConfig();
column.setId("column");
column.setHeader(Messages.get("label.column", "Column"));
column.setWidth(50);
configs.add(column);
column = new ColumnConfig();
column.setId("message");
column.setHeader(Messages.get("label.description", "Description"));
column.setRenderer(new GridCellRenderer<WCAGViolation>() {
public Object render(WCAGViolation model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<WCAGViolation> store,
Grid<WCAGViolation> grid) {
Text txt = new Text(model.getMessage());
txt.setToolTip(model.getMessage());
return txt;
}
});
configs.add(column);
column = new ColumnConfig();
column.setId("context");
column.setHeader(Messages.get("label.context", "Context"));
column.setWidth(60);
column.setAlignment(HorizontalAlignment.CENTER);
column.setRenderer(new GridCellRenderer<WCAGViolation>() {
public Object render(WCAGViolation model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<WCAGViolation> store,
Grid<WCAGViolation> grid) {
if (model.getContext() == null || model.getContext().length() == 0) {
return "";
}
ToolTipConfig tt = new ToolTipConfig();
tt.setTitle(Messages.get("label.context", "Context"));
tt.setTemplate(new Template(model.getContext()));
Html icon = new Html(StandardIconsProvider.STANDARD_ICONS.about().getHTML());
icon.setToolTip(tt);
return icon;
}
});
configs.add(column);
column = new ColumnConfig();
column.setId("code");
column.setHeader(Messages.get("label.code", "Code"));
column.setWidth(60);
column.setAlignment(HorizontalAlignment.CENTER);
column.setRenderer(new GridCellRenderer<WCAGViolation>() {
public Object render(WCAGViolation model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<WCAGViolation> store,
Grid<WCAGViolation> grid) {
if (model.getCode() == null || model.getCode().length() == 0) {
return "";
}
ToolTipConfig tt = new ToolTipConfig();
tt.setTitle(Messages.get("label.code", "Code"));
tt.setTemplate(new Template(model.getCode()));
Html icon = new Html(StandardIconsProvider.STANDARD_ICONS.about().getHTML());
icon.setToolTip(tt);
return icon;
}
});
configs.add(column);
column = new ColumnConfig();
column.setId("example");
column.setHeader(Messages.get("label.example", "Example"));
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(80);
configs.add(column);
ListStore<WCAGViolation> store = new ListStore<WCAGViolation>();
store.add(wcagResult.getErrors());
store.add(wcagResult.getWarnings());