| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractUIContainerItemComponent |
|
| 0.0;0 |
| 1 | /* | |
| 2 | * Copyright 2004-2008 the Seasar Foundation and the Others. | |
| 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, | |
| 13 | * either express or implied. See the License for the specific language | |
| 14 | * governing permissions and limitations under the License. | |
| 15 | */ | |
| 16 | package org.seasar.uruma.component.base; | |
| 17 | ||
| 18 | import java.util.ArrayList; | |
| 19 | import java.util.List; | |
| 20 | ||
| 21 | import org.seasar.uruma.component.UIComponent; | |
| 22 | import org.seasar.uruma.component.UIComponentContainer; | |
| 23 | import org.seasar.uruma.component.UIElement; | |
| 24 | import org.seasar.uruma.context.PartContext; | |
| 25 | import org.seasar.uruma.context.WidgetHandle; | |
| 26 | ||
| 27 | /** | |
| 28 | * {@link UIComponentContainer} の子要素を表す基底クラスです。<br /> | |
| 29 | * | |
| 30 | * @author bskuroneko | |
| 31 | */ | |
| 32 | 96 | public abstract class AbstractUIContainerItemComponent extends |
| 33 | AbstractItemComponent implements UIComponentContainer { | |
| 34 | ||
| 35 | 96 | private List<UIElement> children = new ArrayList<UIElement>(); |
| 36 | ||
| 37 | /* | |
| 38 | * @see org.seasar.uruma.component.UIElementContainer#addChild(org.seasar.uruma.component.UIElement) | |
| 39 | */ | |
| 40 | public void addChild(final UIElement child) { | |
| 41 | 32 | children.add(child); |
| 42 | 32 | if (child instanceof UIComponent) { |
| 43 | 32 | ((UIComponent) child).setParent(getParent()); |
| 44 | } | |
| 45 | 32 | } |
| 46 | ||
| 47 | /* | |
| 48 | * @see org.seasar.uruma.component.UIElementContainer#getChildren() | |
| 49 | */ | |
| 50 | public List<UIElement> getChildren() { | |
| 51 | 76 | return children; |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * 子コンポーネントを取得します。<br /> | |
| 56 | * 子コンポーネントが複数存在する場合、最初の一個を返します。 | |
| 57 | * | |
| 58 | * @return 子コンポーネント。存在しない場合は <code>null</code>。 | |
| 59 | */ | |
| 60 | public UIElement getChild() { | |
| 61 | 116 | if (children.size() > 0) { |
| 62 | 36 | return children.get(0); |
| 63 | } else { | |
| 64 | 80 | return null; |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | /* | |
| 69 | * @see org.seasar.uruma.component.jface.AbstractUIComponent#doRender(org.seasar.uruma.context.WidgetHandle, | |
| 70 | * org.seasar.uruma.context.PartContext) | |
| 71 | */ | |
| 72 | @Override | |
| 73 | protected void doRender(final WidgetHandle parent, final PartContext context) { | |
| 74 | 96 | UIElement content = getChild(); |
| 75 | 96 | if ((content != null) && (content instanceof UIComponent)) { |
| 76 | 32 | WidgetHandle parentHandle = context.getWidgetHandle(getParent() |
| 77 | .getId()); | |
| 78 | 32 | ((UIComponent) content).render(parentHandle, context); |
| 79 | } | |
| 80 | 96 | } |
| 81 | } |