|
|
|
Re: Drill-down report in java swing [message #1045369 is a reply to message #1043815] |
Sat, 20 April 2013 06:02 |
|
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 #1048492 is a reply to message #1048429] |
Wed, 24 April 2013 14:45 |
|
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 |
Thomas Ricaud 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)
|
|
|
Powered by
FUDForum. Page generated in 0.04341 seconds