1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.uruma.renderer.layout.impl; |
17 | |
|
18 | |
import org.eclipse.swt.widgets.Layout; |
19 | |
import org.seasar.uruma.annotation.RenderingPolicy.SetTiming; |
20 | |
import org.seasar.uruma.component.LayoutDataInfo; |
21 | |
import org.seasar.uruma.component.LayoutInfo; |
22 | |
import org.seasar.uruma.component.UIComponent; |
23 | |
import org.seasar.uruma.renderer.RendererSupportUtil; |
24 | |
import org.seasar.uruma.renderer.layout.LayoutSupport; |
25 | |
import org.seasar.uruma.util.ClassUtil; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class GenericLayoutSupport implements LayoutSupport { |
33 | |
private Class<? extends Layout> layoutClass; |
34 | |
|
35 | |
private Class<? extends Object> layoutDataClass; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public GenericLayoutSupport(final Class<? extends Layout> layoutClass, |
46 | 12 | final Class<? extends Object> layoutDataClass) { |
47 | 12 | this.layoutClass = layoutClass; |
48 | 12 | this.layoutDataClass = layoutDataClass; |
49 | 12 | } |
50 | |
|
51 | |
public Layout createLayout() { |
52 | 360 | return ClassUtil.newInstance(layoutClass); |
53 | |
} |
54 | |
|
55 | |
public Layout createLayout(final LayoutInfo<?> layoutInfo) { |
56 | 360 | Layout layout = createLayout(); |
57 | 360 | RendererSupportUtil.setAttributes(layoutInfo, layout, SetTiming.RENDER); |
58 | 360 | return layout; |
59 | |
} |
60 | |
|
61 | |
public Object createLayoutData() { |
62 | 596 | if (layoutDataClass != null) { |
63 | 596 | return ClassUtil.newInstance(layoutDataClass); |
64 | |
} else { |
65 | 0 | return null; |
66 | |
} |
67 | |
} |
68 | |
|
69 | |
public Object createLayoutData(final UIComponent uiComponent, |
70 | |
final LayoutDataInfo layoutDataInfo) { |
71 | 596 | if (layoutDataClass != null) { |
72 | 596 | Object layoutData = createLayoutData(); |
73 | 596 | RendererSupportUtil.setAttributes(layoutDataInfo, layoutData, |
74 | |
SetTiming.RENDER); |
75 | 596 | return layoutData; |
76 | |
} else { |
77 | 0 | return null; |
78 | |
} |
79 | |
} |
80 | |
} |