Coverage Report - org.kuali.student.lum.lu.ui.main.client.controllers.ApplicationController
 
Classes in this File Line Coverage Branch Coverage Complexity
ApplicationController
0%
0/31
0%
0/2
1.1
ApplicationController$1
0%
0/3
N/A
1.1
ApplicationController$AppViews
0%
0/1
N/A
1.1
 
 1  
 package org.kuali.student.lum.lu.ui.main.client.controllers;
 2  
 
 3  
 import org.kuali.student.common.ui.client.configurable.mvc.LayoutController;
 4  
 import org.kuali.student.common.ui.client.mvc.Callback;
 5  
 import org.kuali.student.common.ui.client.mvc.Controller;
 6  
 import org.kuali.student.common.ui.client.mvc.View;
 7  
 import org.kuali.student.common.ui.client.mvc.events.LogoutEvent;
 8  
 import org.kuali.student.common.ui.client.mvc.events.LogoutHandler;
 9  
 import org.kuali.student.lum.lu.ui.main.client.LUMMainEntryPoint;
 10  
 
 11  
 import com.google.gwt.core.client.GWT;
 12  
 import com.google.gwt.user.client.Window;
 13  
 import com.google.gwt.user.client.ui.ComplexPanel;
 14  
 import com.google.gwt.user.client.ui.FlowPanel;
 15  
 import com.google.gwt.user.client.ui.Widget;
 16  
 
 17  
 /**
 18  
  * The top level application controller for the LUM application.  All other views are part of this controller
 19  
  * or its children.  This controller provides the very basic layout of the app and includes the header and
 20  
  * the main content panel.  The header stays in the same location for all screens of KS.
 21  
  * 
 22  
  * <br> This controller contains one child view, the home view (HomeController).
 23  
  * @author Kuali Student Team
 24  
  * @see HomeController
 25  
  * @see LUMMainEntryPoint
 26  
  */
 27  
 public class ApplicationController extends LayoutController{
 28  
 
 29  0
         public static enum AppViews{HOME}
 30  
         
 31  0
         public static FlowPanel contentPanel = new FlowPanel();
 32  0
         public FlowPanel container = new FlowPanel();
 33  
         
 34  
         public ApplicationController(String controllerId, Widget header) {
 35  0
                 super();
 36  0
                 this.init(header);
 37  0
                 this.setupViews();
 38  0
                 this.addHandlers();
 39  0
         }
 40  
         
 41  
         private void init(Widget header){
 42  0
                 container.add(header);
 43  0
                 container.add(contentPanel);
 44  0
                 contentPanel.addStyleName("app-content");
 45  0
                 container.addStyleName("app-wrap");
 46  0
                 this.initWidget(container);
 47  0
         }
 48  
         
 49  
         private void addHandlers(){
 50  0
                 addApplicationEventHandler(LogoutEvent.TYPE, new LogoutHandler() {
 51  
                         public void onLogout(LogoutEvent event) {
 52  0
                                 Window.Location.assign("/j_spring_security_logout");
 53  0
                         }
 54  
                 });
 55  0
         }
 56  
         
 57  
         private void setupViews(){
 58  
                 //if a configurer pattern makes sense here this is where it would be called
 59  0
                 HomeController home = GWT.create(HomeController.class);
 60  0
                 home.init(this, "Home", AppViews.HOME);                
 61  0
                 this.addView(home);
 62  0
                 this.setDefaultView(AppViews.HOME);
 63  0
         }
 64  
 
 65  
         @Override
 66  
         public void updateModel() {
 67  
                 //Does nothing, no model needed here
 68  0
         }
 69  
 
 70  
         @Override
 71  
         protected void hideView(View view) {
 72  0
                 contentPanel.clear();
 73  0
         }
 74  
 
 75  
         @Override
 76  
         protected void renderView(View view) {
 77  0
                 contentPanel.add(view.asWidget());
 78  0
         }
 79  
         
 80  
         public static ComplexPanel getApplicationViewContainer(){
 81  0
                 return contentPanel;
 82  
         }
 83  
         
 84  
         @Override
 85  
         public void showDefaultView(Callback<Boolean> onReadyCallback) {
 86  0
                 super.showView(AppViews.HOME);
 87  0
                 if(this.getCurrentView() instanceof Controller){
 88  0
                         ((Controller) this.getCurrentView()).showDefaultView(onReadyCallback);
 89  
                 }
 90  
                 else{
 91  0
                         onReadyCallback.exec(true);
 92  
                 }
 93  0
         }
 94  
 }