Search in sources :

Example 11 with ISupportChilds

use of com.servoy.j2db.persistence.ISupportChilds 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

ISupportChilds (com.servoy.j2db.persistence.ISupportChilds)11 Form (com.servoy.j2db.persistence.Form)6 IPersist (com.servoy.j2db.persistence.IPersist)6 Solution (com.servoy.j2db.persistence.Solution)4 AbstractBase (com.servoy.j2db.persistence.AbstractBase)3 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 JSONObject (org.json.JSONObject)3 FlattenedSolution (com.servoy.j2db.FlattenedSolution)2 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)2 IPersistVisitor (com.servoy.j2db.persistence.IPersistVisitor)2 IRootObject (com.servoy.j2db.persistence.IRootObject)2 LayoutContainer (com.servoy.j2db.persistence.LayoutContainer)2 RepositoryException (com.servoy.j2db.persistence.RepositoryException)2 TableNode (com.servoy.j2db.persistence.TableNode)2 UUID (com.servoy.j2db.util.UUID)2 Point (java.awt.Point)2