Search in sources :

Example 1 with PropertyConfig

use of org.alfresco.web.config.PropertySheetConfigElement.PropertyConfig in project acs-community-packaging by Alfresco.

the class UIPropertySheet method createComponentsFromConfig.

/**
 * Creates all the property components required to display the properties specified
 * in an external config file.
 *
 * @param context JSF context
 * @param items Collection of properties to render (driven from configuration)
 * @throws IOException
 */
@SuppressWarnings("unchecked")
private void createComponentsFromConfig(FacesContext context, Collection<ItemConfig> items) throws IOException {
    for (ItemConfig item : items) {
        String id = null;
        PropertySheetItem propSheetItem = null;
        // create the appropriate component
        if (item instanceof PropertyConfig) {
            id = PROP_ID_PREFIX + item.getName();
            propSheetItem = (PropertySheetItem) context.getApplication().createComponent(RepoConstants.ALFRESCO_FACES_PROPERTY);
        } else if (item instanceof AssociationConfig) {
            id = ASSOC_ID_PREFIX + item.getName();
            propSheetItem = (PropertySheetItem) context.getApplication().createComponent(RepoConstants.ALFRESCO_FACES_ASSOCIATION);
        } else if (item instanceof ChildAssociationConfig) {
            id = ASSOC_ID_PREFIX + item.getName();
            propSheetItem = (PropertySheetItem) context.getApplication().createComponent(RepoConstants.ALFRESCO_FACES_CHILD_ASSOCIATION);
        } else if (item instanceof SeparatorConfig) {
            id = SEP_ID_PREFIX + item.getName();
            propSheetItem = (PropertySheetItem) context.getApplication().createComponent(RepoConstants.ALFRESCO_FACES_SEPARATOR);
        }
        // now setup the common stuff across all component types
        if (propSheetItem != null) {
            FacesHelper.setupComponentId(context, propSheetItem, id);
            propSheetItem.setName(item.getName());
            propSheetItem.setConverter(item.getConverter());
            propSheetItem.setComponentGenerator(item.getComponentGenerator());
            propSheetItem.setIgnoreIfMissing(item.getIgnoreIfMissing());
            String displayLabel = item.getDisplayLabel();
            if (item.getDisplayLabelId() != null) {
                String label = Application.getMessage(context, item.getDisplayLabelId());
                if (label != null) {
                    displayLabel = label;
                }
            }
            propSheetItem.setDisplayLabel(displayLabel);
            // should be read only set it as such
            if (isReadOnly() || item.isReadOnly()) {
                propSheetItem.setReadOnly(true);
            }
            this.getChildren().add(propSheetItem);
            if (logger.isDebugEnabled())
                logger.debug("Created property sheet item component " + propSheetItem + "(" + propSheetItem.getClientId(context) + ") for '" + item.getName() + "' and added it to property sheet " + this);
        }
    }
}
Also used : ItemConfig(org.alfresco.web.config.PropertySheetConfigElement.ItemConfig) AssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.AssociationConfig) ChildAssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.ChildAssociationConfig) ChildAssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.ChildAssociationConfig) SeparatorConfig(org.alfresco.web.config.PropertySheetConfigElement.SeparatorConfig) PropertyConfig(org.alfresco.web.config.PropertySheetConfigElement.PropertyConfig)

Aggregations

AssociationConfig (org.alfresco.web.config.PropertySheetConfigElement.AssociationConfig)1 ChildAssociationConfig (org.alfresco.web.config.PropertySheetConfigElement.ChildAssociationConfig)1 ItemConfig (org.alfresco.web.config.PropertySheetConfigElement.ItemConfig)1 PropertyConfig (org.alfresco.web.config.PropertySheetConfigElement.PropertyConfig)1 SeparatorConfig (org.alfresco.web.config.PropertySheetConfigElement.SeparatorConfig)1