use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class GoToMeetingsEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (!readOnly) {
addTrainingButton = uifactory.addFormLink("add.training", formLayout, Link.BUTTON);
}
// add the table
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.name.i18nHeaderKey(), MeetingsCols.name.ordinal(), true, MeetingsCols.name.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.start.i18nHeaderKey(), MeetingsCols.start.ordinal(), true, MeetingsCols.start.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.end.i18nHeaderKey(), MeetingsCols.end.ordinal(), true, MeetingsCols.end.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MeetingsCols.organizer.i18nHeaderKey(), MeetingsCols.organizer.ordinal(), true, MeetingsCols.organizer.name()));
if (!readOnly) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("edit", translate("edit"), "edit"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("delete", translate("delete"), "delete"));
}
tableModel = new GoToMeetingTableModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "meetings", tableModel, getTranslator(), formLayout);
FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
sortOptions.setDefaultOrderBy(new SortKey(MeetingsCols.start.name(), false));
tableEl.setSortSettings(sortOptions);
updateModel();
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class MySharedItemsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("my.shared.items");
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, MySharedItemCols.binderKey, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MySharedItemCols.binderName, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MySharedItemCols.courseName, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MySharedItemCols.lastModified));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
model = new MySharedItemsDataModel(columnsModel, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setSearchEnabled(true);
tableEl.setCustomizeColumns(true);
tableEl.setElementCssClass("o_binder_shared_items_listing");
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setPageSize(24);
tableEl.setAndLoadPersistedPreferences(ureq, "my-shared-items");
FlexiTableSortOptions options = new FlexiTableSortOptions();
options.setDefaultOrderBy(new SortKey(MySharedItemCols.binderName.name(), true));
tableEl.setSortSettings(options);
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class SharedPagesController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.bookmark));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.userInfosStatus, new SharedPageStatusCellRenderer(getTranslator())));
FlexiCellRenderer titleRenderer = new BooleanCellRenderer(new StaticFlexiCellRenderer("select", new PageTitleCellRenderer()), new PageTitleCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, true, "select", SharePageCols.pageName.ordinal(), "select", true, SharePageCols.pageName.sortKey(), FlexiColumnModel.ALIGNMENT_LEFT, titleRenderer));
SortKey defaultSortKey = null;
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.username));
defaultSortKey = new SortKey(Cols.username.name(), true);
}
// followed by the users fields
int colPos = USER_PROPS_OFFSET;
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
String propName = userPropertyHandler.getName();
if (defaultSortKey == null && i == 0) {
defaultSortKey = new SortKey(propName, true);
} else if (UserConstants.LASTNAME.equals(propName) && !isAdministrativeUser) {
defaultSortKey = new SortKey(propName, true);
}
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName));
colPos++;
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.lastChanges));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.pageStatus, new StatusCellRenderer(getTranslator())));
model = new SharedPagesDataModel(columnsModel, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setSearchEnabled(true);
tableEl.setCustomizeColumns(true);
tableEl.setElementCssClass("o_binder_shared_bookmark_pages_listing");
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setPageSize(24);
tableEl.setAndLoadPersistedPreferences(ureq, "shared-bookmark-pages");
if (filters != null && !filters.isEmpty()) {
List<FlexiTableFilter> tableFilters = new ArrayList<>(filters.size());
for (PageStatus status : filters) {
String label = translate(status.i18nKey());
tableFilters.add(new FlexiTableFilter(label, status.name(), "o_icon ".concat(status.cssClass())));
}
tableFilters.add(FlexiTableFilter.SPACER);
tableFilters.add(new FlexiTableFilter(translate("filter.show.all"), "all", true));
tableEl.setFilters("Filters", tableFilters, true);
if (defaultFilter != null) {
tableEl.setSelectedFilterKey(defaultFilter.name());
}
}
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class FlexiTableClassicRenderer method renderHeader.
private void renderHeader(StringOutput sb, FlexiTableComponent ftC, FlexiColumnModel fcm, Translator translator) {
String header = getHeader(fcm, translator);
sb.append("<th");
// append sort key to make column width set via css
if (fcm.getSortKey() != null) {
sb.append(" class='o_col_").append(fcm.getSortKey()).append("'");
}
sb.append(">");
// sort is not defined
if (!fcm.isSortable() || fcm.getSortKey() == null) {
sb.append(header);
} else {
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
Boolean asc = null;
String sortKey = fcm.getSortKey();
SortKey[] orderBy = ftE.getOrderBy();
if (orderBy != null && orderBy.length > 0) {
for (int i = orderBy.length; i-- > 0; ) {
if (sortKey.equals(orderBy[i].getKey())) {
asc = new Boolean(orderBy[i].isAsc());
}
}
}
Form theForm = ftE.getRootForm();
if (asc == null) {
sb.append("<a class='o_orderby' href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("sort", sortKey), new NameValuePair("asc", "asc"))).append("\">");
} else if (asc.booleanValue()) {
sb.append("<a class='o_orderby o_orderby_asc' href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("sort", sortKey), new NameValuePair("asc", "desc"))).append("\">");
} else {
sb.append("<a class='o_orderby o_orderby_desc' href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("sort", sortKey), new NameValuePair("asc", "asc"))).append("\">");
}
sb.append(header).append("</a>");
}
sb.append("</th>");
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
StringBuilder sb = new StringBuilder();
List<Identity> teachers = lectureService.getTeachers(lectureBlock);
for (Identity teacher : teachers) {
if (sb.length() > 0)
sb.append(", ");
sb.append(StringHelper.escapeHtml(userManager.getUserDisplayName(teacher)));
}
Formatter formatter = Formatter.getInstance(getLocale());
String date = formatter.formatDate(lectureBlock.getStartDate());
String startTime = formatter.formatTimeShort(lectureBlock.getStartDate());
String endTime = formatter.formatTimeShort(lectureBlock.getEndDate());
String[] args = new String[] { // {0}
lectureBlock.getTitle(), // {1}
sb.toString(), // {2}
date, // {3}
startTime, // {4}
endTime };
layoutCont.contextPut("date", date);
layoutCont.contextPut("startTime", startTime);
layoutCont.contextPut("endTime", endTime);
layoutCont.contextPut("dateAndTime", translate("lecture.block.dateAndTime", args));
layoutCont.contextPut("teachers", sb.toString());
layoutCont.contextPut("lectureBlockTitle", StringHelper.escapeHtml(lectureBlock.getTitle()));
layoutCont.contextPut("lectureBlockExternalId", StringHelper.escapeHtml(lectureBlock.getExternalId()));
StringBuilder description = Formatter.stripTabsAndReturns(Formatter.formatURLsAsLinks(lectureBlock.getDescription()));
layoutCont.contextPut("lectureBlockDescription", StringHelper.xssScan(description));
StringBuilder preparation = Formatter.stripTabsAndReturns(Formatter.formatURLsAsLinks(lectureBlock.getPreparation()));
layoutCont.contextPut("lectureBlockPreparation", StringHelper.xssScan(preparation));
layoutCont.contextPut("lectureBlockLocation", StringHelper.escapeHtml(lectureBlock.getLocation()));
layoutCont.contextPut("lectureBlock", lectureBlock);
layoutCont.contextPut("lectureBlockOptional", !lectureBlock.isCompulsory());
layoutCont.setFormTitle(translate("lecture.block", args));
layoutCont.setFormDescription(StringHelper.escapeJavaScript(lectureBlock.getDescription()));
}
// table
FlexiTableSortOptions options = new FlexiTableSortOptions();
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RollCols.username));
options.setDefaultOrderBy(new SortKey(RollCols.username.sortKey(), true));
}
int colPos = USER_PROPS_OFFSET;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
FlexiColumnModel col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
columnsModel.addFlexiColumnModel(col);
colPos++;
if (!options.hasDefaultOrderBy()) {
options.setDefaultOrderBy(new SortKey(propName, true));
} else if (UserConstants.LASTNAME.equals(propName)) {
options.setDefaultOrderBy(new SortKey(propName, true));
}
}
if (lectureBlock.isCompulsory()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RollCols.status));
for (int i = 0; i < numOfLectures; i++) {
DefaultFlexiColumnModel col = new DefaultFlexiColumnModel("table.header.lecture." + (i + 1), i + CHECKBOX_OFFSET, true, "lecture." + (i + 1));
col.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(col);
}
// all button
DefaultFlexiColumnModel allCol = new DefaultFlexiColumnModel("all", RollCols.all.ordinal(), "all", new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("all"), "all", null, null, translate("all.desc")), null));
allCol.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(allCol);
if (secCallback.canViewAuthorizedAbsences() || secCallback.canEditAuthorizedAbsences()) {
DefaultFlexiColumnModel authorizedCol = new DefaultFlexiColumnModel(RollCols.authorizedAbsence);
authorizedCol.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(authorizedCol);
}
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RollCols.comment));
tableModel = new TeacherRollCallDataModel(columnsModel, secCallback, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
tableEl.setCustomizeColumns(true);
tableEl.setSortSettings(options);
tableEl.setAndLoadPersistedPreferences(ureq, "teacher-roll-call");
// buttons
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
quickSaveButton = uifactory.addFormSubmitButton("save", "save.temporary", formLayout);
quickSaveButton.setElementCssClass("o_sel_lecture_quick_save");
closeLectureBlocksButton = uifactory.addFormLink("close.lecture.blocks", formLayout, Link.BUTTON);
closeLectureBlocksButton.setElementCssClass("o_sel_lecture_close");
if (lectureModule.isStatusCancelledEnabled()) {
cancelLectureBlockButton = uifactory.addFormLink("cancel.lecture.blocks", formLayout, Link.BUTTON);
}
reopenButton = uifactory.addFormLink("reopen.lecture.blocks", formLayout, Link.BUTTON);
reopenButton.setElementCssClass("o_sel_lecture_reopen");
updateUI();
}
Aggregations