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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations