You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Appddevvv (JIRA)" <ji...@apache.org> on 2010/06/03 19:49:00 UTC

[jira] Created: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
-----------------------------------------------------------------------------------------------------------------------------

                 Key: PIVOT-514
                 URL: https://issues.apache.org/jira/browse/PIVOT-514
             Project: Pivot
          Issue Type: Improvement
          Components: wtk
            Reporter: Appddevvv
            Priority: Minor


Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:

a) The client does not need to know which property to attach the children to. 
b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.

The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:

a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
b) If the content property is not specified,
b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
b.2) Add it to the property specified in the XML. This is also how it is handled today.

I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by aappddeevv <aa...@verizon.net>.
I'm fine without the utils class, however, I'll propose that we need some
static methods for default property access to write a tree walker consistent
with the serializer default property setter. The issue is that it is quite
possible, some day in the future :-) that the sequence list in a container
is no longer the primary child instance container in all cases or that it
contains more elements than you want when you walk the tree.



-----Original Message-----
From: Greg Brown (JIRA) [mailto:jira@apache.org] 
Sent: Thursday, June 10, 2010 11:10 AM
To: dev@pivot.apache.org
Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
default "child" property of a component used by the serializer to attach
children objects


     [
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
in.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-514:
-----------------------------

    Attachment: PIVOT-514.patch
                DefaultProperty.java

OK, thanks for the updated patch. I think this can be done without the need
for the utils class - see attached patch.

There was also an issue with the setOrAddDefaultPropertyContent() method in
SerializerUtils - that method checked for instances of java.util.Collection,
where it should have been looking for org.apache.pivot.collections.Sequence
(nothing in Pivot implements java.util.Collection).

Overall, I like the change. It can significantly reduce the size/nesting
depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for an
example.


> create an annotation to specify the default "child" property of a
component used by the serializer to attach children objects
>
----------------------------------------------------------------------------
-------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: DefaultProperty.java, defaultpropertypatch.zip,
defaultpropertypatch.zip, PIVOT-514.patch
>
>
> Add an annotation called @ContentProperty that specifies the default
property to attach children to in the serializer. I found that I was making
mistakes when creating WTKX that this annotation and a default "child
attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children
to. 
> b) To add objects to a collection the parent object does not need to
extend from sequence. The sequence can be contained in the object instead of
implementing the interface. Containment can be another approach to getting
content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment
occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple
extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the
child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled
today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is
handled today.
> I wrote this for a small modeled framework similar to pivot and could work
up a couple of patches for this. This is very similar to how wpf handles
child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Commented: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by aappddeevv <aa...@verizon.net>.
I tried but could not figure out how to reinstate the original file. There
were only actually 5-6 six lines that were added (in addition to some static
methods). I added @Inherited on the annotation as pointed out in another
post to DefaultProperty. 

The serializer patch (3-4 lines) are exclusive of the other patch I
submitted to create some small protected factory methods for subclassing the
serializer.

I also included the patch for the Window, Viewport and Border classes to set
the default property. I have since noticed that there are other components
that could have a default property but I have not tested those. If we can
get the patch in for the basics, then we can add the default property to the
other classes once we write some tests.

I have attached the updated zip file to the original issue in jira.




-----Original Message-----
From: Greg Brown (JIRA) [mailto:jira@apache.org] 
Sent: Wednesday, June 09, 2010 3:58 PM
To: dev@pivot.apache.org
Subject: [jira] Commented: (PIVOT-514) create an annotation to specify the
default "child" property of a component used by the serializer to attach
children objects


    [
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
in.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877180#action_1
2877180 ] 

Greg Brown commented on PIVOT-514:
----------------------------------

Any chance you could try to regenerate this patch? It is tough to see what
actually changed because so many lines are flagged.

It is possible that you changed the line endings, such that every line looks
like it changed?



> create an annotation to specify the default "child" property of a
component used by the serializer to attach children objects
>
----------------------------------------------------------------------------
-------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: defaultpropertypatch.zip
>
>
> Add an annotation called @ContentProperty that specifies the default
property to attach children to in the serializer. I found that I was making
mistakes when creating WTKX that this annotation and a default "child
attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children
to. 
> b) To add objects to a collection the parent object does not need to
extend from sequence. The sequence can be contained in the object instead of
implementing the interface. Containment can be another approach to getting
content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment
occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple
extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the
child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled
today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is
handled today.
> I wrote this for a small modeled framework similar to pivot and could work
up a couple of patches for this. This is very similar to how wpf handles
child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Updated: (PIVOT-514)

Posted by aappddeevv <aa...@verizon.net>.
Yes, this is very cool. My collection comment on this issue was purely what
interface is used to detect a call to add(). Declarative programming is an
important option for pivot clients and more importantly, has great tooling
potential.

Just thinking out loud...and typing fast...

Related to maps, probably one good user XML extension for the serializer and
that has a lot of uses cases is to specify a map as elements versus
attributes.  Also, through more annotation magic, the default key generator
can be specified. Many lookups occur using a class (name) as a lookup key or
the key is easily statically specified by the object or its static nature.
The "elements vs attributes" approach allows you to specify the object
instance inline because specifying an object class to be instantianted in an
attribute value is ambiguous unless you add more DSL (e.g. instead of a $
for a reference lookup, a % for an object creation).

This allows me to specify a bunch of objects without always having to use
attributes. The object can be defined and instantiated inline for the map
versus referenced elsewhere. There are 2-3 major use cases for this e.g.
automated menu population/configuration. And by establishing a very small
convention, allows a large number of declarative processing scenarios that
create new class behaviors without subclassing/coding. This is the true
power of the serializer/component as a container thinking and doesn't put
too much burden on the serializer (i.e. avoiding full DI-container semantics
which is a lot of work to create and is not needed here).

