package com.calipso; import com.calipso.reportgenerator.userinterface.ReportViewer; import com.calipso.reportgenerator.common.InfoException; import com.calipso.reportgenerator.common.IReportManager; import com.calipso.reportgenerator.client.ReportManagerService; import javax.swing.JFrame; import javax.swing.JTextField; import java.awt.BorderLayout; /** * Calipso Software * User: jbassino * Date: 30-may-2006 * Time: 13:35:07 */ public class JMagallanesIntegration { /** * Use here test.init() or test.init2(), to see different possible integrations. * @param args */ public static void main(String[] args) { JMagallanesIntegration test = new JMagallanesIntegration(); try { test.init2(); } catch (InfoException e) { e.printStackTrace(); System.exit(0); } } /** * First option for integration. Includes all the Viewer in another window. User may execute reports. * @throws InfoException */ private void init() throws InfoException { /*Starts the service for executing reports. Parameters are: propertiesPath: Path to the configuration file. If "" gets the file from working directory log: a logger. If null creates a new one. distributedHost: If running J2EE distributed and you need to set a Host diferent from the one specified in the properties file. Usefull for Java Web Start deploy */ IReportManager service = ReportManagerService.getReportManagerService("" ,null, ""); //Creates your swing components JFrame frame = new JFrame("ReportViewer Test"); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(new JTextField("OTHER FORTIS SWING COMPONENTS"), BorderLayout.NORTH); /*Creates a ReportViewer component with the service created before. Parameters are: userID: The user that executes the report reportDefinitionID: you may use a report id to execute. If null, doesn't execute anything, and lets you select report reportViewID: if you execute a report, you may use a view propertiesPath: same as in getReportManagerService reportManager: The service created before for execution visibleActions: Flag to enable/disable buttons for report execution. If false, you must set a ReportId to execute. User won't be able to execute other reports params: If the report executed has parameters or filters, you may set a Map whith the entry "ParameterName, ParameterValue" */ ReportViewer viewer = new ReportViewer("root", "","","",service,true, null); //Add the viewer to your frame frame.getContentPane().add(viewer.getContentPane(), BorderLayout.CENTER); frame.getContentPane().add(new JTextField("OTHER FORTIS SWING COMPONENTS"), BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } /** * Second option of integration. Sets a ReportId, and the viewer executes and shows that report inside the window * User won't be able to execute other reports, because operations and execution are disabled. * @throws InfoException */ private void init2() throws InfoException { IReportManager service = ReportManagerService.getReportManagerService("" ,null, ""); JFrame frame = new JFrame("ReportViewer Test"); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(new JTextField("OTHER FORTIS SWING COMPONENTS"), BorderLayout.NORTH); /* The constructor with the report definition id, executes that report, and starts the viewer showing the result Also, if you set the visibleActions flag to false, the user just see that report. User won't be able to do further executions */ ReportViewer viewer = new ReportViewer("root", "RD_DISTRIBUTION_SALARY_CUBE","","",service,false, null); frame.getContentPane().add(viewer.getContentPane(), BorderLayout.CENTER); frame.getContentPane().add(new JTextField("OTHER FORTIS SWING COMPONENTS"), BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } }