| # GUI Commands User Guide ## Version 2.1 |
| # Delegating Commands DelegatingCommands allow you to create a command whose actual implementation is late bound based on the current UI state. Typical examples include the print, cut, copy and paste operations since they are always in menus and on toolbars but their behaviour typically depends on the currently focused component. DelegatingCommands are also useful when you reguire a command to be accessed from a top level of a container hierarchy ## Overview The following gives an outline of how DelegatingCommands interact with DelegateMediator. Once bound, the DelegatingCommand searchs the container hierarchy for a DelegateMediator. The DelegateMediator tracks the currently focused component and scans the swing hierarchy for components that implement DelegateProvider. The mediator notifies the DelegatingCommand whenever the provider hierarchy changes. The DelegatingCommand updates to use the newly discovered delegates. The following diagram illustrates: NOTE: You typically on need one DelegateMediator instance per frame since the DelegatingCommands will search the container hierarchy for the nearest instance. |