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  
         //layout.add(sectionTitle);
 42  0
         dialog.setNonCaptionHeader(sectionTitle);
 43  
 
 44  
         // Add label to layout panel.
 45  0
         KSLabel exportLabel = new KSLabel("Select the document type to export as (Export appears in a new page, please disable pop-up blockers.):"/*KSLAB-2027 temp fix*//*getMessage("exportDialog")*/);
 46  0
         layout.add(exportLabel);
 47  
 
 48  
         // Add radiobutton to layout panel.
 49  0
         HorizontalBlockFlowPanel radioPanel = new HorizontalBlockFlowPanel();
 50  0
         radioPanel.setHeight("90px");
 51  0
         SimpleListItems formatList = new SimpleListItems();
 52  0
         formatList.addItem(ExportUtils.PDF, this.getMessage("pdfFormat"));
 53  0
         formatList.addItem(ExportUtils.DOC, this.getMessage("docFormat"));
 54  0
         selectItemWidget.setListItems(formatList);
 55  0
         selectItemWidget.selectItem(ExportUtils.PDF);
 56  0
         radioPanel.add(selectItemWidget);
 57  0
         layout.add(radioPanel);
 58  
 
 59  
         // Add buttons to layout panel.
 60  0
         this.addCancelCompleteCallback();
 61  0
         layout.add(actionButtons);
 62  
 
 63  0
         dialog.setMaxHeight(200);
 64  0
         dialog.setMaxWidth(250);
 65  0
     }
 66  
 
 67  
     public void show() {
 68  0
         dialog.setWidget(layout);
 69  0
         dialog.show();
 70  0
     }
 71  
 
 72  
     public void hide() {
 73  0
         dialog.hide();
 74  0
     }
 75  
 
 76  
     public void addSelectCompleteCallback(final Callback<String> callback) {
 77  0
         actionButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() {
 78  
             @Override
 79  
             public void exec(ButtonEnum result) {
 80  0
                 if (result == ButtonEnumerations.ExportCancelEnum.EXPORT) {
 81  0
                     if (selectItemWidget.getSelectedItem() != null) {
 82  0
                         if (callback != null) {
 83  0
                             callback.exec(selectItemWidget.getSelectedItem());
 84  
                         }
 85  0
                         dialog.hide();
 86  
                     }
 87  
                 }
 88  0
             }
 89  
         });
 90  0
     }
 91  
 
 92  
     public void addCancelCompleteCallback() {
 93  0
         actionButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>() {
 94  
             @Override
 95  
             public void exec(ButtonEnum result) {
 96  0
                 if (result == ButtonEnumerations.ExportCancelEnum.CANCEL) {
 97  0
                     dialog.hide();
 98  
                 }
 99  0
             }
 100  
         });
 101  0
     }
 102  
 
 103  
     private String getMessage(final String msgKey) {
 104  0
         return Application.getApplicationContext().getMessage(msgKey);
 105  
     }
 106  
 
 107  
 }