Search in sources :

Example 81 with Link

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

the class EPTagBrowseController 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) {
    // nothing
    if (tagLinks.contains(source)) {
        Link tagLink = (Link) source;
        TagWrapper tagWrapper = (TagWrapper) tagLink.getUserObject();
        if (TagState.possible.equals(tagWrapper.getState())) {
            tagWrapper.setState(TagState.selected);
            List<AbstractArtefact> artefacts = recalculateTagCloud();
            fireEvent(ureq, new EPTagBrowseEvent(artefacts));
        } else if (TagState.selected.equals(tagWrapper.getState())) {
            tagWrapper.setState(TagState.possible);
            List<AbstractArtefact> artefacts = recalculateTagCloud();
            fireEvent(ureq, new EPTagBrowseEvent(artefacts));
        }
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList) List(java.util.List) Link(org.olat.core.gui.components.link.Link)

Example 82 with Link

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

the class EPMultipleArtefactPreviewController method preparePaging.

private void preparePaging(UserRequest ureq, int actualPage) {
    int nrOfArtefacts = artefactsFullList.size();
    vC.contextPut("artefactAmnt", Integer.toString(nrOfArtefacts));
    if (nrOfArtefacts > artefactsPerPage) {
        int divRest = (nrOfArtefacts % artefactsPerPage);
        int nrOfPages = (nrOfArtefacts / artefactsPerPage) + (divRest > 0 ? 1 : 0);
        ArrayList<Link> pageLinkList = new ArrayList<Link>();
        for (int i = 1; i < nrOfPages + 1; i++) {
            Link pageLink = LinkFactory.createCustomLink("pageLink" + i, "pageLink" + i, String.valueOf(i), Link.LINK + Link.NONTRANSLATED, vC, this);
            pageLink.setUserObject(i);
            if (actualPage == i)
                pageLink.setEnabled(false);
            pageLinkList.add(pageLink);
        }
        int fromIndex = (actualPage - 1) * artefactsPerPage;
        int toIndex = actualPage * artefactsPerPage;
        if (toIndex > nrOfArtefacts)
            toIndex = nrOfArtefacts;
        List<AbstractArtefact> artefactsToShow = artefactsFullList.subList(fromIndex, toIndex);
        vC.contextPut("pageLinkList", pageLinkList);
        initOrUpdateArtefactControllers(ureq, artefactsToShow);
    } else {
        // no paging needed
        vC.contextRemove("pageLinkList");
        initOrUpdateArtefactControllers(ureq, artefactsFullList);
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Link(org.olat.core.gui.components.link.Link)

Example 83 with Link

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

the class EPTOCReadOnlyController 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 == artOnOffLink) {
        displayArtefactsInTOC = !displayArtefactsInTOC;
        artOnOffLink.setCustomDisplayText(translate("artOnOffLink." + !displayArtefactsInTOC));
        refreshTOC(ureq);
    } else if (source instanceof Link) {
        // could be a TOC-Link
        Link link = (Link) source;
        String cmd = link.getCommand();
        PortfolioStructure parentStruct = (PortfolioStructure) link.getUserObject();
        if (cmd.equals(LINK_CMD_OPEN_STRUCT)) {
            fireEvent(ureq, new EPStructureEvent(EPStructureEvent.SELECT, parentStruct));
        } else if (cmd.equals(LINK_CMD_OPEN_ARTEFACT)) {
            // open the parent structure
            fireEvent(ureq, new EPStructureEvent(EPStructureEvent.SELECT, parentStruct));
        } else if (cmd.equals(LINK_CMD_OPEN_COMMENTS)) {
            fireEvent(ureq, new EPStructureEvent(EPStructureEvent.SELECT_WITH_COMMENTS, parentStruct));
        }
    }
}
Also used : EPStructureEvent(org.olat.portfolio.ui.structel.EPStructureEvent) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Link(org.olat.core.gui.components.link.Link)

Example 84 with Link

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

the class EPTOCReadOnlyController method buildTOCModel.

/**
 * builds the tocList recursively containing artefacts, pages and
 * struct-Elements
 *
 * @param pStruct
 * @param tocList
 *            list with TOCElement's to use in velocity
 * @param level
 * @param withArtefacts
 *            set false, to skip artefacts
 */
private void buildTOCModel(PortfolioStructure pStruct, List<TOCElement> tocList, int level) {
    level++;
    if (displayArtefactsInTOC) {
        List<AbstractArtefact> artList = ePFMgr.getArtefacts(pStruct);
        if (artList != null && artList.size() != 0) {
            for (AbstractArtefact artefact : artList) {
                String key = String.valueOf(artefact.getKey());
                String title = StringHelper.escapeHtml(artefact.getTitle());
                Link iconLink = LinkFactory.createCustomLink("arte_" + key, LINK_CMD_OPEN_ARTEFACT, "", Link.NONTRANSLATED, vC, this);
                iconLink.setIconRightCSS("o_icon o_icon_start");
                iconLink.setUserObject(pStruct);
                Link titleLink = LinkFactory.createCustomLink("arte_t_" + key, LINK_CMD_OPEN_ARTEFACT, title, Link.NONTRANSLATED, vC, this);
                titleLink.setUserObject(pStruct);
                TOCElement actualTOCEl = new TOCElement(level, "artefact", titleLink, iconLink, null, null);
                tocList.add(actualTOCEl);
            }
        }
    }
    List<PortfolioStructure> childs = ePFMgr.loadStructureChildren(pStruct);
    if (childs != null && childs.size() != 0) {
        for (PortfolioStructure portfolioStructure : childs) {
            String type = "";
            if (portfolioStructure instanceof EPPage) {
                type = CONST_FOR_VC_STYLE_PAGE;
            } else {
                // a structure element
                type = CONST_FOR_VC_STYLE_STRUCT;
            }
            String key = String.valueOf(portfolioStructure.getKey());
            String title = StringHelper.escapeHtml(portfolioStructure.getTitle());
            Link iconLink = LinkFactory.createCustomLink("portstruct" + key, LINK_CMD_OPEN_STRUCT, "", Link.NONTRANSLATED, vC, this);
            iconLink.setIconRightCSS("o_icon o_icon_start");
            iconLink.setUserObject(portfolioStructure);
            Link titleLink = LinkFactory.createCustomLink("portstruct_t_" + key, LINK_CMD_OPEN_STRUCT, title, Link.NONTRANSLATED, vC, this);
            titleLink.setUserObject(portfolioStructure);
            Link commentLink = null;
            if (portfolioStructure instanceof EPPage && secCallback.canCommentAndRate()) {
                UserCommentsCount comments = getUserCommentsCount(portfolioStructure);
                String count = comments == null ? "0" : comments.getCount().toString();
                String label = translate("commentLink", new String[] { count });
                commentLink = LinkFactory.createCustomLink("commentLink" + key, LINK_CMD_OPEN_COMMENTS, label, Link.NONTRANSLATED, vC, this);
                commentLink.setIconLeftCSS("o_icon o_icon_comments");
                commentLink.setUserObject(portfolioStructure);
            }
            // prefetch children to keep reference on them
            List<TOCElement> tocChildList = new ArrayList<TOCElement>();
            buildTOCModel(portfolioStructure, tocChildList, level);
            TOCElement actualTOCEl = new TOCElement(level, type, titleLink, iconLink, commentLink, tocChildList);
            tocList.add(actualTOCEl);
            if (tocChildList.size() != 0) {
                tocList.addAll(tocChildList);
            }
        }
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) Link(org.olat.core.gui.components.link.Link) UserCommentsCount(org.olat.core.commons.services.commentAndRating.model.UserCommentsCount)

Example 85 with Link

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

the class DropdownItem method addElement.

public void addElement(FormLink link) {
    items.add(link);
    Link linkCmp = link.getComponent();
    linkCmp.setDomReplacementWrapperRequired(false);
    dropdown.addComponent(linkCmp);
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Link(org.olat.core.gui.components.link.Link)

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