001/**
002 * Copyright 2010 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015
016package org.kuali.student.common.ui.client.widgets.buttongroups;
017
018import org.kuali.student.common.ui.client.application.Application;
019import org.kuali.student.common.ui.client.application.ApplicationContext;
020import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
021
022
023public class ButtonEnumerations {
024    public interface ButtonEnum{
025        public String getText();
026        public ButtonStyle getStyle();
027        public ButtonEnum getActionType();
028        public ButtonEnum getCancelType();
029    };
030
031    final static ApplicationContext context = Application.getApplicationContext();
032
033    public static enum OkEnum implements ButtonEnum{Ok;
034
035        @Override
036        public String getText() {
037            switch(this){
038                case Ok:
039                    return "Ok";
040            }
041            return null;  
042        }
043    
044        @Override
045        public ButtonStyle getStyle() {
046                return ButtonStyle.PRIMARY;
047        }
048    
049        @Override
050        public ButtonEnum getActionType() {
051            return Ok;
052        }
053    
054        @Override
055        public ButtonEnum getCancelType() {
056            return Ok;
057        }
058        
059    };
060
061    public static enum YesNoEnum implements ButtonEnum{YES, NO;
062
063    @Override
064    public String getText() {
065        switch(this){
066            case YES:
067                return context.getMessage("yes");
068            case NO:
069                return context.getMessage("no");
070        }
071        return null;  
072    }
073        @Override
074        public ButtonStyle getStyle() {
075                return ButtonStyle.PRIMARY;
076        }
077        
078    @Override
079    public ButtonEnum getActionType() {
080        return YES;
081    }
082
083    @Override
084    public ButtonEnum getCancelType() {
085        return NO;
086    }
087    }; 
088
089    public static enum ConfirmCancelEnum implements ButtonEnum{CONFIRM, CANCEL;
090
091    @Override
092    public String getText() {
093        switch(this){
094            case CONFIRM:
095                return context.getMessage("confirm");
096            case CANCEL:
097                return context.getMessage("cancel");
098        }
099        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}