1
2
3
4
5
6
7
8
9
10 package com.sri.emo.wizard.defaults;
11
12 import com.sri.emo.wizard.Link;
13 import com.sri.emo.wizard.PageMetadata;
14
15 import java.io.Serializable;
16
17
18 /***
19 * Wizard Metadata instance.
20 *
21 * @author Michael Rimov
22 */
23 public class EmoWizardMetadata implements PageMetadata, Serializable {
24 /***
25 *
26 */
27 private static final long serialVersionUID = 1L;
28
29 /***
30 * The link to the finish page.
31 */
32 private Link finishLink;
33
34 /***
35 * The link to the next page.
36 */
37 private Link nextLink;
38
39 /***
40 * The link to the previous page.
41 */
42 private Link previousLink;
43
44 /***
45 * The link to the cancel page.
46 */
47 private Link cancelLink;
48
49 /***
50 * The title of the step.
51 */
52 private String title;
53
54 /***
55 * The directive for the step.
56 */
57 private String directive;
58
59 /***
60 * The helptext for the step.
61 */
62 private String helpText;
63
64 /***
65 * Is there any data entry for this page.
66 */
67 private boolean entry;
68
69
70 /***
71 * Is data entry required? Or can it be skipped.
72 */
73 private boolean entryRequired;
74
75 /***
76 * Constructor that takes constructed links.
77 */
78 public EmoWizardMetadata() {
79 nextLink = null;
80 previousLink = null;
81 finishLink = null;
82 cancelLink = null;
83 }
84
85
86 public void setCancelLink(Link cancelLink) {
87 this.cancelLink = cancelLink;
88 }
89
90 public void setFinishLink(Link finishLink) {
91 this.finishLink = finishLink;
92 }
93
94 public void setNextLink(Link nextLink) {
95 this.nextLink = nextLink;
96 }
97
98 public void setPreviousLink(Link previousLink) {
99 this.previousLink = previousLink;
100 }
101
102 public Link getFinish() {
103 return finishLink;
104 }
105
106 public Link getNext() {
107 return nextLink;
108 }
109
110 public Link getPrevious() {
111 return previousLink;
112 }
113
114 public Link getCancel() {
115 return cancelLink;
116 }
117
118 public String getTitle() {
119 return title;
120 }
121
122 public String getDirective() {
123 return directive;
124 }
125
126 public String getHelpText() {
127 return helpText;
128 }
129
130 synchronized public boolean isEntry() {
131 return entry;
132 }
133
134 /***
135 * Sets the directive string.
136 *
137 * @param directive the new value.
138 */
139 public void setDirective(final String directive) {
140 this.directive = directive;
141 }
142
143 /***
144 * Sets the help text.
145 *
146 * @param helpText the new value.
147 */
148 public void setHelpText(final String helpText) {
149 this.helpText = helpText;
150 }
151
152 /***
153 * Sets the title.
154 *
155 * @param title the new value.
156 */
157 public void setTitle(final String title) {
158 this.title = title;
159 }
160
161 /***
162 * True if there is data entry for this page.
163 *
164 * @param entry boolean
165 */
166 public synchronized void setEntry(final boolean entry) {
167 this.entry = entry;
168 }
169
170 /***
171 * Sets whether the data entry is required or not.
172 *
173 * @param entryRequired boolean
174 */
175 public void setEntryRequired(final boolean entryRequired) {
176 this.entryRequired = entryRequired;
177 }
178
179 /***
180 * Override of equals(). This version does not check equality of the links.
181 * <p>{@inheritDoc}</p>
182 *
183 * @param parm1 the other object to check.
184 * @return true if the objects appear equal.
185 */
186 public synchronized boolean equals(final Object parm1) {
187
188 if (parm1 == null) {
189 return false;
190 }
191
192 if (! (parm1 instanceof EmoWizardMetadata)) {
193 return false;
194 }
195
196 EmoWizardMetadata other = (EmoWizardMetadata) parm1;
197
198
199
200
201
202 if (!(!(title == null ^ other.title == null) &&
203 ((title != null && title.equals(other.title))
204 || title == null))) {
205 return false;
206 }
207
208 if (!(!(directive == null ^ other.directive == null) &&
209 ((directive != null && directive.equals(other.directive))
210 || directive == null))) {
211 return false;
212 }
213
214 if (!(!(helpText == null ^ other.helpText == null) &&
215 ((helpText != null && helpText.equals(other.helpText))
216 || helpText == null))) {
217 return false;
218 }
219
220 return true;
221 }
222
223 /***
224 * View id represents some sort of identifier for a custom view. May
225 * translates to Struts/JSF/Webwork view or may not. The controller of
226 * the wizard needs to recognize that it may need special processing if
227 * the view id is not null.
228 */
229 private String viewId = null;
230
231
232 /***
233 * Set the view id.
234 *
235 * @param newId String
236 */
237 public synchronized void setViewId(String newId) {
238 assert newId != null;
239
240 viewId = newId;
241 }
242
243 /***
244 * Retrieve the view id. Defaults to null. May specify a special
245 * type of view handling for a given page.
246 *
247 * @return String
248 */
249 public synchronized String getViewId() {
250 return viewId;
251 }
252
253 /***
254 * Override of toString().
255 * <p>{@inheritDoc}</p>
256 *
257 * @return String
258 */
259 public synchronized String toString() {
260 return "Wizard Page: " + title;
261 }
262
263 /***
264 * Override of Hashcode().
265 * <p>{@inheritDoc}</p>
266 *
267 * @return integer
268 */
269 public synchronized int hashCode() {
270 return title.hashCode();
271 }
272
273
274 /***
275 * Set to true if there is some sort of entry to occur on a page.
276 *
277 * @return boolean
278 */
279 synchronized public boolean isHasEntry() {
280 return entry;
281 }
282
283 /***
284 * Retrurn false if the user can skip a step without entering anything.
285 *
286 * @return boolean true/false
287 */
288 public synchronized boolean isEntryRequired() {
289 return this.entryRequired;
290 }
291
292 }