Search in sources :

Example 86 with Link

use of org.olat.core.gui.components.link.Link in project openolat by klemens.

the class AssessmentModeGuardController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link link = (Link) source;
        if ("go".equals(link.getCommand())) {
            ResourceGuard guard = (ResourceGuard) link.getUserObject();
            launchAssessmentMode(ureq, guard.getReference());
        } else if ("continue".equals(link.getCommand()) || "continue-main".equals(link.getCommand())) {
            ResourceGuard guard = (ResourceGuard) link.getUserObject();
            continueAfterAssessmentMode(ureq, guard);
        }
    }
}
Also used : Link(org.olat.core.gui.components.link.Link)

Example 87 with Link

use of org.olat.core.gui.components.link.Link in project openolat by klemens.

the class AssessmentModeGuardController method syncAssessmentMode.

private ResourceGuard syncAssessmentMode(UserRequest ureq, TransientAssessmentMode mode) {
    Date now = new Date();
    Date beginWithLeadTime = mode.getBeginWithLeadTime();
    Date endWithFollowupTime = mode.getEndWithFollowupTime();
    // check if the mode must not be guarded anymore
    if (mode.isManual() && (Status.end.equals(mode.getStatus()) || Status.none.equals(mode.getStatus()))) {
        return null;
    } else if (!mode.isManual() && (beginWithLeadTime.after(now) || now.after(endWithFollowupTime))) {
        return null;
    }
    ResourceGuard guard = guards.getGuardFor(mode);
    if (guard == null) {
        guard = createGuard(mode);
    }
    StringBuilder sb = new StringBuilder();
    boolean allowed = true;
    if (mode.getIpList() != null) {
        boolean ipInRange = assessmentModeMgr.isIpAllowed(mode.getIpList(), address);
        if (!ipInRange) {
            sb.append("<h4><i class='o_icon o_icon_warn o_icon-fw'>&nbsp;</i>");
            sb.append(translate("error.ip.range"));
            sb.append("</h4>");
            sb.append(translate("error.ip.range.desc", address));
        }
        allowed &= ipInRange;
    }
    if (mode.getSafeExamBrowserKey() != null) {
        boolean safeExamCheck = assessmentModeMgr.isSafelyAllowed(ureq.getHttpReq(), mode.getSafeExamBrowserKey());
        if (!safeExamCheck) {
            sb.append("<h4><i class='o_icon o_icon_warn o_icon-fw'>&nbsp;</i>");
            sb.append(translate("error.safe.exam"));
            sb.append("</h4>");
            sb.append(translate("error.safe.exam.desc"));
        }
        allowed &= safeExamCheck;
    }
    guard.getCountDown().setDate(mode.getBegin());
    String state;
    if (allowed) {
        Link go = guard.getGo();
        Link cont = guard.getContinue();
        state = updateButtons(mode, now, go, cont);
    } else {
        state = "error";
    }
    guard.sync(state, sb.toString(), mode, getLocale());
    return guard;
}
Also used : Date(java.util.Date) Link(org.olat.core.gui.components.link.Link)

Example 88 with Link

use of org.olat.core.gui.components.link.Link in project openolat by klemens.

the class AssessmentModeGuardController method createGuard.

private ResourceGuard createGuard(TransientAssessmentMode mode) {
    String id = Long.toString(CodeHelper.getRAMUniqueID());
    Link goButton = LinkFactory.createCustomLink("go-" + id, "go", "current.mode.start", Link.BUTTON, mainVC, this);
    goButton.setElementCssClass("o_sel_assessment_start");
    goButton.setCustomEnabledLinkCSS("btn btn-primary");
    goButton.setCustomDisabledLinkCSS("o_disabled btn btn-default");
    Link continueButton = LinkFactory.createCustomLink("continue-" + id, "continue", "current.mode.continue", Link.BUTTON, mainVC, this);
    continueButton.setCustomEnabledLinkCSS("btn btn-primary");
    continueButton.setCustomDisabledLinkCSS("o_disabled btn btn-default");
    CountDownComponent countDown = new CountDownComponent("count-" + id, mode.getBegin(), getTranslator());
    countDown.setI18nKey("current.mode.in");
    ResourceGuard guard = new ResourceGuard(mode.getModeKey(), goButton, continueButton, countDown);
    mainVC.put(goButton.getComponentName(), goButton);
    mainVC.put(continueButton.getComponentName(), continueButton);
    mainVC.put(countDown.getComponentName(), countDown);
    goButton.setUserObject(guard);
    continueButton.setUserObject(guard);
    return guard;
}
Also used : CountDownComponent(org.olat.core.gui.components.countdown.CountDownComponent) Link(org.olat.core.gui.components.link.Link)

