Coverage Report - org.kuali.student.common.ui.client.widgets.TextLinkageHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
TextLinkageHelper
0%
0/6
0%
0/2
2.5
TextLinkageHelper$1
0%
0/5
0%
0/4
2.5
 
 1  
 package org.kuali.student.common.ui.client.widgets;
 2  
 
 3  
 import com.google.gwt.event.dom.client.HasKeyUpHandlers;
 4  
 import com.google.gwt.event.dom.client.KeyUpEvent;
 5  
 import com.google.gwt.event.dom.client.KeyUpHandler;
 6  
 import com.google.gwt.user.client.ui.HasText;
 7  
 /**
 8  
  * TextLinkageHelper is used to link two text fields. As you type in one field the text 
 9  
  * appears on the linked field.
 10  
  * 
 11  
  * */
 12  0
 public class TextLinkageHelper {
 13  
     static String masterString;
 14  
     public static void link(final HasText master, final HasText slave) {
 15  0
         masterString = master.getText();
 16  0
         if (master instanceof HasKeyUpHandlers) {
 17  0
               HasKeyUpHandlers masterTextBox = (HasKeyUpHandlers) master;
 18  0
               masterTextBox.addKeyUpHandler(new KeyUpHandler() {
 19  
                 @Override
 20  
                 public void onKeyUp(KeyUpEvent event) {
 21  0
                       if(masterString.equals(slave.getText()) 
 22  
                               ||"".equals(slave.getText()) ){
 23  0
                           masterString = master.getText();
 24  0
                           slave.setText(masterString);
 25  
                       }
 26  0
                 }
 27  
               });
 28  
           }
 29  0
       } 
 30  
 }