Monday, December 26, 2005

Simplified resource bundle handling with osgi.util.NLS

In eclipse 3.1 there is a new package org.eclipse.osgi.util.NLS. This class allows you to have simple access to a resource bundle.
public class MyMessages extends NLS {
private static final String BUNDLE_NAME = "gr.scharf.MyMessages"; //$NON-NLS-1$

public static String HELLO_WORLD;
public static String HELLO_SOMETHING;

static {
// initialize resource bundles
NLS.initializeMessages(BUNDLE_NAME, MyMessages.class);

And in the file gr/scharf/ I put:
  HELLO_WORLD=Hello world!

Then access to the properties is very simple:

Pretty cool, I think, because it loads the strings from the .properties file into the Messages class transparently. This also helps searching for strings in the code, because it is the same name as in the .properties file.

Sunday, December 25, 2005

When workspaces don't build correctly....

I have some workspaces that are quite 'old'. They have been used with several versions of eclipse. It happens quite often, when I add or remove a project that those workspaces do not build. Eclipse complains that some project should be build first and I should clean the workspace. Well, cleaning the workspace does not help. So, I opened and closed some projects until I got it to work. Very frustrating! It seems that the build order is wrong.

Today, I had the problem again. But I looked at Preferences->General->Workspace->"Build Order". There nothing was set and "use default build order" was unchecked. I checked use default build order and now it works!

Am I the only one having this problem? I wonder if something has changed between two versions of eclipse and the "Build Order" setting did not migrate well and caused that problem.