<s> """<STR_LIT>""" <EOL> from muntjac . ui . abstract_component import AbstractComponent <EOL> from muntjac . event . mouse_events import IClickListener , ClickEvent <EOL> from muntjac . terminal . gwt . client . mouse_event_details import MouseEventDetails <EOL> from muntjac . terminal . gwt . client . ui . v_embedded import VEmbedded <EOL> class Embedded ( AbstractComponent ) : <EOL> """<STR_LIT>""" <EOL> CLIENT_WIDGET = None <EOL> _CLICK_EVENT = VEmbedded . CLICK_EVENT_IDENTIFIER <EOL> TYPE_OBJECT = <NUM_LIT:0> <EOL> TYPE_IMAGE = <NUM_LIT:1> <EOL> TYPE_BROWSER = <NUM_LIT:2> <EOL> def __init__ ( self , caption = None , source = None ) : <EOL> """<STR_LIT>""" <EOL> super ( Embedded , self ) . __init__ ( ) <EOL> self . _type = self . TYPE_OBJECT <EOL> self . _source = None <EOL> self . _mimeType = None <EOL> self . _standby = None <EOL> self . _parameters = dict ( ) <EOL> self . _codebase = None <EOL> self . _codetype = None <EOL> self . _classId = None <EOL> self . _archive = None <EOL> if caption is not None : <EOL> self . setCaption ( caption ) <EOL> if source is not None : <EOL> self . setSource ( source ) <EOL> def paintContent ( self , target ) : <EOL> """<STR_LIT>""" <EOL> if self . _type == self . TYPE_IMAGE : <EOL> target . addAttribute ( '<STR_LIT:type>' , '<STR_LIT:image>' ) <EOL> elif self . _type == self . TYPE_BROWSER : <EOL> target . addAttribute ( '<STR_LIT:type>' , '<STR_LIT>' ) <EOL> if self . getSource ( ) is not None : <EOL> target . addAttribute ( '<STR_LIT:src>' , self . getSource ( ) ) <EOL> if self . _mimeType is not None and not ( '<STR_LIT>' == self . _mimeType ) : <EOL> target . addAttribute ( '<STR_LIT>' , self . _mimeType ) <EOL> if self . _classId is not None and not ( '<STR_LIT>' == self . _classId ) : <EOL> target . addAttribute ( '<STR_LIT>' , self . _classId ) <EOL> if self . _codebase is not None and not ( '<STR_LIT>' == self . _codebase ) : <EOL> target . addAttribute ( '<STR_LIT>' , self . _codebase ) <EOL> if self . _codetype is not None and not ( '<STR_LIT>' == self . _codetype ) : <EOL> target . addAttribute ( '<STR_LIT>' , self . _codetype ) <EOL> if self . _standby is not None and not ( '<STR_LIT>' == self . _standby ) : <EOL> target . addAttribute ( '<STR_LIT>' , self . _standby ) <EOL> if self . _archive is not None and not ( '<STR_LIT>' == self . _archive ) : <EOL> target . addAttribute ( '<STR_LIT>' , self . _archive ) <EOL> for key in self . getParameterNames ( ) : <EOL> target . startTag ( '<STR_LIT>' ) <EOL> target . addAttribute ( '<STR_LIT:name>' , key ) <EOL> target . addAttribute ( '<STR_LIT:value>' , self . getParameter ( key ) ) <EOL> target . endTag ( '<STR_LIT>' ) <EOL> def setParameter ( self , name , value ) : <EOL> """<STR_LIT>""" <EOL> self . _parameters [ name ] = value <EOL> self . requestRepaint ( ) <EOL> def getParameter ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return self . _parameters . get ( name ) <EOL> def removeParameter ( self , name ) : <EOL> """<STR_LIT>""" <EOL> if name in self . _parameters : <EOL> del self . _parameters [ name ] <EOL> self . requestRepaint ( ) <EOL> def getParameterNames ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _parameters . keys ( ) <EOL> def getCodebase ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _codebase <EOL> def getCodetype ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _codetype <EOL> def getMimeType ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _mimeType <EOL> def getStandby ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _standby <EOL> def setCodebase ( self , codebase ) : <EOL> """<STR_LIT>""" <EOL> if ( codebase != self . _codebase <EOL> or ( codebase is not None and codebase != self . _codebase ) ) : <EOL> self . _codebase = codebase <EOL> self . requestRepaint ( ) <EOL> def setCodetype ( self , codetype ) : <EOL> """<STR_LIT>""" <EOL> if ( codetype != self . _codetype <EOL> or ( codetype is not None and codetype != self . _codetype ) ) : <EOL> self . _codetype = codetype <EOL> self . requestRepaint ( ) <EOL> def setMimeType ( self , mimeType ) : <EOL> """<STR_LIT>""" <EOL> if ( mimeType != self . _mimeType <EOL> or ( mimeType is not None and mimeType != self . _mimeType ) ) : <EOL> self . _mimeType = mimeType <EOL> if '<STR_LIT>' == mimeType : <EOL> if self . getParameter ( '<STR_LIT>' ) is None : <EOL> self . setParameter ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . requestRepaint ( ) <EOL> def setStandby ( self , standby ) : <EOL> """<STR_LIT>""" <EOL> if ( standby != self . _standby <EOL> or ( standby is not None and standby != self . _standby ) ) : <EOL> self . _standby = standby <EOL> self . requestRepaint ( ) <EOL> def getClassId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _classId <EOL> def setClassId ( self , classId ) : <EOL> """<STR_LIT>""" <EOL> if ( classId != self . _classId <EOL> or ( classId is not None and classId != self . _classId ) ) : <EOL> self . _classId = classId <EOL> self . requestRepaint ( ) <EOL> def getSource ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _source <EOL> def getType ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _type <EOL> def setSource ( self , source ) : <EOL> """<STR_LIT>""" <EOL> if source is not None and source != self . _source : <EOL> self . _source = source <EOL> mt = source . getMIMEType ( ) <EOL> if self . _mimeType is None : <EOL> self . _mimeType = mt <EOL> if mt == '<STR_LIT>' : <EOL> self . _type = self . TYPE_OBJECT <EOL> elif mt [ : mt . find ( '<STR_LIT:/>' ) ] . lower ( ) == '<STR_LIT:image>' : <EOL> self . _type = self . TYPE_IMAGE <EOL> else : <EOL> pass <EOL> self . requestRepaint ( ) <EOL> def setType ( self , typ ) : <EOL> """<STR_LIT>""" <EOL> if ( typ != self . TYPE_OBJECT and typ != self . TYPE_IMAGE <EOL> and typ != self . TYPE_BROWSER ) : <EOL> raise ValueError , '<STR_LIT>' <EOL> if typ != self . _type : <EOL> self . _type = typ <EOL> self . requestRepaint ( ) <EOL> def getArchive ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _archive <EOL> def setArchive ( self , archive ) : <EOL> """<STR_LIT>""" <EOL> if ( archive != self . _archive <EOL> or ( archive is not None and archive != self . _archive ) ) : <EOL> self . _archive = archive <EOL> self . requestRepaint ( ) <EOL> def addListener ( self , listener , iface = None ) : <EOL> """<STR_LIT>""" <EOL> if ( isinstance ( listener , IClickListener ) and <EOL> ( iface is None or issubclass ( iface , IClickListener ) ) ) : <EOL> self . registerListener ( self . _CLICK_EVENT , ClickEvent , <EOL> listener , IClickListener . clickMethod ) <EOL> super ( Embedded , self ) . addListener ( listener , iface ) <EOL> def addCallback ( self , callback , eventType = None , * args ) : <EOL> if eventType is None : <EOL> eventType = callback . _eventType <EOL> if issubclass ( eventType , ClickEvent ) : <EOL> self . registerCallback ( ClickEvent , callback , <EOL> self . _CLICK_EVENT , * args ) <EOL> else : <EOL> super ( Embedded , self ) . addCallback ( callback , eventType , * args ) <EOL> def removeListener ( self , listener , iface = None ) : <EOL> """<STR_LIT>""" <EOL> if ( isinstance ( listener , IClickListener ) and <EOL> ( iface is None or issubclass ( iface , IClickListener ) ) ) : <EOL> self . withdrawListener ( self . _CLICK_EVENT , ClickEvent , listener ) <EOL> super ( Embedded , self ) . removeListener ( listener , iface ) <EOL> def removeCallback ( self , callback , eventType = None ) : <EOL> if eventType is None : <EOL> eventType = callback . _eventType <EOL> if issubclass ( eventType , ClickEvent ) : <EOL> self . withdrawCallback ( ClickEvent , callback , self . _CLICK_EVENT ) <EOL> else : <EOL> super ( Embedded , self ) . removeCallback ( callback , eventType ) <EOL> def changeVariables ( self , source , variables ) : <EOL> super ( Embedded , self ) . changeVariables ( source , variables ) <EOL> if self . _CLICK_EVENT in variables : <EOL> self . fireClick ( variables . get ( self . _CLICK_EVENT ) ) <EOL> def fireClick ( self , parameters ) : <EOL> """<STR_LIT>""" <EOL> mouseDetails = MouseEventDetails . deSerialize ( parameters [ '<STR_LIT>' ] ) <EOL> self . fireEvent ( ClickEvent ( self , mouseDetails ) ) </s>
