Search in sources :

Example 1 with WODynamicGroup

use of com.webobjects.appserver._private.WODynamicGroup in project wonder-slim by undur.

the class WOHTMLWebObjectTag method template.

public WOElement template() {
    NSMutableArray nsmutablearray = null;
    if (_children == null) {
        return null;
    }
    Enumeration enumeration = _children.objectEnumerator();
    if (enumeration != null) {
        nsmutablearray = new NSMutableArray(_children.count());
        StringBuilder stringbuffer = new StringBuilder(128);
        while (enumeration.hasMoreElements()) {
            Object obj1 = enumeration.nextElement();
            if (obj1 instanceof String) {
                stringbuffer.append((String) obj1);
            } else {
                if (stringbuffer.length() > 0) {
                    WOHTMLBareString wohtmlbarestring1 = new WOHTMLBareString(stringbuffer.toString());
                    nsmutablearray.addObject(wohtmlbarestring1);
                    stringbuffer.setLength(0);
                }
                nsmutablearray.addObject(obj1);
            }
        }
        if (stringbuffer.length() > 0) {
            WOHTMLBareString wohtmlbarestring = new WOHTMLBareString(stringbuffer.toString());
            stringbuffer.setLength(0);
            nsmutablearray.addObject(wohtmlbarestring);
        }
    }
    WOElement obj = null;
    if (nsmutablearray != null && nsmutablearray.count() == 1) {
        Object obj2 = nsmutablearray.objectAtIndex(0);
        if (obj2 instanceof WOComponentReference) {
            obj = new WODynamicGroup(_name, null, (WOElement) obj2);
        } else {
            obj = (WOElement) obj2;
        }
    } else {
        obj = new WODynamicGroup(_name, null, nsmutablearray);
    }
    return obj;
}
Also used : Enumeration(java.util.Enumeration) NSMutableArray(com.webobjects.foundation.NSMutableArray) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOComponentReference(com.webobjects.appserver._private.WOComponentReference) WOElement(com.webobjects.appserver.WOElement)

Example 2 with WODynamicGroup

use of com.webobjects.appserver._private.WODynamicGroup in project wonder-slim by undur.

the class WOHTMLWebObjectTag method template.

public WOElement template() {
    NSMutableArray nsmutablearray = null;
    if (_children == null) {
        return null;
    }
    Enumeration enumeration = _children.objectEnumerator();
    if (enumeration != null) {
        nsmutablearray = new NSMutableArray(_children.count());
        StringBuilder stringbuffer = new StringBuilder(128);
        while (enumeration.hasMoreElements()) {
            Object obj1 = enumeration.nextElement();
            if (obj1 instanceof String) {
                stringbuffer.append((String) obj1);
            } else {
                if (stringbuffer.length() > 0) {
                    WOHTMLBareString wohtmlbarestring1 = new WOHTMLBareString(stringbuffer.toString());
                    nsmutablearray.addObject(wohtmlbarestring1);
                    stringbuffer.setLength(0);
                }
                nsmutablearray.addObject(obj1);
            }
        }
        if (stringbuffer.length() > 0) {
            WOHTMLBareString wohtmlbarestring = new WOHTMLBareString(stringbuffer.toString());
            stringbuffer.setLength(0);
            nsmutablearray.addObject(wohtmlbarestring);
        }
    }
    WOElement obj = null;
    if (nsmutablearray != null && nsmutablearray.count() == 1) {
        Object obj2 = nsmutablearray.objectAtIndex(0);
        if (obj2 instanceof WOComponentReference) {
            obj = new WODynamicGroup(_name, null, (WOElement) obj2);
        } else {
            obj = (WOElement) obj2;
        }
    } else {
        obj = new WODynamicGroup(_name, null, nsmutablearray);
    }
    return obj;
}
Also used : Enumeration(java.util.Enumeration) NSMutableArray(com.webobjects.foundation.NSMutableArray) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOComponentReference(com.webobjects.appserver._private.WOComponentReference) WOElement(com.webobjects.appserver.WOElement)

Example 3 with WODynamicGroup

use of com.webobjects.appserver._private.WODynamicGroup in project wonder-slim by undur.

the class ERXWOComponentContent method template.

