Search in sources :

Example 1 with ZIndexWrapper

use of org.olat.core.gui.control.util.ZIndexWrapper in project OpenOLAT by OpenOLAT.

the class GuiStackNiceImpl method pushCallout.

@Override
public void pushCallout(Component content, String targetId, CalloutSettings settings) {
    // wrap the component into a modal foreground dialog with alpha-blended-background
    final Panel guiMsgPlace = new Panel("guimsgplace_for_callout");
    VelocityContainer inset = new VelocityContainer("inset", VELOCITY_ROOT + "/callout.html", null, null) {

        public void validate(UserRequest ureq, ValidationResult vr) {
            super.validate(ureq, vr);
            // just before rendering, we need to tell the windowbackoffice that we are a favorite for accepting gui-messages.
            // the windowbackoffice doesn't know about guimessages, it is only a container that keeps them for one render cycle
            List<ZIndexWrapper> zindexed = wbo.getGuiMessages();
            zindexed.add(new ZIndexWrapper(guiMsgPlace, 10));
        }
    };
    inset.put("cont", content);
    inset.put("guimsgplace", guiMsgPlace);
    inset.contextPut("guimsgtarget", targetId);
    int zindex = 900 + (modalLayers * 100) + 5;
    inset.contextPut("zindexoverlay", zindex + 1);
    inset.contextPut("zindexshim", zindex);
    inset.contextPut("zindexarea", zindex + 5);
    inset.contextPut("zindexextwindows", zindex + 50);
    if (settings != null) {
        inset.contextPut("arrow", settings.isArrow());
        inset.contextPut("orientation", settings.getOrientation().name());
    } else {
        inset.contextPut("arrow", Boolean.TRUE);
        inset.contextPut("orientation", CalloutOrientation.bottom.name());
    }
    modalPanel.pushContent(inset);
    modalLayers++;
}
Also used : SimpleStackedPanel(org.olat.core.gui.components.panel.SimpleStackedPanel) LayeredPanel(org.olat.core.gui.components.panel.LayeredPanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) ZIndexWrapper(org.olat.core.gui.control.util.ZIndexWrapper) ValidationResult(org.olat.core.gui.render.ValidationResult) UserRequest(org.olat.core.gui.UserRequest) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 2 with ZIndexWrapper

use of org.olat.core.gui.control.util.ZIndexWrapper in project OpenOLAT by OpenOLAT.

the class GuiStackNiceImpl method pushModalDialog.

/**
 * @param title the title of the modal dialog, can be null
 * @param content the component to push as modal dialog
 */
@Override
public void pushModalDialog(Component content) {
    wbo.sendCommandTo(new ScrollTopCommand());
    // wrap the component into a modal foreground dialog with alpha-blended-background
    final Panel guiMsgPlace = new Panel("guimsgplace_for_modaldialog");
    VelocityContainer inset = new VelocityContainer("inset", VELOCITY_ROOT + "/modalDialog.html", null, null) {

        @Override
        public void validate(UserRequest ureq, ValidationResult vr) {
            super.validate(ureq, vr);
            // just before rendering, we need to tell the windowbackoffice that we are a favorite for accepting gui-messages.
            // the windowbackoffice doesn't know about guimessages, it is only a container that keeps them for one render cycle
            List<ZIndexWrapper> zindexed = wbo.getGuiMessages();
            zindexed.add(new ZIndexWrapper(guiMsgPlace, 10));
        }
    };
    inset.put("cont", content);
    inset.put("guimsgplace", guiMsgPlace);
    int zindex = 900 + (modalLayers * 100) + 5;
    inset.contextPut("zindexoverlay", zindex + 1);
    inset.contextPut("zindexshim", zindex);
    inset.contextPut("zindexarea", zindex + 5);
    inset.contextPut("zindexextwindows", zindex + 50);
    modalPanel.pushContent(inset);
    // the links in the panel cannot be clicked because of the alpha-blended background over it, but if user chooses own css style ->
    // FIXME:fj:b panel.setEnabled(false) causes effects if there is an image component in the panel -> the component is not dispatched
    // and thus renders inline and wastes the timestamp.
    // Needed:solution (a) a flag (a bit of the mode indicator of the urlbuilder can be used) to indicate that a request always needs to be delivered even
    // if the component or a parent is not enabled.
    // alternative solution(b): wrap the imagecomponent into a controller and use a mapper
    // alternative solution(c): introduce a flag to the component to say "dispatch always", even if a parent component is not enabled
    // 
    // - solution a would be easy, but would allow for forced dispatching by manipulating the url's flag.
    // for e.g. a Link button ("make me admin") that is disabled this is a security breach.
    // - solution b needs some wrapping, the advantage (for images) would be that they are cached by the browser if requested more than once
    // within a controller
    // - solution c is a safe and easy way to allow dispatching (only in case a mediaresource is returned as a result of the dispatching) even
    // if parent elements are not enabled
    // proposal: fix for 5.1.0 with solution c; for 5.0.1 the uncommenting of the line below is okay.
    // if (modalLayers == 0) panel.setEnabled(false);
    modalLayers++;
}
Also used : SimpleStackedPanel(org.olat.core.gui.components.panel.SimpleStackedPanel) LayeredPanel(org.olat.core.gui.components.panel.LayeredPanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) ZIndexWrapper(org.olat.core.gui.control.util.ZIndexWrapper) ValidationResult(org.olat.core.gui.render.ValidationResult) ScrollTopCommand(org.olat.core.gui.control.winmgr.ScrollTopCommand) UserRequest(org.olat.core.gui.UserRequest) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 3 with ZIndexWrapper

