On Mar 10, 2010, at 9:20 AM, Marius Dumitru Florea wrote:
> Vincent Massol wrote:
>> On Mar 10, 2010, at 8:33 AM, Marius Dumitru Florea wrote:
>>
>>> Vincent Massol wrote:
>>>> Hi Asiri,
>>>>
>>>> Don't we have any tests for wiki macros? I don't see any test providing
>>>> that it works. Since wiki macros are something introduced recently I'm
>>>> surprised we don't have tests for it (or do we?).
>>>>
>>>> Also could you explain the need for default parameter values in wiki macro
>>>> parameter descriptor?
>>>> Since the macro content is available in the content field, isn't it easy
>>>> to use a default value there?
>>>>
>>>> So is this just for convenience or is there something I don't see?
>>> The WYSIWYG editor can't extract the default values from the wiki macro
>>> content. If a macro parameter has a default value then the WYSIWYG user
>>> should see it.
>>
>> Ok I see.
>>
>
>> How do you get default param values for java macros? For example for the
>> velocity macro I see that the default value for the "filter" parameter is in
>> execute().
>
> I don't know exactly how default parameter values for Java macros are
> extracted (Thomas should know), the editor just takes them from the
> macro parameter descriptor. I just tested and there's no default value
> displayed for the "filter" parameter of the velocity macro. If this
> parameter has a default value then it should be specified in its
> descriptor. Other velocity macro parameters like "output" or "wiki" have
> a default value specified in the descriptor. Note that the editor
> doesn't include default values in its output (unless the parameter is
> required) so the generated wiki syntax is not affected if you specify
> the default value in the parameter descriptor.
ok, thanks for the explanations!
-Vincent
>
> Thanks,
> Marius
>
>>
>> Thanks
>> -Vincent
>>
>>> Marius
>>>
>>>> Thanks
>>>> -Vincent
>>>>
>>>> On Mar 10, 2010, at 7:43 AM, asiri (SVN) wrote:
>>>>
>>>>> Author: asiri
>>>>> Date: 2010-03-10 07:43:01 +0100 (Wed, 10 Mar 2010)
>>>>> New Revision: 27562
>>>>>
>>>>> Modified:
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroFactory.java
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroInitializer.java
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/WikiMacroConstants.java
>>>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/WikiMacroParameterDescriptor.java
>>>>> Log:
>>>>> XWIKI-4944: Add support for Default Values for XWiki Wiki Macros.
>>>>>
>>>>> * Applied anamaria's patch without changes.
>>>>>
>>>>> Modified:
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroFactory.java
>>>>> ===================================================================
>>>>> ---
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroFactory.java
>>>>> 2010-03-10 05:11:59 UTC (rev 27561)
>>>>> +++
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroFactory.java
>>>>> 2010-03-10 06:43:01 UTC (rev 27562)
>>>>> @@ -191,7 +191,8 @@
>>>>> String parameterDescription =
>>>>> macroParameter.getStringValue(PARAMETER_DESCRIPTION_PROPERTY);
>>>>> boolean parameterMandatory =
>>>>>
>>>>> (macroParameter.getIntValue(PARAMETER_MANDATORY_PROPERTY) == 0) ? false :
>>>>> true;
>>>>> -
>>>>> + String parameterDefaultValue =
>>>>> macroParameter.getStringValue(PARAMETER_DEFAULT_VALUE_PROPERTY);
>>>>> +
>>>>> // Verify parameter name.
>>>>> if (StringUtils.isEmpty(parameterName)) {
>>>>> throw new WikiMacroException(String.format(
>>>>> @@ -203,10 +204,15 @@
>>>>> String errorMessage = "Incomplete macro definition in
>>>>> [%s], macro parameter description is empty";
>>>>> getLogger().debug(String.format(errorMessage,
>>>>> documentReference));
>>>>> }
>>>>> +
>>>>> + // If field empty, assume no default value was provided.
>>>>> + if (StringUtils.isEmpty(parameterDefaultValue)) {
>>>>> + parameterDefaultValue = null;
>>>>> + }
>>>>>
>>>>> // Create the parameter descriptor.
>>>>> parameterDescriptors.add(new
>>>>> WikiMacroParameterDescriptor(parameterName, parameterDescription,
>>>>> - parameterMandatory));
>>>>> + parameterMandatory, parameterDefaultValue));
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> Modified:
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroInitializer.java
>>>>> ===================================================================
>>>>> ---
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroInitializer.java
>>>>> 2010-03-10 05:11:59 UTC (rev 27561)
>>>>> +++
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/DefaultWikiMacroInitializer.java
>>>>> 2010-03-10 06:43:01 UTC (rev 27562)
>>>>> @@ -235,6 +235,7 @@
>>>>> needsUpdate |= bclass.addTextField(PARAMETER_NAME_PROPERTY,
>>>>> "Parameter name", 30);
>>>>> needsUpdate |=
>>>>> bclass.addTextAreaField(PARAMETER_DESCRIPTION_PROPERTY, "Parameter
>>>>> description", 40, 5);
>>>>> needsUpdate |= bclass.addBooleanField(PARAMETER_MANDATORY_PROPERTY,
>>>>> "Parameter mandatory", "yesno");
>>>>> + needsUpdate |=
>>>>> bclass.addTextField(PARAMETER_DEFAULT_VALUE_PROPERTY, "Parameter default
>>>>> value", 30);
>>>>>
>>>>> if (needsUpdate) {
>>>>> update(doc);
>>>>>
>>>>> Modified:
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/WikiMacroConstants.java
>>>>> ===================================================================
>>>>> ---
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/WikiMacroConstants.java
>>>>> 2010-03-10 05:11:59 UTC (rev 27561)
>>>>> +++
>>>>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/WikiMacroConstants.java
>>>>> 2010-03-10 06:43:01 UTC (rev 27562)
>>>>> @@ -111,4 +111,10 @@
>>>>> * Constant for representing parameter mandatory property.
>>>>> */
>>>>> String PARAMETER_MANDATORY_PROPERTY = "mandatory";
>>>>> +
>>>>> + /**
>>>>> + * Constant for representing parameter defaultValue property.
>>>>> + * @since 2.3M1
>>>>> + */
>>>>> + String PARAMETER_DEFAULT_VALUE_PROPERTY = "defaultValue";
>>>>> }
>>>>>
>>>>> Modified:
>>>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/WikiMacroParameterDescriptor.java
>>>>> ===================================================================
>>>>> ---
>>>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/WikiMacroParameterDescriptor.java
>>>>> 2010-03-10 05:11:59 UTC (rev 27561)
>>>>> +++
>>>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/WikiMacroParameterDescriptor.java
>>>>> 2010-03-10 06:43:01 UTC (rev 27562)
>>>>> @@ -54,6 +54,11 @@
>>>>> private boolean mandatory;
>>>>>
>>>>> /**
>>>>> + * Default value of the parameter.
>>>>> + */
>>>>> + private Object defaultValue;
>>>>> +
>>>>> + /**
>>>>> * Creates a new {...@link WikiMacroParameterDescriptor} instance.
>>>>> *
>>>>> * @param id parameter identifier.
>>>>> @@ -68,6 +73,23 @@
>>>>> }
>>>>>
>>>>> /**
>>>>> + * Creates a new {...@link WikiMacroParameterDescriptor} instance.
>>>>> + *
>>>>> + * @param id parameter identifier.
>>>>> + * @param description parameter description.
>>>>> + * @param mandatory if the parameter is mandatory.
>>>>> + * @param defaultValue parameter default value.
>>>>> + * @since 2.3M1
>>>>> + */
>>>>> + public WikiMacroParameterDescriptor(String id, String description,
>>>>> boolean mandatory, Object defaultValue)
>>>>> + {
>>>>> + this.id = id;
>>>>> + this.description = description;
>>>>> + this.mandatory = mandatory;
>>>>> + this.defaultValue = defaultValue;
>>>>> + }
>>>>> +
>>>>> + /**
>>>>> * {...@inheritdoc}
>>>>> */
>>>>> public String getId()
>>>>> @@ -106,7 +128,7 @@
>>>>> */
>>>>> public Object getDefaultValue()
>>>>> {
>>>>> - return null;
>>>>> + return this.defaultValue;
>>>>> }
>>>>>
>>>>> /**
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs