/*******************************************************************************
 * 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.item.crosstab.internal.ui.editors.model;

import org.eclipse.birt.report.designer.util.IVirtualValidator;
import org.eclipse.birt.report.item.crosstab.core.de.CrosstabCellHandle;
import org.eclipse.birt.report.item.crosstab.core.de.CrosstabReportItemHandle;
import org.eclipse.birt.report.item.crosstab.core.util.CrosstabUtil;
import org.eclipse.birt.report.model.api.olap.DimensionHandle;
import org.eclipse.birt.report.model.api.olap.MeasureHandle;

/**
 * The default cell adapter
 */
public class NormalCrosstabCellAdapter extends CrosstabCellAdapter implements IVirtualValidator
{

	/**
	 * Constructor
	 * 
	 * @param handle
	 */
	public NormalCrosstabCellAdapter( CrosstabCellHandle handle )
	{
		super( handle );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode( )
	{
		return getCrosstabItemHandle( ).hashCode( );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals( Object obj )
	{
//		if ( obj == getCrosstabItemHandle( ) )
//		{
//			return true;
//		}
//		if ( obj instanceof CrosstabCellAdapter )
//		{
//			return getCrosstabItemHandle( ) == ( (CrosstabCellAdapter) obj ).getCrosstabItemHandle( )
//			&& getPositionType( ) == ( (CrosstabCellAdapter) obj ).getPositionType( );
//		}
		return super.equals( obj );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.designer.util.IVirtualValidator#handleValidate(java.lang.Object)
	 */
	public boolean handleValidate( Object obj )
	{
		CrosstabReportItemHandle crosstab = getCrosstabCellHandle( ).getCrosstab( );
		if (obj instanceof DimensionHandle)
		{
			if ((getPositionType( ) .equals( ICrosstabCellAdapterFactory.CELL_LEVEL_HANDLE)
					||getPositionType( ) .equals( ICrosstabCellAdapterFactory.CELL_FIRST_LEVEL_HANDLE))
					&& CrosstabUtil.canContain( crosstab, (DimensionHandle )obj))
			{
				return true;
			}
		}

		if (obj instanceof MeasureHandle)
		{
			if (getPositionType( ).equals( ICrosstabCellAdapterFactory.CELL_MEASURE )
					&& CrosstabUtil.canContain( crosstab, (MeasureHandle )obj))
			{
				return true;
			}
		}
		return false;
	}
}

@@ -2060,16 +2060,206 @@
 bj )%0A%09%7B%0A
+%09%09if (obj instanceof Object%5B%5D)%0A%09%09%7B%0A%09%09%09Object%5B%5D objects = (Object%5B%5D)obj;%0A%09%09%09int len = objects.length;%0A%09%09%09if (len != 1)%0A%09%09%09%7B%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%09return handleValidate( objects%5B0%5D );%0A%09%09%7D%0A
 %09%09Crosst

fix validate array error