1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.ui.client.configurable.mvc;
17
18 import java.util.List;
19
20 import org.kuali.student.common.ui.client.mvc.Callback;
21 import org.kuali.student.common.ui.client.mvc.Controller;
22 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
23 import org.kuali.student.common.ui.client.mvc.dto.ReferenceModel;
24
25 import com.google.gwt.user.client.Window;
26 import com.google.gwt.user.client.ui.LazyPanel;
27 import com.google.gwt.user.client.ui.Widget;
28
29
30
31
32
33
34
35 public abstract class DelayedToolView extends LazyPanel implements ToolView{
36 private Controller controller;
37 private Enum<?> viewEnum;
38 private String viewName;
39
40 private HasReferenceId reference;
41
42 private ModelRequestCallback<ReferenceModel> modelRequestCallback =
43 new ModelRequestCallback<ReferenceModel>(){
44 public void onModelReady(ReferenceModel model) {
45 reference.setReferenceId(model.getReferenceId());
46 reference.setReferenceTypeKey(model.getReferenceTypeKey());
47 reference.setReferenceType(model.getReferenceType());
48 reference.setReferenceState(model.getReferenceState());
49 DelayedToolView.this.setVisible(true);
50 }
51
52 public void onRequestFail(Throwable cause) {
53 Window.alert(cause.toString());
54 }
55 };
56
57
58
59
60
61
62 public DelayedToolView(Controller controller, Enum<?> viewEnum, String viewName) {
63 this.controller = controller;
64 this.viewName = viewName;
65 this.viewEnum = viewEnum;
66 }
67
68
69 public DelayedToolView(Enum<?> viewEnum, String viewName) {
70 this.controller = null;
71 this.viewEnum = viewEnum;
72 this.viewName = viewName;
73 }
74
75 @Override
76 public void beforeShow(final Callback<Boolean> onReadyCallback){
77 if (getWidget() instanceof HasReferenceId){
78 reference = (HasReferenceId)getWidget();
79 controller.requestModel(ReferenceModel.class, modelRequestCallback);
80 } else if (this instanceof HasReferenceId){
81 reference = (HasReferenceId)this;
82 controller.requestModel(ReferenceModel.class, modelRequestCallback);
83 } else {
84 this.setVisible(true);
85 }
86
87 onReadyCallback.exec(true);
88 }
89
90
91
92
93 @Override
94 public boolean beforeHide() {
95 return true;
96 }
97
98
99
100
101
102 @Override
103 public Controller getController() {
104 return this.controller;
105 }
106
107
108
109
110
111 @Override
112 public String getName() {
113 return this.viewName;
114 }
115
116 public Enum<?> getViewEnum() {
117 return viewEnum;
118 }
119
120
121
122
123 @Override
124 public void updateModel() {
125
126 }
127
128 public void setController(Controller controller){
129 this.controller = controller;
130 }
131
132
133 public Widget asWidget(){
134 return this;
135 }
136
137 @Override
138 public String collectHistory(String historyStack) {
139 return null;
140 }
141
142
143 @Override
144 protected Widget createWidget() {
145
146 return null;
147 }
148
149 @Override
150 public void onHistoryEvent(String historyStack) {
151
152 }
153
154 @Override
155 public void collectBreadcrumbNames(List<String> names) {
156 names.add(this.getName());
157
158 }
159
160 public boolean isExportButtonActive() {
161 return false;
162 }
163 }