/** * Resolves the macros in a single property.<p> * * @param property the property in which macros should be resolved * @param resolver the macro resolver to use * * @return a new property with resolved macros */ public static CmsXmlContentProperty resolveMacrosInProperty( CmsXmlContentProperty property, I_CmsMacroResolver resolver) { String propName = property.getName(); CmsXmlContentProperty result = new CmsXmlContentProperty( propName, property.getType(), property.getWidget(), resolver.resolveMacros(property.getWidgetConfiguration()), property.getRuleRegex(), property.getRuleType(), property.getDefault(), resolver.resolveMacros(property.getNiceName()), resolver.resolveMacros(property.getDescription()), resolver.resolveMacros(property.getError()), property.isPreferFolder() ? "true" : "false"); return result; }
/** * Creates a deep copy of a property configuration map.<p> * * @param propConfig the property configuration which should be copied * * @return a copy of the property configuration */ public static Map<String, CmsXmlContentProperty> copyPropertyConfiguration( Map<String, CmsXmlContentProperty> propConfig) { Map<String, CmsXmlContentProperty> result = new LinkedHashMap<String, CmsXmlContentProperty>(); for (Map.Entry<String, CmsXmlContentProperty> entry : propConfig.entrySet()) { String key = entry.getKey(); CmsXmlContentProperty propDef = entry.getValue(); result.put(key, propDef.copy()); } return result; }
/** * Helper method used to create the configuration attributes for a CmsPreferenceData bean.<p> * * @param pref the preference data * @param elem the element in which the attributes should be created */ public static void fillAttributes(CmsPreferenceData pref, Element elem) { CmsXmlContentProperty prop = pref.getPropertyDefinition(); for (String[] attrToSet : new String[][] { {I_CmsXmlConfiguration.A_VALUE, pref.getDefaultValue()}, {CmsWorkplaceConfiguration.A_NICE_NAME, prop.getNiceName()}, {CmsWorkplaceConfiguration.A_DESCRIPTION, prop.getDescription()}, {CmsWorkplaceConfiguration.A_WIDGET, prop.getWidget()}, {CmsWorkplaceConfiguration.A_WIDGET_CONFIG, prop.getWidgetConfiguration()}, {CmsWorkplaceConfiguration.A_RULE_REGEX, prop.getRuleRegex()}, {CmsWorkplaceConfiguration.A_ERROR, prop.getError()}}) { String attrName = attrToSet[0]; String value = attrToSet[1]; if (value != null) { elem.addAttribute(attrName, value); } } }
/** * @see org.opencms.configuration.preferences.I_CmsPreference#getPropertyDefinition(org.opencms.file.CmsObject) */ @Override public CmsXmlContentProperty getPropertyDefinition(CmsObject cms) { CmsXmlContentProperty configProp = m_prefData.getPropertyDefinition(); CmsXmlContentProperty wrappedProp = m_wrappedPreference.getPropertyDefinition(cms); CmsXmlContentProperty prop = new CmsXmlContentProperty( getName(), //name "string", //type firstNotNull(configProp.getWidget(), wrappedProp.getWidget()), //widget firstNotNull(configProp.getWidgetConfiguration(), wrappedProp.getWidgetConfiguration()), //widgetconfig firstNotNull(configProp.getRuleRegex(), wrappedProp.getRuleRegex()), //regex firstNotNull(configProp.getRuleType(), wrappedProp.getRuleType()), //ruletype firstNotNull(configProp.getDefault(), wrappedProp.getDefault()), firstNotNull(configProp.getNiceName(), wrappedProp.getNiceName()), //nicename firstNotNull(configProp.getDescription(), wrappedProp.getDescription()), //description firstNotNull(configProp.getError(), wrappedProp.getError()), //error null//preferfolder ); return prop; }
/** * Copies this property definition.<p> * * @return a new copy of the current property definition */ public CmsXmlContentProperty copy() { return new CmsXmlContentProperty( m_name, m_type, m_widget, m_widgetConfiguration, m_ruleRegex, m_ruleType, m_default, m_niceName, m_description, m_error, m_preferFolder); }
/** * Extends the given properties with the default values * from property configuration.<p> * * @param cms the current CMS context * @param propertyConfig the property configuration * @param properties the properties to extend * * @return a merged map of properties */ public static Map<String, String> mergeDefaults( CmsObject cms, Map<String, CmsXmlContentProperty> propertyConfig, Map<String, String> properties) { Map<String, String> result = new HashMap<String, String>(); if (propertyConfig != null) { for (Map.Entry<String, CmsXmlContentProperty> entry : propertyConfig.entrySet()) { CmsXmlContentProperty prop = entry.getValue(); String value = getPropValueIds(cms, prop.getType(), prop.getDefault()); if (value != null) { result.put(entry.getKey(), value); } } } result.putAll(properties); return result; }
/** * Initializes the element settings for this content handler.<p> * * @param root the "settings" element from the appinfo node of the XML content definition * @param contentDefinition the content definition the element settings belong to */ protected void initSettings(Element root, CmsXmlContentDefinition contentDefinition) { Iterator<Element> itProperties = CmsXmlGenericWrapper.elementIterator(root, APPINFO_SETTING); while (itProperties.hasNext()) { Element element = itProperties.next(); CmsXmlContentProperty setting = new CmsXmlContentProperty( element.attributeValue(APPINFO_ATTR_NAME), element.attributeValue(APPINFO_ATTR_TYPE), element.attributeValue(APPINFO_ATTR_WIDGET), element.attributeValue(APPINFO_ATTR_WIDGET_CONFIG), element.attributeValue(APPINFO_ATTR_RULE_REGEX), element.attributeValue(APPINFO_ATTR_RULE_TYPE), element.attributeValue(APPINFO_ATTR_DEFAULT), element.attributeValue(APPINFO_ATTR_NICE_NAME), element.attributeValue(APPINFO_ATTR_DESCRIPTION), element.attributeValue(APPINFO_ATTR_ERROR), element.attributeValue(APPINFO_ATTR_PREFERFOLDER)); String name = setting.getName(); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) { m_settings.put(name, setting); } } }
/** * Gets the name of the property.<p> * * @return the name of the property */ public String getName() { return m_propData.getName(); }
/** * Helper method for converting a map of properties from client format to server format or vice versa.<p> * * @param cms the CmsObject to use for VFS operations * @param props the map of properties * @param propConfig the property configuration * @param toClient if true, convert from server to client, else from client to server * * @return the converted property map */ protected static Map<String, String> convertProperties( CmsObject cms, Map<String, String> props, Map<String, CmsXmlContentProperty> propConfig, boolean toClient) { Map<String, String> result = new HashMap<String, String>(); for (Map.Entry<String, String> entry : props.entrySet()) { String propName = entry.getKey(); String propValue = entry.getValue(); String type = "string"; CmsXmlContentProperty configEntry = getPropertyConfig(propConfig, propName); if (configEntry != null) { type = configEntry.getType(); } String newValue = convertStringPropertyValue(cms, propValue, type, toClient); result.put(propName, newValue); } return result; }
/** * Returns the individual element settings formated with nice-names to be used as additional-info.<p> * * @param containerId the container id * * @return the settings list */ public List<CmsAdditionalInfoBean> getFormatedIndividualSettings(String containerId) { List<CmsAdditionalInfoBean> result = new ArrayList<CmsAdditionalInfoBean>(); CmsFormatterConfig config = getFormatterConfig(containerId); if ((m_settings != null) && (config != null)) { for (Entry<String, String> settingEntry : m_settings.entrySet()) { String settingKey = settingEntry.getKey(); if (config.getSettingConfig().containsKey(settingEntry.getKey())) { String niceName = config.getSettingConfig().get(settingEntry.getKey()).getNiceName(); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly( config.getSettingConfig().get(settingEntry.getKey()).getNiceName())) { settingKey = niceName; } } result.add(new CmsAdditionalInfoBean(settingKey, settingEntry.getValue(), null)); } } return result; }
/** * @see org.opencms.configuration.preferences.I_CmsPreference#createConfigurationItem() */ public Element createConfigurationItem() { CmsXmlContentProperty prop = getPropertyDefinition(); Element elem = DocumentHelper.createElement(CmsWorkplaceConfiguration.N_PREFERENCE); for (String[] attrToSet : new String[][] { {I_CmsXmlConfiguration.A_NAME, getName()}, {I_CmsXmlConfiguration.A_VALUE, getDefaultValue()}, {CmsWorkplaceConfiguration.A_NICE_NAME, prop.getNiceName()}, {CmsWorkplaceConfiguration.A_DESCRIPTION, prop.getDescription()}, {CmsWorkplaceConfiguration.A_WIDGET, prop.getWidget()}, {CmsWorkplaceConfiguration.A_WIDGET_CONFIG, prop.getWidgetConfiguration()}, {CmsWorkplaceConfiguration.A_RULE_REGEX, prop.getRuleRegex()}, {CmsWorkplaceConfiguration.A_ERROR, prop.getError()}}) { String attrName = attrToSet[0]; String value = attrToSet[1]; if (value != null) { elem.addAttribute(attrName, value); } } return elem; }
/** * Copies a property definition, but replaces the nice name attribute.<p> * * @param niceName the new nice name attribute * * @return the copied property definition */ public CmsXmlContentProperty withNiceName(String niceName) { return new CmsXmlContentProperty( m_name, m_type, m_widget, m_widgetConfiguration, m_ruleRegex, m_ruleType, m_default, niceName, m_description, m_error, m_preferFolder); }
/** * Adds a user setting.<p> * * @param value the current value of the user setting * @param config the configuration for the user setting * * @param basic true if this is a basic user setting */ public void addSetting(String value, CmsXmlContentProperty config, boolean basic) { m_values.put(config.getName(), value); m_settingConfiguration.put(config.getName(), config); if (basic) { m_basicOptions.add(config.getName()); } }
String settingType = "string"; if (settingsConf.get(settingName) != null) { settingType = settingsConf.get(settingName).getType();
/** * @see org.opencms.configuration.preferences.CmsBuiltinPreference#getPropertyDefinition(org.opencms.file.CmsObject) */ @Override public CmsXmlContentProperty getPropertyDefinition() { CmsXmlContentProperty prop = new CmsXmlContentProperty( getName(), //name null, //type null, //widget null, //widgetconfig null, //regex null, //ruletype null, //default NICE_NAME, //nicename null, //description null, //error null//preferfolder ); return prop; }
/** * Parses the settings for the dynamic function from the XML content.<p> * * @param cms the current CMS context * @param location the location from which to read the dynamic function settings * @param functionResource the dynamic function resource * * @return the parsed map of settings for the dynamic function */ protected Map<String, CmsXmlContentProperty> parseSettings( CmsObject cms, I_CmsXmlContentLocation location, CmsResource functionResource) { LinkedHashMap<String, CmsXmlContentProperty> settingConfigs = new LinkedHashMap<String, CmsXmlContentProperty>(); List<I_CmsXmlContentValueLocation> locations = location.getSubValues("SettingConfig"); for (I_CmsXmlContentValueLocation settingLoc : locations) { CmsXmlContentProperty settingConfigBean = parseProperty(cms, settingLoc); settingConfigs.put(settingConfigBean.getName(), settingConfigBean); } return settingConfigs; }
CmsXmlContentProperty propDef = propertiesConf.get(propName); if (propDef != null) { isVfs = CmsXmlContentProperty.PropType.isVfsList(propDef.getType());
/** * @see org.opencms.configuration.preferences.CmsBuiltinPreference#getPropertyDefinition(org.opencms.file.CmsObject) */ @Override public CmsXmlContentProperty getPropertyDefinition() { CmsXmlContentProperty prop = new CmsXmlContentProperty( getName(), //name "string", //type null, //widget null, //widgetconfig null, //regex null, //ruletype null, //default NICE_NAME, //nicename null, //description null, //error null//preferfolder ); return prop; }
/** * Parses the settings.<p> * * @param formatterLoc the formatter value location */ private void parseSettings(I_CmsXmlContentLocation formatterLoc) { for (I_CmsXmlContentValueLocation settingLoc : formatterLoc.getSubValues(N_SETTING)) { CmsPropertyConfig propConfig = CmsConfigurationReader.parseProperty(m_cms, settingLoc); CmsXmlContentProperty property = propConfig.getPropertyData(); m_settings.put(property.getName(), property); } }
/** * @see org.opencms.configuration.preferences.CmsBuiltinPreference#getPropertyDefinition(org.opencms.file.CmsObject) */ @Override public CmsXmlContentProperty getPropertyDefinition() { CmsXmlContentProperty prop = new CmsXmlContentProperty( getName(), //name "string", //type "datebox", //widget null, //widgetconfig null, //regex null, //ruletype null, //default "%(key." + org.opencms.workplace.commons.Messages.GUI_LABEL_TIMEWARP_0 + ")", //nicename null, //description null, //error null//preferfolder ); return prop; }