1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.component.rcp;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.eclipse.swt.SWT;
22 import org.seasar.uruma.component.UIElement;
23 import org.seasar.uruma.component.base.AbstractUIContainer;
24 import org.seasar.uruma.component.jface.MenuComponent;
25
26
27
28
29
30
31 public class WorkbenchComponent extends AbstractUIContainer {
32
33
34
35 public String id;
36
37
38
39
40 public String title;
41
42
43
44
45 public String image;
46
47
48
49
50
51
52 public String style;
53
54
55
56
57 public String initWidth;
58
59
60
61
62 public String initHeight;
63
64
65
66
67 public String menu;
68
69
70
71
72 public String statusLine;
73
74
75
76
77 public String initialPerspectiveId;
78
79
80
81
82 public String saveAndRestore;
83
84
85
86
87 public String menuBar;
88
89
90
91
92 public String coolBar;
93
94
95
96
97 public String fastViewBars;
98
99
100
101
102 public String perspectiveBar;
103
104
105
106
107 public String progressIndicator;
108
109
110
111
112
113
114
115
116 public PerspectiveComponent findPerspective(final String rowId) {
117 if (rowId == null) {
118 return null;
119 }
120
121 for (UIElement element : children) {
122 if (element instanceof PerspectiveComponent) {
123 if (rowId.equals(((PerspectiveComponent) element).id)) {
124 return (PerspectiveComponent) element;
125 }
126 }
127 }
128
129 return null;
130 }
131
132
133
134
135
136
137 public List<PerspectiveComponent> getPerspectives() {
138 return getElements(PerspectiveComponent.class);
139 }
140
141
142
143
144
145
146 public List<MenuComponent> getMenus() {
147 return getElements(MenuComponent.class);
148 }
149
150 protected <E> List<E> getElements(final Class<E> clazz) {
151 List<E> result = new ArrayList<E>(children.size());
152
153 for (UIElement element : children) {
154 if (clazz.isAssignableFrom(element.getClass())) {
155 result.add(clazz.cast(element));
156 }
157 }
158
159 return result;
160 }
161 }