To teach users about the settings of more complex nodes or to improve the convenience, you can annotate nodes with node examples. These will appear in a dedicated tab “Examples” on selecting a node within the pipeline editor.
The standardized example API is based around the “Node templates” functionality. To create an example, follow these steps:
- Select a single node in the expected configuration and create a node template via
Right click > Create node template
- Provide an appropriate name and description.
- Deselect all nodes and navigate to the Node templates tab on the right-hand panel
- Select the newly created template and click
Manage > Export selection to file
- Save the
*.json
file into a directory within your extension’s resources (e.g. into/path/to/my/resources/examples
)
The DefaultJavaExtension
class that is the basis for Java extensions comes with a method to automatically register all examples within a specified resources folder.
Insert the following code into your extension service:
@Plugin(type = JIPipeJavaExtension.class) public class MyExtension extends JIPipeDefaultJavaExtension { // ... // If you have custom icons, thumbnails etc., create a JIPipeResourceManager instance that points towards the root directory of your resources // Please read the documentation of JIPipeResourceManager for more information on how to structure the resources directory public static final JIPipeResourceManager RESOURCES = new JIPipeResourceManager(MyExtension.class, "resource/directory/of/my/extension"); // ... @Override public void register(JIPipe jiPipe, Context context, JIPipeProgressInfo progressInfo) { // ... registerNodeExamplesFromResources(RESOURCES, "examples"); // Will automatically search for *.json files in the subdirectory "examples" // ... } // ...