However, this is not compelling enough yet to suggest unless other pivot
elements (those 2-3 uses cases) are also enabled.

For example, as a small convention with support, if the serializer
automatically scans the user data and finds an object with an
interface/annotation called "Initializer", the interface is called. This
initialize can in turn scan the user data for a menu specification and
automatically add or substract a menu (also in the user data) from the main
menu when the component has focus (or whatever). By combining this with
Component's "name", I can specify the attach point as a menu URL. This is
Component-level services configured at the Component level and entirely
optional all without subclassing in my application---I just write services
that are reusable and use composition to create new behaviors. All of this
has minimal API impact (almost none) but does need a small amount of
pivot-library level support. Any Component can be a menu contributor.

If we add cross-tree hierarchical user data lookup (minimal API impact) and
object initialization lifecycle event signaling (some API impact), you have
ingredients to create significant defaulting and user data management
behaviors. This would help with additional application-level, declarative
thematic and stylizing defaulting. By using JSON for style specifications,
which I think is clever, combined with a defaulting system that is
cross-tree, you have a nice set of customization capabilities that reduces
the experience level needed to create great looking applications, avoids
coding (subclassing or using code to configure), enables easier tooling and
can employ declarative configuration for those that like it. Conceptually,
this is at the heart of managing the boundary between coding and
configuration in a *balanced* way.

So in this area (element map, small "initializer" interface, cross-tree user
data lookup, contract for object creation/initialization), plus a little
convention enables a lot of flexibility and to Dirk's point, doesn't box you
in. This is an unique, targeted fusion of WPF and eclipse e4 thinking that
could be possible in pivot. I don't know enough about Adobe and other
frameworks to say how they handle complexity and flexibility.



-----Original Message-----
From: Greg Brown [mailto:gkbrown@mac.com] 
Sent: Friday, June 11, 2010 9:14 AM
To: dev@pivot.apache.org
Subject: Re: [jira] Updated: (PIVOT-514)

I should add that WTKXSerializer *does* actually know about maps (or, more
specifically, dictionaries). If your class exposes a read-only dictionary
property (e.g. Component#getUserData()), WTKXSerializer will properly
populate the dictionary based on markup. For example:

<Window>
  <userData foo="abc" bar="$def"/>
</Window>

The serializer will effectively call getUserData().put("foo", "abc") and
getUserData().put("bar", def), where def is the value of the page-scoped
variable referred to by "def". This is what allows styles to be set using an
element vs. a JSON string, for example:

<Label>
  <styles color="#ff0000"/>
</Label>

vs.

<Label styles="{color:'#ff0000'}">

WTKXSerializer caters to sequences and dictionaries because those are the
structures employed by XML. An XML element is effectively both a sequence
(containing sub-elements and text nodes) and a dictionary (mapping string
attribute names to attribute values). Since sets aren't really used by XML,
there's no need for WTKXSerializer to try to support them.

To some extent, sets are something of an artificial construct. As I
mentioned in my previous email, they can be implemented via the Sequence
interface. They can also be implemented via the Dictionary interface, if
they keys are used as the set's values. In fact, this is how HashSet is
implemented internally. The two primary data structures in most applications
and frameworks are sequences (indexed access) and dictionaries (keyed
access).

Hope this helps.

G


On Jun 11, 2010, at 8:57 AM, Greg Brown wrote:

> You can ensure that a Sequence implementation does not allow duplicate
entries. However, your collection class would also need to implement Set or
Group if you want to expose that API to a caller. WTKXSerializer does not
know anything about Sets (nor does it need to, since that is not a primary
use case for WTKX serialization).
> 
> On Jun 11, 2010, at 8:49 AM, aappddeevv wrote:
> 
>> Meant list and set not map.
>> 
>> -----Original Message-----
>> From: aappddeevv [mailto:aappddeevv@verizon.net] 
>> Sent: Friday, June 11, 2010 7:58 AM
>> To: dev@pivot.apache.org
>> Subject: RE: [jira] Updated: (PIVOT-514) create an annotation to specify
the
>> default "child" property of a component used by the serializer to attach
>> children objects
>> 
>> My thinking was that if a client defined a list or a map using standard
java
>> collection classes. If the recommendation is to always use pivot
collection
>> classes in pivot code and sequence supports both map and list, that
sounds
>> fine.
>> 
>> -----Original Message-----
>> From: Greg Brown (JIRA) [mailto:jira@apache.org] 
>> Sent: Thursday, June 10, 2010 11:10 AM
>> To: dev@pivot.apache.org
>> Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
>> default "child" property of a component used by the serializer to attach
>> children objects
>> 
>> 
>>    [
>>
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
>> in.system.issuetabpanels:all-tabpanel ]
>> 
>> Greg Brown updated PIVOT-514:
>> -----------------------------
>> 
>>   Attachment: PIVOT-514.patch
>>               DefaultProperty.java
>> 
>> OK, thanks for the updated patch. I think this can be done without the
need
>> for the utils class - see attached patch.
>> 
>> There was also an issue with the setOrAddDefaultPropertyContent() method
in
>> SerializerUtils - that method checked for instances of
java.util.Collection,
>> where it should have been looking for
org.apache.pivot.collections.Sequence
>> (nothing in Pivot implements java.util.Collection).
>> 
>> Overall, I like the change. It can significantly reduce the size/nesting
>> depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for
an
>> example.
>> 
>> 
>>> create an annotation to specify the default "child" property of a
>> component used by the serializer to attach children objects
>>> 
>>
----------------------------------------------------------------------------
>> -------------------------------------------------
>>> 
>>>               Key: PIVOT-514
>>>               URL: https://issues.apache.org/jira/browse/PIVOT-514
>>>           Project: Pivot
>>>        Issue Type: Improvement
>>>        Components: wtk
>>>          Reporter: Appddevvv
>>>          Priority: Minor
>>>           Fix For: 1.6
>>> 
>>>       Attachments: DefaultProperty.java, defaultpropertypatch.zip,
>> defaultpropertypatch.zip, PIVOT-514.patch
>>> 
>>> 
>>> Add an annotation called @ContentProperty that specifies the default
>> property to attach children to in the serializer. I found that I was
making
>> mistakes when creating WTKX that this annotation and a default "child
>> attachment" approach could help. Benefits include:
>>> a) The client does not need to know which property to attach the
children
>> to. 
>>> b) To add objects to a collection the parent object does not need to
>> extend from sequence. The sequence can be contained in the object instead
of
>> implementing the interface. Containment can be another approach to
getting
>> content into the parent objects versus inheritance.
>>> c) You can change some of the properties in the class where attachment
>> occurs and your WTKX files do not have to change.
>>> The default mechanism would be similar to what exists today. It's a
simple
>> extension of it. The "attach child" search would be:
>>> a) If the content property is specified, use that property to add the
>> child to. If the content property is a collection, add it to the
collection.
>>> b) If the content property is not specified,
>>> b.1) If the parent object is a collection (this is how it is handled
>> today) then add it to the collection using the List.add(Object) method.
>>> b.2) Add it to the property specified in the XML. This is also how it is
>> handled today.
>>> I wrote this for a small modeled framework similar to pivot and could
work
>> up a couple of patches for this. This is very similar to how wpf handles
>> child content specifications in XML. Thoughts?
>> 
>> -- 
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>> 
> 



