<s> from pyjamas . ui . RootPanel import RootPanel <EOL> from pyjamas . ui . TextArea import TextArea <EOL> from pyjamas . ui . Label import Label <EOL> from pyjamas . ui . Button import Button <EOL> from pyjamas . ui . Composite import Composite <EOL> from pyjamas . ui . HTML import HTML <EOL> from pyjamas . ui . VerticalPanel import VerticalPanel <EOL> from pyjamas . ui . HorizontalPanel import HorizontalPanel <EOL> from pyjamas . ui . ListBox import ListBox <EOL> from pyjamas . ui . TextBox import TextBox <EOL> from pyjamas . JSONService import JSONProxy <EOL> from pyjamas import Factory <EOL> class Email ( Composite ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> element = None <EOL> if kwargs . has_key ( '<STR_LIT>' ) : <EOL> element = kwargs . pop ( '<STR_LIT>' ) <EOL> panel = VerticalPanel ( Element = element ) <EOL> Composite . __init__ ( self , panel , ** kwargs ) <EOL> self . TEXT_WAITING = "<STR_LIT>" <EOL> self . TEXT_ERROR = "<STR_LIT>" <EOL> self . remote_py = EchoServicePython ( ) <EOL> self . status = Label ( ) <EOL> self . subject = TextBox ( ) <EOL> self . subject . setVisibleLength ( <NUM_LIT> ) <EOL> self . sender = TextBox ( ) <EOL> self . sender . setVisibleLength ( <NUM_LIT> ) <EOL> self . message = TextArea ( ) <EOL> self . message . setCharacterWidth ( <NUM_LIT> ) <EOL> self . message . setVisibleLines ( <NUM_LIT:15> ) <EOL> self . button_py = Button ( "<STR_LIT>" , self ) <EOL> buttons = HorizontalPanel ( ) <EOL> buttons . add ( self . button_py ) <EOL> buttons . setSpacing ( <NUM_LIT:8> ) <EOL> panel . add ( HTML ( "<STR_LIT>" ) ) <EOL> panel . add ( self . subject ) <EOL> panel . add ( HTML ( "<STR_LIT>" ) ) <EOL> panel . add ( self . sender ) <EOL> panel . add ( HTML ( "<STR_LIT>" ) ) <EOL> panel . add ( self . message ) <EOL> panel . add ( buttons ) <EOL> panel . add ( self . status ) <EOL> def onClick ( self , sender ) : <EOL> self . status . setText ( self . TEXT_WAITING ) <EOL> text = self . message . getText ( ) <EOL> msg_sender = self . sender . getText ( ) <EOL> msg_subject = self . subject . getText ( ) <EOL> if sender == self . button_py : <EOL> id = self . remote_py . send ( msg_sender , msg_subject , text , self ) <EOL> if id < <NUM_LIT:0> : <EOL> self . status . setText ( self . TEXT_ERROR ) <EOL> def onRemoteResponse ( self , response , request_info ) : <EOL> self . status . setText ( response ) <EOL> def onRemoteError ( self , code , message , request_info ) : <EOL> self . status . setText ( "<STR_LIT>" + str ( code ) + "<STR_LIT>" + str ( message ) ) <EOL> Factory . registerClass ( '<STR_LIT>' , Email ) <EOL> class EchoServicePython ( JSONProxy ) : <EOL> def __init__ ( self ) : <EOL> JSONProxy . __init__ ( self , "<STR_LIT>" , [ "<STR_LIT>" ] ) </s>
