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

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

 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  """Criterion for checking if drop target details contains the specific 
17  property with the specific value.""" 
18   
19  from muntjac.event.dd.acceptcriteria.client_side_criterion import \ 
20      ClientSideCriterion 
21   
22   
23 -class TargetDetailIs(ClientSideCriterion):
24 """Criterion for checking if drop target details contains the specific 25 property with the specific value. Currently only String values are 26 supported. 27 28 TODO: add support for other basic data types that we support in UIDL. 29 """ 30
31 - def __init__(self, dataFlavor, value):
32 """Constructs a criterion which ensures that the value there is a 33 value in L{TargetDetails} that equals the reference value. 34 35 @param dataFlavor: 36 the type of data to be checked 37 @param value: 38 the reference value to which the drop target detail will 39 be compared 40 """ 41 self._propertyName = dataFlavor 42 self._value = value
43 44
45 - def paintContent(self, target):
46 super(TargetDetailIs, self).paintContent(target) 47 target.addAttribute('p', self._propertyName) 48 49 if isinstance(self._value, bool): 50 target.addAttribute('v', self._value.booleanValue()) 51 target.addAttribute('t', 'b') 52 elif isinstance(self._value, str): 53 target.addAttribute('v', self._value)
54 55
56 - def accept(self, dragEvent):
57 data = dragEvent.getTargetDetails().getData(self._propertyName) 58 return self._value == data
59 60
61 - def getIdentifier(self):
62 # sub classes by default use VDropDetailEquals a client implementation 63 return 'com.vaadin.event.dd.acceptcriteria.TargetDetailIs'
64