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);
}
}
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);
}
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");
}
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;
}
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;
}
Aggregations