[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.birt] Re: Report internationalization in RCP application

Glad to hear you got it working.

Loïc Bertholet wrote:
Jason,

Thanks again for trying to help me !
It works if the resources are in a RCP plug-in folder. But in my case, my properties are in the plug-in classpath.


The best way I found is to implement my own IResourceLocator this way :

public class MyResourceLocator implements IResourceLocator
{

private DefaultResourceLocator defaultResourceLocator = new DefaultResourceLocator();

@Override
public URL findResource(ModuleHandle moduleHandle, String filename, int type)
{
URL url = this.getClass().getClassLoader().getResource(filename);


if (url == null) {
url = defaultResourceLocator.findResource(moduleHandle, filename,
type);
}


       return url;
   }

}


And set it to my DesignConfig :

DesignConfig designConfig = new DesignConfig();
designConfig.setResourceLocator(new MyResourceLocator());

Loïc


Jason Weathersby wrote:

Loïc,


I tested this with my installation:

Before you create the engine set the resource location to the folder with your properties file. In this example I used a folder called resources that was in my RCP application. This is where I put my properties file.

EngineConfig config = new EngineConfig();

        try{
        Bundle bundle =
org.eclipse.core.runtime.Platform.getBundle("org.eclipse.birt.examples.rcpengine");

URL url = FileLocator.find(bundle, new Path("/resources"), null);
String myresourcepath = FileLocator.toFileURL(url).getPath(); config.setResourcePath(myresourcepath);

}catch(Exception e){

            e.printStackTrace();
        }


// Create the report engine
IReportEngineFactory factory = (IReportEngineFactory) org.eclipse.birt.core.framework.Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
IReportEngine engine = factory.createReportEngine( config );

Jason