Netbeans Platform Node Icon Badges
Thursday May 03 2018

The Netbeans IDE has some very cool way of letting users know when a certain file contains errors. For example, if you are editing a Java file and the file contains syntax errors, Netbeans will change the file icons with a new icon indicating errors:

Netbeans Error Icons

You can see that the error icons propagate all the way up to the top-most parent, the project itself.

Netbeans Platform Icon Badges

As a user of the Netbeans IDE and before even knowing what the Netbeans Platform was, I always assumed that the normal state of the icon and the error state of the icon were two completely different icons handled by Netbeans. A few days ago I learned that this is not the case.

Netbeans uses the concept of icon badges to display these kind of error icons. Icon badges are basically multiple images merged together at runtime into a single Image object.

In this article I want to quickly go over how you can apply this concept in your Netbeans Platform application when using the Nodes API.


Creating Toolbars for MultiView Elements in Netbeans Platform
Monday April 23 2018

On a previous post I talked about creating a new file type that Netbeans Platform can recognize and display the file's data in different ways by creating different visual editors that implement the MultiViewElement interface.

However, that tutorial did not cover how to add a custom toolbar to each multi view. Like the one Netbeans already provides when editing source code:

Netbeans MultiView Toolbar

This is a very handy toolbar that can be used to add buttons that perform different kinds of actions with the current active file.

A Deeper Look Into the MultiViewElement Object

If you recall from the previous post, a JPanel that implements MultiViewElement was created after finishing the wizard. This MultiViewElement object has some very important characteristics that are key to this tutorial:


Django Formsets with Generic FormViews
Thursday April 19 2018

Django Formsets is an extremely handy feature for handling multiple clones of forms in a single view. In this post I will go over how to implement them using one of Django's built-in generic class based views, the FormView.

The Scenario

To add some context to this tutorial, let's say we want to implement one of those kind of nested searches you see on some sites. Where you can select a field from a dropdown, and type in a search value for each field. Fields can be added and removed dynamically using JavaScript. Something like this:

Nested Search Example

For this tutorial, we will use the following model as an example:

class Book(models.Model):
    title = models.CharField()
    author = models.ForeignKey(Author)
    isbn = models.CharField()
    editorial = models.ForeignKey(Editorial)

Creating the Form

We will begin by creating the form that will be cloned. That is, the form that will represent one search query out of the many that will/could be nested together.

For our case, the form will only contain 3 fields:

  1. The query field: Indicates which field of the model we will query.
  2. The lookup type: Indicates which lookup is going to be used to make the query.
  3. The query value: Indicates what we want to actually search for (i.e Harry Potter for the book title.)


Custom File Types in Netbeans Platform
Wednesday March 28 2018

If your desktop Java application needs to deal with very particular or special kinds of files, we can make use of Netbeans Platform's custom File Type feature to define a file that our application can recognize, and display visual and editing components to view and edit the file's data.

Moreover, we can also make use of Netbeans Platform's Favorites pane, which displays a tree view of a file system, where we can open the special files we need to work with.

Creating a New Module

For this article, we are going to create a new file type for CSV (Comma Separated Value) files. When we open these files, our application will display a visual representation in the form of an editable JTable.

All this functionaltiy will live in its own Netbeans Platform Module. Meaning that it can be plugged in into different applications in a modular fashion.

We are going to create the module and build it using Maven, since we are also going to be adding some functionalities that depend on external libraries that we can easily include in our project with Maven. But you can also just create the module without Maven as well. To create the module go to New Project > Maven > Netbeans Module