Geertjan is a DZone Zone Leader and has posted 453 posts at DZone. You can read more from them at their website. View Full User Profile

How to Create a Custom Project Type in a Mavenized NetBeans Platform Application

09.24.2010
| 9485 views |
  • submit to reddit

Let's take the NetBeans Project Type Module Tutorial and port it to a Maven-based NetBeans Platform application. In contrast to the Hello World Maven NetBeans RCP article, we'll now use the NetBeans IDE's tooling, since the aforementioned article has laid the foundation that we need for using the NetBeans IDE's Maven tooling intelligently.

Take the following steps:

  1. Create the project as follows:






  2. Right-click on the node with the orange icon ("NetBeans Platform based application"), which is the application node, and choose "Build with Dependencies".

  3. Right-click the application node and choose Run. Here's your application:


  4. Copy the three Java classes from the "NetBeans Project Type Module Tutorial" into "TextAnalyzerProjectType NetBeans Module", which is the functionality module. Specifically, put them into the main package within "Source Packages", which is "com.text.analyzer". Copy the two icons into "Other Sources", specifically into "src/main/resources/com.text.analyzer". Make sure that you change the location of the icons in the two Java classes where they are used, otherwise they will not be found when you run the application.

  5. In the POM file of the functionality module, define the "dependencies" section as follows:
         <dependencies>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-openide-util</artifactId>
                <version>${netbeans.version}</version>
            </dependency>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-netbeans-modules-projectuiapi</artifactId>
                <version>RELEASE691</version>
            </dependency>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-openide-util-lookup</artifactId>
                <version>RELEASE691</version>
            </dependency>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-netbeans-modules-projectapi</artifactId>
                <version>RELEASE691</version>
            </dependency>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-openide-filesystems</artifactId>
                <version>RELEASE691</version>
            </dependency>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-openide-loaders</artifactId>
                <version>RELEASE691</version>
            </dependency>
            <dependency>
                <groupId>org.netbeans.api</groupId>
                <artifactId>org-openide-nodes</artifactId>
                <version>RELEASE691</version>
            </dependency>
        </dependencies>
  6. In the POM file of the application node, add this dependency:
            <dependency> 
        <groupId>org.netbeans.modules</groupId>
                <artifactId>org-netbeans-modules-projectui</artifactId>
                <version>RELEASE691</version>
            </dependency>
    The above is needed because we're depending on the Project UI API (see step 5 above). In that particular API, the "OpenIDE-Module-Needs" key is used in the manifest to specify that "ActionsFactory", "OpenProjectsTrampoline", and "ProjectChooserFactory" are needed by this module. Therefore, a module that implements and provides those classes is required, which is the Project UI module, which implements Project UI API. To ensure that that module will be available at runtime, you specify the dependency above as described, in the POM file of the application node. For details, go here.

  7. Repeat steps 2 and 3 above. Then open the Favorites window and browse to a folder that has a subfolder named "texts". Right-click on the folder that has a subfolder named "texts" and then click "Open Project". Here's your application, with the project opened:

 

Congrats, you've now ported the sample to a Maven based NetBeans Platform application.

Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Aljoscha Rittner replied on Tue, 2011/05/03 - 6:59am

Hi Geertjan!

I need some database API classes and this classes depends on the Project UI API. I get this errors:

Project UI API - None of the modules providing the capability 
org.netbeans.modules.project.uiapi.ActionsFactory could be installed. 
Project UI API - None of the modules providing the capability 
org.netbeans.modules.project.uiapi.OpenProjectsTrampoline could be installed. 
Project UI API - None of the modules providing the capability 
org.netbeans.modules.project.uiapi.ProjectChooserFactory could be installed. 

 

The declared dependency org.netbeans.modules:org-netbeans-modules-projectui in my application pom works with a charme.

Thank you for your help :)

br, josh.

Not Zippy replied on Sat, 2012/03/17 - 9:29am

How did you get the artifactId's available for netbeans ? what repository did you use ?
Also  what maven plugin are you using ? Does not seem to be the one distributed with netbeans

Matt Coleman replied on Mon, 2013/04/01 - 3:56am

east to follow steps..i appreciate it

buffalo freelance web designer 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.