<s> from pyjamas . ui . Composite import Composite <EOL> from pyjamas . ui . VerticalPanel import VerticalPanel <EOL> from pyjamas . ui . Hyperlink import Hyperlink <EOL> from pyjamas . ui . ScrollPanel import ScrollPanel <EOL> from pyjamas import Window <EOL> class SinkList ( Composite ) : <EOL> def __init__ ( self ) : <EOL> Composite . __init__ ( self ) <EOL> self . vp_list = VerticalPanel ( ) <EOL> self . sinks = [ ] <EOL> self . selectedSink = - <NUM_LIT:1> <EOL> self . sp = ScrollPanel ( self . vp_list ) <EOL> self . sp . setWidth ( "<STR_LIT>" ) <EOL> self . initWidget ( self . sp ) <EOL> self . setStyleName ( "<STR_LIT>" ) <EOL> self . resize ( Window . getClientWidth ( ) , Window . getClientHeight ( ) ) <EOL> def resize ( self , width , height ) : <EOL> self . sp . setHeight ( "<STR_LIT>" % ( height - <NUM_LIT> ) ) <EOL> def addSink ( self , info ) : <EOL> name = info . getName ( ) <EOL> link = Hyperlink ( name , False , TargetHistoryToken = name ) <EOL> link . setStyleName ( "<STR_LIT>" ) <EOL> self . vp_list . add ( link ) <EOL> self . sinks . append ( info ) <EOL> def find ( self , sinkName ) : <EOL> for info in self . sinks : <EOL> if info . getName ( ) == sinkName : <EOL> return info <EOL> return None <EOL> def setSinkSelection ( self , name ) : <EOL> if self . selectedSink < > - <NUM_LIT:1> : <EOL> self . vp_list . getWidget ( self . selectedSink ) . removeStyleName ( "<STR_LIT>" ) <EOL> for i in range ( len ( self . sinks ) ) : <EOL> info = self . sinks [ i ] <EOL> if ( info . getName ( ) == name ) : <EOL> self . selectedSink = i <EOL> widget = self . vp_list . getWidget ( self . selectedSink ) <EOL> widget . addStyleName ( "<STR_LIT>" ) <EOL> return </s>
