I didn’t blogged for a while because I am working on a new Eclipse application. This application defines a new View. This view is created with allowMultiple = true.
This view is associated with a given file extension. Each time the user double click on such a file a new instance of the view is created using IWorkbenchPage.showView(primaryId, secondaryId).
I quickly got my multi instances view mechanism functional. The next step was to manage “correctly” the behavior of :
Window -> Show View -> MyMultiInstanceView ???
What happens when the user clicks other there … ???
Launching my app in debug mode told me than my view is created (by Eclipse and not explicitily by my code) in that case with a secondaryId == null. Of course this resulted in a famous NullPointerException ;0)
A first and simple solution is to check the secondaryId and provide an empty view (or a view with a simple message) when this Id is null …
I decided to use an other solution using the “master view” (the one displayed when the user clicks windows -> show view) to display informations about all the other opened views (the ones with a secondaryId != null associated to a file). This view just contains a ListViewer showing all the other opened views. A double click on a given element of that list gives brings the associated view to the top. When a view is closed by the user, the associated entry in the view is removed.
This solution help me to solve the problem of providing the user a way to open a “meaningless view” in its perspective.
Here I had to “search” for something to display in the master view. Since new instances can only be created programatically it could be nice in some cases for plug-ins developers to be able to tell the platform: “don’t create Show View menu entry for this view” …