Skip to content

Commit

Permalink
- Summary:Support the crosstab multiple cell.
Browse files Browse the repository at this point in the history
 

- Bugzilla Bug (s) Resolved:

 

- Description: 

- Project ID:

- Tests Description  : 

Manual test

 

- Notes to Build Team: 

None

 

- Notes to Developers: 

None

 

- Notes to QA:  

None

 

- Notes to Documentation:  

None

 

- Files Edited:



 

- Files Added:



 

- Files Deleted:
  • Loading branch information
dgao committed Mar 20, 2012
1 parent 9e3b258 commit 2c509f9
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
import org.eclipse.birt.report.model.api.LibraryHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportItemHandle;
import org.eclipse.birt.report.model.api.activity.NotificationEvent;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.api.command.PropertyEvent;
import org.eclipse.birt.report.model.api.core.Listener;
import org.eclipse.birt.report.model.api.extension.CompatibilityStatus;
import org.eclipse.birt.report.model.api.extension.ExtendedElementException;
import org.eclipse.birt.report.model.api.metadata.DimensionValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.birt.core.data.ExpressionUtil;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.data.engine.api.aggregation.AggregationManager;
import org.eclipse.birt.data.engine.script.DataRow;
import org.eclipse.birt.report.data.adapter.api.DataAdapterUtil;
import org.eclipse.birt.report.data.adapter.api.DataRequestSession;
import org.eclipse.birt.report.data.adapter.api.DataSessionContext;
Expand All @@ -41,7 +40,6 @@
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.ExtendedItemHandle;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportItemHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
Expand Down Expand Up @@ -1563,6 +1561,9 @@ public static int computeAllMeasureHeaderCount(
}

