<s> import pyjd <EOL> if pyjd . is_desktop : <EOL> from __pyjamas__ import doc <EOL> from pyjamas import Factory <EOL> from pyjamas import DOM <EOL> from pyjamas . ui . HTMLTable import HTMLTable <EOL> from pyjamas . ui . RowFormatter import RowFormatter <EOL> from pyjamas . ui . FlexCellFormatter import FlexCellFormatter <EOL> class FlexTable ( HTMLTable ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> if not kwargs . has_key ( '<STR_LIT>' ) : <EOL> kwargs [ '<STR_LIT>' ] = FlexCellFormatter ( self ) <EOL> HTMLTable . __init__ ( self , ** kwargs ) <EOL> def addCell ( self , row ) : <EOL> self . insertCell ( row , self . getCellCount ( row ) ) <EOL> def getCellCount ( self , row ) : <EOL> self . checkRowBounds ( row ) <EOL> return self . getDOMCellCount ( self . getBodyElement ( ) , row ) <EOL> def getFlexCellFormatter ( self ) : <EOL> return self . getCellFormatter ( ) <EOL> def getRowCount ( self ) : <EOL> return self . getDOMRowCount ( ) <EOL> def removeCells ( self , row , column , num ) : <EOL> for i in range ( num ) : <EOL> self . removeCell ( row , column ) <EOL> def prepareCell ( self , row , column ) : <EOL> self . prepareRow ( row ) <EOL> cellCount = self . getCellCount ( row ) <EOL> required = column + <NUM_LIT:1> - cellCount <EOL> if required > <NUM_LIT:0> : <EOL> self . addCells ( self . getBodyElement ( ) , row , required ) <EOL> def prepareRow ( self , row ) : <EOL> rowCount = self . getRowCount ( ) <EOL> for i in range ( rowCount , row + <NUM_LIT:1> ) : <EOL> self . insertRow ( i ) <EOL> def addCells ( self , table , row , num ) : <EOL> rowElem = table . rows . item ( row ) <EOL> for i in range ( num ) : <EOL> cell = doc ( ) . createElement ( "<STR_LIT>" ) <EOL> rowElem . appendChild ( cell ) <EOL> Factory . registerClass ( '<STR_LIT>' , '<STR_LIT>' , FlexTable ) </s>
