use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project OpenOLAT by OpenOLAT.
the class TranslationToolStartCrumbController method initMissingItemsElements.
private void initMissingItemsElements(FormUIFactory formFactory, FormItemContainer formLayout, String[] bundlesKeys, String[] bundlesValues) {
// Add missing bundles selector
missingBundlesSelection = formFactory.addDropdownSingleselect("missingBundlesSelection", this.flc, bundlesKeys, bundlesValues, null);
missingBundlesSelection.addActionListener(FormEvent.ONCHANGE);
missingBundlesSelection.select(ALL_BUNDLES_IDENTIFYER, true);
// Add missing bundles children switch
String[] missingBundles = new String[] { translate("generic.limit.bundles.includeChildren") };
missingBundlesIncludeBundlesChildrenSwitch = formFactory.addCheckboxesHorizontal("missingBundlesIncludeBundlesChildrenSwitch", null, flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
missingBundles);
missingBundlesIncludeBundlesChildrenSwitch.select(KEYS_ENABLED, true);
missingBundlesIncludeBundlesChildrenSwitch.addActionListener(FormEvent.ONCLICK);
formLayout.add(missingBundlesIncludeBundlesChildrenSwitch);
missingBundlesIncludeBundlesChildrenSwitch.setEnabled(false);
// Add priority sort switch
String[] missingBundlesPrio = new String[] { translate("generic.sort.by.priority") };
missingBundlesPrioritySortSwitch = formFactory.addCheckboxesHorizontal("missingBundlesPrioritySortSwitch", null, this.flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
missingBundlesPrio);
missingBundlesPrioritySortSwitch.select(KEYS_ENABLED, true);
missingBundlesPrioritySortSwitch.addActionListener(FormEvent.ONCLICK);
formLayout.add(missingBundlesPrioritySortSwitch);
// Add button to trigger missing keys search
missingListButton = new FormLinkImpl("missingListButton", "missingListButton", "generic.listButton", Link.BUTTON);
formLayout.add(missingListButton);
missingTranslateButton = new FormLinkImpl("missingTranslateButton", "missingTranslateButton", "generic.translateButton", Link.BUTTON);
formLayout.add(missingTranslateButton);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project OpenOLAT by OpenOLAT.
the class NoteController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// At beginning, the forms shows the note as a disabled field and an edit button. When the user
// clicks the edit button, the rich text field turns to the enabled state and the edit button
// is set to visible false and the submit button to visible true.
setFormTitle("note", new String[] { StringHelper.escapeHtml(n.getNoteTitle()) });
// set custom css style to override default read-only view of rich text element
setFormStyle("o_notes");
// we don't use FormUIFactory.addFormSubmitButton(...) here since that would cause the following custom CSS setting to get ignored.
editButton = new FormLinkImpl("edit", "edit", "edit", Link.BUTTON_SMALL);
editButton.setCustomEnabledLinkCSS("pull-right btn btn-default");
editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
formLayout.add(editButton);
noteField = uifactory.addRichTextElementForStringData("noteField", null, n.getNoteText(), 20, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
noteField.setEnabled(false);
noteField.setMaxLength(4000);
submitButton = uifactory.addFormSubmitButton("submit", formLayout);
submitButton.setVisible(false);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project OpenOLAT by OpenOLAT.
the class ENEditGroupAreaFormController method validateGroupFields.
private boolean validateGroupFields() {
boolean retVal = true;
List<Long> activeGroupSelection = null;
List<Long> activeAreaSelection = null;
easyAreaList.clearError();
easyGroupList.clearError();
if (!isEmpty(easyGroupList)) {
// check whether groups exist
activeGroupSelection = getKeys(easyGroupList);
Set<Long> missingGroups = new HashSet<Long>();
List<BusinessGroupShort> existingGroups = businessGroupService.loadShortBusinessGroups(activeGroupSelection);
a_a: for (Long activeGroupKey : activeGroupSelection) {
for (BusinessGroupShort group : existingGroups) {
if (group.getKey().equals(activeGroupKey)) {
continue a_a;
}
}
missingGroups.add(activeGroupKey);
}
if (missingGroups.size() > 0) {
retVal = false;
String labelKey = missingGroups.size() == 1 ? "error.notfound.name" : "error.notfound.names";
String csvMissGrps = toString(missingGroups);
String[] params = new String[] { "-", csvMissGrps };
// create error with link to fix it
String vc_errorPage = velocity_root + "/erroritem.html";
FormLayoutContainer errorGroupItemLayout = FormLayoutContainer.createCustomFormLayout("errorgroupitem", getTranslator(), vc_errorPage);
easyGroupList.setErrorComponent(errorGroupItemLayout, this.flc);
// FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
fixGroupError = new FormLinkImpl("error.fix", "create");
// link
fixGroupError.setCustomEnabledLinkCSS("btn btn-default");
errorGroupItemLayout.add(fixGroupError);
fixGroupError.setErrorKey(labelKey, params);
fixGroupError.showError(true);
fixGroupError.showLabel(false);
// String[].lenght > 1 -> show bulkmode creation group
if (missingGroups.size() > 1) {
fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
} else {
fixGroupError.setUserObject(new String[] { csvMissGrps });
}
easyGroupList.showError(true);
}
}
if (!isEmpty(easyAreaList)) {
// check whether areas exist
activeAreaSelection = getKeys(easyAreaList);
List<Long> missingAreas = new ArrayList<Long>();
List<BGArea> cnt = areaManager.loadAreas(activeAreaSelection);
a_a: for (Long activeAreaKey : activeAreaSelection) {
for (BGArea element : cnt) {
if (element.getKey().equals(activeAreaKey)) {
continue a_a;
}
}
missingAreas.add(activeAreaKey);
}
if (missingAreas.size() > 0) {
retVal = false;
String labelKey = missingAreas.size() == 1 ? "error.notfound.name" : "error.notfound.names";
String csvMissAreas = toString(missingAreas);
String[] params = new String[] { "-", csvMissAreas };
// create error with link to fix it
String vc_errorPage = velocity_root + "/erroritem.html";
FormLayoutContainer errorAreaItemLayout = FormLayoutContainer.createCustomFormLayout("errorareaitem", getTranslator(), vc_errorPage);
easyAreaList.setErrorComponent(errorAreaItemLayout, this.flc);
// FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
// erstellen
fixAreaError = new FormLinkImpl("error.fix", "create");
// link
fixAreaError.setCustomEnabledLinkCSS("btn btn-default");
errorAreaItemLayout.add(fixAreaError);
fixAreaError.setErrorKey(labelKey, params);
fixAreaError.showError(true);
fixAreaError.showLabel(false);
// String[].lenght > 1 -> show bulkmode creation group
if (missingAreas.size() > 1) {
fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
} else {
fixAreaError.setUserObject(new String[] { csvMissAreas });
}
easyAreaList.showError(true);
}
}
boolean easyGroupOK = activeGroupSelection != null && activeGroupSelection.size() > 0;
boolean easyAreaOK = activeAreaSelection != null && activeAreaSelection.size() > 0;
if (!easyGroupOK && !easyAreaOK) {
// error concerns both fields -> set it as switch error
easyGroupList.setErrorKey("form.noGroupsOrAreas", null);
retVal = false;
}
// raise error if someone removed all groups and areas from form
if (!retVal && !easyGroupOK && !easyAreaOK) {
easyGroupList.setErrorKey("form.noGroupsOrAreas", null);
}
return retVal;
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project OpenOLAT by OpenOLAT.
the class BGCopySingleGroupStep method getStepTitle.
@Override
public FormItem getStepTitle() {
String groupName = StringHelper.escapeHtml(groupToCopy.getName());
String title = getTranslator().translate("copy.wizard.bgstep", new String[] { groupName });
FormLink fl = new FormLinkImpl("copy.wizard." + groupToCopy.getKey(), null, title, Link.FLEXIBLEFORMLNK + Link.NONTRANSLATED);
fl.setTranslator(getTranslator());
return fl;
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.
the class NoteController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// At beginning, the forms shows the note as a disabled field and an edit button. When the user
// clicks the edit button, the rich text field turns to the enabled state and the edit button
// is set to visible false and the submit button to visible true.
setFormTitle("note", new String[] { StringHelper.escapeHtml(n.getNoteTitle()) });
// set custom css style to override default read-only view of rich text element
setFormStyle("o_notes");
// we don't use FormUIFactory.addFormSubmitButton(...) here since that would cause the following custom CSS setting to get ignored.
editButton = new FormLinkImpl("edit", "edit", "edit", Link.BUTTON_SMALL);
editButton.setCustomEnabledLinkCSS("pull-right btn btn-default");
editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
formLayout.add(editButton);
noteField = uifactory.addRichTextElementForStringData("noteField", null, n.getNoteText(), 20, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
noteField.setEnabled(false);
noteField.setMaxLength(4000);
submitButton = uifactory.addFormSubmitButton("submit", formLayout);
submitButton.setVisible(false);
}
Aggregations