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;
}
Aggregations