Search in sources :

Example 1 with ChiefControllerMessageEvent

use of org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method event.

@Override
public void event(Event event) {
    if (event == Window.AFTER_VALIDATING) {
        // now update the guimessage
        List<ZIndexWrapper> places = getWindowControl().getWindowBackOffice().getGuiMessages();
        Panel winnerP = null;
        int maxZ = -1;
        if (places != null) {
            // we have places where we can put the gui message
            for (Iterator<ZIndexWrapper> it_places = places.iterator(); it_places.hasNext(); ) {
                ZIndexWrapper ziw = it_places.next();
                int cind = ziw.getZindex();
                if (cind > maxZ) {
                    maxZ = cind;
                    winnerP = ziw.getPanel();
                }
            }
        } else {
            winnerP = guimsgHolder;
        }
        if (winnerP != null && winnerP != currentMsgHolder) {
            currentMsgHolder.setContent(null);
            winnerP.setContent(guimsgPanel);
            currentMsgHolder = winnerP;
        } else {
            currentMsgHolder = guimsgHolder;
            currentMsgHolder.setContent(guimsgPanel);
            currentMsgHolder.setDirty(guimsgPanel.isDirty());
        }
    } else if (event instanceof LanguageChangedEvent) {
        LanguageChangedEvent lce = (LanguageChangedEvent) event;
        UserRequest ureq = lce.getCurrentUreq();
        getTranslator().setLocale(lce.getNewLocale());
        initialize(ureq);
        WindowManager winman = Windows.getWindows(ureq).getWindowManager();
        initializeBase(ureq, winman, initialPanel);
        initialPanel.setContent(mainVc);
        reload = Boolean.TRUE;
    } else if (event instanceof ChiefControllerMessageEvent) {
        // msg can be set to show only on one node or on all nodes
        updateStickyMessage();
    } else if (event instanceof AssessmentModeNotificationEvent) {
        try {
            processAssessmentModeNotificationEvent((AssessmentModeNotificationEvent) event);
        } catch (Exception e) {
            logError("", e);
        }
    }
}
Also used : OncePanel(org.olat.core.gui.components.panel.OncePanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) AssessmentModeNotificationEvent(org.olat.course.assessment.AssessmentModeNotificationEvent) ZIndexWrapper(org.olat.core.gui.control.util.ZIndexWrapper) LanguageChangedEvent(org.olat.core.commons.chiefcontrollers.LanguageChangedEvent) ChiefControllerMessageEvent(org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent) HistoryPoint(org.olat.core.id.context.HistoryPoint) UserRequest(org.olat.core.gui.UserRequest) AssertException(org.olat.core.logging.AssertException) WindowManager(org.olat.core.gui.WindowManager)

Example 2 with ChiefControllerMessageEvent

use of org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent in project openolat by klemens.

the class GlobalStickyMessage method setGlobalStickyMessage.

/**
 * Sets a new global sticky message and updates all chief controllers to use
 * the new message. The message will be displayed to all logged in users in
 * a sticky way
 *
 * @param message The message to display or null if no message should be
 *          used at all
 *  @param global, if you like to set a message only on one node set global to false
 */
public static void setGlobalStickyMessage(String message, boolean global) {
    message = (StringHelper.containsNonWhitespace(message) ? message : null);
    if (global) {
        maintenanceMessageGlobal = message;
    } else {
        maintenanceMessagePerNode = message;
    }
    log.audit("Setting new maintenance message::" + maintenanceMessageGlobal);
    ChiefControllerMessageEvent mme = new ChiefControllerMessageEvent();
    if (message != null) {
        // create CHANGE_EVENT, and change message to something new
        mme.setMsg(message);
    } else if (maintenanceMessageGlobal == null && maintenanceMessagePerNode == null) {
        // remove, clear message, in case no more message should be shown.
        mme = ChiefControllerMessageEvent.CLEAR;
    }
    // send message to all (Full)ChiefControllers
    // 
    mme.setClusterWideMessage(global);
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(mme, GLOBAL_STICKY_MESSAGE);
}
Also used : ChiefControllerMessageEvent(org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent)

Example 3 with ChiefControllerMessageEvent

use of org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent in project OpenOLAT by OpenOLAT.

the class GlobalStickyMessage method setGlobalStickyMessage.

/**
 * Sets a new global sticky message and updates all chief controllers to use
 * the new message. The message will be displayed to all logged in users in
 * a sticky way
 *
 * @param message The message to display or null if no message should be
 *          used at all
 *  @param global, if you like to set a message only on one node set global to false
 */