use of org.olat.core.gui.control.util.ZIndexWrapper 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 4 with ZIndexWrapper

use of org.olat.core.gui.control.util.ZIndexWrapper in project openolat by klemens.

the class GuiStackNiceImpl method pushModalDialog.

/**
 * @param title the title of the modal dialog, can be null
 * @param content the component to push as modal dialog
 */
@Override
public void pushModalDialog(Component content) {
    wbo.sendCommandTo(new ScrollTopCommand());
    // wrap the component into a modal foreground dialog with alpha-blended-background
    final Panel guiMsgPlace = new Panel("guimsgplace_for_modaldialog");
    VelocityContainer inset = new VelocityContainer("inset", VELOCITY_ROOT + "/modalDialog.html", null, null) {

        @Override
        public void validate(UserRequest ureq, ValidationResult vr) {
            super.validate(ureq, vr);
            // just before rendering, we need to tell the windowbackoffice that we are a favorite for accepting gui-messages.
            // the windowbackoffice doesn't know about guimessages, it is only a container that keeps them for one render cycle
            List<ZIndexWrapper> zindexed = wbo.getGuiMessages();
            zindexed.add(new ZIndexWrapper(guiMsgPlace, 10));
        }
    };
    inset.put("cont", content);
    inset.put("guimsgplace", guiMsgPlace);
    int zindex = 900 + (modalLayers * 100) + 5;
    inset.contextPut("zindexoverlay", zindex + 1);
    inset.contextPut("zindexshim", zindex);
    inset.contextPut("zindexarea", zindex + 5);
    inset.contextPut("zindexextwindows", zindex + 50);
    modalPanel.pushContent(inset);
    // the links in the panel cannot be clicked because of the alpha-blended background over it, but if user chooses own css style ->
    // FIXME:fj:b panel.setEnabled(false) causes effects if there is an image component in the panel -> the component is not dispatched
    // and thus renders inline and wastes the timestamp.
    // Needed:solution (a) a flag (a bit of the mode indicator of the urlbuilder can be used) to indicate that a request always needs to be delivered even
    // if the component or a parent is not enabled.
    // alternative solution(b): wrap the imagecomponent into a controller and use a mapper
    // alternative solution(c): introduce a flag to the component to say "dispatch always", even if a parent component is not enabled
    // 
    // - solution a would be easy, but would allow for forced dispatching by manipulating the url's flag.
    // for e.g. a Link button ("make me admin") that is disabled this is a security breach.
    // - solution b needs some wrapping, the advantage (for images) would be that they are cached by the browser if requested more than once
    // within a controller
    // - solution c is a safe and easy way to allow dispatching (only in case a mediaresource is returned as a result of the dispatching) even
    // if parent elements are not enabled
    // proposal: fix for 5.1.0 with solution c; for 5.0.1 the uncommenting of the line below is okay.
    // if (modalLayers == 0) panel.setEnabled(false);
    modalLayers++;
}
Also used : SimpleStackedPanel(org.olat.core.gui.components.panel.SimpleStackedPanel) LayeredPanel(org.olat.core.gui.components.panel.LayeredPanel) Panel(org.olat.core.gui.components.panel.Panel) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) ZIndexWrapper(org.olat.core.gui.control.util.ZIndexWrapper) ValidationResult(org.olat.core.gui.render.ValidationResult) ScrollTopCommand(org.olat.core.gui.control.winmgr.ScrollTopCommand) UserRequest(org.olat.core.gui.UserRequest) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 5 with ZIndexWrapper

use of org.olat.core.gui.control.util.ZIndexWrapper 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

UserRequest (org.olat.core.gui.UserRequest)6 Panel (org.olat.core.gui.components.panel.Panel)6 StackedPanel (org.olat.core.gui.components.panel.StackedPanel)6 ZIndexWrapper (org.olat.core.gui.control.util.ZIndexWrapper)6 LayeredPanel (org.olat.core.gui.components.panel.LayeredPanel)4 SimpleStackedPanel (org.olat.core.gui.components.panel.SimpleStackedPanel)4 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)4 ValidationResult (org.olat.core.gui.render.ValidationResult)4 ChiefControllerMessageEvent (org.olat.core.commons.chiefcontrollers.ChiefControllerMessageEvent)2 LanguageChangedEvent (org.olat.core.commons.chiefcontrollers.LanguageChangedEvent)2 WindowManager (org.olat.core.gui.WindowManager)2 OncePanel (org.olat.core.gui.components.panel.OncePanel)2 ScrollTopCommand (org.olat.core.gui.control.winmgr.ScrollTopCommand)2 HistoryPoint (org.olat.core.id.context.HistoryPoint)2 AssertException (org.olat.core.logging.AssertException)2 AssessmentModeNotificationEvent (org.olat.course.assessment.AssessmentModeNotificationEvent)2