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