Apr 242013
 

The NetBeans IDE’s debugging tools is one of maybe the top 5 features that I simply cannot live without! And as you can imagine, debugging is something I do quite regularly. So I was rather surprised when I only recently discovered an AWESOME feature that has been around for a long, long time. 🙂 This feature is Variable Formatters.

To explain what a Variable Formatter is, some context is required. So lets have a look at the Variables window while debugging a very simple little Java application.

Variables Window

Variables Window

That is a pretty useful view. I can see all the variables that I could possibly need at a glance. (Of course, that is easy with an application this simple.) Of interest to this particular discussion, however, is the Value column. Notice how the various types have different string representations that are displayed. Now lets create a simple class called SomeObject:

public class SomeObject {

    private String var1;
    private String var2;

    public SomeObject(String var1, String var2) {
        this.var1 = var1;
        this.var2 = var2;
    }

    public String getVar2() {
        return var2;
    }
}

and create an ArrayList filled with SomeObjects, to inspect in the debugger:

ArrayList in the Variables Window

ArrayList in the Variables Window

Each of the elements in the list can of course be expanded to see the details. But what if you were looking for a specific element in a very long list? The great news is, that Variable Formatters allows us to customise how these items are displayed! From the main menu, select Tools > Options. Choose the Java page, and then the Java Debugger tab, Variable Formatters category.

Variable Formatters options

Variable Formatters options

A number of formatters are already specified, but we can add a custom one:

Custom Formatter

Custom Formatter

And very impressively, it gets applied immediately when you click OK on the options dialog! Even while the debugger is running! Now the display looks like this:

Customised Display

Customised Display

Suddenly ANY type of variable can have a user friendly, and customised, presentation in the variables window!

Mar 282013
 

The success of a software development project can be measured in many ways. But certainly one of the most important metrics for the users of open source software, is the quality of the software itself. And so it is fitting that the second interview in the series of NetBeans team interviews introduces Marián Mirilovič, NetBeans Quality Engineering Manager.

Marián Mirilovič at Edinburgh Castle, Scotland

Marián Mirilovič at Edinburgh Castle, Scotland

Hermien Pellissier: How long have you been a part of the NetBeans team?

Marián Mirilovič: Actually I was hired into the original NetBeans team (before it was bought by Sun Microsystems) in July 1999, but just a few days before my start date I got call-up and I was forced to spend one year in a Slovak Army base camp. Fortunately I got another offer from the team just before the end of my duty, so my official start point is November 2000. Wow… looking at the date now, it is almost 13 years and most of them unforgettable (especially those at Sun Microsystems).

HP: What is your role in the team?

MM: My actual position is “NetBeans Quality Engineering Manager”. So beside leading the QE team, I am also the one responsible for the final quality of the product, setting expectations in quality area for new releases and getting buy-in to new Quality Criteria by the Development team (the toughest part of my job).

HP: What is a typical work day like for you?

MM: It depends on the phase of the release cycle. But more or less I start with reading emails as we are an international company, and most of my colleagues work in different time-zones, so I usually get replies during my nights. Emails usually give me an updated picture what the status is, if there is a blocker for my team to continue in the activity we are currently working on. When everything goes well, I check the dashboard and go through high-priority bugs reported since my last check. Continue with meetings and tasks connected with the phase of the release cycle we are working on that day. Just before leaving office I do check the dashboard, what was the income in a day and other stats.

HP: When is the Quality Engineering team at its busiest?

MM: The whole season ;). Actually, there are a couple days after releasing new version when we have “a free time”, but after a day or two we start to work on a first patch, so there are almost no down-times.

HP: Which aspect of your job do you enjoy the most, and why?

MM: There are three peaks for me ;). The first one is when we complete testing of a new version and I am proud to send “GO” for a release.

The second is when we are getting replies to our “Thanks for your contribution to the NetBeans X.Y” emails and people thank us for a great IDE and appreciate the work we’d done during the whole release cycle.

And the last one is when we send recognition awards to the most active NetCAT participants. Actually this is usually the last task on the checklist for particular release. 😉

HP: What are your other interests?

MM: First of all my children. I have a four and a half year old daughter and a seven year old son. Both are very active and require a lot of attention. 😉

