Bistro!
Alexis Moussine-Pouchkine's Weblog
public enum Topic { Java, GlassFish, Tools, Sun, InFrenchInZeText, SDPY }

20061020 vendredi octobre 20, 2006

Developing OpenOffice extensions using Java and NetBeans

(short demos at the end)

You can call Sun people slow when it comes to creating an ecosystem of plugins. NetBeans had a platform years ago, but it's only been a year since it became brain-dead easy to develop on top of it. As the saying goes: better late than never...

Now comes OpenOffice.

Starting with version OpenOffice 2.0.4 (freshly released) which was just released, packaging has evolved (new .oxt extension) and tools (Java for the time being) are now available to help you write code to extend the features of the suite or to interact with a silent instance. If you want to find out more about it, read this. Also, the last OpenOffice Conference in Lyon had a presentation by Jürgen Schmidt on “OpenOffice.org Extensions Infrastructure”. Note that all this applies to StarOffice 8 (Update 4) also.

A couple of weeks back, I needed to write a prototype client to illustrate to end-users the use of a web services protocol (more on that in a later entry). TCP tunnels and technical Swing clients are not what you everyday tool and OpenOffice felt like a better choice. The only problem was the rather bad experience I had a couple of years back trying to get my head around UNO, the IDL language behind (inside) OpenOffice. I briefly tried the Eclipse plugin, but it required too much hand-coding and UNO investment.

I was lucky to test-drive an early version of the NetBeans OpenOffice integration plugin (thank you Steffen and Jürgen!). Here's how it went:

