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

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

 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 that can be used create policy to accept/discard dragged 
17  content.""" 
18   
19   
20 -class IAcceptCriterion(object):
21 """Criterion that can be used create policy to accept/discard dragged 22 content (presented by L{Transferable}). 23 24 The drag and drop mechanism will verify the criteria returned by 25 L{DropHandler.getAcceptCriterion} before calling L{DropHandler.drop}. 26 27 The criteria can be evaluated either on the client (browser - see 28 L{ClientSideCriterion}) or on the server (see L{ServerSideCriterion}). 29 If no constraints are needed, an L{AcceptAll} can be used. 30 31 In addition to accepting or rejecting a possible drop, criteria can provide 32 additional hints for client side painting. 33 34 @see: L{DropHandler} 35 @see: L{ClientSideCriterion} 36 @see: L{ServerSideCriterion} 37 """ 38
39 - def isClientSideVerifiable(self):
40 """Returns whether the criteria can be checked on the client or whether 41 a server request is needed to check the criteria. 42 43 This requirement may depend on the state of the criterion (e.g. logical 44 operations between criteria), so this cannot be based on a marker 45 interface. 46 """ 47 raise NotImplementedError
48 49
50 - def paint(self, target):
51 raise NotImplementedError
52 53
54 - def paintResponse(self, target):
55 """This needs to be implemented iff criterion does some lazy server 56 side initialization. The UIDL painted in this method will be passed to 57 client side drop handler implementation. Implementation can assume that 58 L{accept} is called before this method. 59 """ 60 raise NotImplementedError
61 62
63 - def accept(self, dragEvent):
64 """Validates the data in event to be appropriate for the 65 L{DropHandler.drop} method. 66 67 Note that even if your criterion is validated on client side, you 68 should always validate the data on server side too. 69 """ 70 raise NotImplementedError
71