use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class FlexiTableElementImpl method sort.
@Override
public void sort(String sortKey, boolean asc) {
collapseAllDetails();
SortKey key;
if (StringHelper.containsNonWhitespace(sortKey)) {
key = new SortKey(sortKey, asc);
orderBy = new SortKey[] { key };
} else {
key = null;
orderBy = null;
}
if (dataModel instanceof SortableFlexiTableDataModel) {
((SortableFlexiTableDataModel<?>) dataModel).sort(key);
} else if (dataSource != null) {
currentPage = 0;
if (dataModel instanceof FlexiTableDataSource) {
((FlexiTableDataSource<?>) dataModel).clear();
((FlexiTableDataSource<?>) dataModel).load(getSearchText(), getSelectedFilters(), getConditionalQueries(), 0, getPageSize(), orderBy);
} else {
dataSource.clear();
dataSource.load(getSearchText(), getSelectedFilters(), getConditionalQueries(), 0, getPageSize(), orderBy);
}
}
reorderMultiSelectIndex();
selectSortOption(sortKey, asc);
component.setDirty(true);
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class SelectThreadStepForm method loadModel.
private void loadModel() {
Identity identity = guestOnly ? null : getIdentity();
Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
messageToMove = messageToMove.getThreadtop() == null ? messageToMove : messageToMove.getThreadtop();
List<ForumThread> threads = forumManager.getForumThreads(forum, identity);
if (!foCallback.mayEditMessageAsModerator()) {
for (Iterator<ForumThread> threadIt = threads.iterator(); threadIt.hasNext(); ) {
ForumThread next = threadIt.next();
if (Status.getStatus(next.getStatusCode()).isHidden()) {
threadIt.remove();
} else if (messageToMove.getKey().equals(next.getKey())) {
threadIt.remove();
}
}
}
threadTableModel.setObjects(threads);
threadTableModel.sort(new SortKey(ThreadListCols.thread.name(), true));
threadTable.reloadData();
threadTable.reset();
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class IdentityListCourseNodeController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("courseNodeTitle", courseNode.getShortTitle());
layoutCont.contextPut("courseNodeCssClass", CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType()).getIconCSSClass());
if (group != null) {
layoutCont.contextPut("businessGroupName", group.getName());
}
}
ICourse course = CourseFactory.loadCourse(courseEntry);
String select = isSelectable() ? "select" : null;
// add the table
FlexiTableSortOptions options = new FlexiTableSortOptions();
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
if (isAdministrativeUser) {
options.setDefaultOrderBy(new SortKey(IdentityCourseElementCols.username.sortKey(), true));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(IdentityCourseElementCols.username, select));
}
int colIndex = AssessmentToolConstants.USER_PROPS_OFFSET;
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = UserManager.getInstance().isMandatoryUserProperty(AssessmentToolConstants.usageIdentifyer, userPropertyHandler);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, select, true, "userProp-" + colIndex));
if (!options.hasDefaultOrderBy()) {
options.setDefaultOrderBy(new SortKey("userProp-" + colIndex, true));
}
colIndex++;
}
initAssessmentColumns(columnsModel);
initStatusColumns(columnsModel);
initModificationDatesColumns(columnsModel);
initCalloutColumns(columnsModel);
AssessableCourseNode assessableNode = courseNode instanceof AssessableCourseNode ? (AssessableCourseNode) courseNode : null;
usersTableModel = new IdentityListCourseNodeTableModel(columnsModel, assessableNode, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", usersTableModel, 20, false, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
tableEl.setSearchEnabled(new AssessedIdentityListProvider(getIdentity(), courseEntry, referenceEntry, courseNode.getIdent(), assessmentCallback), ureq.getUserSession());
tableEl.setMultiSelect(!coachCourseEnv.isCourseReadOnly());
tableEl.setSortSettings(options);
tableEl.setSelectAllEnable(true);
List<FlexiTableFilter> filters = new ArrayList<>();
filters.add(new FlexiTableFilter(translate("filter.showAll"), "showAll", true));
filters.add(FlexiTableFilter.SPACER);
filters.add(new FlexiTableFilter(translate("filter.passed"), "passed"));
filters.add(new FlexiTableFilter(translate("filter.failed"), "failed"));
filters.add(new FlexiTableFilter(translate("filter.inProgress"), "inProgress"));
filters.add(new FlexiTableFilter(translate("filter.inReview"), "inReview"));
filters.add(new FlexiTableFilter(translate("filter.done"), "done"));
tableEl.setFilters("", filters, false);
if (assessmentCallback.canAssessBusinessGoupMembers() && group == null) {
List<BusinessGroup> coachedGroups = null;
if (assessmentCallback.isAdmin()) {
coachedGroups = course.getCourseEnvironment().getCourseGroupManager().getAllBusinessGroups();
} else {
coachedGroups = assessmentCallback.getCoachedGroups();
}
if (coachedGroups.size() > 0) {
List<FlexiTableFilter> groupFilters = new ArrayList<>();
for (BusinessGroup coachedGroup : coachedGroups) {
String groupName = StringHelper.escapeHtml(coachedGroup.getName());
groupFilters.add(new FlexiTableFilter(groupName, coachedGroup.getKey().toString(), "o_icon o_icon_group"));
}
tableEl.setExtendedFilterButton(translate("filter.groups"), groupFilters);
}
}
tableEl.setAndLoadPersistedPreferences(ureq, getTableId());
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class AssessedBusinessGroupCourseNodeListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ABGCols.key, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ABGCols.name, "select"));
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode aNode = (AssessableCourseNode) courseNode;
if (aNode.hasPassedConfigured()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ABGCols.countPassed, new ProgressRenderer(false, getTranslator())));
}
if (aNode.hasScoreConfigured()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ABGCols.averageScore, new ScoreCellRenderer()));
}
}
tableModel = new AssessedBusinessGroupTableModel(columnsModel, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 20, false, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
FlexiTableSortOptions options = new FlexiTableSortOptions();
options.setDefaultOrderBy(new SortKey(ABGCols.name.name(), true));
tableEl.setSortSettings(options);
tableEl.setAndLoadPersistedPreferences(ureq, "assessment-tool-group-list");
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutcont = (FormLayoutContainer) formLayout;
if (courseNode != null) {
String courseNodeCssClass = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType()).getIconCSSClass();
layoutcont.contextPut("courseNodeCssClass", courseNodeCssClass);
layoutcont.contextPut("courseNodeTitle", courseNode.getShortTitle());
}
}
}
use of org.olat.core.commons.persistence.SortKey in project OpenOLAT by OpenOLAT.
the class AbstractMemberListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
SortKey defaultSortKey = initColumns(columnsModel);
memberListModel = new MemberListTableModel(columnsModel, imModule.isOnlineStatusEnabled());
membersTable = uifactory.addTableElement(getWindowControl(), "memberList", memberListModel, 20, false, getTranslator(), formLayout);
membersTable.setMultiSelect(true);
membersTable.setEmtpyTableMessageKey("nomembers");
membersTable.setAndLoadPersistedPreferences(ureq, this.getClass().getSimpleName());
membersTable.setSearchEnabled(true);
membersTable.setExportEnabled(true);
membersTable.setSelectAllEnable(true);
membersTable.setElementCssClass("o_sel_member_list");
if (defaultSortKey != null) {
FlexiTableSortOptions options = new FlexiTableSortOptions();
options.setDefaultOrderBy(defaultSortKey);
membersTable.setSortSettings(options);
}
editButton = uifactory.addFormLink("edit.members", formLayout, Link.BUTTON);
editButton.setVisible((!globallyManaged || overrideManaged) && !readOnly);
mailButton = uifactory.addFormLink("table.header.mail", formLayout, Link.BUTTON);
removeButton = uifactory.addFormLink("table.header.remove", formLayout, Link.BUTTON);
removeButton.setVisible((!globallyManaged || overrideManaged) && !readOnly);
}
Aggregations