setSelectionType(SelectionStyle.NONE);
setAnimateFolders(false);
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
final TreeGridField nameField = new TreeGridField(ResourceTypeTreeNodeBuilder.ATTRIB_NAME,
MSG.common_title_name());
fields.add(nameField);
final TreeGridField pluginField = new TreeGridField(ResourceTypeTreeNodeBuilder.ATTRIB_PLUGIN,
MSG.common_title_plugin());
fields.add(pluginField);
fields.addAll(getAdditionalListGridFields(true));
ListGridField editField = new TreeGridField(ResourceTypeTreeNodeBuilder.ATTRIB_EDIT, getEditColumnTitle());
editField.setType(ListGridFieldType.IMAGE);
editField.setAlign(Alignment.CENTER);
editField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(final RecordClickEvent event) {
Record record = event.getRecord();
String editAttr = record.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_EDIT);
if (ImageManager.getEditIcon().equals(editAttr)) {
String type = record.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_ID);
String editLink = getEditLink(type);
if (editLink != null) {
CoreGUI.goToView(editLink);
} else {
// there is no subcanvas to go to - the subclass can do it without changing canvas
ResourceTypeRepository.Cache.getInstance().getResourceTypes(Integer.parseInt(type),
getTypeMetadataTypes(), new ResourceTypeRepository.TypeLoadedCallback() {
public void onTypesLoaded(ResourceType type) {
editTemplates(type, event);
}
});
}
}
}
});
fields.add(editField);
nameField.setWidth("*");
pluginField.setWidth("20%");
// note that the additional fields should set their own width
editField.setWidth("70");
setFields(fields.toArray(new ListGridField[fields.size()]));
}