Project: Eclipse_Platform_UI
Bug 250198 [CommonNavigator] Allow CommonNavigator to be subclassed
Reported: 2008-10-08 18:43:28 | Status: verified fixed

I believe CommonNavigator.java should be subclassable. I'm not sure why it is not intended to be subclassed. Many of the individual components ARE intended to be subclassed. I've read many many bugs where users are subclassing CommonNavigator anyway, to get around other bugs or deficiencies. I think this ability to subclass is valuable and important. I'm attaching a patch to allow for easier subclassing of the CommonNavigator class. By adding a protected getMemento() method, an adopter can override both the createCommonViewer and createCommonManager methods. By changing getLinkHelperService() to protected, the user can better override the createCommonActionGroup method with a subclass implementation of the CommonNavigatorActionGroup class. These slight changes would make the CommonNavigator class much easier to override in bits and pieces. I think it is important. Currently, CommonViewer *is* allowed to be subclassed, but to create a Common Navigator with just a slight tiny change to CommonViewer, I'd need to copy the entire CommonNavigator class because createCommonViewer() includes the line: aViewer.getNavigatorContentService().restoreState(memento); which requires access to the memento, which is private. Again, these tiny changes would make subclassing much easier without ruining anything.

Files changed in fix:
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/CommonNavigatorActionGroup.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/CommonNavigatorManager.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/actions/LinkEditorAction.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/extensions/LinkHelperService.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonNavigator.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/CommonNavigatorManager.java bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/navigator/LinkHelperService.java