Search in sources :

Example 26 with Spacer

use of org.olat.core.gui.components.dropdown.Dropdown.Spacer in project openolat by klemens.

the class WikiMainController method updateWikiMenu.

private void updateWikiMenu(Wiki wiki) {
    Collection<String> links = wiki.getListOfAllPageNames();
    if (wikiMenuNode != null) {
        wikiMenuNode.removeAllChildren();
        for (String link : links) {
            String ident = "w" + Encoder.md5hash(link);
            GenericTreeNode menuItemNode = new GenericTreeNode(ident, link, link);
            wikiMenuNode.addChild(menuItemNode);
        }
    }
    wikiMenuDropdown.removeAllComponents();
    for (String link : links) {
        Link menuLink = LinkFactory.createToolLink(link, "select-page", link, this);
        wikiMenuDropdown.addComponent(menuLink);
    }
    if (editMenuButton != null) {
        wikiMenuDropdown.addComponent(new Spacer("wiki-spacer"));
        wikiMenuDropdown.addComponent(editMenuButton);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer) Link(org.olat.core.gui.components.link.Link)

Example 27 with Spacer

use of org.olat.core.gui.components.dropdown.Dropdown.Spacer in project openolat by klemens.

the class FeedRuntimeController method initSettingsTools.

@Override
protected void initSettingsTools(Dropdown settingsDropdown) {
    super.initSettingsTools(settingsDropdown);
    if (reSecurity.isEntryAdmin()) {
        if (quotaManager.hasQuotaEditRights(getIdentity())) {
            settingsDropdown.addComponent(new Spacer(""));
            quotaLink = LinkFactory.createToolLink("quota", translate("tab.quota.edit"), this, "o_sel_repo_quota");
            quotaLink.setIconLeftCSS("o_icon o_icon-fw o_icon_quota");
            settingsDropdown.addComponent(quotaLink);
        }
    }
}
Also used : Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer)

Example 28 with Spacer

use of org.olat.core.gui.components.dropdown.Dropdown.Spacer in project openolat by klemens.

the class RepositoryEntryRuntimeController method initEditionTools.

protected void initEditionTools(Dropdown settingsDropdown) {
    boolean copyManaged = RepositoryEntryManagedFlag.isManaged(re, RepositoryEntryManagedFlag.copy);
    boolean canCopy = (isAuthor || reSecurity.isEntryAdmin()) && (re.getCanCopy() || reSecurity.isEntryAdmin()) && !copyManaged;
    boolean canDownload = re.getCanDownload() && handler.supportsDownload();
    // disable download for courses if not author or owner
    if (re.getOlatResource().getResourceableTypeName().equals(CourseModule.getCourseTypeName()) && !(reSecurity.isEntryAdmin() || isAuthor)) {
        canDownload = false;
    }
    // always enable download for owners
    if (reSecurity.isEntryAdmin() && handler.supportsDownload()) {
        canDownload = true;
    }
    if (canCopy || canDownload) {
        if (settingsDropdown.size() > 0) {
            settingsDropdown.addComponent(new Spacer("copy-download"));
        }
        if (canCopy) {
            copyLink = LinkFactory.createToolLink("copy", translate("details.copy"), this, "o_icon o_icon-fw o_icon_copy");
            copyLink.setElementCssClass("o_sel_repo_copy");
            settingsDropdown.addComponent(copyLink);
        }
        if (canDownload) {
            downloadLink = LinkFactory.createToolLink("download", translate("details.download"), this, "o_icon o_icon-fw o_icon_download");
            downloadLink.setElementCssClass("o_sel_repo_download");
            settingsDropdown.addComponent(downloadLink);
        }
    }
}
Also used : Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer)

Example 29 with Spacer

use of org.olat.core.gui.components.dropdown.Dropdown.Spacer in project openolat by klemens.

