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.SWT; |
19 | |
import org.seasar.eclipse.common.util.SWTUtil; |
20 | |
import org.seasar.framework.util.StringUtil; |
21 | |
import org.seasar.uruma.binding.enables.EnablesDependingDef; |
22 | |
import org.seasar.uruma.binding.enables.EnablesForType; |
23 | |
import org.seasar.uruma.component.EnablesDependable; |
24 | |
import org.seasar.uruma.component.UIComponent; |
25 | |
import org.seasar.uruma.context.ContextFactory; |
26 | |
import org.seasar.uruma.context.PartContext; |
27 | |
import org.seasar.uruma.context.WidgetHandle; |
28 | |
import org.seasar.uruma.context.WindowContext; |
29 | |
import org.seasar.uruma.renderer.Renderer; |
30 | |
import org.seasar.uruma.util.AssertionUtil; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 132 | public abstract class AbstractRenderer implements Renderer { |
38 | |
private WindowContext windowContext; |
39 | |
|
40 | |
private PartContext context; |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public WidgetHandle preRender(final UIComponent uiComponent, |
48 | |
final WidgetHandle parent, final WindowContext context) { |
49 | 1544 | setWindowContext(context); |
50 | |
|
51 | 1544 | return null; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public void reRender(final WidgetHandle widget) { |
58 | |
|
59 | 0 | } |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
protected WindowContext getWindowContext() { |
67 | 48 | return this.windowContext; |
68 | |
} |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
protected void setWindowContext(final WindowContext context) { |
77 | 1652 | AssertionUtil.assertNotNull("context", context); |
78 | 1652 | this.windowContext = context; |
79 | 1652 | } |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
protected PartContext getContext() { |
87 | 100 | return this.context; |
88 | |
} |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
protected void setContext(final PartContext context) { |
97 | 1624 | AssertionUtil.assertNotNull("context", context); |
98 | 1624 | this.context = context; |
99 | 1624 | } |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
protected WidgetHandle createWidgetHandle(final UIComponent uiComponent, |
111 | |
final Object widget) { |
112 | 1832 | WidgetHandle handle = ContextFactory.createWidgetHandle(widget); |
113 | 1832 | handle.setUiComponent(uiComponent); |
114 | 1832 | String id = uiComponent.getId(); |
115 | 1832 | if (!StringUtil.isEmpty(id)) { |
116 | 1832 | handle.setId(id); |
117 | |
} |
118 | |
|
119 | 1832 | return handle; |
120 | |
} |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
protected int getStyle(final UIComponent uiComponent) { |
130 | 1736 | return SWTUtil.getStyle(uiComponent.getStyle(), getDefaultStyle()); |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
protected int getDefaultStyle() { |
141 | 920 | return SWT.NONE; |
142 | |
} |
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
protected void setupEnablesDependingDef(final WidgetHandle handle, |
154 | |
final EnablesDependable dependable) { |
155 | 1476 | String enablesDependingId = dependable.getEnablesDependingId(); |
156 | 1476 | String enablesForType = dependable.getEnablesFor(); |
157 | |
|
158 | 1476 | if (!StringUtil.isEmpty(enablesDependingId)) { |
159 | 40 | EnablesForType type = EnablesForType.SELECTION; |
160 | 40 | if (!StringUtil.isEmpty(enablesForType)) { |
161 | 40 | type = EnablesForType.valueOf(enablesForType); |
162 | |
} |
163 | |
|
164 | 40 | EnablesDependingDef def = new EnablesDependingDef(handle, |
165 | |
enablesDependingId, type); |
166 | 40 | getWindowContext().addEnablesDependingDef(def); |
167 | |
} |
168 | 1476 | } |
169 | |
} |