| 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 |  |   | 
  | 19 |  |   | 
  | 20 |  |   | 
  | 21 |  |   | 
  | 22 |  |   | 
  | 23 |  |   | 
  | 24 |  |   | 
  | 25 |  |   | 
  | 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 |  |                   | 
  | 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 |  |                   | 
  | 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 |  |  } |