This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 201246 - Need a way to provide a custom Navigator window
Summary: Need a way to provide a custom Navigator window
Alias: None
Product: platform
Classification: Unclassified
Component: Navigator (show other bugs)
Version: 7.1
Hardware: PC Other
: P2 normal (vote)
Assignee: Tomas Pavek
Depends on:
Reported: 2011-08-23 12:03 UTC by Tomas Pavek
Modified: 2011-09-01 14:21 UTC (History)
2 users (show)

See Also:
Exception Reporter:

suggested patch (without apichanges and manifest version upgrade) (51.19 KB, text/plain)
2011-08-23 14:45 UTC, Tomas Pavek

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Pavek 2011-08-23 12:03:36 UTC
For the purpose of integration with JDev we need a possibility to reuse the NB navigator (the way it gets the specific panels from providers), but allow to provide a different visualization of the panels. The navigator defines its own TopComponent (NavigatorTC) which shows the panels and allow to switch between them. We'd need to replace it with a different TopComponent and different UI for presenting the panels.

1) The interface that can be abstracted for this purpose from NavigatorTC could be as follows:

public interface NavigatorDisplayer {
    String PROP_PANEL_SELECTION = "navigatorPanelSelection"; // NOI18N

    void setDisplayName(String name);
    void setPanels (List<NavigatorPanel> panels, NavigatorPanel select);
    List<NavigatorPanel> getPanels();
    void setSelectedPanel(NavigatorPanel panel);
    NavigatorPanel getSelectedPanel();
    void addPropertyChangeListener(PropertyChangeListener l);
    void removePropertyChangeListener(PropertyChangeListener l);
    boolean allowAsyncUpdate();
    TopComponent getTopComponent();

These are basically existing methods in NavigatorTC, so almost no changes are needed in navigator itself for the implementation. We just need to make this API available for someone else to implement differently.

2) Besides the presentation abstraction there's also the navigator initialization itself: how it gets started. Currently it does not do anything (is even not created) until there is the UI that shows it (i.e. the NavigatorTC). We should preserve this deferred initialization. This means that there must be some explicit call from the UI to the navigator to initialize it. The navigator itself has no chance to identify the moment when it should start working (collecting data from providers). For that we also need some API method.

3) When the alternative presentation is used then we also need to hide the Navigator's default TopComponent and its action in Window menu.

So can we achieve this? There can be several variants. Would like to prefer something simple not requiring to rewrite the navigator module completely ;). One question is if this should be public API at all when the use case is so specific (nothing that would be needed by anybody within NetBeans), but having non-public APIs between different products is problematic. So let's explore the public API variants.
Comment 1 Tomas Pavek 2011-08-23 14:45:58 UTC
Created attachment 110159 [details]
suggested patch (without apichanges and manifest version upgrade)
Comment 2 Tomas Pavek 2011-08-23 14:52:42 UTC
Here's a suggestion for a minimalistic solution.

1) Expose the NavigatorDisplayer as interface in the API.
2) Make NavigatorTC implement it.
3) Make NavigatorController work with the abstraction instead of with NavigatorTC directly.
4) Introduce static method NavigatorHandler.activate which initializes the navigator when using a custom displayer.

I have prototyped this solution, see attached patch. Let's see if we can get it reviewed in this state, or need more discussion/full review.

The attached patch tries to minimize the changes in the module. I've separated NavigatorTC and NavigatorController and cleaned the relation between them a bit, but it is not complete to that point that NavigatorTC could be moved to a separate module. That would be more work, incl. fixing tests and deal with window system settings (due to change of TC class name). Probably not worth doing at this point. It also allows to keep the navigator module overall work the same way as so far. lowering a chance to introduce new bugs.

Custom NavigatorDisplayer can be registered as a service provider in META-INF/service. I have a working implementation in JDev.

If there is a need to evolve the API in NavigatorDisplayer, then an additional interface will have to be introduced (e.g. NavigatorDisplayer2, etc). Given the stability of the navigator module (nothing changing for years) that hopefully won't be needed very often.

To make the custom NavigatorDisplayer work it must be ensured that the default NavigatorTC is not created by winsys - initializing navigator for itself. For that we could put the layer registrations of window system data (and also the action in Window menu) into a separate module that could be excluded. Not in the attached patch, can possibly be done separately.

Part of the patch I've fixed all tests (were mostly broken).

Anything else is missing?
Comment 3 Tomas Pavek 2011-08-30 11:37:12 UTC
I'm going to integrate the suggested diff tomorrow.
Comment 4 Tomas Pavek 2011-09-01 09:05:07 UTC
Comment 5 Quality Engineering 2011-09-01 14:21:00 UTC
Integrated into 'main-golden'
User: Tomas Pavek <>
Log: #201246: new SPI NavigatorDisplayer