Search in sources :

Example 1 with PropertySheetConfigElement

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

the class UIPropertySheet method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    int howManyChildren = getChildren().size();
    Boolean externalConfig = (Boolean) getAttributes().get("externalConfig");
    // generate a variable name to use if necessary
    if (this.variable == null) {
        this.variable = DEFAULT_VAR_NAME;
    }
    // force retrieval of node info
    Node node = getNode();
    if (howManyChildren == 0) {
        if (externalConfig != null && externalConfig.booleanValue()) {
            // configure the component using the config service
            if (logger.isDebugEnabled())
                logger.debug("Configuring property sheet using ConfigService");
            // get the properties to display
            ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
            Config configProps = null;
            if (getConfigArea() == null) {
                configProps = configSvc.getConfig(node);
            } else {
                // only look within the given area
                configProps = configSvc.getConfig(node, new ConfigLookupContext(getConfigArea()));
            }
            PropertySheetConfigElement itemsToDisplay = (PropertySheetConfigElement) configProps.getConfigElement("property-sheet");
            if (itemsToDisplay != null) {
                Collection<ItemConfig> itemsToRender = null;
                if (this.getMode().equalsIgnoreCase(EDIT_MODE)) {
                    itemsToRender = itemsToDisplay.getEditableItemsToShow().values();
                    if (logger.isDebugEnabled())
                        logger.debug("Items to render: " + itemsToDisplay.getEditableItemNamesToShow());
                } else {
                    itemsToRender = itemsToDisplay.getItemsToShow().values();
                    if (logger.isDebugEnabled())
                        logger.debug("Items to render: " + itemsToDisplay.getItemNamesToShow());
                }
                createComponentsFromConfig(context, itemsToRender);
            } else {
                if (logger.isDebugEnabled())
                    logger.debug("There are no items to render!");
            }
        } else {
            // show all the properties for the current node
            if (logger.isDebugEnabled())
                logger.debug("Configuring property sheet using node's current state");
            createComponentsFromNode(context, node);
        }
    }
    // put the node in the session if it is not there already
    Map sessionMap = getFacesContext().getExternalContext().getSessionMap();
    sessionMap.put(this.variable, node);
    if (logger.isDebugEnabled())
        logger.debug("Put node into session with key '" + this.variable + "': " + node);
    super.encodeBegin(context);
}
Also used : ItemConfig(org.alfresco.web.config.PropertySheetConfigElement.ItemConfig) ConfigLookupContext(org.springframework.extensions.config.ConfigLookupContext) ConfigService(org.springframework.extensions.config.ConfigService) PropertySheetConfigElement(org.alfresco.web.config.PropertySheetConfigElement) PropertyConfig(org.alfresco.web.config.PropertySheetConfigElement.PropertyConfig) SeparatorConfig(org.alfresco.web.config.PropertySheetConfigElement.SeparatorConfig) AssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.AssociationConfig) ChildAssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.ChildAssociationConfig) ItemConfig(org.alfresco.web.config.PropertySheetConfigElement.ItemConfig) Config(org.springframework.extensions.config.Config) Node(org.alfresco.web.bean.repository.Node) Map(java.util.Map)

Example 2 with PropertySheetConfigElement

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

the class DocumentPropertiesDialog method getOtherPropertiesPresent.

/**
 * Determines whether this document has any other properties other than the
 * default set to display to the user.
 *
 * @return true of there are properties to show, false otherwise
 */
public boolean getOtherPropertiesPresent() {
    if ((this.hasOtherProperties == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        // we need to use the config service to see whether there are any
        // editable properties configured for this document.
        ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config configProps = configSvc.getConfig(this.editableNode);
        PropertySheetConfigElement propsToDisplay = (PropertySheetConfigElement) configProps.getConfigElement("property-sheet");
        if (propsToDisplay != null && propsToDisplay.getEditableItemNamesToShow().size() > 0) {
            this.hasOtherProperties = Boolean.TRUE;
        } else {
            this.hasOtherProperties = Boolean.FALSE;
        }
    }
    return this.hasOtherProperties.booleanValue();
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) PropertySheetConfigElement(org.alfresco.web.config.PropertySheetConfigElement) Config(org.springframework.extensions.config.Config)

Aggregations

PropertySheetConfigElement (org.alfresco.web.config.PropertySheetConfigElement)2 Config (org.springframework.extensions.config.Config)2 ConfigService (org.springframework.extensions.config.ConfigService)2 Map (java.util.Map)1 Node (org.alfresco.web.bean.repository.Node)1 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 ConfigLookupContext (org.springframework.extensions.config.ConfigLookupContext)1