Re: [jira] Updated: (PIVOT-514)

Posted by Greg Brown <gk...@mac.com>.
I should add that WTKXSerializer *does* actually know about maps (or, more specifically, dictionaries). If your class exposes a read-only dictionary property (e.g. Component#getUserData()), WTKXSerializer will properly populate the dictionary based on markup. For example:

<Window>
  <userData foo="abc" bar="$def"/>
</Window>

The serializer will effectively call getUserData().put("foo", "abc") and getUserData().put("bar", def), where def is the value of the page-scoped variable referred to by "def". This is what allows styles to be set using an element vs. a JSON string, for example:

<Label>
  <styles color="#ff0000"/>
</Label>

vs.

<Label styles="{color:'#ff0000'}">

WTKXSerializer caters to sequences and dictionaries because those are the structures employed by XML. An XML element is effectively both a sequence (containing sub-elements and text nodes) and a dictionary (mapping string attribute names to attribute values). Since sets aren't really used by XML, there's no need for WTKXSerializer to try to support them.

To some extent, sets are something of an artificial construct. As I mentioned in my previous email, they can be implemented via the Sequence interface. They can also be implemented via the Dictionary interface, if they keys are used as the set's values. In fact, this is how HashSet is implemented internally. The two primary data structures in most applications and frameworks are sequences (indexed access) and dictionaries (keyed access).

Hope this helps.

G


On Jun 11, 2010, at 8:57 AM, Greg Brown wrote:

> You can ensure that a Sequence implementation does not allow duplicate entries. However, your collection class would also need to implement Set or Group if you want to expose that API to a caller. WTKXSerializer does not know anything about Sets (nor does it need to, since that is not a primary use case for WTKX serialization).
> 
> On Jun 11, 2010, at 8:49 AM, aappddeevv wrote:
> 
>> Meant list and set not map.
>> 
>> -----Original Message-----
>> From: aappddeevv [mailto:aappddeevv@verizon.net] 
>> Sent: Friday, June 11, 2010 7:58 AM
>> To: dev@pivot.apache.org
>> Subject: RE: [jira] Updated: (PIVOT-514) create an annotation to specify the
>> default "child" property of a component used by the serializer to attach
>> children objects
>> 
>> My thinking was that if a client defined a list or a map using standard java
>> collection classes. If the recommendation is to always use pivot collection
>> classes in pivot code and sequence supports both map and list, that sounds
>> fine.
>> 
>> -----Original Message-----
>> From: Greg Brown (JIRA) [mailto:jira@apache.org] 
>> Sent: Thursday, June 10, 2010 11:10 AM
>> To: dev@pivot.apache.org
>> Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
>> default "child" property of a component used by the serializer to attach
>> children objects
>> 
>> 
>>    [
>> https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
>> in.system.issuetabpanels:all-tabpanel ]
>> 
>> Greg Brown updated PIVOT-514:
>> -----------------------------
>> 
>>   Attachment: PIVOT-514.patch
>>               DefaultProperty.java
>> 
>> OK, thanks for the updated patch. I think this can be done without the need
>> for the utils class - see attached patch.
>> 
>> There was also an issue with the setOrAddDefaultPropertyContent() method in
>> SerializerUtils - that method checked for instances of java.util.Collection,
>> where it should have been looking for org.apache.pivot.collections.Sequence
>> (nothing in Pivot implements java.util.Collection).
>> 
>> Overall, I like the change. It can significantly reduce the size/nesting
>> depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for an
>> example.
>> 
>> 
>>> create an annotation to specify the default "child" property of a
>> component used by the serializer to attach children objects
>>> 
>> ----------------------------------------------------------------------------
>> -------------------------------------------------
>>> 
>>>               Key: PIVOT-514
>>>               URL: https://issues.apache.org/jira/browse/PIVOT-514
>>>           Project: Pivot
>>>        Issue Type: Improvement
>>>        Components: wtk
>>>          Reporter: Appddevvv
>>>          Priority: Minor
>>>           Fix For: 1.6
>>> 
>>>       Attachments: DefaultProperty.java, defaultpropertypatch.zip,
>> defaultpropertypatch.zip, PIVOT-514.patch
>>> 
>>> 
>>> Add an annotation called @ContentProperty that specifies the default
>> property to attach children to in the serializer. I found that I was making
>> mistakes when creating WTKX that this annotation and a default "child
>> attachment" approach could help. Benefits include:
>>> a) The client does not need to know which property to attach the children
>> to. 
>>> b) To add objects to a collection the parent object does not need to
>> extend from sequence. The sequence can be contained in the object instead of
>> implementing the interface. Containment can be another approach to getting
>> content into the parent objects versus inheritance.
>>> c) You can change some of the properties in the class where attachment
>> occurs and your WTKX files do not have to change.
>>> The default mechanism would be similar to what exists today. It's a simple
>> extension of it. The "attach child" search would be:
>>> a) If the content property is specified, use that property to add the
>> child to. If the content property is a collection, add it to the collection.
>>> b) If the content property is not specified,
>>> b.1) If the parent object is a collection (this is how it is handled
>> today) then add it to the collection using the List.add(Object) method.
>>> b.2) Add it to the property specified in the XML. This is also how it is
>> handled today.
>>> I wrote this for a small modeled framework similar to pivot and could work
>> up a couple of patches for this. This is very similar to how wpf handles
>> child content specifications in XML. Thoughts?
>> 
>> -- 
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>> 
> 


