Revision 06db1b37
Added by Andreas Kohlbecker about 3 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
12 | 12 |
import java.util.EnumSet; |
13 | 13 |
import java.util.HashMap; |
14 | 14 |
import java.util.HashSet; |
15 |
import java.util.List; |
|
15 | 16 |
import java.util.Map; |
16 | 17 |
import java.util.Set; |
17 | 18 |
import java.util.Stack; |
... | ... | |
109 | 110 |
|
110 | 111 |
private Map<CollectionPopupEditor, SpecimenTypeDesignationDTORow> collectionPopupEditorsRowMap = new HashMap<>(); |
111 | 112 |
|
112 |
private Map<ReferencePopupEditor, SpecimenTypeDesignationDTORow> referencePopupEditorsRowMap = new HashMap<>();
|
|
113 |
private Map<ReferencePopupEditor, ToOneRelatedEntityCombobox<Reference>> referencePopupEditorsCombobox = new HashMap<>();
|
|
113 | 114 |
|
114 | 115 |
private Set<CollectionRowItemCollection> popuEditorTypeDesignationSourceRows = new HashSet<>(); |
115 | 116 |
|
... | ... | |
234 | 235 |
} |
235 | 236 |
}); |
236 | 237 |
|
237 |
row.mediaSpecimenReference.loadFrom(
|
|
238 |
row.designationReference.loadFrom(
|
|
238 | 239 |
referencePagingProvider, |
239 | 240 |
referencePagingProvider, |
240 | 241 |
referencePagingProvider.getPageSize() |
241 | 242 |
); |
243 |
row.designationReference.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, row.designationReference.getSelect())); |
|
244 |
row.designationReference.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(row.designationReference.getSelect(), |
|
245 |
SpecimenTypeDesignationWorkingsetEditorPresenter.this)); |
|
246 |
row.designationReference.addClickListenerAddEntity(e -> doReferenceEditorAdd(row.designationReference)); |
|
247 |
row.designationReference.addClickListenerEditEntity(e -> { |
|
248 |
if(row.designationReference.getValue() != null){ |
|
249 |
doReferenceEditorEdit(row.designationReference); |
|
250 |
} |
|
251 |
}); |
|
242 | 252 |
|
253 |
row.mediaSpecimenReference.loadFrom( |
|
254 |
referencePagingProvider, |
|
255 |
referencePagingProvider, |
|
256 |
referencePagingProvider.getPageSize() |
|
257 |
); |
|
243 | 258 |
row.mediaSpecimenReference.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, row.mediaSpecimenReference.getSelect())); |
244 | 259 |
row.mediaSpecimenReference.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(row.mediaSpecimenReference.getSelect(), |
245 | 260 |
SpecimenTypeDesignationWorkingsetEditorPresenter.this)); |
246 |
row.mediaSpecimenReference.addClickListenerAddEntity(e -> doReferenceEditorAdd(row)); |
|
261 |
row.mediaSpecimenReference.addClickListenerAddEntity(e -> doReferenceEditorAdd(row.mediaSpecimenReference));
|
|
247 | 262 |
row.mediaSpecimenReference.addClickListenerEditEntity(e -> { |
248 | 263 |
if(row.mediaSpecimenReference.getValue() != null){ |
249 |
doReferenceEditorEdit(row); |
|
264 |
doReferenceEditorEdit(row.mediaSpecimenReference);
|
|
250 | 265 |
} |
251 | 266 |
}); |
252 | 267 |
|
... | ... | |
272 | 287 |
UserHelperAccess.userHelper().createAuthorityForCurrentUser(dto.getFieldUnit(), crud, null); |
273 | 288 |
} |
274 | 289 |
|
290 |
List<SpecimenTypeDesignationDTO> stdDTOs = dto.getSpecimenTypeDesignationDTOs(); |
|
291 |
for(SpecimenTypeDesignationDTO stddto : stdDTOs) { |
|
292 |
// clean up |
|
293 |
if(!stddto.getTypeStatus().hasDesignationSource()) { |
|
294 |
stddto.setDesignationReference(null); |
|
295 |
stddto.setDesignationReferenceDetail(null); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
275 | 299 |
specimenTypeDesignationWorkingSetService.save(dto); |
276 | 300 |
} |
277 | 301 |
|
... | ... | |
385 | 409 |
} |
386 | 410 |
} |
387 | 411 |
|
388 |
public void doReferenceEditorAdd(SpecimenTypeDesignationDTORow row) {
|
|
412 |
public void doReferenceEditorAdd(ToOneRelatedEntityCombobox<Reference> referenceComobox) {
|
|
389 | 413 |
|
390 | 414 |
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null); |
391 | 415 |
|
... | ... | |
394 | 418 |
referencePopupEditor.withDeleteButton(true); |
395 | 419 |
referencePopupEditor.loadInEditor(null); |
396 | 420 |
|
397 |
referencePopupEditorsRowMap.put(referencePopupEditor, row);
|
|
421 |
referencePopupEditorsCombobox.put(referencePopupEditor, referenceComobox);
|
|
398 | 422 |
} |
399 | 423 |
|
400 |
public void doReferenceEditorEdit(SpecimenTypeDesignationDTORow row) {
|
|
424 |
public void doReferenceEditorEdit(ToOneRelatedEntityCombobox<Reference> referenceComobox) {
|
|
401 | 425 |
|
402 | 426 |
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null); |
403 | 427 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
404 | 428 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
405 | 429 |
referencePopupEditor.withDeleteButton(true); |
406 |
referencePopupEditor.loadInEditor(row.mediaSpecimenReference.getValue().getUuid());
|
|
430 |
referencePopupEditor.loadInEditor(referenceComobox.getValue().getUuid());
|
|
407 | 431 |
|
408 |
referencePopupEditorsRowMap.put(referencePopupEditor, row);
|
|
432 |
referencePopupEditorsCombobox.put(referencePopupEditor, referenceComobox);
|
|
409 | 433 |
} |
410 | 434 |
|
411 | 435 |
@EventBusListenerMethod(filter = EntityChangeEventFilter.ReferenceFilter.class) |
... | ... | |
414 | 438 |
Reference newRef = getRepo().getReferenceService().load(event.getEntityUuid(), Arrays.asList(new String[]{"$"})); |
415 | 439 |
cache.load(newRef); |
416 | 440 |
|
441 |
ToOneRelatedEntityCombobox<Reference> combobox = referencePopupEditorsCombobox.get(event.getSourceView()); |
|
417 | 442 |
if(event.isCreatedType()){ |
418 |
SpecimenTypeDesignationDTORow row = referencePopupEditorsRowMap.get(event.getSourceView()); |
|
419 |
ToOneRelatedEntityCombobox<Reference> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 7); |
|
420 | 443 |
combobox.setValue((Reference) event.getEntity()); |
421 | 444 |
} else { |
422 | 445 |
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) { |
423 |
ToOneRelatedEntityCombobox<Reference> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 7); |
|
424 | 446 |
combobox.reload(); |
425 | 447 |
} |
426 | 448 |
} |
Also available in: Unified diff
fix #9301 adding designationReference and detail to specimen type designation editor