Index: ApplicationComponentContainer.cs =================================================================== --- ApplicationComponentContainer.cs (revision 9580) +++ ApplicationComponentContainer.cs (working copy) @@ -31,6 +31,8 @@ using System.Collections.Generic; using ClearCanvas.Desktop.Validation; +using ClearCanvas.Common; +using System; namespace ClearCanvas.Desktop { @@ -39,6 +41,81 @@ /// public abstract class ApplicationComponentContainer : ApplicationComponent, IApplicationComponentContainer { + /// + /// Defines an application component host appropriate for the components the + /// will contain. The host overrides delegate to + /// the host of the parent container. + /// + public class SubHost : ApplicationComponentHost + { + private ApplicationComponentContainer _owner; + + /// + /// Contruct the contained sub host with the + /// owner that will provide access to the real host. The contained component is passed + /// to the base . + /// + /// + /// + public SubHost( + ApplicationComponentContainer owner, + IApplicationComponent component) + : base(component) + { + Platform.CheckForNullReference(owner, "owner"); + + _owner = owner; + } + + #region ApplicationComponentHost overrides + + /// + /// Gets the associated desktop window. + /// + public override DesktopWindow DesktopWindow + { + get { return OwnerHost.DesktopWindow; } + } + + /// + /// Gets the title displayed in the user-interface. + /// + /// + /// The title generally cannot be set. This behavior is inherited from the + /// base. + /// + /// The host does not support titles. + public override string Title + { + get { return OwnerHost.Title; } + // individual components cannot set the title for the container + set { throw new NotSupportedException(); } + } + + /// + /// Contained components will use the comand history provided by the host that + /// owns the container. + /// + public override CommandHistory CommandHistory + { + get + { + return OwnerHost.CommandHistory; + } + } + + #endregion + + /// + /// Provide access to the owning host in case subclasses need to override host behavior not + /// already handled by this class. + /// + protected IApplicationComponentHost OwnerHost + { + get { return _owner.Host; } + } + } + private IApplicationComponentContainerValidationStrategy _validationStrategy; /// Index: ChildComponentHost.cs =================================================================== --- ChildComponentHost.cs (revision 9580) +++ ChildComponentHost.cs (working copy) @@ -69,5 +69,16 @@ get { return _parentHost.Title; } } + /// + /// Gets the parent's command history + /// + public override CommandHistory CommandHistory + { + get + { + return _parentHost.CommandHistory; + } + } + } } Index: PagedComponentContainer.cs =================================================================== --- PagedComponentContainer.cs (revision 9580) +++ PagedComponentContainer.cs (working copy) @@ -85,41 +85,14 @@ { /// /// Defines an application component host for one page. - /// - private class PageHost : ApplicationComponentHost + /// + private class PageHost : ApplicationComponentContainer.SubHost { - private readonly PagedComponentContainer _container; - internal PageHost(PagedComponentContainer container, ContainerPage page) - : base(page.Component) + : base(container, page.Component) { - _container = container; - } - #region ApplicationComponentHost overrides - - /// - /// Gets the that owns the . - /// - public override DesktopWindow DesktopWindow - { - get { return _container.Host.DesktopWindow; } } - - /// - /// Gets the title of the . - /// - /// - /// The set method is unsupported and will throw an exception. - /// - public override string Title - { - get { return _container.Host.Title; } - // individual components cannot set the title for the container - set { throw new NotSupportedException(); } - } - - #endregion } private class PageList : ObservableList Index: SimpleComponentContainer.cs =================================================================== --- SimpleComponentContainer.cs (revision 9580) +++ SimpleComponentContainer.cs (working copy) @@ -49,39 +49,25 @@ [AssociateView(typeof(SimpleComponentContainerViewExtensionPoint))] public class SimpleComponentContainer : ApplicationComponentContainer { - private class ContainedComponentHost : ApplicationComponentHost + private class ContainedComponentHost : ApplicationComponentContainer.SubHost { - private SimpleComponentContainer _owner; - - internal ContainedComponentHost( - SimpleComponentContainer owner, - IApplicationComponent component) - : base(component) + internal ContainedComponentHost( + SimpleComponentContainer owner, + IApplicationComponent component) + : base(owner, component) { - Platform.CheckForNullReference(owner, "owner"); - _owner = owner; } #region ApplicationComponentHost overrides - /// - /// Gets the associated desktop window. - /// - public override DesktopWindow DesktopWindow + /// + /// Gets or sets the title displayed in the user-interface. + /// + public override string Title { - get { return _owner.Host.DesktopWindow; } + set { OwnerHost.Title = value; } } - /// - /// Gets or sets the title displayed in the user-interface. - /// - /// The host does not support titles. - public override string Title - { - get { return _owner.Host.Title; } - set { _owner.Host.Title = value; } - } - #endregion } Index: SplitComponentContainer.cs =================================================================== --- SplitComponentContainer.cs (revision 9580) +++ SplitComponentContainer.cs (working copy) @@ -68,49 +68,17 @@ { /// /// A host for a . - /// - private class SplitPaneHost : ApplicationComponentHost + /// + private class SplitPaneHost : ApplicationComponentContainer.SubHost { - private SplitComponentContainer _owner; - - internal SplitPaneHost( - SplitComponentContainer owner, - SplitPane pane) - :base(pane.Component) + internal SplitPaneHost(SplitComponentContainer owner, + SplitPane pane) + : base(owner, pane.Component) { - Platform.CheckForNullReference(owner, "owner"); - _owner = owner; } - - #region ApplicationComponentHost overrides - - /// - /// Gets the associated desktop window. - /// - public override DesktopWindow DesktopWindow - { - get { return _owner.Host.DesktopWindow; } - } - - /// - /// Gets the title displayed in the user-interface. - /// - /// - /// The title cannot be set. - /// - /// The host does not support titles. - public override string Title - { - get { return _owner.Host.Title; } - // individual components cannot set the title for the container - set { throw new NotSupportedException(); } - } - - #endregion } - private SplitPane _pane1; private SplitPane _pane2; private SplitOrientation _splitOrientation; Index: TabGroupComponentContainer.cs =================================================================== --- TabGroupComponentContainer.cs (revision 9580) +++ TabGroupComponentContainer.cs (working copy) @@ -69,43 +69,13 @@ /// /// A host for s. /// - private class TabGroupHost : ApplicationComponentHost + private class TabGroupHost : ApplicationComponentContainer.SubHost { - private TabGroupComponentContainer _owner; - - /// - /// Constructor. - /// - /// The container that owns this host. - /// The that is hosted by this object. - internal TabGroupHost(TabGroupComponentContainer owner, TabGroup tabGroup) - : base(tabGroup.Component) + internal TabGroupHost( + TabGroupComponentContainer owner, TabGroup tabGroup) + : base(owner, tabGroup.Component) { - Platform.CheckForNullReference(owner, "owner"); - _owner = owner; } - - #region ApplicationComponentHost overrides - - /// - /// Gets the title of the parent container. - /// - public override string Title - { - get { return _owner.Host.Title; } - // individual components cannot set the title for the container - set { throw new NotSupportedException(); } - } - - /// - /// Gets the that owns the parent container. - /// - public override DesktopWindow DesktopWindow - { - get { return _owner.Host.DesktopWindow; } - } - - #endregion } private List _tabGroups;