RE: [jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by aappddeevv <aa...@verizon.net>.
Yes agreed.  The serializer just needs to know that it can add something to
a collection or set a property explicitly. I myself am not actually worried
about duplication. Some people lately have been using sets instead of lists
in their APIs which is why I used collection to ensure add(something) could
be called on it. I think MS always uses lists but I have seen sets creep in
on the java side.

-----Original Message-----
From: Greg Brown [mailto:gkbrown@mac.com] 
Sent: Friday, June 11, 2010 8:57 AM
To: dev@pivot.apache.org
Subject: Re: [jira] Updated: (PIVOT-514) create an annotation to specify the
default "child" property of a component used by the serializer to attach
children objects

You can ensure that a Sequence implementation does not allow duplicate
entries. However, your collection class would also need to implement Set or
Group if you want to expose that API to a caller. WTKXSerializer does not
know anything about Sets (nor does it need to, since that is not a primary
use case for WTKX serialization).

On Jun 11, 2010, at 8:49 AM, aappddeevv wrote:

> Meant list and set not map.
> 
> -----Original Message-----
> From: aappddeevv [mailto:aappddeevv@verizon.net] 
> Sent: Friday, June 11, 2010 7:58 AM
> To: dev@pivot.apache.org
> Subject: RE: [jira] Updated: (PIVOT-514) create an annotation to specify
the
> default "child" property of a component used by the serializer to attach
> children objects
> 
> My thinking was that if a client defined a list or a map using standard
java
> collection classes. If the recommendation is to always use pivot
collection
> classes in pivot code and sequence supports both map and list, that sounds
> fine.
> 
> -----Original Message-----
> From: Greg Brown (JIRA) [mailto:jira@apache.org] 
> Sent: Thursday, June 10, 2010 11:10 AM
> To: dev@pivot.apache.org
> Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
> default "child" property of a component used by the serializer to attach
> children objects
> 
> 
>     [
>
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
> in.system.issuetabpanels:all-tabpanel ]
> 
> Greg Brown updated PIVOT-514:
> -----------------------------
> 
>    Attachment: PIVOT-514.patch
>                DefaultProperty.java
> 
> OK, thanks for the updated patch. I think this can be done without the
need
> for the utils class - see attached patch.
> 
> There was also an issue with the setOrAddDefaultPropertyContent() method
in
> SerializerUtils - that method checked for instances of
java.util.Collection,
> where it should have been looking for
org.apache.pivot.collections.Sequence
> (nothing in Pivot implements java.util.Collection).
> 
> Overall, I like the change. It can significantly reduce the size/nesting
> depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for
an
> example.
> 
> 
>> create an annotation to specify the default "child" property of a
> component used by the serializer to attach children objects
>> 
>
----------------------------------------------------------------------------
> -------------------------------------------------
>> 
>>                Key: PIVOT-514
>>                URL: https://issues.apache.org/jira/browse/PIVOT-514
>>            Project: Pivot
>>         Issue Type: Improvement
>>         Components: wtk
>>           Reporter: Appddevvv
>>           Priority: Minor
>>            Fix For: 1.6
>> 
>>        Attachments: DefaultProperty.java, defaultpropertypatch.zip,
> defaultpropertypatch.zip, PIVOT-514.patch
>> 
>> 
>> Add an annotation called @ContentProperty that specifies the default
> property to attach children to in the serializer. I found that I was
making
> mistakes when creating WTKX that this annotation and a default "child
> attachment" approach could help. Benefits include:
>> a) The client does not need to know which property to attach the children
> to. 
>> b) To add objects to a collection the parent object does not need to
> extend from sequence. The sequence can be contained in the object instead
of
> implementing the interface. Containment can be another approach to getting
> content into the parent objects versus inheritance.
>> c) You can change some of the properties in the class where attachment
> occurs and your WTKX files do not have to change.
>> The default mechanism would be similar to what exists today. It's a
simple
> extension of it. The "attach child" search would be:
>> a) If the content property is specified, use that property to add the
> child to. If the content property is a collection, add it to the
collection.
>> b) If the content property is not specified,
>> b.1) If the parent object is a collection (this is how it is handled
> today) then add it to the collection using the List.add(Object) method.
>> b.2) Add it to the property specified in the XML. This is also how it is
> handled today.
>> I wrote this for a small modeled framework similar to pivot and could
work
> up a couple of patches for this. This is very similar to how wpf handles
> child content specifications in XML. Thoughts?
> 
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 


