1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.devacfr.maven.skins.reflow.model;
20
21 import javax.annotation.Nonnull;
22
23 import java.util.List;
24 import java.util.Objects;
25
26 import com.google.common.collect.Lists;
27 import org.devacfr.maven.skins.reflow.ISkinConfig;
28
29
30
31
32
33 public class MenuItem {
34
35
36 private final String name;
37
38
39 private final String description;
40
41
42 private final String alt;
43
44
45 private final String border;
46
47
48 private final String height;
49
50
51 private final String width;
52
53
54 private final String href;
55
56
57 private final String image;
58
59
60 private final String position;
61
62
63 private final String target;
64
65
66 private final String title;
67
68
69 private final String inherit;
70
71
72 private final boolean active;
73
74
75 private final List<MenuItem> menuItems = Lists.newArrayList();
76
77
78
79
80
81
82
83
84
85 public MenuItem(@Nonnull final ISkinConfig config, final org.apache.maven.doxia.site.MenuItem item) {
86 Objects.requireNonNull(item);
87 this.alt = item.getAlt();
88 this.description = item.getDescription();
89 this.border = item.getBorder();
90 this.height = item.getHeight();
91 this.width = item.getWidth();
92 this.href = config.relativeLink(item.getHref());
93 this.image = item.getImg();
94 this.name = item.getName();
95 this.position = item.getPosition();
96 this.target = item.getTarget();
97 this.title = item.getTitle();
98 this.active = config.isActiveLink(this.href);
99 this.inherit = null;
100 recurciveAddItem(config, this.menuItems, item.getItems());
101 }
102
103
104
105
106 private void recurciveAddItem(final ISkinConfig config,
107 final List<MenuItem> menuItems,
108 final List<org.apache.maven.doxia.site.MenuItem> origMenuItems) {
109 if (origMenuItems == null) {
110 return;
111 }
112 for (final org.apache.maven.doxia.site.MenuItem menuItem : origMenuItems) {
113 menuItems.add(new MenuItem(config, menuItem));
114 }
115 }
116
117
118
119
120 public String getName() {
121 return name;
122 }
123
124
125
126
127 public List<MenuItem> getMenuItems() {
128 return menuItems;
129 }
130
131
132
133
134 public String getDescription() {
135 return description;
136 }
137
138
139
140
141 public String getInherit() {
142 return inherit;
143 }
144
145
146
147
148 public boolean isActive() {
149 boolean active = this.active;
150 if (active) {
151 return active;
152 }
153 for (final MenuItem menuItem : menuItems) {
154 active = menuItem.isActive();
155 if (active) {
156 break;
157 }
158 }
159 return active;
160 }
161
162
163
164
165 public String getAlt() {
166 return alt;
167 }
168
169
170
171
172 public String getBorder() {
173 return border;
174 }
175
176
177
178
179 public String getHeight() {
180 return height;
181 }
182
183
184
185
186 public String getHref() {
187 return href;
188 }
189
190
191
192
193 public String getImage() {
194 return image;
195 }
196
197
198
199
200 public String getPosition() {
201 return position;
202 }
203
204
205
206
207 public String getTarget() {
208 return target;
209 }
210
211
212
213
214 public String getTitle() {
215 return title;
216 }
217
218
219
220
221 public String getWidth() {
222 return width;
223 }
224 }