Search in sources :

Example 6 with SelectMessageEvent

use of org.olat.modules.fo.ui.events.SelectMessageEvent in project openolat by klemens.

the class MessageListController method doFinalizeMove.

private void doFinalizeMove(UserRequest ureq, MessageView messageToMove, Long parentMessageKey) {
    if (foCallback.mayEditMessageAsModerator()) {
        Message message = forumManager.getMessageById(messageToMove.getKey());
        Message parentMessage = forumManager.getMessageById(parentMessageKey);
        message = forumManager.moveMessage(message, parentMessage);
        markRead(message);
        // commit before sending event
        DBFactory.getInstance().commit();
        ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_MOVE, getClass(), LoggingResourceable.wrap(message));
        Long threadKey = parentMessage.getThreadtop() == null ? parentMessage.getKey() : parentMessage.getThreadtop().getKey();
        fireEvent(ureq, new SelectMessageEvent(SelectMessageEvent.SELECT_THREAD, threadKey, message.getKey()));
    } else {
        showWarning("may.not.move.message");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent)

Example 7 with SelectMessageEvent

use of org.olat.modules.fo.ui.events.SelectMessageEvent in project openolat by klemens.

the class ForumController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (threadListCtrl == source) {
        if (event instanceof SelectMessageEvent) {
            doProcessSelectEvent(ureq, (SelectMessageEvent) event);
        } else if (event instanceof SelectUserListEvent) {
            doUserList(ureq);
        }
    } else if (viewCtrl == source) {
        if (event == Event.BACK_EVENT) {
            reloadThreadList |= viewCtrl.hasMarkedNewMessages();
            doThreadList(ureq);
        } else if (event instanceof DeleteThreadEvent) {
            reloadThreadList = true;
            doThreadList(ureq);
        } else if (event instanceof DeleteMessageEvent) {
            reloadThreadList = true;
        } else if (event instanceof SelectMessageEvent) {
            doProcessSelectEvent(ureq, (SelectMessageEvent) event);
        }
    } else if (userViewCtrl == source) {
        if (event == Event.BACK_EVENT) {
            reloadThreadList |= userViewCtrl.hasMarkedNewMessages();
            cleanUpMessageViews();
            doUserList(ureq);
        } else if (event instanceof SelectMessageEvent) {
            doProcessSelectEvent(ureq, (SelectMessageEvent) event);
        }
    } else if (userListCtrl == source) {
        if (event == Event.BACK_EVENT) {
            removeAsListenerAndDispose(userListCtrl);
            userListCtrl = null;
            doThreadList(ureq);
        } else if (event instanceof SelectUserEvent) {
            SelectUserEvent sue = (SelectUserEvent) event;
            if (sue.isGuest()) {
                doGuestMessageList(ureq);
            } else if (StringHelper.containsNonWhitespace(sue.getPseudonym())) {
                doPseudonymMessageList(ureq, sue.getIdentityKey(), sue.getPseudonym());
            } else if (sue.getIdentityKey() != null) {
                doUserMessageList(ureq, sue.getIdentityKey());
            }
        }
    }
}
Also used : SelectUserListEvent(org.olat.modules.fo.ui.events.SelectUserListEvent) DeleteThreadEvent(org.olat.modules.fo.ui.events.DeleteThreadEvent) SelectUserEvent(org.olat.modules.fo.ui.events.SelectUserEvent) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent) DeleteMessageEvent(org.olat.modules.fo.ui.events.DeleteMessageEvent)

Example 8 with SelectMessageEvent

use of org.olat.modules.fo.ui.events.SelectMessageEvent in project OpenOLAT by OpenOLAT.

