use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class BinderPageListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof FlexiTableRenderEvent) {
FlexiTableRenderEvent re = (FlexiTableRenderEvent) event;
if (re.getRendererType() == FlexiTableRendererType.custom) {
tableEl.sort(new SortKey(null, false));
}
} else if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
if ("select-page".equals(cmd)) {
PortfolioElementRow row = model.getObject(se.getIndex());
if (row.isPendingAssignment()) {
doStartAssignment(ureq, row);
} else {
doOpenRow(ureq, row, false);
}
}
}
} else if (previousSectionLink == source) {
Section previousSection = (Section) previousSectionLink.getUserObject();
doFilterSection(previousSection);
} else if (nextSectionLink == source) {
Section nextSection = (Section) nextSectionLink.getUserObject();
doFilterSection(nextSection);
} else if (showAllSectionsLink == source) {
doShowAll();
} else if (newSectionButton == source) {
doCreateNewSection(ureq);
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("new.entry".equals(cmd)) {
PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
doCreateNewPage(ureq, row.getSection());
} else if ("new.assignment".equals(cmd)) {
PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
doCreateNewAssignment(ureq, row.getSection());
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class GuiDemoFlexiFormAdvancedController method addDateLinkAndFileItems.
/**
* Adds a date chooser, a link and a file chooser to the given form.
*
* @param formItemsFactory
* @param form
*/
private void addDateLinkAndFileItems(FormItemContainer form) {
// Date picker
uifactory.addDateChooser("dateChooser", "guidemo.form.date", null, form);
// Link
final FormLink link = uifactory.addFormLink("link", form);
link.setLabel("guidemo.form.link", null);
// File Chooser
// There is a multipart parameter problem with that element.
uifactory.addFileElement(getWindowControl(), "file", "advanced_form.file", form);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class OAuthAuthenticationController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink) {
FormLink button = (FormLink) source;
if ("login".equals(button.getCmd())) {
OAuthSPI provider = (OAuthSPI) source.getUserObject();
redirect(ureq, provider);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class ContactForm method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == attachmentEl) {
String filename = attachmentEl.getUploadFileName();
if (attachementTempDir == null) {
attachementTempDir = FileUtils.createTempDir("attachements", null, null);
}
long size = attachmentEl.getUploadSize();
if (size + attachmentSize > (contactAttachmentMaxSizeInMb * 1024 * 1024)) {
showWarning(NLS_CONTACT_ATTACHMENT_EXPL, Integer.toString(contactAttachmentMaxSizeInMb));
attachmentEl.reset();
} else {
File attachment = attachmentEl.moveUploadFileTo(attachementTempDir);
// OO-48 somehow file-move can fail, check for it, display error-dialog if it failed
if (attachment == null) {
attachmentEl.reset();
logError("Could not move contact-form attachment to " + attachementTempDir.getAbsolutePath(), null);
setTranslator(Util.createPackageTranslator(FileUploadController.class, getLocale(), getTranslator()));
showError("FileMoveCopyFailed", "");
return;
}
attachmentEl.reset();
attachmentSize += size;
FormLink removeFile = uifactory.addFormLink(attachment.getName(), "delete", null, uploadCont, Link.BUTTON_XSMALL);
removeFile.setIconLeftCSS("o_icon o_icon-fw o_icon_delete");
removeFile.setUserObject(attachment);
attachmentLinks.add(removeFile);
// pretty labels
uploadCont.setLabel(NLS_CONTACT_ATTACHMENT, null);
attachmentNames.put(attachment.getName(), filename + " <span class='text-muted'>(" + Formatter.formatBytes(size) + ")</span>");
attachmentCss.put(attachment.getName(), CSSHelper.createFiletypeIconCssClassFor(filename));
uploadCont.contextPut("attachments", attachmentLinks);
uploadCont.contextPut("attachmentNames", attachmentNames);
uploadCont.contextPut("attachmentCss", attachmentCss);
attachmentEl.setLabel(null, null);
}
} else if (attachmentLinks.contains(source)) {
File uploadedFile = (File) source.getUserObject();
if (uploadedFile != null && uploadedFile.exists()) {
attachmentSize -= uploadedFile.length();
uploadedFile.delete();
}
attachmentLinks.remove(source);
uploadCont.remove(source);
if (attachmentLinks.isEmpty()) {
uploadCont.setLabel(null, null);
attachmentEl.setLabel(NLS_CONTACT_ATTACHMENT, null);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class ParticipantLectureBlocksController method loadModel.
private void loadModel() {
Date now = new Date();
Formatter formatter = Formatter.getInstance(getLocale());
String separator = translate("user.fullname.separator");
List<LectureBlockAndRollCall> rollCalls = lectureService.getParticipantLectureBlocks(entry, assessedIdentity, separator);
List<LectureBlockAuditLog> sendAppealLogs = lectureService.getAuditLog(entry, assessedIdentity, LectureBlockAuditLog.Action.sendAppeal);
Map<Long, Date> appealDates = new HashMap<>();
for (LectureBlockAuditLog sendAppealLog : sendAppealLogs) {
if (sendAppealLog.getRollCallKey() != null) {
appealDates.put(sendAppealLog.getRollCallKey(), sendAppealLog.getCreationDate());
}
}
List<LectureBlockAndRollCallRow> rows = new ArrayList<>(rollCalls.size());
for (LectureBlockAndRollCall rollCall : rollCalls) {
LectureBlockAndRollCallRow row = new LectureBlockAndRollCallRow(rollCall);
if (appealEnabled && !LectureBlockStatus.cancelled.equals(row.getRow().getStatus()) && rollCall.isCompulsory()) {
int lectures = row.getRow().getEffectiveLecturesNumber();
if (lectures <= 0) {
lectures = row.getRow().getPlannedLecturesNumber();
}
int attended = row.getRow().getLecturesAttendedNumber();
if (attended < lectures) {
Date date = row.getRow().getDate();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal = CalendarUtils.getEndOfDay(cal);
cal.add(Calendar.DATE, appealOffset);
Date beginAppeal = CalendarUtils.removeTime(cal.getTime());
cal.add(Calendar.DATE, appealPeriod);
Date endAppeal = CalendarUtils.getEndOfDay(cal).getTime();
Date sendAppealDate = null;
if (row.getRow().getRollCallRef() != null) {
sendAppealDate = appealDates.get(row.getRow().getRollCallRef().getKey());
}
FormLink appealLink = null;
if (sendAppealDate != null) {
String appealFrom = translate("appeal.sent", new String[] { formatter.formatDate(sendAppealDate) });
appealLink = uifactory.addFormLink("appeal_" + count++, "appealsend", appealFrom, null, flc, Link.LINK | Link.NONTRANSLATED);
appealLink.setTitle(translate("appeal.sent.tooltip", new String[] { formatter.formatDate(sendAppealDate), formatter.formatDate(beginAppeal), formatter.formatDate(endAppeal) }));
appealLink.setEnabled(false);
appealLink.setDomReplacementWrapperRequired(false);
} else if (now.compareTo(beginAppeal) >= 0 && now.compareTo(endAppeal) <= 0) {
appealLink = uifactory.addFormLink("appeal_" + count++, "appeal", translate("appeal"), null, flc, Link.LINK | Link.NONTRANSLATED);
appealLink.setTitle(translate("appeal.tooltip", new String[] { formatter.formatDate(beginAppeal), formatter.formatDate(endAppeal) }));
appealLink.setUserObject(row);
// appeal
} else if (now.compareTo(endAppeal) > 0) {
// appeal closed
appealLink = uifactory.addFormLink("appeal_" + count++, "aclosed", "appeal.closed", null, flc, Link.LINK);
appealLink.setEnabled(false);
appealLink.setDomReplacementWrapperRequired(false);
} else if (now.compareTo(date) >= 0) {
// appeal at
String appealFrom = translate("appeal.from", new String[] { formatter.formatDate(beginAppeal) });
appealLink = uifactory.addFormLink("appeal_" + count++, "appealat", appealFrom, null, flc, Link.LINK | Link.NONTRANSLATED);
appealLink.setEnabled(false);
appealLink.setDomReplacementWrapperRequired(false);
}
row.setAppealButton(appealLink);
}
}
rows.add(row);
}
tableModel.setObjects(rows);
tableEl.reset(true, true, true);
}
Aggregations