use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class EPShareListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
// process all form-input fields and update data-model
secureListBox();
// policy might be persisted. check with validateFormLogic()
if (source == addPolicyButton) {
if (validateFormLogic(ureq)) {
addEPSharePolicyWrapper(null);
initPolicyUI();
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
Object userObject = link.getUserObject();
if (userObject instanceof EPSharePolicyWrapper) {
EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) userObject;
if (link.getName().startsWith("map.share.policy.add")) {
if (validateFormLogic(ureq)) {
addEPSharePolicyWrapper(wrapper);
initPolicyUI();
}
} else if (link.getName().startsWith("map.share.policy.delete")) {
removeEPSharePolicyWrapper(wrapper);
initPolicyUI();
} else if (link.getName().startsWith("map.share.policy.invite")) {
if (validateFormLogic(ureq)) {
sendInvitation(ureq, wrapper);
initPolicyUI();
}
} else if (link.getName().startsWith("choose.group")) {
doSelectGroup(ureq, wrapper);
} else if (link.getName().startsWith("choose.identity")) {
doSelectIdentity(ureq, wrapper);
}
} else if (userObject instanceof EPShareGroupWrapper) {
EPShareGroupWrapper wrapper = (EPShareGroupWrapper) userObject;
wrapper.remove();
initPolicyUI();
} else if (userObject instanceof EPShareUserWrapper) {
EPShareUserWrapper wrapper = (EPShareUserWrapper) userObject;
wrapper.remove();
initPolicyUI();
}
} else if (source instanceof SingleSelection && source.getUserObject() instanceof EPSharePolicyWrapper) {
SingleSelection selection = (SingleSelection) source;
if (selection.isOneSelected()) {
String type = selection.getSelectedKey();
EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) selection.getUserObject();
changeType(wrapper, type);
}
initPolicyUI();
}
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class EPShareListController method createContainerForUser.
private void createContainerForUser(EPSharePolicyWrapper policyWrapper, String cmpName, FormLayoutContainer container) {
String page = velocity_root + "/shareWithUsers.html";
FormLayoutContainer userListBox = FormLayoutContainer.createCustomFormLayout("map.share.with." + cmpName, getTranslator(), page);
userListBox.contextPut("wrapper", policyWrapper);
userListBox.setRootForm(mainForm);
container.add("map.share.with." + cmpName, userListBox);
List<Identity> identities = policyWrapper.getIdentities();
List<EPShareUserWrapper> groupWrappers = new ArrayList<EPShareUserWrapper>();
for (Identity identity : identities) {
FormLink rmLink = uifactory.addFormLink("rm-" + identity.getKey(), "", null, userListBox, Link.NONTRANSLATED + Link.LINK);
rmLink.setIconLeftCSS("o_icon o_icon_remove");
EPShareUserWrapper gWrapper = new EPShareUserWrapper(policyWrapper, identity, rmLink);
rmLink.setUserObject(gWrapper);
groupWrappers.add(gWrapper);
}
userListBox.contextPut("identities", groupWrappers);
policyWrapper.setUserListBox(userListBox);
FormLink chooseUsersLink = uifactory.addFormLink("choose.identity", "choose.identity", null, userListBox, Link.BUTTON);
chooseUsersLink.setElementCssClass("o_form_groupchooser");
chooseUsersLink.setUserObject(policyWrapper);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class EPChangelogController method getItemBundlesForSubscriptionItems.
/**
* @param subscriptionItems
* @return
*/
private List<SubscriptionItemBundle> getItemBundlesForSubscriptionItems(List<SubscriptionListItem> subscriptionItems) {
List<SubscriptionItemBundle> bundles = new ArrayList<EPChangelogController.SubscriptionItemBundle>();
Formatter f = Formatter.getInstance(getTranslator().getLocale());
for (int i = 0; i < subscriptionItems.size(); i++) {
SubscriptionListItem listItem = subscriptionItems.get(i);
SubscriptionItemBundle bundle = new SubscriptionItemBundle();
bundle.setDateString(f.formatDate(listItem.getDate()));
String linkName = "subscrIL_" + i;
bundle.setLinkName(linkName);
String text = listItem.getDescription();
FormLink link = uifactory.addFormLink(linkName, text, null, flc, Link.NONTRANSLATED);
link.setUserObject(listItem.getUserObject());
bundle.setCssClass(listItem.getIconCssClass());
bundles.add(bundle);
}
return bundles;
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class EPArtefactViewController 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)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (detailsLinkEnabled && !artefactChooseMode) {
detailsLink = uifactory.addFormLink("details.link", formLayout, Link.BUTTON);
detailsLink.setElementCssClass("o_sel_artefact_details");
}
title = uifactory.addInlineTextElement("title", artefact.getTitle(), formLayout, this);
flc.contextPut("cssClosed", artefactInClosedMap ? "o_artefact_closed" : "");
flc.contextPut("viewOnly", viewOnlyMode);
if (viewOnlyMode || artefactInClosedMap)
title.setEnabled(false);
// get tags and prepare textboxlist-component
List<String> tagL = ePFMgr.getArtefactTags(artefact);
Map<String, String> tagLM = new HashMap<String, String>();
for (String tag : tagL) {
tagLM.put(tag, tag);
}
tblE = uifactory.addTextBoxListElement("tagTextbox", null, "tag.textboxlist.hint", tagLM, formLayout, getTranslator());
if (viewOnlyMode || artefactInClosedMap) {
tblE.setEnabled(false);
} else {
Map<String, String> allUsersTags = ePFMgr.getUsersMostUsedTags(getIdentity(), -1);
tblE.setAutoCompleteContent(allUsersTags);
}
// get maps wherein this artefact is linked and create links to them
List<PortfolioStructure> linkedMaps = ePFMgr.getReferencedMapsForArtefact(artefact);
if (linkedMaps != null && linkedMaps.size() != 0) {
List<FormLink> selectMapNames = new ArrayList<FormLink>(linkedMaps.size());
int count = 0;
for (PortfolioStructure ePMap : linkedMaps) {
String mapTitle = StringHelper.escapeHtml(ePMap.getTitle());
FormLink selectMap = uifactory.addFormLink("map-" + count++, "map", mapTitle, null, formLayout, Link.NONTRANSLATED);
selectMap.setUserObject(ePMap.getOlatResource());
selectMap.setEnabled(!viewOnlyMode && !artefactChooseMode);
selectMapNames.add(selectMap);
}
flc.contextPut("maps", selectMapNames);
}
// build link to original source
if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) {
String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath());
flc.contextPut("artefactSourceLink", sourceLink);
}
// create a delete button
deleteBtn = uifactory.addFormLink("delete.artefact", formLayout, Link.BUTTON);
deleteBtn.setIconLeftCSS("o_icon o_icon_delete");
deleteBtn.addActionListener(FormEvent.ONCLICK);
if (viewOnlyMode || artefactChooseMode || artefactInClosedMap)
deleteBtn.setVisible(false);
// let the artefact-handler paint what is special for this kind of artefact
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
Controller detCtrl = artHandler.createDetailsController(ureq, getWindowControl(), artefact, viewOnlyMode || artefactInClosedMap);
if (detCtrl != null) {
flc.put("detailsController", detCtrl.getInitialComponent());
}
// create edit buttons the adapt meta-data
if (!(viewOnlyMode || artefactChooseMode || artefactInClosedMap)) {
String reflexion = artefact.getReflexion();
reflexion = FilterFactory.getHtmlTagAndDescapingFilter().filter(reflexion);
reflexion = StringHelper.xssScan(reflexion);
reflexion = Formatter.truncate(reflexion, 50);
if (!StringHelper.containsNonWhitespace(reflexion)) {
// show a link even if empty
reflexion = " ";
}
reflexionBtn = uifactory.addFormLink("reflexionBtn", reflexion, null, formLayout, Link.NONTRANSLATED);
reflexionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
String description = artefact.getDescription();
description = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
description = Formatter.truncate(description, 50);
description = StringHelper.xssScan(description);
if (!StringHelper.containsNonWhitespace(description)) {
// show a link even if empty
description = " ";
}
descriptionBtn = uifactory.addFormLink("descriptionBtn", description, null, formLayout, Link.NONTRANSLATED);
descriptionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
}
// if in artefactChooseMode, add an "choose this" button
if (artefactChooseMode) {
chooseBtn = uifactory.addFormLink("choose.artefact", formLayout, Link.BUTTON);
chooseBtn.addActionListener(FormEvent.ONCLICK);
}
flc.contextPut("artefact", artefact);
setArtAttribConfig(artAttribConfig);
}
use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.
the class UsrPropContextEditController method addTableRowComponents.
/**
* adds tableRow-Components (Toggles and Links) for the given Handler
*
* @param handler The handler to create Components for
* @param moveable if true, additional "up"/"down" Links will be rendered
*/
private void addTableRowComponents(UserPropertyHandler handler, boolean moveable) {
List<FormItem> rowFormItemComponents = new ArrayList<FormItem>();
final String handlername = handler.getName();
final boolean isIncluded = context.contains(handler);
final boolean isMandatory = context.isMandatoryUserProperty(handler);
final boolean isAdminOnly = context.isForAdministrativeUserOnly(handler);
final boolean isUserReadOnly = context.isUserViewReadOnly(handler);
// put the translation (in the current language) for the property
String translatedName = I18nManager.getInstance().getLocalizedString(UserPropertyHandler.class.getPackage().getName(), handler.i18nFormElementLabelKey(), null, getLocale(), true, true);
uifactory.addStaticTextElement(FT_NAME_PREFIX_TRANS + handlername, (translatedName == null ? "-" : translatedName), contTableFlc);
FormToggle ftMandatory = uifactory.addToggleButton(FT_NAME_PREFIX_MAND + handlername, " ", contTableFlc, null, null);
ftMandatory.setUserObject(handler);
if (isMandatory)
ftMandatory.toggleOn();
else
ftMandatory.toggleOff();
if (!isIncluded) {
ftMandatory.setEnabled(false);
ftMandatory.setVisible(false);
}
FormToggle ftAdminonly = uifactory.addToggleButton(FT_NAME_PREFIX_ADMN + handlername, " ", contTableFlc, null, null);
ftAdminonly.setUserObject(handler);
if (isAdminOnly)
ftAdminonly.toggleOn();
else
ftAdminonly.toggleOff();
if (!isIncluded) {
ftAdminonly.setEnabled(false);
ftAdminonly.setVisible(false);
}
FormToggle ftUserreadonly = uifactory.addToggleButton(FT_NAME_PREFIX_USR + handlername, " ", contTableFlc, null, null);
ftUserreadonly.setUserObject(handler);
if (isUserReadOnly)
ftUserreadonly.toggleOn();
else
ftUserreadonly.toggleOff();
if (!isIncluded) {
ftUserreadonly.setEnabled(false);
ftUserreadonly.setVisible(false);
}
FormToggle ftInclude = uifactory.addToggleButton(FT_NAME_PREFIX_INCL + handlername, " ", contTableFlc, null, null);
ftInclude.setUserObject(handler);
if (isIncluded) {
ftInclude.toggleOn();
includedPropertiesCount++;
} else
ftInclude.toggleOff();
// up/down links
FormLink fl_up = uifactory.addFormLink(FT_NAME_PREFIX_MUP + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
fl_up.setIconLeftCSS("o_icon o_icon_move_up o_icon-lg");
fl_up.setUserObject(handler);
FormLink fl_down = uifactory.addFormLink(FT_NAME_PREFIX_MDN + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
fl_down.setIconRightCSS("o_icon o_icon_move_down o_icon-lg");
fl_down.setUserObject(handler);
if (!moveable) {
fl_up.setEnabled(false);
fl_up.setVisible(false);
fl_down.setEnabled(false);
fl_down.setVisible(false);
}
rowFormItemComponents.add(ftMandatory);
rowFormItemComponents.add(ftAdminonly);
rowFormItemComponents.add(ftUserreadonly);
rowFormItemComponents.add(fl_up);
rowFormItemComponents.add(fl_down);
rowToggleButtonsMap.put(handlername, rowFormItemComponents);
}
Aggregations