On Mon, Oct 22, 2012 at 9:58 AM, Thomas Mortagne <[email protected]> wrote:
On Tue, Oct 16, 2012 at 3:46 AM, Sergiu Dumitriu <[email protected]> wrote:
On 10/15/2012 06:21 AM, Marius Dumitru Florea wrote:
Hi devs,
I'd like to extend the set of property types available in the AWM class editor (the field palette) and I'm not sure where is the best place to do this: in the Java code (oldcore) or in the wiki. I prefer the wiki. Let me explain.
We recently added two new property types in the oldcore: email and page. If you look at these two you'll see that email is just a string property with a default validation regexp and page is just a dblist property.
The AWM class editor has a system that lets you define property 'templates' in the wiki. To define the email property type I could do this:
* create AppWithinMinutes.Email xclass with a single String property (the 'template') * set the validation regexp to match an email address (but I can set other meta properties as well with *default* values) * add an object of type AppWithinMinutes.FormFieldClass to AppWithinMinutes.Email to specify (among other things) the list of meta properties that should be visible in the class editor. For instance, I'd like to hide the validation regexp.
At this point the AWM class editor will detect the email property type and list it in the field palette and you can add it to your class. The only problem is that when editing the class back the editor doesn't have yet a way to determine what was the template used to add the property so it uses the default one, the one for the String property in this case.
So my question is: do you think it's good to be able to define new property types from the wiki (e.g. Image, Attachment, Color, etc.) or should they all be written in Java? If the answer is Wiki, then I'll think of a way to store the reference to the property template so that the AWM class editor can edit back using the right template.
Note that it crossed my mind to define a property type component that can be implemented both from Java and from the wiki but transforming the oldcore code that handles objects/properties into components is very difficult.
If a property type makes sense, it should be available without using AWM, thus it should be a standard property type defined in Java.
To introduce some components in the way properties are handled, I think that it might be enough to convert just the *MetaClass classes (from com.xpn.xwiki.objects.meta) into components, with com.xpn.xwiki.objects.meta.MetaClass updated to replace the static initialization with a component list lookup. Actual property classes are created by their corresponding *MetaClass, and actual properties are created by their corresponding *PropertyClass, so they don't have to be touched.
+1 for introducing components for this.
Once you have components it's easy to either use wiki component or introduce a special bridge to define new classes in the wiki.
I'm going to push a branch with this in a few minutes and send a proposal. Thanks, Marius
-- Sergiu Dumitriu http://purl.org/net/sergiu/
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs