Package muntjac :: Package event :: Module item_click_event
[hide private]
[frames] | no frames]

Source Code for Module muntjac.event.item_click_event

  1  # Copyright (C) 2012 Vaadin Ltd.  
  2  # Copyright (C) 2012 Richard Lincoln 
  3  #  
  4  # Licensed under the Apache License, Version 2.0 (the "License");  
  5  # you may not use this file except in compliance with the License.  
  6  # You may obtain a copy of the License at  
  7  #  
  8  #     http://www.apache.org/licenses/LICENSE-2.0  
  9  #  
 10  # Unless required by applicable law or agreed to in writing, software  
 11  # distributed under the License is distributed on an "AS IS" BASIS,  
 12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
 13  # See the License for the specific language governing permissions and  
 14  # limitations under the License. 
 15   
 16  """Click event fired by a C{IComponent} implementing C{IContainer} 
 17  interface.""" 
 18   
 19  from muntjac.event.mouse_events import ClickEvent 
 20   
 21   
22 -class IItemClickListener(object):
23
24 - def itemClick(self, event):
25 raise NotImplementedError
26 27 28 ITEM_CLICK_METHOD = getattr(IItemClickListener, 'itemClick') 29 30
31 -class ItemClickEvent(ClickEvent):
32 """Click event fired by a L{Component} implementing L{IContainer} 33 interface. ItemClickEvents happens on an L{IItem} rendered somehow 34 on terminal. Event may also contain a specific L{Property} on which 35 the click event happened. 36 """ 37
38 - def __init__(self, source, item, itemId, propertyId, details):
39 super(ItemClickEvent, self).__init__(source, details) 40 self._item = item 41 self._itemId = itemId 42 self._propertyId = propertyId
43 44
45 - def getItem(self):
46 """Gets the item on which the click event occurred. 47 48 @return: item which was clicked 49 """ 50 return self._item
51 52
53 - def getItemId(self):
54 """Gets a possible identifier in source for clicked Item. 55 """ 56 return self._itemId
57 58
59 - def getPropertyId(self):
60 """Returns property on which click event occurred. Returns C{None} if 61 source cannot be resolved at property leve. For example if clicked a 62 cell in table, the "column id" is returned. 63 64 @return: a property id of clicked property or null if click didn't 65 occur on any distinct property. 66 """ 67 return self._propertyId
68 69
70 -class IItemClickNotifier(object):
71 """The interface for adding and removing C{ItemClickEvent} listeners. By 72 implementing this interface a class explicitly announces that it will 73 generate an C{ItemClickEvent} when one of its items is clicked. 74 75 @see: L{ItemClickListener} 76 @see: L{ItemClickEvent} 77 """ 78
79 - def addListener(self, listener, iface=None):
80 """Register a listener to handle L{ItemClickEvent}s.FieldEvents, 81 82 @param listener: 83 ItemClickListener to be registered 84 """ 85 raise NotImplementedError
86 87
88 - def addCallback(self, callback, eventType=None, *args):
89 raise NotImplementedError
90 91
92 - def removeListener(self, listener, iface=None):
93 """Removes an ItemClickListener. 94 95 @param listener: 96 ItemClickListener to be removed 97 """ 98 raise NotImplementedError
99 100
101 - def removeCallback(self, callback, eventType=None):
102 raise NotImplementedError
103 104
105 -class IItemClickSource(IItemClickNotifier):
106 """Components implementing L{Container} interface may support emitting 107 L{ItemClickEvent}s. 108 109 @deprecated: Use L{ItemClickNotifier} instead. 110 """ 111 pass
112