Re: [jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by Greg Brown <gk...@mac.com>.
You can ensure that a Sequence implementation does not allow duplicate entries. However, your collection class would also need to implement Set or Group if you want to expose that API to a caller. WTKXSerializer does not know anything about Sets (nor does it need to, since that is not a primary use case for WTKX serialization).

On Jun 11, 2010, at 8:49 AM, aappddeevv wrote:

> Meant list and set not map.
> 
> -----Original Message-----
> From: aappddeevv [mailto:aappddeevv@verizon.net] 
> Sent: Friday, June 11, 2010 7:58 AM
> To: dev@pivot.apache.org
> Subject: RE: [jira] Updated: (PIVOT-514) create an annotation to specify the
> default "child" property of a component used by the serializer to attach
> children objects
> 
> My thinking was that if a client defined a list or a map using standard java
> collection classes. If the recommendation is to always use pivot collection
> classes in pivot code and sequence supports both map and list, that sounds
> fine.
> 
> -----Original Message-----
> From: Greg Brown (JIRA) [mailto:jira@apache.org] 
> Sent: Thursday, June 10, 2010 11:10 AM
> To: dev@pivot.apache.org
> Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
> default "child" property of a component used by the serializer to attach
> children objects
> 
> 
>     [
> https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
> in.system.issuetabpanels:all-tabpanel ]
> 
> Greg Brown updated PIVOT-514:
> -----------------------------
> 
>    Attachment: PIVOT-514.patch
>                DefaultProperty.java
> 
> OK, thanks for the updated patch. I think this can be done without the need
> for the utils class - see attached patch.
> 
> There was also an issue with the setOrAddDefaultPropertyContent() method in
> SerializerUtils - that method checked for instances of java.util.Collection,
> where it should have been looking for org.apache.pivot.collections.Sequence
> (nothing in Pivot implements java.util.Collection).
> 
> Overall, I like the change. It can significantly reduce the size/nesting
> depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for an
> example.
> 
> 
>> create an annotation to specify the default "child" property of a
> component used by the serializer to attach children objects
>> 
> ----------------------------------------------------------------------------
> -------------------------------------------------
>> 
>>                Key: PIVOT-514
>>                URL: https://issues.apache.org/jira/browse/PIVOT-514
>>            Project: Pivot
>>         Issue Type: Improvement
>>         Components: wtk
>>           Reporter: Appddevvv
>>           Priority: Minor
>>            Fix For: 1.6
>> 
>>        Attachments: DefaultProperty.java, defaultpropertypatch.zip,
> defaultpropertypatch.zip, PIVOT-514.patch
>> 
>> 
>> Add an annotation called @ContentProperty that specifies the default
> property to attach children to in the serializer. I found that I was making
> mistakes when creating WTKX that this annotation and a default "child
> attachment" approach could help. Benefits include:
>> a) The client does not need to know which property to attach the children
> to. 
>> b) To add objects to a collection the parent object does not need to
> extend from sequence. The sequence can be contained in the object instead of
> implementing the interface. Containment can be another approach to getting
> content into the parent objects versus inheritance.
>> c) You can change some of the properties in the class where attachment
> occurs and your WTKX files do not have to change.
>> The default mechanism would be similar to what exists today. It's a simple
> extension of it. The "attach child" search would be:
>> a) If the content property is specified, use that property to add the
> child to. If the content property is a collection, add it to the collection.
>> b) If the content property is not specified,
>> b.1) If the parent object is a collection (this is how it is handled
> today) then add it to the collection using the List.add(Object) method.
>> b.2) Add it to the property specified in the XML. This is also how it is
> handled today.
>> I wrote this for a small modeled framework similar to pivot and could work
> up a couple of patches for this. This is very similar to how wpf handles
> child content specifications in XML. Thoughts?
> 
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 


