use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class SendMailController method doUploadAttachement.
private void doUploadAttachement() {
if (attachementTempDir == null) {
attachementTempDir = FileUtils.createTempDir("attachements", null, null);
}
long size = attachmentEl.getUploadSize();
String filename = attachmentEl.getUploadFileName();
if (size + attachmentSize > (contactAttachmentMaxSizeInMb * 1024 * 1024)) {
showWarning("contact.attachment,maxsize", Integer.toString(contactAttachmentMaxSizeInMb));
attachmentEl.reset();
} else {
File attachment = attachmentEl.moveUploadFileTo(attachementTempDir);
attachmentEl.reset();
if (attachment == null) {
logError("Could not move contact-form attachment to " + attachementTempDir.getAbsolutePath(), null);
setTranslator(Util.createPackageTranslator(FileUploadController.class, getLocale(), getTranslator()));
showError("FileMoveCopyFailed", "");
} else {
attachmentSize += size;
FormLink removeFile = uifactory.addFormLink("delete_" + (++counter), "delete", "delete", null, uploadCont, Link.LINK);
removeFile.setIconLeftCSS("o_icon o_icon-fw o_icon_delete");
String css = CSSHelper.createFiletypeIconCssClassFor(filename);
Attachment wrapper = new Attachment(attachment, attachment.getName(), css, removeFile);
removeFile.setUserObject(wrapper);
attachments.add(wrapper);
uploadCont.setVisible(true);
}
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class SendMailController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == attachmentEl) {
doUploadAttachement();
}
if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("delete".equals(cmd)) {
Attachment attachment = (Attachment) link.getUserObject();
doDeleteAttachment(attachment);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class AuthorDeletedListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (restoreButton == source) {
List<AuthoringEntryRow> rows = getMultiSelectedRows();
if (!rows.isEmpty()) {
doRestore(ureq, rows);
} else {
showWarning("bulk.update.nothing.selected");
}
} else if (deletePermanentlyButton == source) {
List<AuthoringEntryRow> rows = getMultiSelectedRows();
if (!rows.isEmpty()) {
doDeletePermanently(ureq, rows);
} else {
showWarning("bulk.update.nothing.selected");
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("tools".equals(cmd)) {
AuthoringEntryRow row = (AuthoringEntryRow) link.getUserObject();
doOpenTools(ureq, row, link);
// override the event
return;
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class FeedbackFormController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("fieldset.legend.feedback");
setFormContextHelp("Test and Questionnaire Editor in Detail#details_testeditor_feedback");
FormLayoutContainer switchLayout = FormLayoutContainer.createDefaultFormLayout("switchLayout", getTranslator());
overallFeedbackLayout = FormLayoutContainer.createDefaultFormLayout("overallFeedbackLayout", getTranslator());
responseLevelHintsLayout = FormLayoutContainer.createCustomFormLayout("responseLevelHintsLayout", getTranslator(), Util.getPackageVelocityRoot(this.getClass()) + "/response_level_feedback.html");
// add the layouts to the custom layout
formLayout.add(switchLayout);
formLayout.add(overallFeedbackLayout);
formLayout.add(responseLevelHintsLayout);
String[] yesNoKeys, yesNoValues;
yesNoKeys = new String[] { YES, NO };
yesNoValues = new String[] { translate(YES), translate(NO) };
feedbackSwitch = uifactory.addRadiosHorizontal("feedbackswitch", switchLayout, yesNoKeys, yesNoValues);
feedbackSwitch.addActionListener(FormEvent.ONCLICK);
if (control.isFeedback()) {
feedbackSwitch.select(yesNoKeys[0], true);
} else {
// defaults to 'not showing feedback'
feedbackSwitch.select(yesNoKeys[1], true);
}
responseLevelHintsLayout.contextPut("mediaBaseUrl", mediaBaseUrl);
masteryMat = QTIEditHelper.getFeedbackMasteryMaterial(item);
masteryMat = masteryMat == null ? new Material() : masteryMat;
failureMat = QTIEditHelper.getFeedbackFailMaterial(item);
failureMat = failureMat == null ? new Material() : failureMat;
VFSContainer baseContainer = qtiPackage.getBaseDir();
// Mastery Layout
FormLayoutContainer masteryEditLayout = FormLayoutContainer.createCustomFormLayout("masteryEditLayout", getTranslator(), Util.getPackageVelocityRoot(this.getClass()) + "/rich_text_and_edit_link.html");
masteryEditLayout.setLabel("item_feedback_mastery", null);
overallFeedbackLayout.add(masteryEditLayout);
RichTextElement masteryFeedback = uifactory.addRichTextElementForStringData("richTextElement", "item_feedback_mastery", masteryMat.renderAsHtml(mediaBaseUrl), 4, -1, true, baseContainer, null, masteryEditLayout, ureq.getUserSession(), getWindowControl());
masteryFeedback.getEditorConfiguration().setFigCaption(false);
FormLink editLink = uifactory.addFormLink("editLink", masteryEditLayout, Link.NONTRANSLATED + Link.LINK_CUSTOM_CSS);
editLink.getComponent().setCustomDisplayText(" ");
editLink.getComponent().setIconLeftCSS("o_icon o_icon_edit o_icon-lg qti_edit_link");
registerFeedbackElement(masteryMat, masteryFeedback, editLink);
// One Failure Layout
FormLayoutContainer failureEditLayout = FormLayoutContainer.createCustomFormLayout("failureEditLayout", getTranslator(), Util.getPackageVelocityRoot(this.getClass()) + "/rich_text_and_edit_link.html");
failureEditLayout.setLabel("item_feedback_fail", null);
overallFeedbackLayout.add(failureEditLayout);
RichTextElement failureFeedback = uifactory.addRichTextElementForStringData("richTextElement", "item_feedback_fail", failureMat.renderAsHtml(mediaBaseUrl), 4, -1, true, baseContainer, null, failureEditLayout, ureq.getUserSession(), getWindowControl());
failureFeedback.getEditorConfiguration().setFigCaption(false);
failureFeedback.setLabel("item_feedback_fail", null);
FormLink failureLink = uifactory.addFormLink("editLink", failureEditLayout, Link.NONTRANSLATED + Link.LINK_CUSTOM_CSS);
failureLink.getComponent().setCustomDisplayText("");
failureLink.getComponent().setIconLeftCSS("o_icon o_icon_edit o_icon-lg");
registerFeedbackElement(failureMat, failureFeedback, failureLink);
// Feedback for each response when single or multiple choice question
List<Material> responses = new ArrayList<Material>();
boolean hasResponseLevelHints = false;
if (item.getQuestion().getType() <= Question.TYPE_MC) {
int i = 1;
for (Object obj : item.getQuestion().getResponses()) {
ChoiceResponse response = (ChoiceResponse) obj;
// response-level feedback
Material responseFeedbackMat = QTIEditHelper.getFeedbackOlatRespMaterial(item, response.getIdent());
responseFeedbackMat = responseFeedbackMat == null ? new Material() : responseFeedbackMat;
identities.put(responseFeedbackMat, response.getIdent());
RichTextElement responseHintText = uifactory.addRichTextElementForStringData("feedback_" + i, null, responseFeedbackMat.renderAsHtml(mediaBaseUrl), 4, -1, true, baseContainer, null, responseLevelHintsLayout, ureq.getUserSession(), getWindowControl());
responseHintText.getEditorConfiguration().setFigCaption(false);
FormLink link = uifactory.addFormLink("link_" + i, responseLevelHintsLayout, Link.NONTRANSLATED + Link.LINK_CUSTOM_CSS);
link.getComponent().setCustomDisplayText(" ");
link.getComponent().setIconLeftCSS("o_icon o_icon_edit o_icon-lg");
registerFeedbackElement(responseFeedbackMat, responseHintText, link);
// get response for displaying
Material responseMat = response.getContent();
responses.add(responseMat);
i++;
}
// If 'i' is strictly greater than the initial value, there's at least one
// response.
hasResponseLevelHints = i > 1;
}
flc.contextPut("hasResponseLevelHints", hasResponseLevelHints);
responseLevelHintsLayout.contextPut("responses", responses);
showHideFeedbackFields();
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class RubricEditorController method forgeSliderRow.
private SliderRow forgeSliderRow(Slider slider) {
String startLabel = slider.getStartLabel();
TextElement startLabelEl = uifactory.addTextElement("start.label." + count.incrementAndGet(), "start.label", 256, startLabel, flc);
startLabelEl.setDomReplacementWrapperRequired(false);
String endLabel = slider.getEndLabel();
TextElement endLabelEl = uifactory.addTextElement("end.label." + count.incrementAndGet(), "end.label", 256, endLabel, flc);
endLabelEl.setDomReplacementWrapperRequired(false);
SliderRow row = new SliderRow(slider, startLabelEl, endLabelEl);
if (!restrictedEdit) {
FormLink deleteButton = uifactory.addFormLink("del." + count.incrementAndGet(), "delete_slider", "", null, flc, Link.BUTTON | Link.NONTRANSLATED);
deleteButton.setDomReplacementWrapperRequired(false);
deleteButton.setIconLeftCSS("o_icon o_icon-lg o_icon_delete_item");
deleteButton.setUserObject(row);
row.setDeleteButton(deleteButton);
flc.contextPut("deleteButtons", Boolean.TRUE);
}
return row;
}
Aggregations