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 java.util.List; |
19 | |
|
20 | |
import org.eclipse.swt.custom.CTabItem; |
21 | |
import org.eclipse.swt.graphics.Font; |
22 | |
import org.eclipse.swt.widgets.Control; |
23 | |
import org.seasar.uruma.component.UIComponent; |
24 | |
import org.seasar.uruma.component.UIElement; |
25 | |
import org.seasar.uruma.component.jface.CTabItemComponent; |
26 | |
import org.seasar.uruma.context.PartContext; |
27 | |
import org.seasar.uruma.context.WidgetHandle; |
28 | |
import org.seasar.uruma.renderer.RendererSupportUtil; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 108 | public class CTabItemRenderer extends |
36 | |
AbstractWidgetRenderer<CTabItemComponent, CTabItem> { |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
@Override |
43 | |
protected void doRender(final CTabItemComponent controlComponent, |
44 | |
final CTabItem control) { |
45 | 52 | setFont(controlComponent, control); |
46 | 52 | } |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
@Override |
55 | |
protected void doRenderAfter(final CTabItem widget, |
56 | |
final CTabItemComponent uiComponent, final WidgetHandle parent, |
57 | |
final PartContext context) { |
58 | 52 | setControl(widget, uiComponent); |
59 | 52 | } |
60 | |
|
61 | |
private void setFont(final CTabItemComponent controlComponent, |
62 | |
final CTabItem control) { |
63 | 52 | if (controlComponent.fontName == null |
64 | |
&& controlComponent.fontStyle == null |
65 | |
&& controlComponent.fontHeight == null) { |
66 | 48 | return; |
67 | |
} |
68 | 4 | Font font = RendererSupportUtil.getFont(control.getFont(), |
69 | |
controlComponent.fontName, controlComponent.fontStyle, |
70 | |
controlComponent.fontHeight); |
71 | 4 | control.setFont(font); |
72 | 4 | } |
73 | |
|
74 | |
private void setControl(final CTabItem tabItem, |
75 | |
final CTabItemComponent tabItemComponent) { |
76 | 52 | List<UIElement> children = tabItemComponent.getChildren(); |
77 | |
|
78 | 52 | for (UIElement child : children) { |
79 | 4 | if (child instanceof UIComponent) { |
80 | 4 | String id = ((UIComponent) child).getId(); |
81 | |
|
82 | 4 | WidgetHandle handle = getContext().getWidgetHandle(id); |
83 | 4 | tabItem.setControl((Control) handle.getWidget()); |
84 | |
|
85 | 4 | break; |
86 | |
} |
87 | |
} |
88 | 52 | } |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
@Override |
94 | |
protected Class<CTabItem> getWidgetType() { |
95 | 156 | return CTabItem.class; |
96 | |
} |
97 | |
} |