Project

General

Profile

Revision 9361ce64

ID9361ce643c9b449ce33d77973ffe7d6ff9fc80b5
Parent 725d1ff2
Child ead6f0f6

Added by Andreas Kohlbecker over 3 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

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
137 137

  
138 138
    private AnnotationType[] editableAnotationTypes = RegistrationUIDefaults.EDITABLE_ANOTATION_TYPES;
139 139

  
140
    private int genusOrUninomialRow;
141

  
140 142
    /**
141 143
     * By default  AnnotationType.EDITORIAL() is enabled.
142 144
     *
......
301 303
        protectedNameCacheField = addSwitchableTextField("Name cache", "nameCache", "protectedNameCache", 0, row, GRID_COLS-1, row);
302 304
        protectedNameCacheField.setWidth(100, Unit.PERCENTAGE);
303 305
        row++;
304
        if(isModeEnabled(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART)){
305
            genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
306
        } else {
307
            genusOrUninomialField = new LazyComboBox<String>(String.class);
308
            addField(genusOrUninomialField, "genusOrUninomial", 0, row, 1, row);
309
        }
306
        genusOrUninomialRow = row;
307
        genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
310 308
        genusOrUninomialField.setWidth(200, Unit.PIXELS);
311 309
        infraGenericEpithetField = addTextField("Infrageneric epithet", "infraGenericEpithet", 2, row, 3, row);
312 310
        infraGenericEpithetField.setWidth(200, Unit.PIXELS);
......
703 701
        Boolean withValidationSection = isSpeciesOrBelow && BooleanUtils.isTrue(validationToggle.getValue());
704 702

  
705 703
        if(isModeEnabled(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART)){
704
            if(isSpeciesOrBelow) {
705
                if(TextField.class.isAssignableFrom(genusOrUninomialField.getClass())){
706
                    genusOrUninomialField = replaceComponent("genusOrUninomial", genusOrUninomialField, new LazyComboBox<String>(String.class), 0, genusOrUninomialRow, 1, genusOrUninomialRow);
707
                }
708
            } else {
709
                if(LazyComboBox.class.isAssignableFrom(genusOrUninomialField.getClass())) {
710
                    genusOrUninomialField = replaceComponent("genusOrUninomial", genusOrUninomialField, new TextFieldNFix(), 0, genusOrUninomialRow, 1, genusOrUninomialRow);
711
                }
712
            }
713
        }
714

  
715
        if(isModeEnabled(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART)){
706 716
            if(rank.isInfraSpecific()) {
707 717
                if(TextField.class.isAssignableFrom(specificEpithetField.getClass())) {
708 718
                     specificEpithetField = replaceComponent("specificEpithet", specificEpithetField, new LazyComboBox<String>(String.class), 0, specificEpithetFieldRow, 1, specificEpithetFieldRow);
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
18 18
import java.util.Stack;
19 19
import java.util.UUID;
20 20

  
21
import org.apache.log4j.Logger;
21 22
import org.hibernate.Session;
22 23
import org.hibernate.Transaction;
23 24
import org.springframework.beans.factory.annotation.Autowired;
......
105 106
@ViewScope
106 107
public class RegistrationWorkingsetPresenter extends AbstractPresenter<RegistrationWorkingsetView> {
107 108

  
108
    /**
109
     *
110
     */
109
    private static final Logger logger = Logger.getLogger(RegistrationWorkingsetPresenter.class);
110

  
111 111
    private static final List<String> REGISTRATION_INIT_STRATEGY = Arrays.asList(
112 112
            "$",
113 113
            "blockedBy",
......
341 341

  
342 342
    private void saveRegistrationStatusChange(UUID uuid, Object value) {
343 343
        Registration reg = getRepo().getRegistrationService().load(uuid);
344
        if(value != null && value instanceof RegistrationStatus && !Objects.equals(value, reg.getStatus())){
345
            reg.setStatus((RegistrationStatus)value);
346
            getRegistrationStore().saveBean(reg, (AbstractView)getView());
347
            refreshView(true);
344
        if(value != null && value instanceof RegistrationStatus){
345
            if(!Objects.equals(value, reg.getStatus())){
346
                reg.setStatus((RegistrationStatus)value);
347
                getRegistrationStore().saveBean(reg, (AbstractView)getView());
348
                refreshView(true);
349
            }
348 350
        } else {
349
            // only log an error here!
351
            // only log here as error
350 352
            logger.error("Ivalid attempt to set RegistrationStatus to " + Objects.toString(value.toString(), "NULL"));
351 353
        }
352 354
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)