Is there a list of “supported” types and their UI representation? Is there a way to create a list of values to choose from for a macro parameter. Or a color picker?
Any existing Java class is supported. In other words, the parameter type you specify must be an existing Java type. The UI representation depends on whether the type you specify has an associated HTML displayer. If it doesn’t then it falls back on the default HTML displayer, which shows a plain text input to edit the parameter value. Unfortunately this is not documented… but you can see a list of available HTML displayers at https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-web/src/main/webapp/templates/html_displayer . XWiki takes the simple name of the type you specify, makes it lower case and then looks for the corresponding template.
The easiest is to create a Java enum with the allowed values and specify this as the parameter type. The existing enum displayer will display a drop down select with the enum values from your enum type.
Set the type of your parameter to java.awt.Color or any custom “Color” type and then the existing color displayer will show a color picker for your macro parameter.
I tried color and date, but without success. Maybe this is not yet implemented in 11.10.4? Or I did something wrong …
Also, I didn’t grasp how to attach an enum to the parameter? Do I need to do that from the macro or is it “read” from the default parameter? Probably newbie question …
What type did you use exactly? From the screenshot it seems it did have an effect on the ColorPicker parameter, at least, because it’s field is not a plain text input anymore. The color picker should open when you click on the right (gray) side.
In the same way as you did with the color and date: you set the parameter type to your custom Java enum class. The displayer will then automatically read the values from the specified enum and display them in a drop down select box.
For the color picker, it is “java.awt.Color”
For the date picker, it is “java.util.Date”
For the Enum test, it is “java.lang.Enum”
Where for the Enum I’m not so sure, since this maybe might be like java.lang.Number (superclass) kind of thing …
Tried that already, did not work …
Sorry, lack of (java) development experience and/or imagination
So where would I declare the class and instantiate the object? Would that be part of the object of the XWiki.WikiMacroParameterClass (like the default value) or ???. Completely lost here …
You need to investigate why. Check at least the JavaScript console to see if there are any JavaScript errors. Look at the Network tab (browser developer tools) to see if the color picker JavaScript / CSS is loaded.
There are no JavaScript errors and also no 404 or other errors when loading the page. What would be the library used to show the color picker? JQuery? The only file loaded with “color” in the name is the one from CKEditor:
xwiki/custom/CKEditor_plugins/colordialog/plugin.js
xwiki/custom/CKEditor_plugins/colordialog/lang/en.js
and for “picker” it is:
xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.41/plugins/xwiki-resource/resourcePicker.min.css
xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.41/plugins/xwiki-resource/resourcePicker.bundle.min.js
xwiki/webjars/wiki%3Axwiki/application-ckeditor-webjar/1.41/plugins/xwiki-resource/resourcePicker.min.css
What would be the CSS / JS library to look for?
Regarding the ENUM type, I see. Thank you for the sample to start from. Maybe it would be an option to extend the Wiki Macro options to support a predefined list of values? Not sure if this would be a generic requirement and other might deem this useful too …
Anyway, about to upgrade to xWiki 12 right now to be “up to date” …