Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Drill-down report in java swing
Drill-down report in java swing [message #1042357] Tue, 16 April 2013 10:18 Go to next message
Thomas Ricaud is currently offline Thomas RicaudFriend
Messages: 6
Registered: April 2013
Location: Paris
Junior Member
Hi,

I'm building a java swing application including some BIRT report.
I did the usual setup and i have all the POJO jar in my classpath. (BIRT 4.2.2)
I can now run a report with a html ouptformat in a Jeditor . It works fine.

My issue is to create a drill down report in this report .
I today use the drilldown capacities included in BIRT and it works fine in eclipse. But in a JEditor in my java swing application it doesn't.

If anyone as any idea on how i could start to proceed that would be great.

Best Regards,
Re: Drill-down report in java swing [message #1043759 is a reply to message #1042357] Thu, 18 April 2013 05:05 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Are you wanting the drill down to open in a new window or in the same?

Michael

Developer Evangelist, Silanis
Re: Drill-down report in java swing [message #1043815 is a reply to message #1043759] Thu, 18 April 2013 06:50 Go to previous messageGo to next message
Thomas Ricaud is currently offline Thomas RicaudFriend
Messages: 6
Registered: April 2013
Location: Paris
Junior Member
Any solution would be ok.
I have a small preference for navigating in the same window.
Re: Drill-down report in java swing [message #1045369 is a reply to message #1043815] Sat, 20 April 2013 06:02 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Sorry for the delay. I was pretty certain I had posted in here the other day, but it looks like it didn't go through. You could use JavaFX with Swing to add a WebView to your app to show a browser with your BIRT report in it. Then, a drill through should work.

Michael

Developer Evangelist, Silanis
Re: Drill-down report in java swing [message #1048429 is a reply to message #1045369] Wed, 24 April 2013 13:01 Go to previous messageGo to next message
Thomas Ricaud is currently offline Thomas RicaudFriend
Messages: 6
Registered: April 2013
Location: Paris
Junior Member
I'm going to try what Michael suggested but i haven't got a chance yet.
Re: Drill-down report in java swing [message #1048492 is a reply to message #1048429] Wed, 24 April 2013 14:45 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

I've gotten a simple app working with JavaFX and Swing. It allows you to call BIRT reports within your app from the web viewer. This should allow for drill throughs in the reports. I'll hopefully have it finished and blogged about, on BIRT Exchange, soon. I'll post a link in here when I finish.

Michael

Developer Evangelist, Silanis
Re: Drill-down report in java swing [message #1125495 is a reply to message #1048492] Fri, 04 October 2013 15:22 Go to previous message
Thomas Ricaud is currently offline Thomas RicaudFriend
Messages: 6
Registered: April 2013
Location: Paris
Junior Member
Hi,

I finally found some time to get to work in eclipse. Here some code I did to open a swing popup with my report inside.

I got it to work locally in eclipse but not when I run my jnlp application outside eclipse.

here is my JFrame code with the resource locator I had to create to run a report from a jar file and my error at the very bottom.

If anyone has any idea ( it looks like I need to set some sort of javascriptengine context)

package gizmo.userinterface;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IRenderOption;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;

public class RunReport extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4255436363495737794L;
	JEditorPane myEditorPane = null;
	IReportEngine engine = null;
	EngineConfig config = null;

	RunReport() {
		myEditorPane = new JEditorPane();
		myEditorPane.setEditable(false);
		JScrollPane scrollPane = new JScrollPane(myEditorPane);
		JFrame myframe = new JFrame("Comparaison processus");
		myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		myframe.getContentPane().add(scrollPane);
		myframe.setSize(600, 600);
		myframe.setVisible(true);
		startPlatform();
		runReport();
		stopPlatform();
	}

	@SuppressWarnings("unchecked")
	public void runReport() {
		try {
			IReportRunnable design = null;

			// Open the report design
			InputStream stream = this
					.getClass()
					.getResourceAsStream(
							"/gizmo/resources/CompareProcessInTwoEnvironment.rptdesign");
			design = engine.openReportDesign(stream);

			// Create task to run and render the report,
			IRunAndRenderTask task = engine.createRunAndRenderTask(design);

			HTMLRenderOption options = new HTMLRenderOption();
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			options.setOutputStream(bos);
			options.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);
			options.setEmbeddable(true);
			task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, RunReport.class.getClassLoader());
			
			task.setParameterValue("Process", "ATV01");
			task.setRenderOption(options);
			task.run();
			task.close();

			myEditorPane.setContentType("text/html");
			myEditorPane.setText(bos.toString());

			System.out.println("Finished Gen");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public void startPlatform() {
		try {
			config = new EngineConfig();
			config.setResourceLocator(new GizmoRessourceLocator());

			Platform.startup(config);
			IReportEngineFactory factory = (IReportEngineFactory) Platform
					.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
			engine = factory.createReportEngine(config);
			
		}

		catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void stopPlatform() {
		engine.destroy();
		Platform.shutdown();
	}

}


package gizmo.userinterface;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.Collections;
import java.util.Map;

import org.eclipse.birt.report.model.api.IResourceLocator;
import org.eclipse.birt.report.model.api.ModuleHandle;

public class GizmoRessourceLocator implements IResourceLocator {

	public GizmoRessourceLocator() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public URL findResource(ModuleHandle module, String filename, int type) {
		return findResource(module, filename, type, Collections.emptyMap());

	}

	@Override
	public URL findResource(final ModuleHandle moduleHandle,
			final String fileName, final int type,
			@SuppressWarnings("rawtypes") final Map appContext) {
		try {
			// The actual URL is not important, it just needs to be valid.
			// We will later use the parameters to this method to resolve the
			// InputStream.
			return new URL(null, "birtres://"+fileName, new URLStreamHandler() {
				
				@Override
				protected URLConnection openConnection(URL url)
						throws IOException {
					return new URLConnection(url) {

						

						@Override
						public InputStream getInputStream() throws IOException {
							// TODO Return your stream here.
							// Do something with fileName for example.
							System.out
									.println("getInputStream called. fileName is: "
											+ fileName);
							InputStream stream = this
									.getClass()
									.getResourceAsStream(
											"/gizmo/resources/"+fileName);
							return stream;

						}

						@Override
						public void connect() throws IOException {
							// TODO Auto-generated method stub
							
						}
					};
				}
			});
		} catch (MalformedURLException e) {
			// Since it is our own URL, this should not happen.
			throw new IllegalStateException(
					"Hardcoded URL malformed. Please revisit this class.");
		}

	}

}


Now i'm stuck with a error when I run the application outside eclipse.

getInputStream called. fileName is: procedurecode.rptlibrary
oct. 04, 2013 5:18:54 PM org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
SEVERE: An error happened while running the report. Cause:
java.lang.IllegalArgumentException: securityDomain should be null if setSecurityController() was never called
	at org.mozilla.javascript.Context.compileImpl(Context.java:2340)
	at org.mozilla.javascript.Context.compileString(Context.java:1359)
	at org.mozilla.javascript.Context.compileString(Context.java:1348)
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine$3.run(JavascriptEngine.java:240)
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine$3.run(JavascriptEngine.java:1)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine.compile(JavascriptEngine.java:236)
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine.compile(JavascriptEngine.java:1)
	at org.eclipse.birt.core.script.ScriptContext.compile(ScriptContext.java:148)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.compile(ExecutionContext.java:773)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:707)
	at org.eclipse.birt.report.engine.executor.ReportItemExecutor.evaluate(ReportItemExecutor.java:284)
	at org.eclipse.birt.report.engine.executor.TextItemExecutor.executeHtmlText(TextItemExecutor.java:115)
	at org.eclipse.birt.report.engine.executor.TextItemExecutor.execute(TextItemExecutor.java:70)
	at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:87)
	at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:92)
	at org.eclipse.birt.report.engine.executor.ReportExecutor.createPageExecutor(ReportExecutor.java:229)
	at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplciateReportExecutor.createPageExecutor(SuppressDuplciateReportExecutor.java:61)
	at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.createPageExecutor(WrappedReportExecutor.java:49)
	at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeMasterPage(ReportExecutorUtil.java:63)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.start(HTMLPageLM.java:147)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:91)
	at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
	at gizmo.userinterface.RunReport.runReport(RunReport.java:69)
	at gizmo.userinterface.RunReport.<init>(RunReport.java:42)
	at gizmo.userinterface.AideDevelopment$Listener.actionPerformed(AideDevelopment.java:74)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$200(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report.
	at org.eclipse.birt.report.engine.api.impl.EngineTask.handleFatalExceptions(EngineTask.java:2329)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:191)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
	at gizmo.userinterface.RunReport.runReport(RunReport.java:69)
	at gizmo.userinterface.RunReport.<init>(RunReport.java:42)
	at gizmo.userinterface.AideDevelopment$Listener.actionPerformed(AideDevelopment.java:74)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$200(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Previous Topic:Resizing images for DOC output does not work
Next Topic:Global Variables not working in Web Viewer
Goto Forum:
  


Current Time: Tue Mar 19 07:32:23 GMT 2024

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

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

Back to the top