Coverage Report - org.kuali.student.common.ui.client.util.WindowTitleUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
WindowTitleUtils
0%
0/32
0%
0/22
3.75
 
 1  
 package org.kuali.student.common.ui.client.util;
 2  
 
 3  
 import com.google.gwt.user.client.Window;
 4  
 
 5  
 /**
 6  
  * Provides a variety of helper methods to manipulate page title based on location
 7  
  * 
 8  
  * @author Kuali Student Team
 9  
  *
 10  
  */
 11  0
 public class WindowTitleUtils {
 12  
         
 13  0
         private static String contextTitle = "";
 14  0
         private static String appTitle = "";
 15  0
         private static String subTitle = "";
 16  
         
 17  
         public static void setApplicationTitle(String title){
 18  0
                 appTitle = title;
 19  0
                 contextTitle = "";
 20  0
                 subTitle = "";
 21  0
                 Window.setTitle(generateWindowTitle());
 22  0
         }
 23  
         
 24  
         /**
 25  
          * Call this when scope of the application changes to make this be the new
 26  
          * preceding title for the window, followed by last breadcrumb name
 27  
          */
 28  
         public static void setContextTitle(String title){
 29  0
                 contextTitle = title;
 30  0
                 subTitle = "";
 31  0
                 Window.setTitle(generateWindowTitle());
 32  0
         }
 33  
         
 34  
         /**
 35  
          * Call this to change the subtitle
 36  
          */
 37  
         public static void setSubtitle(String title){
 38  0
                 subTitle = title;
 39  0
                 Window.setTitle(generateWindowTitle());
 40  0
         }
 41  
         
 42  
         private static String generateWindowTitle(){
 43  0
                 String title = null;
 44  0
                 if(appTitle != null && !appTitle.equals("")){
 45  0
                         title = appTitle;
 46  
                 }
 47  
                 
 48  0
                 if(contextTitle != null && !contextTitle.equals("")){
 49  0
                         if(title != null){
 50  0
                                 if(!contextTitle.equals(appTitle)){
 51  0
                                         title = title + ": " + contextTitle;
 52  
                                 }
 53  
                         }
 54  
                         else{
 55  0
                                 title = contextTitle;
 56  
                         }
 57  
                 }
 58  
                 
 59  0
                 if(subTitle != null && !subTitle.equals("")){
 60  0
                         if(title != null){
 61  0
                                 if(!subTitle.equals(contextTitle)){
 62  0
                                         title = title + " - " + subTitle;
 63  
                                 }
 64  
                         }
 65  
                         else{
 66  0
                                 title = subTitle;
 67  
                         }
 68  
                 }
 69  
                 
 70  0
                 if(title == null){
 71  0
                         title = "KS";
 72  
                 }
 73  
                 
 74  0
                 return title;
 75  
         }
 76  
 }