} DataItemHandle dataItemHandle = factory.newDataItem( null ); dataItemHandle.setValueExpr( groupHandle.getKeyExpr( ) ); if ( parent instanceof ListHandle ) { groupHandle.getHeader( ).add( dataItemHandle ); } else if ( parent instanceof TableHandle ) { if ( groupHandle.getHeader( ).getCount( ) != 0 ) { RowHandle rowHandle = ( (RowHandle) groupHandle.getHeader( ) .get( 0 ) ); CellHandle cellHandle = (CellHandle) rowHandle.getCells( ) .get( 0 ); cellHandle.getContent( ).add( dataItemHandle ); } }
}
	private static boolean addGroup( DesignElementHandle parent, int position )			throws SemanticException	{		GroupHandle groupHandle = null;		SlotHandle slotHandle = null;		ElementFactory factory = parent.getElementFactory( );		if ( parent instanceof TableHandle )		{			groupHandle = factory.newTableGroup( );			slotHandle = ( (TableHandle) parent ).getGroups( );			int columnCount = ( (TableHandle) parent ).getColumnCount( );			groupHandle.getHeader( ).add( factory.newTableRow( columnCount ) );			groupHandle.getFooter( ).add( factory.newTableRow( columnCount ) );		}		else if ( parent instanceof ListHandle )		{			groupHandle = factory.newListGroup( );			slotHandle = ( (ListHandle) parent ).getGroups( );		}		if ( groupHandle != null && slotHandle != null )		{			slotHandle.add( groupHandle, position );			if ( !DEUtil.getDataSetList( parent ).isEmpty( ) )			{//If data set can be found or a blank group will be inserted.				GroupDialog dialog = new GroupDialog( getDefaultShell( ) );				dialog.setDataSetList( DEUtil.getDataSetList( parent ) );				dialog.setInput( groupHandle );				if ( dialog.open( ) == Window.CANCEL )				{//Cancel the action					return false;				}				DataItemHandle dataItemHandle = factory.newDataItem( null );				dataItemHandle.setValueExpr( groupHandle.getKeyExpr( ) );				if ( parent instanceof ListHandle )				{					groupHandle.getHeader( ).add( dataItemHandle );				}				else if ( parent instanceof TableHandle )				{					if ( groupHandle.getHeader( ).getCount( ) != 0 )					{						RowHandle rowHandle = ( (RowHandle) groupHandle.getHeader( )								.get( 0 ) );						CellHandle cellHandle = (CellHandle) rowHandle.getCells( )								.get( 0 );						cellHandle.getContent( ).add( dataItemHandle );					}				}			}			return true;		}		return false;	}