context.setExtendedItem( eih ); context.setProcessor( new ChartReportStyleProcessor( eih, false ) ); context = (ChartWizardContext) chartBuilder.open( null, taskId, context ); if ( context != null && context.getModel( ) != null ) {  eih.setProperty( "outputFormat", context.getOutputFormat( ) );     crii.executeSetModelCommand( eih, cm, context.getModel( ) );  try { final Bounds bo = context.getModel( ) .getBlock( ) .getBounds( );   NumberFormat nf = ChartUIUtil.getDefaultNumberFormatInstance( );  if ( eih.getWidth( ).getStringValue( ) == null ) { eih.setWidth( nf.format( bo.getWidth( ) ) + "pt" ); } if ( eih.getHeight( ).getStringValue( ) == null ) { eih.setHeight( nf.format( bo.getHeight( ) ) + "pt" ); } } catch ( SemanticException smx ) { logger.log( smx ); }  if ( crii.getDesignerRepresentation( ) != null ) { ( (DesignerRepresentation) crii.getDesignerRepresentation( ) ).setDirty( true ); }  iInstanceCount--;    this.extendedHandle = null;  return Window.OK; }
else context.setOutputFormat( (String) of );
	public int open( ExtendedItemHandle eih )	{		if ( iInstanceCount > 0 ) // LIMIT TO ONE INSTANCE		{			return Window.CANCEL;		}		iInstanceCount++;		try		{			IReportItem item = null;			try			{				item = eih.getReportItem( );				if ( item == null )				{					eih.loadExtendedElement( );					item = eih.getReportItem( );				}			}			catch ( ExtendedElementException exception )			{				logger.log( exception );			}			if ( item == null )			{				logger.log( ILogger.ERROR,						Messages.getString( "ChartReportItemBuilderImpl.log.UnableToLocate" ) ); //$NON-NLS-1$				iInstanceCount--;				return Window.CANCEL;			}			final ChartReportItemImpl crii = ( (ChartReportItemImpl) item );			final Chart cm = (Chart) crii.getProperty( "chart.instance" ); //$NON-NLS-1$			final Chart cmClone = ( cm == null ) ? null					: (Chart) EcoreUtil.copy( cm );			// Set the ExtendedItemHandle instance (for use by the Chart Builder			// UI			this.extendedHandle = eih;			{				// Use workbench shell to open the dialog				Shell parentShell = null;				if ( PlatformUI.isWorkbenchRunning( ) )				{					parentShell = PlatformUI.getWorkbench( )							.getDisplay( )							.getActiveShell( );				}				ChartWizard chartBuilder = new ChartWizard( parentShell );				ChartWizardContext context = new ChartWizardContext( cmClone );				context.setUIServiceProvider( this );				context.setDataServiceProvider( new ReportDataServiceProvider( eih ) );				context.setRtL( ReportItemUIUtil.isRtl( ) );				Object of = eih.getProperty( "outputFormat" ); //$NON-NLS-1$				if ( of instanceof String )				{					// GIF is deprecated in favor of PNG. Automatically update					// model					if ( of.equals( "GIF" ) ) //$NON-NLS-1$					{						context.setOutputFormat( "PNG" ); //$NON-NLS-1$					}					else						context.setOutputFormat( (String) of );				}				context.setExtendedItem( eih );				context.setProcessor( new ChartReportStyleProcessor( eih, false ) );				context = (ChartWizardContext) chartBuilder.open( null,						taskId,						context );				if ( context != null && context.getModel( ) != null )				{					// update the output format property information.					eih.setProperty( "outputFormat", context.getOutputFormat( ) ); //$NON-NLS-1$					// TODO: Added till the model team sorts out pass-through					// for					// setProperty					crii.executeSetModelCommand( eih, cm, context.getModel( ) );					try					{						final Bounds bo = context.getModel( )								.getBlock( )								.getBounds( );						// Modified to fix Bugzilla #99331						NumberFormat nf = ChartUIUtil.getDefaultNumberFormatInstance( );						if ( eih.getWidth( ).getStringValue( ) == null )						{							eih.setWidth( nf.format( bo.getWidth( ) ) + "pt" ); //$NON-NLS-1$						}						if ( eih.getHeight( ).getStringValue( ) == null )						{							eih.setHeight( nf.format( bo.getHeight( ) ) + "pt" ); //$NON-NLS-1$						}					}					catch ( SemanticException smx )					{						logger.log( smx );					}					if ( crii.getDesignerRepresentation( ) != null )					{						( (DesignerRepresentation) crii.getDesignerRepresentation( ) ).setDirty( true );					}					iInstanceCount--;					// Reset the ExtendedItemHandle instance since it is no					// longer					// needed					this.extendedHandle = null;					return Window.OK;				}			}			iInstanceCount--;			// Reset the ExtendedItemHandle instance since it is no longer			// needed			this.extendedHandle = null;			return Window.CANCEL;		}		catch ( Exception e )		{			iInstanceCount--;			throw new RuntimeException( e );		}	}