/** * 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; }
/** * 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#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; }
/** * @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; }
/** * 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; }