Coverage Report - org.kuali.student.common.ui.client.widgets.dialog.ReportExportDialog
 
Classes in this File Line Coverage Branch Coverage Complexity
ReportExportDialog
0%
0/35
N/A
1.5
ReportExportDialog$1
0%
0/7
0%
0/6
1.5
ReportExportDialog$2
0%
0/4
0%
0/2
1.5
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
 3  
  * not use this file except in compliance with the License. You may obtain a copy of the License at
 4  
  * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
 5  
  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 6  
  * implied. See the License for the specific language governing permissions and limitations under the License.
 7  
  */
 8  
 
 9  
 package org.kuali.student.common.ui.client.widgets.dialog;
 10  
 
 11  
 import org.kuali.student.common.ui.client.application.Application;
 12  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 13  
 import org.kuali.student.common.ui.client.mvc.Callback;
 14  
 import org.kuali.student.common.ui.client.util.ExportUtils;
 15  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 16  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 17  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations;
 18  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum;
 19  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup;
 20  
 import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel;
 21  
 import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel;
 22  
 import org.kuali.student.common.ui.client.widgets.list.impl.KSRadioButtonListImpl;
 23  
 import org.kuali.student.common.ui.client.widgets.list.impl.SimpleListItems;
 24  
 
 25  
 import com.google.gwt.core.client.GWT;
 26  
 
 27  0
 public class ReportExportDialog {
 28  
 
 29  0
     private VerticalFlowPanel layout = new VerticalFlowPanel();
 30  
     private KSLightBox dialog;
 31  
 
 32  0
     private KSRadioButtonListImpl selectItemWidget = GWT.create(KSRadioButtonListImpl.class);
 33  
 
 34  0
     private ActionCancelGroup actionButtons = new ActionCancelGroup(ButtonEnumerations.ExportCancelEnum.EXPORT, ButtonEnumerations.ExportCancelEnum.CANCEL);
 35  
 
 36  0
     public ReportExportDialog() {
 37  
 
 38  0
         dialog = new KSLightBox();
 39  0
         layout.addStyleName("KS-Advanced-Search-Buttons");
 40  0
         SectionTitle sectionTitle = SectionTitle.generateH2Title(this.getMessage("exportTitle"));
 41  0
         layout.add(sectionTitle);
 42  
 
 43  
         // Add label to layout panel.
 44  0
         KSLabel exportLabel = new KSLabel(getMessage("exportDialog"));
 45  0
         layout.add(exportLabel);
 46  
 
 47  
         // Add radiobutton to layout panel.
 48  0
         HorizontalBlockFlowPanel radioPanel = new HorizontalBlockFlowPanel();
 49  0
         radioPanel.setHeight("90px");
 50  0
         SimpleListItems formatList = new SimpleListItems();
 51  0
         formatList.addItem(ExportUtils.PDF, this.getMessage("pdfFormat"));
 52  0
         formatList.addItem(ExportUtils.DOC, this.getMessage("docFormat"));
 53  0
         selectItemWidget.setListItems(formatList);
 54  0
         selectItemWidget.selectItem(ExportUtils.PDF);
 55  0
         radioPanel.add(selectItemWidget);
 56  0
         layout.add(radioPanel);
 57  
 
 58  
         // Add buttons to layout panel.
 59  0
         this.addCancelCompleteCallback();
 60  0
         layout.add(actionButtons);
 61  
 
 62  0
         dialog.setMaxHeight(200);
 63  0
         dialog.setMaxWidth(250);
 64  0
     }
 65  
 
 66  
     public void show() {
 67  0
         dialog.setWidget(layout);
 68  0
         dialog.show();
 69  0
     }
 70  
 
 71  
     public void hide() {
 72  0
         dialog.hide();
 73  0
     }
 74  
 
 75  
     public void addSelectCompleteCallback(final Callback<String> callback) {
 76  0
         actionButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() {
 77  
             @Override
 78  
             public void exec(ButtonEnum result) {
 79  0
                 if (result == ButtonEnumerations.ExportCancelEnum.EXPORT) {
 80  0
                     if (selectItemWidget.getSelectedItem() != null) {
 81  0
                         if (callback != null) {
 82  0
                             callback.exec(selectItemWidget.getSelectedItem());
 83  
                         }
 84  0
                         dialog.hide();
 85  
                     }
 86  
                 }
 87  0
             }
 88  
         });
 89  0
     }
 90  
 
 91  
     public void addCancelCompleteCallback() {
 92  0
         actionButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() {
 93  
             @Override
 94  
             public void exec(ButtonEnum result) {
 95  0
                 if (result == ButtonEnumerations.ExportCancelEnum.CANCEL) {
 96  0
                     dialog.hide();
 97  
                 }
 98  0
             }
 99  
         });
 100  0
     }
 101  
 
 102  
     private String getMessage(final String msgKey) {
 103  0
         return Application.getApplicationContext().getMessage(msgKey);
 104  
     }
 105  
 
 106  
 }