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

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:

https://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/ABCFileTypeNavigator

Comments:

Thanks for making this example available Geertjan.

Posted by Sean Phillips on June 04, 2013 at 11:51 AM PDT #

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! :)

Posted by Holger Stenger on June 04, 2013 at 11:10 PM PDT #

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.

Michele

Posted by guest on June 06, 2013 at 01:39 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today