Package AccessEngine :: Package AEEvent :: Module ChooserChange
[hide private]
[frames] | no frames]

Source Code for Module AccessEngine.AEEvent.ChooserChange

  1  ''' 
  2  Defines an L{AEEvent} indicating an event of interest occurred in an  
  3  L{AEChooser}. 
  4   
  5  @author: Peter Parente 
  6  @organization: IBM Corporation 
  7  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
  8  @license: The BSD License 
  9   
 10  @author: Frank Zenker 
 11  @author: Ramona Bunk 
 12  @organization: IT Science Center Ruegen gGmbH, Germany 
 13  @copyright: Copyright (c) 2007, 2008 ITSC Ruegen 
 14  @license: The BSD License 
 15   
 16  All rights reserved. This program and the accompanying materials are made 
 17  available under the terms of the BSD license which accompanies 
 18  this distribution, and is available at 
 19  U{http://www.opensource.org/licenses/bsd-license.php} 
 20  ''' 
 21   
 22  import AccessEngine 
 23  import Base 
 24  from AccessEngine import AEConstants 
 25   
26 -class ChooserChange(Base.AEEvent):
27 ''' 28 Event that fires when a L{AEChooser} indicates important input from a user. 29 30 This class registers its name and whether it should be monitored by default 31 in an L{AEMonitor} using the L{Base.registerEventType} function when 32 this module is first imported. The L{AEMonitor} can use this information to 33 build its menus. 34 35 @ivar aid: Unique identifier for the application L{AETier} with which the 36 L{AEChooser} that fired this event is associated 37 @type aid: opaque 38 @ivar chooser: L{AEChooser} that fired this event 39 @type chooser: L{AEChooser} 40 @ivar kind: Kind of event, one of OK, CANCEL, or APPLY from L{AEChooser} 41 @type kind: integer 42 @ivar kwargs: Aribitrary data to be passed to the handler of this event 43 @type kwargs: dictionary 44 ''' 45 Base.registerEventType('ChooserChange', False)
46 - def __init__(self, aid, chooser, kind, **kwargs):
47 ''' 48 Stores important references. 49 50 @param aid: Unique identifier for the application L{AETier} with which the 51 L{AEChooser} that fired this event is associated 52 @type aid: opaque 53 @param chooser: L{AEChooser} that fired this event 54 @type chooser: L{AEChooser} 55 @param kind: Kind of event, one of OK, CANCEL, or APPLY from L{AEChooser} 56 @type kind: integer 57 ''' 58 Base.AEEvent.__init__(self, focused=True, **kwargs) 59 self.aid = aid 60 self.kwargs = kwargs 61 self.kind = kind 62 self.chooser = chooser
63
64 - def __str__(self):
65 ''' 66 Returns a human readable representation of this event including its name, 67 action, and chooser. 68 69 @return: Information about this event 70 @rtype: string 71 ''' 72 name = Base.AEEvent.__str__(self) 73 if self.kind == AEConstants.CHOOSER_OK: 74 action = 'ok' 75 elif self.kind == AEConstants.CHOOSER_CANCEL: 76 action = 'cancel' 77 elif self.kind == AEConstants.CHOOSER_APPLY: 78 action = 'apply' 79 else: 80 action = self.kind 81 return '%s:\n\tchooser: %s\n\taction: %s' % \ 82 (name, self.chooser.getName(), action)
83
84 - def execute(self):
85 ''' 86 Contacts the L{AETierManager} and asks it to manage this chooser event. 87 88 @return: True to indicate the event executed properly 89 @rtype: boolean 90 ''' 91 AccessEngine.AETierManager.manageChooser(self) 92 return True
93
94 - def getTaskKey(self):
95 ''' 96 Gets the L{AEChooser} ID that triggered this event. This information is 97 used to locate the task that should handle this event. 98 99 @return: ID of the chooser that fired the event 100 @rtype: integer 101 ''' 102 return id(self.chooser)
103
104 - def getAppID(self):
105 ''' 106 @return: Unique application ID identifying the top most container for the 107 source of this event (i.e. the application) 108 @rtype: opaque object 109 ''' 110 return self.aid
111
112 - def getDataForTask(self):
113 ''' 114 Fetches data out of this L{ChooserChange} for use by a 115 L{AEScript.EventScript.onChooserChange}. 116 117 @return: Dictionary of parameters to be passed to a 118 L{AEScript.EventScript.onChooserChange} as follows: 119 - chooser: The chooser that fired the event 120 - kind: The kind of event 121 - any addition data in the L{kwargs} instance variable 122 @rtype: dictionary 123 ''' 124 self.kwargs['chooser'] = self.chooser 125 self.kwargs['kind'] = self.kind 126 return self.kwargs
127