Package Task :: Module ViewTask
[hide private]
[frames] | no frames]

Source Code for Module Task.ViewTask

  1  ''' 
  2  Defines a L{Task} to execute in response to a L{AEEvent.ViewChange}. 
  3   
  4  @author: Peter Parente 
  5  @organization: IBM Corporation 
  6  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
  7  @license: The BSD License 
  8   
  9  All rights reserved. This program and the accompanying materials are made  
 10  available under the terms of the BSD license which accompanies 
 11  this distribution, and is available at 
 12  U{http://www.opensource.org/licenses/bsd-license.php} 
 13  ''' 
 14   
 15  import Base, EventTask, AEConstants 
 16  import AEEvent 
 17   
18 -class ViewTask(EventTask.EventTask):
19 ''' 20 Executed when a view change occurs. 21 22 This class registers its name and whether it should be monitored by default 23 in an L{AEMonitor} using the L{Base.registerTaskType} function when this 24 module is first imported. An L{AEMonitor} can use this information to build 25 its menus. 26 ''' 27 Base.registerTaskType('ViewTask', True) 28
29 - def getEventType(self):
30 ''' 31 @return: Type of L{AEEvent} this L{Task} wants to handle 32 @rtype: class 33 ''' 34 return AEEvent.ViewChange
35
36 - def update(self, por, title, gained, layer, **kwargs):
37 ''' 38 Updates this L{Task} in response to a consumed view change event. Called by 39 L{Tier.Tier._executeTask}. 40 41 @param por: Point of regard to the root of the new view 42 @type por: L{POR} 43 @param title: Title of the view 44 @type title: string 45 @param gained: The kind of view change event 46 @type gained: integer 47 @param layer: Layer on which the event occurred 48 @type layer: integer 49 ''' 50 pass
51
52 - def execute(self, por, title, gained, layer, **kwargs):
53 ''' 54 Executes this L{Task} in response to a view change event. Called by 55 L{Tier.Tier._executeTask}. 56 57 @param por: Point of regard to the root of the new view 58 @type por: L{POR} 59 @param title: Title of the view 60 @type title: string 61 @param gained: The kind of view change event 62 @type gained: integer 63 @param layer: Layer on which the event occurred 64 @type layer: integer 65 @return: True to allow other L{Task}s to process this event 66 @rtype: boolean 67 ''' 68 if gained == AEConstants.EVENT_VIEW_GAINED: 69 return self.executeGained(por=por, title=title, layer=layer, **kwargs) 70 elif gained == AEConstants.EVENT_VIEW_LOST: 71 return self.executeLost(por=por, title=title, layer=layer, **kwargs) 72 elif gained == AEConstants.EVENT_VIEW_STARTUP: 73 return self.executeStartup(por=por, title=title, layer=layer, **kwargs) 74 elif gained == AEConstants.EVENT_VIEW_FIRST_GAINED: 75 return self.executeFirstGained(por=por, title=title, layer=layer, 76 **kwargs)
77
78 - def executeGained(self, por, title, layer, **kwargs):
79 ''' 80 Executes this L{Task} in response to a view gained event. Called by 81 L{execute}. 82 83 @param por: Point of regard to the root of the new view 84 @type por: L{POR} 85 @param title: Title of the view 86 @type title: string 87 @param layer: Layer on which the event occurred 88 @type layer: integer 89 @return: True to allow other L{Task}s to process this event 90 @rtype: boolean 91 ''' 92 return True
93
94 - def executeLost(self, por, title, layer, **kwargs):
95 ''' 96 Executes this L{Task} in response to a view lost event. Called by 97 L{execute}. 98 99 @param por: Point of regard to the root of the lost view 100 @type por: L{POR} 101 @param title: Title of the view 102 @type title: string 103 @param layer: Layer on which the event occurred 104 @type layer: integer 105 @return: True to allow other L{Task}s to process this event 106 @rtype: boolean 107 ''' 108 return True
109
110 - def executeStartup(self, por, title, layer, **kwargs):
111 ''' 112 Executes this L{Task} in response to the view being identified during LSR 113 startup. Called by L{execute}. 114 115 @param por: Point of regard to the root of the mutated view 116 @type por: L{POR} 117 @param title: Title of the view 118 @type title: string 119 @param layer: Layer on which the event occurred 120 @type layer: integer 121 @return: True to allow other L{Task}s to process this event 122 @rtype: boolean 123 ''' 124 return True
125
126 - def executeFirstGained(self, por, title, layer, **kwargs):
127 ''' 128 Executes this L{Task} in response to the view being identified as the 129 active view during LSR startup. Called by L{execute}. 130 131 @param por: Point of regard to the root of the mutated view 132 @type por: L{POR} 133 @param title: Title of the view 134 @type title: string 135 @param layer: Layer on which the event occurred 136 @type layer: integer 137 @return: True to allow other L{Task}s to process this event 138 @rtype: boolean 139 ''' 140 return True
141