use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class MessageEditController method createOrUpdateAttachmentListLayout.
// adds or updates the list of already existing attachments with a delete
// button for each
private void createOrUpdateAttachmentListLayout(FormItemContainer formLayout) {
FormItem attachLayout = formLayout.getFormComponent("attachLayout");
List<VFSItem> attachments = new ArrayList<VFSItem>();
// add already existing attachments:
if (message.getKey() != null) {
VFSContainer msgContainer = fm.getMessageContainer(message.getForum().getKey(), message.getKey());
attachments.addAll(msgContainer.getItems(exclFilter));
}
// add files from TempFolder
attachments.addAll(getTempFolderFileList());
Collections.sort(attachments, new Comparator<VFSItem>() {
final Collator c = Collator.getInstance(getLocale());
public int compare(final VFSItem o1, final VFSItem o2) {
return c.compare((o1).getName(), (o2).getName());
}
});
FormLayoutContainer tmpLayout;
if (attachLayout == null) {
String editPage = Util.getPackageVelocityRoot(this.getClass()) + "/attachments-editview.html";
tmpLayout = FormLayoutContainer.createCustomFormLayout("attachLayout", getTranslator(), editPage);
formLayout.add(tmpLayout);
} else {
tmpLayout = (FormLayoutContainer) attachLayout;
}
tmpLayout.contextPut("attachments", attachments);
// add delete links for each attachment if user is allowed to see them
int attNr = 1;
for (VFSItem tmpFile : attachments) {
FormLink tmpLink = uifactory.addFormLink(CMD_DELETE_ATTACHMENT + attNr, tmpLayout, Link.BUTTON_XSMALL);
if (!(foCallback.mayEditMessageAsModerator() || ((userIsMsgCreator) && (msgHasChildren == false)))) {
tmpLink.setEnabled(false);
tmpLink.setVisible(false);
}
tmpLink.setUserObject(tmpFile);
tmpLink.setI18nKey("attachments.remove.string");
attNr++;
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class MediaCenterController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
MediaRow row = model.getObject(se.getIndex());
if ("select".equals(cmd)) {
if (select) {
doSelect(ureq, row.getKey());
} else {
Activateable2 activateable = doOpenMedia(ureq, row.getKey());
if (activateable != null) {
activateable.activate(ureq, null, null);
}
}
}
} else if (event instanceof FlexiTableSearchEvent) {
loadModel();
}
} else if (newMediaCallout == source) {
doOpenNewMediaCallout(ureq, newMediaCallout);
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("select".equals(cmd)) {
MediaRow row = (MediaRow) link.getUserObject();
if (select) {
doSelect(ureq, row.getKey());
} else {
Activateable2 activateable = doOpenMedia(ureq, row.getKey());
if (activateable != null) {
activateable.activate(ureq, null, null);
}
}
} else if ("tag".equals(cmd)) {
doToggleCategory(link);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class MediaDetailsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("title", StringHelper.escapeHtml(media.getTitle()));
layoutCont.contextPut("description", StringHelper.xssScan(media.getDescription()));
layoutCont.contextPut("iconCssClass", handler.getIconCssClass(media));
mediaCtrl = handler.getMediaController(ureq, getWindowControl(), media, new StandardMediaRenderingHints());
if (mediaCtrl != null) {
listenTo(mediaCtrl);
layoutCont.put("media", mediaCtrl.getInitialComponent());
}
String metaPage = velocity_root + "/media_details_metadata.html";
FormLayoutContainer metaCont = FormLayoutContainer.createCustomFormLayout("meta", getTranslator(), metaPage);
layoutCont.add("meta", metaCont);
metaCont.setRootForm(mainForm);
metaCont.contextPut("media", media);
String author = userManager.getUserDisplayName(media.getAuthor());
metaCont.contextPut("author", author);
if (media.getCollectionDate() != null) {
String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
metaCont.contextPut("collectionDate", collectionDate);
}
if (media.getBusinessPath() != null) {
gotoOriginalLink = LinkFactory.createLink("goto.original", metaCont.getFormItemComponent(), this);
}
if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
metaCont.contextPut("metadata", metadata);
}
List<Category> categories = portfolioService.getCategories(media);
if (categories != null && categories.size() > 0) {
Map<String, String> categoriesMap = categories.stream().collect(Collectors.toMap(c -> c.getName(), c -> c.getName()));
TextBoxListElement categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categoriesMap, metaCont, getTranslator());
categoriesEl.setHelpText(translate("categories.hint"));
categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
categoriesEl.setEnabled(false);
}
List<FormLink> binderLinks = new ArrayList<>(usedInList.size());
Set<Long> binderUniqueKeys = new HashSet<>();
for (BinderPageUsage binder : usedInList) {
if (binderUniqueKeys.contains(binder.getBinderKey()))
continue;
FormLink link;
if (binder.getBinderKey() == null) {
link = uifactory.addFormLink("binder_" + (++counter), "page", binder.getPageTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
binderUniqueKeys.add(binder.getPageKey());
} else {
link = uifactory.addFormLink("binder_" + (++counter), "binder", binder.getBinderTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
binderUniqueKeys.add(binder.getBinderKey());
}
link.setUserObject(binder);
binderLinks.add(link);
}
metaCont.contextPut("binderLinks", binderLinks);
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class TitleEditorController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
List<String> headingFormatLinkNames = new ArrayList<>();
for (int i = 1; i <= 6; i++) {
FormLink headingFormatLink = uifactory.addFormLink("h" + i, "h" + i, "h" + i, null, formLayout, Link.LINK);
headingFormatLinkNames.add(headingFormatLink.getComponent().getComponentName());
}
flc.getFormItemComponent().contextPut("headingFormatLinkNames", headingFormatLinkNames);
String cmpId = "title-" + CodeHelper.getRAMUniqueID() + "h";
String content = titlePart.getContent();
titleItem = uifactory.addRichTextElementForStringDataCompact(cmpId, null, content, 8, 80, null, formLayout, ureq.getUserSession(), getWindowControl());
titleItem.getEditorConfiguration().setSendOnBlur(true);
titleItem.getEditorConfiguration().disableMenuAndMenuBar();
staticItem = uifactory.addStaticTextElement(cmpId + "_static", contentOrExample(content), formLayout);
flc.getFormItemComponent().contextPut("cmpId", cmpId);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class AbstractItemListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == itemsTable) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("rSelect".equals(se.getCommand())) {
ItemRow row = model.getObject(se.getIndex());
if (row != null) {
doClick(ureq, row);
}
} else if ("select-item".equals(se.getCommand())) {
ItemRow row = getModel().getObject(se.getIndex());
if (row != null) {
doSelect(ureq, row);
}
} else if ("quick-view".equals(se.getCommand())) {
int rowIndex = se.getIndex();
if (rowIndex >= 0) {
if (itemsTable.isDetailsExpended(rowIndex)) {
itemsTable.collapseDetails(rowIndex);
} else {
itemsTable.collapseAllDetails();
ItemRow row = getModel().getObject(rowIndex);
if (row != null) {
itemsTable.expandDetails(rowIndex);
QuestionItem item = qpoolService.loadItemById(row.getKey());
previewCtrl.updateItem(ureq, item);
quickViewMetadataCtrl.setItem(ureq, item);
}
}
}
}
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
if ("select".equals(link.getCmd())) {
ItemRow row = (ItemRow) link.getUserObject();
doSelect(ureq, row);
} else if ("mark".equals(link.getCmd())) {
ItemRow row = (ItemRow) link.getUserObject();
if (doMark(row)) {
link.setIconLeftCSS(Mark.MARK_CSS_LARGE);
} else {
link.setIconLeftCSS(Mark.MARK_ADD_CSS_LARGE);
}
link.getComponent().setDirty(true);
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations