Slide Deck Integrator Plugin for NetBeans IDE

I learned a bunch of interesting things today. It all started when I went back to the idea of documenting how I made the plugin that I'm using in the Top 10 NetBeans APIs series, for displaying my slides within NetBeans IDE. The problem is that I had lost my sources (also the binary, I think). But I needed to rewrite it anyway because I had hard coded the slides into the module.

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.

Comments:

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)

Posted by Jesse Glick on January 26, 2009 at 04:08 AM PST #

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
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today