Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to include and use libraries (rptlibrary file) in an Eclipse RCP application
How to include and use libraries (rptlibrary file) in an Eclipse RCP application [message #1009019] Thu, 14 February 2013 09:57 Go to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
Hi,

I have a report done with BIRT 3.7.2. This report was working correctly in our RCP application. But to ease the reuse of our styles and images, I wanted to make a Birt library, shared between reports.

My report seems to access correctly to the library in the Birt Designer, as in the preview tab, all is correctly displayed.

But when I try to use the report in my RCP application I have this error :
14 févr. 2013 10:54:23 org.eclipse.birt.report.model.core.LayoutModule loadLibrarySilently
ATTENTION: Syntax error found, and see error details.
Error.DesignFileException.SYNTAX_ERROR - 1 errors found! 
1.)  org.eclipse.birt.report.model.parser.DesignParserException (code = Error.DesignParserException.FILE_NOT_FOUND, message : The file "reports/designLib.rptlibrary" is not found.)

	at org.eclipse.birt.report.model.core.LayoutModule.loadLibrary(LayoutModule.java:379)
	at org.eclipse.birt.report.model.core.LayoutModule.loadLibrarySilently(LayoutModule.java:469)
	at org.eclipse.birt.report.model.parser.IncludedLibrariesStructureListState$IncludedLibraryStructureState.end(IncludedLibrariesStructureListState.java:145)
	at org.eclipse.birt.report.model.util.XMLParserHandler.endElement(XMLParserHandler.java:176)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)


The rptdesign and the rptlibrary are in the same folder "reports" at the root of my plugin. But I don't know how I can do to make that my report find and use my library ...

Any idea ?


Re: How to include and use libraries (rptlibrary file) in an Eclipse RCP application [message #1009217 is a reply to message #1009019] Thu, 14 February 2013 17:32 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Are you using the viewer? In my example RCP app, if the report and library are in the same folder it works for me. When I change them I set a parameter for the viewer plugin to use as the resource folder. I am doing this in code like:

//get library folder
Bundle mybundle = org.eclipse.core.runtime.Platform.getBundle("org.eclipse.birt.examples.rcpviewer");
URL liburl = FileLocator.find(mybundle, new Path("/rptlib"), null);
String libfolder = FileLocator.toFileURL(liburl).getPath();


HashMap myparms = new HashMap();
HashMap emitmap = new HashMap();

myparms.put("SERVLET_NAME_KEY", "frameset");
myparms.put("FORMAT_KEY", "html");
myparms.put("RESOURCE_FOLDER_KEY", libfolder);
myparms.put("ALLOW_PAGE", "false");
myparms.put("SHOW_PARAMETER_PAGE", "false");

myparms.put("EMITTER_OPTIONS_KEY", emitmap);
WebViewer.display(rpt, browser, myparms);

Jason
BIRT-Exchange

Re: How to include and use libraries (rptlibrary file) in an Eclipse RCP application [message #1009503 is a reply to message #1009217] Fri, 15 February 2013 08:40 Go to previous messageGo to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
Hi,

We are using a Browser to display the report (org.eclipse.swt.browser.Browser). This browser is filled with the content of a ByteArrayOutputStream, which is used as output stream of our IRunAndRenderTask.

But your example gave me an idea, I will try to set a custom resource locator to our EngineConfig instance, to find the resource in our bundle.

Jonathan


[Updated on: Fri, 15 February 2013 08:40]

Report message to a moderator

Re: How to include and use libraries (rptlibrary file) in an Eclipse RCP application [message #1009511 is a reply to message #1009503] Fri, 15 February 2013 08:57 Go to previous messageGo to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
Yeah ! It's working !

I don't know if it's the best solution but this is what i do :
private class CustomResourceLocator extends ResourceLocatorImplBase {

  /** Get the bundle containing the reports resources, in different folders. */
  private Bundle reportsBundle = ReportsPlugin.getPlugin().getBundle();
        
                
  /**
   * {@inheritDoc}
   * 
   * Customise the find function to ensure that the resource can be located in our context,
   * it means in our Eclipse RCP application.
   */
  @Override
  public URL findResource(ModuleHandle moduleHandle, String fileName, int type, Map appContext) {
            
    // First, try to locate the resource in our context
    URL resourceURL = FileLocator.find(
      reportsBundle, 
      new Path(fileName), 
      null);
            
    // If the resource is not found, try the standard search
    if (resourceURL == null) {
      resourceURL = super.findResource(moduleHandle, fileName, type, appContext);
    }
            
    return resourceURL; 
  }
}


And this resource locator is set to our EngineConfig.



Re: How to include and use libraries (rptlibrary file) in an Eclipse RCP application [message #1011022 is a reply to message #1009511] Mon, 18 February 2013 17:27 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This looks good.

Jason
Previous Topic:Is it possible to do Data Cube Scripting?
Next Topic:PPT export - MAC problem
Goto Forum:
  


Current Time: Thu Apr 25 22:38:39 GMT 2024

Powered by FUDForum. Page generated in 0.03400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top