public static void setGlobalStickyMessage(String message, boolean global) {
    message = (StringHelper.containsNonWhitespace(message) ? message : null);
    if (global) {
        maintenanceMessageGlobal = message;
    } else {
        maintenanceMessagePerNode = message;
    }
    log.audit("Setting new maintenance message::" + maintenanceMessageGlobal);
    ChiefControllerMessageEvent mme = new ChiefControllerMessageEvent();
    if (message != null) {
        // create CHANGE_EVENT, and change message to something new
        mme.setMsg(message);
    } else if (maintenanceMessageGlobal == null && maintenanceMessagePerNode == null) {
        // remove, clear message, in case no more message should be shown.
        mme = ChiefControllerMessageEvent.CLEAR;
    }
    // send message to all (Full)ChiefControllers
    // 
    mme.setClusterWideMessage(global);
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(mme, GLOBAL_STICKY_MESSAGE);
}
Also used : ChiefControllerMessageEvent(org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent)

Example 4 with ChiefControllerMessageEvent

use of org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent in project openolat by klemens.

the class BaseFullWebappController method event.

@Override
public void event(Event event) {
    if (event == Window.AFTER_VALIDATING) {
        // now update the guimessage
        List<ZIndexWrapper> places = getWindowControl().getWindowBackOffice().getGuiMessages();
        Panel winnerP = null;
        int maxZ = -1;
        if (places != null) {
            // we have places where we can put the gui message
            for (Iterator<ZIndexWrapper> it_places = places.iterator(); it_places.hasNext(); ) {
                ZIndexWrapper ziw = it_places.next();
                int cind = ziw.getZindex();
                if (cind > maxZ) {
                    maxZ = cind;
                    winnerP = ziw.getPanel();
                }
            }
        } else {
            winnerP = guimsgHolder;
        }
        if (winnerP != null && winnerP != currentMsgHolder) {
            currentMsgHolder.setContent(null);
            winnerP.setContent(guimsgPanel);
            currentMsgHolder = winnerP;
        } else {
            currentMsgHolder = guimsgHolder;
            currentMsgHolder.setContent(guimsgPanel);
            currentMsgHolder.setDirty(guimsgPanel.isDirty());
        }
    } else if (event instanceof LanguageChangedEvent) {
        LanguageChangedEvent lce = (LanguageChangedEvent) event;
        UserRequest ureq = lce.getCurrentUreq();
        getTranslator().setLocale(lce.getNewLocale());
        initialize(ureq);
        WindowManager winman = Windows.getWindows(ureq).getWindowManager();
        initializeBase(ureq, winman, initialPanel);
        initialPanel.setContent(mainVc);
        reload = Boolean.TRUE;
    } else if (event instanceof ChiefControllerMessageEvent) {
        // msg can be set to show only on one node or on all nodes
        updateStickyMessage();
    } else if (event instanceof AssessmentModeNotificationEvent) {
        try {
            processAssessmentModeNotificationEvent((AssessmentModeNotificationEvent) event);
        } catch (Exception e) {
            logError("", e);
        }
    }
}
Also used : OncePanel(org.olat.core.gui.components.panel.OncePanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) AssessmentModeNotificationEvent(org.olat.course.assessment.AssessmentModeNotificationEvent) ZIndexWrapper(org.olat.core.gui.control.util.ZIndexWrapper) LanguageChangedEvent(org.olat.core.commons.chiefcontrollers.LanguageChangedEvent) ChiefControllerMessageEvent(org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent) HistoryPoint(org.olat.core.id.context.HistoryPoint) UserRequest(org.olat.core.gui.UserRequest) AssertException(org.olat.core.logging.AssertException) WindowManager(org.olat.core.gui.WindowManager)

Aggregations

ChiefControllerMessageEvent (org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent)4 LanguageChangedEvent (org.olat.core.commons.chiefcontrollers.LanguageChangedEvent)2 UserRequest (org.olat.core.gui.UserRequest)2 WindowManager (org.olat.core.gui.WindowManager)2 OncePanel (org.olat.core.gui.components.panel.OncePanel)2 Panel (org.olat.core.gui.components.panel.Panel)2 StackedPanel (org.olat.core.gui.components.panel.StackedPanel)2 ZIndexWrapper (org.olat.core.gui.control.util.ZIndexWrapper)2 HistoryPoint (org.olat.core.id.context.HistoryPoint)2 AssertException (org.olat.core.logging.AssertException)2 AssessmentModeNotificationEvent (org.olat.course.assessment.AssessmentModeNotificationEvent)2