Geertjan's Blog

  • June 3, 2013

How to Create a Satellite View in a Navigator for a Custom DataObject

Geertjan Wielenga
Product Manager

Recently there was a question on the NetBeans Platform mailing list (if you're creating NetBeans Platform applications and are not on the mailing list, you're missing a lot of good discussions and code samples) about custom DataObjects, Navigators, and Visual Library satellite views.

So I started with the code in the NetBeans File Type Integration tutorial. I added a Navigator, in a separate module, just to prove the point that it can work that way. Rather than the Navigator somehow finding the MultiViewElement, and then getting the Scene from it, the DataObject has the Scene in its Lookup. That enables the MultiViewElement to get the Scene from the DataObject, while the Navigator gets it from the selection.

Also, a requirement is that when the Source is open, i.e., the Source toggle button has been clicked, the Navigator should be emptied, i.e., the satellite view should not show anything. To achieve that, I add/remove the Scene from the DataObject's Lookup in the MultiViewElement's componentShowing/componentHidden. That's possible because I put the DataObject's InstanceContent into its own Lookup (maybe unorthodox or plain wrong but it works), then retrieve the InstanceContent in the MultiViewElement and add/remove the Scene from it.

The code is here:


Join the discussion

Comments ( 3 )
  • Sean Phillips Tuesday, June 4, 2013

    Thanks for making this example available Geertjan.

  • Holger Stenger Wednesday, June 5, 2013

    I use another approach. I defined an interface called SatelliteViewProvider with a method to create a JComponent for a satellite view. The interface is trivial to implement for a TopComponent using the Visual Library and of course needs to be in the lookup of the TopComponent. While you don't get a satellite view unless you open the file, you can have two independent views of the same file, i.e. two TopComponent instances with separate scenes.

    By the way, it's nice to see some tips and tricks again after weeks of only showing applications! :)

  • guest Thursday, June 6, 2013

    Hi Geertjan,

    I'm trying to add a custom palette to my file type.

    I was able to add the palette and the items.

    Drag and drop is ok in the text editor of the file.

    Now I would like to have the drag and drop in the visual editor of my file type (I'd like to do something similar to swing palette of NetBeans).

    How can I do this?

    Any suggestion?

    Thanks for your blog. It is always really useful.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.