RunTimeContext rtc = new RunTimeContext( ); rtc.setScriptClassLoader( iscl );   final Chart cmRunTime = (Chart) EcoreUtil.copy( model ); rtc.setLocale( Locale.getDefault( ) );  ChartScriptContext csc = new ChartScriptContext( ); csc.setChartInstance( cmRunTime ); csc.setExternalContext( externalContext ); csc.setLocale( rtc.getLocale( ) ); csc.setLogger( logger ); rtc.setScriptContext( csc );  ScriptHandler sh = new ScriptHandler( ); rtc.setScriptHandler( sh );  sh.setScriptClassLoader( iscl );   try { if ( externalContext != null && externalContext.getScriptable( ) != null ) { sh.init( externalContext.getScriptable( ) ); } else { sh.init( null ); } sh.setRunTimeModel( cmRunTime );  final String sScriptContent = cmRunTime.getScript( ); if ( sScriptContent != null ) { sh.register( sScriptContent ); } } catch ( ChartException sx ) { throw new ChartException( ChartEnginePlugin.ID, ChartException.GENERATION, sx ); }      return rtc;
return prepare( model, externalContext, iscl, ULocale.forLocale( locale ) );
	public RunTimeContext prepare( Chart model,			IExternalContext externalContext, IScriptClassLoader iscl,			Locale locale ) throws ChartException	{		RunTimeContext rtc = new RunTimeContext( );		rtc.setScriptClassLoader( iscl );		// Update the context with a locale if it is undefined.		final Chart cmRunTime = (Chart) EcoreUtil.copy( model );		rtc.setLocale( Locale.getDefault( ) );		ChartScriptContext csc = new ChartScriptContext( );		csc.setChartInstance( cmRunTime );		csc.setExternalContext( externalContext );		csc.setLocale( rtc.getLocale( ) );		csc.setLogger( logger );		rtc.setScriptContext( csc );		ScriptHandler sh = new ScriptHandler( );		rtc.setScriptHandler( sh );		sh.setScriptClassLoader( iscl );		// initialize scripthandler.		try		{			if ( externalContext != null					&& externalContext.getScriptable( ) != null )			{				sh.init( externalContext.getScriptable( ) );			}			else			{				sh.init( null );			}			sh.setRunTimeModel( cmRunTime );			final String sScriptContent = cmRunTime.getScript( );			if ( sScriptContent != null )			{				sh.register( sScriptContent );			}		}		catch ( ChartException sx )		{			throw new ChartException( ChartEnginePlugin.ID,					ChartException.GENERATION,					sx );		}		// Call the onPrepare script event function.		// not supported yet		/*		 * ScriptHandler.callFunction( sh, ScriptHandler.ON_PREPARE, cmRunTime,		 * rtc.getScriptContext( ) );		 */		return rtc;	}