Code Search for Developers
 
 
  

BIRTExternalContext.java from BIRT at Krugle


Show BIRTExternalContext.java syntax highlighted

/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.chart.reportitem;

import org.eclipse.birt.chart.log.ILogger;
import org.eclipse.birt.chart.log.Logger;
import org.eclipse.birt.chart.script.IExternalContext;
import org.eclipse.birt.report.engine.api.script.IReportContext;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ImporterTopLevel;
import org.mozilla.javascript.Scriptable;

/**
 * An external context implementation for BIRT environment.
 */
public class BIRTExternalContext implements IExternalContext
{

	private static final long serialVersionUID = 1L;

	private transient IReportContext context;
	private transient Scriptable scriptableContext;

	private static ILogger logger = Logger.getLogger( "org.eclipse.birt.chart.reportitem/trace" ); //$NON-NLS-1$

	/**
	 * The constructor.
	 */
	public BIRTExternalContext( )
	{
		super( );
	}

	/**
	 * The constructor.
	 * 
	 * @param context
	 */
	public BIRTExternalContext( IReportContext context )
	{
		this.context = context;

		final Context cx = Context.enter( );

		try
		{
			Scriptable scope = new ImporterTopLevel( cx );

			scriptableContext = cx.getWrapFactory( ).wrapAsJavaObject( cx,
					scope,
					context,
					null );
		}
		catch ( Exception e )
		{
			logger.log( e );
		}
		finally
		{
			Context.exit( );
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.script.IExternalContext#getScriptable()
	 */
	public Scriptable getScriptable( )
	{
		return scriptableContext;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.chart.script.IExternalContext#getObject()
	 */
	public Object getObject( )
	{
		return context;
	}

}




See more files for this project here

BIRT

BIRT is an open source, Eclipse-based reporting system that integrates with your application to produce compelling reports for both web and PDF.

Project homepage: http://www.eclipse.org/birt/phoenix/
Programming language(s): Java,XML
License: gpl2

  i18n/
    Messages.java
    nls.properties
  plugin/
    ChartReportItemPlugin.java
  ui/
    widget/
  BIRTActionEvaluator.java
  BIRTActionRenderer.java
  BIRTDataRowEvaluator.java
  BIRTExternalContext.java
  BIRTMessageLookup.java
  BIRTScriptClassLoader.java
  ChartChoiceDefinitionImpl.java
  ChartElementCommandImpl.java
  ChartPropertyDefinitionImpl.java
  ChartReportItemFactoryImpl.java
  ChartReportItemGenerationImpl.java
  ChartReportItemImpl.java
  ChartReportItemPresentationImpl.java
  ChartReportItemQueryImpl.java
  ChartReportStyleProcessor.java
  ChartSimplePropertyCommandImpl.java
  CompatibleExpressionUpdater.java
  QueryHelper.java