Archive for April, 2009

EclEmma

Emma is a coverage tool.

EclEmma is an Eclipse plugin that generates Emma coverage. It installs via an update site. It executes via the Run Dialog, so any existing run configuration can be easily “coveraged” (including RCP JUnit tests). An additional coverage tab in the Run Dialog allows you to select which packages will be instrumented.

Results are shown graphically in an Eclipse view, grouped by packages. The view allows you to drill into classes and into methods, showing the coverage of each level along the way. Double-clicking in the view brings up the source code, which is color coded to represent which lines were covered.

This is very useful during the personal development process, as individuals can selectively run unit tests to check for coverage in the related modules they are working with. The results are interactive and allows the developer to quickly see which areas require coverage improvement. This is much easier than waiting and going through a Continuous Integration report later (if any). In fact, I have successfully employed this approach to identify areas lacking coverage, and discovering bugs after having test cases for those areas identified.

Comments

JSplitPane divider location

Use JSplitPane.setDividerLocation() to set the location of the split pane divider.

The interesting thing is this only works after the split pane is realized on the screen. Therefore using this in my initialization procedure before setVisible(true) makes it useless. I’ve confirmed this by setting the divider location immediately before and after frame.setVisible(true).

Comments

JTable column headers

A JTable’s column headers are not shown when you add a JTable to the container.

To show the headers, add the table into a JScrollPane before adding it into the container.

If for whatever reason the scroll pane is not desired, use JTable.getTableHeader() to get the column header component, which you can add to the NORTH side of a BorderLayout for example.

Comments

Groovy Cheatsheet

Used Groovy more frequently recently, so I came up with a cheat sheet for myself. Saw lots of anti-patterns too, but have not got a chance to put them here.

Comments