Package muntjac :: Package ui :: Module popup_date_field
[hide private]
[frames] | no frames]

Source Code for Module muntjac.ui.popup_date_field

 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  """Defines a date entry component.""" 
17   
18  from muntjac.ui.date_field import DateField 
19  from muntjac.data.property import IProperty 
20   
21   
22 -class PopupDateField(DateField):
23 """A date entry component, which displays the actual date selector 24 as a popup. 25 26 @see: L{DateField} 27 @see: L{InlineDateField} 28 @author: Vaadin Ltd. 29 @author: Richard Lincoln 30 @version: 1.1.2 31 """ 32
33 - def __init__(self, *args):
34 self._inputPrompt = None 35 36 nargs = len(args) 37 if nargs == 0: 38 super(PopupDateField, self).__init__() 39 elif nargs == 1: 40 if isinstance(args[0], IProperty): 41 dataSource, = args 42 super(PopupDateField, self).__init__(dataSource) 43 else: 44 caption, = args 45 super(PopupDateField, self).__init__(caption) 46 elif nargs == 2: 47 if isinstance(args[1], IProperty): 48 caption, dataSource = args 49 super(PopupDateField, self).__init__(caption, dataSource) 50 else: 51 caption, value = args 52 super(PopupDateField, self).__init__(caption, value) 53 else: 54 raise ValueError, 'too many arguments'
55 56
57 - def paintContent(self, target):
58 super(PopupDateField, self).paintContent(target) 59 if self._inputPrompt is not None: 60 target.addAttribute('prompt', self._inputPrompt)
61 62
63 - def getInputPrompt(self):
64 """Gets the current input prompt. 65 66 @see: L{setInputPrompt} 67 @return: the current input prompt, or null if not enabled 68 """ 69 return self._inputPrompt
70 71
72 - def setInputPrompt(self, inputPrompt):
73 """Sets the input prompt - a textual prompt that is displayed when 74 the field would otherwise be empty, to prompt the user for input. 75 """ 76 self._inputPrompt = inputPrompt 77 self.requestRepaint()
78