if (data.size() == 0) {
dataSummary.setText("No items have been uploaded.");
return;
}
UploadedDatum firstItem = data.get(0);
dataSummary.setText(
"Showing " + Integer.toString(data.size()) + " " + firstItem.getDatumType().getPlural());
dataGrid.clear();
// Header row + one for each bug x datum, Attribute, Component, Capability
dataGrid.resize(data.size() + 1, 4);
// Set grid headers.
dataGrid.setWidget(0, 0, new Label(firstItem.getDatumType().getPlural()));
dataGrid.setWidget(0, 1, new Label("Attribute"));
dataGrid.setWidget(0, 2, new Label("Component"));
dataGrid.setWidget(0, 3, new Label("Capability"));
dataGrid.getWidget(0, 0).addStyleName(GRID_HEADER_CSS_STYLE);
dataGrid.getWidget(0, 1).addStyleName(GRID_HEADER_CSS_STYLE);
dataGrid.getWidget(0, 2).addStyleName(GRID_HEADER_CSS_STYLE);
dataGrid.getWidget(0, 3).addStyleName(GRID_HEADER_CSS_STYLE);
// Fill with data.
for (int i = 0; i < data.size(); i++) {
UploadedDatum datum = data.get(i);
String host = LinkUtil.getLinkHost(datum.getLinkUrl());
Widget description;
if (host != null) {
HorizontalPanel panel = new HorizontalPanel();
Anchor anchor = new Anchor(datum.getLinkText(), datum.getLinkUrl());
anchor.setTarget("_blank");
Label hostLabel = new Label(host);
panel.add(anchor);
panel.add(hostLabel);
description = panel;
} else {
description = new Label(datum.getLinkText() + " [" + datum.getLinkUrl() + "]");
}
description.addStyleName(GRID_CELL_CSS_STYLE);
description.setTitle(datum.getToolTip());
dataGrid.setWidget(i + 1, 0, description);
// Display images indicating whether or not the datum is associated with project artifacts.
// For example, a Bug may be associated with a Component or a Testcase might validate scenarios
// for a given Attribute. The user can associate data with project artifacts using SuperLabels.
dataGrid.setWidget(i + 1, 1, (datum.isAttachedToAttribute()) ? getX() : getCheckmark());
dataGrid.setWidget(i + 1, 2, (datum.isAttachedToComponent()) ? getX() : getCheckmark());
dataGrid.setWidget(i + 1, 3, (datum.isAttachedToCapability()) ? getX() : getCheckmark());
}
}