Thursday Dec 07, 2006

Test Libraries Node for NetBeans Module Project

Tomas Musil (our QA specialist) yesterday contributed Test libraries node for NetBeans module project. It simplifies editing classpath for tests.Thanks to Tomas contribution, you don't need to edit project.xml for setting classpaths of tests manually. New test dependency can be added from popup of test libraries node.

Add Unit Test Dependency action shows Add dependency dialog.

The dialog has the same behaviour like dialog or adding module dependency. Test library dependency also contains customizer. It can be shown from popup of test library node.

Tuesday Dec 05, 2006

NetBeans Tea-Team

Few developers and me from NetBeans core team very often drink tea. We drink different kind of tea - green, yellow, black, pu erh, etc. Yesterday architect of our tea-team (the "enfant terrible") took pictures of us.

Who is on the picture? On the left side is sitting Milos Kleint. He develops Maven 2 plugin. Besides him is Martin Krauskopf. Martin is now working on debugger for JRuby. On the right side is laughing Radim Kubacki. He takes care of performance of NetBeans IDE.

Other developers are so kind to boil water.
Our editor VIP - Mila Metelka:

Retouche EXPERT - Tomas Zezula:

BTW he fixed me today bug.

Tuesday Sep 19, 2006

Command Line Parsing API in NetBeans Platform

Jaroslav Tulach integrated Command Line Parsing API to NetBeans platform this week. The API was already tested in DVB Central project.

I wrote simple OptionProcessor in few minutes:

import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.netbeans.api.sendopts.CommandException;
import org.netbeans.spi.sendopts.Env;
import org.netbeans.spi.sendopts.Option;
import org.netbeans.spi.sendopts.OptionProcessor;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;

public class MyOptions  extends OptionProcessor {
    private static Option message = Option.requiredArgument(Option.NO_SHORT_NAME, "message");
    public Set

The MyOptions processor is register in META-INF/sevices. The registration can by done by META-INF/services browser. The MyOptions provider display first parameter of -message parameter in message dialog box. For Example

./netbeans --message Hello
shows Hello message.

Friday Sep 15, 2006

META-INF/services Browser for NBM project

Together with Jaroslav Tulach we are developing META-INF/services browser for NetBeans module project. In short META-INF services node was added to Important files node:

The META-INF services node has two children nodes:

  • <Exported Services> - services exported by module.
  • <All Services> - services from NetBeans platform and all modules in module suite.
The Service can be added from pop-up menu of Service type by clicking to Add New Service item. It shows Add Service dialog:

Full class name of Service is typed to Class name text field. The class name of new service can be also selected in packages view. The package view will be shown after clicking on Browse button:

Already installed service can be masked/unmasked from default Lookup by Delete menu item on service instance in All Services view.

Details about this feature are in issue #66606. We want to integrate it to Milestone 4 NetBeans build.

Thursday Sep 14, 2006

Run only tests which uses your code

NetBeans test distribution allows to run tests for modules which requires a specific module on runtime testing classpath. For Example you have built test distribution for 'org-openide-filesystems' and 'org-netbeans-modules-masterfs' NetBeans modules.

Use case 1: You want to run test with 'org-openide-filesystems' module on runtime testing classpath:

     ant unit -Dtest.required.modules=org-openide-filesystems.jar -Dnetbeans.dest.dir=netbeans_installation_dir
It runs both modules - 'org-openide-modules-masterfs.jar' and 'org-openide-filesystems.jar'.

Use case 2: You want to run test with 'org-netbeans-modules-masterfs' module on runtime classpath:

