Project

General

Profile

« Previous | Next » 

Revision 9361ce64

Added by Andreas Kohlbecker almost 6 years ago

fix #7524 replacing uninomial field on rank change

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
21 21

  
22 22
import com.vaadin.data.Property;
23 23
import com.vaadin.spring.annotation.SpringComponent;
24
import com.vaadin.ui.AbstractField;
24 25
import com.vaadin.ui.Field;
25 26

  
26 27
import eu.etaxonomy.cdm.api.service.INameService;
......
109 110
        getView().getRankSelect().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(TermType.Rank));
110 111
        getView().getRankSelect().setItemCaptionPropertyId("label");
111 112

  
112
        // genusOrUninomialField
113
        if(getView().getGenusOrUninomialField() instanceof LazyComboBox){
114
            genusOrUninomialPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService());
115
            genusOrUninomialPartPagingProvider.listenToFields(
116
                    null,
117
                    getView().getInfraGenericEpithetField(),
118
                    getView().getSpecificEpithetField(),
119
                    getView().getInfraSpecificEpithetField()
120
                   );
121
            ((LazyComboBox)getView().getGenusOrUninomialField()).loadFrom(genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
122
        }
123

  
124 113
        CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = new CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase>(getRepo().getAgentService(), TeamOrPersonBase.class);
125 114
        termOrPersonPagingProvider.setInitStrategy(AgentBaseInit.TEAM_OR_PERSON_INIT_STRATEGY);
126 115
        CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = new CdmFilterablePagingProvider<AgentBase, Person>(getRepo().getAgentService(), Person.class);
......
335 324
    public void onFieldReplaceEvent(FieldReplaceEvent<String> event){
336 325

  
337 326
        PropertyIdPath boundPropertyIdPath = boundPropertyIdPath(event.getNewField());
338
        if(boundPropertyIdPath != null && boundPropertyIdPath.matches("specificEpithet")){
339
            if(event.getNewField() instanceof LazyComboBox){
327
        if(boundPropertyIdPath != null){
328
            if(boundPropertyIdPath.matches("specificEpithet")){
329
                AbstractField<String> genusOrUninomialField = getView().getGenusOrUninomialField();
330
                if(event.getNewField() instanceof LazyComboBox){
340 331

  
341
                if(specificEpithetPartPagingProvider  == null){
342
                    specificEpithetPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService(), Rank.SPECIES());
343
                }
344
                specificEpithetPartPagingProvider.listenToFields(
345
                        getView().getGenusOrUninomialField(),
346
                        null, null, null);
347
                specificEpithetPartPagingProvider.updateFromFields();
348
                LazyComboBox<String> specificEpithetField = (LazyComboBox<String>)event.getNewField();
349
                refreshSpecificEpithetComboBoxListener = e -> { specificEpithetField.refresh(); specificEpithetField.setValue(null);};
350
                getView().getGenusOrUninomialField().addValueChangeListener(refreshSpecificEpithetComboBoxListener);
351
                specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider, specificEpithetPartPagingProvider.getPageSize());
352
            } else {
353
                if(specificEpithetPartPagingProvider != null){
354
                    specificEpithetPartPagingProvider.unlistenAllFields();
332
                    if(specificEpithetPartPagingProvider  == null){
333
                        specificEpithetPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService(), Rank.SPECIES());
334
                    }
335
                    specificEpithetPartPagingProvider.listenToFields(
336
                            genusOrUninomialField,
337
                            null, null, null);
338
                    specificEpithetPartPagingProvider.updateFromFields();
339
                    LazyComboBox<String> specificEpithetField = (LazyComboBox<String>)event.getNewField();
340
                    refreshSpecificEpithetComboBoxListener = e -> { specificEpithetField.refresh(); specificEpithetField.setValue(null);};
341
                    genusOrUninomialField.addValueChangeListener(refreshSpecificEpithetComboBoxListener);
342
                    specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider, specificEpithetPartPagingProvider.getPageSize());
343
                } else {
344
                    if(specificEpithetPartPagingProvider != null){
345
                        specificEpithetPartPagingProvider.unlistenAllFields();
346
                    }
347
                    if(refreshSpecificEpithetComboBoxListener != null){
348
                        genusOrUninomialField.removeValueChangeListener(refreshSpecificEpithetComboBoxListener);
349
                        refreshSpecificEpithetComboBoxListener = null;
350
                    }
355 351
                }
356
                if(refreshSpecificEpithetComboBoxListener != null){
357
                    getView().getGenusOrUninomialField().removeValueChangeListener(refreshSpecificEpithetComboBoxListener);
358
                    refreshSpecificEpithetComboBoxListener = null;
352
            } else if(boundPropertyIdPath.matches("genusOrUninomial")) {
353
                if(event.getNewField() instanceof LazyComboBox){
354
                    if(genusOrUninomialPartPagingProvider  == null){
355
                        genusOrUninomialPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService());
356
                    }
357
                    genusOrUninomialPartPagingProvider.listenToFields(
358
                                null,
359
                                getView().getInfraGenericEpithetField(),
360
                                getView().getSpecificEpithetField(),
361
                                getView().getInfraSpecificEpithetField()
362
                               );
363
                    LazyComboBox<String> genusOrUninomialField = (LazyComboBox<String>)event.getNewField();
364
                    genusOrUninomialField.loadFrom(genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
365

  
366
                }else {
367
                    if(genusOrUninomialPartPagingProvider != null){
368
                        genusOrUninomialPartPagingProvider.unlistenAllFields();
369
                    }
359 370
                }
371

  
360 372
            }
361 373
        }
362 374

  

Also available in: Unified diff