use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.
the class ProjectListController method createTableController.
private TableController createTableController(final UserRequest ureq, WindowControl wControl) {
numberOfCustomFieldInTable = 0;
numberOfEventInTable = 0;
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("projectlist.no.projects"));
tableConfig.setPreferencesOffered(true, "projectbrokerList");
// Do not allow show all because many entries takes too long to render
tableConfig.setShowAllLinkEnabled(false);
removeAsListenerAndDispose(tableController);
tableController = new TableController(tableConfig, ureq, wControl, this.getTranslator(), true);
listenTo(tableController);
int dataColumn = 0;
tableController.addColumnDescriptor(new DefaultColumnDescriptor("projectlist.tableheader.title", dataColumn++, TABLE_ACTION_SHOW_DETAIL, getLocale()));
CustomRenderColumnDescriptor projectManagerDescriptor = new CustomRenderColumnDescriptor("projectlist.tableheader.account.manager", dataColumn++, TABLE_ACTION_ACCOUNT_MANAGER, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectManagerColumnRenderer()) {
/**
* @see org.olat.core.gui.components.table.DefaultColumnDescriptor#compareTo(int, int)
*/
@Override
public int compareTo(int rowa, int rowb) {
return super.compareTo(rowa, rowb);
}
/**
* @see org.olat.core.gui.components.table.CustomRenderColumnDescriptor#renderValue(org.olat.core.gui.render.StringOutput, int, org.olat.core.gui.render.Renderer)
*/
@Override
public void renderValue(StringOutput sb, int row, Renderer renderer) {
Object val = getModelData(row);
// to get info about row in Renderer!
String rowSt = Integer.toString(row);
getCustomCellRenderer().render(sb, renderer, val, getLocale(), getAlignment(), rowSt);
}
};
tableController.addColumnDescriptor(projectManagerDescriptor);
// Custom-Fields
List<CustomField> customFieldList = moduleConfig.getCustomFields();
for (Iterator<CustomField> iterator = customFieldList.iterator(); iterator.hasNext(); ) {
CustomField customField = iterator.next();
if (customField.isTableViewEnabled()) {
numberOfCustomFieldInTable++;
DefaultColumnDescriptor columnDescriptor = new DefaultColumnDescriptor(customField.getName(), dataColumn++, null, getLocale());
columnDescriptor.setTranslateHeaderKey(false);
tableController.addColumnDescriptor(columnDescriptor);
}
}
// Project Events
for (Project.EventType eventType : Project.EventType.values()) {
if (moduleConfig.isProjectEventEnabled(eventType) && moduleConfig.isProjectEventTableViewEnabled(eventType)) {
numberOfEventInTable++;
tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("projectlist.tableheader.event." + eventType.getI18nKey(), dataColumn++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectEventColumnRenderer()));
}
}
tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("projectlist.tableheader.state", dataColumn++, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new ProjectStateColumnRenderer()));
tableController.addColumnDescriptor(new DefaultColumnDescriptor("projectlist.tableheader.numbers", dataColumn++, null, getLocale()) {
@Override
public int compareTo(int rowa, int rowb) {
Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
if (a == null || b == null) {
boolean bb = (b == null);
return (a == null) ? (bb ? 0 : -1) : (bb ? 1 : 0);
}
try {
Long la = new Long((String) a);
Long lb = new Long((String) b);
return la.compareTo(lb);
} catch (NumberFormatException e) {
return super.compareTo(rowa, rowb);
}
}
});
String selectCmd = userCourseEnv.isCourseReadOnly() ? null : TABLE_ACTION_SELECT;
tableController.addColumnDescriptor(new BooleanColumnDescriptor("projectlist.tableheader.select", dataColumn++, selectCmd, translate("table.action.select"), "-"));
String cancelCmd = userCourseEnv.isCourseReadOnly() ? null : TABLE_ACTION_CANCEL_SELECT;
tableController.addColumnDescriptor(new BooleanColumnDescriptor("projectlist.tableheader.cancel.select", dataColumn++, cancelCmd, translate("projectlist.tableheader.cancel.select"), "-"));
return tableController;
}
use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.
the class MediaFilesTableModel method addColumnDescriptors.
public void addColumnDescriptors(TableController tableCtr) {
tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.filename", 0, WikiMainController.ACTION_SHOW_MEDIA, getLocale(), 1, new StrikeThroughCellRenderer()));
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.created.by", 1, null, getLocale()));
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.creation.date", 2, null, getLocale()));
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.deleted.by", 3, null, getLocale()));
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.deleted.at", 4, null, getLocale()));
}
use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.
the class RepositoryTableModel method addColumnDescriptors.
/**
* @param tableCtr
* @param selectButtonLabel Label of action row or null if no action row should be used
* @param enableDirectLaunch
* @return the position of the display name column
*/
public ColumnDescriptor addColumnDescriptors(TableController tableCtr, boolean selectTitle, boolean selectIcon, boolean remove, boolean infos) {
Locale loc = translator.getLocale();
CustomCellRenderer acRenderer = new RepositoryEntryACColumnDescriptor();
tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.ac", RepoCols.ac.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, acRenderer) {
@Override
public int compareTo(int rowa, int rowb) {
Object o1 = table.getTableDataModel().getObject(rowa);
Object o2 = table.getTableDataModel().getObject(rowb);
if (o1 == null || !(o1 instanceof RepositoryEntry))
return -1;
if (o2 == null || !(o2 instanceof RepositoryEntry))
return 1;
RepositoryEntry re1 = (RepositoryEntry) o1;
RepositoryEntry re2 = (RepositoryEntry) o2;
if (re1.isMembersOnly()) {
if (!re2.isMembersOnly()) {
return 1;
}
} else if (re2.isMembersOnly()) {
return -1;
}
OLATResourceAccess ac1 = repoEntriesWithOffer.get(re1.getOlatResource().getKey());
OLATResourceAccess ac2 = repoEntriesWithOffer.get(re2.getOlatResource().getKey());
if (ac1 == null && ac2 != null)
return -1;
if (ac1 != null && ac2 == null)
return 1;
if (ac1 != null && ac2 != null)
return compareAccess(re1, ac1, re2, ac2);
return super.compareString(re1.getDisplayname(), re2.getDisplayname());
}
private int compareAccess(RepositoryEntry re1, OLATResourceAccess ac1, RepositoryEntry re2, OLATResourceAccess ac2) {
int s1 = ac1.getMethods().size();
int s2 = ac2.getMethods().size();
int compare = s1 - s2;
if (compare != 0)
return compare;
if (s1 > 0 && s2 > 0) {
String t1 = ac1.getMethods().get(0).getMethod().getType();
String t2 = ac2.getMethods().get(0).getMethod().getType();
int compareType = super.compareString(t1, t2);
if (compareType != 0)
return compareType;
}
return super.compareString(re1.getDisplayname(), re2.getDisplayname());
}
});
tableCtr.addColumnDescriptor(new RepositoryEntryTypeColumnDescriptor("table.header.typeimg", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT));
String selectAction = selectTitle ? TABLE_ACTION_SELECT_LINK : null;
if (repositoryModule.isManagedRepositoryEntries()) {
tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.externalid", RepoCols.externalId.ordinal(), selectAction, loc));
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.externalref", RepoCols.externalRef.ordinal(), selectAction, loc));
}
boolean lfVisible = lifecycleDao.countPublicLifecycle() > 0;
tableCtr.addColumnDescriptor(lfVisible, new DefaultColumnDescriptor("table.header.lifecycle.label", RepoCols.lifecycleLabel.ordinal(), null, loc));
tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lifecycle.softkey", RepoCols.lifecycleSoftKey.ordinal(), null, loc));
ColumnDescriptor nameColDesc = new DefaultColumnDescriptor("table.header.displayname", RepoCols.displayname.ordinal(), selectAction, loc) {
@Override
public int compareTo(int rowa, int rowb) {
Object o1 = table.getTableDataModel().getValueAt(rowa, 1);
Object o2 = table.getTableDataModel().getValueAt(rowb, 1);
if (o1 == null || !(o1 instanceof RepositoryEntry))
return -1;
if (o2 == null || !(o2 instanceof RepositoryEntry))
return 1;
RepositoryEntry re1 = (RepositoryEntry) o1;
RepositoryEntry re2 = (RepositoryEntry) o2;
boolean c1 = RepositoryManager.getInstance().createRepositoryEntryStatus(re1.getStatusCode()).isClosed();
boolean c2 = RepositoryManager.getInstance().createRepositoryEntryStatus(re2.getStatusCode()).isClosed();
// same as Boolean compare
int result = (c2 == c1 ? 0 : (c1 ? 1 : -1));
if (result == 0) {
Object a = table.getTableDataModel().getValueAt(rowa, dataColumn);
Object b = table.getTableDataModel().getValueAt(rowb, dataColumn);
if (a == null || !(a instanceof String))
return -1;
if (b == null || !(b instanceof String))
return 1;
String s1 = (String) a;
String s2 = (String) b;
result = compareString(s1, s2);
}
return result;
}
};
tableCtr.addColumnDescriptor(nameColDesc);
CustomCellRenderer dateRenderer = new DateCellRenderer(loc);
tableCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.lifecycle.start", RepoCols.lifecycleStart.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, dateRenderer));
tableCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.lifecycle.end", RepoCols.lifecycleEnd.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, dateRenderer));
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.author", RepoCols.author.ordinal(), null, loc));
CustomCellRenderer accessRenderer = new RepositoryEntryAccessColumnDescriptor(translator);
ColumnDescriptor accessColDesc = new CustomRenderColumnDescriptor("table.header.access", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT, accessRenderer) {
@Override
public int compareTo(int rowa, int rowb) {
Object o1 = table.getTableDataModel().getValueAt(rowa, 1);
Object o2 = table.getTableDataModel().getValueAt(rowb, 1);
if (o1 == null || !(o1 instanceof RepositoryEntry))
return -1;
if (o2 == null || !(o2 instanceof RepositoryEntry))
return 1;
RepositoryEntry re1 = (RepositoryEntry) o1;
RepositoryEntry re2 = (RepositoryEntry) o2;
int ar1 = re1.getAccess();
if (re1.isMembersOnly()) {
ar1 = 99;
}
int ar2 = re2.getAccess();
if (re2.isMembersOnly()) {
ar2 = 99;
}
if (ar1 < ar2)
return -1;
if (ar1 > ar2)
return 1;
return super.compareString(re1.getDisplayname(), re2.getDisplayname());
}
};
tableCtr.addColumnDescriptor(accessColDesc);
tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.date", RepoCols.creationDate.ordinal(), null, loc));
tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lastusage", RepoCols.lastUsage.ordinal(), null, loc));
if (infos) {
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_INFOS, "info.header", translator.translate("info.header")) {
@Override
public void renderValue(StringOutput so, int row, Renderer renderer) {
so.append("<i id='o_core").append(row).append("ref' class='o_icon o_icon-lg o_icon_info_resource'> </i>");
}
});
}
if (selectIcon) {
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_SELECT_LINK, "select", translator.translate("table.select")));
}
if (remove) {
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_REMOVE_LINK, "remove", translator.translate("remove")));
}
return nameColDesc;
}
use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.
the class OrderDetailController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
backLink = uifactory.addFormLink("back", formLayout, Link.LINK_BACK);
FormLayoutContainer mainLayout = FormLayoutContainer.createDefaultFormLayout("mainCmp", getTranslator());
mainLayout.setRootForm(mainForm);
formLayout.add("mainCmp", mainLayout);
String orderNr = order.getOrderNr();
uifactory.addStaticTextElement("order-nr", "order.nr", orderNr, mainLayout);
Date creationDate = order.getCreationDate();
String creationDateStr = Formatter.getInstance(getLocale()).formatDateAndTime(creationDate);
uifactory.addStaticTextElement("creation-date", "order.creationDate", creationDateStr, mainLayout);
String orderTotal = PriceFormat.fullFormat(order.getTotal());
String orderTotalStr;
if (acModule.isVatEnabled()) {
BigDecimal vat = acModule.getVat();
String vatStr = vat == null ? "" : vat.setScale(3, BigDecimal.ROUND_HALF_EVEN).toPlainString();
orderTotalStr = translate("access.info.price.vat", new String[] { orderTotal, vatStr });
} else {
orderTotalStr = translate("access.info.price.noVat", new String[] { orderTotal });
}
uifactory.addStaticTextElement("order-total", "order.total", orderTotalStr, mainLayout);
OrderItemsDataModel tableModel = getOrderItemsDataModel();
if (tableModel.getRowCount() == 1) {
OrderItemWrapper wrapper = tableModel.getObject(0);
if (wrapper.getItem().getOffer().getResource() != null) {
// resource is null if the resource has been deleted
String linkName = StringHelper.escapeHtml(wrapper.getDisplayName());
selectResourceLink = uifactory.addFormLink("resource", linkName, translate("order.item"), mainLayout, Link.NONTRANSLATED);
selectResourceLink.setUserObject(wrapper);
selectResourceLink.setCustomEnabledLinkCSS("form-control-static");
}
}
User user = order.getDelivery().getUser();
String delivery = StringHelper.escapeHtml(userManager.getUserDisplayName(user));
uifactory.addStaticTextElement("delivery", "order.delivery", delivery, mainLayout);
if (formLayout instanceof FormLayoutContainer) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setDownloadOffered(false);
tableConfig.setTableEmptyMessage(translate("orders.empty"));
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), Collections.<ShortName>emptyList(), null, null, null, false, getTranslator());
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("order.item.name", 0, null, getLocale()));
tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("order.part.payment", 1, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new AccessMethodRenderer(acModule)));
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(CMD_SELECT, "table.order.details", getTranslator().translate("order.details")));
tableCtr.setTableDataModel(tableModel);
listenTo(tableCtr);
FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;
layoutContainer.put("orderItemList", tableCtr.getInitialComponent());
}
}
use of org.olat.core.gui.components.table.CustomRenderColumnDescriptor in project openolat by klemens.
the class InfoPeekViewController method init.
private void init(UserRequest ureq) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("peekview.noInfos"));
tableConfig.setDisplayTableHeader(false);
tableConfig.setCustomCssClass("o_portlet_table");
tableConfig.setDisplayRowCount(false);
tableConfig.setPageingEnabled(false);
tableConfig.setDownloadOffered(false);
tableConfig.setSortingEnabled(false);
removeAsListenerAndDispose(tableController);
tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("peekview.title", 0, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new InfoNodeRenderer()));
String resSubPath = courseNode.getIdent();
List<InfoMessage> infos = infoService.loadInfoMessageByResource(ores, resSubPath, null, null, null, 0, 5);
InfosTableModel model = new InfosTableModel(infos);
tableController.setTableDataModel(model);
listenTo(tableController);
}
Aggregations