| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.uruma.renderer.impl; |
| 17 | |
|
| 18 | |
import org.eclipse.swt.widgets.Composite; |
| 19 | |
import org.eclipse.swt.widgets.Layout; |
| 20 | |
import org.seasar.framework.beans.BeanDesc; |
| 21 | |
import org.seasar.framework.beans.PropertyDesc; |
| 22 | |
import org.seasar.framework.beans.factory.BeanDescFactory; |
| 23 | |
import org.seasar.uruma.component.CommonAttributes; |
| 24 | |
import org.seasar.uruma.component.LayoutInfo; |
| 25 | |
import org.seasar.uruma.component.UIComponent; |
| 26 | |
import org.seasar.uruma.component.UICompositeComponent; |
| 27 | |
import org.seasar.uruma.component.jface.CompositeComponent; |
| 28 | |
import org.seasar.uruma.renderer.layout.LayoutSupport; |
| 29 | |
import org.seasar.uruma.renderer.layout.LayoutSupportFactory; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | 944 | public abstract class AbstractCompositeRenderer<COMPONENT_TYPE extends CompositeComponent, COMPOSITE_TYPE extends Composite> |
| 46 | |
extends AbstractControlRenderer<COMPONENT_TYPE, COMPOSITE_TYPE> { |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
abstract protected void doRenderComposite( |
| 60 | |
COMPONENT_TYPE compositeComponent, COMPOSITE_TYPE composite); |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
@Override |
| 66 | |
protected void inherit(final COMPONENT_TYPE uiComponent) { |
| 67 | 452 | super.inherit(uiComponent); |
| 68 | 452 | inheritCommonAttributes(uiComponent); |
| 69 | 452 | } |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
@Override |
| 76 | |
protected final void doRenderControl( |
| 77 | |
final COMPONENT_TYPE compositeComponent, |
| 78 | |
final COMPOSITE_TYPE control) { |
| 79 | 452 | setLayout(compositeComponent, control); |
| 80 | |
|
| 81 | 452 | doRenderComposite(compositeComponent, control); |
| 82 | 452 | } |
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
@SuppressWarnings("unchecked") |
| 95 | |
protected void setLayout(final COMPONENT_TYPE compositeComponent, |
| 96 | |
final COMPOSITE_TYPE control) { |
| 97 | 452 | LayoutInfo<?> layoutInfo = compositeComponent.getLayoutInfo(); |
| 98 | 452 | if (layoutInfo != null) { |
| 99 | 360 | LayoutSupport layoutSupport = LayoutSupportFactory |
| 100 | |
.getLayoutSupport((Class<? extends LayoutInfo<?>>) layoutInfo |
| 101 | |
.getClass()); |
| 102 | 360 | Layout layout = layoutSupport.createLayout(compositeComponent |
| 103 | |
.getLayoutInfo()); |
| 104 | 360 | control.setLayout(layout); |
| 105 | |
} |
| 106 | 452 | } |
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
protected void inheritCommonAttributes( |
| 115 | |
final COMPONENT_TYPE compositeComponent) { |
| 116 | 452 | UIComponent parent = compositeComponent.getParent(); |
| 117 | 452 | if (parent == null) { |
| 118 | 112 | return; |
| 119 | |
} |
| 120 | |
|
| 121 | 340 | if (!(parent instanceof UICompositeComponent)) { |
| 122 | 0 | return; |
| 123 | |
} |
| 124 | |
|
| 125 | 340 | CommonAttributes parentAttributes = ((UICompositeComponent) parent) |
| 126 | |
.getCommonAttributes(); |
| 127 | 340 | if (parentAttributes == null) { |
| 128 | 224 | return; |
| 129 | |
} |
| 130 | |
|
| 131 | 116 | CommonAttributes commonAttributes = compositeComponent |
| 132 | |
.getCommonAttributes(); |
| 133 | 116 | if (commonAttributes == null) { |
| 134 | 116 | compositeComponent.setCommonAttributes(parentAttributes); |
| 135 | |
} else { |
| 136 | 0 | BeanDesc desc = BeanDescFactory.getBeanDesc(commonAttributes |
| 137 | |
.getClass()); |
| 138 | 0 | int size = desc.getPropertyDescSize(); |
| 139 | 0 | for (int i = 0; i < size; i++) { |
| 140 | 0 | PropertyDesc pd = desc.getPropertyDesc(i); |
| 141 | 0 | if (pd.getValue(commonAttributes) == null) { |
| 142 | 0 | Object value = pd.getValue(parentAttributes); |
| 143 | 0 | pd.setValue(commonAttributes, value); |
| 144 | |
} |
| 145 | |
} |
| 146 | |
} |
| 147 | 116 | } |
| 148 | |
} |