protected void verifyComponents(ComponentLibrary library) throws CdkException { // Verify types and classes. Do it first to be sure what all all values are set before second // stage. for (ComponentModel component : library.getComponents()) { try { verifyComponentType(component); } catch (RuntimeException e) { throw new CdkException("Caught error when verifying component " + component, e); } } // Verify component attributes HashSet<ComponentModel> verified = Sets.newHashSet(); for (ComponentModel component : library.getComponents()) { try { verifyComponentType(component); verifyComponentAttributes(library, component, verified); // generate component family if missing if (null == component.getFamily()) { component.setFamily(namingConventions.inferUIComponentFamily(component.getId())); } // add facelet tag if missing if (component.getTags().isEmpty()) { TagModel tag = new TagModel(); component.getTags().add(tag); tag.setName(namingConventions.inferTagName(component.getId())); tag.setGenerate(false); tag.setType(TagType.Facelets); } } catch (RuntimeException e) { throw new CdkException("Caught error when verifying component " + component, e); } } }
private void copyRendererAttributes(final RendererModel renderer, ComponentModel component) { for (PropertyBase property : renderer.getAttributes()) { PropertyBase attribute = component.getOrCreateAttribute(property.getName()); attribute.merge(property); verifyAttribute(attribute, component); } renderer.setFamily(component.getFamily()); }
/** * @param library * @param component * @param verified */ protected void verifyComponentAttributes( ComponentLibrary library, final ComponentModel component, Collection<ComponentModel> verified) { // There is potential StackOverflow, so we process only components which have not been // verified before. if (!verified.contains(component)) { // Propagate attributes from parent component, if any. verified.add(component); if (null != component.getBaseClass()) { try { // Step one, lookup for parent. ComponentModel parentComponent = findParent(library.getComponents(), component); component.setParent(parentComponent); if (null == component.getFamily()) { component.setFamily(parentComponent.getFamily()); } // To be sure what all properties for parent component were propagated. verifyComponentAttributes(library, parentComponent, verified); for (PropertyBase parentAttribute : parentComponent.getAttributes()) { PropertyBase attribute = component.getOrCreateAttribute(parentAttribute.getName()); attribute.merge(parentAttribute); // already exists in parent component. attribute.setGenerate(false); } } catch (NoSuchElementException e) { // No parent component in the library } } // Check attributes. for (PropertyBase attribute : component.getAttributes()) { verifyAttribute(attribute, component); } // compact(component.getAttributes()); // Check renderers. // Check Tag for (TagModel tag : component.getTags()) { verifyTag(tag, component.getId(), DEFAULT_COMPONENT_HANDLER); } verifyDescription(component); for (FacetModel facet : component.getFacets()) { verifyDescription(facet); } } }