Search in sources :

Example 16 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class MembersAvatarDisplayRunController method createMemberLinks.

protected List<Member> createMemberLinks(List<Identity> identities, Set<Long> duplicateCatcher, FormLayoutContainer formLayout, boolean withEmail) {
    if (duplicateCatcher == null) {
        duplicateCatcher = new HashSet<>();
    }
    List<Member> members = new ArrayList<>(identities.size());
    for (Identity identity : identities) {
        if (duplicateCatcher.contains(identity.getKey())) {
            continue;
        }
        duplicateCatcher.add(identity.getKey());
        Member member = createMember(identity);
        members.add(member);
        String guiId = Integer.toString(++count);
        String fullname = StringHelper.escapeHtml(member.getFullName());
        FormLink idLink = uifactory.addFormLink("id_".concat(guiId), "id", fullname, null, formLayout, Link.NONTRANSLATED);
        idLink.setUserObject(member);
        formLayout.add(idLink.getComponent().getComponentName(), idLink);
        member.setIdLink(idLink);
        if (withEmail) {
            FormLink emailLink = uifactory.addFormLink("mail_".concat(guiId), "mail", "", null, formLayout, Link.NONTRANSLATED);
            emailLink.setUserObject(member);
            emailLink.setIconLeftCSS("o_icon o_icon_mail o_icon-lg");
            emailLink.setElementCssClass("o_mail");
            formLayout.add(emailLink.getComponent().getComponentName(), emailLink);
            member.setEmailLink(emailLink);
        }
        if (chatEnabled && editable) {
            FormLink chatLink = uifactory.addFormLink("chat_".concat(guiId), "chat", "", null, formLayout, Link.NONTRANSLATED);
            chatLink.setUserObject(member);
            chatLink.setElementCssClass("o_chat");
            formLayout.add(chatLink.getComponent().getComponentName(), chatLink);
            member.setChatLink(chatLink);
        }
    }
    if (chatEnabled && editable) {
        Long me = getIdentity().getKey();
        if (imModule.isOnlineStatusEnabled()) {
            Map<Long, Member> loadStatus = new HashMap<>();
            for (Member member : members) {
                if (member.getKey().equals(me)) {
                    member.getChatLink().setVisible(false);
                } else if (sessionManager.isOnline(member.getKey())) {
                    loadStatus.put(member.getKey(), member);
                } else {
                    member.getChatLink().setIconLeftCSS("o_icon o_icon_status_unavailable");
                }
            }
            if (loadStatus.size() > 0) {
                List<Long> statusToLoadList = new ArrayList<>(loadStatus.keySet());
                Map<Long, String> statusMap = imService.getBuddyStatus(statusToLoadList);
                for (Long toLoad : statusToLoadList) {
                    String status = statusMap.get(toLoad);
                    Member member = loadStatus.get(toLoad);
                    if (status == null || Presence.available.name().equals(status)) {
                        member.getChatLink().setIconLeftCSS("o_icon o_icon_status_available");
                    } else if (Presence.dnd.name().equals(status)) {
                        member.getChatLink().setIconLeftCSS("o_icon o_icon_status_dnd");
                    } else {
                        member.getChatLink().setIconLeftCSS("o_icon o_icon_status_unavailable");
                    }
                }
            }
        } else {
            for (Member member : members) {
                if (member.getKey().equals(me)) {
                    member.getChatLink().setVisible(false);
                } else {
                    member.getChatLink().setIconLeftCSS("o_icon o_icon_status_chat");
                }
            }
        }
    }
    return members;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Member(org.olat.course.nodes.members.Member)

Example 17 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class GTAAvailableTaskController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            AvailableTask row = taskModel.getObject(se.getIndex());
            if ("select".equals(se.getCommand())) {
                doSelect(ureq, row);
            }
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        if ("description".equals(link.getCmd())) {
            doDescription(ureq, (AvailableTask) link.getUserObject());
        } else if ("preview-html".equals(link.getCmd())) {
            String filename = (String) link.getUserObject();
            doPreview(ureq, filename);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 18 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class CourseReminderListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addButton == source) {
        doAddReminder(ureq);
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("tools".equals(cmd)) {
            ReminderRow row = (ReminderRow) link.getUserObject();
            doOpenTools(ureq, row, link);
        }
    } else if (source == tableEl) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            ReminderRow row = tableModel.getObject(se.getIndex());
            if ("edit".equals(cmd)) {
                doEdit(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : ReminderRow(org.olat.course.reminder.model.ReminderRow) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 19 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class CourseReminderListController method updateModel.

private void updateModel() {
    List<ReminderInfos> reminders = reminderManager.getReminderInfos(repositoryEntry);
    List<ReminderRow> rows = new ArrayList<>(reminders.size());
    for (ReminderInfos reminder : reminders) {
        FormLink toolsLink = uifactory.addFormLink("tools_" + counter.incrementAndGet(), "tools", "", null, null, Link.NONTRANSLATED);
        toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
        toolsLink.setElementCssClass("o_sel_course_reminder_tools");
        toolsLink.setTitle(translate("tools"));
        ReminderRow row = new ReminderRow(reminder, toolsLink);
        toolsLink.setUserObject(row);
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset();
    tableEl.setVisible(rows.size() > 0);
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) ReminderRow(org.olat.course.reminder.model.ReminderRow) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 20 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class AbstractPageListController method forgePageRow.

protected PortfolioElementRow forgePageRow(UserRequest ureq, Page page, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap, Map<Long, Long> numberOfCommentsMap, boolean selectElement) {
    Section section = page.getSection();
    PortfolioElementRow row = new PortfolioElementRow(page, assessmentSection, config.isAssessable());
    String openLinkId = "open_" + (++counter);
    FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
    openLink.setIconRightCSS("o_icon o_icon_start");
    openLink.setEnabled(selectElement);
    openLink.setPrimary(true);
    row.setOpenFormLink(openLink);
    openLink.setUserObject(row);
    addCategoriesToRow(row, categorizedElementMap);
    if (assignments != null) {
        for (Assignment assignment : assignments) {
            if (page.equals(assignment.getPage())) {
                row.setAssignment(assignment);
            }
        }
    }
    decorateImage(ureq, row, page);
    if (numberOfCommentsMap != null) {
        Long numOfComments = numberOfCommentsMap.get(page.getKey());
        if (numOfComments != null) {
            row.setNumOfComments(numOfComments.longValue());
        } else {
            row.setNumOfComments(0);
        }
    } else {
        row.setNumOfComments(0);
    }
    if (secCallback.canCloseSection(section)) {
        if (SectionStatus.isClosed(section)) {
            FormLink reopenLink = uifactory.addFormLink("ropens_" + (++counter), "reopen.section", "reopen.section", null, flc, Link.BUTTON_SMALL);
            reopenLink.setUserObject(row);
            row.setReopenSectionLink(reopenLink);
        } else {
            FormLink closeLink = uifactory.addFormLink("closes_" + (++counter), "close.section", "close.section", null, flc, Link.BUTTON_SMALL);
            closeLink.setUserObject(row);
            row.setCloseSectionLink(closeLink);
        }
    }
    if (portfolioV2Module.isEntriesCommentsEnabled() && secCallback.canComment(page)) {
        String title;
        String cssClass = "o_icon o_icon-fw o_icon_comments";
        if (row.getNumOfComments() == 1) {
            title = translate("comment.one");
        } else if (row.getNumOfComments() > 1) {
            title = translate("comment.several", new String[] { Long.toString(row.getNumOfComments()) });
        } else {
            title = translate("comment.zero");
            cssClass += "_none";
        }
        FormLink commentLink = uifactory.addFormLink("com_" + (++counter), "comment", title, null, flc, Link.LINK | Link.NONTRANSLATED);
        commentLink.setIconLeftCSS(cssClass);
        commentLink.setUserObject(row);
        row.setCommentFormLink(commentLink);
    }
    return row;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Aggregations

FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)376 ArrayList (java.util.ArrayList)108 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)64 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)36 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)34 List (java.util.List)30 FormItem (org.olat.core.gui.components.form.flexible.FormItem)28 HashMap (java.util.HashMap)26 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)24 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 Date (java.util.Date)18 Map (java.util.Map)18 Link (org.olat.core.gui.components.link.Link)18 Identity (org.olat.core.id.Identity)18 Component (org.olat.core.gui.components.Component)16 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)16 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)16 Controller (org.olat.core.gui.control.Controller)16 Event (org.olat.core.gui.control.Event)16