So now, the slides are read from the layer.xml file! All one needs to do is (1) install my plugin, (2) create a new module that has nothing more than the standard NetBeans plugin metadata, plus a folder structure like this in the layer.xml file:
<folder name="Slides">
<file name="Getting Started">
<attr name="prefix" stringvalue="1"/>
<attr name="iconLoc" stringvalue="org/bla/foo/icons/icon1.png"/>
<attr name="position" intvalue="100"/>
<attr name="slideLoc" stringvalue="org/bla/foo/slides/slide1.png"/>
</file>
<file name="Lookup">
<attr name="prefix" stringvalue="2"/>
<attr name="iconLoc" stringvalue="org/bla/foo/icons/icon2.png"/>
<attr name="position" intvalue="200"/>
<attr name="slideLoc" stringvalue="org/bla/foo/slides/slide2.png"/>
</file>
</folder>
Next, make sure to put icons and slides in the above places in the module. Even a completely non-technical person could prepare the above module, since there's not one character of code that needs to be typed. Then, (3), install the module providing the above layer.xml file into the same IDE as where my plugin (see step 1) is found.
My plugin will then read that folder (it looks within the "Slides" folder and then figures out what to do with the files and attributes you've registered) and presents a result like this:
However, even to a newbie NetBeans Platform developer, the approach I've taken is no news. What IS news is the content of the slide shown in the illustration above. (It is a slide by Jarda from the recent training he gave with Toni and Thomas in Linz.) So, from 7.0 onwards (and already in daily builds) you can use the above much simpler construction for accessing a resource in the System Filesystem.
The second newsworthy thing is the piece in bold below:
@Override
protected boolean createKeys(List keys) {
FileObject slides = FileUtil.getConfigFile("Slides");
FileObject[] kids = slides.getChildren();
for (FileObject kid : FileUtil.getOrder(Arrays.asList(kids), true)) {
keys.add(kid);
}
return true;
}
By using FileUtil.getOrder, I am allowing the NetBeans Platform to use the "position" attribute in the layer.xml file for ordering the FileObjects, which is what lets me (without any coding, other than that small statement) ensure that the nodes are created in the correct order.
Unfortunately, I can't release my plugin yet because it uses the above constructions (as well as annotations in the TopComponents) which are not supported in 6.5. So, I'm on some daily build right now, which means the plugin will be incompatible soon. As soon as 7.0 M2 comes out, I'll make this available.
Potentially it could be used by NetBeans Platform Trainers—Toni would provide a module with the slides for his presentations, so would Jarda, I would provide my own presentations, and whoever else would do the same. Then I'd install all these modules and the slides would be merged into a single slide deck and could then be presented from inside the IDE as if they were all one set. Which is of course exactly the case. Thanks, System Filesystem, you rock.
FileUtil.getOrder is there since 6.0. FileUtil.getConfigFile(path) is new, but this can be done without much more code in 6.5: Repository.getDefault().getDefaultFileSystem().findResource(path)