The other important thing in my life is sport. I play ice-hockey, beach volleyball, and I like jogging in summer and skiing in winter.

HP: What is your favourite holiday destination?

MM: We are used to spending our summer holidays on one of the Greek Islands. The other usual place is the area under High Tatras in Slovakia (my birthplace) and the last one is Lake Lipno in the Czech Republic.

HP: What is your favourite show or movie?

MM: I like the Sci-Fi genre and movies about history. I have read plenty of Isaac Asimov and Arthur C. Clarke’s books. There are a lot of movies I like. The first two that come to my mind just because I saw them recently are “Invictus” and “Moneyball”.

HP: Are there any blogs (NetBeans related or otherwise) that you would recommend?

MM: I like Geertjan’s Blog (https://blogs.oracle.com/geertjan/) and I strongly recommend reading it. Also NetBeans’ PHP blog (https://blogs.oracle.com/netbeansphp) is pretty active and keeps our huge PHP community updated.

HP: Thank you for the interview!

Mar 112013
 

NetBeans is an IDE, a platform, and a community. And the full time NetBeans team at Oracle plays a very important role in all of that. However, the people that does all the great work are also very modest about their accomplishments. And so the community doesn’t know all the interesting people that are involved and what they do every day. This is the first in a series of interviews with the various team members, to introduce them to the community. Today I am priviledged to introduce Jiří Kovalský.

Jiří Kovalský on vacation in the Jizerske hory mountains

Jiří Kovalský on vacation in the Jizerske hory mountains

Hermien Pellissier: How long have you been a part of the NetBeans team?

Jiří Kovalský: I am proud to work for the NetBeans project already since July 2000 so it will be 13 years this summer! Being part of one team for such a long time has both good and bad aspects. On one side you watch the fantastic progress of the project while on the other hand it also brings sad moments like seeing your good friends leaving the road you walked together for years.

HP: What is your role in the team?

JK: I am actually sitting on two chairs. My job title reads “NetBeans Community Manager” so I should be managing NetBeans community but I prefer to call it cooperation or coordination at maximum rather than any kind of management. In open source world people contribute voluntarily, right? NetBeans has a huge community which by the way reached 1.3 million active users last year and it’s logical that there are many people who want to give something back for the free tool they use daily. So, I for example try to do my best to help those active users contribute where it makes sense and coordinate such efforts to maximize productivity.

You might have probably heard of NetCAT program which is now an essential part of the NetBeans stabilization phase. Imagine there are ~100 NetCAT participants who test NetBeans development builds. Such a crowd needs a bit of coordination to distribute the work load, you must provide clear instructions to avoid misunderstandings and of course empathy is handy too. And that’s my job.

Besides NetCAT, I for example “manage” team of Plugin Verifiers. These are volunteers who constantly test NetBeans plugins which aim to the NetBeans Update Center. I am also responsible for processing Oracle Contributor Agreements.

HP: And what’s the other chair?

JK: Secondly, I am member of the NetBeans Quality Engineering team responsible for Java/Ant Debugger and JUnit/TestNG support. This includes testing these features, reporting bugs, updating test specifications or maintenance of automated tests. Since the beginning I have been also involved in design of the Plugin Portal so I feel responsibility for that web too.

HP: What is a typical work day like for you?

JK: Firstly, I must explain that I work from home 4 days a week. Since I live in a small town called Bohumin, I travel to the office in Prague every other week for two days.

I wake up at 6:00 AM, make some tea and prepare a breakfast for kids. Then I wake them up and prepare my breakfast and a snack for the children. At 7:30 we drive to school. On my way home I sometimes do some shopping. After my return from the school I finally turn on my computer. Yes, its uptime is 24 hours at maximum. 🙂

I know some mentors would disagree with it but I start my working hours by reading e-mails. Being the NetBeans Community Manager I have to communicate a lot and morning is the perfect time to resolve things from those community members who live on the other side of the Earth. Requests from those in my time zone or near enough can wait till the afternoon, can’t they? 🙂 I dedicate ~1 hour to e-mails and then switch to the most important task planned for the day. This can be for example testing latest NetBeans IDE and JDK bundles, calculating activity of NetCAT participants, searching for new plugins to be featured on the web site, verification of bug fixes planned to an update release, writing a speech for an online chat with community members or stabilization of Debugger sanity automated test suite.

Around noon I eat lunch in advance cooked by my wife or prepare something myself. One of my bad habits is reading Facebook or some newspapers during lunch. 🙂 In the afternoon I again check my e-mails and try to fully clear my Inbox. Then I sometimes prepare for meetings if there are any. If not, I switch to another priority task on my Todo list. Typically it concerns some communication with NetBeans community which needs concentration and time. I am not fan of multitasking so I prefer finishing my task at all costs before going further. Downside of this approach is that I sometimes end my day with more duties than I had in the morning.

At 4:30 PM I often interrupt my work and drive for kids and wife. If there is something critical I continue working in the evening when our house goes silent. This happens when I for example write a NetCAT status report which takes around 6 hours in total. I try to shutdown my computer no later than 10:30 PM. Just out of curiosity, in 2012 I spent 18.9% with e-mails, 28.4% with NetCAT or 14.3% on testing.

HP: Which aspect of your job do you enjoy the most, and why?

JK: You know what’s exciting? That so many different people from variety of cultures with almost no chance to meet in person cooperate together to build a better product. I like that although I am just a tiny bit in this big puzzle I can make a difference. Just as anyone who feels strongly about NetBeans too. That’s what I like about my job.

HP: Which new NetBeans feature(s) are you most excited about?

JK: How many you want to hear? Just one? 🙂 Oh, it will be difficult. So, just briefly:

7.3: New web client development support and the integration with Chrome is simply amazing.
7.2: Background indexing using transactions which lead to vastly increased performance.
Overall: It may sound stupid but I like small Editing features like Hippie Completion (Ctrl+K), regular expressions in Find & Replace tool and Macros. These are some quite good time savers.

HP: What are your other interests?

JK: First of all family comes to my mind. I like to spend my time with my wife and kids. I like reading books for Ondrej (6 years old son), I like listening to Zuzana (8 years old daughter) playing violin, I like programming with Barbora (10 years old daughter) and of course I like for example skiing or going to a theatre with my wife.

Sport is significant for me in general. I am especially keen on playing volleyball (Fridays) and squash (bi weekly). I do weights once a week. I am also kind of interested in arts – I collect old paintings for instance. I don’t have any from Pablo Picasso or Claude Monet yet 😀 but these were really great painters.

HP: Which movie/book genre(s) is/are your favourite(s)?

JK: I know it is scary but I don’t read books. I am sure though I will enjoy it when I retire. 🙂 However, I like Sci-fi genre which fascinated me when I first saw the Aliens movie by James Cameron in 1988. The Matrix from 1999 was another hit and recently I liked Avatar a lot from 2009.

HP: What is your favourite holiday destination?

JK: I don’t have any concrete preference but since the Czech Republic is a landlocked country I like for some reason sea, waves and the fresh air. My wife prefers mountains so we made a compromise and go to mountains one year and fly to some coast next year. 🙂

HP: Are there any blogs (NetBeans related or otherwise) that you would recommend?

JK: I don’t watch blogs much but Geertjan’s blog keeps surprising me with its useful content and has the most hits in my browser’s history. Otherwise I am happy subscriber of PHD Comics by Jorge Cham. It’s not only entertaining but educative at the same time.

HP: Thank you very much for the interview!

Dec 192012
 

The open space on the menu bar of a NetBeans Platform application is often wasted. In the NetBeans IDE, the quick search bar is positioned in that handy location. And your application can have that too of course. However, the question was raised on the forums recently how one would go about adding your own component there. Here is the promised post explaining the steps in detail. The result will look like the screenshot below, with the new User label introduced in the space where the quick search would have been.

Screenshot showing the standalone module running in the IDE

Screenshot showing the standalone module running in the IDE

Step 1: The Module. We need a NetBeans Platform module to work with. So if you don’t have one yet, create one now. It can be either a standalone module or exist as a part of a suite. I created a standalone module. When you run a standalone module, it basically gets installed into an instance of the IDE. That is why the screenshot shows all the bits of the IDE.

Step 2: The Component. Create a new JPanel form (I called mine CustomComponent) and add a JLabel to it. Specify and icon for the label if you wish. The important point to take note of is that you need to specify a size for the panel (resize it in the GUI builder) and then specify that same size as the minimum and maximum size of the panel too. Otherwise the size of the panel will not be what you expected.

Custom component in the GUI builder

Custom component in the GUI builder

Step 3: The Action. Just as the NetBeans IDE 7.2 Plugin Quick Start tutorial describes, create a new Action. Just as the tutorial describes, choose Global Toolbar Button on the GUI Registration page (this will be changed later). Change the action to extend from AbstractAction and implement Presenter.Toolbar, all still as in the tutorial. And in the getToolbarPresenter() method return an instance of CustomComponent.

Then change the @ActionReference annotation’s path to just be “Menu” and position to be 10000.

So at the end of this step we now have the action class below.

import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.Presenter;

@ActionID(category = "Build",
id = "za.co.pellissier.componentinmenubar.CustomComponentActionListener")
@ActionRegistration(
displayName = "#CTL_CustomComponentActionListener")
@ActionReference(path = "Menu", position = 10000)
@Messages("CTL_CustomComponentActionListener=CustomComponent")
public final class CustomComponentActionListener
extends AbstractAction implements Presenter.Toolbar {

@Override
public void actionPerformed(ActionEvent e) {
}

@Override
public Component getToolbarPresenter() {
return new CustomComponent();
}
}

Step 4. Alignment. In order to force the component to be right-aligned, we can add a spacer just to the left of it. Here the NetBeans Quick Search Integration Tutorial has a handy example (in the very last section). Create an XML Layer file in your module. The file should be opened on creation. Now add a spacer like in the tutorial, resulting in the layer.xml file looking like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
    <file name="Spacer.instance">
        <attr name="instanceCreate" methodvalue="javax.swing.Box.createHorizontalGlue"/>
        <attr name="position" intvalue="9999"/>
    </file> 
</filesystem>

Note the position of 9999, which is just to the left of the 10000 of the component.

Step 5. Hiding Quick Search. In practice you could have the quick search and your own component next to one another. However, for the purpose of this tutorial I decided to hide the quick search feature. Modify the layer file once more, so that it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
    <folder name="Menu">
        <file name="org-netbeans-modules-quicksearch-QuickSearchAction.shadow_hidden"/>
    </folder>
    <file name="Spacer.instance">
        <attr name="instanceCreate" methodvalue="javax.swing.Box.createHorizontalGlue"/>
        <attr name="position" intvalue="9999"/>
    </file> 
</filesystem>

That is it. Now you have a custom component being displayed in the empty space on the menu bar.

Nov 212012
 

Today I was working again on the undocked TopComponent that inspired the post Hiding Tabs for Undocked TopComponents, this time adding a custom statusbar to it. And in the process I found a way of adding a banner to a NetBeans Platform application. There might be unexpected side effects with layout, but so far it looks good. 🙂 Here is what my sample application looks like, to explain what I mean by ‘banner’ (the green part in the screenshot).

Sample application with banner

Sample application with banner

Well, as far as I gather the idea is not brand new. I had a hint from a forum thread that helped to point me in the right direction. Toni mentions there that you can add components outside the control of the window system, but the blog post linked to there no longer exists…

I started by browsing through the GUI elements in debug mode. And I soon found out that by calling

((JRootPane) WindowManager.getDefault().getMainWindow().
        getComponents()[0]).getContentPane()

you can find the main panel that contains all the GUI elements. And this panel has a BorderLayout. So lets look at the different parts of the NetBeans IDE as contained in this window to illustrate.

NetBeans IDE showing layout areas

NetBeans IDE showing layout areas

I created a normal JPanel form (I called mine BannerPanel) and added the components that you see on the screenshot to it. Then I created an installer class for the module, and into the restored method I put the following code:

WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
    @Override
    public void run() {
        Frame mainWindow = WindowManager.getDefault().getMainWindow();
        Container contentPane = 
                ((JRootPane) mainWindow.getComponents()[0]).getContentPane();
        BannerPanel banner = new BannerPanel();
        contentPane.add(BorderLayout.NORTH, banner);
        ((BorderLayout) contentPane.getLayout()).
                invalidateLayout(contentPane);
        mainWindow.validate();
    }
});

