Forwarding of Java Property Changes from EventList beans to listener

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Forwarding of Java Property Changes from EventList beans to listener

Andrew Swenson
Is there a Glazed List Solution to the following problem?

I have a list of beans with properties X,Y,Z.
I am not interested in keeping track of beans being added or removed (thats what glazed lists is for).
I am interested in doing something special when any bean fires a property event whos name is "X".

Is there any way or workaround though subclassing where i can say something like:

eventList.addPropertyChangeListener("X", class whos interested in property changes of type X)

ObservableElementList does 90% of this, because it keeps track of which elements are added and removed from the list, but it does not let me know which property changed.
Reply | Threaded
Open this post in threaded view
|

Re: Forwarding of Java Property Changes from EventList beans to listener

James Lemieux
I think you're looking to use this method in the GlazedLists factory class when creating your Connector for your ObservableElementList:

public static <E> ObservableElementList.Connector<E> beanConnector(Class<E> beanClass, boolean matchPropertyNames, String... propertyNames)

James

On Thu, Mar 6, 2008 at 3:42 PM, Swensation <[hidden email]> wrote:

Is there a Glazed List Solution to the following problem?

I have a list of beans with properties X,Y,Z.
I am not interested in keeping track of beans being added or removed (thats
what glazed lists is for).
I am interested in doing something special when any bean fires a property
event whos name is "X".

Is there any way or workaround though subclassing where i can say something
like:

eventList.addPropertyChangeListener("X", class whos interested in property
changes of type X)

ObservableElementList does 90% of this, because it keeps track of which
elements are added and removed from the list, but it does not let me know
which property changed.
--
View this message in context: http://www.nabble.com/Forwarding-of-Java-Property-Changes-from-EventList-beans-to-listener-tp15885403p15885403.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Forwarding of Java Property Changes from EventList beans to listener

Andrew Swenson
In reply to this post by Andrew Swenson
Would it be reasonable to extend:

ca.odell.glazedlists.impl.beans.JavaBeanEventListConnector

and override createPropertyChangeListener().  There, my property change listener be able to intercept property changes, and do the specific thing i want.   Everything else in the connector is exactly what i want, so i dont want to reimplement this.  Does that sound about right?

It seems like createPropertyChangeListener() being protected implies thats where i should be making the change.




Reply | Threaded
Open this post in threaded view
|

Re: Forwarding of Java Property Changes from EventList beans to listener

James Lemieux
Andrew,

   So, I think I'm understanding your problem a little more thoroughly. You aren't interested in the facilities provided by ObservableElementList. Instead, you're looking to watch the elements of the list for specific property changes which invoke some "special logic" of your own. If that's the case, I'd recommend using a different mechanism:

Use a FunctionList and implement the FunctionList.AdvancedFunction interface. In that AdvancedFunction implementation, rather than transforming an element into some new kind of Object, use it as a hook to install/uninstall your PropertyChangeListener and then return the original element from your function. (It's sort of like the IdentityFunction in that it doesn't actually change the Object) By implementing AdvancedFunction you should also get a dispose() callback for each element when the FunctionList is disposed(). This would be your chance to uninstall the PropertyChangeListener when the FunctionList is no longer useful.

Hope this helps,

James

On Fri, Mar 7, 2008 at 8:47 AM, Andrew Swenson <[hidden email]> wrote:

Would it be reasonable to extend:

ca.odell.glazedlists.impl.beans.JavaBeanEventListConnector

and override createPropertyChangeListener().  There, my property change
listener be able to intercept property changes, and do the specific thing i
want.   Everything else in the connector is exactly what i want, so i dont
want to reimplement this.  Does that sound about right?

It seems like createPropertyChangeListener() being protected implies thats
where i should be making the change.





--
View this message in context: http://www.nabble.com/Forwarding-of-Java-Property-Changes-from-EventList-beans-to-listener-tp15885403p15900647.html
Sent from the GlazedLists - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]