// add support multiple header
/**Validate the crosstab header cell
* @param crosstab
*/
public static void validateCrosstabHeader( CrosstabReportItemHandle crosstab )
{
int headerCellCount = crosstab.getHeaderCount( );
Expand Down Expand Up @@ -1593,24 +1594,6 @@ public static void validateCrosstabHeader( CrosstabReportItemHandle crosstab )
}
else if ( columnLevelList.size( ) == 0 && rowLevelList.size( ) > 0 )
{
for ( int i = 0; i < headerCellCount; i++ )
{
CrosstabCellHandle temp = crosstab.getHeader( i );
LabelHandle labelHandle = crosstab.getModuleHandle( )
.getElementFactory( )
.newLabel( null );
try
{
labelHandle.setText( rowLevelList.get( i )
.getCubeLevel( )
.getName( ) );
temp.addContent( labelHandle );
}
catch ( SemanticException e )
{
// Do nothing
}
}
if ( headerCellCount < rowSize )
{
for ( int i = 0; i < rowSize - headerCellCount; i++ )
Expand Down Expand Up @@ -1669,17 +1652,35 @@ public static List<LevelViewHandle> getLevelList(

// pos < 0 means , is n't add or remove lever cause the update header cell,
// (hide measer header cell)
/**Update the header cell
* @param crosstab
* @param pos
* @param axisType
*/
public static void updateHeaderCell( CrosstabReportItemHandle crosstab,
int pos, int axisType )
{
updateHeaderCell( crosstab, pos, axisType, false );
updateHeaderCell( crosstab, pos, axisType, false, 0);
}

public static void updateHeaderCell( CrosstabReportItemHandle crosstab,
int pos, int axisType, boolean isMoveDimension )
int pos, int axisType, boolean isMoveDimension, int adjustCount )
{

HeaderData data = caleHeaderData( crosstab );

if (isMoveDimension)
{
if ( ICrosstabConstants.COLUMN_AXIS_TYPE == axisType )
{
data.rowNumber = data.rowNumber - adjustCount;
}
else
{
data.columnNumber = data.columnNumber - adjustCount;
}
}

int total = data.rowNumber * data.columnNumber;

PropertyHandle headerHandle = crosstab.getModelHandle( )
Expand Down Expand Up @@ -1749,7 +1750,7 @@ else if ( pos == -2
axisType = ICrosstabConstants.COLUMN_AXIS_TYPE;
}
}

boolean isAdd = total - crosstab.getHeaderCount( ) > 0;
if ( !isMoveDimension && !needUpdateHeaderCell( crosstab, isAdd ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import org.eclipse.birt.report.model.api.olap.DimensionHandle;
import org.eclipse.birt.report.model.api.olap.LevelHandle;

import com.ibm.icu.util.TaiwanCalendar;

/**
* CrosstabReportItemTask
*/
Expand Down Expand Up @@ -755,7 +753,8 @@ private void moveDimension( DimensionViewHandle dimensionView,
int pos = CrosstabModelUtil.findPreLevelCount( clonedDimensionView );
for (int i=0; i<clonedDimensionView.getLevelCount( ); i++)
{
CrosstabModelUtil.updateHeaderCell( clonedDimensionView.getCrosstab( ), pos + i, clonedDimensionView.getAxisType( ), true );
CrosstabModelUtil.updateHeaderCell( clonedDimensionView.getCrosstab( ), pos + i,
clonedDimensionView.getAxisType( ), true, clonedDimensionView.getLevelCount( ) - i - 1 );
}
}
catch ( SemanticException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.birt.report.item.crosstab.core.ICrosstabConstants;
import org.eclipse.birt.report.item.crosstab.core.ICrosstabReportItemConstants;
import org.eclipse.birt.report.item.crosstab.core.de.AggregationCellHandle;
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.de.DimensionViewHandle;
import org.eclipse.birt.report.item.crosstab.core.de.LevelViewHandle;
Expand All @@ -41,7 +40,6 @@
import org.eclipse.birt.report.model.api.ComputedColumnHandle;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.ExtendedItemHandle;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.ModuleHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
Expand Down Expand Up @@ -605,6 +603,9 @@ public static DimensionViewHandle getDimensionViewHandle(

}
//Support multiple header cell
/**Merge all header cell
* @param crosstab
*/
public static void mergeHeaderCell(CrosstabReportItemHandle crosstab)
{
int count = crosstab.getHeaderCount( );
Expand All @@ -627,6 +628,9 @@ public static void mergeHeaderCell(CrosstabReportItemHandle crosstab)
}
}

/**Splite the header cell
* @param crosstab
*/
public static void spliteHeaderCell(CrosstabReportItemHandle crosstab)
{
int[] numbers = CrosstabModelUtil.getHeaderRowAndColumnNumber( crosstab );
Expand Down
5 changes: 5 additions & 0 deletions xtab/org.eclipse.birt.report.item.crosstab.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@
forcePluginActivation="true"
property="CrosstabPropertyHandleWrapper.type"
value="measures" />
<test
forcePluginActivation="true"
property="CrosstabPropertyHandleWrapper.type"
value="crosstabHeader">
</test>
</or>
</enablement>
</adapter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ protected void buildShowMenu( IMenuManager menu,

}

private void createCrosstabHeaderCellMenu(IMenuManager menu, Object firstSelectedObj,
IContributionItem beforeThis)
{

}
private void createLevelMenu( IMenuManager menu, Object firstSelectedObj,
IContributionItem beforeThis )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ public void execute( )
List newAction = ModelUtil.cloneStructList( source );
dataHandle.setAction( (Action) newAction.get( 0 ) );
}

CrosstabAdaptUtil.addLabelToHeader( levelViewHandle );
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ else if (DesignChoiceConstants.COLUMN_DATA_TYPE_STRING.equals( type ))
}
}

/**Add all the label to the header cell
* @param reportHandle
*/
public static void addAllHeaderLabel(CrosstabReportItemHandle reportHandle)
{
for (int i=0; i<reportHandle.getDimensionCount( ICrosstabConstants.ROW_AXIS_TYPE ); i++)
Expand All @@ -690,6 +693,9 @@ public static void addAllHeaderLabel(CrosstabReportItemHandle reportHandle)
}
}

/**Add the label to the header cell.
* @param levelHandle
*/
public static void addLabelToHeader(LevelViewHandle levelHandle)
{
if (ICrosstabConstants.COLUMN_AXIS_TYPE == levelHandle.getAxisType( ))
Expand Down Expand Up @@ -722,6 +728,10 @@ public static void addLabelToHeader(LevelViewHandle levelHandle)
}
}