Now you will notice that I am putting the panel into BorderLayout.NORTH, which according to the screenshot earlier is where the toolbar already is. What is in fact in that space is a container panel that keeps the space for the toolbar. So replacing it means that the panel actually starts at the same height as the toolbar. And this means that you need to leave some open space at the top of the panel that you design. See the screenshot below showing my very green form in the GUI designer.

Banner in GUI designer

Banner in GUI designer

One last gotcha. You have to specify a height for the form by re-sizing it with the GUI designer. Otherwise the form will end up being small enough to be hidden behind the toolbar.

And remember – this is a way to bypass the NetBeans Platform window system to add components around it. So if things go wrong, you will have to go on a quest to find a Swing guru… 🙂

Nov 142012
 

In our NetBeans Platform application, we have a TopComponent that needs to always be opened in an undocked and maximised state. When I manually undocked the window the first time though, I immediately noticed that the single tab that appears in the window just looks really silly.

So I set out to get the window to automatically undock as well as to remove that annoying tab.

In order to get the window to be opened as undocked, I needed to define a new separated mode to dock the window into. See section 3 of Geertjan’s Secrets of the NetBeans Window System post for more details about the mode. Note that the mode’s kind property needs to be editor for the whole thing to work.

I called my new mode floater, and the code that opens and maximises the window now looked like this:

