use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.
the class TranslationToolI18nItemListCrumbController method initForm.
/*
* (non-Javadoc)
*
* @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) {
// Add the translate all button
allTranslateButtonTop = new FormLinkImpl("allTranslateButtonTop", "allTranslateButtonTop", "generic.translateAllButton", Link.BUTTON);
formLayout.add(allTranslateButtonTop);
allTranslateButtonBottom = new FormLinkImpl("allTranslateButtonBottom", "allTranslateButtonBottom", "generic.translateAllButton", Link.BUTTON);
formLayout.add(allTranslateButtonBottom);
// Add a translate button for each package
String currentBundleName = null;
int bundlesCount = 0;
for (I18nItem item : i18nItems) {
if (!item.getBundleName().equals(currentBundleName)) {
currentBundleName = item.getBundleName();
String linkName = "translateBundle_" + currentBundleName;
String label = (customizingMode ? "generic.customize.translateButton" : "generic.translateButton");
FormLink bundleTranslateButton = new FormLinkImpl(linkName, linkName, label, Link.BUTTON_SMALL);
// use first item of bundle
bundleTranslateButton.setUserObject(item);
formLayout.add(bundleTranslateButton);
bundlesCount++;
}
}
// Add all the items to velocity
this.flc.contextPut("i18nItems", i18nItems);
this.flc.contextPut("bundlesCount", bundlesCount);
this.flc.contextPut("keysCount", i18nItems.size());
// Override text labels for customizing mode
if (customizingMode) {
allTranslateButtonTop.setI18nKey("generic.customize.translateAllButton");
allTranslateButtonBottom.setI18nKey("generic.customize.translateAllButton");
}
this.flc.contextPut("customizingMode", Boolean.valueOf(customizingMode));
this.flc.contextPut("customizingPrefix", (customizingMode ? "customize." : ""));
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.
the class TranslationToolStartCrumbController method initExistingItemsElements.
private void initExistingItemsElements(FormUIFactory formFactory, FormItemContainer formLayout, String[] bundlesKeys, String[] bundlesValues) {
// Add existing bundles selector
existingBundlesSelection = formFactory.addDropdownSingleselect("existingBundlesSelection", this.flc, bundlesKeys, bundlesValues, null);
existingBundlesSelection.addActionListener(FormEvent.ONCHANGE);
existingBundlesSelection.select(ALL_BUNDLES_IDENTIFYER, true);
// Add existing bundles children switch
String[] existingBundlesInclude = new String[] { translate("generic.limit.bundles.includeChildren") };
existingBundlesIncludeBundlesChildrenSwitch = formFactory.addCheckboxesHorizontal("existingBundlesIncludeBundlesChildrenSwitch", null, flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
existingBundlesInclude);
existingBundlesIncludeBundlesChildrenSwitch.select(KEYS_ENABLED, true);
existingBundlesIncludeBundlesChildrenSwitch.addActionListener(FormEvent.ONCLICK);
formLayout.add(existingBundlesIncludeBundlesChildrenSwitch);
existingBundlesIncludeBundlesChildrenSwitch.setEnabled(false);
// Add priority sort switch
String[] existingBundlespPrio = new String[] { translate("generic.sort.by.priority") };
existingBundlesPrioritySortSwitch = formFactory.addCheckboxesHorizontal("existingBundlesPrioritySortSwitch", null, flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
existingBundlespPrio);
existingBundlesPrioritySortSwitch.select(KEYS_ENABLED, true);
existingBundlesPrioritySortSwitch.addActionListener(FormEvent.ONCLICK);
formLayout.add(existingBundlesPrioritySortSwitch);
// Add button to trigger existing keys search
existingListButton = new FormLinkImpl("existingListButton", "existingListButton", "generic.listButton", Link.BUTTON);
formLayout.add(existingListButton);
existingTranslateButton = new FormLinkImpl("existingTranslateButton", "existingTranslateButton", "generic.translateButton", Link.BUTTON);
formLayout.add(existingTranslateButton);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.
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 klemens.
the class FormUIFactory method addFormLink.
/**
* @param name to be used to render in velocity <code>$r.render("name")</code>
* @param cmd The cmd to be used
* @param i18nLink i18n key for the link text
* @param i18nLabel i18n key for the link elements label, maybe <code>null</code>
* @param formLayout FormLink is added as element here
* @param presentation See Link.BUTTON etc.
* @return
*/
public FormLink addFormLink(String name, String cmd, String i18nLink, String i18nLabel, FormItemContainer formLayout, int presentation) {
FormLinkImpl fte = new FormLinkImpl(name, cmd, i18nLink, presentation);
fte.setI18nKey(i18nLink);
setLabelIfNotNull(i18nLabel, fte);
if (formLayout != null) {
formLayout.add(fte);
}
return fte;
}
use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.
the class FormUIFactory method addFormLink.
/**
* Add a form link with a special css class
*
* @param name The name of the form element (identifyer), also used as i18n key
* @param formLayout
* @param css class
* @return
*/
public FormLink addFormLink(String name, FormItemContainer formLayout, String customEnabledLinkCSS) {
FormLinkImpl fte = new FormLinkImpl(name);
fte.setCustomEnabledLinkCSS(customEnabledLinkCSS);
if (formLayout != null) {
formLayout.add(fte);
}
return fte;
}
Aggregations