How to Create a Custom Project Type in a Mavenized NetBeans Platform Application
Join the DZone community and get the full member experience.
Join For FreeLet'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:
- Create the project as follows:
- Right-click on the node with the orange icon ("NetBeans Platform based application"), which is the application node, and choose "Build with Dependencies".
- Right-click the application node and choose Run. Here's your application:
- 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.
- 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>
- 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. - 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.
application
NetBeans
Opinions expressed by DZone contributors are their own.
Comments