tagEditor.setExtraSpace(10);
return tagEditor;
}
private Table addMemberDeploymentsTable() {
Table table = new Table(MSG.view_bundle_deploy_deploymentPlatforms());
table.setShowFooterRefresh(false);
TitleBar titleBar = new TitleBar(MSG.view_bundle_deploy_selectARow());
table.setTitleBar(titleBar);
// resource icon field
ResourceCategory resourceCategory = ResourceCategory.PLATFORM;
try {
resourceCategory = deployment.getDestination().getGroup().getResourceType().getCategory();
} catch (Exception skip) { // BZ 1027732 in case a group somehow got empty or switched to a mixed group, avoid NPE
}
ListGridField resourceIcon = new ListGridField("resourceAvailability");
HashMap<String, String> icons = new HashMap<String, String>();
icons.put(AvailabilityType.UP.name(), ImageManager.getResourceIcon(resourceCategory, AvailabilityType.UP));
icons.put(AvailabilityType.DOWN.name(), ImageManager.getResourceIcon(resourceCategory, AvailabilityType.DOWN));
icons.put(AvailabilityType.DISABLED.name(),
ImageManager.getResourceIcon(resourceCategory, AvailabilityType.DISABLED));
icons.put(AvailabilityType.UNKNOWN.name(),
ImageManager.getResourceIcon(resourceCategory, AvailabilityType.UNKNOWN));
resourceIcon.setValueIcons(icons);
resourceIcon.setValueIconSize(16);
resourceIcon.setType(ListGridFieldType.ICON);
resourceIcon.setWidth(40);
// resource field
ListGridField resource = new ListGridField("resource", MSG.common_title_resource());
resource.setWidth("*");
resource.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord listGridRecord, int i, int i1) {
return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("resourceId"))
+ "\">" + StringUtility.escapeHtml(String.valueOf(value)) + "</a>";
}
});
// resource version field
ListGridField resourceVersion = new ListGridField("resourceVersion", MSG.common_title_version());
resourceVersion.setAutoFitWidth(true);
resourceVersion.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
// status icon field
ListGridField status = new ListGridField("status", MSG.common_title_status());
status.setValueIcons(statusIcons);
status.setValueIconHeight(11);
status.setValueIconWidth(11);
status.setShowValueIconOnly(true);
status.setWidth(60);
List<ListGridRecord> records = new ArrayList<ListGridRecord>();
for (BundleResourceDeployment rd : deployment.getResourceDeployments()) {
ListGridRecord record = new ListGridRecord();
Resource rr = rd.getResource();
record.setAttribute("resource", rr.getName());
record.setAttribute("resourceAvailability", rr.getCurrentAvailability().getAvailabilityType().name());
record.setAttribute("resourceId", rr.getId());
record.setAttribute("resourceVersion", rr.getVersion());
record.setAttribute("status", rd.getStatus().name());
record.setAttribute("id", rd.getId());
record.setAttribute("object", rd);
records.add(record);
}
// To get the ListGrid the Table must be initialized (via onInit()) by adding to the Canvas
table.setHeight("30%");
table.setWidth100();
table.setShowResizeBar(true);
table.setResizeBarTarget("next");
addMember(table);
ListGrid listGrid = table.getListGrid();
listGrid.setFields(resourceIcon, resource, resourceVersion, status);
listGrid.setData(records.toArray(new ListGridRecord[records.size()]));
listGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
@Override
public void onSelectionChanged(SelectionEvent selectionEvent) {