Search in sources :

Example 81 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

the class SelectThreadStepForm method displayAsNewThread.

private void displayAsNewThread(UserRequest ureq) {
    Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
    String creatorFullname = userManager.getUserDisplayName(messageToMove.getCreator());
    Date lastModified = messageToMove.getLastModified();
    int numOfPosts = forumManager.countMessageChildren(messageToMove.getKey()) + 1;
    ForumThread row = new ForumThread(messageToMove, creatorFullname, lastModified, numOfPosts);
    List<ForumThread> threads = threadTableModel.getObjects();
    if (containsMessage(row)) {
        showWarning("thread.already.exits");
    } else {
        threads.add(row);
        addToRunContext(SendMailStepForm.NEW_THREAD, Boolean.TRUE);
        threadTableModel.setObjects(threads);
        threadTableModel.sort(new SortKey(ThreadListCols.thread.name(), true));
        threadTable.reloadData();
        threadTable.reset();
        // move on to next wizard step directly
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    }
}
Also used : Message(org.olat.modules.fo.Message) ForumThread(org.olat.modules.fo.model.ForumThread) SortKey(org.olat.core.commons.persistence.SortKey) Date(java.util.Date)

Example 82 with SortKey

use of org.olat.core.commons.persistence.SortKey in project openolat by klemens.

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();
}
Also used : Message(org.olat.modules.fo.Message) ForumThread(org.olat.modules.fo.model.ForumThread) SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity)

Aggregations

SortKey (org.olat.core.commons.persistence.SortKey)82 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)48 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)42 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)42 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)30 ArrayList (java.util.ArrayList)20 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)18 Identity (org.olat.core.id.Identity)18 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)14 Test (org.junit.Test)12 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)12 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)12 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)10 QuestionItem (org.olat.modules.qpool.QuestionItem)10 QuestionItemView (org.olat.modules.qpool.QuestionItemView)10 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)8 DateFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer)8 FlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer)6 BusinessGroup (org.olat.group.BusinessGroup)6