Search in sources :

Example 1 with AbstractLayoutAttribute

use of org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute 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);
}
Also used : AbstractLayoutElement(org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FormItem(org.olat.core.gui.components.form.flexible.FormItem) AbstractLayoutAttribute(org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with AbstractLayoutAttribute

use of org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute 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);
}
Also used : AbstractLayoutElement(org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FormItem(org.olat.core.gui.components.form.flexible.FormItem) AbstractLayoutAttribute(org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with AbstractLayoutAttribute

use of org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute in project OpenOLAT by OpenOLAT.

the class AbstractLayoutElement method initAttributeConfig.

protected void initAttributeConfig() {
    if (getConfig() != null) {
        List<AbstractLayoutAttribute> avAttribs = getAvailableAttributes();
        for (AbstractLayoutAttribute abstractLayoutAttribute : avAttribs) {
            String type = abstractLayoutAttribute.getLayoutAttributeTypeName();
            if (type.equals(PreviewLA.IDENTIFIER)) {
                StringBuffer sbPreviewStyle = new StringBuffer();
                prepareAttributePart(0, sbPreviewStyle);
                abstractLayoutAttribute.setAttributeValue(sbPreviewStyle.toString());
            } else {
                abstractLayoutAttribute.setAttributeValue((String) getConfig().get(type));
            }
        }
    }
}
Also used : AbstractLayoutAttribute(org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute)

Example 4 with AbstractLayoutAttribute

use of org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute in project OpenOLAT by OpenOLAT.

the class AbstractLayoutElement method prepareAttributePart.

protected void prepareAttributePart(int rel, StringBuffer sb) {
    for (AbstractLayoutAttribute attrib : availableAttributes) {
        if (StringHelper.containsNonWhitespace(attrib.getAttributeValue())) {
            sb.append("\t");
            sb.append(attrib.getRelativeCompiledAttribute(rel));
        }
    }
}
Also used : AbstractLayoutAttribute(org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute)

Example 5 with AbstractLayoutAttribute

use of org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute in project openolat by klemens.

the class AbstractLayoutElement method initAttributeConfig.

protected void initAttributeConfig() {
    if (getConfig() != null) {
        List<AbstractLayoutAttribute> avAttribs = getAvailableAttributes();
        for (AbstractLayoutAttribute abstractLayoutAttribute : avAttribs) {
            String type = abstractLayoutAttribute.getLayoutAttributeTypeName();
            if (type.equals(PreviewLA.IDENTIFIER)) {
                StringBuffer sbPreviewStyle = new StringBuffer();
                prepareAttributePart(0, sbPreviewStyle);
                abstractLayoutAttribute.setAttributeValue(sbPreviewStyle.toString());
            } else {
                abstractLayoutAttribute.setAttributeValue((String) getConfig().get(type));
            }
        }
    }
}
Also used : AbstractLayoutAttribute(org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute)

Aggregations

AbstractLayoutAttribute (org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute)6 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 AbstractLayoutElement (org.olat.course.config.ui.courselayout.elements.AbstractLayoutElement)2