use of org.olat.core.gui.components.form.flexible.elements.FormLink in project openolat by klemens.
the class LicenseAdminConfigController method initHandlerConfigs.
private void initHandlerConfigs() {
List<FormLayoutContainer> handlerConfigs = new ArrayList<>(licenseHandlers.size());
for (LicenseHandler handler : licenseHandlers) {
boolean handlerEnabled = licenseModule.isEnabled(handler);
if (handlerEnabled) {
String handlerType = handler.getType();
FormLayoutContainer handlerCont = FormLayoutContainer.createDefaultFormLayout("handler-" + handlerType, getTranslator());
handlerCont.setRootForm(mainForm);
flc.add("handler-" + handlerType, handlerCont);
uifactory.addSpacerElement("spacer-" + handlerType, handlerCont, false);
SpacerElement handlerName = uifactory.addSpacerElement("name-" + handlerType, handlerCont, true);
handlerName.setLabel(handler.getTitle(getLocale()), null, false);
SingleSelection defaultLicenseTypeEl = uifactory.addDropdownSingleselect(DEFAULT_LICENSE_TYPE_PREFIX + handlerType, "admin.default.license.type", handlerCont, new String[0], new String[0], null);
defaultLicenseTypeEl.setUserObject(handler);
defaultLicenseTypeEl.addActionListener(FormEvent.ONCHANGE);
defaultLicenseTypeEls.put(handlerType, defaultLicenseTypeEl);
reloadDefaultLicenseTypeEl(handler);
String[] licensorCreatorKeys = licensorCreators.stream().map(LicensorCreator::getType).toArray(String[]::new);
String[] licensorCreatorValues = licensorCreators.stream().map(creator -> creator.getName(getLocale())).toArray(String[]::new);
SingleSelection licensorCreatorEl = uifactory.addDropdownSingleselect(LICENSOR_CREATOR_TYPE_PREFIX + handlerType, "admin.licensor.creator", handlerCont, licensorCreatorKeys, licensorCreatorValues, null);
licensorCreatorEl.setUserObject(handler);
String creatorType = licenseModule.getLicensorCreatorType(handler);
if (creatorType != null) {
licensorCreatorEl.select(creatorType, true);
}
licensorCreatorEl.addActionListener(FormEvent.ONCHANGE);
if (CONSTANT_CREATOR_TYPE.equals(creatorType)) {
String licensorConstant = licenseModule.getConstantLicensor(handler);
uifactory.addStaticTextElement("lgc-" + handlerType, "admin.licensor.constant", licensorConstant, handlerCont);
FormLink editLicensorConstantLink = uifactory.addFormLink("lgb-", "admin.licensor.constant.edit", "", handlerCont, Link.BUTTON);
editLicensorConstantLink.setUserObject(handler);
}
handlerConfigs.add(handlerCont);
}
}
flc.getFormItemComponent().contextPut("handlerConfigs", handlerConfigs);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project openolat by klemens.
the class DialogElementListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
DialogElementRow row = tableModel.getObject(se.getIndex());
if ("forum".equals(se.getCommand())) {
fireEvent(ureq, new SelectRowEvent(row));
} else if ("delete".equals(se.getCommand())) {
doConfirmDelete(ureq, row);
}
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("download".equals(cmd)) {
doFileDelivery(ureq, (DialogElement) link.getUserObject());
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project openolat by klemens.
the class EdubaseBookSectionListController method wrapBookSection.
private void wrapBookSection(BookSection bookSection) {
String bookSectionId = "" + countBookSections++;
// remove
FormLink removeLink = uifactory.addFormLink(RM_PREFIX.concat(bookSectionId), RM_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
bookSectionsCont.add(removeLink);
bookSectionsCont.add(RM_PREFIX.concat(bookSectionId), removeLink);
// add
FormLink addLink = uifactory.addFormLink(ADD_PREFIX.concat(bookSectionId), ADD_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
bookSectionsCont.add(addLink);
bookSectionsCont.add(ADD_PREFIX.concat(bookSectionId), addLink);
// up
FormLink upLink = uifactory.addFormLink(UP_PREFIX.concat(bookSectionId), UP_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
bookSectionsCont.add(upLink);
bookSectionsCont.add(UP_PREFIX.concat(bookSectionId), upLink);
// down
FormLink downLink = uifactory.addFormLink(DOWN_PREFIX.concat(bookSectionId), DOWN_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
bookSectionsCont.add(downLink);
bookSectionsCont.add(DOWN_PREFIX.concat(bookSectionId), downLink);
// Details button
FormLink detailsLinkEl = uifactory.addFormLink(DETAILS_PREFIX.concat(bookSectionId), DETAILS_PREFIX, "edubase.book.section.details", null, bookSectionsCont, Link.BUTTON);
detailsLinkEl.setElementCssClass("o_edubase_bs_details");
bookSectionsCont.add(detailsLinkEl);
bookSectionsCont.add(DETAILS_PREFIX.concat(bookSectionId), detailsLinkEl);
// book id
TextElement bookIdEl = uifactory.addTextElement(BOOK_ID_PREFIX.concat(bookSectionId), "edubase.book.section.id", 128, bookSection.getBookId(), bookSectionsCont);
bookIdEl.setMandatory(true);
bookIdEl.setHelpTextKey("edubase.book.section.id.help", null);
// page from
String pageFrom = bookSection.getPageFrom() != null ? Integer.toString(bookSection.getPageFrom()) : null;
TextElement pageFromEl = uifactory.addTextElement(PAGE_FROM_PREFIX.concat(bookSectionId), "edubase.book.section.page.from", 6, pageFrom, bookSectionsCont);
// page to
String pageTo = bookSection.getPageTo() != null ? Integer.toString(bookSection.getPageTo()) : null;
TextElement pageToEl = uifactory.addTextElement(PAGE_TO_PREFIX.concat(bookSectionId), "edubase.book.section.page.to", 6, pageTo, bookSectionsCont);
// title
TextElement titleEl = uifactory.addTextElement("title".concat(bookSectionId), "edubase.book.section.title", 128, bookSection.getTitle(), bookSectionsCont);
// description
RichTextElement descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic(DESC_PREFIX.concat(bookSectionId), "edubase.book.section.description", bookSection.getDescription(), 4, -1, bookSectionsCont, getWindowControl());
boolean discriptionEnabled = config.getBooleanSafe(EdubaseCourseNode.CONFIG_DESCRIPTION_ENABLED);
descriptionEl.setVisible(discriptionEnabled);
bookSectionWrappers.add(new BookSectionWrapper(bookSection, removeLink, addLink, upLink, downLink, detailsLinkEl, bookIdEl, pageFromEl, pageToEl, titleEl, descriptionEl));
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project openolat by klemens.
the class PortfolioResultDetailsController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if (cmd != null && cmd.startsWith("map.deadline.change")) {
if (deadlineCalloutCtr == null) {
EPStructuredMap map = (EPStructuredMap) link.getUserObject();
popupDeadlineBox(ureq, map);
} else {
// close on second click
closeDeadlineBox();
}
} else if (link.getName().startsWith("open.map")) {
PortfolioStructureMap map = (PortfolioStructureMap) link.getUserObject();
doOpenMap(ureq, map);
} else if (link.getName().startsWith("open.binder")) {
Binder map = (Binder) link.getUserObject();
doOpenMap(ureq, map);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project openolat by klemens.
the class CustomfieldsFormController method formInnerEvent.
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink) {
FormLink link = (FormLink) source;
if (link.getName().equals(ADD_FIELD_LINK)) {
if (customFields.size() < MAX_NBR_CUSTOM_FIELDS) {
// Add new custom-field
int indexNewCustomField = customFields.size();
customFields.add(new CustomField("", "", false));
// first remove existing submit button, add it again at the end
flc.remove(formSubmit);
createFormElemente(this.flc, indexNewCustomField, customFields.get(indexNewCustomField));
formSubmit = uifactory.addFormSubmitButton("save", this.flc);
} else {
this.showInfo("info.max.nbr.custom.fields");
}
} else {
int deleteElementNumber = ((Integer) link.getUserObject()).intValue();
getLogger().debug("remove customfield #=" + deleteElementNumber);
customFields.remove(deleteElementNumber);
initFormElements(flc);
}
}
this.flc.setDirty(true);
}
Aggregations