Skip to content

Commit

Permalink
Provide utility class to parse expressions and find out if they use d…
Browse files Browse the repository at this point in the history
…ataSetRow.

Signed-off-by: Carl Thronson <cthronson@actuate.com>
  • Loading branch information
Carl Thronson committed Dec 9, 2015
1 parent fc9d0f0 commit b40bee0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.eclipse.birt.chart.util.ChartExpressionUtil.ExpressionCodec;
import org.eclipse.birt.chart.util.ChartUtil;
import org.eclipse.birt.chart.util.PluginSettings;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.ui.frameworks.taskwizard.WizardBase;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -1070,11 +1071,25 @@ private void enableAggEditor( String expression )
{
if ( expression != null && fAggEditorComposite != null )
{
boolean isMeasure = expression.startsWith( "data" ); //$NON-NLS-1$
fAggEditorComposite.setEnabled( !isMeasure );
try
{
ExpressionCodec ec = ChartModelHelper.instance( ).createExpressionCodec( );
ec.decode( expression );
expression = ec.convertJSExpression( false );

boolean enabled = this.context.getUIFactory( )
.createUIHelper( )
.useDataSetRow( context.getExtendedItem( ), expression );
fAggEditorComposite.setEnabled( enabled );
}
catch ( BirtException e )
{
WizardBase.displayException( e );
}

}
}

public void updateLabel( )
{
lblDesc.setText( description );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.birt.chart.ui.swt.interfaces.IChartType;
import org.eclipse.birt.chart.ui.swt.interfaces.IChartUIHelper;
import org.eclipse.birt.chart.ui.swt.wizard.ChartWizardContext;
import org.eclipse.birt.core.exception.BirtException;

/**
* Default implementation or base class of UI helper interface.
Expand Down Expand Up @@ -43,4 +44,10 @@ public boolean canCombine( IChartType type, ChartWizardContext context )
return type.canCombine( );
}

@Override
public boolean useDataSetRow( Object reportItem, String expression ) throws BirtException
{
// Default implementation, do nothing
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.ui.swt.wizard.ChartWizardContext;
import org.eclipse.birt.core.exception.BirtException;

/**
* UI helper used to help chart UI customize composites in it.
Expand Down Expand Up @@ -58,4 +59,14 @@ public interface IChartUIHelper
* @since 3.7
*/
boolean canCombine( IChartType type, ChartWizardContext context );

/**
* Return true if expression uses binding that contains data set row directly or indirectly
*
* @param reportItem
* @param expression
*
* @throws BirtException
*/
boolean useDataSetRow(Object reportItem, String expression) throws BirtException;
}

0 comments on commit b40bee0

Please sign in to comment.