the class DropdownRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    Dropdown dropdown = (Dropdown) source;
    sb.append("<div class='btn-group'>", dropdown.isEmbbeded());
    Iterable<Component> components = dropdown.getComponents();
    if (dropdown.isButton()) {
        sb.append("<button type='button' class='btn btn-default dropdown-toggle");
    } else {
        sb.append("<a href='#' class='dropdown-toggle");
    }
    if (StringHelper.containsNonWhitespace(dropdown.getElementCssClass())) {
        sb.append(" ").append(dropdown.getElementCssClass());
    }
    sb.append("' data-toggle='dropdown'>");
    if (StringHelper.containsNonWhitespace(dropdown.getIconCSS())) {
        sb.append("<i class='").append(dropdown.getIconCSS()).append("'>&nbsp;</i>");
    }
    String i18nKey = dropdown.getI18nKey();
    if (StringHelper.containsNonWhitespace(i18nKey)) {
        String label;
        if (dropdown.isTranslated()) {
            label = i18nKey;
        } else {
            label = dropdown.getTranslator().translate(dropdown.getI18nKey());
        }
        sb.append("<span>").append(label).append("</span>");
    }
    sb.append(" <i class='o_icon o_icon_caret'> </i>");
    if (dropdown.isButton()) {
        sb.append("</button>");
    } else {
        sb.append("</a>");
    }
    sb.append("<ul class='dropdown-menu");
    if (StringHelper.containsNonWhitespace(dropdown.getElementCssClass())) {
        sb.append(" ").append(dropdown.getElementCssClass());
    }
    if (dropdown.getOrientation() == DropdownOrientation.right) {
        sb.append(" dropdown-menu-right");
    }
    sb.append("' role='menu'>");
    boolean wantSpacer = false;
    for (Component component : components) {
        if (component instanceof Spacer) {
            wantSpacer = true;
        } else if (component.isVisible()) {
            if (wantSpacer) {
                sb.append("<li class='divider'></li>");
                wantSpacer = false;
            }
            if (component.isEnabled()) {
                sb.append("<li>");
            } else {
                sb.append("<li class='disabled'>");
            }
            renderer.render(component, sb, args);
            sb.append("</li>");
        }
    }
    sb.append("</ul>").append("</div>", dropdown.isEmbbeded());
}
Also used : Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer) Component(org.olat.core.gui.components.Component)

Example 30 with Spacer

use of org.olat.core.gui.components.dropdown.Dropdown.Spacer in project openolat by klemens.

the class CourseRuntimeController method initTools.

