PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: coulix on November 25, 2008, 04:40:16



Title: Mediator with multiple views, toolbar stack ?
Post by: coulix on November 25, 2008, 04:40:16
Hi guys,

I am facing a design problem i havent encountered before.

I have a BoardView with a boardMediator
a boardToolbarView with boardToolbarMediator, the toolbar it a tile of several Shapes.

Each Shape should be associated to a toolbar for its type (rectangle, circle, etc).

Instead of creating a RectangeToolbarMediator, CircleToolbarMediator etc ...
for each type can i create just one ShapeToolbarMediator registering several views CircleToolbarView, RectangeToolbarView etc.


Then when my boardToolMediator send a toolchange notification, ShapeToolbarMediator will listen for it and display the appropriate shapeToolbarView.

How would you do such a thing ?

-------------------
|                      H |     H: boardToolBar
|                      H |     x: shapeToolBar
|             xxx     H |
-------------------

Thanks




Title: Re: Mediator with multiple views, toolbar stack ?
Post by: puremvc on November 25, 2008, 06:50:44
Depends on haw much granularity you actually need. Will each shape toolbar be dispatching a bunch of events that could bubble and have the board toolbar mediator handle? Perhaps it hears the shape type and which toolbar function and triggers a different command? 

-=Cliff>


Title: Re: Mediator with multiple views, toolbar stack ?
Post by: coulix on November 25, 2008, 07:03:02
Each Shape property toolbar will be dispatching events to be handle by the Property Toolbar mediator (fill color, line color) which in turn sends a notification to the BoardMediator.
Board Mediator being responsible for creating the shapes on the board.

The BoardToolBar mediator only handles the tool choices: select, pen, rectangle, circle ...
The PropertyToolbar mediator will take care of the property details of the current tool (fill ...)

I am trying to use a view stack as the propertyToolbarView for now.

I dont think i need a mediator for each property toolbar.


Title: Re: Mediator with multiple views, toolbar stack ?
Post by: Jason MacDonald on November 25, 2008, 07:07:08
If you are using Flex, why not make one toolbar and use States to to manage the different types of toolbars? This works particularly well if you have common buttons that span all the different toolbars. Use your selected shape type (circle, square, etc) as the state name, dispatching it to the toolbar component to change states.


Title: Re: Mediator with multiple views, toolbar stack ?
Post by: coulix on November 25, 2008, 07:19:25
I did not know about states looking at it right now,
Thanks  :D


Title: Re: Mediator with multiple views, toolbar stack ?
Post by: Jason MacDonald on November 25, 2008, 07:32:28
I did not know about states looking at it right now,
Thanks  :D

Glad I could help :)