Package muntjac :: Package event :: Package dd :: Package acceptcriteria :: Module contains_data_flavor
[hide private]
[frames] | no frames]

Source Code for Module muntjac.event.dd.acceptcriteria.contains_data_flavor

 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  """A criterion that checks whether Transferable contains given data 
17  flavor.""" 
18   
19  from muntjac.event.dd.acceptcriteria.client_side_criterion import \ 
20      ClientSideCriterion 
21   
22   
23 -class ContainsDataFlavor(ClientSideCriterion):
24 """A Criterion that checks whether L{Transferable} contains given data 25 flavor. The developer might for example accept the incoming data only 26 if it contains "Url" or "Text". 27 """ 28
29 - def __init__(self, dataFlavor):
30 """Constructs a new instance of L{ContainsDataFlavor}. 31 32 @param dataFlavor: 33 the type of data that will be checked from 34 L{Transferable} 35 """ 36 self._dataFlavorId = dataFlavor
37 38
39 - def paintContent(self, target):
40 super(ContainsDataFlavor, self).paintContent(target) 41 target.addAttribute('p', self._dataFlavorId)
42 43
44 - def accept(self, dragEvent):
45 return (self._dataFlavorId 46 in dragEvent.getTransferable().getDataFlavors())
47 48
49 - def getIdentifier(self):
50 # extending classes use client side implementation from this class 51 return 'com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor'
52