Search in sources :

Example 1 with FormMultipartItem

use of org.olat.core.gui.components.form.flexible.FormMultipartItem in project OpenOLAT by OpenOLAT.

the class FormLayoutContainer method add.

@Override
public void add(String name, FormItem formComp) {
    if (!hasRootForm) {
        throw new AssertionError("first ensure that the layout container knows about its rootform!!");
    }
    // set the formtranslator, and parent
    Translator itemTranslator = formComp.getTranslator();
    if (itemTranslator != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    formComp.setTranslator(itemTranslator);
    formComp.setRootForm(getRootForm());
    // 
    String formCompName = name;
    // book keeping of FormComponent order
    formComponentsNames.add(formCompName);
    formComponents.put(formCompName, formComp);
    /*
		 * add the gui representation
		 */
    formLayoutContainer.put(formCompName, formComp.getComponent());
    formLayoutContainer.put(formCompName + FormItem.ERRORC, formComp.getErrorC());
    formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, formComp.getExampleC());
    formLayoutContainer.put(formCompName + FormItem.LABELC, formComp.getLabelC());
    // Check for multipart data, add upload limit to form
    if (formComp instanceof FormMultipartItem) {
        getRootForm().setMultipartEnabled(true);
    }
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) FormMultipartItem(org.olat.core.gui.components.form.flexible.FormMultipartItem)

Example 2 with FormMultipartItem

use of org.olat.core.gui.components.form.flexible.FormMultipartItem in project OpenOLAT by OpenOLAT.

the class FormLayoutContainer method replace.

public void replace(FormItem toBeReplaced, FormItem with) {
    String formCompName = toBeReplaced.getName();
    int pos = formComponentsNames.indexOf(formCompName);
    formComponentsNames.add(pos, with.getName());
    formComponentsNames.remove(formCompName);
    /*
		 * remove the gui representation
		 */
    formLayoutContainer.remove(toBeReplaced.getComponent());
    formLayoutContainer.remove(toBeReplaced.getErrorC());
    formLayoutContainer.remove(toBeReplaced.getExampleC());
    formLayoutContainer.remove(toBeReplaced.getLabelC());
    // set the formtranslator, and parent
    Translator itemTranslator = with.getTranslator();
    if (with.getTranslator() != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    with.setTranslator(itemTranslator);
    with.setRootForm(getRootForm());
    formComponents.put(formCompName, with);
    /*
		 * add the gui representation
		 */
    formLayoutContainer.put(formCompName, with.getComponent());
    formLayoutContainer.put(formCompName + FormItem.ERRORC, with.getErrorC());
    formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, with.getExampleC());
    formLayoutContainer.put(formCompName + FormItem.LABELC, with.getLabelC());
    // Check for multipart data, add upload limit to form
    if (with instanceof FormMultipartItem) {
        getRootForm().setMultipartEnabled(true);
    }
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) FormMultipartItem(org.olat.core.gui.components.form.flexible.FormMultipartItem)

Example 3 with FormMultipartItem

use of org.olat.core.gui.components.form.flexible.FormMultipartItem in project openolat by klemens.

the class FormLayoutContainer method replace.

public void replace(FormItem toBeReplaced, FormItem with) {
    String formCompName = toBeReplaced.getName();
    int pos = formComponentsNames.indexOf(formCompName);
    formComponentsNames.add(pos, with.getName());
    formComponentsNames.remove(formCompName);
    /*
		 * remove the gui representation
		 */
    formLayoutContainer.remove(toBeReplaced.getComponent());
    formLayoutContainer.remove(toBeReplaced.getErrorC());
    formLayoutContainer.remove(toBeReplaced.getExampleC());
    formLayoutContainer.remove(toBeReplaced.getLabelC());
    // set the formtranslator, and parent
    Translator itemTranslator = with.getTranslator();
    if (with.getTranslator() != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    with.setTranslator(itemTranslator);
    with.setRootForm(getRootForm());
    formComponents.put(formCompName, with);
    /*
		 * add the gui representation
		 */
    formLayoutContainer.put(formCompName, with.getComponent());
    formLayoutContainer.put(formCompName + FormItem.ERRORC, with.getErrorC());
    formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, with.getExampleC());
    formLayoutContainer.put(formCompName + FormItem.LABELC, with.getLabelC());
    // Check for multipart data, add upload limit to form
    if (with instanceof FormMultipartItem) {
        getRootForm().setMultipartEnabled(true);
    }
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) FormMultipartItem(org.olat.core.gui.components.form.flexible.FormMultipartItem)

Example 4 with FormMultipartItem

use of org.olat.core.gui.components.form.flexible.FormMultipartItem in project openolat by klemens.

the class FormLayoutContainer method add.

@Override
public void add(String name, FormItem formComp) {
    if (!hasRootForm) {
        throw new AssertionError("first ensure that the layout container knows about its rootform!!");
    }
    // set the formtranslator, and parent
    Translator itemTranslator = formComp.getTranslator();
    if (itemTranslator != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    formComp.setTranslator(itemTranslator);
    formComp.setRootForm(getRootForm());
    // 
    String formCompName = name;
    // book keeping of FormComponent order
    formComponentsNames.add(formCompName);
    formComponents.put(formCompName, formComp);
    /*
		 * add the gui representation
		 */
    formLayoutContainer.put(formCompName, formComp.getComponent());
    formLayoutContainer.put(formCompName + FormItem.ERRORC, formComp.getErrorC());
    formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, formComp.getExampleC());
    formLayoutContainer.put(formCompName + FormItem.LABELC, formComp.getLabelC());
    // Check for multipart data, add upload limit to form
    if (formComp instanceof FormMultipartItem) {
        getRootForm().setMultipartEnabled(true);
    }
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) FormMultipartItem(org.olat.core.gui.components.form.flexible.FormMultipartItem)

Aggregations

FormMultipartItem (org.olat.core.gui.components.form.flexible.FormMultipartItem)4 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)4 Translator (org.olat.core.gui.translator.Translator)4