/**If merge crosstab header cell.
* @param crosstab
* @return
*/
public static boolean canMergeCrosstabHeaderCell(CrosstabReportItemHandle crosstab)
{
//int[] numbers = CrosstabModelUtil.getHeaderRowAndColumnNumber( crosstab );
Expand All @@ -733,6 +743,10 @@ public static boolean canMergeCrosstabHeaderCell(CrosstabReportItemHandle crosst
return false;
}

/**If splite the crosstab header cell
* @param crosstab
* @return
*/
public static boolean canSpliteCrosstabHeaderCell(CrosstabReportItemHandle crosstab)
{
int[] numbers = CrosstabModelUtil.getHeaderRowAndColumnNumber( crosstab );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public Object[] getChildren( Object model )
List measures = (List) value;
return measures.toArray( );
}
if (propertyName.equals( ICrosstabReportItemConstants.HEADER_PROP ))
{
return handle.getContents( ).toArray( );
}
return new Object[0];
}

Expand Down Expand Up @@ -78,6 +82,8 @@ public String getNodeDisplayName( Object element )
return Messages.getString("AreaNodeProvider.RowArea"); //$NON-NLS-1$
if ( propertyName.equals( ICrosstabReportItemConstants.MEASURES_PROP ) )
return Messages.getString("AreaNodeProvider.DetailArea"); //$NON-NLS-1$
if ( propertyName.equals( ICrosstabReportItemConstants.HEADER_PROP ) )
return "Headers"; //$NON-NLS-1$

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ public Object[] getChildren( Object model )
try
{
CrosstabReportItemHandle crossTab = (CrosstabReportItemHandle) crossTabHandle.getReportItem( );
// if ( crossTab.getHeader( ) != null )
// list.add( crossTab.getHeader( ).getModelHandle( ) );
for (int i=0; i<crossTab.getHeaderCount( ); i++)
{
list.add( crossTab.getHeader( i ).getModelHandle( ) );
}
CrosstabPropertyHandleWrapper headerWrap = new CrosstabPropertyHandleWrapper( crossTabHandle.getPropertyHandle( ICrosstabReportItemConstants.HEADER_PROP ) );
headerWrap.setTestType( "crosstabHeader" );
list.add( headerWrap );
if ( crossTab.getCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE ) != null )
list.add( crossTab.getCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE )
.getModelHandle( ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class CrosstabPropertyHandleWrapper implements IAdaptable
{

private PropertyHandle handle;
private String type;

public Object getAdapter( Class adapter )
{
Expand All @@ -36,6 +37,19 @@ public Object getAdapter( Class adapter )
}
return null;
}

public void setTestType(String testType)
{
this.type = testType;
}
public String getTestType()
{
if (type == null)
{
return getModel( ).getPropertyDefn( ).getName( );
}
return type;
}

public CrosstabPropertyHandleWrapper( PropertyHandle handle )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public boolean test( Object receiver, String property, Object[] args,
if ( receiver instanceof CrosstabPropertyHandleWrapper )
{
String propertyName = expectedValue.toString( );
return propertyName.equals( ( ( (CrosstabPropertyHandleWrapper) receiver ).getModel( ) ).getPropertyDefn( )
.getName( ) );
return propertyName.equals( ( ( (CrosstabPropertyHandleWrapper) receiver ).getTestType( ) ));

}
}
Expand Down

0 comments on commit 2c509f9

Please sign in to comment.