Registering the Plug-in Module


When you use the New Action wizard to add a menu item to the IDE, the wizard registers the menu item in the plug-in module's layer.xml file (bold font added for readability):

    <?xml version="1.0" encoding="UTF-8"?>  <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1. 1//EN" "http:/  /www.netbeans.org/dtds/filesystem-1_1.dtd">  <filesystem>      <folder name="Actions">          <folder name="Edit">              <file name="modules-mynewmodule-myNewAction.instance">                  <attr name="instanceClass"                  stringvalue="mynewmodule.myNewAction"/>               </file>           </folder>        </folder>        <folder name="Menu">             <folder name="Edit">             <file name="modules-mynewmodule-myNewAction.shadow"/>             </folder>          </folder>      </filesystem>


Similarly, when you use the New File Type wizard to create a loader for a new file type, the wizard creates layer.xml entries that register a set of default menu items that will appear in the file's pop-up menu.

So, what is the layer.xml file? The layer.xml file is the plug-in module's configuration file. Items that you want displayed in the IDE need to be registered in layer.xml. If you use a wizard, the wizard registers the items for you. However, you can tweak the registered items later in the layer.xml file. For example, you may want to rearrange a menu item so that it will be displayed lower down in the list of items belonging to a menu.

A special tree view containing a node for each element is provided to simplify modifications to the layer.xml file. In Figure 17-9, you can see the tree view of the layer.xml file shown above.

Figure 17-9. Browsing the current module project's layer.xml file


You can right-click the node for the new menu itemstandard items such as Cut, Copy, and Paste are available. In addition, you can localize the menu item or pick an icon that will be displayed in the menu item.

The next tree hierarchy, named "<this layer in context>," shows you all the items registered by all the modules that are loaded in the IDE. The items in bold are those that your plug-in module will contribute to the IDE, assuming you install the plug-in module, as shown in Figure 17-10.

Figure 17-10. Browsing all the layer.xml files registered in the current platform




NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net