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:
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
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.
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
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:
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 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.
For this tutorial, we will use the following model as an example:
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:
- The query field: Indicates which field of the model we will query.
- The lookup type: Indicates which lookup is going to be used to make the query.
- The query value: Indicates what we want to actually search for (i.e Harry Potter for the book title.)
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
Pytest has become my favorite Python testing framework. And in this article I want to go over on how I learned to write nice tests for Django and Django REST Framework.
We will be using the following tools: