| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.apache.tapestry5.internal.services; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.Block; |
| 18 | |
import org.apache.tapestry5.services.BeanBlockContribution; |
| 19 | |
import org.apache.tapestry5.services.BeanBlockOverrideSource; |
| 20 | |
import org.apache.tapestry5.services.BeanBlockSource; |
| 21 | |
|
| 22 | |
import java.util.Collection; |
| 23 | |
|
| 24 | |
public class BeanBlockSourceImpl implements BeanBlockSource |
| 25 | |
{ |
| 26 | |
|
| 27 | |
private final BeanBlockOverrideSource overrideSource; |
| 28 | |
|
| 29 | |
private final BeanBlockOverrideSource masterSource; |
| 30 | |
|
| 31 | |
public BeanBlockSourceImpl(RequestPageCache pageCache, |
| 32 | |
BeanBlockOverrideSource overrideSource, Collection<BeanBlockContribution> configuration) |
| 33 | 18 | { |
| 34 | 18 | this.overrideSource = overrideSource; |
| 35 | 18 | masterSource = new BeanBlockOverrideSourceImpl(pageCache, configuration); |
| 36 | 18 | } |
| 37 | |
|
| 38 | |
public boolean hasDisplayBlock(String datatype) |
| 39 | |
{ |
| 40 | 7386 | return overrideSource.hasDisplayBlock(datatype) || masterSource.hasDisplayBlock(datatype); |
| 41 | |
} |
| 42 | |
|
| 43 | |
public Block getDisplayBlock(String datatype) |
| 44 | |
{ |
| 45 | 316 | Block result = overrideSource.getDisplayBlock(datatype); |
| 46 | |
|
| 47 | 316 | if (result == null) |
| 48 | 310 | result = masterSource.getDisplayBlock(datatype); |
| 49 | |
|
| 50 | 316 | if (result == null) |
| 51 | 2 | throw new RuntimeException(ServicesMessages.noDisplayForDataType(datatype)); |
| 52 | |
|
| 53 | 314 | return result; |
| 54 | |
} |
| 55 | |
|
| 56 | |
public Block getEditBlock(String datatype) |
| 57 | |
{ |
| 58 | 268 | Block result = overrideSource.getEditBlock(datatype); |
| 59 | |
|
| 60 | 268 | if (result == null) |
| 61 | 266 | result = masterSource.getEditBlock(datatype); |
| 62 | |
|
| 63 | 268 | if (result == null) |
| 64 | 2 | throw new RuntimeException(ServicesMessages.noEditForDataType(datatype)); |
| 65 | |
|
| 66 | 266 | return result; |
| 67 | |
} |
| 68 | |
|
| 69 | |
} |