Tuesday Jul 15, 2008

Notes for NetBeans Platform 6.5 (Part 1)

Following on from Notes for NetBeans Platform 6.5 Milestone 1, let's look at some more and some slightly subtle changes in the upcoming 6.5 release, when creating new modules (i.e., plugins). I'm using a build from earlier today, you won't find much of what I describe here in earlier builds.

So, first, as always, we start up the New Module wizard. Look, our first change. A checkbox allowing you to enable/disable creating of the layer.xml file, which solves the problem introduced in 6.1 where the problem of modules with empty layer.xml files was solved by not prefilling the XML Layer field, which caused the problem where many people accidentally didn't create it even when they needed it and were confused later:

OK. Now let's create a new window. We use the New Window Component wizard and see a new checkbox, which I've mentioned before but which I will demonstrate in this blog entry. It is called "Keep preferred size when slided-in":

Select it and then click Finish. In the generated TopComponent constructor you'll find this line:

putClientProperty("netbeans.winsys.tc.keep_preferred_size_when_slided_in", Boolean.TRUE);

However, if the selected "Window Position" was "editor", which cannot be slided-in (i.e., minimized), then the above checkbox cannot be selected:

However, look at the generated files:

Where's the Action class? Not there! So how will you open the window? Before, the IDE always generated an action class and registered it in the layer.xml file. This time however, i.e., from 6.5 M2 onwards, you'll see the action declared in the layer file, without being present in your code at all (although you could continue doing things as before, just the wizard won't generate the old code for you):

<filesystem>
    <folder name="Actions">
        <folder name="Window">
            <file name="org-netbeans-modules-demo-DemoAction.instance">
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.demo.Bundle"/>
                <attr name="component" methodvalue="org.netbeans.modules.demo.DemoTopComponent.findInstance"/>
                <attr name="displayName" bundlevalue="org.netbeans.modules.demo.Bundle#CTL_DemoAction"/>
                <attr name="instanceCreate" methodvalue="org.openide.windows.TopComponent.openAction"/>
            </file>
        </folder>
    </folder>
    <folder name="Menu">
        <folder name="Window">
            <file name="DemoAction.shadow">
                <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-demo-DemoAction.instance"/>
            </file>
        </folder>
    </folder>
    <folder name="Windows2">
        <folder name="Components">
            <file name="DemoTopComponent.settings" url="DemoTopComponentSettings.xml"/>
        </folder>
        <folder name="Modes">
            <folder name="navigator">
                <file name="DemoTopComponent.wstcref" url="DemoTopComponentWstcref.xml"/>
            </folder>
        </folder>
    </folder>
</filesystem>

Look at the above tags carefully and see how the definition of the actions class is handled within the layer.xml file itself, which kind of reminds me of how things are done in Spring RCP.

Finally, when you install the module, you'll see the "Demo" menu item as before and you'll also see that when the window is slided-in (i.e., minimized), its size is now determined by its preferred size property, which means you have control over it for the first time:

There are other related changes too, which I'll discuss soon.

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
« July 2008 »
SunMonTueWedThuFriSat
  
4
5
6
11
12
13
14
17
26
30
  
       
Today