/*******************************************************************************
 * 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 java.util.Set;

import org.eclipse.birt.report.model.api.GroupElementFactory;
import org.eclipse.birt.report.model.api.GroupPropertyHandle;
import org.eclipse.birt.report.model.api.ReportElementHandle;
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.birt.report.model.elements.interfaces.IReportItemModel;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

/**
 * Bookmark expreesion page.
 * 
 */
public class BookMarkExpressionPage extends AttributePage
{

	private Composite bookmarkArea;

	/**
	 * Contructor
	 */
	public BookMarkExpressionPage( 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( 1 ) );

		bookmarkArea = (Composite) WidgetUtil.buildGridControl( this,
				propertiesMap,
				ReportDesignConstants.REPORT_ITEM,
				IReportItemModel.BOOKMARK_PROP,
				1,
				true );
		GridData gd = new GridData(GridData.FILL_VERTICAL);
		gd.widthHint = 500;

		bookmarkArea.setLayoutData( gd);

	}

	protected void refreshValues( Set propertiesSet )
	{
		if ( input.size( ) > 0 )
		{
			ReportElementHandle handle = (ReportElementHandle) input.get( 0 );
			GroupPropertyHandle propertyHandle = GroupElementFactory.newGroupElement( handle.getModuleHandle( ),
					input )
					.getPropertyHandle( IReportItemModel.BOOKMARK_PROP );
			Control[] children = bookmarkArea.getChildren( );
			for ( int i = 0; i < children.length; i++ )
			{
				children[i].setEnabled( !propertyHandle.isReadOnly( ) );
			}
		}
		super.refreshValues( propertiesSet );
	}

}