private WOElement template(WOComponent component) {
    WOElement content = component._childTemplate();
    WOElement result = null;
    String templateName = (_templateName == null) ? null : (String) _templateName.valueInComponent(component);
    if (content != null && content.getClass() == WODynamicGroup.class) {
        WODynamicGroup group = (WODynamicGroup) content;
        if (templateName == null) {
            // MS: If you don't set a template name, then let's construct all the children of
            // this element that are NOT ERXWOTemplate's, so we don't double-display.  This lets
            // you use an ERXWOComponentContent and have it just act like a "default" template
            // that skips all the children that are explicitly wrapped in an ERXWOTemplate.
            NSMutableArray<WOElement> originalChildrenElements = group.childrenElements();
            if (originalChildrenElements != null && originalChildrenElements.count() > 0) {
                NSMutableArray<WOElement> nonTemplateChildrenElements = new NSMutableArray<>();
                for (WOElement originalChild : originalChildrenElements) {
                    if (!(originalChild instanceof ERXWOTemplate)) {
                        nonTemplateChildrenElements.addObject(originalChild);
                    }
                }
                result = new WODynamicGroup(null, null, nonTemplateChildrenElements);
            }
        } else {
            for (Enumeration e = group.childrenElements().objectEnumerator(); e.hasMoreElements() && result == null; ) {
                WOElement current = (WOElement) e.nextElement();
                if (current instanceof ERXWOTemplate) {
                    ERXWOTemplate template = (ERXWOTemplate) current;
                    String name = template.templateName(component);
                    if (name.equals(templateName)) {
                        result = template;
                    }
                }
            }
        }
    } else if (content instanceof ERXWOTemplate) {
        ERXWOTemplate template = (ERXWOTemplate) content;
        String name = template.templateName(component);
        if (name.equals(templateName)) {
            result = template;
        }
    } else if (templateName == null) {
        result = content;
    }
    return result;
}
Also used : ERXWOTemplate(er.extensions.components.conditionals.ERXWOTemplate) Enumeration(java.util.Enumeration) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) NSMutableArray(com.webobjects.foundation.NSMutableArray) WOHTMLBareString(com.webobjects.appserver._private.WOHTMLBareString) WOElement(com.webobjects.appserver.WOElement)

Example 4 with WODynamicGroup

use of com.webobjects.appserver._private.WODynamicGroup in project wonder-slim by undur.

the class AjaxTabbedPanel method findTabs.

/**
 * Looks through the child components to locate the AjaxTabbedPanelTabs that are controlled by this panel.
 * Tabs without an explicit id attributed are assigned a calculated one.
 *
 * @param template the graph of elements passed to the constructor.
 */
private void findTabs(WODynamicGroup template) {
    if (template == null || template.childrenElements() == null)
        return;
    NSArray children = template.childrenElements();
    for (int i = 0; i < children.count(); i++) {
        WOElement child = (WOElement) children.objectAtIndex(i);
        if (child instanceof AjaxTabbedPanelTab) {
            AjaxTabbedPanelTab childTab = (AjaxTabbedPanelTab) child;
            // The tabs need to have an id attribute so we assign one if needed
            if (childTab.id() == null) {
                childTab.setParentId(id);
                childTab.setTabNumber(new WOConstantValueAssociation("_pane_" + tabs.count()));
            }
            tabs.addObject(childTab);
        } else if (child instanceof WODynamicGroup) {
            findTabs((WODynamicGroup) child);
        }
    }
}
Also used : NSArray(com.webobjects.foundation.NSArray) WODynamicGroup(com.webobjects.appserver._private.WODynamicGroup) WOConstantValueAssociation(com.webobjects.appserver._private.WOConstantValueAssociation) WOElement(com.webobjects.appserver.WOElement)

Aggregations

WOElement (com.webobjects.appserver.WOElement)4 WODynamicGroup (com.webobjects.appserver._private.WODynamicGroup)4 WOHTMLBareString (com.webobjects.appserver._private.WOHTMLBareString)3 NSMutableArray (com.webobjects.foundation.NSMutableArray)3 Enumeration (java.util.Enumeration)3 WOComponentReference (com.webobjects.appserver._private.WOComponentReference)2 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)1 NSArray (com.webobjects.foundation.NSArray)1 ERXWOTemplate (er.extensions.components.conditionals.ERXWOTemplate)1