Another way a TopComponent can be context sensitive is in the requirement that the menubar and toolbar need to relate to a specific TopComponent. Below you see that when Win1 is active, a different group of menus and toolbars is available...
... than when Win2 is active:
Part of the solution to this is described here recently about multiple rows of toolbars. However, this only addresses the topic of toolbars. What about menubars? And maybe other components too? I.e., when a TopComponent is active, it would be great if a subfolder of the FileSystem would become enabled, while all other parts would become disabled.
The complete solution to this scenario has been described before, here. Jesse Glick has all the code for this here:
What the above lets you do is create layer entries like this:
<attr name="position" intvalue="150"/>
<attr name="position" intvalue="250"/>
Then, each TopComponent can specify which folder they want to own:
The "SystemSubPathLayerProvider" does all the work in the background to enable and disable items appropriately, whether they are toolbars, menubars, or whatever else.
Nothing is written to disk, this is all done programmatically within the code, and not written to the user directory.