RE: [jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by aappddeevv <aa...@verizon.net>.
Meant list and set not map.

-----Original Message-----
From: aappddeevv [mailto:aappddeevv@verizon.net] 
Sent: Friday, June 11, 2010 7:58 AM
To: dev@pivot.apache.org
Subject: RE: [jira] Updated: (PIVOT-514) create an annotation to specify the
default "child" property of a component used by the serializer to attach
children objects

My thinking was that if a client defined a list or a map using standard java
collection classes. If the recommendation is to always use pivot collection
classes in pivot code and sequence supports both map and list, that sounds
fine.

-----Original Message-----
From: Greg Brown (JIRA) [mailto:jira@apache.org] 
Sent: Thursday, June 10, 2010 11:10 AM
To: dev@pivot.apache.org
Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
default "child" property of a component used by the serializer to attach
children objects


     [
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
in.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-514:
-----------------------------

    Attachment: PIVOT-514.patch
                DefaultProperty.java

OK, thanks for the updated patch. I think this can be done without the need
for the utils class - see attached patch.

There was also an issue with the setOrAddDefaultPropertyContent() method in
SerializerUtils - that method checked for instances of java.util.Collection,
where it should have been looking for org.apache.pivot.collections.Sequence
(nothing in Pivot implements java.util.Collection).

Overall, I like the change. It can significantly reduce the size/nesting
depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for an
example.


> create an annotation to specify the default "child" property of a
component used by the serializer to attach children objects
>
----------------------------------------------------------------------------
-------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: DefaultProperty.java, defaultpropertypatch.zip,
defaultpropertypatch.zip, PIVOT-514.patch
>
>
> Add an annotation called @ContentProperty that specifies the default
property to attach children to in the serializer. I found that I was making
mistakes when creating WTKX that this annotation and a default "child
attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children
to. 
> b) To add objects to a collection the parent object does not need to
extend from sequence. The sequence can be contained in the object instead of
implementing the interface. Containment can be another approach to getting
content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment
occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple
extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the
child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled
today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is
handled today.
> I wrote this for a small modeled framework similar to pivot and could work
up a couple of patches for this. This is very similar to how wpf handles
child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by aappddeevv <aa...@verizon.net>.
My thinking was that if a client defined a list or a map using standard java
collection classes. If the recommendation is to always use pivot collection
classes in pivot code and sequence supports both map and list, that sounds
fine.

-----Original Message-----
From: Greg Brown (JIRA) [mailto:jira@apache.org] 
Sent: Thursday, June 10, 2010 11:10 AM
To: dev@pivot.apache.org
Subject: [jira] Updated: (PIVOT-514) create an annotation to specify the
default "child" property of a component used by the serializer to attach
children objects


     [
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
in.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-514:
-----------------------------

    Attachment: PIVOT-514.patch
                DefaultProperty.java

OK, thanks for the updated patch. I think this can be done without the need
for the utils class - see attached patch.

There was also an issue with the setOrAddDefaultPropertyContent() method in
SerializerUtils - that method checked for instances of java.util.Collection,
where it should have been looking for org.apache.pivot.collections.Sequence
(nothing in Pivot implements java.util.Collection).

Overall, I like the change. It can significantly reduce the size/nesting
depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for an
example.


> create an annotation to specify the default "child" property of a
component used by the serializer to attach children objects
>
----------------------------------------------------------------------------
-------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: DefaultProperty.java, defaultpropertypatch.zip,
defaultpropertypatch.zip, PIVOT-514.patch
>
>
> Add an annotation called @ContentProperty that specifies the default
property to attach children to in the serializer. I found that I was making
mistakes when creating WTKX that this annotation and a default "child
attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children
to. 
> b) To add objects to a collection the parent object does not need to
extend from sequence. The sequence can be contained in the object instead of
implementing the interface. Containment can be another approach to getting
content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment
occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple
extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the
child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled
today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is
handled today.
> I wrote this for a small modeled framework similar to pivot and could work
up a couple of patches for this. This is very similar to how wpf handles
child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Issue Comment Edited: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by aappddeevv <aa...@verizon.net>.
I'll try.  I may be able to hand edit.

-----Original Message-----
From: Greg Brown (JIRA) [mailto:jira@apache.org] 
Sent: Wednesday, June 09, 2010 4:01 PM
To: dev@pivot.apache.org
Subject: [jira] Issue Comment Edited: (PIVOT-514) create an annotation to
specify the default "child" property of a component used by the serializer
to attach children objects


    [
https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plug
in.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877180#action_1
2877180 ] 

Greg Brown edited comment on PIVOT-514 at 6/9/10 3:59 PM:
----------------------------------------------------------

Is it possible that you changed the line endings, such that every line looks
like it changed? I believe it used UNIX/OS X line endings (LF) originally.
If you are on Windows, you may have unintentionally changed it to CR/LF.

Maybe you could try changing the line endings to LF and regenerate the
patch, to see if that fixes the problem?


      was (Author: gbrown):
    Any chance you could try to regenerate this patch? It is tough to see
what actually changed because so many lines are flagged.

It is possible that you changed the line endings, such that every line looks
like it changed?


  
> create an annotation to specify the default "child" property of a
component used by the serializer to attach children objects
>
----------------------------------------------------------------------------
-------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: defaultpropertypatch.zip
>
>
> Add an annotation called @ContentProperty that specifies the default
property to attach children to in the serializer. I found that I was making
mistakes when creating WTKX that this annotation and a default "child
attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children
to. 
> b) To add objects to a collection the parent object does not need to
extend from sequence. The sequence can be contained in the object instead of
implementing the interface. Containment can be another approach to getting
content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment
occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple
extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the
child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled
today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is
handled today.
> I wrote this for a small modeled framework similar to pivot and could work
up a couple of patches for this. This is very similar to how wpf handles
child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Appddevvv (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Appddevvv updated PIVOT-514:
----------------------------

    Attachment: defaultpropertypatch.zip

Updated patch. The WTKXSerializer are patch notes not a real patch but shows the 3-4 lines that change in the java file with some lines before and after for context.

> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: defaultpropertypatch.zip, defaultpropertypatch.zip
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Appddevvv (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875513#action_12875513 ] 

Appddevvv commented on PIVOT-514:
---------------------------------

I'll work up a patch with DefaultProperty and try to figure out how you are implementing testing to add some tests.

As a thought, I don't bind being a little specific compared to any other systems. I think you'll eventually need similar capabilities that other similar frameworks have implemented as pivot is built out especially around working across the logical component tree, managing a property system that is robust, improving compiler/tool checking so everything is not completely string based or decoupling from the listener pattern and decoupling styles/triggers in a tool friendly way or using more interfaces versus concrete classes.  All of these things can become quite burdensome to manage without some type of support: e4, wpf, etc.  I hit many of the same framework issues when I was sketching out a similar system and started implementation. But one step at a time based on need.



> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Appddevvv (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Appddevvv updated PIVOT-514:
----------------------------

    Attachment: defaultpropertypatch.zip

The patches Window, Border and WTKXSerializer. Unfortunately, a reformat seems to have changed the WTKXSerializer class but the actual change is only 4-5 lines. I did not know how to undo the format issue that caused the patch to grow.

The other two files (the annotation and some static utils methods) need be placed in the same package as WTKXSerializer.


> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: defaultpropertypatch.zip
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Appddevvv (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875967#action_12875967 ] 

Appddevvv commented on PIVOT-514:
---------------------------------

Well I created the code for the default property and it seems to work well.  I only had to modify a few lines in the serializer class to add in some code that I had to deal with this already. Everything works as expected. However, I did notice a few areas of concern that affects the "safety" of using the serializer.

a) The current tree of wtk components often inherit from container. The container implements sequence. The serializer already automatically added elements to the sequence if no property was found. That's fine. However, I noticed (and tested) that illogical elements could be added to the sequence and that elements could be added to the sequence (if no property was specified) that did not make sense or produce the wrong listener behavior. That is, adding a component to a container would be allowed in the serializer but would be the improper use of the parent object. 

Take SplitPane. It needs to have the left and right property set in order to fire listeners but if they are added to the sequence parent directly, the split pane listeners are not fired. The serializer and the user would never know until they debugged the situation and realized that they need to set the properties explicitly event though the serializer may not care. This is an inherent usage danger with the serializer. Obviously, if the split pane observed or intercepted the sequence mutating calls it could of course, fire the listeners regardless of how the components were added to the "container."

b) By adding a default property, it is possible to always have the right property set and further "safety checks" could be made.

c) Relying on the sequence in a container parent can also has less type safety versus a contained component list embedded in the object.

I think that relying on the sequence in container for the parent-child tree during tree construction can lead to confusing use by clients and I am raising this issue.  The only way to easily change this is to separate out the current container-component tree and create a tree based on the default property and/or a contained component list (which would be set as the default property).

I'm not proposing that we start constructing a different tree at this point but wanted to raise this as a discussion point. Its not clear that this is causing pivot clients alot of grief at the moment.  Creating a different tree structure has complexity all on its own, but the use of the serializer can lead to unexpected behavior if not used correctly.  Perhaps this could be a 2.0 discussion point and I'll think about raising this as a separate issue.

I'll submit the patch on the original intent of this issue (the default property) in a bit. I was looking into the parser to see if I could easily (without major changes) allow free text as a child element and have that automatically added to the default property or text property as well.


> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Appddevvv (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875967#action_12875967 ] 

Appddevvv edited comment on PIVOT-514 at 6/6/10 8:23 AM:
---------------------------------------------------------

Well I created the code for the default property and it seems to work well.  I only had to modify a few lines in the serializer class to add in some code that I had to deal with this already. Everything works as expected. However, I noticed a few areas of concern that affects the "safety" of using the serializer.

a) The current tree of wtk components often inherit from container. The container implements sequence. The serializer already automatically added elements to the sequence if no property was found. That's fine. However, I noticed (and tested) that illogical elements could be added to the sequence and that elements could be added to the sequence (if no property was specified) that did not make sense or produce the wrong listener behavior. That is, adding a component to a container would be allowed in the serializer but would be improper use of the parent.

Take SplitPane. It needs to have the left and right property set in order to fire listeners but if they are added to the sequence parent directly, the split pane listeners are not fired. The serializer and the user would never know until they debugged the situation and realized that they need to set the properties explicitly event though the serializer may not care. This is an inherent usage danger with the serializer. Obviously, if the split pane observed or intercepted the sequence mutating calls it could of course, fire the listeners regardless of how the components were added to the "container."

b) By adding a default property, it is possible to always have the right property set and further "safety checks" could be made.

