Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setContentBase()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#setContentBase() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MasterReportXmlResourceFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected Object finishResult( final Object res, final ResourceManager manager, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { final MasterReport report = (MasterReport) res; if ( report == null ) { throw new ResourceCreationException( "Report has not been parsed." ); } if ( context != null ) { report.setContentBase( context ); } else { report.setContentBase( data.getKey() ); } report.setDefinitionSource( data.getKey() ); report.setResourceManager( manager ); report.updateLegacyConfiguration(); return report; }
Example 2
Source File: LookAndFeelStep.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private AbstractReportDefinition loadDefinitionFromFile( final File filename ) { try { final ResourceKey selectedFile = resourceManager.createKey( filename ); final Resource directly = resourceManager.create( selectedFile, null, new Class[] { MasterReport.class } ); final MasterReport resource = (MasterReport) directly.getResource(); final DocumentBundle bundle = resource.getBundle(); if ( bundle == null ) { // Ok, that should not happen if we work with the engine's parsers, but better safe than sorry. final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle( resource.getContentBase() ); documentBundle.getWriteableDocumentMetaData().setBundleType( ClassicEngineBoot.BUNDLE_TYPE ); resource.setBundle( documentBundle ); resource.setContentBase( documentBundle.getBundleMainKey() ); } else { final MemoryDocumentBundle mem = new MemoryDocumentBundle( resource.getContentBase() ); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyMetaData( mem, bundle ); resource.setBundle( mem ); resource.setContentBase( mem.getBundleMainKey() ); } return (AbstractReportDefinition) resource.derive(); } catch ( Exception ex ) { getDesignTimeContext().error( ex ); return null; } }
Example 3
Source File: Prd4542Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static MasterReport loadReport( final Object selectedFile, final ResourceManager resourceManager ) throws ResourceException, IOException { final Resource directly = resourceManager.createDirectly( selectedFile, MasterReport.class ); final MasterReport resource = (MasterReport) directly.getResource(); final DocumentBundle bundle = resource.getBundle(); if ( bundle == null ) { // Ok, that should not happen if we work with the engine's parsers, but better safe than sorry. final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle( resource.getContentBase() ); documentBundle.getWriteableDocumentMetaData().setBundleType( ClassicEngineBoot.BUNDLE_TYPE ); resource.setBundle( documentBundle ); resource.setContentBase( documentBundle.getBundleMainKey() ); } else { final MemoryDocumentBundle mem = new MemoryDocumentBundle( resource.getContentBase() ); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyMetaData( mem, bundle ); resource.setBundle( mem ); resource.setContentBase( mem.getBundleMainKey() ); } final Object visible = resource.getBundle().getMetaData().getBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "visible" );//NON-NLS if ( "true".equals( visible ) )//NON-NLS { resource.setAttribute( AttributeNames.Pentaho.NAMESPACE, "visible", Boolean.TRUE );//NON-NLS } else if ( "false".equals( visible ) )//NON-NLS { resource.setAttribute( AttributeNames.Pentaho.NAMESPACE, "visible", Boolean.FALSE );//NON-NLS } return resource; }
Example 4
Source File: Prd3319IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method does what the report designer does on save. * * @param report * @param file * @throws Exception */ private void saveReport( final MasterReport report, final File file ) throws Exception { BundleWriter.writeReportToZipFile( report, file ); final ResourceManager resourceManager = report.getResourceManager(); final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class ); final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource(); final ResourceKey bundleKey = bundle.getBundleKey(); final MemoryDocumentBundle mem = new MemoryDocumentBundle(); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyMetaData( mem, bundle ); report.setBundle( mem ); report.setContentBase( mem.getBundleMainKey() ); report.setDefinitionSource( bundleKey ); }
Example 5
Source File: Prd3159IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method does what the report designer does on save. * * @param report * @param file * @throws Exception */ private void saveReport( final MasterReport report, final File file ) throws Exception { BundleWriter.writeReportToZipFile( report, file ); final ResourceManager resourceManager = report.getResourceManager(); final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class ); final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource(); final ResourceKey bundleKey = bundle.getBundleKey(); final MemoryDocumentBundle mem = new MemoryDocumentBundle(); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyMetaData( mem, bundle ); report.setBundle( mem ); report.setContentBase( mem.getBundleMainKey() ); report.setDefinitionSource( bundleKey ); }
Example 6
Source File: Prd3795IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method does what the report designer does on save. */ private void saveReport( final MasterReport report, final File file ) throws Exception { BundleWriter.writeReportToZipFile( report, file ); final ResourceManager resourceManager = report.getResourceManager(); final Resource bundleResource = resourceManager.createDirectly( file, DocumentBundle.class ); final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource(); final ResourceKey bundleKey = bundle.getBundleKey(); final MemoryDocumentBundle mem = new MemoryDocumentBundle(); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyMetaData( mem, bundle ); report.setBundle( mem ); report.setContentBase( mem.getBundleMainKey() ); report.setDefinitionSource( bundleKey ); }
Example 7
Source File: OpenReportAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static MasterReport loadReport( final Object selectedFile, final ResourceManager resourceManager ) throws ResourceException, IOException { final Resource directly = resourceManager.createDirectly( selectedFile, MasterReport.class ); final MasterReport resource = (MasterReport) directly.getResource(); final DocumentBundle bundle = resource.getBundle(); if ( bundle == null ) { // Ok, that should not happen if we work with the engine's parsers, but better safe than sorry. final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle( resource.getContentBase() ); documentBundle.getWriteableDocumentMetaData().setBundleType( ClassicEngineBoot.BUNDLE_TYPE ); resource.setBundle( documentBundle ); resource.setContentBase( documentBundle.getBundleMainKey() ); } else { final MemoryDocumentBundle mem = new MemoryDocumentBundle( resource.getContentBase() ); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyMetaData( mem, bundle ); resource.setBundle( mem ); resource.setContentBase( mem.getBundleMainKey() ); } final Object visible = resource.getBundle().getMetaData().getBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "visible" );//NON-NLS if ( "true".equals( visible ) )//NON-NLS { resource.setAttribute( AttributeNames.Pentaho.NAMESPACE, "visible", Boolean.TRUE );//NON-NLS } else if ( "false".equals( visible ) )//NON-NLS { resource.setAttribute( AttributeNames.Pentaho.NAMESPACE, "visible", Boolean.FALSE );//NON-NLS } return resource; }
Example 8
Source File: DesignTimeUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public static void resetTemplate( final MasterReport report ) { resetDocumentMetaData( report ); report.setContentBase( null ); }
Example 9
Source File: AbstractSaveReportAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public boolean saveReport( final ReportDesignerContext context, final ReportDocumentContext activeContext, final Component parent ) { final MasterReport report = activeContext.getContextRoot(); // Get the current file target File target = getTarget( report, parent ); if ( target == null ) { return false; } // if no name has been set for the report, default to the name of the file String attPath; try { attPath = target.getCanonicalPath(); } catch ( IOException ioe ) { // then let's not set the save path attribute to the *canonical path* attPath = target.getAbsolutePath(); } // Write the report to the filename if ( SaveReportUtilities.saveReport( context, activeContext, target ) ) { try { // change report save path only in case save success. see PRD-5567 report .setAttribute( ReportDesignerBoot.DESIGNER_NAMESPACE, ReportDesignerBoot.LAST_FILENAME, attPath ); // Update the definition source to be the location from which the file is saved final ResourceManager resourceManager = report.getResourceManager(); final Resource bundleResource = resourceManager.createDirectly( target, DocumentBundle.class ); final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource(); final ResourceKey bundleKey = bundle.getBundleKey(); report.setDefinitionSource( bundleKey ); report.setContentBase( bundleKey ); report.setResourceManager( bundle.getResourceManager() ); activeContext.resetChangeTracker(); } catch ( ResourceException e ) { UncaughtExceptionsModel.getInstance().addException( e ); } return true; } final ExceptionDialog exceptionDialog; final Window window = LibSwingUtil.getWindowAncestor( parent ); if ( window instanceof Dialog ) { exceptionDialog = new ExceptionDialog( (Dialog) window ); } else if ( window instanceof Frame ) { exceptionDialog = new ExceptionDialog( (Frame) window ); } else { exceptionDialog = new ExceptionDialog(); } exceptionDialog.showDialog(); return false; }