Search in sources :

Example 61 with Link

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

the class BreadCrumbController method event.

/*
	 * (non-Javadoc)
	 * 
	 * @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) {
    for (Link link : breadCrumbLinks) {
        if (source == link) {
            // set content to new controller view and disable the corresponding link
            link.setEnabled(false);
            CrumbController crumbController = (CrumbController) link.getUserObject();
            breadCrumbVC.put("content", crumbController.getInitialComponent());
            // remove all children from this new controller
            CrumbController childCrumb = crumbController.getChildCrumbController();
            if (childCrumb != null) {
                removeFromBreadCrumb(childCrumb);
            }
            // manually fire an event to the crumb controller
            crumbController.dispatchEvent(ureq, this, CRUMB_VIEW_ACTIVATED);
            break;
        } else {
            link.setEnabled(true);
        }
    }
}
Also used : Link(org.olat.core.gui.components.link.Link)

Example 62 with Link

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

the class BreadCrumbController method putToBreadCrumbStack.

/**
 * Put a crumb controller with it's view to the bread crumb stack. Use the
 * crumbController.activateAndListenToChildCrumbController() to put new crumbs
 * to the stack in your code
 *
 * @param crumbController
 */
void putToBreadCrumbStack(CrumbController crumbController) {
    // re-enable last link
    if (breadCrumbLinks.size() > 0)
        breadCrumbLinks.get(breadCrumbLinks.size() - 1).setEnabled(true);
    // create new link for this crumb and add it to data model
    String cmd = "crumb-" + breadCrumbLinks.size();
    Link link = LinkFactory.createCustomLink(cmd, cmd, cmd, Link.NONTRANSLATED, breadCrumbVC, this);
    link.setCustomDisplayText(crumbController.getCrumbLinkText());
    link.setTitle(crumbController.getCrumbLinkHooverText());
    link.setUserObject(crumbController);
    link.setEnabled(false);
    breadCrumbLinks.add(link);
    breadCrumbVC.put("content", crumbController.getInitialComponent());
    // set bread crumb navigation controller
    crumbController.setBreadCrumbController(this);
}
Also used : Link(org.olat.core.gui.components.link.Link)

Example 63 with Link

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

the class BreadCrumbController method resetCrumbTexts.

/**
 * Reset all texts on the crumb path
 */
public void resetCrumbTexts() {
    for (Link link : breadCrumbLinks) {
        CrumbController crumbController = (CrumbController) link.getUserObject();
        link.setCustomDisplayText(crumbController.getCrumbLinkText());
        link.setTitle(crumbController.getCrumbLinkHooverText());
    }
}
Also used : Link(org.olat.core.gui.components.link.Link)

Example 64 with Link

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

the class BreadCrumbController method removeFromBreadCrumb.

/**
 * Remove a crumb controller and all it's child controllers that are created
 * by this controller or it's children from the bread crumb stack and calls
 * dispose on the crumb controller. Use
 * crumbController.removeFromBreadCrumbPathAndDispose() if you manually want
 * to remove a crumb controller from the bread crumb
 *
 * @param crumbController
 */
void removeFromBreadCrumb(CrumbController crumbController) {
    int activateLinkPos = 0;
    for (Link link : breadCrumbLinks) {
        CrumbController linkController = (CrumbController) link.getUserObject();
        if (linkController.equals(crumbController)) {
            linkController.deactivateAndDisposeChildCrumbController();
            linkController.dispose();
            break;
        }
        activateLinkPos++;
    }
    if (activateLinkPos > 0) {
        // remove children elements from list and reput to hibernate
        breadCrumbLinks = breadCrumbLinks.subList(0, activateLinkPos);
        breadCrumbVC.contextPut("breadCrumbs", breadCrumbLinks);
        // disable current link and update content view from current controller
        Link parentLink = breadCrumbLinks.get(activateLinkPos - 1);
        parentLink.setEnabled(false);
        CrumbController parentController = (CrumbController) parentLink.getUserObject();
        breadCrumbVC.put("content", parentController.getInitialComponent());
    }
}
Also used : Link(org.olat.core.gui.components.link.Link)

Example 65 with Link

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

the class EdubasePeekViewController method createPeekviewComponent.

private Component createPeekviewComponent(ModuleConfiguration modulConfiguration) {
    VelocityContainer container = createVelocityContainer(PEEKVIEW_CONTAINER);
    ;
    // BookSections
    List<BookSection> bookSections = modulConfiguration.getList(EdubaseCourseNode.CONFIG_BOOK_SECTIONS, BookSection.class).stream().sorted(new PositionComparator()).limit(NUMBER_BOOK_SECTION_DESC_DISABLED).collect(Collectors.toList());
    container.contextPut("bookSections", bookSections);
    // Add a link to show all BookSections (go to node)
    Link allItemsLink = LinkFactory.createLink("peekview.allItemsLink", container, this);
    allItemsLink.setIconRightCSS("o_icon o_icon_start");
    allItemsLink.setCustomEnabledLinkCSS("pull-right");
    return container;
}
Also used : PositionComparator(org.olat.modules.edubase.model.PositionComparator) BookSection(org.olat.modules.edubase.BookSection) Link(org.olat.core.gui.components.link.Link) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

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