This is an automated email from the ASF dual-hosted git repository.
vieiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-website.git
The following commit(s) were added to refs/heads/master by this push:
new dbb916c Project type tutorial review (#574)
dbb916c is described below
commit dbb916cfcedc2d25bf832b1e5a073bc87a09962e
Author: Antonio Vieiro <[email protected]>
AuthorDate: Wed Jan 5 06:40:48 2022 +0100
Project type tutorial review (#574)
Reviewing the project type tutorial.
---
.../src/content/tutorials/nbm-projecttype.asciidoc | 54 +++++++++-------------
1 file changed, 22 insertions(+), 32 deletions(-)
diff --git a/netbeans.apache.org/src/content/tutorials/nbm-projecttype.asciidoc
b/netbeans.apache.org/src/content/tutorials/nbm-projecttype.asciidoc
index baf0d63..0238669 100644
--- a/netbeans.apache.org/src/content/tutorials/nbm-projecttype.asciidoc
+++ b/netbeans.apache.org/src/content/tutorials/nbm-projecttype.asciidoc
@@ -29,29 +29,20 @@
:experimental:
:description: NetBeans Project Type Module Tutorial - Apache NetBeans
:keywords: Apache NetBeans Platform, Platform Tutorials, NetBeans Project Type
Module Tutorial
+:reviewed: 2022-01-04
This tutorial demonstrates how to create a new project type in a NetBeans
Platform application.
-*Before going further, make sure this is the tutorial you actually need!*
+NOTE: Before going further, make sure this is the tutorial you actually need!
* Rather than creating a new project type, you might want to extend an
_existing_ project type instead, as described in the
link:https://netbeans.apache.org/tutorials/nbm-projectextension.html[NetBeans
Project Type Extension Module Tutorial].
-* For Maven-based NetBeans Platform applications, see
link:http://netbeans.dzone.com/how-create-maven-nb-project-type[How to Create a
Custom Project Type in a Mavenized NetBeans Platform Application].
+* For Maven-based NetBeans Platform applications, see
link:http://web.archive.org/web/20130603022225/http://netbeans.dzone.com/how-create-maven-nb-project-type[How
to Create a Custom Project Type in a Mavenized NetBeans Platform Application].
* If the projects for which you're creating a project type (whether on Ant or
Maven based NetBeans Platform applications) need to use Ant as their build
tool, you should use the
link:https://netbeans.apache.org/tutorials/nbm-projecttypeant.html[NetBeans
Ant-Based Project Type Module Tutorial] instead.
-NOTE: This document uses NetBeans Platform 7.2 and NetBeans IDE 7.2. If you
are using an earlier version, see link:71/nbm-projecttype.html[the previous
version of this document].
+You will also make use of these icons, which you can right-click here and
download: image:images/icon.png[] and image:images/sub-icon.png[]
-
-
-
-
-
-You will also make use of these icons, which you can right-click here and
download:
-image::images/icon.png[]
-image::images/sub-icon.png[]
-
-For troubleshooting purposes, you are welcome to download the
link:http://web.archive.org/web/20130305120247/http://java.net:80/projects/nb-api-samples/sources/api-samples/show/versions/7.2/tutorials/CustomerProjectType[completed
tutorial source code].
-
+For troubleshooting purposes, you are welcome to download the
link:http://web.archive.org/web/20130305120247/http://java.net:80/projects/nb-api-samples/sources/api-samples/show/versions/7.2/tutorials/CustomerProjectType[complete
tutorial source code].
== Introduction to Project Types
@@ -59,7 +50,6 @@ A _project type_ is a NetBeans Platform term for a grouping
of folders and files
Our project type will be defined by the existence of a file named
"customer.txt". The tutorial assumes you have available, on disk, multiple
folders containing such a file, for example as illustrated below:
-
image::images/result-1.png[]
As in the case of the folders named "customer1", "customer2", and "customer3"
above, if a folder contains a file named "customer", with a "txt" extension,
the NetBeans Platform will recognize the folder as a project. The user will be
able to open the project into a NetBeans Platform application. The user will
also be able to create new projects, via the New Projects window
(Ctrl-Shift-N), which is where we will register some sample projects.
@@ -150,7 +140,7 @@ We start by implementing the ``
link:http://bits.netbeans.org/dev/javadoc/org-n
1. Change the default code to the following:
-[source,java]
+[source,java,subs="macros"]
----
import java.io.IOException;
@@ -204,7 +194,7 @@ Next, we implement the ``
link:http://bits.netbeans.org/dev/javadoc/org-netbean
1. We'll start with a simple skeleton implementation:
-[source,java]
+[source,java,subs="macros"]
----
import org.netbeans.api.project.Project;
@@ -292,7 +282,7 @@ public class CustomerProject implements Project {
* <<projectcustomizer,Creating and Registering the Project Customizer>>
* <<projectsubtype,Creating and Registering the Project Subprojects>>
-
+[[projectinformation]]
=== Creating and Registering the Project Information
In this section, you register minimum NetBeans project support, that is, you
create and register a class that provides an icon and a display name for the
project.
@@ -305,7 +295,7 @@ In this section, you register minimum NetBeans project
support, that is, you cre
[start=2]
1. As an inner class of the ``CustomerProject`` class, define the project
information as follows:
-[source,java]
+[source,java,subs="macros"]
----
private final class Info implements
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectapi/org/netbeans/api/project/ProjectInformation.html[ProjectInformation]
{
@@ -382,6 +372,7 @@ image::images/result-2.png[]
Now that you can open folders as projects into your application, let's work on
the project's logical view. The logical view is displayed in the Projects
window. The Projects window typically only shows the most important files or
folders that the user should work with, together with the related display
names, icons, and popup actions.
+[[projectlogicalview]]
=== Creating and Registering the Project Logical View
In this section, you define the logical view of your project, as shown in the
Projects window of your application.
@@ -391,7 +382,7 @@ In this section, you define the logical view of your
project, as shown in the Pr
[start=1]
1. As an inner class of the ``CustomerProject`` class, define the project
logical view as follows:
-[source,java]
+[source,java,subs="macros"]
----
class CustomerProjectLogicalView implements
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/org/netbeans/spi/project/ui/LogicalViewProvider.html[LogicalViewProvider]
{
@@ -507,7 +498,7 @@ image::images/result-4.png[]
The project node now shows the display name, icon, and popup actions that you
defined.
-
+[[projectchildren]]
=== Creating and Registering the Project Node Children
In this section, you learn how to define which folders and files should be
displayed in the logical view, that is, the Projects window. Currently, you are
showing all folders and files because the children of the project node are
defined by ``FilterNode.Children(node)`` , which means "display all the
children of the node".
@@ -517,13 +508,12 @@ In this section, you learn how to define which folders
and files should be displ
[start=1]
1. Change the constructor of the ProjectNode as follows:
-[source,java]
+[source,java, subs="macros"]
----
public ProjectNode(Node node, CustomerProject project)
throws DataObjectNotFoundException {
- super(node,
- *
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/org/netbeans/spi/project/ui/support/NodeFactorySupport.html#createCompositeChildren(org.netbeans.api.project.Project,
java.lang.String)[NodeFactorySupport.createCompositeChildren](
+ super(node,
link:pass:[http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/org/netbeans/spi/project/ui/support/NodeFactorySupport.html#createCompositeChildren(org.netbeans.api.project.Project,
java.lang.String)][NodeFactorySupport.createCompositeChildren](
project,
"Projects/org-customer-project/Nodes"),*
// new FilterNode.Children(node),
@@ -559,7 +549,7 @@ public Lookup getLookup() {
[start=3]
1. Create a new Java class ``TextsNodeFactory`` in a new package
``org.customer.project.nodes`` as follows, while taking special note of the
``@NodeFactory.Registration`` annotation:
-[source,java]
+[source,java, subs="macros"]
----
package org.customer.project.nodes;
@@ -648,7 +638,7 @@ image::images/text-folder-1.png[]
An important point to realize in this section is that the ``
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/org/netbeans/spi/project/ui/support/NodeFactory.Registration.html[@NodeFactory.Registration]``
annotation can be used to register new child nodes of the customer project
node, either within the current module or via external modules. In this way,
the logical view of your project is extensible, that is, logical views can be
pluggable, if an extension p [...]
-
+[[projectcustomizer]]
=== Creating and Registering the Project Customizer
In this section, you learn how to create a pluggable customizer. When the user
right-clicks the project node, they will see a Properties menu item. When they
click it, the customizer will open. The categories in the customizer can be
contributed by external modules, that is, the customizer will be created to be
extensible.
@@ -725,7 +715,7 @@ image::images/customizer-3.png[]
[start=5]
1. Now we create the infrastructure for our pluggable Project Properties
window:
-[source,java]
+[source,java,subs="macros"]
----
package org.customer.project;
@@ -805,7 +795,7 @@ public Lookup getLookup() {
[start=7]
1. In a new package ``org.customer.project.panels`` , create a new Java class
named ``GeneralCustomerProperties`` , with this content:
-[source,java]
+[source,java,subs="macros"]
----
package org.customer.project.panels;
@@ -858,7 +848,7 @@ When you click the OK button, you will see a message in the
status bar. The mess
You now have the start of a project customizer.
-
+[[projectcustomizer]]
=== Creating and Registering the Project Subprojects
In this section, you learn how to create new project types that are nested
within other project types:
@@ -877,7 +867,7 @@ Above, you can see that the "customer3" project has several
folders. One of thos
[start=2]
1. Create a ``
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectapi/org/netbeans/spi/project/SubprojectProvider.html[SubprojectProvider]``
that looks inside the customer project's "reports" folder for projects of
your type:
-[source,java]
+[source,java,subs="macros"]
----
public class ReportsSubprojectProvider implements
link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectapi/org/netbeans/spi/project/SubprojectProvider.html[SubprojectProvider]
{
@@ -951,7 +941,7 @@ public Lookup getLookup() {
[start=4]
1. Similar to the ``TextsNodeFactory`` that you created earlier in this
tutorial, create a new Java class ``ReportsSubProjectNodeFactory`` as
follows, while again taking special note of the ``@NodeFactory.Registration``
annotation, which registers the ``NodeFactory`` into the logical view of the
customer project:
-[source,java]
+[source,java,subs="macros"]
----
@NodeFactory.Registration(projectType = "org-customer-project", position = 20)
@@ -1045,7 +1035,7 @@ Using the instructions in this subsection, you can create
a richly structured an
In this section, you have defined the basic infrastructure of a new type of
project in your NetBeans Platform application.
-
+[[projectsubtype]]
== Registering the Project Type as Project Sample
In this section, we create some project samples that make use of our project
type. We also register these project samples in the New Project window of our
application.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists