Individual Source Bundles and Eclipse Newsgroups

January 23, 2009

This is a 2 goals post

  1. “Tip” about Individual Source Bundles
  2. Everybody should use Eclipse Newsgroups

Let’s get started with the technical issue …

After reading the online help page about Individual Source Bundle I started to modify my headless build in order to generate individual source bundles for my examples plugins. Following the help page, I quickly had individual source bundles successfully exported, fine !!!

The problem comes here …. after installing my plugins in a clean SDK Eclipse installation I was not able to import my examples plugins as source projects. Here is the “error in opening zip file”  :

erroinzip

Several investigations and many “Googling” didn’t solve the problem. I still had this @*####.. error !!!

Now comes this magic thing calls Community.

I decided (in fact it was on of my last solution before stepping inside PDE’s code) to ask the question on PDE newsgroup. 24 hours after my question was asked, I received THE answer from Andrew Niefer. Many thanks !!!

Individual source bundles must be packaged as Jar files and not as directories, it is implicitly said in the help:

“For each bundle there is a corresponding source bundle which is a jar containing the source for that bundle”

I just Unchecked the Unpack plug-in archive after installation in my feature.xml for all my individual source bundle and now it works !!!!!

My conclusion here are:

I’ll try to use more and more newsgroups and I’ll try as often as possible to answer questions asked on newsgroups.

Always package my source bundles as Jar files



JFace Bug 9262

January 16, 2009

Just a quick tip about JFace viewers.

JFace Bug 9262

JFace Bug 9262

Wondering where this bug comes from ??? After 10mn about reading again and again my code to figure out why my SWT tree was showing recursively (infinitely) my root object, I finally suspected JFace (without convictions) and reached this bug, source of my problem.

According to the Javadoc of the IStructuredContentProvider. public Object[] getElements(Object inputElement) method you can’t return a single item object array containing only inputElement.

“NOTE: For instances where the viewer is displaying a tree containing a single ‘root’ element it is still necessary that the ‘input’ does not return itself from this method. This leads to recursion issues (see bug 9262).”

To solve this issue I just created a new class for my root object and instead of returning an object containing the inputElement I return an array containing a new instance of this root element (having of course a reference on the inputElement).

Manuel


Restorable Views

January 14, 2009

Since Eclipse 3.4, the extension point allowing to define new views inside the workbench has a new attribute called restorable.

Here is the description for this attribute: “flag indicating whether this view allows to be restored upon workbench restart. If set to false, the view will not be open after a workbench restart. The default is true.”

This can be useful for views which content can’t be restored across workbench instances. In our case to “emulate” this behavior we had previously to listen for workbench closes and to programatically close the views that will not be restored.

As a result the following piece of code (that may causes errors !!!!) is replaced just by ONE XML line

private void closeMe() {
     Display.getDefault().syncExec(new Runnable() {
         public void run() {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                 .getActivePage().hideView(OutlineView.this);
            idToSession.removeByV(session);
            sessionToView.removeByK(session);
        }
   });
}

PlatformUI.getWorkbench().addWorkbenchListener(new IWorkbenchListener() {
    public void postShutdown(IWorkbench workbench) {}
    public boolean preShutdown(IWorkbench workbench, boolean forced) {
       closeMe();
       return true;
   }
});

Manu


What I (As Computer Scientist) Ignored About Floating-Point Arithmetic

January 12, 2009

Hi there, it’s the first time I am blogging this year so before starting this post here is the famous Happy New Year in its french version  Bonne Année

I started the 2009 year with the following sad statement:

“I ignored  What Every Computer Scientist Should Know About Floating-Point Arithmetic …” :(

Dealing for the first time with double values in my Ecplise’s plugins last week, Floating-Point arithmetic wished me an happy New Year with its lot of astonishments.

0.1 + 0.1 +0.1 +0.1 = 0.39999999678 ???

After several reading and discussions with experimented colleagues I know now just a little bit more about Floating point arithmetic. I was able to understand and to solve the problems I faced  as a naive programmer dealing with this arithmetic and I think it’s enough for now. Nevertheless I’ll keep carefully the link to the article previously mentioned in order to belonging as soon as possible to this category of scientist developers Knowing the minimum required about floating point arithmetic. :)

I am also curious to know how many of you are working or have been working intensively with Java double and float primitive types ??

Manu