Project

General

Profile

Revision d7edf1e0

IDd7edf1e089bd6f3a63904f86bf6160aaa4d1839a
Parent 1faff10b
Child eb75f8eb

Added by Andreas Kohlbecker about 3 years ago

fix #7572 CollectionCaptionGenerator to show collection code and institution in comboboxes

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/util/CollectionCaptionGenerator.java
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.util;
10

  
11
import java.util.Objects;
12

  
13
import org.vaadin.viritin.fields.CaptionGenerator;
14

  
15
import eu.etaxonomy.cdm.model.occurrence.Collection;
16

  
17
/**
18
 * @author a.kohlbecker
19
 *
20
 */
21
public final class CollectionCaptionGenerator implements CaptionGenerator<Collection> {
22

  
23
    private static final long serialVersionUID = 3151383366731447990L;
24

  
25
    public CollectionCaptionGenerator(){
26
    }
27

  
28
    @Override
29
    public String getCaption(Collection option) {
30
        String caption = Objects.toString(option.getCode(), "");
31
        option.getTitleCache();
32
        if(option.getInstitute() != null){
33
            caption += (caption.isEmpty() ? "" : " - ") + option.getInstitute().getTitleCache();
34
        }
35
        return caption;
36
    }
37
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
52 52
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO;
53 53
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
54 54
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
55
import eu.etaxonomy.cdm.vaadin.util.CollectionCaptionGenerator;
55 56
import eu.etaxonomy.cdm.vaadin.view.occurrence.CollectionPopupEditor;
56 57
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
57 58
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
......
207 208
                        collectionPagingProvider,
208 209
                        collectionPagingProvider.getPageSize()
209 210
                        );
210
                row.collection.getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Collection>());
211
                row.collection.getSelect().setCaptionGenerator(new CollectionCaptionGenerator());
211 212
                row.collection.getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Collection>(row.collection));
212 213
                row.collection.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Collection>(row.collection.getSelect(),
213 214
                        SpecimenTypeDesignationWorkingsetEditorPresenter.this));
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionPopupEditor.java
22 22
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
23 23
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
24 24
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
25
import eu.etaxonomy.cdm.vaadin.util.CollectionCaptionGenerator;
25 26
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
26 27
import eu.etaxonomy.vaadin.event.EditorActionType;
27 28
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
......
145 146
        addField(superCollectionCombobox, "superCollection", 0, row, 1, row);
146 147

  
147 148
        superCollectionCombobox.getSelect().setCaptionGenerator(
148
                new CdmTitleCacheCaptionGenerator<Collection>()
149
                new CollectionCaptionGenerator()
149 150
                );
150 151
        superCollectionCombobox.getSelect().addValueChangeListener(
151 152
                new ToOneRelatedEntityButtonUpdater<Collection>(superCollectionCombobox)

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)