Search in sources :

Example 11 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator 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 12 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class FormLayoutContainer method register.

/**
 * register only, does not addsubcomponents, does not expose formItem in the velocity.
 * In 99% of the cases you should use an addXX method instead.
 * @param formComp
 */
public void register(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 (formComp.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;
    }
    formComp.setTranslator(itemTranslator);
    formComp.setRootForm(getRootForm());
    String formCompName = formComp.getName();
    // book keeping of FormComponent order
    listeningOnlyFormComponents.put(formCompName, formComp);
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 13 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class ForumNodeForumCallback method informOnDelete.

/**
 * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
 *      org.olat.course.ICourse)
 */
@Override
public String informOnDelete(Locale locale, ICourse course) {
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
    // no forum created yet
    if (forumKeyProperty == null)
        return null;
    return new PackageTranslator(PACKAGE_FO, locale).translate("warn.forumdelete");
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 14 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class TACourseNode method informOnDelete.

/**
 * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
 *      org.olat.course.ICourse)
 */
@Override
public String informOnDelete(Locale locale, ICourse course) {
    Translator trans = new PackageTranslator(PACKAGE_TA, locale);
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    List<Property> list = cpm.listCourseNodeProperties(this, null, null, null);
    // properties exist
    if (list.size() != 0)
        return trans.translate("warn.nodedelete");
    File fTaskFolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course, this));
    // task folder contains files
    if (fTaskFolder.exists() && fTaskFolder.list().length > 0)
        return trans.translate(NLS_WARN_NODEDELETE);
    // no data yet.
    return null;
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Property(org.olat.properties.Property) File(java.io.File) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 15 with PackageTranslator

use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.

the class IQSELFCourseNode method informOnDelete.

/**
 * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
 *      org.olat.course.ICourse)
 */
@Override
public String informOnDelete(Locale locale, ICourse course) {
    // Check if there are qtiresults for this selftest
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    Long repKey = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true).getKey();
    if (QTIResultManager.getInstance().hasResultSets(course.getResourceableId(), this.getIdent(), repKey)) {
        return new PackageTranslator(PACKAGE_IQ, locale).translate("info.nodedelete");
    }
    return null;
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Aggregations

PackageTranslator (org.olat.core.gui.translator.PackageTranslator)40 Translator (org.olat.core.gui.translator.Translator)34 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)8 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)8 Property (org.olat.properties.Property)8 Controller (org.olat.core.gui.control.Controller)6 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)6 Roles (org.olat.core.id.Roles)6 NodeEditController (org.olat.course.editor.NodeEditController)6 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)6 File (java.io.File)4 FormMultipartItem (org.olat.core.gui.components.form.flexible.FormMultipartItem)4 AssessmentCourseNodeController (org.olat.course.assessment.ui.tool.AssessmentCourseNodeController)4 MSEditFormController (org.olat.course.nodes.ms.MSEditFormController)4 DropboxController (org.olat.course.nodes.ta.DropboxController)4 ReturnboxController (org.olat.course.nodes.ta.ReturnboxController)4 TaskController (org.olat.course.nodes.ta.TaskController)4 Locale (java.util.Locale)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 BusinessControl (org.olat.core.id.context.BusinessControl)2