Decorator works! At least in the early tests.  See my comments with >>>

Thanks! I'll test creating a map using elements (for the user data). That
would finish all the use cases out.

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

> - Explain exactly what it is you are trying to do in as few sentences as
> possible.
> 
>> 
>> Create reusable behaviors with minimalistic API and usage requirements.

Could you use the Action API here?

>>>Will check. Don't think so for these use-cases.


>> I am putting a
>> cross-cutting concern into the Component's scope and allowing it to
>> initialize itself on the component. I'm pushing code up into the class
>> inheritance tree but not using a dynamic language to do it.

I assume you mean "component hierarchy" (or "object hiearchy") vs. "class
inheritance tree", since you mentioned that you were trying to do this
without subclassing - correct?

>>>Yup...actually both into the inheritance tree and up the logical tree
kind-of.

> - Describe how you have tried to apply existing Pivot constructs to solve
> the problem, including source code as needed.
> 
>> 
>> By scripting and subclassing the serializer.

That's a pretty big hammer. The reason that I'm continuing to try to draw
out your requirements is because I suspect there may be a simpler solution
(or at least part of a solution).

>>>Yes, but it solves the problem transparently more or less and puts 1 or 2
mechanisms in one place that enables a lot of capability. I actually don't
consider it a big hammer. UI are typically about object lifecycle management
and resource lifecycle management--getting the right resources to the object
at the right to paint something.


> a) Added a find method to UserDataDictionary

I could potentially see an argument for adding this type of functionality.
Even though styles don't inherit, there is no reason that user data can't.
On the other hand, it's pretty easy to put the tree traversal code at the
app level, and, as you pointed out, there are some hidden gotchas if you try
to access data that hasn't been defined yet. 


>>>I'm okay either way if I can bundle things into reusable chunks and make
it easier to share those chunks without requiring clients to subclass or use
scripting, etc. I actually found it useful for the find() in working with
supplying data and shared resources for child views. Its nice that it could
always be there. The gotchas are no worse than anything else if you use
during tree construction.
 

> b) Intercepted the paint(Graphics2D) method. Don't know if that's the
right
> place. But it was the only place I could find to apply the styles
> consistently and the tree was fully built:

Maybe you could solve this problem via decorators? Decorators are designed
specifically to allow a caller to add additional painting behavior to a
component without subclassing (which sounds a lot like what you are trying
to do). Also, your pre- and post-processing methods look a lot like
Decorator's prepare() and update() methods.

>>> I spent 10 min writing moving the code to a decorator and at first blush
it looks like it works. The only error I received was that the Decorator
cannot have 0,0,0,0 bounds and null affine transform's returned--fixed that.
Seems to work enough for me! And its added to all components transparently
through the serializer. I'll keep an eye on it to ensure that the decorator
sequence is not causing a problem.

If anyone wants simple inheritable styles I can post it. You can sprinkle it
in anytime you want. 

> To be honest, I have spent more time trying to get a
> split pane (horizontal) to show another split pane (right side, but
> vertical) than inherited styles.

This is supported and is demonstrated in the Kitchen Sink tutorial. What is
the problem you are running into?

>>>I'll check it out. Never been able to get any of the demos to work across
3 browsers.  Not sure where kitchen sink code is at...could not find in
subversion.

My toplevel split pane shows everything fine. But when I put a grid or
boxpane into a split view (right side), its disappearing completely. No
divider or anything. If I just put a label or a grid directly into the top
level split pane, it shows up. I spent more time playing around with this
and looking at the demos (did not see KitchenSink in the demo sub-project).
I'm not even sure how to debug it.


Reply via email to