What I simply wanted to do is provide a UI to the user to be able to send to current document using an optimized, reliable, and secure web services protocol (implemented in my case using GlassFish's WSIT). If this document was in Open Document format, I would show the document metadata (properties) and send them over in the payload together with the document.

I decided on using Java 6 because of all the great desktop improvements (most important to me were look-and-feel fidelity and no more gray rectangle) it provides and because obviously Java now has Web Services in the JDK. So here are the ingredients:

- Java 6 SDK (I used build 96)
- OpenOffice 2.0.4 (build 680)
- OpenOffice SDK (same version)
- NetBeans 6 Milestone 3

Java needs to be enabled (this is the default), and OpenOffice should be set to use the proper JRE (this is also where debugging options for the JVM are set) :



Once the OpenOffice NetBeans plugin is installed (get it here), and the OpenOffice and SDK configured (Tools -> Options -> Misc.).

NetBeans now has several new project types: client application, Calc Add-in, UNO component:


You can now develop using Java and Swing (Matisse is yet again a life saver) and build the archive (an .oxt file containing the JAR and XML metadata) or even deploy directly (using a call to the unopkg binary) to the OpenOffice instance (you'll need to restart it to test).

setting up UNO environment ...
build UNO idl files finished
uno-idl-compile:
init:
deps-jar:
jar:
Building jar: D:\dev\PRESTOopenoffice\dist\PRESTOopenoffice.jar
uno-package:
creating UNO extension package ...
Deleting: D:\dev\PRESTOopenoffice\dist\PRESTOopenoffice.oxt
Building zip: D:\dev\PRESTOopenoffice\dist\PRESTOopenoffice.oxt
Copying 1 file to D:\dev\PRESTOopenoffice\dist
uno-deploy:
deploying UNO extension package ...
T:/OpenOffice.org2.0\program\unopkg add -f D:\dev\PRESTOopenoffice\dist\PRESTOopenoffice.oxt
BUILD SUCCESSFUL (total time: 3 seconds)

Installing the extension can also be done manually using the Package Manager from the Tools menu (which is how your users would use it). Note that you can deploy this extension into previous versions of OpenOffice (2.0.x) or StarOffice 8 by changing the extension from .oxt to .uno.pkg.

A Calc Add-In project looks like this:



I will not go into all the details of these files. All I can say is that I happy I don't have to know most of what they do and why they exist.
The CalcAddins.xcu file is key to registering your extension in the OpenOffice UI : a menu item, a toolbar, etc... All this can be conditional and internationalized. The uno-extension-manifest.xml file is very similar to the JAR manifest and points to all the resources needed by the extension (including to file described above and all the Java code).

Once set up, you'll have code completion for com.sun.star.* classes.

Debug
It really felt strange the first time I crashed OpenOffice. I started looking for a stacktrace but couldn't find one. So I ended up setting NetBeans de remote debug the JVM running inside OpenOffice executing my code. To enable debugging, add this line to the Parameters in the above Java options window:
-Xrunjdwp:transport=dt_socket,server=y,address=12999,suspend=n
and use Run -> Attach Debugger in NetBeans (the connector is SocketListen and port is 12999 on localhost). You can't step into OpenOffice code at this point, but this proved to be very useful.
   
Tips
- I'm no UNO/OpenOffice expert, so I relied on OO-Snippets (to get the current document path in my case).
- If you really want to mess with .xcu files, make sure NetBeans recognizes them as XML: Tools ->Options ->Advanced ->IDE Configuration ->System ->Object Types ->XML Objects.
- Make sure the .oxt file contains all the Java code you need including libraries (hack the uno-package ANT target if necessary and make sure the manifest has an appropriate entry to reference the library jars relatively using Class-Path:). If you're really in hacking mode, drop library jars in the jre/lib/ext folder.
- If you're crashing OpenOffice all too often, try disabling the auto recovery.
- Looking for standard output: simply start OpenOffice from the command line.

And finally, the small demos :


Using the module in NetBeans.

 Installing and using the extension in OpenOffice.

Hopefully this will give you ideas of what can be achieved with OpenOffice and a little bit of Java coding.
I have a few ideas myself, let's see if can find the time to implement.


( oct. 20 2006, 01:44:04 AM CEST ) Permalink Comments [16]

20061012 jeudi octobre 12, 2006

The "enfant terrible" interview
I first heard about NetBeans in April 1999 in Paris (at the JESS conference) and met Yarda (the man behind the NetBeans Platform) a few years back when we visited a customer in Paris. So Yarda's interview was nice to read and here's what I found interesting:
- the new command line module for the Platform is available (I can think of a thing or two for non-visual but modular applications).
- Yarda speaking about his initial school project : "One of the reasons for the success was probably that the teachers weren't able to install Java at that time and the screenshots looked pretty good." tells you how much Java install got better (on almost all platforms) and how much The Gimp rulez! ;-)
- being an "enfant terrible" is a good thing.

In other NetBeans news, UML builds are now available from the Update Center (compatible with NetBeans 5.5 RC1).

( oct. 12 2006, 11:05:00 PM CEST ) Permalink

20061002 lundi octobre 02, 2006

Visual Pack for NetBeans is approaching
Roman has a nice demo and details about the upcoming Visual Development pack for NetBeans. He calls it Matisse for the web. I beg to disagree, Java Studio Creator has data-binding already (allthough I hear not all will be initially in the pack later this month).

Other than having only one IDE (which is certainly good), the value I see in this pack is to have Java EE 5 support which means I can start mixing the WYSIWYG JSF 1.2 features with the JPA (Java Persistence API) and EJB 3 technologies (with web-tier resource injection in managed beans for instance) and deploy this all to the latest Glassfish (startup and WAR re-deployment speeds have become really nice).

Playing around with this should be fun and it will most certainly remind me of the Project Rave Technology Preview

( oct. 02 2006, 07:10:00 AM CEST ) Permalink Comments [8]

20061001 dimanche octobre 01, 2006

Spring and NetBeans
Just showed up in my RSS reader: Spring Framework Support Module for NetBeans

( oct. 01 2006, 11:06:00 PM CEST ) Permalink Comments [1]

20060925 lundi septembre 25, 2006

Facelets in NetBeans
After JOnAS support in NetBeans, another sweet news: Facelets support in NetBeans. Setup (web.xml editing) is done when creating web project and tag code completion is there also.

Component aliasing in Facelets seems like THE big feature.

Sounds like this issue will be closed soon.
Don't be shy, file issues (including RFEs), they will be read and eventually implemented.

( sept. 25 2006, 03:03:00 PM CEST ) Permalink Comments [3]

20060903 dimanche septembre 03, 2006

Get up to speed on the NetBeans Visual Library 2.0
I've stated previously how much I though the Visual Editor in NetBeans was promising.
Well, Geertjan is running a series of blogs which makes me wish I had more time to dive into this.



( sept. 03 2006, 02:57:00 PM CEST ) Permalink

20060823 mercredi août 23, 2006

Creator and Hibernate tutorial released
NetBeans has great intregration with a bunch of JBoss technology: JBossAS, Hibernate (including the validation framework), SEAM. Now we have a tutorial for using Hibernate together with Java Studio Creator.

( août 23 2006, 12:59:00 AM CEST ) Permalink Comments [2]

20060822 mardi août 22, 2006

JDK examples as NetBeans/ANT projects
Not sure in which JDK6 build this happened first, but JDK examples applications are now available as free-form (ANT-based) projects in NetBeans.



Simply point NetBeans to $JDK_INSTALL/demo

( août 22 2006, 10:59:00 AM CEST ) Permalink Comments [2]

20060612 lundi juin 12, 2006

WTP debugger
Straight from the BEA Workshop 3.1 release notes -
"JSP Debugging: The Workshop Studio JSP debugger replaces the WTP debugger. This makes JSP debugging actually works, ..."

BEA is the lead on WTP, maybe they could contribute their debugger?

( juin 12 2006, 09:00:00 PM CEST ) Permalink

20060524 mercredi mai 24, 2006

Roumen didn't sleep all nigth to bring you this...
Geertjan's best NetBeans 5.5 feature (aka the CRUD feature) now has a screencast with sound.
Check it out here.

( mai 24 2006, 08:17:00 AM CEST ) Permalink

20060523 mardi mai 23, 2006

Animation, eye candy and real API
One of the last sessions I attended at JavaOne was "TS-8943 NetBeans Common Framework for Information Visualization". I've always been interested in graph and visualization APIs ever since I wrote my first Java program which calculated MTBF and MTTR based on how a set of hardware components were (visually) assembled (in series or in parallel).

The presentation was good and started off with the fact that NetBeans and associated tools already have a lot in place, only nothing really unified and usable outside of the NetBeans IDE. So I had a little fun recording random animations in different NetBeans and Sun tools:



So, lot of things there - trees, graphs, layouts, diagrams, zooming, complex structures, animations, transparencey, drop shadow. I'm sure Romain would enjoy most of this (and rewrite the rest).

The good part of this presentation was the intent to have a unified "visualization framework" with a Swing-alike programming model. Demos shown were pretty nice.

The place to look for substantial improvements is http://graph.netbeans.org.

( mai 23 2006, 12:51:00 PM CEST ) Permalink Comments [6]

20060520 samedi mai 20, 2006

More NetBeans Matisse progress
As announced in its roadmap, the NetBeans Matisse gui builder is getting yet even better one step at a time:

Changing the component identifier name triggers all the appropriate refactoring (event handler method name change for instance) -


Improved internationalization feature allows in-line editing in various locales with every label/string outsourced to a resource bundle -


( mai 20 2006, 08:48:00 PM CEST ) Permalink Comments [4]

20060511 jeudi mai 11, 2006

My French blogging doesn't break the NetBeans feed anymore!


( mai 11 2006, 07:00:00 PM CEST ) Permalink

20060430 dimanche avril 30, 2006

Using the Google Calendar (GData) Java APIs in NetBeans
I'd be lost without my Palm device, I've struggled many times with synchronization and wish I could master this sync process myself. So when Google announced their calendar service I felt like I needed to give it a try. Here's my simple setup to use the GData APIs in the NetBeans IDE.

First, download the GData client library from http://code.google.com/apis/gdata/gdata.zip.
It contains client APIs, documentation and source code for both Java and C#. Extract the archive to $GDATA_HOME.

In NetBeans, go to Tools -> Library Manager -> "New Library"
Give the new library any name (such as "GData library").

In the "Classpath" tab, select "Add JAR/Folder..." and add the following jar files:
- $GDATA_HOME/java/lib/gdata-calendar-1.0.jar
- $GDATA_HOME/java/lib/gdata-client-1.0.jar



In the "Sources" tab*, add $GDATA_HOME/java/src and in the Javadoc tab, add $GDATA_HOME/doc/javadoc.
Dismiss the window.

Add this new library to your project (Properties->Libraries or the "Add Library" on the project's Libraries node),



and start coding with code completion, online Javadoc (very useful with any new API) and source debug* :



More info on this pretty exiting API here: http://code.google.com/apis/gdata/index.html

Make also sure all of this uses Java 5 (I've had trouble with Java 6 for some reason with odd server-side JNI messages...) and that you are familiar with the xsd:date and xsd:dataTime formats (hint: use XMLGregorianCalendar and pay attention to timezones!).

* : Note having the sources defined in the library will only let you debug the GData classes if you recompile them with -g.
In that case simply use the build.xml ANT file that's provided to run the default target and change the various <javac debug="false" to <javac debug="true".
Be careful not to use the clean target, it deletes the src folder!

( avr. 30 2006, 07:02:21 PM CEST ) Permalink Comments [2]

20060426 mercredi avril 26, 2006

NetBeans 5.5 Q-Build 2 (April 24th)
I've been updating quite frequently my various NetBeans 5.5. daily builds in the past few weeks as I'm making my way into the brave new world of Java EE 5 and I'm glad we now have a new Quality Build (#2) available for download.

Check out the New and Noteworthy section. One think that got my attention is what could be done with the combined "Entity Classes from Database wizard" and "JSF Pages from Entity Class wizard" features...

This does not cover the UML and SOA tools which are part of the Enterprise Pack (new release real soon I guess).


Update: Adam has more on NetBeans 5.5 here

( avr. 26 2006, 02:31:00 PM CEST ) Permalink Comments [1]


GlassFish Podcast
Get GlassFish V3
Support GlassFish Enterprise

Today's Page Hits: 1132




bea conference glassfish groovy ips java javaee javafx javaone javazone jug mysql netbeans openesb openoffice opensource paris performance pkg podcast presentation sdpy spring sun swing techdays tips updatecenter v3 webservices
Links