1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.view.name;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.EnumSet;
|
13
|
import java.util.HashMap;
|
14
|
import java.util.HashSet;
|
15
|
import java.util.List;
|
16
|
import java.util.Map;
|
17
|
import java.util.Set;
|
18
|
import java.util.Stack;
|
19
|
|
20
|
import org.springframework.beans.factory.DisposableBean;
|
21
|
import org.springframework.beans.factory.annotation.Autowired;
|
22
|
import org.springframework.context.annotation.Scope;
|
23
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
24
|
import org.vaadin.viritin.fields.AbstractElementCollection;
|
25
|
|
26
|
import com.vaadin.spring.annotation.SpringComponent;
|
27
|
|
28
|
import eu.etaxonomy.cdm.cache.CdmTransientEntityAndUuidCacher;
|
29
|
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter.LabelType;
|
30
|
import eu.etaxonomy.cdm.model.ICdmEntityUuidCacher;
|
31
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
32
|
import eu.etaxonomy.cdm.model.agent.Person;
|
33
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
34
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
35
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
36
|
import eu.etaxonomy.cdm.model.location.Country;
|
37
|
import eu.etaxonomy.cdm.model.name.Registration;
|
38
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
39
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
40
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
41
|
import eu.etaxonomy.cdm.model.permission.CRUD;
|
42
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
43
|
import eu.etaxonomy.cdm.model.term.TermType;
|
44
|
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
|
45
|
import eu.etaxonomy.cdm.persistence.dao.common.Restriction.Operator;
|
46
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
47
|
import eu.etaxonomy.cdm.service.CdmBeanItemContainerFactory;
|
48
|
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
|
49
|
import eu.etaxonomy.cdm.service.CdmFilterablePagingProviderFactory;
|
50
|
import eu.etaxonomy.cdm.service.ISpecimenTypeDesignationWorkingSetService;
|
51
|
import eu.etaxonomy.cdm.service.UserHelperAccess;
|
52
|
import eu.etaxonomy.cdm.service.initstrategies.AgentBaseInit;
|
53
|
import eu.etaxonomy.cdm.vaadin.component.CollectionRowItemCollection;
|
54
|
import eu.etaxonomy.cdm.vaadin.event.EditorActionContext;
|
55
|
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
|
56
|
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEventFilter;
|
57
|
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
|
58
|
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationTermLists;
|
59
|
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO;
|
60
|
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO;
|
61
|
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
|
62
|
import eu.etaxonomy.cdm.vaadin.util.CollectionCaptionGenerator;
|
63
|
import eu.etaxonomy.cdm.vaadin.util.ReferenceEllypsisCaptionGenerator;
|
64
|
import eu.etaxonomy.cdm.vaadin.view.occurrence.CollectionPopupEditor;
|
65
|
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
|
66
|
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
|
67
|
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter;
|
68
|
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
|
69
|
import eu.etaxonomy.vaadin.mvp.AbstractView;
|
70
|
/**
|
71
|
* SpecimenTypeDesignationWorkingsetPopupEditorView implementation must override the showInEditor() method,
|
72
|
* see {@link #prepareAsFieldGroupDataSource()} for details.
|
73
|
*
|
74
|
* @author a.kohlbecker
|
75
|
* @since Jun 13, 2017
|
76
|
*/
|
77
|
@SpringComponent
|
78
|
@Scope("prototype")
|
79
|
public class SpecimenTypeDesignationWorkingsetEditorPresenter
|
80
|
extends AbstractEditorPresenter<SpecimenTypeDesignationWorkingSetDTO , SpecimenTypeDesignationWorkingsetPopupEditorView>
|
81
|
implements CachingPresenter, DisposableBean {
|
82
|
|
83
|
private static final long serialVersionUID = 4255636253714476918L;
|
84
|
|
85
|
private static final EnumSet<CRUD> COLLECTION_EDITOR_CRUD = EnumSet.of(CRUD.UPDATE, CRUD.DELETE);
|
86
|
|
87
|
|
88
|
/**
|
89
|
* This object for this field will either be injected by the {@link PopupEditorFactory} or by a Spring
|
90
|
* {@link BeanFactory}
|
91
|
*/
|
92
|
@Autowired
|
93
|
private ISpecimenTypeDesignationWorkingSetService specimenTypeDesignationWorkingSetService;
|
94
|
|
95
|
@Autowired
|
96
|
protected CdmFilterablePagingProviderFactory pagingProviderFactory;
|
97
|
|
98
|
@Autowired
|
99
|
protected CdmBeanItemContainerFactory cdmBeanItemContainerFactory;
|
100
|
|
101
|
/**
|
102
|
* if not null, this CRUD set is to be used to create a CdmAuthoritiy for the base entitiy which will be
|
103
|
* granted to the current use as long this grant is not assigned yet.
|
104
|
*/
|
105
|
private EnumSet<CRUD> crud = null;
|
106
|
|
107
|
private ICdmEntityUuidCacher cache;
|
108
|
|
109
|
SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto;
|
110
|
|
111
|
private Map<CollectionPopupEditor, SpecimenTypeDesignationDTORow> collectionPopupEditorsRowMap = new HashMap<>();
|
112
|
|
113
|
private Map<ReferencePopupEditor, ToOneRelatedEntityCombobox<Reference>> referencePopupEditorsCombobox = new HashMap<>();
|
114
|
|
115
|
private Set<CollectionRowItemCollection> popuEditorTypeDesignationSourceRows = new HashSet<>();
|
116
|
|
117
|
private java.util.Collection<CdmBase> rootEntities = new HashSet<>();
|
118
|
|
119
|
|
120
|
/**
|
121
|
* Loads an existing working set from the database. This process actually involves
|
122
|
* loading the Registration specified by the <code>RegistrationAndWorkingsetId.registrationId</code> and in
|
123
|
* a second step to find the workingset by the <code>registrationAndWorkingsetId.workingsetId</code>.
|
124
|
* <p>
|
125
|
* The <code>identifier</code> must be of the type {@link TypeDesignationWorkingsetIds} whereas the
|
126
|
* field <code>registrationId</code> must be present.
|
127
|
* The field <code>workingsetId</code> however can be null.
|
128
|
* I this case a new workingset with a new {@link FieldUnit} as
|
129
|
* base entity is being created.
|
130
|
*
|
131
|
* @param identifier a {@link TypeDesignationWorkingsetIds}
|
132
|
*/
|
133
|
@Override
|
134
|
protected SpecimenTypeDesignationWorkingSetDTO<Registration> loadBeanById(Object identifier) {
|
135
|
|
136
|
cache = new CdmTransientEntityAndUuidCacher(this);
|
137
|
if(identifier != null){
|
138
|
|
139
|
SpecimenTypeDesignationWorkingsetIds idset = (SpecimenTypeDesignationWorkingsetIds)identifier;
|
140
|
|
141
|
if(idset.baseEntityRef != null){
|
142
|
// load existing workingset
|
143
|
workingSetDto = specimenTypeDesignationWorkingSetService.load(idset.registrationUuid, idset.baseEntityRef);
|
144
|
if(workingSetDto.getFieldUnit() == null){
|
145
|
workingSetDto = specimenTypeDesignationWorkingSetService.fixMissingFieldUnit(workingSetDto);
|
146
|
// FIXME open Dialog to warn user about adding an empty fieldUnit to the typeDesignations
|
147
|
// This method must go again into the presenter !!!!
|
148
|
logger.info("Basing all typeDesignations on a new fieldUnit");
|
149
|
}
|
150
|
// need to use load but put see #7214
|
151
|
cache.load(workingSetDto.getOwner());
|
152
|
rootEntities.add(workingSetDto.getOwner());
|
153
|
} else {
|
154
|
// create a new workingset, for a new fieldunit which is the base for the workingset
|
155
|
workingSetDto = specimenTypeDesignationWorkingSetService.create(idset.getRegistrationUUID(), idset.getTypifiedNameUuid());
|
156
|
// need to use load but put see #7214
|
157
|
Registration registration = workingSetDto.getOwner();
|
158
|
cache.load(registration);
|
159
|
cache.load(workingSetDto.getTypifiedName());
|
160
|
rootEntities.add(workingSetDto.getOwner());
|
161
|
rootEntities.add(workingSetDto.getTypifiedName());
|
162
|
|
163
|
}
|
164
|
|
165
|
} else {
|
166
|
workingSetDto = null;
|
167
|
}
|
168
|
|
169
|
return workingSetDto;
|
170
|
}
|
171
|
|
172
|
|
173
|
/**
|
174
|
* {@inheritDoc}
|
175
|
*/
|
176
|
@SuppressWarnings("serial")
|
177
|
@Override
|
178
|
public void handleViewEntered() {
|
179
|
|
180
|
getView().getCountrySelectField().setContainerDataSource(cdmBeanItemContainerFactory.buildVocabularyTermsItemContainer(Country.uuidCountryVocabulary));
|
181
|
|
182
|
CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = pagingProviderFactory.teamOrPersonPagingProvider();
|
183
|
CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = pagingProviderFactory.personPagingProvider();
|
184
|
termOrPersonPagingProvider.setInitStrategy(AgentBaseInit.TEAM_OR_PERSON_INIT_STRATEGY);
|
185
|
// the ToOneRelatedEntityReloader is added internally in the TeamOrPersonField:
|
186
|
getView().getCollectorField().setFilterablePersonPagingProvider(personPagingProvider, this);
|
187
|
getView().getCollectorField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
|
188
|
|
189
|
getView().getExactLocationField().getReferenceSystemSelect().setContainerDataSource(cdmBeanItemContainerFactory.buildTermItemContainer(TermType.ReferenceSystem));
|
190
|
getView().getExactLocationField().getReferenceSystemSelect().setItemCaptionPropertyId("label");
|
191
|
|
192
|
getView().getTypeDesignationsCollectionField().addElementRemovedListener(e -> deleteTypeDesignation(e.getElement()));
|
193
|
getView().getTypeDesignationsCollectionField().addElementAddedListener(e -> addTypeDesignation(e.getElement()));
|
194
|
|
195
|
getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildVocabularyTermsItemContainer(
|
196
|
AnnotationType.EDITORIAL().getVocabulary().getUuid()));
|
197
|
|
198
|
popuEditorTypeDesignationSourceRows.clear();
|
199
|
CdmFilterablePagingProvider<Collection, Collection> collectionPagingProvider = new CdmFilterablePagingProvider<Collection, Collection>(getRepo().getCollectionService());
|
200
|
collectionPagingProvider.getRestrictions().add(new Restriction<>("institute.titleCache", Operator.OR, MatchMode.ANYWHERE, CdmFilterablePagingProvider.QUERY_STRING_PLACEHOLDER));
|
201
|
|
202
|
CdmFilterablePagingProvider<Reference, Reference> referencePagingProvider = pagingProviderFactory.referencePagingProvider();
|
203
|
|
204
|
|
205
|
getView().getTypeDesignationsCollectionField().setEditorInstantiator(new AbstractElementCollection.Instantiator<SpecimenTypeDesignationDTORow>() {
|
206
|
|
207
|
@Override
|
208
|
public SpecimenTypeDesignationDTORow create() {
|
209
|
|
210
|
SpecimenTypeDesignationDTORow row = new SpecimenTypeDesignationDTORow();
|
211
|
|
212
|
row.kindOfUnit.setContainerDataSource(cdmBeanItemContainerFactory.buildTermItemContainer(
|
213
|
RegistrationTermLists.KIND_OF_UNIT_TERM_UUIDS())
|
214
|
);
|
215
|
row.kindOfUnit.setNullSelectionAllowed(false);
|
216
|
|
217
|
row.typeStatus.setContainerDataSource(cdmBeanItemContainerFactory.buildTermItemContainer(
|
218
|
RegistrationTermLists.SPECIMEN_TYPE_DESIGNATION_STATUS_UUIDS())
|
219
|
);
|
220
|
row.typeStatus.setNullSelectionAllowed(false);
|
221
|
|
222
|
|
223
|
row.collection.loadFrom(
|
224
|
collectionPagingProvider,
|
225
|
collectionPagingProvider,
|
226
|
collectionPagingProvider.getPageSize()
|
227
|
);
|
228
|
row.collection.getSelect().setCaptionGenerator(new CollectionCaptionGenerator());
|
229
|
row.collection.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Collection>(row.collection.getSelect(),
|
230
|
SpecimenTypeDesignationWorkingsetEditorPresenter.this));
|
231
|
row.collection.addClickListenerAddEntity(e -> doCollectionEditorAdd(row));
|
232
|
row.collection.addClickListenerEditEntity(e -> {
|
233
|
if(row.collection.getValue() != null){
|
234
|
doCollectionEditorEdit(row);
|
235
|
}
|
236
|
});
|
237
|
|
238
|
row.designationReference.loadFrom(
|
239
|
referencePagingProvider,
|
240
|
referencePagingProvider,
|
241
|
referencePagingProvider.getPageSize()
|
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
|
});
|
252
|
|
253
|
row.mediaSpecimenReference.loadFrom(
|
254
|
referencePagingProvider,
|
255
|
referencePagingProvider,
|
256
|
referencePagingProvider.getPageSize()
|
257
|
);
|
258
|
row.mediaSpecimenReference.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, row.mediaSpecimenReference.getSelect()));
|
259
|
row.mediaSpecimenReference.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(row.mediaSpecimenReference.getSelect(),
|
260
|
SpecimenTypeDesignationWorkingsetEditorPresenter.this));
|
261
|
row.mediaSpecimenReference.addClickListenerAddEntity(e -> doReferenceEditorAdd(row.mediaSpecimenReference));
|
262
|
row.mediaSpecimenReference.addClickListenerEditEntity(e -> {
|
263
|
if(row.mediaSpecimenReference.getValue() != null){
|
264
|
doReferenceEditorEdit(row.mediaSpecimenReference);
|
265
|
}
|
266
|
});
|
267
|
|
268
|
getView().applyDefaultComponentStyle(row.components());
|
269
|
|
270
|
popuEditorTypeDesignationSourceRows.add(row);
|
271
|
|
272
|
return row;
|
273
|
}
|
274
|
|
275
|
});
|
276
|
|
277
|
}
|
278
|
|
279
|
|
280
|
/**
|
281
|
* {@inheritDoc}
|
282
|
*/
|
283
|
@Override
|
284
|
protected void saveBean(SpecimenTypeDesignationWorkingSetDTO dto) {
|
285
|
|
286
|
if(crud != null){
|
287
|
UserHelperAccess.userHelper().createAuthorityForCurrentUser(dto.getFieldUnit(), crud, null);
|
288
|
}
|
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
|
|
299
|
specimenTypeDesignationWorkingSetService.save(dto);
|
300
|
}
|
301
|
|
302
|
/**
|
303
|
* {@inheritDoc}
|
304
|
*/
|
305
|
@Override
|
306
|
protected void deleteBean(SpecimenTypeDesignationWorkingSetDTO bean) {
|
307
|
specimenTypeDesignationWorkingSetService.delete(bean, true);
|
308
|
}
|
309
|
|
310
|
/**
|
311
|
* @param element
|
312
|
* @return
|
313
|
*/
|
314
|
private void addTypeDesignation(SpecimenTypeDesignationDTO element) {
|
315
|
getView().updateAllowDeleteTypeDesignation();
|
316
|
}
|
317
|
|
318
|
|
319
|
/**
|
320
|
* In this method the SpecimenTypeDesignation is dissociated from the Registration.
|
321
|
* The actual deletion of the SpecimenTypeDesignation and DerivedUnit will take place in {@link #saveBean(SpecimenTypeDesignationWorkingSetDTO)}
|
322
|
*
|
323
|
* TODO once https://dev.e-taxonomy.eu/redmine/issues/7077 is fixed dissociating from the Registration could be removed here
|
324
|
*
|
325
|
* @param e
|
326
|
* @return
|
327
|
*/
|
328
|
private void deleteTypeDesignation(SpecimenTypeDesignationDTO element) {
|
329
|
|
330
|
Registration reg = workingSetDto.getOwner();
|
331
|
SpecimenTypeDesignation std = element.asSpecimenTypeDesignation();
|
332
|
|
333
|
reg.getTypeDesignations().remove(std);
|
334
|
|
335
|
getView().updateAllowDeleteTypeDesignation();
|
336
|
}
|
337
|
|
338
|
/**
|
339
|
* @param crud
|
340
|
*/
|
341
|
public void setGrantsForCurrentUser(EnumSet<CRUD> crud) {
|
342
|
this.crud = crud;
|
343
|
|
344
|
}
|
345
|
|
346
|
/**
|
347
|
* {@inheritDoc}
|
348
|
*/
|
349
|
@Override
|
350
|
public ICdmEntityUuidCacher getCache() {
|
351
|
return cache;
|
352
|
}
|
353
|
|
354
|
@Override
|
355
|
public void disposeCache() {
|
356
|
cache.dispose();
|
357
|
}
|
358
|
|
359
|
public void doCollectionEditorAdd(SpecimenTypeDesignationDTORow row) {
|
360
|
|
361
|
CollectionPopupEditor collectionPopupEditor = openPopupEditor(CollectionPopupEditor.class, null);
|
362
|
|
363
|
collectionPopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD);
|
364
|
collectionPopupEditor.withDeleteButton(true);
|
365
|
collectionPopupEditor.loadInEditor(null);
|
366
|
|
367
|
collectionPopupEditorsRowMap.put(collectionPopupEditor, row);
|
368
|
}
|
369
|
|
370
|
public void doCollectionEditorEdit(SpecimenTypeDesignationDTORow row) {
|
371
|
|
372
|
CollectionPopupEditor collectionPopupEditor = openPopupEditor(CollectionPopupEditor.class, null);
|
373
|
|
374
|
collectionPopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD);
|
375
|
collectionPopupEditor.withDeleteButton(true);
|
376
|
collectionPopupEditor.loadInEditor(row.collection.getValue().getUuid());
|
377
|
|
378
|
collectionPopupEditorsRowMap.put(collectionPopupEditor, row);
|
379
|
}
|
380
|
|
381
|
|
382
|
@EventBusListenerMethod(filter = EntityChangeEventFilter.OccurrenceCollectionFilter.class)
|
383
|
public void onCollectionEvent(EntityChangeEvent event){
|
384
|
|
385
|
if(event.getSourceView() instanceof AbstractPopupEditor) {
|
386
|
|
387
|
Stack<EditorActionContext> context = ((AbstractPopupEditor) event.getSourceView()).getEditorActionContext();
|
388
|
if(context.size() > 1){
|
389
|
AbstractView<?> parentView = context.get(context.size() - 2).getParentView();
|
390
|
if(getView().equals(parentView)){
|
391
|
Collection newCollection = getRepo().getCollectionService().load(
|
392
|
event.getEntityUuid(), Arrays.asList(new String[]{"$.institute"})
|
393
|
);
|
394
|
cache.load(newCollection);
|
395
|
|
396
|
if(event.isCreatedType()){
|
397
|
SpecimenTypeDesignationDTORow row = collectionPopupEditorsRowMap.get(event.getSourceView());
|
398
|
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 3);
|
399
|
combobox.setValue((Collection) event.getEntity());
|
400
|
} else {
|
401
|
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) {
|
402
|
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 3);
|
403
|
combobox.reload();
|
404
|
}
|
405
|
}
|
406
|
}
|
407
|
}
|
408
|
|
409
|
}
|
410
|
}
|
411
|
|
412
|
public void doReferenceEditorAdd(ToOneRelatedEntityCombobox<Reference> referenceComobox) {
|
413
|
|
414
|
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null);
|
415
|
|
416
|
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES);
|
417
|
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD);
|
418
|
referencePopupEditor.withDeleteButton(true);
|
419
|
referencePopupEditor.loadInEditor(null);
|
420
|
|
421
|
referencePopupEditorsCombobox.put(referencePopupEditor, referenceComobox);
|
422
|
}
|
423
|
|
424
|
public void doReferenceEditorEdit(ToOneRelatedEntityCombobox<Reference> referenceComobox) {
|
425
|
|
426
|
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null);
|
427
|
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES);
|
428
|
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD);
|
429
|
referencePopupEditor.withDeleteButton(true);
|
430
|
referencePopupEditor.loadInEditor(referenceComobox.getValue().getUuid());
|
431
|
|
432
|
referencePopupEditorsCombobox.put(referencePopupEditor, referenceComobox);
|
433
|
}
|
434
|
|
435
|
@EventBusListenerMethod(filter = EntityChangeEventFilter.ReferenceFilter.class)
|
436
|
public void onReferenceEvent(EntityChangeEvent event){
|
437
|
|
438
|
Reference newRef = getRepo().getReferenceService().load(event.getEntityUuid(), Arrays.asList(new String[]{"$"}));
|
439
|
cache.load(newRef);
|
440
|
|
441
|
ToOneRelatedEntityCombobox<Reference> combobox = referencePopupEditorsCombobox.get(event.getSourceView());
|
442
|
if(event.isCreatedType()){
|
443
|
combobox.setValue((Reference) event.getEntity());
|
444
|
} else {
|
445
|
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) {
|
446
|
combobox.reload();
|
447
|
}
|
448
|
}
|
449
|
|
450
|
}
|
451
|
|
452
|
/**
|
453
|
* {@inheritDoc}
|
454
|
*/
|
455
|
@Override
|
456
|
public void addRootEntity(CdmBase entity) {
|
457
|
rootEntities.add(entity);
|
458
|
}
|
459
|
|
460
|
/**
|
461
|
* {@inheritDoc}
|
462
|
*/
|
463
|
@Override
|
464
|
public java.util.Collection<CdmBase> getRootEntities() {
|
465
|
return rootEntities ;
|
466
|
}
|
467
|
|
468
|
/**
|
469
|
* {@inheritDoc}
|
470
|
*/
|
471
|
@Override
|
472
|
public void destroy() throws Exception {
|
473
|
super.destroy();
|
474
|
cache.dispose();
|
475
|
}
|
476
|
|
477
|
}
|