X

Geertjan's Blog

  • December 1, 2008

Goodbye DataLoader, Goodbye DataNode

Geertjan Wielenga
Product Manager
In most cases, you don't need a separate class to define a DataLoader and another separate class to define a DataNode. So in 6.5, the DataLoader is registered (by the New File Type wizard) in the layer, without being created as a Java class, while the DataNode isn't created by the New File Type wizard either. I applied these principles to the old Book Multiview Sample, which is all I needed to do to updgrade it to 6.5—I deleted the BookDataNode class and the BookDataLoader class. Then I added the following to the layer, within Loaders/text/x-book:
<folder name="Factories">
<file name="BookDataLoader.instance">
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/bookmultiview/Datasource.gif"/>
<attr name="dataObjectClass" stringvalue="org.netbeans.modules.bookmultiview.BookDataObject"/>
<attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/>
<attr name="mimeType" stringvalue="text/x-book"/>
</file>
</folder>

Next, I rewrote BookDataObject.createNodeDelegate to the following, which is all that was needed in the first place anyway:

@Override
protected Node createNodeDelegate() {
return new DataNode(this, Children.LEAF);
}

And then I was done. Two less Java classes means two less classes to debug, test, maintain, etc.

Here's how the sample looks now, which will be used as the basis of a highly simplied tutorial on this topic, because several people I've met recently on NetBeans Platform Certified Training courses are very interested in synchronization between the two views in a multiview editor:

So, my plan is to strip this sample down to its absolute basics, so that only one field is left on the visual side, with one tag on the XML side, then add a Visual Library view, and show how the three can be synchronized. I believe this material would be very useful to several NetBeans Platform users out there.

Join the discussion

Comments ( 6 )
  • Maurice Rogers Jr. Monday, December 1, 2008

    Good Day Geertjan,

    I was looking at your screen shot and wondered what look and feel you applied to NetBeans?


  • Geertjan Monday, December 1, 2008

    None, Maurice. That is Ubuntu. I am on 8.10, which is Intrepid Ibex.


  • Kovica Monday, December 1, 2008

    I'm a beginner when it come to NetBeans Platform, so don't be harsh on me. :)

    Where do you find things like SystemFileSystem.icon, dataObjectClass, ... How do you know BookDataLoader.instance goes into Factories? How do you know what attributes you must specify for BookDataLoader.instance?


  • Geertjan Tuesday, December 2, 2008

    Because you use the New File Type wizard. That does it for you.


  • Kovica Tuesday, December 2, 2008

    Yes, if you use the wizard, but I want to know in general. Let's say there is no wizard.


  • Craig Marshall Wednesday, March 18, 2009

    No where seems to document how to override the data loader now, for if you want bespoke functionality in the data object loading.


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