1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Defines a component that shows user state of a process."""
17
18 from muntjac.data.util.object_property import ObjectProperty
19 from muntjac.ui.abstract_field import AbstractField
20
21 from muntjac.data import property as prop
22
23
24 -class ProgressIndicator(AbstractField, prop.IValueChangeListener,
25 prop.IProperty, prop.IViewer):
26 """C{ProgressIndicator} is component that shows user state of
27 a process (like long computing or file upload)
28
29 C{ProgressIndicator} has two mainmodes. One for indeterminate processes
30 and other (default) for processes which progress can be measured.
31
32 May view an other property that indicates progress 0...1
33
34 @author: Vaadin Ltd.
35 @author: Richard Lincoln
36 @version: 1.1.2
37 """
38
39 CLIENT_WIDGET = None
40
41
42
43 CONTENT_TEXT = 0
44
45
46 CONTENT_PREFORMATTED = 1
47
48
75
76
78 """Sets the component to read-only. Readonly is not used in
79 ProgressIndicator.
80
81 @param readOnly:
82 True to enable read-only mode, False to disable it.
83 """
84 if self._dataSource is None:
85 raise ValueError, 'datasource must be set'
86
87 self._dataSource.setReadOnly(readOnly)
88
89
91 """Is the component read-only ? Readonly is not used in
92 ProgressIndicator - this returns allways false.
93
94 @return: True if the component is in read only mode.
95 """
96 if self._dataSource is None:
97 raise ValueError, 'datasource must be set'
98
99 return self._dataSource.isReadOnly()
100
101
102 - def paintContent(self, target):
103 """Paints the content of this component.
104
105 @param target:
106 the Paint Event.
107 @raise PaintException:
108 if the Paint Operation fails.
109 """
110 target.addAttribute('indeterminate', self._indeterminate)
111 target.addAttribute('pollinginterval', self._pollingInterval)
112 target.addAttribute('state', str(self.getValue()))
113
114
116 """Gets the value of the ProgressIndicator. Value of the
117 ProgressIndicator is a float between 0 and 1.
118
119 @return: the Value of the ProgressIndicator.
120 @see: L{AbstractField.getValue}
121 """
122 if self._dataSource is None:
123 raise ValueError, 'datasource must be set'
124
125 return self._dataSource.getValue()
126
127
128 - def setValue(self, newValue, repaintIsNotNeeded=None):
129 """Sets the value of the ProgressIndicator. Value of the
130 ProgressIndicator is the float between 0 and 1.
131
132 @param newValue: the new value of the ProgressIndicator.
133 @see: L{AbstractField.setValue}
134 """
135 if repaintIsNotNeeded is None:
136 if self._dataSource is None:
137 raise ValueError, 'datasource must be set'
138
139 self._dataSource.setValue(newValue)
140 else:
141 super(ProgressIndicator, self).setValue(newValue,
142 repaintIsNotNeeded)
143
144
146 """@see: L{AbstractField.__str__}"""
147 if self._dataSource is None:
148 raise ValueError, 'datasource must be set'
149
150 return str(self._dataSource)
151
152
154 """@see: L{AbstractField.getType}"""
155 if self._dataSource is None:
156 raise ValueError, 'datasource must be set'
157
158 return self._dataSource.getType()
159
160
162 """Gets the viewing data-source property.
163
164 @return: the datasource.
165 @see: L{AbstractField.getPropertyDataSource}
166 """
167 return self._dataSource
168
169
171 """Sets the property as data-source for viewing.
172
173 @param newDataSource:
174 the new data source.
175 @see: L{AbstractField.setPropertyDataSource}
176 """
177
178 if (self._dataSource is not None
179 and issubclass(self._dataSource.__class__,
180 prop.IValueChangeNotifier)):
181 self._dataSource.removeListener(self,
182 prop.IValueChangeListener)
183
184
185 self._dataSource = newDataSource
186
187
188 if (self._dataSource is not None
189 and issubclass(self._dataSource.__class__,
190 prop.IValueChangeNotifier)):
191 self._dataSource.addListener(self, prop.IValueChangeListener)
192
193
194 - def getContentMode(self):
195 """Gets the mode of ProgressIndicator.
196
197 @return: true if in indeterminate mode.
198 """
199 return self._indeterminate
200
201
203 """Sets wheter or not the ProgressIndicator is indeterminate.
204
205 @param newValue:
206 true to set to indeterminate mode.
207 """
208 self._indeterminate = newValue
209 self.requestRepaint()
210
211
213 """Gets whether or not the ProgressIndicator is indeterminate.
214
215 @return: true to set to indeterminate mode.
216 """
217 return self._indeterminate
218
219
221 """Sets the interval that component checks for progress.
222
223 @param newValue:
224 the interval in milliseconds.
225 """
226 self._pollingInterval = newValue
227 self.requestRepaint()
228
229
231 """Gets the interval that component checks for progress.
232
233 @return: the interval in milliseconds.
234 """
235 return self._pollingInterval
236