12.01.2015 Views

Plug-in - NetBeans

Plug-in - NetBeans

Plug-in - NetBeans

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Plug</strong>-<strong>in</strong> Module Quick Start<br />

item and a toolbar button to the IDE.<br />

When you select the menu item or toolbar<br />

button, a DialogDisplayer, provided by the<br />

<strong>NetBeans</strong> APIs, with the text “I’m plugged<br />

<strong>in</strong>!” will be shown.<br />

Sett<strong>in</strong>g Up a <strong>Plug</strong>-<strong>in</strong><br />

Module Project<br />

<strong>NetBeans</strong> provides a wizard that sets<br />

up all the basic files needed for a plug-<strong>in</strong><br />

module.<br />

Creat<strong>in</strong>g a <strong>NetBeans</strong><br />

<strong>Plug</strong>-<strong>in</strong> Module Project<br />

In <strong>NetBeans</strong>, choose File|New Project,<br />

and under Categories select <strong>NetBeans</strong><br />

<strong>Plug</strong>-<strong>in</strong> Modules. <strong>NetBeans</strong> plug-<strong>in</strong> module<br />

support provides three project types:<br />

• Module Project. Creates a template<br />

for a standalone plug-<strong>in</strong> module.<br />

• Library Wrapper Module Project.<br />

Creates a plug-<strong>in</strong> module for an external<br />

JAR file required by one or more plug-<strong>in</strong><br />

modules.<br />

• Module Suite Project. Creates a<br />

template for a set of <strong>in</strong>terdependent plug<strong>in</strong><br />

modules and library wrapper modules,<br />

which you want to deploy together.<br />

Select Module Project and click Next.<br />

In the Name and Location panel, type<br />

“MyFirstModule” <strong>in</strong> Project Name. Change<br />

the Project Location to any directory on<br />

your computer, such as c:\mymodules.<br />

Leave the Standalone Module radio button<br />

and the Set as Ma<strong>in</strong> Project checkbox<br />

selected. Click Next.<br />

In the Basic Module Configuration panel,<br />

replace “yourorghere” <strong>in</strong> Code Name Base<br />

with “myorg”, so that the whole code name<br />

base is “org.myorg.myfirstmodule”. Notice<br />

that the localiz<strong>in</strong>g bundle and the XML layer will be stored <strong>in</strong> the<br />

package org.myorg.myfirstmodule. These files do the follow<strong>in</strong>g:<br />

• Localiz<strong>in</strong>g Bundle. Specifies language-specific str<strong>in</strong>gs for<br />

<strong>in</strong>ternationalization.<br />

• XML Layer. Registers items such as menus and toolbar<br />

buttons <strong>in</strong> the <strong>NetBeans</strong> System Filesystem (see the sidebar<br />

“<strong>Plug</strong>-<strong>in</strong> Module Terms”).<br />

Click F<strong>in</strong>ish. The IDE creates the MyFirstModule project,<br />

conta<strong>in</strong><strong>in</strong>g all of your sources and project metadata,<br />

such as the project’s Ant build script.<br />

The project opens <strong>in</strong> the IDE. You<br />

can view its logical structure <strong>in</strong> the<br />

Projects w<strong>in</strong>dow (Ctrl-1) and its file<br />

structure <strong>in</strong> the Files w<strong>in</strong>dow (Ctrl-2).<br />

See Figure 1.<br />

In addition to the localiz<strong>in</strong>g bundle<br />

and the XML layer, the project also<br />

<strong>in</strong>cludes the follow<strong>in</strong>g important files:<br />

• Module Manifest. Declares that the<br />

project is a plug-<strong>in</strong> module. In addition, it<br />

sets some module-specific sett<strong>in</strong>gs, such<br />

as the location of the XML layer, the location<br />

of the localiz<strong>in</strong>g bundle, and the module<br />

version.<br />

• Build Script. Provides a place where you can create<br />

your own Ant targets and override those that are specified <strong>in</strong> nbproject/build-impl.xml.<br />

• Project Metadata. Conta<strong>in</strong>s <strong>in</strong>formation such as the<br />

project’s type, contents, platform, classpath, dependencies,<br />

and mapp<strong>in</strong>gs between project commands and targets<br />

<strong>in</strong> Ant scripts.<br />

A 1<br />

• <strong>NetBeans</strong> Platform<br />

Config. Conta<strong>in</strong>s properties<br />

used by the IDE or<br />

Platform.<br />

• Per-user <strong>NetBeans</strong><br />

P l a t f o r m C o n f i g<br />

Conta<strong>in</strong>s properties<br />

specific to your <strong>in</strong>stallation<br />

of the IDE.<br />

A<br />

Figure 1<br />

Logical<br />

structure of the<br />

new plug-<strong>in</strong><br />

module<br />

First Edition N 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!