<s> from ApplicationConstants import Notification <EOL> from pyjamas . ui . HorizontalPanel import HorizontalPanel <EOL> from pyjamas . ui . VerticalPanel import VerticalPanel <EOL> from pyjamas . ui . Label import Label <EOL> from pyjamas . ui . Button import Button <EOL> from pyjamas . ui . DialogBox import DialogBox <EOL> from pyjamas . ui . FlexTable import FlexTable <EOL> from pyjamas . ui . HTML import HTML <EOL> from pyjamas . ui . TextBox import TextBox <EOL> from pyjamas . Cookies import setCookie , getCookie <EOL> from pyjamas . Window import alert <EOL> class PreferencesDlg ( DialogBox ) : <EOL> fileLocation = None <EOL> def __init__ ( self , left = <NUM_LIT:50> , top = <NUM_LIT:50> ) : <EOL> DialogBox . __init__ ( self , modal = False ) <EOL> self . setPopupPosition ( left , top ) <EOL> self . setText ( "<STR_LIT>" ) <EOL> ftable = FlexTable ( ) <EOL> ftableFormatter = ftable . getFlexCellFormatter ( ) <EOL> row = <NUM_LIT:0> <EOL> try : <EOL> self . fileLocation = getCookie ( "<STR_LIT>" ) <EOL> except : <EOL> self . fileLocation = None <EOL> row += <NUM_LIT:1> <EOL> ftable . setWidget ( row , <NUM_LIT:0> , Label ( "<STR_LIT>" , wordWrap = False ) ) <EOL> self . fileLocationInput = TextBox ( ) <EOL> self . fileLocationInput . addChangeListener ( self . checkValid ) <EOL> self . fileLocationInput . addKeyboardListener ( self ) <EOL> self . fileLocationInput . setVisibleLength ( <NUM_LIT:30> ) <EOL> self . fileLocationInput . setText ( self . fileLocation ) <EOL> ftable . setWidget ( row , <NUM_LIT:1> , self . fileLocationInput ) <EOL> row += <NUM_LIT:1> <EOL> hpanel = HorizontalPanel ( ) <EOL> self . saveBtn = Button ( "<STR_LIT>" , self . onSave ) <EOL> self . saveBtn . setEnabled ( False ) <EOL> hpanel . add ( self . saveBtn ) <EOL> self . cancelBtn = Button ( "<STR_LIT>" , self . onCancel ) <EOL> hpanel . add ( self . cancelBtn ) <EOL> ftable . setWidget ( row , <NUM_LIT:0> , hpanel ) <EOL> ftableFormatter . setColSpan ( row , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . setWidget ( ftable ) <EOL> def onCancel ( self , sender ) : <EOL> self . hide ( ) <EOL> def onSave ( self , sender ) : <EOL> try : <EOL> setCookie ( "<STR_LIT>" , self . fileLocationInput . getText ( ) , <NUM_LIT> ) <EOL> except : <EOL> pass <EOL> self . hide ( ) <EOL> def checkValid ( self , evt = None ) : <EOL> if self . fileLocation != self . fileLocationInput . getText ( ) : <EOL> self . saveBtn . setEnabled ( True ) <EOL> else : <EOL> self . saveBtn . setEnabled ( False ) <EOL> def onClick ( self , sender ) : <EOL> pass <EOL> def onKeyUp ( self , sender , keyCode , modifiers ) : <EOL> self . checkValid ( ) <EOL> def onKeyDown ( self , sender , keyCode , modifiers ) : <EOL> pass <EOL> def onKeyPress ( self , sender , keyCode , modifiers ) : <EOL> pass </s>
