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 | 0 | public abstract class DelayedToolView extends LazyPanel implements ToolView{ |
35 | |
private Controller controller; |
36 | |
private Enum<?> viewEnum; |
37 | |
private String viewName; |
38 | |
|
39 | |
private HasReferenceId reference; |
40 | |
|
41 | 0 | private ModelRequestCallback<ReferenceModel> modelRequestCallback = |
42 | 0 | new ModelRequestCallback<ReferenceModel>(){ |
43 | |
public void onModelReady(ReferenceModel model) { |
44 | 0 | reference.setReferenceId(model.getReferenceId()); |
45 | 0 | reference.setReferenceTypeKey(model.getReferenceTypeKey()); |
46 | 0 | reference.setReferenceType(model.getReferenceType()); |
47 | 0 | reference.setReferenceState(model.getReferenceState()); |
48 | 0 | DelayedToolView.this.setVisible(true); |
49 | 0 | } |
50 | |
|
51 | |
public void onRequestFail(Throwable cause) { |
52 | 0 | Window.alert(cause.toString()); |
53 | 0 | } |
54 | |
}; |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | 0 | public DelayedToolView(Controller controller, Enum<?> viewEnum, String viewName) { |
62 | 0 | this.controller = controller; |
63 | 0 | this.viewName = viewName; |
64 | 0 | this.viewEnum = viewEnum; |
65 | 0 | } |
66 | |
|
67 | |
|
68 | 0 | public DelayedToolView(Enum<?> viewEnum, String viewName) { |
69 | 0 | this.controller = null; |
70 | 0 | this.viewEnum = viewEnum; |
71 | 0 | this.viewName = viewName; |
72 | 0 | } |
73 | |
|
74 | |
@Override |
75 | |
public void beforeShow(final Callback<Boolean> onReadyCallback){ |
76 | 0 | if (getWidget() instanceof HasReferenceId){ |
77 | 0 | reference = (HasReferenceId)getWidget(); |
78 | 0 | controller.requestModel(ReferenceModel.class, modelRequestCallback); |
79 | 0 | } else if (this instanceof HasReferenceId){ |
80 | 0 | reference = (HasReferenceId)this; |
81 | 0 | controller.requestModel(ReferenceModel.class, modelRequestCallback); |
82 | |
} else { |
83 | 0 | this.setVisible(true); |
84 | |
} |
85 | |
|
86 | 0 | onReadyCallback.exec(true); |
87 | 0 | } |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
@Override |
93 | |
public boolean beforeHide() { |
94 | 0 | return true; |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
@Override |
102 | |
public Controller getController() { |
103 | 0 | return this.controller; |
104 | |
} |
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
@Override |
111 | |
public String getName() { |
112 | 0 | return this.viewName; |
113 | |
} |
114 | |
|
115 | |
public Enum<?> getViewEnum() { |
116 | 0 | return viewEnum; |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
@Override |
123 | |
public void updateModel() { |
124 | |
|
125 | 0 | } |
126 | |
|
127 | |
public void setController(Controller controller){ |
128 | 0 | this.controller = controller; |
129 | 0 | } |
130 | |
|
131 | |
|
132 | |
public Widget asWidget(){ |
133 | 0 | return this; |
134 | |
} |
135 | |
|
136 | |
@Override |
137 | |
public String collectHistory(String historyStack) { |
138 | 0 | return null; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
@Override |
143 | |
protected Widget createWidget() { |
144 | |
|
145 | 0 | return null; |
146 | |
} |
147 | |
|
148 | |
@Override |
149 | |
public void onHistoryEvent(String historyStack) { |
150 | |
|
151 | 0 | } |
152 | |
|
153 | |
@Override |
154 | |
public void collectBreadcrumbNames(List<String> names) { |
155 | 0 | names.add(this.getName()); |
156 | |
|
157 | 0 | } |
158 | |
} |