Mode floater = WindowManager.getDefault().findMode("floater");
TopComponent tc = 
        WindowManager.getDefault().findTopComponent("test2TopComponent");
floater.dockInto(tc);
tc.open();
JFrame root = (JFrame) SwingUtilities.getRoot(tc);
root.setExtendedState(root.getExtendedState() | Frame.MAXIMIZED_BOTH);

But the pesky tab was of course still there, so I needed more information. And in my search I came across another of Geertjan’s articles – Farewell to Space Consuming Weird Tabs. I did, however, not want to remove all the tabs from the whole application, just that particular one. So after creating the class test.NoTabsTabDisplayerUI as Geertjan describes, I had to find the right spot to set the UIManager property. And as it turns out, I just had to set the property before opening the window, and reset it to its previous value after. So the code finally is:

Mode floater = WindowManager.getDefault().findMode("floater");
Object oldTabDisplayer = UIManager.get("EditorTabDisplayerUI");
UIManager.put("EditorTabDisplayerUI", "test.NoTabsTabDisplayerUI");
TopComponent tc = 
        WindowManager.getDefault().findTopComponent("test2TopComponent");
floater.dockInto(tc);
tc.open();
JFrame root = (JFrame) SwingUtilities.getRoot(tc);
root.setExtendedState(root.getExtendedState() | Frame.MAXIMIZED_BOTH);
UIManager.put("EditorTabDisplayerUI", oldTabDisplayer);

