Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package your.package.here;
- /*
- * THIS EXAMPLE IS ONLY USING THE TWO FIRST COLUMNS SELECTED FROM THE SQL-DB AND
- * THE FIRST COLUMN MUST BE IN STRING-FORMAT AND THE SECOND IN NUMERIC-FORMAT (INT/FLOAT...)
- * GL
- */
- import org.eclipse.birt.chart.model.attribute.Position;
- import org.eclipse.birt.chart.model.type.BarSeries;
- import org.eclipse.birt.chart.model.type.LineSeries;
- import org.eclipse.birt.chart.model.type.PieSeries;
- import org.eclipse.birt.chart.model.type.impl.*;
- import org.eclipse.birt.chart.model.*;
- import org.eclipse.birt.chart.model.attribute.Angle3D;
- import org.eclipse.birt.chart.model.attribute.AxisType;
- import org.eclipse.birt.chart.model.attribute.ChartDimension;
- import org.eclipse.birt.chart.model.attribute.IntersectionType;
- import org.eclipse.birt.chart.model.attribute.LegendItemType;
- import org.eclipse.birt.chart.model.attribute.Orientation;
- import org.eclipse.birt.chart.model.attribute.TickStyle;
- import org.eclipse.birt.chart.model.attribute.impl.Angle3DImpl;
- import org.eclipse.birt.chart.model.attribute.impl.Rotation3DImpl;
- import org.eclipse.birt.chart.model.component.Axis;
- import org.eclipse.birt.chart.model.component.Series;
- import org.eclipse.birt.chart.model.component.impl.AxisImpl;
- import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
- import org.eclipse.birt.chart.model.data.Query;
- import org.eclipse.birt.chart.model.data.SeriesDefinition;
- import org.eclipse.birt.chart.model.data.impl.QueryImpl;
- import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
- import org.eclipse.birt.chart.model.impl.*;
- import org.eclipse.birt.chart.model.layout.Legend;
- import java.util.*;
- import java.util.List;
- import java.awt.event.*;
- import javax.swing.*;
- import java.awt.*;
- import java.util.logging.Level;
- import java.io.File;
- import org.eclipse.birt.report.engine.api.*;
- import org.eclipse.birt.report.model.api.*;
- import org.eclipse.birt.report.model.api.elements.structures.CachedMetaData;
- import org.eclipse.birt.report.model.api.elements.structures.ComputedColumn;
- import org.eclipse.birt.report.model.api.elements.structures.OdaResultSetColumn;
- import org.eclipse.birt.report.model.api.util.CompatibilityUtil;
- import org.eclipse.birt.core.framework.Platform;
- import com.ibm.icu.util.ULocale;
- public class ReportWindow extends JFrame implements ActionListener {
- /**
- *
- */
- private static final long serialVersionUID = -3957044182265192709L;
- private JTabbedPane tabbedpane = new JTabbedPane();
- private ImageIcon iconSettings = null;
- private ImageIcon iconReport = null;
- private JTextField birtHome = new JTextField("C:/dev/BIRT/birt-runtime-2_5_1");
- private JTextField birtEngine = new JTextField("C:/dev/BIRT/birt-runtime-2_5_1/ReportEngine");
- private JTextField birtLog = new JTextField("C:/dev/BIRT/ReportWindow/output/log");
- private JTextField datasourceName = new JTextField("Sample Data Source");
- private JTextField datasourceDriver = new JTextField("org.eclipse.birt.report.data.oda.sampledb.Driver");
- private JTextField datasourceUrl = new JTextField("jdbc:classicmodels:sampledb");
- private JTextField datasourceUser = new JTextField("ClassicModels");
- private JPasswordField datasourcePassword = new JPasswordField("");
- private JTextField datasetSelect = new JTextField("CUSTOMERNAME, CREDITLIMIT");
- private JTextField datasetFrom = new JTextField("CUSTOMERS");
- private JTextField datasetWhere = new JTextField("");
- private JTextField reportDesign = new JTextField("C:/dev/BIRT/ReportWindow/output/design/dynamictable_design_" + getDate() + ".rptdesign");
- private JTextField reportReport = new JTextField("C:/dev/BIRT/ReportWindow/output/report/dynamictable_report_" + getDate() + ".rptdocument");
- private JTextField reportHtml = new JTextField("C:/dev/BIRT/ReportWindow/output/html/test_" + getDate() + ".html");
- private JTextField reportImages = new JTextField("C:/dev/BIRT/ReportWindow/output/html/images/");
- private JCheckBox checkCake = new JCheckBox("Do you want the data with a tasteful pie", true);
- private JCheckBox checkLine = new JCheckBox("and line", true);
- private JCheckBox checkBar = new JCheckBox("'em up in the bar?", true);
- private JButton buttonExecute = new JButton("Execute");
- private String getDate() {
- return new Date(System.currentTimeMillis()).toString().replace(':', '-');
- }
- ReportWindow() {
- super("Report Window");
- setIconImage(new ImageIcon("./resources/icon.png").getImage());
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(tabbedpane, BorderLayout.CENTER);
- JPanel settings = new JPanel();
- iconSettings = new ImageIcon("./resources/settings.png");
- iconReport = new ImageIcon("./resources/report.png");
- JPanel birt = new JPanel(new BorderLayout());
- JPanel birtLabels = new JPanel(new GridLayout(3, 1));
- birtLabels.add(new JLabel("Home Directory:"));
- birtLabels.add(new JLabel("Report Engine Directory:"));
- birtLabels.add(new JLabel("Log Directory:"));
- JPanel birtInput = new JPanel(new GridLayout(3, 1));
- birtInput.add(birtHome);
- birtInput.add(birtEngine);
- birtInput.add(birtLog);
- birt.setBorder(BorderFactory.createTitledBorder("Specify Birt"));
- birt.add(birtLabels, BorderLayout.WEST);
- birt.add(birtInput, BorderLayout.CENTER);
- JPanel datasource = new JPanel(new BorderLayout());
- JPanel datasourceLabels = new JPanel(new GridLayout(6, 1));
- datasourceLabels.add(new JLabel("Name:"));
- datasourceLabels.add(new JLabel("Type:"));
- datasourceLabels.add(new JLabel("Driver Class:"));
- datasourceLabels.add(new JLabel("URL:"));
- datasourceLabels.add(new JLabel("Username:"));
- datasourceLabels.add(new JLabel("Password:"));
- JPanel datasourceInput = new JPanel(new GridLayout(6, 1));
- datasourceInput.add(datasourceName);
- datasourceInput.add(new JComboBox(new Object[] {"JDBC"}));
- datasourceInput.add(datasourceDriver);
- datasourceInput.add(datasourceUrl);
- datasourceInput.add(datasourceUser);
- datasourceInput.add(datasourcePassword);
- datasource.add(datasourceLabels, BorderLayout.WEST);
- datasource.add(datasourceInput, BorderLayout.CENTER);
- datasource.setBorder(BorderFactory.createTitledBorder("Specify Data Source"));
- JPanel dataset = new JPanel(new BorderLayout());
- JPanel datasetLabels = new JPanel(new GridLayout(4, 1));
- datasetLabels.add(new JLabel("Type:"));
- datasetLabels.add(new JLabel("Select (comma-separated columns):"));
- datasetLabels.add(new JLabel("From:"));
- datasetLabels.add(new JLabel("Where (optional):"));
- JPanel datasetInput = new JPanel(new GridLayout(4, 1));
- datasetInput.add(new JComboBox(new Object[] {"JDBC"}), BorderLayout.NORTH);
- datasetInput.add(datasetSelect);
- datasetInput.add(datasetFrom);
- datasetInput.add(datasetWhere);
- dataset.add(datasetLabels, BorderLayout.WEST);
- dataset.add(datasetInput, BorderLayout.CENTER);
- dataset.setBorder(BorderFactory.createTitledBorder("Specify Data Set"));
- JPanel report = new JPanel(new BorderLayout());
- JPanel reportLabels = new JPanel(new GridLayout(4, 1));
- reportLabels.add(new JLabel("Design-file:"));
- reportLabels.add(new JLabel("Report-file:"));
- reportLabels.add(new JLabel("HTML-file:"));
- reportLabels.add(new JLabel("Images directory:"));
- JPanel reportInput = new JPanel(new GridLayout(4, 1));
- reportInput.add(reportDesign);
- reportInput.add(reportReport);
- reportInput.add(reportHtml);
- reportInput.add(reportImages);
- report.add(reportLabels, BorderLayout.WEST);
- report.add(reportInput, BorderLayout.CENTER);
- report.setBorder(BorderFactory.createTitledBorder("Specify Report Output"));
- JPanel execute = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- buttonExecute.addActionListener(this);
- checkCake.setHorizontalTextPosition(JCheckBox.LEADING);
- checkLine.setHorizontalTextPosition(JCheckBox.LEADING);
- checkBar.setHorizontalTextPosition(JCheckBox.LEADING);
- execute.add(checkCake);
- execute.add(checkLine);
- execute.add(checkBar);
- execute.add(buttonExecute);
- SpringLayout layout = new SpringLayout();
- settings.setLayout(layout);
- settings.add(birt);
- settings.add(datasource);
- settings.add(dataset);
- settings.add(report);
- settings.add(execute);
- layout.putConstraint(SpringLayout.WEST, birt, 0, SpringLayout.WEST, settings);
- layout.putConstraint(SpringLayout.NORTH, datasource, 5, SpringLayout.SOUTH, birt);
- layout.putConstraint(SpringLayout.NORTH, dataset, 5, SpringLayout.SOUTH, datasource);
- layout.putConstraint(SpringLayout.NORTH, report, 5, SpringLayout.SOUTH, dataset);
- layout.putConstraint(SpringLayout.NORTH, execute, 5, SpringLayout.SOUTH, report);
- layout.putConstraint(SpringLayout.EAST, execute, 0, SpringLayout.EAST, report);
- tabbedpane.addTab("Setup", iconSettings, settings, "Setup Birt, data source, data set and the report here!");
- setLocation(100, 100);
- setSize(800, 650);
- setVisible(true);
- }
- public void actionPerformed(ActionEvent ae) {
- if (ae.getSource() == buttonExecute) {
- makeNewTab(
- birtHome.getText(), birtEngine.getText(), birtLog.getText(),
- datasourceName.getText(), datasourceDriver.getText(),
- datasourceUrl.getText(), datasourceUser.getText(),
- datasourcePassword.getPassword(), datasetSelect.getText(), datasetFrom.getText(),
- reportDesign.getText(), reportReport.getText(), reportHtml.getText(),
- checkCake.isSelected());
- }
- }
- public Chart createPie(ReportDesignHandle designHandle, ElementFactory designFactory, String[] cols) throws Exception
- {
- System.out.println("starting buildPieChartReport method");
- ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
- cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL );
- cwoaPie.setType( "Pie Chart" );
- cwoaPie.setSubType( "Standard Pie Chart" );
- cwoaPie.getBlock().getBounds().setWidth(800.0); // REQUIRED!
- cwoaPie.getBlock().getBounds().setHeight(400.0); // REQUIRED!
- // Plot
- cwoaPie.setSeriesThickness( 1 );
- // Legend
- Legend lg = cwoaPie.getLegend( );
- lg.getOutline( ).setVisible( true );
- // Title
- cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue( "Pie Chart" );
- // Base Series
- SeriesDefinition sd = SeriesDefinitionImpl.create( );
- sd.getSeriesPalette( ).shift( 0 );
- Series seCategory = SeriesImpl.create( );
- Query query = QueryImpl.create( "row[\"" + cols[0] + "\"]" ); // MUST BE STRING-FORMAT
- seCategory.getDataDefinition().add(query);
- sd.getSeries( ).add( seCategory );
- cwoaPie.getSeriesDefinitions( ).add( sd );
- // Orthogonal Series
- PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
- Query query2 = QueryImpl.create( "row[\"" + cols[1] + "\"]" ); // MUST BE NUMERIC FORMAT
- sePie.getDataDefinition().add(query2);
- sePie.setSeriesIdentifier( cols[0] ); // NAME
- sePie.setExplosion( 5 );
- SeriesDefinition sdCity = SeriesDefinitionImpl.create( );
- sd.getSeriesDefinitions( ).add( sdCity );
- sdCity.getSeries( ).add( sePie );
- return cwoaPie;
- }
- private Chart createBar(ReportDesignHandle design, ElementFactory factory, String[] cols) {
- ChartWithAxes bar = ChartWithAxesImpl.create();
- bar.setDimension(ChartDimension.THREE_DIMENSIONAL_LITERAL);
- bar.setType("Bar Chart");
- bar.setSubType("Side-by-side");
- bar.getBlock().getBounds().setWidth(600.0); // REQUIRED
- bar.getBlock().getBounds().setHeight(600.0); // REQUIRED
- bar.getBlock().getOutline().setVisible(true);
- bar.getTitle().getLabel().getCaption().setValue("Baren");
- bar.getLegend().setItemType(LegendItemType.CATEGORIES_LITERAL);
- // X
- Axis x = bar.getPrimaryBaseAxes()[0];
- x.setType(AxisType.TEXT_LITERAL);
- x.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
- x.getOrigin().setType(IntersectionType.MIN_LITERAL);
- // Y
- Axis y = bar.getPrimaryOrthogonalAxis(x);
- y.setType(AxisType.LINEAR_LITERAL);
- y.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
- y.getLabel().getCaption().getFont().setRotation(90.0);
- // Z
- Axis z = AxisImpl.create(Axis.ANCILLARY_BASE);
- z.setType(AxisType.TEXT_LITERAL);
- z.setLabelPosition(Position.BELOW_LITERAL);
- z.setTitlePosition(Position.BELOW_LITERAL);
- z.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
- z.setOrientation(Orientation.HORIZONTAL_LITERAL);
- x.getAncillaryAxes().add(z);
- // X series
- Series xCategory = SeriesImpl.create();
- xCategory.getDataDefinition().add(QueryImpl.create("row[\"" + cols[0] + "\"]")); // MUST BE STRING-FORMAT
- SeriesDefinition xDefinition = SeriesDefinitionImpl.create();
- xDefinition.getSeriesPalette().shift(0);
- xDefinition.getSeries().add(xCategory);
- x.getSeriesDefinitions().add(xDefinition);
- // Y series 1
- BarSeries yCategory = (BarSeries) BarSeriesImpl.create();
- yCategory.getDataDefinition().add(QueryImpl.create("row[\"" + cols[1] + "\"]")); // MUST BE NUMERIC
- yCategory.getLabel().setVisible(true);
- yCategory.setLabelPosition(Position.OUTSIDE_LITERAL);
- // Y series 2
- BarSeries yCategory2 = (BarSeries) BarSeriesImpl.create();
- yCategory2.getDataDefinition().add(QueryImpl.create("row[\"" + cols[1] + "\"]")); // MUST BE NUMERIC
- yCategory2.getLabel().setVisible(true);
- yCategory2.setLabelPosition(Position.OUTSIDE_LITERAL);
- SeriesDefinition yDefinition = SeriesDefinitionImpl.create();
- yDefinition.getSeriesPalette().shift(-1);
- yDefinition.getSeries().add(yCategory);
- yDefinition.getSeries().add(yCategory2);
- y.getSeriesDefinitions().add(yDefinition);
- // Z series
- SeriesDefinition zDefinition = SeriesDefinitionImpl.create();
- z.getSeriesDefinitions().add(zDefinition);
- // Rotate
- bar.setRotation(Rotation3DImpl.create(new Angle3D[] {Angle3DImpl.create(-10, 25, 0)}));
- return bar;
- }
- private Chart createLine(ReportDesignHandle design, ElementFactory factory, String[] cols) {
- ChartWithAxes bar = ChartWithAxesImpl.create();
- bar.setType("Line Chart");
- bar.setSubType("Overlay");
- bar.getBlock().getBounds().setWidth(800.0); // REQUIRED
- bar.getBlock().getBounds().setHeight(400.0); // REQUIRED
- bar.getTitle().getLabel().getCaption().setValue("Baren"); // funny name :P
- bar.getTitle().setVisible(true);
- bar.getLegend().setVisible(true);
- // X-axis
- Axis x = bar.getPrimaryBaseAxes()[0];
- x.setType(AxisType.TEXT_LITERAL);
- // Y-axis
- Axis y = bar.getPrimaryOrthogonalAxis(x);
- y.setType(AxisType.LINEAR_LITERAL);
- // X series
- SeriesDefinition xDefinition = SeriesDefinitionImpl.create();
- xDefinition.getSeriesPalette().shift(0);
- Series xCategory = SeriesImpl.create();
- xCategory.getDataDefinition().add(QueryImpl.create("row[\"" + cols[0] + "\"]")); // MUST BE STRING-FORMAT
- xDefinition.getSeries().add(xCategory);
- x.getSeriesDefinitions().add(xDefinition);
- // Y series
- LineSeries yCategory = (LineSeries) LineSeriesImpl.create();
- yCategory.getDataDefinition().add(QueryImpl.create("row[\"" + cols[1] + "\"]")); // MUST BE NUMERIC
- yCategory.getLabel().setVisible(true);
- SeriesDefinition yDefinition = SeriesDefinitionImpl.create();
- yDefinition.getGrouping().setEnabled(false);
- yDefinition.getSeries().add(yCategory);
- y.getSeriesDefinitions().add(yDefinition);
- return bar;
- }
- private void makeNewTab(String birtHome, String birtEngine, String birtLog,
- String name, String driver, String url, String user, char[] password,
- String select, String from,
- String designFilename, String reportFilename, String htmlFilename,
- boolean cake) {
- JScrollPane scrollis = new JScrollPane();
- System.out.println("Starting ...");
- try {
- // Startup
- EngineConfig config = new EngineConfig();
- config.setEngineHome(birtEngine);
- config.setLogConfig(birtLog, Level.WARNING);
- Platform.startup(config);
- IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
- IReportEngine engine = factory.createReportEngine(config);
- System.out.println("Engine is set up ...");
- // Create new design
- DesignConfig config2 = new DesignConfig();
- config2.setProperty("BIRT_HOME", birtHome);
- IDesignEngine engine2 = null;
- try {
- Platform.startup(config2);
- IDesignEngineFactory factory2 = (IDesignEngineFactory) Platform.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);
- engine2 = factory2.createDesignEngine(config2);
- } catch (Exception e) {
- e.printStackTrace();
- }
- SessionHandle session = engine2.newSessionHandle(ULocale.ENGLISH);
- ReportDesignHandle design = session.createDesign();
- ElementFactory factory3 = design.getElementFactory();
- // Required
- DesignElementHandle element = factory3.newSimpleMasterPage("Page Master");
- design.getMasterPages().add(element);
- // Data source
- OdaDataSourceHandle dsHandle = factory3.newOdaDataSource(
- name, "org.eclipse.birt.report.data.oda.jdbc" );
- dsHandle.setProperty( "odaDriverClass", driver );
- dsHandle.setProperty( "odaURL", url );
- dsHandle.setProperty( "odaUser", user );
- dsHandle.setProperty( "odaPassword", String.valueOf(password) );
- design.getDataSources( ).add( dsHandle );
- // Data set
- OdaDataSetHandle dsetHandle = factory3.newOdaDataSet( "My Data Set",
- "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
- dsetHandle.setDataSource( name );
- String[] cols = select.split(",");
- for (int i=0; i<cols.length; i++) {
- cols[i] = cols[i].trim();
- }
- ExtendedItemHandle chartItemPie = factory3.newExtendedItem(null, "Chart"); // "Chart" with capital C!!
- chartItemPie.setProperty(ExtendedItemHandle.DATA_SET_PROP, "My Data Set");
- chartItemPie.setProperty("outputFormat", "PNG");
- ExtendedItemHandle chartItemBar = factory3.newExtendedItem(null, "Chart");
- chartItemBar.setProperty(ExtendedItemHandle.DATA_SET_PROP, "My Data Set");
- chartItemBar.setProperty("outputFormat", "PNG");
- ExtendedItemHandle chartItemLine = factory3.newExtendedItem(null, "Chart");
- chartItemLine.setProperty(ExtendedItemHandle.DATA_SET_PROP, "My Data Set");
- chartItemLine.setProperty("outputFormat", "PNG");
- // Cached things
- List<OdaResultSetColumn> columns = new LinkedList<OdaResultSetColumn>();
- // Cached
- dsetHandle.setCachedMetaData(new CachedMetaData());
- StringBuilder query = new StringBuilder();
- query.append("SELECT ");
- for (int i=0; i<cols.length; i++) {
- query.append(cols[i]);
- // Something
- ComputedColumn cc = StructureFactory.createComputedColumn();
- cc.setName(cols[i]);
- if (i == 0)
- cc.setDataType("string");
- else
- cc.setDataType("decimal");
- cc.setExpression("dataSetRow[\"" + cols[i] + "\"]");
- chartItemPie.addColumnBinding(cc, true);
- chartItemBar.addColumnBinding(cc, true);
- chartItemLine.addColumnBinding(cc, true);
- // Cached things
- OdaResultSetColumn column = StructureFactory.createOdaResultSetColumn();
- column.setColumnName(cols[i]);
- column.setPosition(new Integer(i + 1));
- columns.add(column);
- /*
- */
- if (i < cols.length - 1)
- query.append(", ");
- }
- query.append(" FROM ");
- query.append(from);
- String where = datasetWhere.getText();
- if (where.length() > 0) {
- query.append(" ");
- query.append(where);
- }
- dsetHandle.setQueryText( query.toString() );
- System.out.println("query:" + query);
- CompatibilityUtil.addResultSetColumn(dsetHandle, columns);
- design.getDataSets( ).add( dsetHandle );
- if (checkLine.isSelected()) {
- chartItemLine.getReportItem().setProperty("chart.instance", createLine(design,factory3, cols));
- design.getBody().add(chartItemLine);
- }
- if (cake) {
- chartItemPie.getReportItem().setProperty("chart.instance", createPie(design, factory3, cols));
- design.getBody().add(chartItemPie);
- }
- if (checkBar.isSelected()) {
- chartItemBar.getReportItem().setProperty("chart.instance", createBar(design, factory3, cols));
- design.getBody().add(chartItemBar);
- }
- // Build table
- TableHandle table = factory3.newTableItem( "table", cols.length );
- table.setWidth( "100%" );
- table.setDataSet( design.findDataSet( "My Data Set" ) );
- PropertyHandle computedSet = table.getColumnBindings( );
- ComputedColumn cs1 = null;
- for( int i=0; i < cols.length; i++){
- cs1 = StructureFactory.createComputedColumn();
- cs1.setName(cols[i]);
- cs1.setExpression("dataSetRow[\"" + cols[i] + "\"]");
- computedSet.addItem(cs1);
- }
- // table header
- RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
- for( int i=0; i < cols.length; i++){
- LabelHandle label1 = factory3.newLabel( cols[i] );
- label1.setText(cols[i]);
- CellHandle cell = (CellHandle) tableheader.getCells( ).get( i );
- cell.getContent( ).add( label1 );
- }
- // table detail
- RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );
- for( int i=0; i < cols.length; i++){
- CellHandle cell = (CellHandle) tabledetail.getCells( ).get( i );
- DataItemHandle data = factory3.newDataItem( "data_"+cols[i] );
- data.setResultSetColumn( cols[i]);
- cell.getContent( ).add( data );
- }
- design.getBody( ).add( table );
- // Save the design and close it.
- design.saveAs( designFilename ); //$NON-NLS-1$
- design.close( );
- System.out.println("Finished");
- // Html
- IRunAndRenderTask supertask = engine.createRunAndRenderTask(engine.openReportDesign(designFilename));
- supertask.setMaxRowsPerQuery(10);
- HTMLRenderOption htmlOptions = new HTMLRenderOption();
- htmlOptions.setImageDirectory(reportImages.getText());
- htmlOptions.setHtmlPagination(false);
- htmlOptions.setHtmlRtLFlag(false);
- htmlOptions.setEmbeddable(false);
- htmlOptions.setSupportedImageFormats("JPG;PNG;BMP;SVG");
- htmlOptions.setOutputFormat("html");
- htmlOptions.setOutputFileName(htmlFilename);
- supertask.setRenderOption(htmlOptions);
- supertask.run();
- supertask.close();
- // Show html-page
- File file = new File(htmlFilename);
- JEditorPane editor = new JEditorPane();
- System.out.println("Opening file:" + file.toURI().toURL().toString());
- editor.setPage(file.toURI().toURL());
- scrollis.getViewport().add(editor);
- tabbedpane.addTab(htmlFilename, iconReport, scrollis, "Check out the new file!!");
- // Close
- engine.destroy();
- Platform.shutdown();
- } catch (Exception e) {
- e.printStackTrace();
- JOptionPane.showMessageDialog(this, e.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE);
- }
- System.out.println("Done!");
- }
- public void processWindowEvent(WindowEvent we) {
- if (we.getID() == we.WINDOW_CLOSING) {
- close();
- }
- }
- void close() {
- System.exit(0);
- }
- public static void main(String[] args) {
- new ReportWindow();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement