View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.ui.client.widgets.buttongroups;
17  
18  import org.kuali.student.common.ui.client.application.Application;
19  import org.kuali.student.common.ui.client.application.ApplicationContext;
20  import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
21  
22  
23  public class ButtonEnumerations {
24      public interface ButtonEnum{
25          public String getText();
26          public ButtonStyle getStyle();
27          public ButtonEnum getActionType();
28          public ButtonEnum getCancelType();
29      };
30  
31      final static ApplicationContext context = Application.getApplicationContext();
32  
33      public static enum OkEnum implements ButtonEnum{Ok;
34  
35          @Override
36          public String getText() {
37              switch(this){
38                  case Ok:
39                      return "Ok";
40              }
41              return null;  
42          }
43      
44      	@Override
45      	public ButtonStyle getStyle() {
46      		return ButtonStyle.PRIMARY;
47      	}
48      
49          @Override
50          public ButtonEnum getActionType() {
51              return Ok;
52          }
53      
54          @Override
55          public ButtonEnum getCancelType() {
56              return Ok;
57          }
58  	
59      };
60  
61      public static enum YesNoEnum implements ButtonEnum{YES, NO;
62  
63      @Override
64      public String getText() {
65          switch(this){
66              case YES:
67                  return context.getMessage("yes");
68              case NO:
69                  return context.getMessage("no");
70          }
71          return null;  
72      }
73  	@Override
74  	public ButtonStyle getStyle() {
75  		return ButtonStyle.PRIMARY;
76  	}
77  	
78      @Override
79      public ButtonEnum getActionType() {
80          return YES;
81      }
82  
83      @Override
84      public ButtonEnum getCancelType() {
85          return NO;
86      }
87      }; 
88  
89      public static enum ConfirmCancelEnum implements ButtonEnum{CONFIRM, CANCEL;
90  
91      @Override
92      public String getText() {
93          switch(this){
94              case CONFIRM:
95                  return context.getMessage("confirm");
96              case CANCEL:
97                  return context.getMessage("cancel");
98          }
99          return null;  
100     }
101 	@Override
102 	public ButtonStyle getStyle() {
103         switch(this){
104         case CONFIRM:
105             return ButtonStyle.PRIMARY;
106         case CANCEL:
107             return ButtonStyle.DEFAULT_ANCHOR;
108         }
109 		return ButtonStyle.PRIMARY;
110 	}
111     @Override
112     public ButtonEnum getActionType() {
113         return CONFIRM;
114     }
115     @Override
116     public ButtonEnum getCancelType() {
117         return CANCEL;
118     }	
119     };
120 
121     public static enum YesNoCancelEnum implements ButtonEnum{YES, NO, CANCEL;
122 
123     @Override
124     public String getText() {
125         switch(this){
126             case YES:
127                 return context.getMessage("yes");
128             case NO:
129                 return context.getMessage("no");
130             case CANCEL:
131                 return context.getMessage("cancel");
132         }
133         return null;  
134     }
135 	@Override
136 	public ButtonStyle getStyle() {
137 		switch(this){
138 			case CANCEL:
139 				return ButtonStyle.ANCHOR_LARGE_CENTERED;
140 			default:
141 				return ButtonStyle.PRIMARY;
142 		}
143 		
144 	}
145     @Override
146     public ButtonEnum getActionType() {
147         return YES;
148     }
149 
150     @Override
151     public ButtonEnum getCancelType() {
152         return NO;
153     }
154     };
155 
156     public static enum AddModifyRemoveEnum implements ButtonEnum{ADD, MODIFY, REMOVE;
157 
158     @Override
159     public String getText() {
160         switch(this){
161             case ADD:
162                 return context.getMessage("add");
163             case MODIFY:
164                 return context.getMessage("modify");
165             case REMOVE:
166                 return context.getMessage("remove");
167         }
168         return null;  
169     }
170 	@Override
171 	public ButtonStyle getStyle() {
172 		return ButtonStyle.PRIMARY;
173 	}
174     @Override
175     public ButtonEnum getActionType() {
176         return null;
177     }
178 
179     @Override
180     public ButtonEnum getCancelType() {
181         return null;
182     }	
183     };
184 
185     public static enum SendCancelEnum implements ButtonEnum{SEND, CANCEL;
186 
187     @Override
188     public String getText() {
189         switch(this){
190             case SEND:
191                 return context.getMessage("send");
192             case CANCEL:
193                 return context.getMessage("cancel");
194         }
195         return null;  
196     }
197 	@Override
198 	public ButtonStyle getStyle() {
199 		return ButtonStyle.PRIMARY;
200 	}
201     @Override
202     public ButtonEnum getActionType() {
203         return SEND;
204     }
205 
206     @Override
207     public ButtonEnum getCancelType() {
208         return CANCEL;
209     }	
210     };
211 
212     public static enum GoCancelEnum implements ButtonEnum{GO, CANCEL;
213 
214     @Override
215     public String getText() {
216         switch(this){
217             case GO:
218                 return context.getMessage("go");
219             case CANCEL:
220                 return context.getMessage("cancel");
221         }
222         return null;  
223     }
224 	@Override
225 	public ButtonStyle getStyle() {
226 		return ButtonStyle.PRIMARY;
227 	}
228     @Override
229     public ButtonEnum getActionType() {
230         return GO;
231     }
232 
233     @Override
234     public ButtonEnum getCancelType() {
235         return CANCEL;
236     }
237     };
238     
239     public static enum CreateCancelEnum implements ButtonEnum{CREATE, CANCEL;
240 
241     @Override
242     public String getText() {
243         switch(this){
244             case CREATE:
245                 return context.getMessage("create");
246             case CANCEL:
247                 return context.getMessage("cancel");
248         }
249         return null;  
250     }
251 	@Override
252 	public ButtonStyle getStyle() {
253 		return ButtonStyle.PRIMARY;
254 	}
255     @Override
256     public ButtonEnum getActionType() {
257         return CREATE;
258     }
259 
260     @Override
261     public ButtonEnum getCancelType() {
262         return CANCEL;
263     }
264     };
265 
266     public static enum SearchCancelEnum implements ButtonEnum{SEARCH, CANCEL;
267 
268         @Override
269         public String getText() {
270             switch(this){
271                 case SEARCH:
272                     return context.getMessage("search");
273                 case CANCEL:
274                     return context.getMessage("cancel");
275             }
276             return null;
277         }
278     	@Override
279         public ButtonStyle getStyle() {
280             switch(this){
281             case SEARCH:
282                 return ButtonStyle.PRIMARY;
283             case CANCEL:
284                 return ButtonStyle.ANCHOR_LARGE_CENTERED;
285             }
286             return ButtonStyle.PRIMARY;
287         }
288         @Override
289         public ButtonEnum getActionType() {
290             return SEARCH;
291         }
292         @Override
293         public ButtonEnum getCancelType() {
294             return CANCEL;
295         }
296     };
297 
298     public static enum AddCancelEnum implements ButtonEnum{ADD, CANCEL;
299 
300         @Override
301         public String getText() {
302             switch(this){
303                 case ADD:
304                     return context.getMessage("add");
305                 case CANCEL:
306                     return context.getMessage("cancel");
307             }
308             return null;
309         }
310     	@Override
311         public ButtonStyle getStyle() {
312             switch(this){
313             case ADD:
314                 return ButtonStyle.PRIMARY;
315             case CANCEL:
316                 return ButtonStyle.ANCHOR_LARGE_CENTERED;
317             }
318             return ButtonStyle.PRIMARY;
319         }
320         @Override
321         public ButtonEnum getActionType() {
322             return ADD;
323         }
324         @Override
325         public ButtonEnum getCancelType() {
326             return CANCEL;
327         }
328     };
329 
330     public static enum UpdateCancelEnum implements ButtonEnum{UPDATE, CANCEL;
331 
332         @Override
333         public String getText() {
334             switch(this){
335                 case UPDATE:
336                     return context.getMessage("update");
337                 case CANCEL:
338                     return context.getMessage("cancel");
339             }
340             return null;
341         }
342     	@Override
343         public ButtonStyle getStyle() {
344             switch(this){
345             case UPDATE:
346                 return ButtonStyle.PRIMARY;
347             case CANCEL:
348                 return ButtonStyle.DEFAULT_ANCHOR;
349             }
350             return ButtonStyle.PRIMARY;
351         }
352         @Override
353         public ButtonEnum getActionType() {
354             return UPDATE;
355         }
356         @Override
357         public ButtonEnum getCancelType() {
358             return CANCEL;
359         }
360     };
361 
362     public static enum ContinueCancelEnum implements ButtonEnum{CONTINUE, CANCEL;
363 
364         @Override
365         public String getText() {
366             switch(this){
367                 case CONTINUE:
368                     return context.getMessage("continue");
369                 case CANCEL:
370                     return context.getMessage("cancel");
371             }
372             return null;
373         }
374     	@Override
375         public ButtonStyle getStyle() {
376             switch(this){
377             case CONTINUE:
378                 return ButtonStyle.PRIMARY;
379             case CANCEL:
380                 return ButtonStyle.DEFAULT_ANCHOR;
381             }
382             return ButtonStyle.PRIMARY;
383         }
384         @Override
385         public ButtonEnum getActionType() {
386             return CONTINUE;
387         }
388         @Override
389         public ButtonEnum getCancelType() {
390             return CANCEL;
391         }
392     };
393 
394     public static enum SaveCancelEnum implements ButtonEnum{SAVE, CANCEL;
395 
396         @Override
397         public String getText() {
398             switch(this){
399                 case SAVE:
400                     return context.getMessage("save");
401                 case CANCEL:
402                     return context.getMessage("cancel");
403             }
404             return null;
405         }
406     	@Override
407         public ButtonStyle getStyle() {
408             switch(this){
409             case SAVE:
410                 return ButtonStyle.PRIMARY;
411             case CANCEL:
412                 return ButtonStyle.DEFAULT_ANCHOR;
413             }
414             return ButtonStyle.PRIMARY;
415         }
416         @Override
417         public ButtonEnum getActionType() {
418             return SAVE;
419         }
420         @Override
421         public ButtonEnum getCancelType() {
422             return CANCEL;
423         }
424     };
425 
426     public static enum SaveContinueCancelEnum implements ButtonEnum{SAVE_CONTINUE, CANCEL;
427 
428         @Override
429         public String getText() {
430             switch(this){
431                 case SAVE_CONTINUE:
432                     return context.getMessage("saveContinue");
433                 case CANCEL:
434                     return context.getMessage("cancel");
435             }
436             return null;
437         }
438     	@Override
439         public ButtonStyle getStyle() {
440             switch(this){
441             case SAVE_CONTINUE:
442                 return ButtonStyle.PRIMARY;
443             case CANCEL:
444                 return ButtonStyle.DEFAULT_ANCHOR;
445             }
446             return ButtonStyle.PRIMARY;
447         }
448         @Override
449         public ButtonEnum getActionType() {
450             return SAVE_CONTINUE;
451         }
452         @Override
453         public ButtonEnum getCancelType() {
454             return CANCEL;
455         }
456     };
457     
458     public static enum ConfirmApprovalCancelEnum implements ButtonEnum{CONFIRM, CANCEL;
459 
460     @Override
461     public String getText() {
462         switch(this){
463             case CONFIRM:
464                 return context.getMessage("confirmApproval");
465             case CANCEL:
466                 return context.getMessage("cancel");
467         }
468         return null;  
469     }
470 	@Override
471 	public ButtonStyle getStyle() {
472         switch(this){
473         case CONFIRM:
474             return ButtonStyle.PRIMARY;
475         case CANCEL:
476             return ButtonStyle.DEFAULT_ANCHOR;
477         }
478 		return ButtonStyle.PRIMARY;
479 	}
480     @Override
481     public ButtonEnum getActionType() {
482         return CONFIRM;
483     }
484     @Override
485     public ButtonEnum getCancelType() {
486         return CANCEL;
487     }	
488     };
489     
490     public static enum AcknowledgeCancelEnum implements ButtonEnum{ACKNOWLEDGE, CANCEL;
491 
492     @Override
493     public String getText() {
494         switch(this){
495             case ACKNOWLEDGE:
496                 return context.getMessage("acknowledge");
497             case CANCEL:
498                 return context.getMessage("cancel");
499         }
500         return null;  
501     }
502 	@Override
503 	public ButtonStyle getStyle() {
504         switch(this){
505         case ACKNOWLEDGE:
506             return ButtonStyle.PRIMARY;
507         case CANCEL:
508             return ButtonStyle.DEFAULT_ANCHOR;
509         }
510 		return ButtonStyle.PRIMARY;
511 	}
512     @Override
513     public ButtonEnum getActionType() {
514         return ACKNOWLEDGE;
515     }
516     @Override
517     public ButtonEnum getCancelType() {
518         return CANCEL;
519     }	
520     };
521     
522     public static enum RejectCancelEnum implements ButtonEnum{REJECT, CANCEL;
523 
524     @Override
525     public String getText() {
526         switch(this){
527             case REJECT:
528                 return context.getMessage("reject");
529             case CANCEL:
530                 return context.getMessage("cancel");
531         }
532         return null;  
533     }
534 	@Override
535 	public ButtonStyle getStyle() {
536         switch(this){
537         case REJECT:
538             return ButtonStyle.PRIMARY;
539         case CANCEL:
540             return ButtonStyle.DEFAULT_ANCHOR;
541         }
542 		return ButtonStyle.PRIMARY;
543 	}
544     @Override
545     public ButtonEnum getActionType() {
546         return REJECT;
547     }
548     @Override
549     public ButtonEnum getCancelType() {
550         return CANCEL;
551     }	
552     };
553     
554     public static enum ExportCancelEnum implements ButtonEnum{EXPORT, CANCEL;
555 
556     @Override
557     public String getText() {
558         switch(this){
559             case EXPORT:
560                 return context.getMessage("export");
561             case CANCEL:
562                 return context.getMessage("cancel");
563         }
564         return null;
565     }
566     @Override
567     public ButtonStyle getStyle() {
568         switch(this){
569         case EXPORT:
570             return ButtonStyle.PRIMARY;
571         case CANCEL:
572             return ButtonStyle.DEFAULT_ANCHOR;
573         }
574         return ButtonStyle.PRIMARY;
575     }
576     @Override
577     public ButtonEnum getActionType() {
578         return EXPORT;
579     }
580     @Override
581     public ButtonEnum getCancelType() {
582         return CANCEL;
583     }
584 };
585 
586     public static enum ApproveCancelEnum implements ButtonEnum {
587         APPROVE, CANCEL;
588 
589         @Override
590         public String getText() {
591             switch (this) {
592                 case APPROVE:
593                     return context.getMessage("approve");
594                 case CANCEL:
595                     return context.getMessage("cancel");
596             }
597             return null;
598         }
599 
600         @Override
601         public ButtonStyle getStyle() {
602             switch (this) {
603                 case APPROVE:
604                     return ButtonStyle.PRIMARY;
605                 case CANCEL:
606                     return ButtonStyle.DEFAULT_ANCHOR;
607             }
608             return ButtonStyle.PRIMARY;
609         }
610 
611         @Override
612         public ButtonEnum getActionType() {
613             return APPROVE;
614         }
615 
616         @Override
617         public ButtonEnum getCancelType() {
618             return CANCEL;
619         }
620     };
621 }