Example 89 with Link

use of org.olat.core.gui.components.link.Link in project openolat by klemens.

the class FeedPeekviewController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link nodeLink = (Link) source;
        String itemId = (String) nodeLink.getUserObject();
        if (itemId == null) {
            fireEvent(ureq, new OlatCmdEvent(OlatCmdEvent.GOTONODE_CMD, nodeId));
        } else {
            fireEvent(ureq, new OlatCmdEvent(OlatCmdEvent.GOTONODE_CMD, nodeId + "/" + itemId));
        }
    }
}
Also used : OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) Link(org.olat.core.gui.components.link.Link)

Example 90 with Link

use of org.olat.core.gui.components.link.Link in project openolat by klemens.

the class BaseFullWebappController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link link = (Link) source;
        String mC = link.getCommand().substring(0, 1);
        if (mC.equals("t")) {
            // activate normal tab
            SiteInstance s = (SiteInstance) link.getUserObject();
            // fix the state of the last tab/site
            updateBusinessPath(ureq);
            HistoryPoint point = null;
            if (siteToBusinessPath.containsKey(s)) {
                point = siteToBusinessPath.get(s);
            }
            activateSite(s, ureq, null, true);
            if (point != null) {
                BusinessControlFactory.getInstance().addToHistory(ureq, point);
            }
            updateBusinessPath(ureq, s);
        } else if (mC.equals("a")) {
            // activate dyntab
            DTab dt = (DTab) link.getUserObject();
            // fix the state of the last tab/site
            updateBusinessPath(ureq);
            HistoryPoint point = null;
            if (dtabToBusinessPath.containsKey(dt)) {
                point = dtabToBusinessPath.get(dt);
            }
            doActivateDTab(dt);
            if (dt.getController() instanceof Activateable2) {
                ((Activateable2) dt.getController()).activate(ureq, null, new ReloadEvent());
            }
            if (point != null) {
                BusinessControlFactory.getInstance().addToHistory(ureq, point);
            }
        } else if (mC.equals("c")) {
            // close dyntab
            DTab dt = (DTab) link.getUserObject();
            requestCloseTab(ureq, dt);
        }
    } else if (source == getWindowControl().getWindowBackOffice().getWindow()) {
        if (event == Window.OLDTIMESTAMPCALL) {
            getLogger().info("RELOAD");
            HistoryPoint point = ureq.getUserSession().popLastHistoryEntry();
            if (point != null) {
                back(ureq, point);
            }
        }
    }
}
Also used : BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) DTab(org.olat.core.gui.control.generic.dtabs.DTab) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) Link(org.olat.core.gui.components.link.Link) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Aggregations

Link (org.olat.core.gui.components.link.Link)234 ArrayList (java.util.ArrayList)50 Component (org.olat.core.gui.components.Component)26 Identity (org.olat.core.id.Identity)22 Controller (org.olat.core.gui.control.Controller)18 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)14 List (java.util.List)12 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)12 BasicController (org.olat.core.gui.control.controller.BasicController)12 Date (java.util.Date)10 OlatCmdEvent (org.olat.core.gui.components.htmlsite.OlatCmdEvent)10 Event (org.olat.core.gui.control.Event)10 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)10 DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)9 VetoableCloseController (org.olat.core.gui.control.VetoableCloseController)8 WindowControl (org.olat.core.gui.control.WindowControl)8 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)8 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)8 HashSet (java.util.HashSet)6