Data Loader Extension
Netbeans has a pluggable architecture called DataLoader that allows you to implement your own loading mechanism of data files. Datasets instantiated through the DataLoader architecture will be cached automatically by NetBeans.
Registering a Data Loader
A registered Data Loader associates a file type with your own class implementing org.openide.loaders.MultiDataObject. Part of the contract of a MultiDataObject is that its lookup provides an instance of a class implementing IData. For instance:
MultiDataObject obj = ...
obj.getLookup(IData.class) will return an IData instance.
There are three things that you have to do to plug in your own DataLoader.
1. Register your DataLoader in the layer.xml
LAYER.XML
<folder name="Loaders">
<folder name="seismic">
<folder name="x-demo2d">
<folder name="Factories">
<file name="Demo2DSeismicDataLoader.instance">
<attr name="dataObjectClass" stringvalue="com.interactive.intviewer.demoseismicdata.twod.DemoTwoDSeismicDataObject"/>
<attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/>
</file>
</folder>
</folder>
</folder>
</folder>
In this example, the file name "Demo2DSeismicDataLoader" is a unique name. The "dataObjectClass" attribute needs to be the fully qualified name of your MultiDataObject class. The "instanceCreate" attribute must be org.openide.loaders.DataLoaderPool.factory.
The "x-demo2d" folder in this example indicates the MIME type that this DataLoader should handle.
2. Implement a data object class, which extends org.openide.loaders.MultiDataObject. In addition to the constructor, there is only one method that must be implemented, which is the getLookup method.
3. Implement a data class, which implements com.interactive.intviewerapi.data.IData
Registering a MIME type
You will also need to implement your own MIME type. This is a very simple process, as all it takes is another layer.xml entry.
LAYER.XML
<folder name="MimeTypes">
<folder name="seismic">
<folder name="x-demo2d">
<attr name="name" stringvalue="Demo2D"/>
<attr name="ext" stringvalue="demo2d DEMO2D"/>
</folder>
</folder>
</folder>
The "name" attribute is just the name for your MIME type. It will be displayed in file choosers. The "ext" attribute is a list of all of the valid extensions for your MIME type. More information on how to handle mime types is available.
Examples
Follow this link for a sample implementation of seismic data loader that reads a custom seismic file format.