Revision 84746052
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import com.vaadin.data.Property; |
22 | 22 |
import com.vaadin.spring.annotation.SpringComponent; |
23 |
import com.vaadin.ui.AbstractSelect; |
|
24 | 23 |
import com.vaadin.ui.Field; |
25 | 24 |
|
26 | 25 |
import eu.etaxonomy.cdm.api.service.INameService; |
... | ... | |
50 | 49 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
51 | 50 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
52 | 51 |
import eu.etaxonomy.vaadin.component.ReloadableLazyComboBox; |
53 |
import eu.etaxonomy.vaadin.component.ReloadableSelect; |
|
54 | 52 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmDTOEditorPresenter; |
55 | 53 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
56 | 54 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
... | ... | |
261 | 259 |
return; |
262 | 260 |
} |
263 | 261 |
|
264 |
referenceEditorPopup = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView(), null);
|
|
262 |
referenceEditorPopup = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView(), event.getTarget());
|
|
265 | 263 |
|
266 | 264 |
referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
267 | 265 |
referenceEditorPopup.withDeleteButton(true); |
... | ... | |
282 | 280 |
if(getView() == null || event.getSourceView() != getView() ){ |
283 | 281 |
return; |
284 | 282 |
} |
285 |
referenceEditorPopup = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView(), null);
|
|
283 |
referenceEditorPopup = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView(), event.getTarget());
|
|
286 | 284 |
|
287 | 285 |
referenceEditorPopup.withDeleteButton(true); |
288 | 286 |
referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator); |
289 | 287 |
referenceEditorPopup.loadInEditor(event.getEntityUuid()); |
290 | 288 |
if(newReferenceInstantiator != null){ |
291 |
// this is a bit clumsy, we actually need to inject something like a view configurer
|
|
289 |
// this is a bit clumsy, we actually need to inject something like a view configurator
|
|
292 | 290 |
// which can enable, disable fields |
293 | 291 |
referenceEditorPopup.getInReferenceCombobox().setEnabled(false); |
294 | 292 |
referenceEditorPopup.getTypeSelect().setEnabled(false); |
... | ... | |
301 | 299 |
if(event.getSourceView() instanceof AbstractPopupEditor) { |
302 | 300 |
|
303 | 301 |
AbstractPopupEditor popupEditor = (AbstractPopupEditor) event.getSourceView(); |
304 |
Field<?> targetField = getNavigationManager().targetFieldOf(getView(), popupEditor); |
|
305 | 302 |
|
306 |
Property ds = targetField.getPropertyDataSource(); |
|
307 |
if(event.getSourceView() == referenceEditorPopup){ |
|
308 |
if(event.isCreateOrModifiedType()){ |
|
303 |
Field<?> targetField = getNavigationManager().targetFieldOf(popupEditor); |
|
304 |
|
|
305 |
if(targetField != null){ |
|
306 |
|
|
307 |
Property ds = targetField.getPropertyDataSource(); |
|
309 | 308 |
|
310 |
getCache().load(event.getEntity()); |
|
311 |
if(event.isCreatedType()){ |
|
312 |
getView().getNomReferenceCombobox().setValue((Reference) event.getEntity()); |
|
313 |
} else { |
|
314 |
getView().getNomReferenceCombobox().reload(); // refreshSelectedValue(modifiedReference); |
|
309 |
if(event.getSourceView() == referenceEditorPopup){ |
|
310 |
if(event.isCreateOrModifiedType()){ |
|
311 |
|
|
312 |
getCache().load(event.getEntity()); |
|
313 |
if(event.isCreatedType()){ |
|
314 |
getView().getNomReferenceCombobox().setValue((Reference) event.getEntity()); |
|
315 |
} else { |
|
316 |
getView().getNomReferenceCombobox().reload(); // refreshSelectedValue(modifiedReference); |
|
317 |
} |
|
318 |
getView().getCombinationAuthorshipField().discard(); //refresh from the datasource |
|
319 |
getView().updateAuthorshipFields(); |
|
315 | 320 |
} |
316 |
getView().getCombinationAuthorshipField().discard(); //refresh from the datasource |
|
317 |
getView().updateAuthorshipFields();
|
|
321 |
|
|
322 |
referenceEditorPopup = null;
|
|
318 | 323 |
} |
324 |
if(event.getSourceView() == basionymNamePopup){ |
|
325 |
ReloadableLazyComboBox basionymSourceField = (ReloadableLazyComboBox)targetField; |
|
319 | 326 |
|
320 |
referenceEditorPopup = null; |
|
321 |
} |
|
322 |
if(event.getSourceView() == basionymNamePopup){ |
|
323 |
AbstractSelect basionymSourceField = (AbstractSelect) targetField; |
|
324 |
if(event.isCreateOrModifiedType()){ |
|
325 |
|
|
326 |
getCache().load(event.getEntity()); |
|
327 |
if(event.isCreatedType()){ |
|
328 |
basionymSourceField .setValue(event.getEntity()); |
|
329 |
} else { |
|
330 |
((ReloadableSelect)basionymSourceField).reload(); |
|
327 |
if(event.isCreateOrModifiedType()){ |
|
328 |
|
|
329 |
getCache().load(event.getEntity()); |
|
330 |
if(event.isCreatedType()){ |
|
331 |
basionymSourceField .setValue(event.getEntity()); |
|
332 |
} else { |
|
333 |
basionymSourceField.reload(); |
|
334 |
} |
|
335 |
getView().getBasionymAuthorshipField().discard(); //refresh from the datasource |
|
336 |
getView().getExBasionymAuthorshipField().discard(); //refresh from the datasource |
|
337 |
getView().updateAuthorshipFields(); |
|
338 |
|
|
339 |
} |
|
340 |
if(event.isRemovedType()){ |
|
341 |
basionymSourceField.setValue(null); |
|
342 |
getView().updateAuthorshipFields(); |
|
331 | 343 |
} |
332 |
getView().getBasionymAuthorshipField().discard(); //refresh from the datasource |
|
333 |
getView().getExBasionymAuthorshipField().discard(); //refresh from the datasource |
|
334 |
getView().updateAuthorshipFields(); |
|
335 | 344 |
|
336 |
} |
|
337 |
if(event.isRemovedType()){ |
|
338 |
basionymSourceField.setValue(null); |
|
339 |
getView().updateAuthorshipFields(); |
|
345 |
basionymNamePopup = null; |
|
340 | 346 |
} |
341 | 347 |
|
342 |
basionymNamePopup = null; |
|
343 | 348 |
} |
344 |
|
|
345 | 349 |
} |
346 | 350 |
} |
347 | 351 |
|
Also available in: Unified diff
PopupViewRegistration to manage view popupview and target field - fixing problems