Notes for NetBeans Platform 6.5 (Part 1)
By Geertjan-Oracle on Jul 15, 2008
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:
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.