private void initTools(Dropdown tools, ICourse course, final UserCourseEnvironmentImpl uce) {
    // 1) administrative tools
    if (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) || hasCourseRight(CourseRights.RIGHT_MEMBERMANAGEMENT) || hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || hasCourseRight(CourseRights.RIGHT_ARCHIVING) || hasCourseRight(CourseRights.RIGHT_STATISTICS) || hasCourseRight(CourseRights.RIGHT_DB) || hasCourseRight(CourseRights.RIGHT_ASSESSMENT) || hasCourseRight(CourseRights.RIGHT_ASSESSMENT_MODE)) {
        tools.setI18nKey("header.tools");
        tools.setElementCssClass("o_sel_course_tools");
        if (uce != null && (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR))) {
            boolean managed = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.editcontent);
            boolean readOnly = uce.isCourseReadOnly();
            editLink = LinkFactory.createToolLink("edit.cmd", translate("command.openeditor"), this, "o_icon_courseeditor");
            editLink.setElementCssClass("o_sel_course_editor");
            editLink.setEnabled(!corrupted && !managed);
            editLink.setVisible(!readOnly);
            tools.addComponent(editLink);
            folderLink = LinkFactory.createToolLink("cfd", translate("command.coursefolder"), this, "o_icon_coursefolder");
            folderLink.setElementCssClass("o_sel_course_folder");
            tools.addComponent(folderLink);
            tools.addComponent(new Spacer(""));
        }
        if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || hasCourseRight(CourseRights.RIGHT_MEMBERMANAGEMENT)) {
            membersLink = LinkFactory.createToolLink("unifiedusermngt", translate("command.opensimplegroupmngt"), this, "o_icon_membersmanagement");
            membersLink.setElementCssClass("o_sel_course_members");
            tools.addComponent(membersLink);
        }
        if (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach() || hasCourseRight(CourseRights.RIGHT_ASSESSMENT)) {
            assessmentLink = LinkFactory.createToolLink("assessment", translate("command.openassessment"), this, "o_icon_assessment_tool");
            assessmentLink.setElementCssClass("o_sel_course_assessment_tool");
            tools.addComponent(assessmentLink);
        }
        if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_ARCHIVING)) {
            archiverLink = LinkFactory.createToolLink("archiver", translate("command.openarchiver"), this, "o_icon_archive_tool");
            tools.addComponent(archiverLink);
        }
        tools.addComponent(new Spacer(""));
        if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_STATISTICS)) {
            courseStatisticLink = LinkFactory.createToolLink("statistic", translate("command.openstatistic"), this, "o_icon_statistics_tool");
            tools.addComponent(courseStatisticLink);
        }
        if (uce != null && (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach() || hasCourseRight(CourseRights.RIGHT_STATISTICS))) {
            final AtomicInteger testNodes = new AtomicInteger();
            final AtomicInteger surveyNodes = new AtomicInteger();
            new TreeVisitor(new Visitor() {

                @Override
                public void visit(INode node) {
                    if (((CourseNode) node).isStatisticNodeResultAvailable(uce, QTIType.test, QTIType.onyx)) {
                        testNodes.incrementAndGet();
                    } else if (((CourseNode) node).isStatisticNodeResultAvailable(uce, QTIType.survey)) {
                        surveyNodes.incrementAndGet();
                    }
                }
            }, course.getRunStructure().getRootNode(), true).visitAll();
            if (testNodes.intValue() > 0) {
                testStatisticLink = LinkFactory.createToolLink("qtistatistic", translate("command.openteststatistic"), this, "o_icon_statistics_tool");
                tools.addComponent(testStatisticLink);
            }
            if (surveyNodes.intValue() > 0) {
                surveyStatisticLink = LinkFactory.createToolLink("qtistatistic", translate("command.opensurveystatistic"), this, "o_icon_statistics_tool");
                tools.addComponent(surveyStatisticLink);
            }
        }
        tools.addComponent(new Spacer(""));
        if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR)) {
            areaLink = LinkFactory.createToolLink("careas", translate("command.courseareas"), this, "o_icon_courseareas");
            areaLink.setElementCssClass("o_sel_course_areas");
            tools.addComponent(areaLink);
        }
        if (courseDBManager.isEnabled() && (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_DB))) {
            dbLink = LinkFactory.createToolLink("customDb", translate("command.opendb"), this, "o_icon_coursedb");
            tools.addComponent(dbLink);
        }
        ordersLink = LinkFactory.createToolLink("bookings", translate("details.orders"), this, "o_sel_repo_booking");
        ordersLink.setIconLeftCSS("o_icon o_icon-fw o_icon_booking");
        ordersLink.setElementCssClass("o_sel_course_ac_tool");
        boolean booking = acService.isResourceAccessControled(getRepositoryEntry().getOlatResource(), null);
        ordersLink.setVisible(!corrupted && booking);
        tools.addComponent(ordersLink);
    }
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode)

Aggregations

Spacer (org.olat.core.gui.components.dropdown.Dropdown.Spacer)32 Dropdown (org.olat.core.gui.components.dropdown.Dropdown)6 Link (org.olat.core.gui.components.link.Link)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Component (org.olat.core.gui.components.Component)2 LinkPopupSettings (org.olat.core.gui.components.link.LinkPopupSettings)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 INode (org.olat.core.util.nodes.INode)2 TreeVisitor (org.olat.core.util.tree.TreeVisitor)2 Visitor (org.olat.core.util.tree.Visitor)2 CourseConfig (org.olat.course.config.CourseConfig)2 CourseNode (org.olat.course.nodes.CourseNode)2 ENCourseNode (org.olat.course.nodes.ENCourseNode)2 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)2 BusinessGroup (org.olat.group.BusinessGroup)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)2 OrderedRepositoryHandler (org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler)2