Oct 102012
 

A while ago I decided that there is one particular module in a Maven-based NetBeans Platform application that I want to document properly with Javadocs, since it contains an API that other developers will (hopefully) use in future. And so I set out to find where the overview.html and package.html files should go. It turns out that it is actually very simple – just follow the same structure as for any Maven project! There is a very useful description of the structure available here.

Lesson learned: If you don’t find any useful information about some aspect of building Maven-based NetBeans Module projects specifically, the answer might very well just be a standard, generic Maven one. 🙂

Oct 092012
 

Sometimes it is useful to be able to visually separate groups of buttons on the main application toolbar. However, the NetBeans Platform doesn’t add separators to the toolbar by default as it is able to for the menubar. When I recently saw the question being posed again, I decided that it is time to find a way to accomplish this. And the key was in fact the NetBeans IDE 7.2 Plugin Quick Start tutorial. That tutorial describes how you can add other components besides buttons to the toolbar.

I followed the tutorial, but I didn’t create a panel. Instead I implemented the getToolbarPresenter() as follows:

@Override
public Component getToolbarPresenter() {
    JSeparator separator = new JSeparator();
    separator.setOrientation(JSeparator.VERTICAL);
    return separator;
}

That is it. Now I have a separator between two of the buttons on the toolbar.

Separator on the toolbar

Separator on the toolbar