use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
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.FormItem in project openolat by klemens.
the class EMailCalloutCtrl method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
if (autoCompleteAllowed) {
ListProvider provider = new UserSearchListProvider();
autocompleterC = new FlexiAutoCompleterController(ureq, getWindowControl(), provider, null, isAdministrativeUser, allowExternalAddress, 60, 3, null, mainForm);
autocompleterC.setFormElement(false);
listenTo(autocompleterC);
FormItem item = autocompleterC.getInitialFormItem();
formLayout.add(item);
} else if (allowExternalAddress) {
emailEl = uifactory.addTextElement("email" + CodeHelper.getRAMUniqueID(), "email", null, 256, "", formLayout);
}
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class CourseReminderEditController method initRuleForm.
protected RuleElement initRuleForm(UserRequest ureq, RuleSPI ruleSpi, ReminderRule rule) {
String id = Integer.toString(counter++);
String type = ruleSpi.getClass().getSimpleName();
SingleSelection typeEl = uifactory.addDropdownSingleselect("rule.type.".concat(id), null, rulesCont, typeKeys, typeValues, null);
typeEl.addActionListener(FormEvent.ONCHANGE);
for (String typeKey : typeKeys) {
if (type.equals(typeKey)) {
typeEl.select(typeKey, true);
}
}
FormLink addRuleButton = uifactory.addFormLink("add.rule.".concat(id), "add", "add.rule", null, rulesCont, Link.BUTTON);
addRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add");
addRuleButton.setElementCssClass("o_sel_course_add_rule");
FormLink deleteRuleButton = uifactory.addFormLink("delete.rule.".concat(id), "delete", "delete.rule", null, rulesCont, Link.BUTTON);
deleteRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
deleteRuleButton.setElementCssClass("o_sel_course_delete_rule");
RuleEditorFragment editor = ruleSpi.getEditorFragment(rule, entry);
FormItem customItem = editor.initForm(rulesCont, this, ureq);
RuleElement ruleEl = new RuleElement(typeEl, addRuleButton, deleteRuleButton, editor, customItem);
typeEl.setUserObject(ruleEl);
addRuleButton.setUserObject(ruleEl);
deleteRuleButton.setUserObject(ruleEl);
return ruleEl;
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class CourseReminderEditController method doUpdateRuleForm.
private void doUpdateRuleForm(UserRequest ureq, RuleElement panelToUpdate, RuleSPI ruleSpi) {
// remove old editor
rulesCont.remove(panelToUpdate.getCustomItem());
// add new one
RuleEditorFragment editor = ruleSpi.getEditorFragment(null, entry);
FormItem customItem = editor.initForm(rulesCont, this, ureq);
panelToUpdate.setCustomItem(customItem, editor);
rulesCont.setDirty(true);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project openolat by klemens.
the class UserSearchFlexiController method doSearch.
public void doSearch() {
String login = loginEl.getValue();
// build user fields search map
Map<String, String> userPropertiesSearch = new HashMap<>();
for (UserPropertyHandler userPropertyHandler : userSearchFormPropertyHandlers) {
if (userPropertyHandler == null)
continue;
FormItem ui = propFormItems.get(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
if (userPropertyHandler.getName().startsWith("genericCheckboxProperty")) {
if (!"false".equals(uiValue)) {
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
} else if (StringHelper.containsNonWhitespace(uiValue)) {
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
}
if (userPropertiesSearch.isEmpty()) {
userPropertiesSearch = null;
}
tableEl.reset();
List<Identity> users = searchUsers(login, userPropertiesSearch, true);
if (!users.isEmpty()) {
userTableModel.setObjects(users);
flc.contextPut("showButton", "true");
} else {
getWindowControl().setInfo(translate("error.no.user.found"));
}
}
Aggregations