/*******************************************************************************
 * 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.views.attributes.page;

import org.eclipse.birt.report.designer.internal.ui.views.attributes.widget.PropertyDescriptorFactory;
import org.eclipse.birt.report.designer.ui.views.attributes.IPropertyDescriptor;
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.ReportItemHandle;
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

/**
 * The general attribute page of DataItem element.
 */
public class DataPage extends GeneralPage
{

	/**
	 * @param parent
	 *            A widget which will be the parent of the new instance (cannot
	 *            be null)
	 * @param style
	 *            The style of widget to construct
	 */
	public DataPage( Composite parent, int style )
	{
		super( parent, style );
	}

//	/*
//	 * (non-Javadoc)
//	 * 
//	 * @see org.eclipse.birt.report.designer.internal.ui.views.attributes.page.AttributePage#buildUI()
//	 */
//	protected void buildUI( )
//	{
//		setLayout( WidgetUtil.createGridLayout( 6 ) );
//
//		WidgetUtil.buildGridControl( this,
//				propertiesMap,
//				ReportDesignConstants.DATA_ITEM,
//				DataItemHandle.NAME_PROP,
//				2,
//				false );
//		
//		WidgetUtil.createHorizontalLine(this,6);
//		
//		WidgetUtil.buildGridControl( this,
//				propertiesMap,
//				ReportDesignConstants.STYLE_ELEMENT,
//				StyleHandle.FONT_FAMILY_PROP,
//				1,
//				false );
//
//		WidgetUtil.buildGridControl( this,
//				propertiesMap,
//				ReportDesignConstants.STYLE_ELEMENT,
//				StyleHandle.FONT_SIZE_PROP,
//				1,
//				false );
//
//		WidgetUtil.createGridPlaceholder( this, 2, true );
//		
//		WidgetUtil.buildGridControl( this,
//				propertiesMap,
//				ReportDesignConstants.STYLE_ELEMENT,
//				StyleHandle.COLOR_PROP,
//				1,
//				false );
//
//		WidgetUtil.buildGridControl( this,
//				propertiesMap,
//				ReportDesignConstants.STYLE_ELEMENT,
//				StyleHandle.BACKGROUND_COLOR_PROP,
//				1,
//				false );
//		
//		WidgetUtil.createGridPlaceholder( this, 2, true );
//
//		WidgetUtil.createGridPlaceholder( this, 1, false );
//		Composite container = WidgetUtil.buildFontStyleUI( this, propertiesMap );
//		GridData data = new GridData( );
//		data.horizontalSpan = 3;
//		container.setLayoutData( data );
//
//		int height = container.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
//		Label separator = new Label( container, SWT.SEPARATOR
//				| SWT.VERTICAL
//				| SWT.CENTER );
//		int width = separator.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x
//				+ WidgetUtil.SPACING
//				* 2;
//		separator.setLayoutData( new RowData( width, height ) );
//
//		IPropertyDescriptor descriptor = PropertyDescriptorFactory.getPropertyDescriptor( ReportDesignConstants.STYLE_ELEMENT,
//				StyleHandle.TEXT_ALIGN_PROP );
//		propertiesMap.put( StyleHandle.TEXT_ALIGN_PROP, descriptor );
//		descriptor.createControl( container );
//
//
//		
//		WidgetUtil.createHorizontalLine( this, 6 );
//
//		WidgetUtil.buildGridControl( this,
//				propertiesMap,
//				ReportDesignConstants.REPORT_ITEM,
//				ReportItemHandle.STYLE_PROP,
//				1,
//				false );
//	}
	
	protected void buildUI( )
	{
		setContentLayout( WidgetUtil.createGridLayout( 6 ) );
		super.buildUI( );
	}
	


	void buildContent( Composite content )
	{
		
		WidgetUtil.buildGridControl( content,
				propertiesMap,
				ReportDesignConstants.DATA_ITEM,
				DataItemHandle.NAME_PROP,
				1,
				false );

		WidgetUtil.createHorizontalLine( content, 6 );
		
		WidgetUtil.buildGridControl( content,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.FONT_FAMILY_PROP,
				1,
				false );

		WidgetUtil.buildGridControl( content,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.FONT_SIZE_PROP,
				1,
				false );

		WidgetUtil.createGridPlaceholder( content, 2, true );
		
		WidgetUtil.buildGridControl( content,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.COLOR_PROP,
				1,
				false );

		WidgetUtil.buildGridControl( content,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.BACKGROUND_COLOR_PROP,
				1,
				false );
		
		WidgetUtil.createGridPlaceholder( content, 2, true );

		WidgetUtil.createGridPlaceholder( content, 1, false );
		Composite container = WidgetUtil.buildFontStyleUI( content, propertiesMap );
		GridData data = new GridData( );
		data.horizontalSpan = 3;
		container.setLayoutData( data );

		int height = container.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y;
		Label separator = new Label( container, SWT.SEPARATOR
				| SWT.VERTICAL
				| SWT.CENTER );
		int width = separator.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x
				+ WidgetUtil.SPACING
				* 2;
		separator.setLayoutData( new RowData( width, height ) );

		IPropertyDescriptor descriptor = PropertyDescriptorFactory.getPropertyDescriptor( ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.TEXT_ALIGN_PROP );
		propertiesMap.put( StyleHandle.TEXT_ALIGN_PROP, descriptor );
		descriptor.createControl( container );


		
		WidgetUtil.createHorizontalLine( content, 6 );

		WidgetUtil.buildGridControl( content,
				propertiesMap,
				ReportDesignConstants.REPORT_ITEM,
				ReportItemHandle.STYLE_PROP,
				1,
				false );

	}


}