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.Collections; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.eclipse.swt.widgets.TreeItem; |
23 | |
import org.seasar.uruma.annotation.ComponentAttribute; |
24 | |
import org.seasar.uruma.annotation.ComponentElement; |
25 | |
import org.seasar.uruma.annotation.FieldDescription; |
26 | |
import org.seasar.uruma.annotation.RenderingPolicy; |
27 | |
import org.seasar.uruma.annotation.RenderingPolicy.ConversionType; |
28 | |
import org.seasar.uruma.annotation.RenderingPolicy.TargetType; |
29 | |
import org.seasar.uruma.component.base.AbstractUIComponent; |
30 | |
import org.seasar.uruma.context.PartContext; |
31 | |
import org.seasar.uruma.context.WidgetHandle; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
@ComponentElement |
39 | 32 | public class TreeItemComponent extends AbstractUIComponent { |
40 | |
|
41 | |
|
42 | |
|
43 | |
@RenderingPolicy(targetType = TargetType.NONE) |
44 | |
@ComponentAttribute |
45 | |
@FieldDescription("テキスト") |
46 | |
|
47 | |
|
48 | |
public String text; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
@RenderingPolicy(targetType = TargetType.NONE) |
54 | |
@ComponentAttribute |
55 | |
@FieldDescription("イメージ") |
56 | |
|
57 | |
|
58 | |
public String image; |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
@RenderingPolicy(conversionType = ConversionType.COLOR) |
64 | |
@ComponentAttribute |
65 | |
@FieldDescription("背景色") |
66 | |
public String background; |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
@RenderingPolicy(conversionType = ConversionType.BOOLEAN) |
72 | |
@ComponentAttribute |
73 | |
@FieldDescription("チェック状態") |
74 | |
public String checked; |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
@RenderingPolicy(conversionType = ConversionType.BOOLEAN) |
80 | |
@ComponentAttribute |
81 | |
@FieldDescription("展開状態") |
82 | |
public String expanded; |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
@RenderingPolicy(conversionType = ConversionType.INT) |
88 | |
@ComponentAttribute |
89 | |
@FieldDescription("フォント高さ") |
90 | |
public String fontHeight; |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
@RenderingPolicy(conversionType = ConversionType.STRING) |
96 | |
@ComponentAttribute |
97 | |
@FieldDescription("フォント名称") |
98 | |
public String fontName; |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
@RenderingPolicy(conversionType = ConversionType.STRING) |
104 | |
@ComponentAttribute |
105 | |
@FieldDescription("フォントスタイル") |
106 | |
public String fontStyle; |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
@RenderingPolicy(conversionType = ConversionType.COLOR) |
112 | |
@ComponentAttribute |
113 | |
@FieldDescription("前景色") |
114 | |
public String foreground; |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
@RenderingPolicy(conversionType = ConversionType.BOOLEAN) |
120 | |
@ComponentAttribute |
121 | |
@FieldDescription("グレーアウト状態") |
122 | |
public String grayed; |
123 | |
|
124 | |
private TreeItemComponent parent; |
125 | |
|
126 | 32 | private List<TreeItemComponent> children = new ArrayList<TreeItemComponent>(); |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
@Override |
133 | |
protected void doRender(final WidgetHandle parent, final PartContext context) { |
134 | 32 | renderChildren(context.getWidgetHandle(getId()), context); |
135 | 32 | } |
136 | |
|
137 | |
protected void renderChildren(final WidgetHandle parent, |
138 | |
final PartContext context) { |
139 | 32 | for (TreeItemComponent child : children) { |
140 | 24 | child.render(parent, context); |
141 | |
} |
142 | 32 | } |
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
public TreeItemComponent getParentTreeItem() { |
150 | 0 | return this.parent; |
151 | |
} |
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public void setParentTreeItem(final TreeItemComponent parent) { |
160 | 24 | this.parent = parent; |
161 | 24 | } |
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
public void addTreeItem(final TreeItemComponent treeItem) { |
170 | 24 | children.add(treeItem); |
171 | 24 | } |
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public List<TreeItemComponent> getTreeItems() { |
179 | 0 | return Collections.unmodifiableList(this.children); |
180 | |
} |
181 | |
} |