Coverage Report - org.kuali.student.common.ui.client.widgets.dialog.ConfirmationDialog
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfirmationDialog
0%
0/37
N/A
1
ConfirmationDialog$1
0%
0/3
N/A
1
 
 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.dialog;
 17  
 
 18  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 19  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 20  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 21  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 22  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
 23  
 import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel;
 24  
 
 25  
 import com.google.gwt.event.dom.client.ClickEvent;
 26  
 import com.google.gwt.event.dom.client.ClickHandler;
 27  
 import com.google.gwt.event.logical.shared.CloseHandler;
 28  
 import com.google.gwt.event.shared.HandlerRegistration;
 29  
 import com.google.gwt.user.client.ui.FlowPanel;
 30  
 
 31  0
 public class ConfirmationDialog {
 32  
         private KSLightBox dialog;
 33  
 
 34  0
         private KSButton cancel = new KSButton("Cancel", ButtonStyle.ANCHOR_LARGE_CENTERED);
 35  0
         private KSButton confirm = new KSButton("Confirm", ButtonStyle.PRIMARY_SMALL);
 36  0
         private HorizontalBlockFlowPanel buttonPanel = new HorizontalBlockFlowPanel();
 37  0
         private KSLabel messageLabel = new KSLabel();
 38  0
         private SectionTitle title = SectionTitle.generateH3Title("");
 39  
         
 40  0
         private FlowPanel layout = new FlowPanel();
 41  
         
 42  0
         public ConfirmationDialog(String titleText, String message){
 43  0
                 setupLayout(titleText, message);
 44  0
         }
 45  
         
 46  0
         public ConfirmationDialog(String titleText, String message, String confirmText){
 47  0
                 confirm.setText(confirmText);
 48  0
                 setupLayout(titleText, message);
 49  0
         }
 50  
         
 51  
         private void setupLayout(String titleText, String message){
 52  
                 //title.setText(titleText);
 53  0
                 dialog = new KSLightBox(titleText);
 54  
 
 55  0
                 cancel.addClickHandler(new ClickHandler(){
 56  
 
 57  
                         @Override
 58  
                         public void onClick(ClickEvent event) {
 59  0
                                 dialog.hide();
 60  0
                         }
 61  
                 });
 62  
                 
 63  0
                 messageLabel.setText(message);
 64  0
                 dialog.addButton(confirm);
 65  0
                 dialog.addButton(cancel);
 66  0
                 layout.add(messageLabel);
 67  0
                 layout.add(buttonPanel);
 68  0
                 layout.addStyleName("ks-confirmation-message-layout");
 69  0
                 messageLabel.setStyleName("ks-confirmation-message-label");
 70  0
                 dialog.setWidget(layout);
 71  0
                 dialog.setSize(600, 100);
 72  0
         }
 73  
         
 74  
         public void show(){
 75  0
                 dialog.show();
 76  0
         }
 77  
         
 78  
         public void hide(){
 79  0
                 dialog.hide();
 80  0
         }
 81  
         
 82  
         public void removeCloseLink(){
 83  0
                 dialog.removeCloseLink();
 84  0
         }
 85  
         
 86  
         public HandlerRegistration addCloseHandler(CloseHandler handler){
 87  0
                 return dialog.addCloseHandler(handler);
 88  
         }
 89  
         
 90  
         public void setMessageText(String text){
 91  0
                 messageLabel.setText(text);
 92  0
         }
 93  
         
 94  
         public KSButton getConfirmButton(){
 95  0
                 return confirm;
 96  
         }
 97  
         
 98  
         public KSButton getCancelButton(){
 99  0
                 return cancel;
 100  
         }
 101  
 }