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