/*******************************************************************************
 * 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.dialogs;

import org.eclipse.birt.report.designer.ui.dialogs.ExpressionProvider;
import org.eclipse.birt.report.designer.ui.expressions.ExpressionFilter;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.elements.interfaces.ICubeModel;
import org.eclipse.core.runtime.IAdaptable;

/**
 * 
 */

public class CrosstabComputedMeasureExpressionProvider extends
		CrosstabExpressionProvider
{

	public CrosstabComputedMeasureExpressionProvider( DesignElementHandle handle )
	{
		super( handle, null );
	}

	protected void addFilterToProvider( )
	{
		this.addFilter( new ExpressionFilter( ) {

			public boolean select( Object parentElement, Object element )
			{
				if ( ExpressionFilter.CATEGORY.equals( parentElement )
						&& ExpressionProvider.CURRENT_CUBE.equals( element ) )
				{
					// return false;
				}
				if ( CURRENT_CUBE.equals( parentElement ) )
				{
					PropertyHandle handle = null;
					if ( element instanceof PropertyHandle )
						handle = (PropertyHandle) element;
					else if ( element instanceof IAdaptable
							&& ( (IAdaptable) element ).getAdapter( PropertyHandle.class ) instanceof PropertyHandle )
						handle = (PropertyHandle) ( (IAdaptable) element ).getAdapter( PropertyHandle.class );

					if ( handle != null
							&& handle.getPropertyDefn( )
									.getName( )
									.equals( ICubeModel.MEASURE_GROUPS_PROP ) )
					{
						return true;
					}
					return false;
				}
				return true;
			}
		} );
	}

}

@@ -1189,16 +1189,18 @@
  );%0A%09%7D%0A%0A
+//
 %09protect
@@ -1230,19 +1230,23 @@
 ider( )%0A
+//
 %09%7B%0A
+//
 %09%09this.a
@@ -1281,17 +1281,21 @@
 er( ) %7B%0A
-%0A
+//%0A//
 %09%09%09publi
@@ -1351,21 +1351,25 @@
 ement )%0A
+//
 %09%09%09%7B%0A
+//
 %09%09%09%09if (
@@ -1419,16 +1419,18 @@
 ement )%0A
+//
 %09%09%09%09%09%09&&
@@ -1478,30 +1478,34 @@
 element ) )%0A
+//
 %09%09%09%09%7B%0A
+//
 %09%09%09%09%09// retu
@@ -1510,30 +1510,34 @@
 turn false;%0A
+//
 %09%09%09%09%7D%0A
+//
 %09%09%09%09if ( CUR
@@ -1572,22 +1572,26 @@
 ent ) )%0A
+//
 %09%09%09%09%7B%0A
+//
 %09%09%09%09%09Pro
@@ -1617,16 +1617,18 @@
 = null;%0A
+//
 %09%09%09%09%09if 
@@ -1657,32 +1657,34 @@
 ropertyHandle )%0A
+//
 %09%09%09%09%09%09handle = (
@@ -1708,16 +1708,18 @@
 lement;%0A
+//
 %09%09%09%09%09els
@@ -1755,16 +1755,18 @@
 aptable%0A
+//
 %09%09%09%09%09%09%09&
@@ -1855,16 +1855,18 @@
 andle )%0A
+//
 %09%09%09%09%09%09ha
@@ -1950,17 +1950,21 @@
 lass );%0A
-%0A
+//%0A//
 %09%09%09%09%09if 
@@ -1980,16 +1980,18 @@
 != null%0A
+//
 %09%09%09%09%09%09%09&
@@ -2014,24 +2014,26 @@
 ertyDefn( )%0A
+//
 %09%09%09%09%09%09%09%09%09.ge
@@ -2041,16 +2041,18 @@
 Name( )%0A
+//
 %09%09%09%09%09%09%09%09
@@ -2100,15 +2100,19 @@
 ) )%0A
+//
 %09%09%09%09%09%7B%0A
+//
 %09%09%09%09
@@ -2130,15 +2130,19 @@
 ue;%0A
+//
 %09%09%09%09%09%7D%0A
+//
 %09%09%09%09
@@ -2156,22 +2156,26 @@
  false;%0A
+//
 %09%09%09%09%7D%0A
+//
 %09%09%09%09retu
@@ -2187,20 +2187,26 @@
 ue;%0A
+//
 %09%09%09%7D%0A
+//
 %09%09%7D );%0A
+//
 %09%7D%0A%0A

Remove the restriction on cube element on the expression builder when creating a derived measure.