Search in sources :

Example 36 with Part

use of com.servoy.j2db.persistence.Part in project servoy-client by Servoy.

the class ComponentFactory method getStyleForBasicComponentInternal.

private static Pair<IStyleSheet, IStyleRule> getStyleForBasicComponentInternal(IServiceProvider sp, AbstractBase bc, Form form, Set<Integer> visited) {
    if (bc == null || sp == null)
        return null;
    // Protection agains cycle in form inheritance hierarchy.
    if (!visited.add(new Integer(form.getID())))
        return null;
    Style repos_style = getStyleForForm(sp, form);
    Pair<IStyleSheet, IStyleRule> pair = null;
    if (repos_style != null) {
        IStyleSheet ss = getCSSStyle(sp, repos_style);
        String lookupName = getLookupName(bc);
        if (lookupName != null) {
            String formLookup = "";
            ISupportChilds parent = bc.getParent();
            if (parent instanceof Form) {
                String styleClass = ((Form) parent).getStyleClass();
                if (styleClass != null && styleClass.length() != 0) {
                    formLookup = "form." + styleClass;
                } else {
                    formLookup = "form";
                }
            } else if (parent instanceof Portal) {
                String styleClass = ((Portal) parent).getStyleClass();
                if (styleClass != null && styleClass.length() != 0) {
                    formLookup = "portal." + styleClass;
                } else {
                    formLookup = "portal";
                }
                parent = ((Portal) parent).getParent();
                if (parent instanceof Form) {
                    styleClass = ((Form) parent).getStyleClass();
                    if (styleClass != null && styleClass.length() != 0) {
                        formLookup = "form." + styleClass + ' ' + formLookup;
                    } else {
                        formLookup = "form " + formLookup;
                    }
                }
            }
            IStyleRule s = null;
            String styleClass = (bc instanceof BaseComponent) ? ((BaseComponent) bc).getStyleClass() : null;
            if (bc instanceof Part) {
                styleClass = ((Part) bc).getStyleClass();
            }
            if (lookupName.equals("check") || lookupName.equals("combobox") || "radio".equals(lookupName)) {
                if (styleClass != null && styleClass.length() != 0) {
                    lookupName += '.' + styleClass;
                }
                lookupName = formLookup + ' ' + lookupName;
                s = ss.getCSSRule(lookupName);
                if (s.getAttributeCount() > 0)
                    return new Pair<IStyleSheet, IStyleRule>(ss, s);
                else
                    lookupName = "field";
            }
            if (styleClass != null && styleClass.length() != 0) {
                lookupName += '.' + styleClass;
            }
            lookupName = formLookup + ' ' + lookupName;
            s = ss.getCSSRule(lookupName);
            pair = new Pair<IStyleSheet, IStyleRule>(ss, s);
        // see BoxPainter for getBorder/getInsets/getLength examples
        }
    }
    if ((pair == null || pair.getRight() == null || (pair.getRight()).getAttributeCount() == 0)) {
        if (sp.getFlattenedSolution() != null) {
            List<Form> formHierarchy = sp.getFlattenedSolution().getFormHierarchy(form);
            for (int i = 1; i < formHierarchy.size(); i++) {
                pair = getStyleForBasicComponentInternal(sp, bc, formHierarchy.get(i), visited);
                if (pair != null && pair.getRight() != null && (pair.getRight()).getAttributeCount() != 0) {
                    break;
                }
            }
        }
    }
    return pair;
}
Also used : BaseComponent(com.servoy.j2db.persistence.BaseComponent) IStyleSheet(com.servoy.j2db.util.IStyleSheet) ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) Part(com.servoy.j2db.persistence.Part) Style(com.servoy.j2db.persistence.Style) IStyleRule(com.servoy.j2db.util.IStyleRule) Portal(com.servoy.j2db.persistence.Portal) RuntimePortal(com.servoy.j2db.ui.scripting.RuntimePortal)

Aggregations

Part (com.servoy.j2db.persistence.Part)36 Point (java.awt.Point)17 Form (com.servoy.j2db.persistence.Form)14 IPersist (com.servoy.j2db.persistence.IPersist)9 IFormElement (com.servoy.j2db.persistence.IFormElement)8 Dimension (java.awt.Dimension)8 ArrayList (java.util.ArrayList)8 BaseComponent (com.servoy.j2db.persistence.BaseComponent)7 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)6 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)6 IStyleRule (com.servoy.j2db.util.IStyleRule)5 IStyleSheet (com.servoy.j2db.util.IStyleSheet)5 FormController (com.servoy.j2db.FormController)4 IForm (com.servoy.j2db.IForm)4 Color (java.awt.Color)4 Portal (com.servoy.j2db.persistence.Portal)3 IComponent (com.servoy.j2db.ui.IComponent)3 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3