Revision 29713b34
Added by Andreas Kohlbecker about 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.Arrays; |
12 | 12 |
import java.util.EnumSet; |
13 |
import java.util.HashMap; |
|
13 | 14 |
import java.util.HashSet; |
15 |
import java.util.Map; |
|
14 | 16 |
import java.util.Set; |
15 |
import java.util.UUID; |
|
16 | 17 |
|
17 | 18 |
import org.springframework.beans.factory.annotation.Autowired; |
18 | 19 |
import org.springframework.context.annotation.Scope; |
... | ... | |
92 | 93 |
|
93 | 94 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto; |
94 | 95 |
|
95 |
private CollectionPopupEditor collectionPopupEditor;
|
|
96 |
private Map<CollectionPopupEditor, SpecimenTypeDesignationDTORow> collectionPopupEditorsRowMap = new HashMap<>();
|
|
96 | 97 |
|
97 |
private Set<CollectionRowItemCollection> collectionPopuEditorSourceRows = new HashSet<>();
|
|
98 |
private Map<ReferencePopupEditor, SpecimenTypeDesignationDTORow> referencePopupEditorsRowMap = new HashMap<>();
|
|
98 | 99 |
|
99 |
private ReferencePopupEditor referencePopupEditor;
|
|
100 |
private Set<CollectionRowItemCollection> popuEditorTypeDesignationSourceRows = new HashSet<>();
|
|
100 | 101 |
|
101 | 102 |
private java.util.Collection<CdmBase> rootEntities = new HashSet<>(); |
102 | 103 |
|
... | ... | |
173 | 174 |
getView().getTypeDesignationsCollectionField().addElementAddedListener(e -> addTypeDesignation(e.getElement())); |
174 | 175 |
|
175 | 176 |
|
176 |
collectionPopuEditorSourceRows.clear();
|
|
177 |
popuEditorTypeDesignationSourceRows.clear();
|
|
177 | 178 |
getView().getTypeDesignationsCollectionField().setEditorInstantiator(new AbstractElementCollection.Instantiator<SpecimenTypeDesignationDTORow>() { |
178 | 179 |
|
179 | 180 |
CdmFilterablePagingProvider<Collection, Collection> collectionPagingProvider = new CdmFilterablePagingProvider<Collection, Collection>(getRepo().getCollectionService()); |
... | ... | |
205 | 206 |
row.collection.getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Collection>(row.collection)); |
206 | 207 |
row.collection.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Collection>(row.collection.getSelect(), |
207 | 208 |
SpecimenTypeDesignationWorkingsetEditorPresenter.this)); |
208 |
row.collection.addClickListenerAddEntity(e -> doCollectionEditorAdd()); |
|
209 |
row.collection.addClickListenerAddEntity(e -> doCollectionEditorAdd(row));
|
|
209 | 210 |
row.collection.addClickListenerEditEntity(e -> { |
210 | 211 |
if(row.collection.getValue() != null){ |
211 |
doCollectionEditorEdit(row.collection.getValue().getUuid());
|
|
212 |
doCollectionEditorEdit(row); |
|
212 | 213 |
} |
213 | 214 |
}); |
214 | 215 |
|
... | ... | |
222 | 223 |
row.mediaSpecimenReference.getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(row.mediaSpecimenReference)); |
223 | 224 |
row.mediaSpecimenReference.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(row.mediaSpecimenReference.getSelect(), |
224 | 225 |
SpecimenTypeDesignationWorkingsetEditorPresenter.this)); |
225 |
row.mediaSpecimenReference.addClickListenerAddEntity(e -> doReferenceEditorAdd()); |
|
226 |
row.mediaSpecimenReference.addClickListenerAddEntity(e -> doReferenceEditorAdd(row));
|
|
226 | 227 |
row.mediaSpecimenReference.addClickListenerEditEntity(e -> { |
227 | 228 |
if(row.mediaSpecimenReference.getValue() != null){ |
228 |
doReferenceEditorEdit(row.mediaSpecimenReference.getValue().getUuid());
|
|
229 |
doReferenceEditorEdit(row); |
|
229 | 230 |
} |
230 | 231 |
}); |
231 | 232 |
|
232 | 233 |
getView().applyDefaultComponentStyle(row.components()); |
233 | 234 |
|
234 |
collectionPopuEditorSourceRows.add(row);
|
|
235 |
popuEditorTypeDesignationSourceRows.add(row);
|
|
235 | 236 |
|
236 | 237 |
return row; |
237 | 238 |
} |
... | ... | |
306 | 307 |
return cache; |
307 | 308 |
} |
308 | 309 |
|
309 |
public void doCollectionEditorAdd() { |
|
310 |
public void doCollectionEditorAdd(SpecimenTypeDesignationDTORow row) {
|
|
310 | 311 |
|
311 |
collectionPopupEditor = getNavigationManager().showInPopup(CollectionPopupEditor.class, getView()); |
|
312 |
CollectionPopupEditor collectionPopupEditor = getNavigationManager().showInPopup(CollectionPopupEditor.class, getView());
|
|
312 | 313 |
|
313 | 314 |
collectionPopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
314 | 315 |
collectionPopupEditor.withDeleteButton(true); |
315 | 316 |
collectionPopupEditor.loadInEditor(null); |
317 |
|
|
318 |
collectionPopupEditorsRowMap.put(collectionPopupEditor, row); |
|
316 | 319 |
} |
317 | 320 |
|
318 |
public void doCollectionEditorEdit(UUID collectionUuid) {
|
|
321 |
public void doCollectionEditorEdit(SpecimenTypeDesignationDTORow row) {
|
|
319 | 322 |
|
320 |
collectionPopupEditor = getNavigationManager().showInPopup(CollectionPopupEditor.class, getView()); |
|
323 |
CollectionPopupEditor collectionPopupEditor = getNavigationManager().showInPopup(CollectionPopupEditor.class, getView());
|
|
321 | 324 |
|
322 | 325 |
collectionPopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
323 | 326 |
collectionPopupEditor.withDeleteButton(true); |
324 |
collectionPopupEditor.loadInEditor(collectionUuid); |
|
327 |
collectionPopupEditor.loadInEditor(row.collection.getValue().getUuid()); |
|
328 |
|
|
329 |
collectionPopupEditorsRowMap.put(collectionPopupEditor, row); |
|
325 | 330 |
} |
326 | 331 |
|
327 | 332 |
|
... | ... | |
333 | 338 |
); |
334 | 339 |
cache.load(newCollection); |
335 | 340 |
|
336 |
for( CollectionRowItemCollection row : collectionPopuEditorSourceRows) { |
|
337 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 2); |
|
341 |
if(event.isCreatedType()){ |
|
342 |
SpecimenTypeDesignationDTORow row = collectionPopupEditorsRowMap.get(event.getSourceView()); |
|
343 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 3); |
|
344 |
combobox.setValue((Collection) event.getEntity()); |
|
345 |
} |
|
346 |
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) { |
|
347 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 3); |
|
338 | 348 |
combobox.reload(); |
339 | 349 |
} |
340 | 350 |
} |
341 | 351 |
|
342 |
public void doReferenceEditorAdd() { |
|
352 |
public void doReferenceEditorAdd(SpecimenTypeDesignationDTORow row) {
|
|
343 | 353 |
|
344 |
referencePopupEditor = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView()); |
|
354 |
ReferencePopupEditor referencePopupEditor = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView());
|
|
345 | 355 |
|
346 | 356 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
347 | 357 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
348 | 358 |
referencePopupEditor.withDeleteButton(true); |
349 | 359 |
referencePopupEditor.loadInEditor(null); |
360 |
|
|
361 |
referencePopupEditorsRowMap.put(referencePopupEditor, row); |
|
350 | 362 |
} |
351 | 363 |
|
352 |
public void doReferenceEditorEdit(UUID referenceUuid) {
|
|
364 |
public void doReferenceEditorEdit(SpecimenTypeDesignationDTORow row) {
|
|
353 | 365 |
|
354 |
referencePopupEditor = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView()); |
|
366 |
ReferencePopupEditor referencePopupEditor = getNavigationManager().showInPopup(ReferencePopupEditor.class, getView());
|
|
355 | 367 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
356 | 368 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
357 | 369 |
referencePopupEditor.withDeleteButton(true); |
358 |
referencePopupEditor.loadInEditor(referenceUuid); |
|
370 |
referencePopupEditor.loadInEditor(row.mediaSpecimenReference.getValue().getUuid()); |
|
371 |
|
|
372 |
referencePopupEditorsRowMap.put(referencePopupEditor, row); |
|
359 | 373 |
} |
360 | 374 |
|
361 | 375 |
@EventBusListenerMethod(filter = EntityChangeEventFilter.ReferenceFilter.class) |
... | ... | |
364 | 378 |
Reference newRef = getRepo().getReferenceService().load(event.getEntityUuid(), Arrays.asList(new String[]{"$"})); |
365 | 379 |
cache.load(newRef); |
366 | 380 |
|
367 |
for( CollectionRowItemCollection row : collectionPopuEditorSourceRows) { |
|
368 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 6); |
|
369 |
combobox.reload(); |
|
381 |
if(event.isCreatedType()){ |
|
382 |
SpecimenTypeDesignationDTORow row = referencePopupEditorsRowMap.get(event.getSourceView()); |
|
383 |
ToOneRelatedEntityCombobox<Reference> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 7); |
|
384 |
combobox.setValue((Reference) event.getEntity()); |
|
385 |
|
|
386 |
} else { |
|
387 |
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) { |
|
388 |
ToOneRelatedEntityCombobox<Reference> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 7); |
|
389 |
combobox.reload(); |
|
390 |
} |
|
370 | 391 |
} |
371 | 392 |
} |
372 | 393 |
|
Also available in: Unified diff
selecting newly created collection and reference in specimen type designation workingset editor