use of org.olat.core.gui.components.table.DefaultColumnDescriptor 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.DefaultColumnDescriptor in project openolat by klemens.
the class ENRunController method createTableController.
private TableController createTableController(UserRequest ureq, boolean hasAnyWaitingList) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("grouplist.no.groups"));
removeAsListenerAndDispose(tableCtr);
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
listenTo(tableCtr);
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("grouplist.table.name", 0, CMD_VISIT_CARD, getLocale()));
DefaultColumnDescriptor descCd = new DefaultColumnDescriptor("grouplist.table.desc", 1, null, getLocale());
descCd.setEscapeHtml(EscapeMode.antisamy);
tableCtr.addColumnDescriptor(descCd);
tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("grouplist.table.partipiciant", 2, 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 {
Integer la, lb;
if (a instanceof String) {
String sa = (String) a;
la = Integer.parseInt(sa.substring(0, sa.indexOf("/")));
} else {
la = (Integer) a;
}
if (b instanceof String) {
String sb = (String) b;
lb = Integer.parseInt(sb.substring(0, sb.indexOf("/")));
} else {
lb = (Integer) b;
}
return la.compareTo(lb);
} catch (NumberFormatException e) {
return super.compareTo(rowa, rowb);
}
}
});
tableCtr.addColumnDescriptor(hasAnyWaitingList, new DefaultColumnDescriptor("grouplist.table.waitingList", 3, null, getLocale()));
DefaultColumnDescriptor stateColdEsc = new DefaultColumnDescriptor("grouplist.table.state", 4, null, getLocale());
stateColdEsc.setEscapeHtml(EscapeMode.none);
tableCtr.addColumnDescriptor(stateColdEsc);
String enrollCmd = userCourseEnv.isCourseReadOnly() ? null : CMD_ENROLL_IN_GROUP;
BooleanColumnDescriptor columnDesc = new BooleanColumnDescriptor("grouplist.table.enroll", 5, enrollCmd, translate(CMD_ENROLL_IN_GROUP), translate("grouplist.table.no_action"));
columnDesc.setSortingAllowed(false);
tableCtr.addColumnDescriptor(columnDesc);
String cancelCmd = userCourseEnv.isCourseReadOnly() ? null : CMD_ENROLLED_CANCEL;
tableCtr.addColumnDescriptor(new BooleanColumnDescriptor("grouplist.table.cancel_enroll", 6, cancelCmd, translate(CMD_ENROLLED_CANCEL), translate("grouplist.table.no_action")));
return tableCtr;
}
use of org.olat.core.gui.components.table.DefaultColumnDescriptor in project openolat by klemens.
the class HomeOrgStatisticManager method createColumnDescriptor.
@Override
public ColumnDescriptor createColumnDescriptor(UserRequest ureq, int column, String headerId) {
if (column == 0) {
return new DefaultColumnDescriptor("stat.table.header.node", 0, null, ureq.getLocale());
}
/* if (headerId!=null) {
Translator translator = Util.createPackageTranslator(ShibbolethModule.class, ureq.getLocale());
if (translator!=null) {
String newHeaderId = translator.translate("swissEduPersonHomeOrganization."+headerId);
if (newHeaderId!=null && !newHeaderId.startsWith(Translator.NO_TRANSLATION_ERROR_PREFIX)) {
headerId = newHeaderId;
}
}
}*/
TotalAwareColumnDescriptor cd = new TotalAwareColumnDescriptor(headerId, column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT);
cd.setTranslateHeaderKey(false);
return cd;
}
use of org.olat.core.gui.components.table.DefaultColumnDescriptor in project openolat by klemens.
the class OrgTypeStatisticManager method createColumnDescriptor.
@Override
public ColumnDescriptor createColumnDescriptor(UserRequest ureq, int column, String headerId) {
if (column == 0) {
return new DefaultColumnDescriptor("stat.table.header.node", 0, null, ureq.getLocale());
}
if (headerId != null) {
Translator translator = Util.createPackageTranslator(ShibbolethModule.class, ureq.getLocale());
if (translator != null) {
String newHeaderId = translator.translate("swissEduPersonHomeOrganizationType." + headerId);
if (newHeaderId != null && !newHeaderId.startsWith(Translator.NO_TRANSLATION_ERROR_PREFIX)) {
headerId = newHeaderId;
}
}
}
TotalAwareColumnDescriptor cd = new TotalAwareColumnDescriptor(headerId, column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT);
cd.setTranslateHeaderKey(false);
return cd;
}
use of org.olat.core.gui.components.table.DefaultColumnDescriptor in project openolat by klemens.
the class StudyLevelStatisticManager method createColumnDescriptor.
@Override
public ColumnDescriptor createColumnDescriptor(UserRequest ureq, int column, String headerId) {
if (column == 0) {
return new DefaultColumnDescriptor("stat.table.header.node", 0, null, ureq.getLocale());
}
if (headerId != null) {
Translator translator = Util.createPackageTranslator(ShibbolethModule.class, ureq.getLocale());
if (translator != null) {
String newHeaderId = translator.translate("swissEduPersonStudyLevel." + headerId);
if (newHeaderId != null && !newHeaderId.startsWith(Translator.NO_TRANSLATION_ERROR_PREFIX)) {
headerId = newHeaderId;
}
}
}
TotalAwareColumnDescriptor cd = new TotalAwareColumnDescriptor(headerId, column, StatisticDisplayController.CLICK_TOTAL_ACTION + column, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_RIGHT);
cd.setTranslateHeaderKey(false);
return cd;
}
Aggregations