<s> from muntjac . ui . abstract_component import AbstractComponent <EOL> from muntjac . ui . component import Event as ComponentEvent <EOL> class IFragmentChangedListener ( object ) : <EOL> """<STR_LIT>""" <EOL> def fragmentChanged ( self , source ) : <EOL> raise NotImplementedError <EOL> _FRAGMENT_CHANGED_METHOD = getattr ( IFragmentChangedListener , '<STR_LIT>' ) <EOL> class UriFragmentUtility ( AbstractComponent ) : <EOL> """<STR_LIT>""" <EOL> CLIENT_WIDGET = None <EOL> def addListener ( self , listener , iface = None ) : <EOL> if ( isinstance ( listener , IFragmentChangedListener ) and <EOL> ( iface is None or issubclass ( iface , IFragmentChangedListener ) ) ) : <EOL> self . registerListener ( FragmentChangedEvent , <EOL> listener , _FRAGMENT_CHANGED_METHOD ) <EOL> super ( UriFragmentUtility , 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 , FragmentChangedEvent ) : <EOL> self . registerCallback ( FragmentChangedEvent , callback , None , * args ) <EOL> else : <EOL> super ( UriFragmentUtility , self ) . addCallback ( callback , <EOL> eventType , * args ) <EOL> def removeListener ( self , listener , iface = None ) : <EOL> if ( isinstance ( listener , IFragmentChangedListener ) and <EOL> ( iface is None or issubclass ( iface , IFragmentChangedListener ) ) ) : <EOL> self . withdrawListener ( FragmentChangedEvent , <EOL> listener , _FRAGMENT_CHANGED_METHOD ) <EOL> super ( UriFragmentUtility , self ) . removeListener ( listener , iface ) <EOL> def removeCallback ( self , callback , eventType = None ) : <EOL> if eventType is None : <EOL> eventType = callback . _eventType <EOL> if issubclass ( eventType , FragmentChangedEvent ) : <EOL> self . withdrawCallback ( FragmentChangedEvent , callback ) <EOL> else : <EOL> super ( UriFragmentUtility , self ) . removeCallback ( callback , eventType ) <EOL> def __init__ ( self ) : <EOL> super ( UriFragmentUtility , self ) . __init__ ( ) <EOL> self . _fragment = None <EOL> self . setImmediate ( True ) <EOL> def paintContent ( self , target ) : <EOL> super ( UriFragmentUtility , self ) . paintContent ( target ) <EOL> value = self . _fragment if self . _fragment is not None else '<STR_LIT>' <EOL> target . addVariable ( self , '<STR_LIT>' , value ) <EOL> def changeVariables ( self , source , variables ) : <EOL> super ( UriFragmentUtility , self ) . changeVariables ( source , variables ) <EOL> self . _fragment = variables . get ( '<STR_LIT>' ) <EOL> self . fireEvent ( FragmentChangedEvent ( self ) ) <EOL> def getFragment ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _fragment <EOL> def setFragment ( self , newFragment , fireEvent = True ) : <EOL> """<STR_LIT>""" <EOL> if ( ( newFragment is None and self . _fragment is not None ) <EOL> or ( newFragment is not None <EOL> and newFragment != self . _fragment ) ) : <EOL> self . _fragment = newFragment <EOL> if fireEvent : <EOL> fireEvent ( FragmentChangedEvent ( self ) ) <EOL> self . requestRepaint ( ) <EOL> class FragmentChangedEvent ( ComponentEvent ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , source ) : <EOL> """<STR_LIT>""" <EOL> super ( FragmentChangedEvent , self ) . __init__ ( source ) <EOL> def getUriFragmentUtility ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . getSource ( ) </s>
