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 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
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(controllerId); |
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 | |
|
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 | |
|
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 | |
} |