Search in sources :

Example 1 with ScrollTopCommand

use of org.olat.core.gui.control.winmgr.ScrollTopCommand 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 2 with ScrollTopCommand

use of org.olat.core.gui.control.winmgr.ScrollTopCommand in project OpenOLAT by OpenOLAT.

the class UserSearchFlexiController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == backLink) {
        flc.contextPut("noList", "false");
        flc.contextPut("showButton", "false");
        if (userTableModel != null) {
            userTableModel.setObjects(new ArrayList<>());
            tableEl.reset();
        }
    } else if (searchButton == source) {
        if (validateForm(ureq)) {
            getWindowControl().getWindowBackOffice().sendCommandTo(new ScrollTopCommand());
            doSearch();
        }
    } else if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            Identity chosenIdent = userTableModel.getObject(se.getIndex());
            fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
        }
    } else {
        super.formInnerEvent(ureq, source, event);
    }
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) ScrollTopCommand(org.olat.core.gui.control.winmgr.ScrollTopCommand)

Example 3 with ScrollTopCommand

use of org.olat.core.gui.control.winmgr.ScrollTopCommand in project openolat by klemens.

the class StepsMainRunController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, org.olat.core.gui.components.form.flexible.impl.FormEvent event) {
    int whichTitleClickedIndex = stepTitleLinks.indexOf(source);
    if (source == cancelButton || source == closeLink) {
        if (cancel != null) {
            // execute some cancel / rollback code
            // a wizard is expected not to touch / change data in the cancel
            // case undo your work here.
            Step returnStep = cancel.execute(ureq, getWindowControl(), stepsContext);
            if (returnStep != Step.NOSTEP) {
            // error case FIXME:pb finish wizard for this case
            } else {
            // fireEvent(ureq, Event.CANCELLED_EVENT);
            }
        }
        fireEvent(ureq, Event.CANCELLED_EVENT);
    } else if (source == nextButton) {
        // submit and let current unsaved step do its work
        flc.getRootForm().submitAndNext(ureq);
        // getWindowControl().getWindowBackOffice()
        // .sendCommandTo(new JSCommand("try { o_scrollToElement('.o_wizard.modal.show.in'); } catch(e){ }"));
        getWindowControl().getWindowBackOffice().sendCommandTo(new ScrollTopCommand());
    // the current step decides whether to proceed to the next step or
    // not.
    } else if (source == finishButton) {
        // submit and let last unsaved step do its work
        finishCycle = true;
        flc.getRootForm().submitAndFinish(ureq);
        getWindowControl().getWindowBackOffice().sendCommandTo(new ScrollTopCommand());
    // the current step decides whether to proceed or not
    // an end step will fire FINISH
    // a intermediate step will fire NEXT .. but NEXT && FINISHCYCLE
    // means also finish
    } else if (source == prevButton) {
        lastEvent = StepsEvent.ACTIVATE_PREVIOUS;
        doAfterDispatch = true;
        getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("try { o_scrollToElement('.o_wizard.modal.show.in'); } catch(e){ }"));
    } else if (whichTitleClickedIndex >= 0) {
        // remove all steps until the clicked one
        for (int from = currentStepIndex; from > whichTitleClickedIndex; from--) {
            stepPages.pop();
            steps.pop();
            currentStepIndex--;
            // disable
            stepTitleLinks.get(currentStepIndex).setEnabled(false);
            // "previous"
            // step.
            StepFormController controller = stepPagesController.pop();
            controller.back();
            removeAsListenerAndDispose(controller);
            // update current step index to velocity
            flc.contextPut("currentStepPos", currentStepIndex + 1);
        }
        flc.add("FFO_CURRENTSTEPPAGE", stepPages.peek());
        PrevNextFinishConfig pnfConf = steps.peek().getInitialPrevNextFinishConfig();
        prevButton.setEnabled(pnfConf.isBackIsEnabled());
        nextButton.setEnabled(pnfConf.isNextIsEnabled());
        finishButton.setEnabled(pnfConf.isFinishIsEnabled());
    }
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand) ScrollTopCommand(org.olat.core.gui.control.winmgr.ScrollTopCommand)

Example 4 with ScrollTopCommand

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

use of org.olat.core.gui.control.winmgr.ScrollTopCommand in project openolat by klemens.

the class UserSearchFlexiController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == backLink) {
        flc.contextPut("noList", "false");
        flc.contextPut("showButton", "false");
        if (userTableModel != null) {
            userTableModel.setObjects(new ArrayList<>());
            tableEl.reset();
        }
    } else if (searchButton == source) {
        if (validateForm(ureq)) {
            getWindowControl().getWindowBackOffice().sendCommandTo(new ScrollTopCommand());
            doSearch();
        }
    } else if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            Identity chosenIdent = userTableModel.getObject(se.getIndex());
            fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
        }
    } else {
        super.formInnerEvent(ureq, source, event);
    }
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) ScrollTopCommand(org.olat.core.gui.control.winmgr.ScrollTopCommand)

Aggregations

ScrollTopCommand (org.olat.core.gui.control.winmgr.ScrollTopCommand)6 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)2 UserRequest (org.olat.core.gui.UserRequest)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 LayeredPanel (org.olat.core.gui.components.panel.LayeredPanel)2 Panel (org.olat.core.gui.components.panel.Panel)2 SimpleStackedPanel (org.olat.core.gui.components.panel.SimpleStackedPanel)2 StackedPanel (org.olat.core.gui.components.panel.StackedPanel)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 ZIndexWrapper (org.olat.core.gui.control.util.ZIndexWrapper)2 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)2 ValidationResult (org.olat.core.gui.render.ValidationResult)2 Identity (org.olat.core.id.Identity)2