     ant unit -Dtest.required.modules=org-netbeans-modules-masterfs.jar -Dnetbeans.dest.dir=netbeans_installation_dir
It runs tests only for org-netbeans-modules-masterfs module because org-netbeans-modules-masterfs module is not on runtime testing classpath of org-openide-filesystems module.

Thursday Sep 07, 2006

Using velocity templates in NBM projects

Many people asked me how to use velocity template in their NetBeans module projects. So there is short example. Velocity libraries are wrapped to org-apache-velocity.nbm NetBeans module.

First time you need to install the module to NetBeans platform. Now we can start to write Velocity module. Add org-apache-velocity on classpath of module. Example class with generating code is below:

public class SimpleTemplate {  
    /\*\* Write generated code to target document
    public static void apply(Writer t,String vmTemplate,Map beans) {
        try {
            VelocityContext context = VTResourceLoader.getContext();
            for (Iterator bIt = beans.keySet().iterator() ; bIt.hasNext() ;) {
                String name = (String);
                Object bean = beans.get(name);
                context.put(name, bean);
            Template template = Velocity.getTemplate(vmTemplate);
            if (t == null) {
                throw new IllegalStateException(" no target defined ");
            template.merge(context, t);
        } catch (Exception e) {
            Logger.getAnonymousLogger().log(Level.SEVERE,"Exception during generating templates",e);
The velocity template is present in velocity/templates folder of layer.xml :
      <folder name="velocity"> 
        <folder name="templates">
             <file name="template.vm" url="Simple.vm"/>

Map of java objects is parameter for templates. Only one bean is used in our example:
public class SimpleBean {
    private String name;

    public String getName() {
        return name;

    public void setName(String name) { = name;

A template.vm example : = $
We can write action with body:
    public void performAction() {
        // TODO implement action body
        InputOutput io = IOProvider.getDefault().getIO("template test",true);
        Map map = new HashMap();
        SimpleBean sb = new SimpleBean();
It prints to output window transformed template: = Text

Wednesday Sep 06, 2006

Test Dependencies of NetBeans Modules Moved to Project.xml

Test Dependencies of NetBeans module project are defined in nbproject/ for previous versions of NetBeans.The test dependencies can be also added to project.xml for projects of NetBeans 6.x. The new variant is recommended. The test dependencies allows to define:

  • Compile and runtime dependency to module.
  • Compile and runtime dependency for tests of modules.
  • Recursive dependecy to module.

For migrating test dependencies from to project.xml was implemented fix-test-dependencies ant tasks in NetBeans module project. You can do it from command line:

cd your_nbm_project_dir
ant fix-test-dependencies

GUI for adding/removing test dependencies has not yet been implemented. I hope it will be available early. It can by done only manually by editing project.xml file. The tags for test dependencies (defined in xml schema) are described below:

        <! -- Dependencies for a source root with tests: -->
            Name of test type. Normally you will use 'unit'.
   modules also support 'qa-functional' test-type.
            <!-- A dependency on a module or its tests: -->
                <!-- Identification of module our tests depend upon: -->
                <!-- Include also transitive module dependencies of that module: -->
                <!-- Always available when running, but to include at compile time also: -->
                <!-- To request the tests of that module, rather than itself: -->

Source root for a test type:
{project.dir}/test/unit/src - source root for unit test

For example you have three modules with code name bases A,B,C. A depends on B, B depends on C. You want to add test dependencies to unit test type of module D:

Use case 1: Runtime dependency on module.
  • Runtime classpath is D+A.
  • Compile classpath is D.

Use case 2: Runtime dependency on a module and its recursive runtime classpath.
  • Runtime classpath is A+B+C+D.
  • Compile classpath is D.

Use case 3: Compile and runtime dependency on a module its recursive runtime classpath.
  • Runtime classpath is A+B+C+D.
  • Compile classpath is A+B+C+D.

Use case 4: Compile and runtime dependency on a module, its recursive runtime classpath and tests.
  • Runtime classpath is A+B+C+D + A/unit tests.
  • Compile classpath is A+B+C+D + A/unit tests.

Friday Sep 01, 2006

Binary Test Distribution For NetBeans IDE

I'm finishing binary test distribution for NetBeans IDE. The test distribution won't be available for NetBeans 5.5 because it's too late to do it. The distribution will be available for NetBeans 6.0 build on download page, I hope. Quality Engineering team got idea to distribute NetBeans with its test binaries few years ago. We decided after a while to spend time to remove cvs dependencies on running tests and create files layout for test binaries.

To build test distribution is very simple now. You only need to checkout cvs files for NetBeans dev build, build ide and test distribution:

cvs co standard_nowww
cd nbbuild
ant build-test-dist

Ant needs more memory for building tests than is default value. So increase it by overring ANT_OPTS environment variable.

The property ignore compilation failures because few tests are still uncompilable. It is curious that some test are uncompilable. Why developer write tests if the test is uncompilable after a while. IMHO all the tests will have to be run daily if continuos integration is dream. I hope it will be solved as soon as possible.

The tests are built into nbbuild/build/testdist folder and packed to nbbuild/build/ file. In the root folder of test distribution is short README.txt file. It contains description how to run tests. For example when you want to run all test(qa-functional and unit), you need only run ant :

ant all -Dnetbeans.dest.dir="${netbeans.home}"

The netbeans.dest.dir property contains directory with NetBeans installation. Te result of testrun is formated to html files. The html files are available in:

  • unit/results - for unit tests
  • qa-functional/results - for qa-functional tests

More details about binary test distribution are here.

Sunday Aug 20, 2006

Floating Windows In NetBeans

NetBeans 6.0 Milestone 2 build contains Floating windows feature. A window (TopComponent) can be undocked by dragging the window's title bar outside the NetBeans IDE. UI specification is available here. The specifacation also coontans few flash demos. For examle :

The feauture is also part of NetBeans platform. If you want to use it in your rich-client applications on top of the NetBeans Platform you need to rebuild it against NetBeans 6.0 M2 platform. I tried it for Paint Application tutorial. Screenshot is below.

Wednesday Jul 12, 2006

Fullscreen mode in NetBeans platform

I've already blogged about fullscreen mode here. The fullscreen mode feature has been integrated into NetBeans 6.0 development daily builds.

It is very easy to add this feature to already written application based on NetBeans platform. If the application is compiled against NetBeans 6.0dev platform View|Full Screen menu item will be added automatically. Screenshot with NetBeans FeedReader in fullscreen mode is shown below.

The fullscreen mode works for JNLP application too.

Wednesday Jun 14, 2006

Netbeans met GWT and more GWT components

I wrote about my first experience with GWT in my last blog. Yesterday I experimented with GWT application in NetBeans. The new GWT plugin contains GWT project type. It is now easy build, run and debug GWT projects in NetBeans. The code completion with javadoc is also available. Tomas will publish his plugin early, I hope.

On are more GWT components. My favorite is Auto-Completion Textbox. It allows to add Code completion to Texbox on web page. The AutoCompleteTextBox component extends TextBox class. It adds to TextBox one new useful method:

public void setCompletionItems(CompletionItems items)
The CoompletionItems type is code completion provider:
public interface CompletionItems {
         \* Returns an array of all completion items matching
         \* @param match The user-entered text all compleition items have to match
         \* @return      Array of strings
        public String[] getCompletionItems(String match);
I wrote a simple application with AutoCompleteTextBox. The class with GWT EntryPoint is below. It shows code completion for names.
public class Main implements EntryPoint {
    class NameCompletionItem implements CompletionItems {
        public String[] getCompletionItems(String match) {
            ArrayList list = new ArrayList();
            String values[] =  new String[]{"roumen","radim","xzajo","geertjan","lukas"}; 
            String lowerMatch = match.toLowerCase();
            for (int i = 0 ; i < values.length ; i++) {
                String value = values[i];
                if (value.startsWith(lowerMatch)) {
            String retVals [] = new String[list.size()];
            for (int i = 0 ; i < list.size() ; i++) {
               retVals[i] = (String) list.get(i); 
            return retVals;
    public void onModuleLoad() {
        AutoCompletionTexBox textBox = new AutoCompletionTexBox();
        textBox.setCompletionItems(new NameCompletionItem());

Conversion between ArrayList and array of Strings doesn't work on client side of GWT (Collection.toArray(Object[] array). The gwt compiler shows an error. Therefore I used the for loop. Screenshot with code completion in browser is below.

Friday May 26, 2006

XTest testing framework flash

Jiri Skrivanek updated documentation how to use XTest framework in NetBeans IDE. XTest is extension of JUnit 3.x. It was designed to help develops tests for NetBeans platform. The flash demo is available here. Updated tutorial for XTest is on this page.

Many people in NetBeans asked me why not to switch to TestNG with annotations. To tell you truth xtest already has more features than TestNG now. Xtest has also few disadvantages. It is difficult to configure it. The authors of xtest never wrote tests. Only Jiri Skrivanek, the last owner, writes tests. Maybe he is the right person who fix problems with xtest.

Why we still use Xtest for testing NetBeans? There are few reasons:

  • Over 4000 already written tests. Why to rewrite them or simulate the environment?
  • Ability to store results to database
  • Test4u infrastructure runs daily on different platforms and JDKs
  • Used for responsiveness and performance testing

Thursday May 25, 2006

NetBeans in full screen mode

Yesterday I was speaking with Stanislav Albrecht. He is working on fullscreen mode feature in NetBeans. He showed me it on Windows L&F. The feature has not finished yet. He need to implement full sreen mode feature also for others Look&Feels. But I was impressed. I use fullscreen mode in other application on my notebook. It saves workspace on my display. I can use it now also in NetBeans.

UI spec with flash demo for this feature is available on this page. Stanislav gave me a build with this feature for testing. I will show few screenshots. On the first screenshot is NetBeans in normal mode.

Two actions are highlighted in the screenshot. The first is in main menu. It shows NetBeans in full screen mode. The second is represented by icon in the right corner of window. It maximizes the window in NetBeans layout. The other windows are slided off - minimized by window sliding feature. I clicked on both actions. The result is on the screenshot below.

The main menu will be hidden in final version. This feature will be also available for application based on RCP. Developers don't need to change their applications. They only need to rebuild their applications with new NetBeans platform. The full screen action and maximize window button will be added automatically.

Thursday Apr 27, 2006

Spellchecker for Javadoc plugin

Spellchecker module was added on update center this week. Author is Jan Lahoda. This module provides Spellchecker API. It underlines misspelled words in the editor, provides hints with possible fixes. Currently is implemented spellchecker for javadoc.

It will be useful if someone also implements spellchecker for HTML editor. Is there any volunteer?

Friday Apr 07, 2006

Preview Version of LaTeX for NetBeans 5.0

I am proud to announce testing version of Jan Lahoda's LaTeX for NetBeans 5.0 plugin. How to install

  1. Download and install NetBeans 5.0
  2. Download plugin LaTeX update center. Plugin is available here. Install it in NetBeans (Tools|Update Center).
  3. Open again Update Center and install all LaTeX modules.

When all modules are successfully download and installed it is necessary to do two thinks :

  1. LaTeX post installation (LaTeX|Post Install Wizard from main menu).
  2. Setup paths of external binaries (Latex category in Tools|Options). Options dialog with settings on my Ubuntu Linux is shown bellow.

Please give feedback to Jan Lahoda on mailing list. To subscribe send mail to address.




« June 2016