/*******************************************************************************
 * 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.report.designer.internal.ui.dialogs;

import org.eclipse.birt.report.designer.internal.ui.editors.parts.DeferredGraphicalViewer;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.GraphicalPartFactory;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ReportRootEditPart;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;

/**
 * Support the draw the Report viewer to the composite. 
 */
public class ReportGraphicsViewComposite extends GraphicsViewComposite
{

	//Bacause the report editpart is defered refresh, so it need a refresh manager.It will be deleted in the future?
	//private DeferredRefreshManager refreshManger;

	/**
	 * @param parent
	 * @param style
	 * @param contents
	 */
	public ReportGraphicsViewComposite( Composite parent, int style, Object contents )
	{
		super( parent, style, contents );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.designer.internal.ui.dialogs.GraphicsViewComposite#createGraphicalViewer()
	 */
	protected GraphicalViewer createGraphicalViewer( )
	{
		return new DeferredGraphicalViewer();
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.designer.internal.ui.dialogs.GraphicsViewComposite#configGraphicalViewer(org.eclipse.gef.GraphicalViewer)
	 */
	protected void configGraphicalViewer(GraphicalViewer viewer)
	{
		DeferredGraphicalViewer reportViewer = (DeferredGraphicalViewer)viewer;
		//reportViewer.hookRefreshListener( getRefreshManager( ) );
		Shell shell = new Shell( );
		reportViewer.createControl( shell );
		reportViewer.setEditDomain( new DefaultEditDomain( null ) );
		reportViewer.setRootEditPart( new ReportRootEditPart( ) );
		reportViewer.setEditPartFactory( new GraphicalPartFactory( ) );
		reportViewer.setContents( getDrawContents( ) );
		reportViewer.flush( );
	}
	
	

}
