/*******************************************************************************
 * 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.designer.ui.views.attributes.providers.AttributeConstant;
import org.eclipse.birt.report.model.api.ColumnHandle;
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.widgets.Composite;

/**
 * The general attribute page of Column element.
 */
public class ColumnPage extends AttributePage
{

	/**
	 * Constructor
	 * 
	 * @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 ColumnPage( Composite parent, int style )
	{
		super( parent, style );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.designer.internal.ui.views.attributes.page.AttributePage#buildUI(java.util.List)
	 */
	protected void buildUI( )
	{
		setLayout( WidgetUtil.createGridLayout( 5 ) );

		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.COLUMN_ELEMENT,
				ColumnHandle.WIDTH_PROP,
				1,
				false );
		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				AttributeConstant.HORIZONTAL_ALIGN,
				1,
				false );
		propertiesMap.put( StyleHandle.TEXT_ALIGN_PROP,
				propertiesMap.get( AttributeConstant.HORIZONTAL_ALIGN ) );

		WidgetUtil.createGridPlaceholder( this, 1, true );

		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.BACKGROUND_COLOR_PROP,
				1,
				false );

		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.STYLE_ELEMENT,
				StyleHandle.VERTICAL_ALIGN_PROP,
				1,
				false );

		WidgetUtil.createGridPlaceholder( this, 1, true );

		WidgetUtil.createHorizontalLine( this, 5 );

		WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.COLUMN_ELEMENT,
				ReportItemHandle.STYLE_PROP,
				1,
				false );

		// Suppress duplicates
		IPropertyDescriptor checkBoxesDescriptor = PropertyDescriptorFactory.getPropertyDescriptor( ReportDesignConstants.COLUMN_ELEMENT,
				ColumnHandle.SUPPRESS_DUPLICATES_PROP );
		propertiesMap.put( ColumnHandle.SUPPRESS_DUPLICATES_PROP,
				checkBoxesDescriptor );

		checkBoxesDescriptor.createControl( this );
	}
}