c) Relying on the sequence in a container parent has less type safety versus a contained component list embedded in the object.

I think that relying on the sequence in container for the parent-child tree during tree construction can lead to confusing use by clients and I am raising this issue.  The only way to easily change this is to separate out the current container-component tree and create a tree based on the default property and/or a contained component list (which would be set as the default property).

I'm not proposing that we start constructing a different tree at this point but wanted to raise this as a discussion point. Its not clear that this is causing pivot clients alot of grief at the moment.  Creating a different tree structure has complexity all on its own, but the use of the serializer can lead to unexpected behavior if not used correctly.  Perhaps this could be a 2.0 discussion point and I'll think about raising this as a separate issue.

I'll submit the patch on the original intent of this issue (the default property) shortly. I was looking into the parser to see if I could easily (without major changes) allow free text as a child element and have that automatically added to the default property or text property as well.


      was (Author: aappddeevv):
    Well I created the code for the default property and it seems to work well.  I only had to modify a few lines in the serializer class to add in some code that I had to deal with this already. Everything works as expected. However, I did notice a few areas of concern that affects the "safety" of using the serializer.

a) The current tree of wtk components often inherit from container. The container implements sequence. The serializer already automatically added elements to the sequence if no property was found. That's fine. However, I noticed (and tested) that illogical elements could be added to the sequence and that elements could be added to the sequence (if no property was specified) that did not make sense or produce the wrong listener behavior. That is, adding a component to a container would be allowed in the serializer but would be the improper use of the parent object. 

