1 | |
package org.kuali.student.lum.program.client.major.edit; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.Iterator; |
5 | |
import java.util.List; |
6 | |
import java.util.Set; |
7 | |
import java.util.TreeSet; |
8 | |
|
9 | |
import org.kuali.student.common.assembly.data.Data; |
10 | |
import org.kuali.student.common.assembly.data.Data.Property; |
11 | |
import org.kuali.student.common.assembly.data.QueryPath; |
12 | |
import org.kuali.student.common.ui.client.application.Application; |
13 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
14 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
15 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView; |
16 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
17 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
18 | |
import org.kuali.student.common.ui.client.mvc.HasCrossConstraints; |
19 | |
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
20 | |
import org.kuali.student.common.ui.client.mvc.View; |
21 | |
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
22 | |
import org.kuali.student.common.ui.client.service.DataSaveResult; |
23 | |
import org.kuali.student.common.ui.client.validator.ValidatorClientUtils; |
24 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
25 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract; |
26 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotification; |
27 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotifier; |
28 | |
import org.kuali.student.common.ui.shared.IdAttributes; |
29 | |
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
30 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
31 | |
import org.kuali.student.lum.common.client.configuration.LUMViews; |
32 | |
import org.kuali.student.lum.common.client.helpers.RecentlyViewedHelper; |
33 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
34 | |
import org.kuali.student.lum.program.client.ProgramConstants; |
35 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
36 | |
import org.kuali.student.lum.program.client.ProgramSections; |
37 | |
import org.kuali.student.lum.program.client.ProgramStatus; |
38 | |
import org.kuali.student.lum.program.client.ProgramUtils; |
39 | |
import org.kuali.student.lum.program.client.events.AddSpecializationEvent; |
40 | |
import org.kuali.student.lum.program.client.events.AfterSaveEvent; |
41 | |
import org.kuali.student.lum.program.client.events.ChangeViewEvent; |
42 | |
import org.kuali.student.lum.program.client.events.MetadataLoadedEvent; |
43 | |
import org.kuali.student.lum.program.client.events.ModelLoadedEvent; |
44 | |
import org.kuali.student.lum.program.client.events.SpecializationCreatedEvent; |
45 | |
import org.kuali.student.lum.program.client.events.SpecializationSaveEvent; |
46 | |
import org.kuali.student.lum.program.client.events.SpecializationUpdateEvent; |
47 | |
import org.kuali.student.lum.program.client.events.StateChangeEvent; |
48 | |
import org.kuali.student.lum.program.client.events.StoreRequirementIDsEvent; |
49 | |
import org.kuali.student.lum.program.client.events.UpdateEvent; |
50 | |
import org.kuali.student.lum.program.client.major.MajorController; |
51 | |
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
52 | |
import org.kuali.student.lum.program.client.rpc.AbstractCallback; |
53 | |
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
54 | |
|
55 | |
import com.google.gwt.core.client.GWT; |
56 | |
import com.google.gwt.event.dom.client.ClickEvent; |
57 | |
import com.google.gwt.event.dom.client.ClickHandler; |
58 | |
import com.google.gwt.event.shared.HandlerManager; |
59 | |
import com.google.gwt.user.client.Window; |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | 0 | public class MajorEditController extends MajorController { |
65 | |
|
66 | 0 | private final KSButton saveButton = new KSButton(ProgramProperties.get().common_save()); |
67 | 0 | private final KSButton cancelButton = new KSButton(ProgramProperties.get().common_cancel(), KSButtonAbstract.ButtonStyle.ANCHOR_LARGE_CENTERED); |
68 | 0 | private final Set<String> existingVariationIds = new TreeSet<String>(); |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
public MajorEditController(DataModel programModel, ViewContext viewContext, HandlerManager eventBus) { |
77 | 0 | super(programModel, viewContext, eventBus); |
78 | 0 | configurer = GWT.create(MajorEditConfigurer.class); |
79 | 0 | sideBar.setState(ProgramSideBar.State.EDIT); |
80 | 0 | initHandlers(); |
81 | 0 | } |
82 | |
|
83 | |
@Override |
84 | |
protected void configureView() { |
85 | 0 | super.configureView(); |
86 | 0 | if (!initialized) { |
87 | 0 | eventBus.fireEvent(new MetadataLoadedEvent(programModel.getDefinition(), this)); |
88 | 0 | List<Enum<?>> excludedViews = new ArrayList<Enum<?>>(); |
89 | 0 | excludedViews.add(ProgramSections.PROGRAM_REQUIREMENTS_EDIT); |
90 | 0 | excludedViews.add(ProgramSections.SUPPORTING_DOCUMENTS_EDIT); |
91 | 0 | excludedViews.add(ProgramSections.SUMMARY); |
92 | 0 | addCommonButton(ProgramProperties.get().program_menu_sections(), saveButton, excludedViews); |
93 | 0 | addCommonButton(ProgramProperties.get().program_menu_sections(), cancelButton, excludedViews); |
94 | 0 | initialized = true; |
95 | |
} |
96 | 0 | } |
97 | |
|
98 | |
private void initHandlers() { |
99 | 0 | saveButton.addClickHandler(new ClickHandler() { |
100 | |
|
101 | |
@Override |
102 | |
public void onClick(ClickEvent event) { |
103 | 0 | doSave(); |
104 | 0 | } |
105 | |
}); |
106 | 0 | cancelButton.addClickHandler(new ClickHandler() { |
107 | |
|
108 | |
@Override |
109 | |
public void onClick(ClickEvent event) { |
110 | 0 | doCancel(); |
111 | 0 | } |
112 | |
}); |
113 | 0 | eventBus.addHandler(UpdateEvent.TYPE, new UpdateEvent.Handler() { |
114 | |
@Override |
115 | |
public void onEvent(UpdateEvent event) { |
116 | 0 | Enum<?> view = event.getCurrentView(); |
117 | 0 | if (view != null) { |
118 | 0 | setCurrentViewEnum(view); |
119 | |
} |
120 | 0 | doSave(event.getOkCallback()); |
121 | |
|
122 | 0 | } |
123 | |
}); |
124 | 0 | eventBus.addHandler(StateChangeEvent.TYPE, new StateChangeEvent.Handler() { |
125 | |
@Override |
126 | |
public void onEvent(final StateChangeEvent event) { |
127 | |
|
128 | |
|
129 | |
|
130 | 0 | programRemoteService.validate(programModel.getRoot(), new KSAsyncCallback<List<ValidationResultInfo>>(){ |
131 | |
@Override |
132 | |
public void onSuccess(final List<ValidationResultInfo> currentStateResults) { |
133 | 0 | programModel.validateNextState(new Callback<List<ValidationResultInfo>>() { |
134 | |
@Override |
135 | |
public void exec(List<ValidationResultInfo> nextStateResults) { |
136 | |
|
137 | 0 | Application.getApplicationContext().clearValidationWarnings(); |
138 | 0 | Application.getApplicationContext().addValidationWarnings(currentStateResults); |
139 | 0 | isValid(Application.getApplicationContext().getValidationWarnings(), false); |
140 | |
|
141 | 0 | boolean isSectionValid = isValid(nextStateResults, true) |
142 | |
&& Application.getApplicationContext().getValidationWarnings().isEmpty(); |
143 | 0 | if (isSectionValid) { |
144 | 0 | Callback<Boolean> callback = new Callback<Boolean>() { |
145 | |
@Override |
146 | |
public void exec(Boolean result) { |
147 | 0 | if (result) { |
148 | 0 | reloadMetadata = true; |
149 | 0 | loadMetadata(new Callback<Boolean>() { |
150 | |
@Override |
151 | |
public void exec(Boolean result) { |
152 | 0 | if (result) { |
153 | 0 | ProgramUtils.syncMetadata(configurer, programModel.getDefinition()); |
154 | 0 | HistoryManager.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), context); |
155 | |
} |
156 | 0 | } |
157 | |
}); |
158 | |
} |
159 | 0 | } |
160 | |
}; |
161 | 0 | updateState(event.getProgramStatus().getValue(), callback); |
162 | 0 | } else { |
163 | 0 | KSNotifier.add(new KSNotification("Unable to save, please check fields for errors.", false, true, 5000)); |
164 | |
} |
165 | 0 | } |
166 | |
}); |
167 | |
|
168 | |
|
169 | 0 | } |
170 | |
|
171 | |
}); |
172 | 0 | } |
173 | |
}); |
174 | |
|
175 | 0 | eventBus.addHandler(SpecializationSaveEvent.TYPE, new SpecializationSaveEvent.Handler() { |
176 | |
@Override |
177 | |
public void onEvent(SpecializationSaveEvent event) { |
178 | |
|
179 | 0 | Data currentVariations = getDataProperty(ProgramConstants.VARIATIONS); |
180 | |
|
181 | 0 | existingVariationIds.clear(); |
182 | |
|
183 | 0 | for (Data.Property prop : currentVariations) { |
184 | 0 | String existingId = (String) ((Data) prop.getValue()).get(ProgramConstants.ID); |
185 | 0 | existingVariationIds.add(existingId); |
186 | 0 | } |
187 | 0 | String updatedId = event.getData().get(ProgramConstants.ID); |
188 | 0 | Integer updatedKey = null; |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | 0 | if (updatedId != null) { |
195 | 0 | for (Data.Property prop : currentVariations) { |
196 | 0 | String id = (String) ((Data) prop.getValue()).get(ProgramConstants.ID); |
197 | 0 | if (updatedId.equals(id)) { |
198 | 0 | updatedKey = prop.getKey(); |
199 | 0 | Data currentMetaInfo = ((Data) prop.getValue()).get("metaInfo"); |
200 | 0 | String latestVersionInd = currentMetaInfo.get("versionInd"); |
201 | 0 | Data newMetaInfo = event.getData().get("metaInfo"); |
202 | 0 | if (newMetaInfo == null) { |
203 | 0 | newMetaInfo = new Data(); |
204 | 0 | event.getData().set("metaInfo", newMetaInfo); |
205 | |
} |
206 | 0 | newMetaInfo.set("versionInd", latestVersionInd); |
207 | 0 | break; |
208 | |
} |
209 | 0 | } |
210 | |
|
211 | 0 | currentVariations.set(updatedKey, event.getData()); |
212 | |
} else { |
213 | 0 | currentVariations.add(event.getData()); |
214 | |
|
215 | |
} |
216 | 0 | doSave(); |
217 | 0 | } |
218 | |
}); |
219 | 0 | eventBus.addHandler(AddSpecializationEvent.TYPE, new AddSpecializationEvent.Handler() { |
220 | |
@Override |
221 | |
public void onEvent(AddSpecializationEvent event) { |
222 | 0 | String id = getStringProperty(ProgramConstants.ID); |
223 | 0 | ProgramRegistry.setRow((getDataProperty(ProgramConstants.VARIATIONS)).size()); |
224 | 0 | ProgramRegistry.setData(ProgramUtils.createNewSpecializationBasedOnMajor(programModel)); |
225 | 0 | ViewContext viewContext = new ViewContext(); |
226 | 0 | viewContext.setId(id); |
227 | 0 | viewContext.setIdType(IdAttributes.IdType.OBJECT_ID); |
228 | 0 | HistoryManager.navigate(AppLocations.Locations.EDIT_VARIATION.getLocation(), viewContext); |
229 | |
|
230 | 0 | } |
231 | |
}); |
232 | |
|
233 | 0 | eventBus.addHandler(StoreRequirementIDsEvent.TYPE, new StoreRequirementIDsEvent.Handler() { |
234 | |
@Override |
235 | |
public void onEvent(StoreRequirementIDsEvent event) { |
236 | 0 | List<String> ids = event.getProgramRequirementIds(); |
237 | |
|
238 | 0 | programModel.set(QueryPath.parse(ProgramConstants.PROGRAM_REQUIREMENTS), new Data()); |
239 | 0 | Data programRequirements = programModel.get(ProgramConstants.PROGRAM_REQUIREMENTS); |
240 | |
|
241 | 0 | if (programRequirements == null) { |
242 | 0 | Window.alert("Cannot find program requirements in data model."); |
243 | 0 | GWT.log("Cannot find program requirements in data model", null); |
244 | 0 | return; |
245 | |
} |
246 | |
|
247 | 0 | for (String id : ids) { |
248 | 0 | programRequirements.add(id); |
249 | |
} |
250 | 0 | doSave(); |
251 | 0 | } |
252 | |
}); |
253 | 0 | eventBus.addHandler(ChangeViewEvent.TYPE, new ChangeViewEvent.Handler() { |
254 | |
@Override |
255 | |
public void onEvent(ChangeViewEvent event) { |
256 | 0 | showView(event.getViewToken()); |
257 | 0 | } |
258 | |
}); |
259 | 0 | } |
260 | |
|
261 | |
@Override |
262 | |
protected void loadModel(ModelRequestCallback<DataModel> callback) { |
263 | 0 | ViewContext viewContext = getViewContext(); |
264 | 0 | if (viewContext.getIdType() == IdType.COPY_OF_OBJECT_ID) { |
265 | 0 | createNewVersionAndLoadModel(callback, viewContext); |
266 | |
} else { |
267 | 0 | super.loadModel(callback); |
268 | |
} |
269 | 0 | } |
270 | |
|
271 | |
protected void createNewVersionAndLoadModel(final ModelRequestCallback<DataModel> callback, final ViewContext viewContext) { |
272 | 0 | Data data = new Data(); |
273 | 0 | Data versionData = new Data(); |
274 | 0 | versionData.set(new Data.StringKey("versionIndId"), getViewContext().getId()); |
275 | 0 | versionData.set(new Data.StringKey("versionComment"), "Major Disicpline Version"); |
276 | 0 | data.set(new Data.StringKey("versionInfo"), versionData); |
277 | |
|
278 | 0 | programRemoteService.saveData(data, new AbstractCallback<DataSaveResult>(ProgramProperties.get().common_retrievingData()) { |
279 | |
@Override |
280 | |
public void onSuccess(DataSaveResult result) { |
281 | 0 | super.onSuccess(result); |
282 | 0 | refreshModelAndView(result); |
283 | 0 | viewContext.setId(ProgramUtils.getProgramId(programModel)); |
284 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
285 | 0 | callback.onModelReady(programModel); |
286 | 0 | eventBus.fireEvent(new ModelLoadedEvent(programModel)); |
287 | 0 | } |
288 | |
|
289 | |
@Override |
290 | |
public void onFailure(Throwable caught) { |
291 | 0 | super.onFailure(caught); |
292 | 0 | callback.onRequestFail(caught); |
293 | 0 | } |
294 | |
}); |
295 | |
|
296 | 0 | } |
297 | |
|
298 | |
private void doSave(final Callback<Boolean> okCallback) { |
299 | 0 | requestModel(new ModelRequestCallback<DataModel>() { |
300 | |
@Override |
301 | |
public void onModelReady(DataModel model) { |
302 | 0 | MajorEditController.this.updateModelFromCurrentView(); |
303 | 0 | model.validate(new Callback<List<ValidationResultInfo>>() { |
304 | |
@Override |
305 | |
public void exec(List<ValidationResultInfo> result) { |
306 | 0 | boolean isSectionValid = isValid(result, true); |
307 | 0 | if (isSectionValid) { |
308 | 0 | saveData(okCallback); |
309 | |
} else { |
310 | 0 | okCallback.exec(false); |
311 | 0 | KSNotifier.add(new KSNotification("Unable to save, please check fields for errors.", false, true, 5000)); |
312 | |
} |
313 | 0 | } |
314 | |
}); |
315 | |
|
316 | 0 | } |
317 | |
|
318 | |
@Override |
319 | |
public void onRequestFail(Throwable cause) { |
320 | 0 | GWT.log("Unable to retrieve model for validation and save", cause); |
321 | 0 | } |
322 | |
}); |
323 | 0 | } |
324 | |
|
325 | |
private void doCancel() { |
326 | 0 | showView(ProgramSections.SUMMARY); |
327 | 0 | } |
328 | |
|
329 | |
@Override |
330 | |
protected void doSave() { |
331 | 0 | doSave(NO_OP_CALLBACK); |
332 | 0 | } |
333 | |
|
334 | |
private void saveData(final Callback<Boolean> okCallback) { |
335 | 0 | programRemoteService.saveData(programModel.getRoot(), new AbstractCallback<DataSaveResult>(ProgramProperties.get().common_savingData()) { |
336 | |
@Override |
337 | |
public void onSuccess(DataSaveResult result) { |
338 | 0 | super.onSuccess(result); |
339 | |
|
340 | |
|
341 | 0 | clearAllWarnings(); |
342 | 0 | Application.getApplicationContext().clearValidationWarnings(); |
343 | |
|
344 | 0 | List<ValidationResultInfo> validationResults = result.getValidationResults(); |
345 | 0 | Application.getApplicationContext().addValidationWarnings(validationResults); |
346 | 0 | if (ValidatorClientUtils.hasErrors(validationResults)) { |
347 | 0 | ProgramUtils.retrofitValidationResults(validationResults); |
348 | 0 | isValid(validationResults, false, true); |
349 | 0 | ProgramUtils.handleValidationErrorsForSpecializations(validationResults, programModel); |
350 | |
|
351 | |
|
352 | 0 | Data currentVariations = getDataProperty(ProgramConstants.VARIATIONS); |
353 | |
|
354 | 0 | existingVariationIds.clear(); |
355 | |
|
356 | 0 | for (Iterator<Property> iter = currentVariations.iterator();iter.hasNext();) { |
357 | 0 | Property prop = iter.next(); |
358 | 0 | String existingId = (String) ((Data) prop.getValue()).get(ProgramConstants.ID); |
359 | 0 | if(existingId==null){ |
360 | 0 | iter.remove(); |
361 | |
}else{ |
362 | 0 | existingVariationIds.add(existingId); |
363 | |
} |
364 | 0 | } |
365 | |
|
366 | 0 | okCallback.exec(false); |
367 | 0 | } else { |
368 | 0 | refreshModelAndView(result); |
369 | 0 | resetFieldInteractionFlag(); |
370 | 0 | configurer.applyPermissions(); |
371 | 0 | handleSpecializations(); |
372 | 0 | throwAfterSaveEvent(); |
373 | 0 | HistoryManager.logHistoryChange(); |
374 | 0 | ViewContext viewContext = getViewContext(); |
375 | 0 | viewContext.setId(getStringProperty(ProgramConstants.ID)); |
376 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
377 | |
|
378 | 0 | if (ValidatorClientUtils.hasWarnings(validationResults)){ |
379 | |
|
380 | 0 | isValid(result.getValidationResults(), false, true); |
381 | 0 | KSNotifier.show("Saved with Warnings"); |
382 | |
} else { |
383 | 0 | KSNotifier.show(ProgramProperties.get().common_successfulSave()); |
384 | |
} |
385 | |
|
386 | |
|
387 | 0 | ViewContext docContext = new ViewContext(); |
388 | 0 | docContext.setId(getStringProperty(ProgramConstants.ID)); |
389 | 0 | docContext.setIdType(IdType.OBJECT_ID); |
390 | 0 | docContext.setAttribute(ProgramConstants.TYPE, ProgramConstants.MAJOR_LU_TYPE_ID + '/' + ProgramSections.PROGRAM_DETAILS_VIEW); |
391 | 0 | RecentlyViewedHelper.addDocument(getProgramName(), |
392 | |
HistoryManager.appendContext(AppLocations.Locations.VIEW_PROGRAM.getLocation(), docContext)); |
393 | |
|
394 | 0 | okCallback.exec(true); |
395 | 0 | processCurrentView(); |
396 | |
} |
397 | 0 | } |
398 | |
}); |
399 | 0 | } |
400 | |
|
401 | |
private void processCurrentView() { |
402 | 0 | Enum<?> currentView = getCurrentViewEnum(); |
403 | 0 | if (currentView.name().equals(ProgramSections.VIEW_ALL.name())) { |
404 | 0 | HistoryManager.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), getViewContext()); |
405 | |
} else { |
406 | 0 | showView(currentView); |
407 | |
} |
408 | 0 | } |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
private void handleSpecializations() { |
414 | 0 | String newVariationId = null; |
415 | 0 | Data variations = programModel.get(ProgramConstants.VARIATIONS); |
416 | 0 | for (Data.Property prop : variations) { |
417 | 0 | String varId = (String) ((Data) prop.getValue()).get(ProgramConstants.ID); |
418 | 0 | if (!existingVariationIds.contains(varId)) { |
419 | 0 | newVariationId = varId; |
420 | 0 | existingVariationIds.add(newVariationId); |
421 | 0 | break; |
422 | |
} |
423 | 0 | } |
424 | 0 | if (newVariationId != null) { |
425 | 0 | eventBus.fireEvent(new SpecializationCreatedEvent(newVariationId)); |
426 | |
} else { |
427 | 0 | eventBus.fireEvent(new SpecializationUpdateEvent(variations)); |
428 | |
} |
429 | 0 | } |
430 | |
|
431 | |
private void throwAfterSaveEvent() { |
432 | 0 | eventBus.fireEvent(new AfterSaveEvent(programModel, this)); |
433 | 0 | } |
434 | |
|
435 | |
@Override |
436 | |
public void onModelLoadedEvent() { |
437 | 0 | Enum<?> changeSection = ProgramRegistry.getSection(); |
438 | 0 | if (changeSection != null) { |
439 | 0 | showView(changeSection); |
440 | 0 | ProgramRegistry.setSection(null); |
441 | |
} else { |
442 | 0 | String id = getStringProperty(ProgramConstants.ID); |
443 | 0 | if (id == null) { |
444 | 0 | showView(ProgramSections.PROGRAM_DETAILS_EDIT); |
445 | |
} else { |
446 | 0 | showView(ProgramSections.SUMMARY); |
447 | |
} |
448 | |
} |
449 | |
|
450 | 0 | } |
451 | |
|
452 | |
@Override |
453 | |
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
454 | 0 | if(!initialized){ |
455 | 0 | Application.getApplicationContext().clearCrossConstraintMap(null); |
456 | 0 | Application.getApplicationContext().clearPathToFieldMapping(null); |
457 | |
} |
458 | |
|
459 | 0 | Application.getApplicationContext().setParentPath(""); |
460 | 0 | super.beforeShow(onReadyCallback); |
461 | 0 | } |
462 | |
|
463 | |
|
464 | |
|
465 | |
@Override |
466 | |
public <V extends Enum<?>> void showView(V viewType, |
467 | |
final Callback<Boolean> onReadyCallback) { |
468 | 0 | Callback<Boolean> updateCrossConstraintsCallback = new Callback<Boolean>(){ |
469 | |
public void exec(Boolean result) { |
470 | 0 | onReadyCallback.exec(result); |
471 | 0 | for(HasCrossConstraints crossConstraint:Application.getApplicationContext().getCrossConstraints(null)){ |
472 | 0 | crossConstraint.reprocessWithUpdatedConstraints(); |
473 | |
} |
474 | 0 | showWarnings(); |
475 | 0 | } |
476 | |
}; |
477 | 0 | super.showView(viewType, updateCrossConstraintsCallback); |
478 | 0 | } |
479 | |
|
480 | |
|
481 | |
@Override |
482 | |
public void beforeViewChange(Enum<?> viewChangingTo, final Callback<Boolean> okToChangeCallback){ |
483 | 0 | if(LUMViews.VARIATION_EDIT.equals(viewChangingTo)){ |
484 | 0 | getView(ProgramSections.MANAGE_BODIES_EDIT, new Callback<View>(){ |
485 | |
@Override |
486 | |
public void exec(final View view) { |
487 | 0 | if(view!=null && view instanceof SectionView){ |
488 | 0 | requestModel(new ModelRequestCallback<DataModel>(){ |
489 | |
public void onModelReady(DataModel model) { |
490 | 0 | ((SectionView)view).updateWidgetData(model); |
491 | 0 | okToChangeCallback.exec(true); |
492 | 0 | } |
493 | |
public void onRequestFail(Throwable cause) { |
494 | 0 | okToChangeCallback.exec(false); |
495 | 0 | } |
496 | |
}); |
497 | |
}else{ |
498 | 0 | okToChangeCallback.exec(true); |
499 | |
} |
500 | 0 | }}); |
501 | |
}else{ |
502 | 0 | okToChangeCallback.exec(true); |
503 | |
} |
504 | 0 | this.showExport(isExportButtonActive()); |
505 | 0 | } |
506 | |
} |