Search in sources :

Example 6 with ScrollTopCommand

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

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)

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