1 package org.kuali.student.common.ui.client.configurable.mvc.layouts;
2
3 import java.util.List;
4
5 import org.kuali.student.common.ui.client.configurable.mvc.LayoutController;
6 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
7 import org.kuali.student.common.ui.client.mvc.Callback;
8 import org.kuali.student.common.ui.client.mvc.View;
9 import org.kuali.student.common.ui.client.mvc.history.HistoryManager;
10 import org.kuali.student.common.ui.client.util.ExportElement;
11 import org.kuali.student.common.ui.client.widgets.headers.KSDocumentHeader;
12 import org.kuali.student.common.ui.client.widgets.tabs.KSTabPanel;
13 import org.kuali.student.common.ui.client.widgets.tabs.KSTabPanel.TabPanelStyle;
14
15 import com.google.gwt.user.client.ui.FlowPanel;
16 import com.google.gwt.user.client.ui.Widget;
17
18
19
20
21
22
23
24
25 public class TabMenuController extends LayoutController{
26
27 protected KSTabPanel tabPanel = new KSTabPanel(TabPanelStyle.SMALL);
28 protected FlowPanel layout = new FlowPanel();
29 protected KSDocumentHeader header = new KSDocumentHeader(false);
30
31 public TabMenuController(String controllerId) {
32 super();
33 header.addStyleName("tabLayout-ContentHeader");
34 layout.add(header);
35 header.setVisible(false);
36 layout.add(tabPanel);
37 this.initWidget(layout);
38 }
39
40
41
42
43 public void setBasicTitle(String titleText){
44 layout.insert(SectionTitle.generateH1Title(titleText), 0);
45 }
46
47 public void setContentTitle(String title){
48 header.setTitle(title);
49 header.setVisible(true);
50 }
51
52 public void addContentWidget(Widget w){
53 header.addWidget(w);
54 header.setVisible(true);
55 }
56
57 public void setContentInfo(String info){
58 header.getInfoLabel().setHTML(info);
59 header.getInfoLabel().removeStyleName("content-warning");
60 header.getInfoLabel().addStyleName("content-info");
61 }
62
63 public void setContentWarning(String info){
64 header.getInfoLabel().setHTML(info);
65 header.getInfoLabel().removeStyleName("content-info");
66 header.getInfoLabel().addStyleName("content-warning");
67
68 }
69
70 public void showPrint(boolean show){
71 header.showPrint(show);
72 }
73
74 public void showExport(boolean show) {
75 header.showExport(show);
76 }
77
78
79
80
81 @Override
82 public void updateModel() {
83 this.updateModelFromCurrentView();
84 }
85
86 @Override
87 protected void hideView(View view) {
88
89 }
90
91 @Override
92 protected void renderView(View view) {
93
94 }
95
96 @Override
97 public void showDefaultView(Callback<Boolean> onReadyCallback) {
98 super.showDefaultView(onReadyCallback);
99 if(this.defaultView != null){
100 tabPanel.selectTab(this.defaultView.toString());
101 }
102 }
103
104 public void addTab(final View view, String tabName){
105 super.addView(view);
106 tabPanel.addTab(view.getViewEnum().toString(), tabName, view.asWidget());
107 tabPanel.addTabCustomCallback(view.getViewEnum().toString(), new Callback<String>(){
108 @Override
109 public void exec(String result) {
110 HistoryManager.setLogNavigationHistory(false);
111 showView(view.getViewEnum());
112 }
113 });
114 }
115
116 @Override
117 public List<ExportElement> getExportElementsFromView() {
118 return super.getExportElementsFromView();
119
120 }
121 }