the class MessageListController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == exportCtrl) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            if (event == Event.CHANGED_EVENT) {
                StepsRunContext runContext = exportCtrl.getRunContext();
                Message originTopMessage = (Message) runContext.get(SendMailStepForm.START_THREADTOP);
                originTopMessage = forumManager.loadMessage(originTopMessage.getKey());
                if (originTopMessage != null) {
                    // refresh origin thread
                    fireEvent(ureq, new SelectMessageEvent(SelectMessageEvent.SELECT_THREAD, originTopMessage.getKey()));
                } else {
                    fireEvent(ureq, Event.BACK_EVENT);
                }
            }
            getWindowControl().pop();
            removeAsListenerAndDispose(exportCtrl);
            exportCtrl = null;
        }
    } else if (source == confirmDeleteCtrl) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            MessageView deletedMessage = (MessageView) confirmDeleteCtrl.getUserObject();
            doDeleteMessage(ureq, deletedMessage);
        }
    } else if (editMessageCtrl == source) {
        // edit done -> save
        if (event instanceof ErrorEditMessage) {
            handleEditError(ureq);
        } else {
            Message message = editMessageCtrl.getMessage();
            if (message != null) {
                if (thread != null && thread.getKey().equals(message.getKey())) {
                    thread = message;
                }
                reloadModel(ureq, message);
            } else {
                showInfo("header.cannoteditmessage");
            }
        }
        cmc.deactivate();
    } else if (replyMessageCtrl == source) {
        if (event instanceof ErrorEditMessage) {
            handleEditError(ureq);
        } else {
            Message reply = replyMessageCtrl.getMessage();
            if (reply != null) {
                reloadModel(ureq, reply);
            } else {
                showInfo("header.cannotsavemessage");
            }
        }
        cmc.deactivate();
    } else if (messageTableCtrl == source) {
        if (event instanceof SelectMessageEvent) {
            SelectMessageEvent sme = (SelectMessageEvent) event;
            doSelectTheOne(ureq, sme.getMessageKey());
        }
    } else if (moveCtrl == source) {
        if (event instanceof SelectMessageEvent) {
            SelectMessageEvent sme = (SelectMessageEvent) event;
            doFinalizeMove(ureq, moveCtrl.getSelectView(), sme.getMessageKey());
            cmc.deactivate();
        }
    } else if (confirmSplitCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            MessageView splitedMessage = (MessageView) confirmSplitCtrl.getUserObject();
            doSplitThread(ureq, splitedMessage);
        }
    } else if (source == cmc) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext)

Example 9 with SelectMessageEvent

use of org.olat.modules.fo.ui.events.SelectMessageEvent in project OpenOLAT by OpenOLAT.

the class MessageListController method doSplitThread.

private void doSplitThread(UserRequest ureq, MessageView message) {
    if (foCallback.mayEditMessageAsModerator()) {
        Message reloadedMessage = forumManager.getMessageById(message.getKey());
        Message newTopMessage = forumManager.splitThread(reloadedMessage);
        // do logging
        ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_SPLIT, getClass(), LoggingResourceable.wrap(newTopMessage));
        showInfo("new.thread.location");
        // open the new thread
        fireEvent(ureq, new SelectMessageEvent(SelectMessageEvent.SELECT_THREAD, newTopMessage.getKey()));
    } else {
        showWarning("may.not.split.thread");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent)

Example 10 with SelectMessageEvent

use of org.olat.modules.fo.ui.events.SelectMessageEvent in project openolat by klemens.

the class ForumMessageListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("select".equals(cmd)) {
                MessageLightView message = dataModel.getObject(se.getIndex());
                fireEvent(ureq, new SelectMessageEvent(SelectMessageEvent.SELECT_MESSAGE, message.getKey()));
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent)

Aggregations

SelectMessageEvent (org.olat.modules.fo.ui.events.SelectMessageEvent)10 Message (org.olat.modules.fo.Message)6 ErrorEditMessage (org.olat.modules.fo.ui.events.ErrorEditMessage)6 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 DeleteMessageEvent (org.olat.modules.fo.ui.events.DeleteMessageEvent)2 DeleteThreadEvent (org.olat.modules.fo.ui.events.DeleteThreadEvent)2 SelectUserEvent (org.olat.modules.fo.ui.events.SelectUserEvent)2 SelectUserListEvent (org.olat.modules.fo.ui.events.SelectUserListEvent)2