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

Source Code for Module muntjac.event.data_bound_transferable

 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  """Parent class for Transferable implementations that have a Muntjac 
17  container as a data source.""" 
18   
19  from muntjac.event.transferable_impl import TransferableImpl 
20  from muntjac.data.container import IViewer 
21   
22   
23 -class DataBoundTransferable(TransferableImpl):
24 """Parent class for L{Transferable} implementations that have a Muntjac 25 container as a data source. The transfer is associated with an item 26 (identified by its Id) and optionally also a property identifier (e.g. a 27 table column identifier when transferring a single table cell). 28 29 The component must implement the interface L{IViewer}. 30 31 In most cases, receivers of data transfers should depend on this class 32 instead of its concrete subclasses. 33 """ 34
35 - def __init__(self, sourceComponent, rawVariables):
36 super(DataBoundTransferable, self).__init__(sourceComponent, 37 rawVariables)
38 39
40 - def getItemId(self):
41 """Returns the identifier of the item being transferred. 42 43 @return: item identifier 44 """ 45 pass
46 47
48 - def getPropertyId(self):
49 """Returns the optional property identifier that the transfer concerns. 50 51 This can be e.g. the table column from which a drag operation 52 originated. 53 54 @return: property identifier 55 """ 56 pass
57 58
59 - def getSourceContainer(self):
60 """Returns the container data source from which the transfer occurs. 61 62 L{IViewer.getContainerDataSource} is used to obtain the underlying 63 container of the source component. 64 65 @return: Container 66 """ 67 sourceComponent = self.getSourceComponent() 68 if isinstance(sourceComponent, IViewer): 69 return sourceComponent.getContainerDataSource() 70 else: 71 # this should not happen 72 return None
73