<s> import pyjd <EOL> from pyjamas . ui . Button import Button <EOL> from pyjamas . ui . RootPanel import RootPanel <EOL> from pyjamas . ui . HTML import HTML <EOL> from pyjamas . ui . DockPanel import DockPanel <EOL> from pyjamas . ui import HasAlignment <EOL> from pyjamas . ui . Hyperlink import Hyperlink <EOL> from pyjamas . ui . VerticalPanel import VerticalPanel <EOL> from pyjamas import Window <EOL> from pyjamas . ui . Sink import SinkList <EOL> from pyjamas import History <EOL> import IntroTab <EOL> import TooltipTab <EOL> import AutoCompleteTab <EOL> import Canvas2DTab <EOL> import CanvasTab <EOL> class AddonsGallery : <EOL> def onHistoryChanged ( self , token ) : <EOL> info = self . sink_list . find ( token ) <EOL> if info : <EOL> self . show ( info , False ) <EOL> else : <EOL> self . showIntro ( ) <EOL> def onModuleLoad ( self ) : <EOL> self . curInfo = '<STR_LIT>' <EOL> self . curSink = None <EOL> self . description = HTML ( ) <EOL> self . sink_list = SinkList ( ) <EOL> self . panel = DockPanel ( ) <EOL> self . loadSinks ( ) <EOL> self . sinkContainer = DockPanel ( ) <EOL> self . sinkContainer . setStyleName ( "<STR_LIT>" ) <EOL> vp = VerticalPanel ( ) <EOL> vp . setWidth ( "<STR_LIT>" ) <EOL> vp . add ( self . description ) <EOL> vp . add ( self . sinkContainer ) <EOL> self . description . setStyleName ( "<STR_LIT>" ) <EOL> self . panel . add ( self . sink_list , DockPanel . WEST ) <EOL> self . panel . add ( vp , DockPanel . CENTER ) <EOL> self . panel . setCellVerticalAlignment ( self . sink_list , HasAlignment . ALIGN_TOP ) <EOL> self . panel . setCellWidth ( vp , "<STR_LIT>" ) <EOL> History . addHistoryListener ( self ) <EOL> RootPanel ( ) . add ( self . panel ) <EOL> initToken = History . getToken ( ) <EOL> if len ( initToken ) : <EOL> self . onHistoryChanged ( initToken ) <EOL> else : <EOL> self . showIntro ( ) <EOL> def show ( self , info , affectHistory = None ) : <EOL> if info == self . curInfo : return <EOL> self . curInfo = info <EOL> if self . curSink < > None : <EOL> self . curSink . onHide ( ) <EOL> self . sinkContainer . remove ( self . curSink ) <EOL> self . curSink = info . getInstance ( ) <EOL> self . sink_list . setSinkSelection ( info . getName ( ) ) <EOL> self . description . setHTML ( info . getDescription ( ) ) <EOL> if ( affectHistory ) : <EOL> History . newItem ( info . getName ( ) ) <EOL> self . sinkContainer . add ( self . curSink , DockPanel . CENTER ) <EOL> self . sinkContainer . setCellWidth ( self . curSink , "<STR_LIT>" ) <EOL> self . sinkContainer . setCellHeight ( self . curSink , "<STR_LIT>" ) <EOL> self . sinkContainer . setCellVerticalAlignment ( self . curSink , HasAlignment . ALIGN_TOP ) <EOL> self . curSink . onShow ( ) <EOL> def loadSinks ( self ) : <EOL> self . sink_list . add ( IntroTab . init ( ) ) <EOL> self . sink_list . add ( TooltipTab . init ( ) ) <EOL> self . sink_list . add ( AutoCompleteTab . init ( ) ) <EOL> self . sink_list . add ( Canvas2DTab . init ( ) ) <EOL> self . sink_list . add ( CanvasTab . init ( ) ) <EOL> def showIntro ( self ) : <EOL> self . show ( self . sink_list . find ( "<STR_LIT>" ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pyjd . setup ( "<STR_LIT>" ) <EOL> app = AddonsGallery ( ) <EOL> app . onModuleLoad ( ) <EOL> pyjd . run ( ) </s>
