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 public static enum AppViews{HOME}
30
31 public static FlowPanel contentPanel = new FlowPanel();
32 public FlowPanel container = new FlowPanel();
33
34 public ApplicationController(String controllerId, Widget header) {
35 super();
36 this.init(header);
37 this.setupViews();
38 this.addHandlers();
39 }
40
41 private void init(Widget header){
42 container.add(header);
43 container.add(contentPanel);
44 contentPanel.addStyleName("app-content");
45 container.addStyleName("app-wrap");
46 this.initWidget(container);
47 }
48
49 private void addHandlers(){
50 addApplicationEventHandler(LogoutEvent.TYPE, new LogoutHandler() {
51 public void onLogout(LogoutEvent event) {
52 Window.Location.assign("/j_spring_security_logout");
53 }
54 });
55 }
56
57 private void setupViews(){
58
59 HomeController home = GWT.create(HomeController.class);
60 home.init(this, "Home", AppViews.HOME);
61 this.addView(home);
62 this.setDefaultView(AppViews.HOME);
63 }
64
65 @Override
66 public void updateModel() {
67
68 }
69
70 @Override
71 protected void hideView(View view) {
72 contentPanel.clear();
73 }
74
75 @Override
76 protected void renderView(View view) {
77 contentPanel.add(view.asWidget());
78 }
79
80 public static ComplexPanel getApplicationViewContainer(){
81 return contentPanel;
82 }
83
84 @Override
85 public void showDefaultView(Callback<Boolean> onReadyCallback) {
86 super.showView(AppViews.HOME);
87 if(this.getCurrentView() instanceof Controller){
88 ((Controller) this.getCurrentView()).showDefaultView(onReadyCallback);
89 }
90 else{
91 onReadyCallback.exec(true);
92 }
93 }
94 }