On Aug 4, 2009, at 5:42 AM, Asiri Rathnayake wrote:
Hi
On Mon, Aug 3, 2009 at 10:31 PM, Fabio Mancinelli <
fabio.mancinelli(a)xwiki.com> wrote:
On Aug 3, 2009, at 6:27 PM, Asiri Rathnayake wrote:
While the
"every plugin could declare to be in a given category" is
easily casted to the Macro world, I am not sure how to translate
the
"every plugin is free to add new categories".
How about like this:
* Each macro has a getCategory() method.
* Macro manager calls this method and if the category is an existing
one, it
is put into that collection.
The problem with this is that a "category" is a data structure so
test
for equality could be problematic.
Imagine 3 macros return:
ID:category1
Name:Foo foo foo
Icon:foo.jpg
ID:category1
Name:Bar bar bar
Icon:bar.jpg
ID:category2
name:Foo foo foo
Icon:baz.jpg
How would you handle this?
My idea was to make a "category" not a data structure but a simple
string
only, I don't think there is a requirement for categories to be data
structures at this moment (IMHO).
As vincent suggested, getCategory() method of MacroDescriptor could:
1. Check if "org.xwiki.macro.<macro_name>.category" configuration
option is
set in xwiki.properties
2. If it is set, return that value.
3. Otherwise, return a default value
This would allow editing macro categories and arranging macros into
categories as admins prefer. I wonder what Guillaume thinks about
this :)
Few issues with this approach arises with
MacroManager::getCategories() &
MacroManager::getMacrosForCategory() method implementations. Since
we have
dynamic macro registrations (wiki macros), each of these methods
will have
to build the response by going through all the macros in the system.
This is not really a problem. 2 solutions:
1) cm.lookupList() is immediate and you just need to loop.
2) you can subscribe to Component Manager registrations events and
refresh a category cache when a new macro is registered/unregistered
-Vincent
- Asiri
> Imho, getCategory() should return a simple string that is an id of a
> category defined and stored in a "registry"
> The problem is how could a macro put a category inside this registry?
>
> Maybe at initialization time it could do store new categories in the
> registry (if it wants to do so) so that a subsequent call to
> getCategory would return an existing id.
>
> The registry could also be populated by default with a set of
> "standard" categories (maybe defined in some wiki pages).
>
> -Fabio