Take SplitPane. It needs to have the left and right property set in order to fire listeners but if they are added to the sequence parent directly, the split pane listeners are not fired. The serializer and the user would never know until they debugged the situation and realized that they need to set the properties explicitly event though the serializer may not care. This is an inherent usage danger with the serializer. Obviously, if the split pane observed or intercepted the sequence mutating calls it could of course, fire the listeners regardless of how the components were added to the "container."

b) By adding a default property, it is possible to always have the right property set and further "safety checks" could be made.

c) Relying on the sequence in a container parent can also has less type safety versus a contained component list embedded in the object.

I think that relying on the sequence in container for the parent-child tree during tree construction can lead to confusing use by clients and I am raising this issue.  The only way to easily change this is to separate out the current container-component tree and create a tree based on the default property and/or a contained component list (which would be set as the default property).

I'm not proposing that we start constructing a different tree at this point but wanted to raise this as a discussion point. Its not clear that this is causing pivot clients alot of grief at the moment.  Creating a different tree structure has complexity all on its own, but the use of the serializer can lead to unexpected behavior if not used correctly.  Perhaps this could be a 2.0 discussion point and I'll think about raising this as a separate issue.

I'll submit the patch on the original intent of this issue (the default property) in a bit. I was looking into the parser to see if I could easily (without major changes) allow free text as a child element and have that automatically added to the default property or text property as well.

  
> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-514:
-----------------------------

    Fix Version/s: 1.6

> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown resolved PIVOT-514.
------------------------------

    Resolution: Fixed

This has been resolved. I'll open another ticket for adding default properties to classes where it makes sense.


> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: DefaultProperty.java, defaultpropertypatch.zip, defaultpropertypatch.zip, PIVOT-514.patch
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-514) Create an annotation to specify the default "child" property of a component

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-514:
-----------------------------

    Summary: Create an annotation to specify the default "child" property of a component  (was: create an annotation to specify the default "child" property of a component used by the serializer to attach children objects)

> Create an annotation to specify the default "child" property of a component
> ---------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 2.0
>
>         Attachments: DefaultProperty.java, defaultpropertypatch.zip, defaultpropertypatch.zip, PIVOT-514.patch
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877180#action_12877180 ] 

Greg Brown commented on PIVOT-514:
----------------------------------

Any chance you could try to regenerate this patch? It is tough to see what actually changed because so many lines are flagged.

It is possible that you changed the line endings, such that every line looks like it changed?



> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: defaultpropertypatch.zip
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875300#action_12875300 ] 

Greg Brown commented on PIVOT-514:
----------------------------------

It's not a bad idea - Flex has a similar concept. ContentProperty is probably a little too specific to the Window class, but DefaultProperty (which is what Flex calls it) might work.


> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877180#action_12877180 ] 

Greg Brown edited comment on PIVOT-514 at 6/9/10 3:59 PM:
----------------------------------------------------------

Is it possible that you changed the line endings, such that every line looks like it changed? I believe it used UNIX/OS X line endings (LF) originally. If you are on Windows, you may have unintentionally changed it to CR/LF.

Maybe you could try changing the line endings to LF and regenerate the patch, to see if that fixes the problem?


      was (Author: gbrown):
    Any chance you could try to regenerate this patch? It is tough to see what actually changed because so many lines are flagged.

It is possible that you changed the line endings, such that every line looks like it changed?


  
> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: defaultpropertypatch.zip
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-514) create an annotation to specify the default "child" property of a component used by the serializer to attach children objects

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-514:
-----------------------------

    Attachment: PIVOT-514.patch
                DefaultProperty.java

OK, thanks for the updated patch. I think this can be done without the need for the utils class - see attached patch.

There was also an issue with the setOrAddDefaultPropertyContent() method in SerializerUtils - that method checked for instances of java.util.Collection, where it should have been looking for org.apache.pivot.collections.Sequence (nothing in Pivot implements java.util.Collection).

Overall, I like the change. It can significantly reduce the size/nesting depth of a WTKX file. See the changes to tab_panes.wtkx in the patch for an example.


> create an annotation to specify the default "child" property of a component used by the serializer to attach children objects
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-514
>                 URL: https://issues.apache.org/jira/browse/PIVOT-514
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>             Fix For: 1.6
>
>         Attachments: DefaultProperty.java, defaultpropertypatch.zip, defaultpropertypatch.zip, PIVOT-514.patch
>
>
> Add an annotation called @ContentProperty that specifies the default property to attach children to in the serializer. I found that I was making mistakes when creating WTKX that this annotation and a default "child attachment" approach could help. Benefits include:
> a) The client does not need to know which property to attach the children to. 
> b) To add objects to a collection the parent object does not need to extend from sequence. The sequence can be contained in the object instead of implementing the interface. Containment can be another approach to getting content into the parent objects versus inheritance.
> c) You can change some of the properties in the class where attachment occurs and your WTKX files do not have to change.
> The default mechanism would be similar to what exists today. It's a simple extension of it. The "attach child" search would be:
> a) If the content property is specified, use that property to add the child to. If the content property is a collection, add it to the collection.
> b) If the content property is not specified,
> b.1) If the parent object is a collection (this is how it is handled today) then add it to the collection using the List.add(Object) method.
> b.2) Add it to the property specified in the XML. This is also how it is handled today.
> I wrote this for a small modeled framework similar to pivot and could work up a couple of patches for this. This is very similar to how wpf handles child content specifications in XML. Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.