use of org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement in project OpenOLAT by OpenOLAT.
the class CourseLayoutGeneratorController method prepareStyleEditor.
private void prepareStyleEditor(Map<String, Map<String, Object>> customConfig) {
// keep config order
guiWrapper = new LinkedHashMap<String, Map<String, FormItem>>();
List<AbstractLayoutElement> allElements = customCMgr.getAllAvailableElements();
List<AbstractLayoutAttribute> allAttribs = customCMgr.getAllAvailableAttributes();
styleFlc.contextPut("allAttribs", allAttribs);
// needed reference to get listener back.
styleFlc.setUserObject(this);
for (AbstractLayoutElement abstractLayoutElement : allElements) {
String elementType = abstractLayoutElement.getLayoutElementTypeName();
Map<String, Object> elConf = customConfig.get(elementType);
AbstractLayoutElement concreteElmt = abstractLayoutElement.createInstance(elConf);
HashMap<String, FormItem> elAttribGui = new HashMap<String, FormItem>();
List<AbstractLayoutAttribute> attributes = concreteElmt.getAvailableAttributes();
for (AbstractLayoutAttribute attrib : attributes) {
String compName = elementType + ELEMENT_ATTRIBUTE_DELIM + attrib.getLayoutAttributeTypeName();
FormItem fi = attrib.getFormItem(compName, styleFlc);
fi.addActionListener(FormEvent.ONCHANGE);
elAttribGui.put(attrib.getLayoutAttributeTypeName(), fi);
}
guiWrapper.put(elementType, elAttribGui);
}
styleFlc.contextPut("guiWrapper", guiWrapper);
}
use of org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement in project openolat by klemens.
the class CourseLayoutGeneratorController method prepareStyleEditor.
private void prepareStyleEditor(Map<String, Map<String, Object>> customConfig) {
// keep config order
guiWrapper = new LinkedHashMap<String, Map<String, FormItem>>();
List<AbstractLayoutElement> allElements = customCMgr.getAllAvailableElements();
List<AbstractLayoutAttribute> allAttribs = customCMgr.getAllAvailableAttributes();
styleFlc.contextPut("allAttribs", allAttribs);
// needed reference to get listener back.
styleFlc.setUserObject(this);
for (AbstractLayoutElement abstractLayoutElement : allElements) {
String elementType = abstractLayoutElement.getLayoutElementTypeName();
Map<String, Object> elConf = customConfig.get(elementType);
AbstractLayoutElement concreteElmt = abstractLayoutElement.createInstance(elConf);
HashMap<String, FormItem> elAttribGui = new HashMap<String, FormItem>();
List<AbstractLayoutAttribute> attributes = concreteElmt.getAvailableAttributes();
for (AbstractLayoutAttribute attrib : attributes) {
String compName = elementType + ELEMENT_ATTRIBUTE_DELIM + attrib.getLayoutAttributeTypeName();
FormItem fi = attrib.getFormItem(compName, styleFlc);
fi.addActionListener(FormEvent.ONCHANGE);
elAttribGui.put(attrib.getLayoutAttributeTypeName(), fi);
}
guiWrapper.put(elementType, elAttribGui);
}
styleFlc.contextPut("guiWrapper", guiWrapper);
}
use of org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement in project OpenOLAT by OpenOLAT.
the class CustomConfigManager method saveCustomConfigAndCompileCSS.
/**
* save the custom css configuration in a reprocessable format (map with inner map)
* also generates the two needed css-files (main / iframe)
* @param customConfig
* @param courseEnvironment
*/
public void saveCustomConfigAndCompileCSS(Map<String, Map<String, Object>> customConfig, CourseEnvironment courseEnvironment) {
VFSContainer themeBase = null;
VFSContainer base = null;
base = (VFSContainer) courseEnvironment.getCourseBaseContainer().resolve(CourseLayoutHelper.LAYOUT_COURSE_SUBFOLDER);
if (base == null) {
base = courseEnvironment.getCourseBaseContainer().createChildContainer(CourseLayoutHelper.LAYOUT_COURSE_SUBFOLDER);
}
themeBase = (VFSContainer) base.resolve("/" + CourseLayoutHelper.CONFIG_KEY_CUSTOM);
if (themeBase == null) {
themeBase = base.createChildContainer(CourseLayoutHelper.CONFIG_KEY_CUSTOM);
}
VFSLeaf configTarget = (VFSLeaf) themeBase.resolve(CUSTOM_CONFIG_XML);
if (configTarget == null) {
configTarget = themeBase.createChildLeaf(CUSTOM_CONFIG_XML);
}
XStream xStream = XStreamHelper.createXStreamInstance();
xStream.toXML(customConfig, configTarget.getOutputStream(false));
// compile the css-files
StringBuffer sbMain = new StringBuffer();
StringBuffer sbIFrame = new StringBuffer();
for (Entry<String, Map<String, Object>> iterator : customConfig.entrySet()) {
String type = iterator.getKey();
Map<String, Object> elementConfig = iterator.getValue();
AbstractLayoutElement configuredLayEl = createLayoutElementByType(type, elementConfig);
sbIFrame.append(configuredLayEl.getCSSForIFrame());
sbMain.append(configuredLayEl.getCSSForMain());
}
// attach line for logo, if there is any to cssForMain:
appendLogoPart(sbMain, themeBase);
VFSLeaf mainFile = (VFSLeaf) themeBase.resolve(MAIN_CSS);
if (mainFile == null)
mainFile = themeBase.createChildLeaf(MAIN_CSS);
VFSLeaf iFrameFile = (VFSLeaf) themeBase.resolve(IFRAME_CSS);
if (iFrameFile == null)
iFrameFile = themeBase.createChildLeaf(IFRAME_CSS);
FileUtils.save(mainFile.getOutputStream(false), sbMain.toString(), "utf-8");
FileUtils.save(iFrameFile.getOutputStream(false), sbIFrame.toString(), "utf-8");
}
use of org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement in project openolat by klemens.
the class CustomConfigManager method saveCustomConfigAndCompileCSS.
/**
* save the custom css configuration in a reprocessable format (map with inner map)
* also generates the two needed css-files (main / iframe)
* @param customConfig
* @param courseEnvironment
*/
public void saveCustomConfigAndCompileCSS(Map<String, Map<String, Object>> customConfig, CourseEnvironment courseEnvironment) {
VFSContainer themeBase = null;
VFSContainer base = null;
base = (VFSContainer) courseEnvironment.getCourseBaseContainer().resolve(CourseLayoutHelper.LAYOUT_COURSE_SUBFOLDER);
if (base == null) {
base = courseEnvironment.getCourseBaseContainer().createChildContainer(CourseLayoutHelper.LAYOUT_COURSE_SUBFOLDER);
}
themeBase = (VFSContainer) base.resolve("/" + CourseLayoutHelper.CONFIG_KEY_CUSTOM);
if (themeBase == null) {
themeBase = base.createChildContainer(CourseLayoutHelper.CONFIG_KEY_CUSTOM);
}
VFSLeaf configTarget = (VFSLeaf) themeBase.resolve(CUSTOM_CONFIG_XML);
if (configTarget == null) {
configTarget = themeBase.createChildLeaf(CUSTOM_CONFIG_XML);
}
XStream xStream = XStreamHelper.createXStreamInstance();
xStream.toXML(customConfig, configTarget.getOutputStream(false));
// compile the css-files
StringBuffer sbMain = new StringBuffer();
StringBuffer sbIFrame = new StringBuffer();
for (Entry<String, Map<String, Object>> iterator : customConfig.entrySet()) {
String type = iterator.getKey();
Map<String, Object> elementConfig = iterator.getValue();
AbstractLayoutElement configuredLayEl = createLayoutElementByType(type, elementConfig);
sbIFrame.append(configuredLayEl.getCSSForIFrame());
sbMain.append(configuredLayEl.getCSSForMain());
}
// attach line for logo, if there is any to cssForMain:
appendLogoPart(sbMain, themeBase);
VFSLeaf mainFile = (VFSLeaf) themeBase.resolve(MAIN_CSS);
if (mainFile == null)
mainFile = themeBase.createChildLeaf(MAIN_CSS);
VFSLeaf iFrameFile = (VFSLeaf) themeBase.resolve(IFRAME_CSS);
if (iFrameFile == null)
iFrameFile = themeBase.createChildLeaf(IFRAME_CSS);
FileUtils.save(mainFile.getOutputStream(false), sbMain.toString(), "utf-8");
FileUtils.save(iFrameFile.getOutputStream(false), sbIFrame.toString(), "utf-8");
}
Aggregations