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