Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TopN/BottomN/Top%/Bottom % from filter options in xtab #379

Merged
merged 1 commit into from
Mar 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.birt.report.model.api.metadata.IPropertyType;
import org.eclipse.birt.report.model.api.metadata.IStructureDefn;
import org.eclipse.birt.report.model.api.olap.CubeHandle;
import org.eclipse.birt.report.model.metadata.ChoiceSet;

/**
* ChoiceSetFactory provides common interface to access all kinds of collection
Expand Down Expand Up @@ -196,11 +197,61 @@ public static IChoiceSet getDimensionChoiceSet( String elementName,
*/
public static IChoiceSet getStructChoiceSet( String structName,
String property )
{
return getStructChoiceSet( structName, property, false );
}

/**
* Gets the collection that given structure property value can selected from
* them.
* @param structName
* The name of the element.
* @param property
* DE Property key.
* @param removeNoSupportFilters
* indicate to shorter the choices excluding Top/Bottom N and others
* @return The ChoiceSet instance contains all the allowed values.
*/
public static IChoiceSet getStructChoiceSet( String structName,
String property , boolean removeNoSupportFilters )
{
IPropertyDefn propertyDefn = DEUtil.getMetaDataDictionary( )
.getStructure( structName )
.findProperty( property );
return propertyDefn.getAllowedChoices( );
IChoiceSet cs = propertyDefn.getAllowedChoices( );
if( removeNoSupportFilters )
{
return removeNoSupportedChoices( cs );
}
return cs;
}

private static IChoiceSet removeNoSupportedChoices( IChoiceSet cs )
{
if ( cs == null )
{
return null;
}
ArrayList<String> notSupportedList = new ArrayList<String>( );
notSupportedList.add( DesignChoiceConstants.FILTER_OPERATOR_TOP_N );
notSupportedList.add( DesignChoiceConstants.FILTER_OPERATOR_BOTTOM_N );
notSupportedList
.add( DesignChoiceConstants.FILTER_OPERATOR_TOP_PERCENT );
notSupportedList
.add( DesignChoiceConstants.FILTER_OPERATOR_BOTTOM_PERCENT );
IChoice[] choiceList = cs.getChoices( );
ArrayList<IChoice> newChoiceList = new ArrayList<IChoice>( );
for ( int i = 0; i < choiceList.length; i++ )
{
if ( !notSupportedList.contains( choiceList[i].getName( ) ) )
{
newChoiceList.add( choiceList[i] );
}
}
ChoiceSet newcs = new ChoiceSet( cs.getName( ) );
newcs.setChoices(
newChoiceList.toArray( new IChoice[newChoiceList.size( )] ) );
return newcs;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public class CrosstabFilterConditionBuilder extends BaseTitleAreaDialog
static
{
IChoiceSet chset = ChoiceSetFactory.getStructChoiceSet( FilterCondition.FILTER_COND_STRUCT,
FilterCondition.OPERATOR_MEMBER );
FilterCondition.OPERATOR_MEMBER, true );
IChoice[] chs = chset.getChoices( new AlphabeticallyComparator( ) );
OPERATOR = new String[chs.length][2];

Expand Down