Coverage Report - org.kuali.student.lum.lu.ui.main.client.LUMMainEntryPoint
 
Classes in this File Line Coverage Branch Coverage Complexity
LUMMainEntryPoint
0%
0/36
0%
0/2
1.333
LUMMainEntryPoint$1
0%
0/3
N/A
1.333
 
 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.lum.lu.ui.main.client;
 17  
 
 18  
 
 19  
 import org.kuali.student.common.messages.dto.MessageList;
 20  
 import org.kuali.student.common.ui.client.application.Application;
 21  
 import org.kuali.student.common.ui.client.application.ApplicationContext;
 22  
 import org.kuali.student.common.ui.client.mvc.Callback;
 23  
 import org.kuali.student.common.ui.client.mvc.Controller;
 24  
 import org.kuali.student.common.ui.client.mvc.breadcrumb.BreadcrumbManager;
 25  
 import org.kuali.student.common.ui.client.mvc.history.HistoryManager;
 26  
 import org.kuali.student.common.ui.client.service.MessagesRpcService;
 27  
 import org.kuali.student.common.ui.client.util.BrowserUtils;
 28  
 import org.kuali.student.common.ui.client.util.WindowTitleUtils;
 29  
 import org.kuali.student.common.ui.client.widgets.ApplicationPanel;
 30  
 import org.kuali.student.common.ui.client.widgets.KSFooter;
 31  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 32  
 import org.kuali.student.lum.lu.ui.main.client.controllers.ApplicationController;
 33  
 import org.kuali.student.lum.lu.ui.main.client.theme.LumTheme;
 34  
 import org.kuali.student.lum.lu.ui.main.client.widgets.ApplicationHeader;
 35  
 
 36  
 import com.google.gwt.core.client.EntryPoint;
 37  
 import com.google.gwt.core.client.GWT;
 38  
 import com.google.gwt.dom.client.StyleInjector;
 39  
 import com.google.gwt.user.client.rpc.SerializationException;
 40  
 import com.google.gwt.user.client.rpc.SerializationStreamFactory;
 41  
 import com.google.gwt.user.client.rpc.SerializationStreamReader;
 42  
 
 43  0
 public class LUMMainEntryPoint implements EntryPoint{
 44  
 
 45  0
     private ApplicationController manager = null;
 46  0
     private AppLocations locations = new AppLocations();
 47  0
     private ApplicationHeader header = GWT.create(ApplicationHeader.class);
 48  
     @Override
 49  
     public void onModuleLoad() {
 50  0
         final ApplicationContext context = Application.getApplicationContext();
 51  
 
 52  0
         final String injectString = LumTheme.INSTANCE.getLumCss().getCssString();
 53  0
         StyleInjector.injectStylesheet(injectString);   
 54  
 
 55  
         try {
 56  0
             loadMessages(context);                    
 57  0
             loadApp(context);
 58  0
         } catch (Exception e) {
 59  0
             GWT.log("Error loading entrypoint", e);
 60  0
         } 
 61  0
     }
 62  
 
 63  
     private void initScreen(){
 64  0
         manager = new ApplicationController("KualiStudent", header);
 65  0
         WindowTitleUtils.setApplicationTitle(Application.getApplicationContext().getMessage("applicationName"));
 66  0
         ApplicationPanel.get().add(manager);
 67  0
         ApplicationPanel.get().add(new KSFooter());
 68  0
         HistoryManager.bind(manager, locations);
 69  0
         BreadcrumbManager.bind(manager);
 70  0
         HistoryManager.processWindowLocation();
 71  0
         if(manager.getCurrentView() == null)
 72  0
             manager.showDefaultView(Controller.NO_OP_CALLBACK);
 73  0
         header.setHeaderTitle(Application.getApplicationContext().getMessage("applicationTitleLabel"));
 74  0
     }
 75  
     
 76  
     private void loadMessages(final ApplicationContext context) throws SerializationException {
 77  0
         MessageList commonMessageList =  getMsgSerializedObject("commonMessages" );
 78  0
         MessageList lumMessageList =  getMsgSerializedObject("luMessages" );
 79  0
         context.addMessages(commonMessageList.getMessages());
 80  0
         context.addMessages(lumMessageList.getMessages());
 81  0
     }
 82  
 
 83  
     @SuppressWarnings("unchecked")
 84  
     public  <T> T getMsgSerializedObject(String key ) throws SerializationException
 85  
     {
 86  0
         String serialized = BrowserUtils.getString( key );
 87  0
         SerializationStreamFactory ssf = GWT.create( MessagesRpcService.class); // magic
 88  0
         SerializationStreamReader ssr = ssf.createStreamReader( serialized );
 89  0
         T ret = (T)ssr.readObject();
 90  0
         return ret;
 91  
     } 
 92  
       
 93  
     public void loadApp(final ApplicationContext context){        
 94  0
         context.initializeContext(new Callback<Boolean>(){
 95  
                         @Override
 96  
                         public void exec(Boolean result) {
 97  0
                 initScreen();                                
 98  0
                         }                
 99  
         });
 100  0
     }
 101  
 
 102  
 }