Setting up a Plug-in Module


NetBeans IDE provides three project templates that you use when you begin creating plug-in modules. They are as follows:

  • Module. Use this to provide the functionality and actual business logic of your plug-in module. For example, the menu items, dialog boxes, window components, and so on, as well as all the code for interaction between these items, are defined in one or more module projects.

  • Library Wrapper Module. Use this to put a third-party library on a plug-in module's classpath. For example, a plug-in module that makes use of the third-party library JDOM would only be able to use JDOM's classes after the library provided by JDOM is wrapped in a library wrapper module. By itself, the library wrapper module project does nothing. The library wrapper module project must be deployed together with its related module projects via a module suite project.

  • Module Suite. Use this to group a set of interdependent modules and library wrappers. This allows them to be deployed together. For rich-client applications, module suites provide additional featuresa splash screen, a launcher, and a title for the titlebar. In addition, module suite projects include functionality that enables rich-client applications to be bundled into a ZIP file or provided as a JNLP (web-startable) application.

If you intend to build a simple plug-in module without dependencies, you will not need a module suite.


Creating a Module Project

To create a plug-in module, start by using a module project template. To use a module project template:

  1. Choose File | New Project (Ctrl-Shift-N). In the Categories tree, choose NetBeans Plug-in Modules. In the Projects tree, choose Module Project. Click Next.

    The New Module Project wizard appears.

  2. Type a project name and specify where it should be stored in your file system.

  3. Select whether the module project will be standalone or part of a module suite project. If you specify that the module project will be standalone (as shown in Figure 17-2), you must also specify the platform it will be built against.

    Figure 17-2. New Module Project wizard

    By default, a module project is built against the NetBeans IDE installation you are running. If you want to build against a different version or installation (such as a stripped-down copy of the NetBeans Platform with no IDE modules at all), you can configure the IDE to do so. Depending on the platform you choose, you may or may not have the modules that you need available to you. For example, a stripped-down version of a platform might not have the modules that relate to editor functionality. Therefore, make sure that the platform you choose includes the modules you need.

    If a suitable platform is not available, click Manage and then use the NetBeans Platform Manager to choose a different platform.

    If you specify that the module project will be standalone, you can change your mind later and add it to a module suite project. You can only add your module project to a module suite project if one already exists.

  4. Specify whether the module project will be the IDE's main project. The main benefit of this is that there is only one main project in the IDE, and certain keyboard shortcuts are specifically geared toward the main project. For example, F6 is Run Main Project.

  5. Click Next. Here you specify the code name base. The code name base uniquely identifies a plug-in module. By convention, it is typically the name of the base package, such as org.netbeans.modules.mymodule.

    In Module Display Name, you can specify a more user-friendly name that is displayed in the IDE.

  6. Finally, you specify the location of the localizing bundle and the XML layer file.

    The former will contain name-value keys for localization, while the latter will register each item that the plug-in module will add to the IDE. The XML layer file is discussed in Registering the Plug-in Module later in this chapter. Normally, you would not change the default locations.

  7. Click Finish.

The project opens in the IDE. Nodes representing the module project are shown in the Projects window. The Projects window hides the complexity of all the files in the module project and structures them in a helpful way, as shown in Figure 17-3.

Figure 17-3. A module project in the Projects window


When you switch to the Files window (Ctrl-2), you can see all the files that make up the module project.

Creating a Module Suite Project

When developing a plug-in module, you often need to make use of a third-party library. Since the third-party library will be deployed together with the plug-in module, you will need to group them together via a module suite project. Therefore, you use the module suite project template before using the library wrapper module project template. To use a module suite project template:

  1. Choose File | New Project (Ctrl-Shift-N). In the Categories tree, choose NetBeans Plug-in Modules. In the Projects tree, choose Module Suite Project. Click Next.

  2. Type a project name and specify where it should be stored in your file system, as shown in Figure 17-4.

    Figure 17-4. New Module Suite Project wizard

  3. Specify the platform against which your module suite project will be built.

    By default, a module suite project is built against the NetBeans IDE installation in which you are creating it. Depending on the platform you choose, you may or may not have the modules that you need available to you. For example, a stripped-down version of a platform might not have the modules that relate to editor functionality. Therefore, make sure that the platform you choose includes the modules you need. If a suitable platform is not available, click Manage and use the NetBeans Platform Manager to choose a different platform.

  4. Specify whether the module suite project will be the IDE's main project. Click Finish.

    The project opens in the IDE. When you expand the project node, a Modules node appears. Right-click this node if you need to add module projects that are not currently assigned to any other module suite.

Creating a Library Wrapper Module Project

NetBeans IDE 5.0 lets you wrap one or more third-party libraries with the module project. To use the library wrapper module project template:

  1. Choose File | New Project (Ctrl-Shift-N). In the Categories tree, choose NetBeans Plug-in Modules. In the Projects tree, choose Library Wrapper Module Project. Click Next.

  2. Browse to the third-party library that you need to make available to your module project.

  3. Optionally, browse to the third-party library's license. While doing this is optional in the IDE, adding a third-party library's license will probably not be optional if you want to make the plug-in module publicly available. Click Next.

  4. Specify a project name and a location on your file system where you want to store it.

  5. Next, specify the module suite to which the library wrapper module will belong, as shown in Figure 17-5. The library wrapper module project will be deployed along with the module suite. Click Next.

    Figure 17-5. New Library Wrapper Module Project wizard

  6. Specify the code name base. The code name base uniquely identifies a plugin module. By convention, it is typically the name of the base package, such as org.netbeans.modules.mymodule.

    In Module Display Name, you can specify a more user-friendly name that is displayed in the IDE.

    Finally, you specify the location of the localizing bundle. This will contain name-value keys for localization.



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