Revision 0aa1233b
Added by Andreas Kohlbecker almost 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.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.List; |
15 |
import java.util.Map; |
|
14 | 16 |
import java.util.UUID; |
15 | 17 |
|
16 | 18 |
import org.apache.commons.lang.StringUtils; |
... | ... | |
18 | 20 |
import org.hibernate.criterion.Restrictions; |
19 | 21 |
import org.springframework.context.annotation.Scope; |
20 | 22 |
import org.vaadin.spring.events.annotation.EventBusListenerMethod; |
23 |
import org.vaadin.viritin.fields.AbstractElementCollection; |
|
21 | 24 |
|
22 | 25 |
import com.vaadin.data.Property; |
23 | 26 |
import com.vaadin.spring.annotation.SpringComponent; |
... | ... | |
31 | 34 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
32 | 35 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
33 | 36 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
37 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
|
38 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
|
34 | 39 |
import eu.etaxonomy.cdm.model.name.Rank; |
35 | 40 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
36 | 41 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
... | ... | |
80 | 85 |
@Scope("prototype") |
81 | 86 |
public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, TaxonNamePopupEditorView> { |
82 | 87 |
|
88 |
private static final long serialVersionUID = -3538980627079389221L; |
|
89 |
|
|
90 |
private static final EnumSet<CRUD> SUB_EDITOR_CRUD = EnumSet.of(CRUD.UPDATE, CRUD.DELETE); |
|
83 | 91 |
|
84 | 92 |
private static final List<String> RELATED_NAME_INIT_STRATEGY = Arrays.asList( |
85 | 93 |
"$", |
... | ... | |
90 | 98 |
|
91 | 99 |
public static final List<String> REFERENCE_INIT_STRATEGY = Arrays.asList("authorship", "inReference.authorship", "inReference.inReference.authorship", "inReference.inReference.inReference.authorship"); |
92 | 100 |
|
93 |
private static final long serialVersionUID = -3538980627079389221L; |
|
94 | 101 |
|
95 | 102 |
private static final Logger logger = Logger.getLogger(TaxonNameEditorPresenter.class); |
96 | 103 |
|
... | ... | |
100 | 107 |
|
101 | 108 |
private BeanInstantiator<Reference> newReferenceInstantiator; |
102 | 109 |
|
110 |
private Map<ReferencePopupEditor, NomenclaturalStatusRow> statusTypeReferencePopupEditorsRowMap = new HashMap<>(); |
|
111 |
|
|
103 | 112 |
private TaxonNameStringFilterablePagingProvider genusOrUninomialPartPagingProvider; |
104 | 113 |
|
105 | 114 |
private TaxonNameStringFilterablePagingProvider specificEpithetPartPagingProvider; |
... | ... | |
117 | 126 |
/** |
118 | 127 |
* {@inheritDoc} |
119 | 128 |
*/ |
129 |
@SuppressWarnings("serial") |
|
120 | 130 |
@Override |
121 | 131 |
public void handleViewEntered() { |
122 | 132 |
|
... | ... | |
153 | 163 |
getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getNomReferenceCombobox(), this)); |
154 | 164 |
getView().getNomReferenceCombobox().getSelect().addValueChangeListener( e -> updateOrthographicCorrectionRestriction()); |
155 | 165 |
|
156 |
|
|
157 |
relatedNamePagingProvider = pagingProviderFactory.taxonNamesWithoutOrthophicIncorrect(); |
|
158 |
relatedNamePagingProvider.setInitStrategy(RELATED_NAME_INIT_STRATEGY); |
|
159 |
getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>()); |
|
160 |
getView().getBasionymComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this); |
|
161 |
|
|
162 |
getView().getReplacedSynonymsComboboxSelect().setCaptionGenerator( new CdmTitleCacheCaptionGenerator<TaxonName>()); |
|
163 |
getView().getReplacedSynonymsComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this); |
|
164 |
|
|
165 | 166 |
CdmFilterablePagingProvider<Reference, Reference> icbnCodesPagingProvider = pagingProviderFactory.referencePagingProvider(); |
166 | 167 |
// @formatter:off |
167 | 168 |
// TODO use markers on references instead of isbn. The marker type MarkerType.NOMENCLATURAL_RELEVANT() has already prepared (#7466) |
... | ... | |
175 | 176 |
})); |
176 | 177 |
// @formatter:on |
177 | 178 |
|
179 |
statusTypeReferencePopupEditorsRowMap.clear(); |
|
180 |
getView().getNomStatusCollectionField().addElementAddedListener(e -> addNomenclaturalStatus(e.getElement())); |
|
181 |
getView().getNomStatusCollectionField().setEditorInstantiator(new AbstractElementCollection.Instantiator<NomenclaturalStatusRow>() { |
|
182 |
|
|
183 |
@Override |
|
184 |
public NomenclaturalStatusRow create() { |
|
185 |
NomenclaturalStatusRow row = new NomenclaturalStatusRow(); |
|
186 |
|
|
187 |
row.type.setContainerDataSource(cdmBeanItemContainerFactory.buildBeanItemContainer(NomenclaturalStatusType.ALTERNATIVE().getVocabulary().getUuid())); |
|
188 |
row.type.setNullSelectionAllowed(false); |
|
189 |
|
|
190 |
row.citation.loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize()); |
|
191 |
row.citation.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.NOMENCLATURAL, row.citation.getSelect())); |
|
192 |
row.citation.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(row.citation.getSelect(), |
|
193 |
TaxonNameEditorPresenter.this)); |
|
194 |
row.citation.addClickListenerAddEntity(e -> doReferenceEditorAdd(row)); |
|
195 |
row.citation.addClickListenerEditEntity(e -> { |
|
196 |
if(row.citation.getValue() != null){ |
|
197 |
doReferenceEditorEdit(row); |
|
198 |
} |
|
199 |
}); |
|
200 |
|
|
201 |
getView().applyDefaultComponentStyle(row.components()); |
|
202 |
|
|
203 |
return row; |
|
204 |
} |
|
205 |
}); |
|
206 |
|
|
207 |
relatedNamePagingProvider = pagingProviderFactory.taxonNamesWithoutOrthophicIncorrect(); |
|
208 |
relatedNamePagingProvider.setInitStrategy(RELATED_NAME_INIT_STRATEGY); |
|
209 |
getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>()); |
|
210 |
getView().getBasionymComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this); |
|
211 |
|
|
212 |
getView().getReplacedSynonymsComboboxSelect().setCaptionGenerator( new CdmTitleCacheCaptionGenerator<TaxonName>()); |
|
213 |
getView().getReplacedSynonymsComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this); |
|
214 |
|
|
178 | 215 |
getView().getValidationField().getRelatedNameComboBox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>()); |
179 | 216 |
getView().getValidationField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize()); |
180 | 217 |
getView().getValidationField().getRelatedNameComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getValidationField().getRelatedNameComboBox(), this)); |
... | ... | |
195 | 232 |
AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid())); |
196 | 233 |
} |
197 | 234 |
|
235 |
/** |
|
236 |
* @param element |
|
237 |
* @return |
|
238 |
*/ |
|
239 |
private void addNomenclaturalStatus(NomenclaturalStatus element) { |
|
240 |
// Nothing to do |
|
241 |
} |
|
242 |
|
|
198 | 243 |
@Override |
199 | 244 |
protected void adaptDataProviders() { |
200 | 245 |
updateOrthographicCorrectionRestriction(); |
... | ... | |
239 | 284 |
"nomenclaturalReference.inReference.inReference.inReference.authorship", |
240 | 285 |
|
241 | 286 |
"status.type", |
287 |
"status.citation.authorship.$", |
|
288 |
"status.citation.inReference.authorship.$", |
|
242 | 289 |
|
243 | 290 |
"combinationAuthorship", |
244 | 291 |
"exCombinationAuthorship", |
... | ... | |
336 | 383 |
return getRepo().getNameService(); |
337 | 384 |
} |
338 | 385 |
|
386 |
|
|
387 |
public void doReferenceEditorAdd(NomenclaturalStatusRow row) { |
|
388 |
|
|
389 |
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null); |
|
390 |
|
|
391 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
|
392 |
referencePopupEditor.grantToCurrentUser(SUB_EDITOR_CRUD); |
|
393 |
referencePopupEditor.withDeleteButton(true); |
|
394 |
referencePopupEditor.loadInEditor(null); |
|
395 |
|
|
396 |
statusTypeReferencePopupEditorsRowMap.put(referencePopupEditor, row); |
|
397 |
} |
|
398 |
|
|
399 |
public void doReferenceEditorEdit(NomenclaturalStatusRow row) { |
|
400 |
|
|
401 |
ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null); |
|
402 |
referencePopupEditor.withReferenceTypes(RegistrationUIDefaults.MEDIA_REFERENCE_TYPES); |
|
403 |
referencePopupEditor.grantToCurrentUser(SUB_EDITOR_CRUD); |
|
404 |
referencePopupEditor.withDeleteButton(true); |
|
405 |
referencePopupEditor.loadInEditor(row.citation.getValue().getUuid()); |
|
406 |
|
|
407 |
statusTypeReferencePopupEditorsRowMap.put(referencePopupEditor, row); |
|
408 |
} |
|
339 | 409 |
/** |
340 | 410 |
* @param referenceEditorPopup |
341 | 411 |
*/ |
Also available in: Unified diff
fix #8193 ElementCollectionField to edit nomenclatural status in TaxonNamePopupEditor