1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
package org.apache.tapestry.components; |
16 |
|
|
17 |
|
import java.util.ArrayList; |
18 |
|
import java.util.Collections; |
19 |
|
import java.util.HashMap; |
20 |
|
import java.util.Iterator; |
21 |
|
import java.util.List; |
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import org.apache.hivemind.ApplicationRuntimeException; |
25 |
|
import org.apache.hivemind.HiveMind; |
26 |
|
import org.apache.tapestry.IBinding; |
27 |
|
import org.apache.tapestry.IForm; |
28 |
|
import org.apache.tapestry.IMarkupWriter; |
29 |
|
import org.apache.tapestry.IRequestCycle; |
30 |
|
import org.apache.tapestry.Tapestry; |
31 |
|
import org.apache.tapestry.TapestryUtils; |
32 |
|
import org.apache.tapestry.coerce.ValueConverter; |
33 |
|
import org.apache.tapestry.engine.NullWriter; |
34 |
|
import org.apache.tapestry.form.AbstractFormComponent; |
35 |
|
import org.apache.tapestry.markup.NestedMarkupWriterImpl; |
36 |
|
import org.apache.tapestry.services.ComponentRenderWorker; |
37 |
|
import org.apache.tapestry.services.DataSqueezer; |
38 |
|
import org.apache.tapestry.services.ExpressionEvaluator; |
39 |
|
import org.apache.tapestry.services.ResponseBuilder; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
3 |
public abstract class ForBean extends AbstractFormComponent |
48 |
|
{ |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private static final char DESC_VALUE = 'V'; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
private static final char DESC_PRIMARY_KEY = 'P'; |
65 |
|
|
66 |
3 |
private final RepSource _completeRepSource = new CompleteRepSource(); |
67 |
|
|
68 |
3 |
private final RepSource _keyExpressionRepSource = new KeyExpressionRepSource(); |
69 |
|
|
70 |
|
|
71 |
|
private Object _value; |
72 |
|
|
73 |
|
private int _index; |
74 |
|
|
75 |
|
private boolean _rendering; |
76 |
|
|
77 |
3 |
private boolean _hasNext = false; |
78 |
|
|
79 |
|
|
80 |
|
public abstract boolean getRenderTag(); |
81 |
|
|
82 |
|
public abstract String getElement(); |
83 |
|
|
84 |
|
public abstract String getKeyExpression(); |
85 |
|
|
86 |
|
public abstract IPrimaryKeyConverter getConverter(); |
87 |
|
|
88 |
|
public abstract Object getDefaultValue(); |
89 |
|
|
90 |
|
public abstract boolean getMatch(); |
91 |
|
|
92 |
|
public abstract boolean getVolatile(); |
93 |
|
|
94 |
|
|
95 |
|
public abstract DataSqueezer getDataSqueezer(); |
96 |
|
|
97 |
|
public abstract ValueConverter getValueConverter(); |
98 |
|
|
99 |
|
public abstract ExpressionEvaluator getExpressionEvaluator(); |
100 |
|
|
101 |
|
public abstract ComponentRenderWorker getRenderWorker(); |
102 |
|
|
103 |
|
public abstract ResponseBuilder getResponseBuilder(); |
104 |
|
|
105 |
|
public boolean hasNext() |
106 |
|
{ |
107 |
0 |
return _hasNext; |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
115 |
|
{ |
116 |
|
|
117 |
3 |
IForm form = (IForm) cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE); |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
3 |
boolean cycleRewinding = cycle.isRewinding(); |
123 |
3 |
if (cycleRewinding && form != null && !form.isRewinding()) |
124 |
0 |
return; |
125 |
|
|
126 |
3 |
setForm(form); |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
3 |
Iterator dataSource = getData(cycle, form); |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
3 |
if (dataSource == null) |
136 |
0 |
return; |
137 |
|
|
138 |
5 |
if (!cycleRewinding && form != null && !NullWriter.class.isInstance(writer)) |
139 |
1 |
form.setFormFieldUpdating(true); |
140 |
|
|
141 |
3 |
String element = HiveMind.isNonBlank(getElement()) ? getElement() : getTemplateTagName(); |
142 |
|
|
143 |
3 |
boolean render = !cycleRewinding && HiveMind.isNonBlank(element) && getRenderTag(); |
144 |
|
|
145 |
3 |
IMarkupWriter loopWriter = writer; |
146 |
|
|
147 |
|
|
148 |
|
try |
149 |
|
{ |
150 |
3 |
_index = 0; |
151 |
3 |
_rendering = true; |
152 |
|
|
153 |
7 |
while (dataSource.hasNext()) |
154 |
|
{ |
155 |
5 |
_hasNext = true; |
156 |
|
|
157 |
|
|
158 |
5 |
_value = dataSource.next(); |
159 |
|
|
160 |
|
|
161 |
4 |
updateOutputParameters(); |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
4 |
if (getResponseBuilder().isDynamic() |
167 |
|
&& getResponseBuilder().contains(this) |
168 |
|
&& !NestedMarkupWriterImpl.class.isInstance(writer)) { |
169 |
|
|
170 |
0 |
loopWriter = getResponseBuilder().getWriter(getClientId(), ResponseBuilder.ELEMENT_TYPE); |
171 |
|
} |
172 |
|
|
173 |
4 |
if (render) { |
174 |
|
|
175 |
2 |
loopWriter.begin(element); |
176 |
|
|
177 |
2 |
renderInformalParameters(loopWriter, cycle); |
178 |
2 |
renderIdAttribute(loopWriter, cycle); |
179 |
|
} |
180 |
|
|
181 |
4 |
renderBody(loopWriter, cycle); |
182 |
|
|
183 |
4 |
if (render) { |
184 |
|
|
185 |
2 |
loopWriter.end(element); |
186 |
|
} |
187 |
|
|
188 |
4 |
_index++; |
189 |
|
|
190 |
4 |
_hasNext = dataSource.hasNext(); |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
4 |
getRenderWorker().renderComponent(cycle, this); |
200 |
4 |
generateClientId(); |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
4 |
loopWriter = writer; |
205 |
|
} |
206 |
|
} |
207 |
|
finally |
208 |
|
{ |
209 |
3 |
_rendering = false; |
210 |
3 |
_value = null; |
211 |
2 |
} |
212 |
2 |
} |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
protected void cleanupAfterRender(IRequestCycle cycle) |
219 |
|
{ |
220 |
3 |
} |
221 |
|
|
222 |
|
protected void generateClientId() |
223 |
|
{ |
224 |
7 |
String id = getSpecifiedId(); |
225 |
|
|
226 |
7 |
if (id != null && getPage() != null && getPage().getRequestCycle() != null) |
227 |
0 |
setClientId(getPage().getRequestCycle().getUniqueId(TapestryUtils.convertTapestryIdToNMToken(id))); |
228 |
7 |
} |
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
public final Object getValue() |
236 |
|
{ |
237 |
0 |
if (!_rendering) |
238 |
0 |
throw Tapestry.createRenderOnlyPropertyException(this, "value"); |
239 |
|
|
240 |
0 |
return _value; |
241 |
|
} |
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
public int getIndex() |
249 |
|
{ |
250 |
0 |
if (!_rendering) |
251 |
0 |
throw Tapestry.createRenderOnlyPropertyException(this, "index"); |
252 |
|
|
253 |
0 |
return _index; |
254 |
|
} |
255 |
|
|
256 |
|
public boolean isDisabled() |
257 |
|
{ |
258 |
0 |
return false; |
259 |
|
} |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
protected void updateOutputParameters() |
265 |
|
{ |
266 |
4 |
IBinding indexBinding = getBinding("index"); |
267 |
4 |
if (indexBinding != null) |
268 |
0 |
indexBinding.setObject(new Integer(_index)); |
269 |
|
|
270 |
4 |
IBinding valueBinding = getBinding("value"); |
271 |
4 |
if (valueBinding != null) |
272 |
0 |
valueBinding.setObject(_value); |
273 |
4 |
} |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
protected void updatePrimaryKeysParameter(String[] stringReps) |
279 |
|
{ |
280 |
1 |
IBinding primaryKeysBinding = getBinding("primaryKeys"); |
281 |
1 |
if (primaryKeysBinding == null) |
282 |
1 |
return; |
283 |
|
|
284 |
0 |
DataSqueezer squeezer = getDataSqueezer(); |
285 |
|
|
286 |
0 |
int repsCount = stringReps.length; |
287 |
0 |
List primaryKeys = new ArrayList(repsCount); |
288 |
0 |
for (int i = 0; i < stringReps.length; i++) |
289 |
|
{ |
290 |
0 |
String rep = stringReps[i]; |
291 |
0 |
if (rep.length() == 0 || rep.charAt(0) != DESC_PRIMARY_KEY) |
292 |
0 |
continue; |
293 |
0 |
Object primaryKey = squeezer.unsqueeze(rep.substring(1)); |
294 |
0 |
primaryKeys.add(primaryKey); |
295 |
|
} |
296 |
|
|
297 |
0 |
primaryKeysBinding.setObject(primaryKeys); |
298 |
0 |
} |
299 |
|
|
300 |
|
|
301 |
|
protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) |
302 |
|
{ |
303 |
0 |
} |
304 |
|
|
305 |
|
protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) |
306 |
|
{ |
307 |
0 |
} |
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
private Iterator getData(IRequestCycle cycle, IForm form) |
324 |
|
{ |
325 |
3 |
if (form == null || getVolatile()) |
326 |
1 |
return evaluateSourceIterator(); |
327 |
|
|
328 |
2 |
String name = form.getElementId(this); |
329 |
|
|
330 |
2 |
if (cycle.isRewinding()) |
331 |
1 |
return getStoredData(cycle, name); |
332 |
|
|
333 |
1 |
return storeSourceData(form, name); |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
|
protected Iterator getStoredData(IRequestCycle cycle, String name) |
347 |
|
{ |
348 |
1 |
String[] stringReps = cycle.getParameters(name); |
349 |
1 |
if (stringReps == null) |
350 |
0 |
return null; |
351 |
|
|
352 |
1 |
updatePrimaryKeysParameter(stringReps); |
353 |
|
|
354 |
1 |
return new ReadSourceDataIterator(stringReps); |
355 |
|
} |
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
private class ReadSourceDataIterator implements Iterator |
362 |
|
{ |
363 |
1 |
private final Iterator _sourceIterator = evaluateSourceIterator(); |
364 |
|
|
365 |
1 |
private final Iterator _fullSourceIterator = evaluateFullSourceIterator(); |
366 |
|
|
367 |
|
private final String[] _stringReps; |
368 |
|
|
369 |
1 |
private int _index = 0; |
370 |
|
|
371 |
1 |
private final Map _repToValueMap = new HashMap(); |
372 |
|
|
373 |
|
ReadSourceDataIterator(String[] stringReps) |
374 |
1 |
{ |
375 |
1 |
_stringReps = stringReps; |
376 |
1 |
} |
377 |
|
|
378 |
|
public boolean hasNext() |
379 |
|
{ |
380 |
5 |
return _index < _stringReps.length; |
381 |
|
} |
382 |
|
|
383 |
|
public Object next() |
384 |
|
{ |
385 |
2 |
String rep = _stringReps[_index++]; |
386 |
|
|
387 |
2 |
return getValueFromStringRep(_sourceIterator, _fullSourceIterator, _repToValueMap, rep); |
388 |
|
} |
389 |
|
|
390 |
|
public void remove() |
391 |
|
{ |
392 |
0 |
throw new UnsupportedOperationException("remove()"); |
393 |
|
} |
394 |
|
|
395 |
|
} |
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
protected Iterator storeSourceData(IForm form, String name) |
408 |
|
{ |
409 |
1 |
return new StoreSourceDataIterator(form, name, evaluateSourceIterator()); |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
private class StoreSourceDataIterator implements Iterator |
418 |
|
{ |
419 |
|
private final IForm _form; |
420 |
|
|
421 |
|
private final String _name; |
422 |
|
|
423 |
|
private final Iterator _delegate; |
424 |
|
|
425 |
|
StoreSourceDataIterator(IForm form, String name, Iterator delegate) |
426 |
1 |
{ |
427 |
1 |
_form = form; |
428 |
1 |
_name = name; |
429 |
1 |
_delegate = delegate; |
430 |
1 |
} |
431 |
|
|
432 |
|
public boolean hasNext() |
433 |
|
{ |
434 |
1 |
return _delegate.hasNext(); |
435 |
|
} |
436 |
|
|
437 |
|
public Object next() |
438 |
|
{ |
439 |
1 |
Object value = _delegate.next(); |
440 |
|
|
441 |
|
|
442 |
|
|
443 |
1 |
String rep = getStringRepFromValue(value); |
444 |
|
|
445 |
0 |
_form.addHiddenValue(_name, rep); |
446 |
|
|
447 |
0 |
return value; |
448 |
|
} |
449 |
|
|
450 |
|
public void remove() |
451 |
|
{ |
452 |
0 |
throw new UnsupportedOperationException("remove()"); |
453 |
|
} |
454 |
|
} |
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
protected String getStringRepFromValue(Object value) |
464 |
|
{ |
465 |
|
String rep; |
466 |
|
|
467 |
1 |
DataSqueezer squeezer = getDataSqueezer(); |
468 |
|
|
469 |
|
|
470 |
|
|
471 |
1 |
Object pk = getPrimaryKeyFromValue(value); |
472 |
|
|
473 |
|
try { |
474 |
|
|
475 |
1 |
if (pk != null) { |
476 |
|
|
477 |
|
|
478 |
0 |
rep = DESC_PRIMARY_KEY + squeezer.squeeze(pk); |
479 |
|
} else { |
480 |
|
|
481 |
|
|
482 |
1 |
rep = DESC_VALUE + squeezer.squeeze(value); |
483 |
|
} |
484 |
|
|
485 |
1 |
} catch (Exception e) { |
486 |
1 |
throw new ApplicationRuntimeException(ComponentMessages.keySqueezeError(this, value, e), this, getLocation(), e); |
487 |
0 |
} |
488 |
|
|
489 |
0 |
return rep; |
490 |
|
} |
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
protected Object getPrimaryKeyFromValue(Object value) |
501 |
|
{ |
502 |
1 |
if (value == null) |
503 |
0 |
return null; |
504 |
|
|
505 |
1 |
Object primaryKey = getKeyExpressionFromValue(value); |
506 |
|
|
507 |
1 |
if (primaryKey == null) |
508 |
1 |
primaryKey = getConverterFromValue(value); |
509 |
|
|
510 |
1 |
return primaryKey; |
511 |
|
} |
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
protected Object getKeyExpressionFromValue(Object value) |
522 |
|
{ |
523 |
1 |
String keyExpression = getKeyExpression(); |
524 |
1 |
if (keyExpression == null) |
525 |
1 |
return null; |
526 |
|
|
527 |
0 |
Object primaryKey = getExpressionEvaluator().read(value, keyExpression); |
528 |
0 |
return primaryKey; |
529 |
|
} |
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
protected Object getConverterFromValue(Object value) |
540 |
|
{ |
541 |
1 |
IPrimaryKeyConverter converter = getConverter(); |
542 |
1 |
if (converter == null) |
543 |
1 |
return null; |
544 |
|
|
545 |
0 |
Object primaryKey = converter.getPrimaryKey(value); |
546 |
|
|
547 |
0 |
return primaryKey; |
548 |
|
} |
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
|
558 |
|
|
559 |
|
protected Object getValueFromStringRep(Iterator sourceIterator, Iterator fullSourceIterator, |
560 |
|
Map repToValueMap, String rep) |
561 |
|
{ |
562 |
2 |
Object value = null; |
563 |
2 |
DataSqueezer squeezer = getDataSqueezer(); |
564 |
|
|
565 |
|
|
566 |
2 |
if (rep == null || rep.length() == 0) |
567 |
0 |
return getDefaultValue(); |
568 |
|
|
569 |
|
|
570 |
2 |
boolean match = getMatch(); |
571 |
2 |
if (match) |
572 |
|
{ |
573 |
0 |
value = findValueWithStringRep( sourceIterator, fullSourceIterator, repToValueMap, |
574 |
|
rep, _completeRepSource); |
575 |
|
|
576 |
0 |
if (value != null) |
577 |
0 |
return value; |
578 |
|
} |
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
2 |
char desc = rep.charAt(0); |
584 |
2 |
String squeezed = rep.substring(1); |
585 |
2 |
switch (desc) |
586 |
|
{ |
587 |
|
case DESC_VALUE: |
588 |
|
|
589 |
0 |
value = squeezer.unsqueeze(squeezed); |
590 |
0 |
break; |
591 |
|
|
592 |
|
case DESC_PRIMARY_KEY: |
593 |
|
|
594 |
0 |
if (!match && getKeyExpression() != null) |
595 |
0 |
value = findValueWithStringRep( |
596 |
|
sourceIterator, |
597 |
|
fullSourceIterator, |
598 |
|
repToValueMap, |
599 |
|
rep, |
600 |
|
_keyExpressionRepSource); |
601 |
|
|
602 |
|
|
603 |
0 |
if (value == null) |
604 |
|
{ |
605 |
0 |
IPrimaryKeyConverter converter = getConverter(); |
606 |
0 |
if (converter != null) |
607 |
|
{ |
608 |
0 |
Object pk = squeezer.unsqueeze(squeezed); |
609 |
0 |
value = converter.getValue(pk); |
610 |
|
} |
611 |
|
} |
612 |
|
break; |
613 |
|
} |
614 |
|
|
615 |
2 |
if (value == null) |
616 |
2 |
value = getDefaultValue(); |
617 |
|
|
618 |
2 |
return value; |
619 |
|
} |
620 |
|
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
|
632 |
|
|
633 |
|
protected Object findValueWithStringRep(Iterator sourceIterator, Iterator fullSourceIterator, |
634 |
|
Map repToValueMap, String rep, RepSource repSource) |
635 |
|
{ |
636 |
0 |
Object value = repToValueMap.get(rep); |
637 |
0 |
if (value != null) |
638 |
0 |
return value; |
639 |
|
|
640 |
0 |
value = findValueWithStringRepInIterator(sourceIterator, repToValueMap, rep, repSource); |
641 |
0 |
if (value != null) |
642 |
0 |
return value; |
643 |
|
|
644 |
0 |
value = findValueWithStringRepInIterator(fullSourceIterator, repToValueMap, rep, repSource); |
645 |
0 |
return value; |
646 |
|
} |
647 |
|
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
|
656 |
|
|
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
protected Object findValueWithStringRepInIterator(Iterator it, Map repToValueMap, String rep, |
663 |
|
RepSource repSource) |
664 |
|
{ |
665 |
0 |
while (it.hasNext()) |
666 |
|
{ |
667 |
0 |
Object sourceValue = it.next(); |
668 |
0 |
if (sourceValue == null) |
669 |
0 |
continue; |
670 |
|
|
671 |
0 |
String sourceRep = repSource.getStringRep(sourceValue); |
672 |
0 |
repToValueMap.put(sourceRep, sourceValue); |
673 |
|
|
674 |
0 |
if (rep.equals(sourceRep)) |
675 |
0 |
return sourceValue; |
676 |
0 |
} |
677 |
|
|
678 |
0 |
return null; |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
protected Iterator evaluateSourceIterator() |
687 |
|
{ |
688 |
3 |
Iterator it = null; |
689 |
3 |
Object source = null; |
690 |
|
|
691 |
3 |
IBinding sourceBinding = getBinding("source"); |
692 |
3 |
if (sourceBinding != null) |
693 |
3 |
source = sourceBinding.getObject(); |
694 |
|
|
695 |
3 |
if (source != null) |
696 |
3 |
it = (Iterator) getValueConverter().coerceValue(source, Iterator.class); |
697 |
|
|
698 |
3 |
if (it == null) |
699 |
0 |
it = Collections.EMPTY_LIST.iterator(); |
700 |
|
|
701 |
3 |
return it; |
702 |
|
} |
703 |
|
|
704 |
|
|
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
|
709 |
|
protected Iterator evaluateFullSourceIterator() |
710 |
|
{ |
711 |
1 |
Iterator it = null; |
712 |
1 |
Object fullSource = null; |
713 |
|
|
714 |
1 |
IBinding fullSourceBinding = getBinding("fullSource"); |
715 |
1 |
if (fullSourceBinding != null) |
716 |
0 |
fullSource = fullSourceBinding.getObject(); |
717 |
|
|
718 |
1 |
if (fullSource != null) |
719 |
0 |
it = (Iterator) getValueConverter().coerceValue(fullSource, Iterator.class); |
720 |
|
|
721 |
1 |
if (it == null) |
722 |
1 |
it = Collections.EMPTY_LIST.iterator(); |
723 |
|
|
724 |
1 |
return it; |
725 |
|
} |
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
protected interface RepSource |
731 |
|
{ |
732 |
|
String getStringRep(Object value); |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
|
739 |
3 |
protected class CompleteRepSource implements RepSource |
740 |
|
{ |
741 |
|
public String getStringRep(Object value) |
742 |
|
{ |
743 |
0 |
return getStringRepFromValue(value); |
744 |
|
} |
745 |
|
} |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
750 |
|
|
751 |
3 |
protected class KeyExpressionRepSource implements RepSource |
752 |
|
{ |
753 |
|
public String getStringRep(Object value) |
754 |
|
{ |
755 |
0 |
Object pk = getKeyExpressionFromValue(value); |
756 |
0 |
return DESC_PRIMARY_KEY + getDataSqueezer().squeeze(pk); |
757 |
|
} |
758 |
|
} |
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
|
protected boolean getCanTakeFocus() |
764 |
|
{ |
765 |
0 |
return false; |
766 |
|
} |
767 |
|
|
768 |
|
public String getDisplayName() |
769 |
|
{ |
770 |
0 |
return null; |
771 |
|
} |
772 |
|
|
773 |
|
} |