Search in sources :

Example 31 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method getDialogContainer.

/**
 * Retrieves the configured dialog container page
 *
 * @param context FacesContext
 * @return The container page
 */
protected String getDialogContainer(FacesContext context) {
    String container;
    // determine which kind of container we need to return, if the
    // external session flag is set then use the plain container
    Object obj = context.getExternalContext().getSessionMap().get(EXTERNAL_CONTAINER_SESSION);
    if (obj != null && obj instanceof Boolean && ((Boolean) obj).booleanValue()) {
        if ((this.plainDialogContainer == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
            ConfigService configSvc = Application.getConfigService(context);
            Config globalConfig = configSvc.getGlobalConfig();
            if (globalConfig != null) {
                this.plainDialogContainer = globalConfig.getConfigElement("plain-dialog-container").getValue();
            }
        }
        container = this.plainDialogContainer;
    } else {
        if ((this.dialogContainer == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
            ConfigService configSvc = Application.getConfigService(context);
            Config globalConfig = configSvc.getGlobalConfig();
            if (globalConfig != null) {
                this.dialogContainer = globalConfig.getConfigElement("dialog-container").getValue();
            }
        }
        container = this.dialogContainer;
    }
    if (logger.isDebugEnabled())
        logger.debug("Using dialog container: " + container);
    return container;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig) DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) Config(org.springframework.extensions.config.Config)

Example 32 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class CreateCompositeRuleWizard method getWizardContainerViewId.

private String getWizardContainerViewId(FacesContext context) {
    String viewId = null;
    ConfigService configSvc = Application.getConfigService(context);
    Config globalConfig = configSvc.getGlobalConfig();
    if (globalConfig != null) {
        viewId = globalConfig.getConfigElement("wizard-container").getValue();
    } else {
        logger.error("plain-dialog-container configuraion setting is not found");
    }
    return viewId;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) Config(org.springframework.extensions.config.Config)

Example 33 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class CreateRuleWizard method getModelTypes.

/**
 * Returns a list of the types available in the repository
 *
 * @return List of SelectItem objects
 */
public List<SelectItem> getModelTypes() {
    if ((this.modelTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext context = FacesContext.getCurrentInstance();
        ConfigService svc = Application.getConfigService(context);
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("subtypes");
            if (typesCfg != null) {
                this.modelTypes = new ArrayList<SelectItem>();
                for (ConfigElement child : typesCfg.getChildren()) {
                    QName idQName = Repository.resolveToQName(child.getAttribute("name"));
                    // get the display label from config
                    String label = Utils.getDisplayLabel(context, child);
                    // if there wasn't a client based label try and get it from the dictionary
                    if (label == null) {
                        TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
                        if (typeDef != null) {
                            label = typeDef.getTitle(this.getDictionaryService());
                        } else {
                            label = idQName.getLocalName();
                        }
                    }
                    this.modelTypes.add(new SelectItem(idQName.toString(), label));
                }
                // make sure the list is sorted by the label
                QuickSort sorter = new QuickSort(this.modelTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
                sorter.sort();
            } else {
                logger.warn("Could not find 'subtypes' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
    return this.modelTypes;
}
Also used : FacesContext(javax.faces.context.FacesContext) QuickSort(org.alfresco.web.data.QuickSort) ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config) SelectItem(javax.faces.model.SelectItem) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 34 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class ImagePickerRadioRenderer method encodeChildren.

/**
 * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
@SuppressWarnings("unchecked")
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
    if (component.isRendered() == false) {
        return;
    }
    UIImagePicker imagePicker = (UIImagePicker) component;
    Map attrs = imagePicker.getAttributes();
    Integer cols = (Integer) attrs.get("columns");
    if (cols != null && cols instanceof Integer) {
        this.columns = cols.intValue();
    }
    // retrieve the onclick handler, if there is one
    String onclick = (String) attrs.get("onclick");
    ResponseWriter out = context.getResponseWriter();
    // determine whether the options should be pulled from config or
    // from the child components
    String configSection = (String) attrs.get("configSection");
    if (configSection != null && configSection.length() > 0) {
        // render all the icons from the list that appear in the given
        // config section
        ConfigService cfgService = Application.getConfigService(context);
        Config cfg = cfgService.getConfig(configSection);
        if (cfg != null) {
            ConfigElement iconsCfg = cfg.getConfigElement("icons");
            if (iconsCfg != null) {
                for (ConfigElement icon : iconsCfg.getChildren()) {
                    String iconName = icon.getAttribute("name");
                    String iconPath = icon.getAttribute("path");
                    if (iconName != null && iconPath != null) {
                        UIListItem item = new UIListItem();
                        item.setValue(iconName);
                        item.setImage(iconPath);
                        renderItem(context, out, imagePicker, item, onclick);
                    }
                }
            }
        }
    } else {
        try {
            // get the child components
            for (Iterator i = imagePicker.getChildren().iterator(); i.hasNext(); ) /**/
            {
                UIComponent child = (UIComponent) i.next();
                if (child instanceof UIListItems) {
                    // get the value of the list items component and iterate
                    // through it's collection
                    Object listItems = ((UIListItems) child).getValue();
                    if (listItems instanceof Collection) {
                        Iterator iter = ((Collection) listItems).iterator();
                        while (iter.hasNext()) {
                            UIListItem item = (UIListItem) iter.next();
                            if (item.isRendered()) {
                                renderItem(context, out, imagePicker, item, onclick);
                            }
                        }
                    }
                } else if (child instanceof UIListItem && child.isRendered() == true) {
                    // found a valid UIListItem child to render
                    UIListItem item = (UIListItem) child;
                    renderItem(context, out, imagePicker, item, onclick);
                }
            }
        } catch (PropertyNotFoundException pnfe) {
            // method specified in the value binding expression
            if (logger.isWarnEnabled())
                logger.warn("Failed to retrieve icons: " + pnfe.toString());
            out.write(Application.getMessage(context, "no_icons_found"));
        }
    }
    // if we are in the middle of a row, close it
    if (open) {
        out.write("</tr>\n");
    }
}
Also used : PropertyNotFoundException(javax.faces.el.PropertyNotFoundException) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config) UIComponent(javax.faces.component.UIComponent) UIListItems(org.alfresco.web.ui.common.component.UIListItems) UIImagePicker(org.alfresco.web.ui.common.component.UIImagePicker) ConfigService(org.springframework.extensions.config.ConfigService) ResponseWriter(javax.faces.context.ResponseWriter) UIListItem(org.alfresco.web.ui.common.component.UIListItem) Iterator(java.util.Iterator) Collection(java.util.Collection) Map(java.util.Map)

Example 35 with ConfigService

use of org.springframework.extensions.config.ConfigService in project acs-community-packaging by Alfresco.

the class WebClientConfigBootstrap method init.

/**
 * @deprecated
 */
public void init() {
    if (this.applicationContext.containsBean("webClientConfigService") == true) {
        ConfigService configService = (ConfigService) this.applicationContext.getBean("webClientConfigService");
        if (configService != null) {
            setConfigService(configService);
            register();
        }
    }
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService)

Aggregations

ConfigService (org.springframework.extensions.config.ConfigService)35 Config (org.springframework.extensions.config.Config)28 ConfigElement (org.springframework.extensions.config.ConfigElement)18 SelectItem (javax.faces.model.SelectItem)10 QuickSort (org.alfresco.web.data.QuickSort)9 FacesContext (javax.faces.context.FacesContext)7 DialogConfig (org.alfresco.web.config.DialogsConfigElement.DialogConfig)5 WizardConfig (org.alfresco.web.config.WizardsConfigElement.WizardConfig)5 ClientConfigElement (org.alfresco.web.config.ClientConfigElement)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)3 QName (org.alfresco.service.namespace.QName)3 IOException (java.io.IOException)2 Map (java.util.Map)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 PropertySheetConfigElement (org.alfresco.web.config.PropertySheetConfigElement)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 UIComponent (javax.faces.component.UIComponent)1 ResponseWriter (javax.faces.context.ResponseWriter)1 PropertyNotFoundException (javax.faces.el.PropertyNotFoundException)1