Lieven Dekeyser <email@hidden> wrote:
>The description contains a list of abstract visual component and
>controller descriptions. These are interconnected with reference
>relations, which, at runtime, result in references being set to link to
>the actual visual components.
It seems you've also tied your abstraction to the fundamental assumption of
a single menubar. That is, you haven't abstracted the relationship between
menubar and window.
>There are abstract Menu and Menu Item types that are being mapped to
>JMenu and JMenuItem in Java/Swing, but could be mapped to NSMenu and
>NSMenuItem in Cocoa. The controller implementation in Java/Swing will
>use references to the actual JMenu and JMenuItem instances to change
>these instances' states.
If the controller implementation will use actual references, then that's a
conscious design decision. It's the obvious mapping when going from NSMenu
to JMenu, but only because you've fundamentally assumed there's a single
menubar. That is, you've assumed that the Cocoa model is the only model
possible.
If you step away from that fundamental assumption, then you can insert
proxies that appear to be single menus in a single menubar, but are
actually backed by however many JMenus and JMenuItems are needed in order
to have a JMenuBar per window. In other words, the proxy isolates the
design premise (single menubar) from the actual implementation (JMenuBar
per window).
>If a Java/Swing implementation decides to
>change some aspect of a menu at runtime, it needs the reference to the
>actual instance, and that would not be possible if there are multiple
>copies of these objects.
If there's a single instance of the proxy, let's call it MenuProxy, then it
takes care of changing however many actual instances of JMenu are tied to
it. The application side sees a single MenuProxy (and MenuBarProxy, and
MenuItemProxy). What goes on behind the proxy is irrelevant. And the
relationship between MenuItemProxy and JMenuItem or Action is also hidden,
in the implementation of the proxy class.
If some other toolkit ever did present an actual single menubar, then the
proxy API is identical, but the implementation has only one menu element
per proxy, instead of several.
This can also be viewed as the Facade pattern, because of its simplifying
effect, or an Adapter pattern, for the way it presents one API towards the
application, yet another API (of menubar per window) towards the underlying
elements.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden