Monday Mar 15, 2010

NetBeans Platform in the French Community

Mike Francois from recently translated into French an article I wrote on DZone. Here it is:

Interopérabilité d'OSGi avec la plateforme NetBeans

"Avec la sortie de NetBeans 6.9, la plate-forme de service OSGi s'est vue obtenir un support complet par l'EDI.

Geertjan Wielenga, auteur technique de l'équipe NetBeans, a rédigé un article sur l'interopérabilité d'OSGi avec la plate-forme NetBeans.

Ci-dessous, la traduction de son article qui je l'espère vous apprécierez autant que j'en ai eu pour le traduire."

So, it is great to have articles like this written, so that the NetBeans Platform can be introduced to French speakers too. At the same time, several French organizations are already making use of the NetBeans Platform, from the ray simulation analyzer at the University of Poitiers (described here) to the radar simulation analyzer at the French Ministry of Defence (described here).

And, in the next few weeks, a first NetBeans Platform Certified Training will be held for a selected group of new NetBeans Platform developers in France. That will be the first time that the course will be delivered via WebEx, maybe the start of several more, if everything turns out well. With Mike Francois from, I'm talking to see whether a small tour of cities/universities could be arranged to introduce the NetBeans Platform to French developers.

If French readers of the above are interested in this development in some way, feel free to say so (and suggest locations for trainings in France) privately via an e-mail to me or by leaving a comment at the end of this blog entry.

File-Based Document-Centric NetBeans Platform Application

Not all document-centric applications need a full-blown project system. So here is a small application that lets you create files. The files could open in a multiview editor, of course, but for sake of argument, let's simply open them in a plain text editor.

In the end, you'll be able to open the New File dialog:

...and choose the Letter wizard, set some properties:

...which is then generated (via FreeMarker) into your template:

To attain the above result, use the Wizard wizard to create a one panel file wizard. Design the panel as shown above. Then use the following content in your "instantiate" method within the iterator class:

@SuppressWarnings(value = "unchecked")
public Set instantiate() throws IOException {

    DataObject activatedDObj = WindowManager.getDefault().getRegistry().getActivated().getLookup().lookup(DataObject.class);
    String targetName = wizard.getProperty(LetterVisualPanel1.NAME).toString();
    DataFolder df = DataFolder.findFolder(activatedDObj.getPrimaryFile());

    Object[] data = (Object[]) wizard.getProperty(LetterVisualPanel1.PRODUCTS.toString());
    HashMap hashMap = new HashMap();
    hashMap.put("url", wizard.getProperty(LetterVisualPanel1.URL));
    hashMap.put("name", targetName);
    hashMap.put("types", data);

    FileObject template = FileUtil.getConfigFile("Templates/Letters/letter.letter");

    DataObject dTemplate = DataObject.find(template);

    DataObject dobj = dTemplate.createFromTemplate(df, targetName, hashMap);

    FileObject createdFile = dobj.getPrimaryFile();

    return Collections.singleton(createdFile);


Read about the DataObject.createFromTemplate here, as well as about how to register the template in the layer file:

<folder name="Templates">
    <folder name="Letters">
        <file name="letter.letter" url="letter.ftl">
            <attr name="SystemFileSystem.localizingBundle" stringvalue=""/>
            <attr name="displayName" bundlevalue=""/>
            <attr name="instantiatingIterator" newvalue=""/>
            <attr name="template" boolvalue="true"/>
            <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
            <attr name="instantiatingWizardURL" urlvalue="nbresloc:org/car/templates/letterWizardDescription.html"/>

And here's the related "letter.ftl" file referred to above:




            Welcome ${name}<#if name = "Tom">, you wonderful person!</#if>!

       <p>URL: <a href="${url}">${url}</a>

        <table border=1>
           <tr><th>Chosen Products<th></tr>
          <#list types as product>



To let FreeMarker process the above file, you need the "javax.script.ScriptEngine" element in your layer, as shown above, together with the following line in your manifest:

OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker

Then set dependencies on the DataSystems API, as well as the FreeMarker Integration module (until 6.9, after which you won't need this at all), which is within the "ide" cluster.

And now you're done. Simply brand the Favorites window as shown elsewhere and then you have a file-based document-centric application, i.e., you're not using any project-related APIs (which would have added a lot of superfluous features in the context of this small file-based application).


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« March 2010 »