| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.uruma.component.jface; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.eclipse.swt.widgets.Composite; |
| 22 | |
import org.seasar.uruma.annotation.ComponentElement; |
| 23 | |
import org.seasar.uruma.component.CommonAttributes; |
| 24 | |
import org.seasar.uruma.component.LayoutDataInfo; |
| 25 | |
import org.seasar.uruma.component.LayoutInfo; |
| 26 | |
import org.seasar.uruma.component.UIComponent; |
| 27 | |
import org.seasar.uruma.component.UICompositeComponent; |
| 28 | |
import org.seasar.uruma.component.UIElement; |
| 29 | |
import org.seasar.uruma.component.UIElementVisitor; |
| 30 | |
import org.seasar.uruma.context.PartContext; |
| 31 | |
import org.seasar.uruma.context.WidgetHandle; |
| 32 | |
import org.seasar.uruma.context.WindowContext; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
@ComponentElement |
| 40 | 524 | public class CompositeComponent extends ControlComponent implements |
| 41 | |
UICompositeComponent { |
| 42 | |
private LayoutInfo<?> layoutInfo; |
| 43 | |
|
| 44 | |
private LayoutDataInfo childLayoutDataInfo; |
| 45 | |
|
| 46 | |
private CommonAttributes commonAttributes; |
| 47 | |
|
| 48 | 524 | private List<UIElement> children = new ArrayList<UIElement>(); |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
public LayoutInfo<?> getLayoutInfo() { |
| 54 | 3188 | return this.layoutInfo; |
| 55 | |
} |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
public void setLayoutInfo(final LayoutInfo<?> layoutInfo) { |
| 61 | 368 | this.layoutInfo = layoutInfo; |
| 62 | 368 | } |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
public LayoutDataInfo getChildLayoutDataInfo() { |
| 70 | 0 | return this.childLayoutDataInfo; |
| 71 | |
} |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
public void setChildLayoutDataInfo(final LayoutDataInfo childLayoutDataInfo) { |
| 80 | 0 | this.childLayoutDataInfo = childLayoutDataInfo; |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
public CommonAttributes getCommonAttributes() { |
| 87 | 1644 | return commonAttributes; |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
public void setCommonAttributes(final CommonAttributes commonAttributes) { |
| 94 | 204 | this.commonAttributes = commonAttributes; |
| 95 | 204 | } |
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
public void addChild(final UIElement child) { |
| 101 | 1528 | this.children.add(child); |
| 102 | |
|
| 103 | 1528 | if (child instanceof UIComponent) { |
| 104 | 1528 | ((UIComponent) child).setParent(this); |
| 105 | |
} |
| 106 | 1528 | } |
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
public List<UIElement> getChildren() { |
| 112 | 52 | return children; |
| 113 | |
} |
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
@Override |
| 120 | |
protected void doPreRender(final WidgetHandle parent, |
| 121 | |
final WindowContext context) { |
| 122 | 496 | preRenderChild(context.getWidgetHandle(getId()), context); |
| 123 | 496 | } |
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
@Override |
| 130 | |
protected void doRender(final WidgetHandle parent, final PartContext context) { |
| 131 | 508 | renderChild(context.getWidgetHandle(getId()), context); |
| 132 | 508 | } |
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
@Override |
| 138 | |
public void accept(final UIElementVisitor visitor) { |
| 139 | 0 | visitor.visit(this); |
| 140 | 0 | } |
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
protected void preRenderChild(final WidgetHandle parent, |
| 151 | |
final WindowContext context) { |
| 152 | 496 | for (UIElement child : children) { |
| 153 | 1448 | if (child instanceof UIComponent) { |
| 154 | 1448 | ((UIComponent) child).preRender(parent, context); |
| 155 | |
} |
| 156 | |
} |
| 157 | 496 | } |
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
protected void renderChild(final WidgetHandle parent, |
| 168 | |
final PartContext context) { |
| 169 | 508 | for (UIElement child : children) { |
| 170 | 1472 | if (child instanceof UIComponent) { |
| 171 | 1472 | ((UIComponent) child).render(parent, context); |
| 172 | |
} |
| 173 | |
} |
| 174 | 508 | } |
| 175 | |
} |