We are currently building an application which visualizes thousands of entities, simultaneously, in different ways - for example in a geographical map view, or in a data grid.
These entities are organized hierarchically, and so there are开发者_如何学运维 various meaningful subgrouping of entities.
Also the map view lets you make arbitrary selections using a lasoo-type tool.
What we need is for all views to be synchronized such that what you select in one view is reflected in the others.
Each of these view components do not know about each other.
Im looking for design patterns and/or open source applications which demonstrate approaches to item selction in a complex multi-view app.
I would use an event-listener pattern (publish/subscribe if you like)
You can create class SelectionManager in the model or anywhere else where views could access it.
All views subscribe to selection to get selectionChanged(SelectionEvent e) event. Active view (the one user interacting with) would be reporting(publishing) this event to the SelectionManager, triggering selectionChanged(SelectionEvent e).
When the view get this event, and if the view is not the source(originator/publisher) of this event - update its selection.
精彩评论