Revision 8195658e
Added by Andreas Kohlbecker about 3 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
26 | 26 |
import org.springframework.context.annotation.Scope; |
27 | 27 |
import org.vaadin.spring.events.annotation.EventBusListenerMethod; |
28 | 28 |
import org.vaadin.viritin.fields.AbstractElementCollection; |
29 |
import org.vaadin.viritin.fields.ElementCollectionField; |
|
29 | 30 |
|
30 | 31 |
import com.vaadin.data.util.BeanItemContainer; |
31 | 32 |
import com.vaadin.spring.annotation.SpringComponent; |
... | ... | |
73 | 74 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
74 | 75 |
import eu.etaxonomy.cdm.vaadin.util.CollectionCaptionGenerator; |
75 | 76 |
import eu.etaxonomy.cdm.vaadin.util.ReferenceEllypsisCaptionGenerator; |
77 |
import eu.etaxonomy.cdm.vaadin.util.fields.ElementCollectionHelper; |
|
76 | 78 |
import eu.etaxonomy.cdm.vaadin.view.occurrence.CollectionPopupEditor; |
77 | 79 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
80 |
import eu.etaxonomy.cdm.vaadin.view.reference.RegistrationUiReferenceEditorFormConfigurator; |
|
78 | 81 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox; |
79 | 82 |
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter; |
80 | 83 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
... | ... | |
136 | 139 |
|
137 | 140 |
private Map<ReferencePopupEditor, ToOneRelatedEntityCombobox<Reference>> referencePopupEditorsCombobox = new HashMap<>(); |
138 | 141 |
|
139 |
private Set<CollectionRowItemCollection> popuEditorTypeDesignationSourceRows = new HashSet<>(); |
|
142 |
private ElementCollectionHelper<ElementCollectionField> typeDesignationsCollectionFieldHelper; |
|
143 |
|
|
144 |
private Set<CollectionRowItemCollection> typeDesignationEditorRows = new HashSet<>(); |
|
140 | 145 |
|
141 | 146 |
private java.util.Collection<CdmBase> rootEntities = new HashSet<>(); |
142 | 147 |
|
... | ... | |
221 | 226 |
}; |
222 | 227 |
} |
223 | 228 |
|
229 |
// new Reference only a sub sections of the publishedUnit |
|
230 |
newReferenceInstantiator = new BeanInstantiator<Reference>() { |
|
231 |
@Override |
|
232 |
public Reference createNewBean() { |
|
233 |
Reference newRef = ReferenceFactory.newSection(); |
|
234 |
newRef.setInReference(publishedUnit.getCitation()); |
|
235 |
return newRef; |
|
236 |
} |
|
237 |
}; |
|
238 |
|
|
224 | 239 |
return workingSetDto; |
225 | 240 |
} |
226 | 241 |
|
... | ... | |
250 | 265 |
getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildVocabularyTermsItemContainer( |
251 | 266 |
AnnotationType.EDITORIAL().getVocabulary().getUuid())); |
252 | 267 |
|
253 |
popuEditorTypeDesignationSourceRows.clear();
|
|
268 |
typeDesignationEditorRows.clear();
|
|
254 | 269 |
CdmFilterablePagingProvider<Collection, Collection> collectionPagingProvider = new CdmFilterablePagingProvider<Collection, Collection>(getRepo().getCollectionService()); |
255 | 270 |
collectionPagingProvider.getRestrictions().add(new Restriction<>("institute.titleCache", Operator.OR, MatchMode.ANYWHERE, CdmFilterablePagingProvider.QUERY_STRING_PLACEHOLDER)); |
256 | 271 |
|
257 | 272 |
referencePagingProvider = pagingProviderFactory.referencePagingProvider(); |
258 | 273 |
|
274 |
typeDesignationsCollectionFieldHelper = new ElementCollectionHelper(getView().getTypeDesignationsCollectionField()); |
|
259 | 275 |
getView().getTypeDesignationsCollectionField().setEditorInstantiator(new AbstractElementCollection.Instantiator<SpecimenTypeDesignationDTORow>() { |
260 | 276 |
|
261 | 277 |
@Override |
... | ... | |
321 | 337 |
|
322 | 338 |
getView().applyDefaultComponentStyle(row.components()); |
323 | 339 |
|
324 |
popuEditorTypeDesignationSourceRows.add(row);
|
|
340 |
typeDesignationEditorRows.add(row);
|
|
325 | 341 |
|
326 | 342 |
return row; |
327 | 343 |
} |
328 | 344 |
}); |
329 |
|
|
330 | 345 |
} |
331 | 346 |
|
332 | 347 |
protected BeanItemContainer<DefinedTermBase> provideTypeStatusTermItemContainer() { |
... | ... | |
461 | 476 |
cache.load(newCollection); |
462 | 477 |
|
463 | 478 |
if(event.isCreatedType()){ |
479 |
//TODO use typeDesignationsCollectionFieldHelper instead to get component |
|
464 | 480 |
SpecimenTypeDesignationDTORow row = collectionPopupEditorsRowMap.get(event.getSourceView()); |
465 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 3);
|
|
481 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, SpecimenTypeDesignationDTORow.FIELD_INDEX_COLLECTION);
|
|
466 | 482 |
combobox.setValue((Collection) event.getEntity()); |
467 | 483 |
} else { |
468 |
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) { |
|
469 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 3); |
|
484 |
//TODO use typeDesignationsCollectionFieldHelper instead to get component |
|
485 |
for( CollectionRowItemCollection row : typeDesignationEditorRows) { |
|
486 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, SpecimenTypeDesignationDTORow.FIELD_INDEX_COLLECTION); |
|
470 | 487 |
combobox.reload(); |
471 | 488 |
} |
472 | 489 |
} |
... | ... | |
479 | 496 |
|
480 | 497 |
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null); |
481 | 498 |
|
482 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
|
483 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
|
484 |
referencePopupEditor.withDeleteButton(true); |
|
485 |
referencePopupEditor.loadInEditor(null); |
|
499 |
String property = typeDesignationsCollectionFieldHelper.properyFor(referenceComobox); |
|
500 |
if(property.equals(SpecimenTypeDesignationDTORow.FIELD_NAME_DESIGNATION_REFERENCE)){ |
|
501 |
referencePopupEditor.withReferenceTypes(EnumSet.of(ReferenceType.Section)); |
|
502 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
|
503 |
referencePopupEditor.withDeleteButton(true); |
|
504 |
RegistrationUiReferenceEditorFormConfigurator |
|
505 |
.create(true).configure(referencePopupEditor, newReferenceInstantiator); |
|
506 |
referencePopupEditor.loadInEditor(null); |
|
507 |
} else { |
|
508 |
// only other option by now |
|
509 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
|
510 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
|
511 |
referencePopupEditor.withDeleteButton(true); |
|
512 |
referencePopupEditor.loadInEditor(null); |
|
513 |
} |
|
486 | 514 |
|
487 | 515 |
referencePopupEditorsCombobox.put(referencePopupEditor, referenceComobox); |
488 | 516 |
} |
... | ... | |
490 | 518 |
public void doReferenceEditorEdit(ToOneRelatedEntityCombobox<Reference> referenceComobox) { |
491 | 519 |
|
492 | 520 |
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null); |
493 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
|
494 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
|
495 |
referencePopupEditor.withDeleteButton(true); |
|
496 |
referencePopupEditor.loadInEditor(referenceComobox.getValue().getUuid()); |
|
521 |
|
|
522 |
String property = typeDesignationsCollectionFieldHelper.properyFor(referenceComobox); |
|
523 |
|
|
524 |
if(property.equals(SpecimenTypeDesignationDTORow.FIELD_NAME_DESIGNATION_REFERENCE)){ |
|
525 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
|
526 |
referencePopupEditor.withDeleteButton(true); |
|
527 |
RegistrationUiReferenceEditorFormConfigurator |
|
528 |
.create(false).typeSelectReadonly(true).configure(referencePopupEditor, newReferenceInstantiator); |
|
529 |
referencePopupEditor.loadInEditor(referenceComobox.getValue().getUuid()); |
|
530 |
} else { |
|
531 |
// only other option by now |
|
532 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
|
533 |
referencePopupEditor.grantToCurrentUser(COLLECTION_EDITOR_CRUD); |
|
534 |
referencePopupEditor.withDeleteButton(true); |
|
535 |
referencePopupEditor.loadInEditor(referenceComobox.getValue().getUuid()); |
|
536 |
} |
|
497 | 537 |
|
498 | 538 |
referencePopupEditorsCombobox.put(referencePopupEditor, referenceComobox); |
499 | 539 |
} |
500 | 540 |
|
541 |
|
|
542 |
|
|
501 | 543 |
@EventBusListenerMethod(filter = EntityChangeEventFilter.ReferenceFilter.class) |
502 | 544 |
public void onReferenceEvent(EntityChangeEvent event){ |
503 | 545 |
|
... | ... | |
508 | 550 |
if(event.isCreatedType()){ |
509 | 551 |
combobox.setValue((Reference) event.getEntity()); |
510 | 552 |
} else { |
511 |
for( CollectionRowItemCollection row : popuEditorTypeDesignationSourceRows) {
|
|
553 |
for( CollectionRowItemCollection row : typeDesignationEditorRows) {
|
|
512 | 554 |
combobox.reload(); |
513 | 555 |
} |
514 | 556 |
} |
Also available in: Unified diff
fix #9480 SpecimenTypeDesignationEditor: limiting designationReference editing to sections of published unit