Revision 85ddc538
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java | ||
---|---|---|
34 | 34 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
35 | 35 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
36 | 36 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
37 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
|
|
37 |
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator;
|
|
38 | 38 |
import eu.etaxonomy.cdm.vaadin.util.converter.CdmBaseDeproxyConverter; |
39 | 39 |
import eu.etaxonomy.cdm.vaadin.view.name.CachingPresenter; |
40 | 40 |
import eu.etaxonomy.vaadin.component.CompositeCustomField; |
41 | 41 |
import eu.etaxonomy.vaadin.component.EntityFieldInstantiator; |
42 |
import eu.etaxonomy.vaadin.component.ReloadableLazyComboBox; |
|
42 | 43 |
import eu.etaxonomy.vaadin.component.SwitchableTextField; |
43 | 44 |
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesListSelect; |
44 | 45 |
|
... | ... | |
57 | 58 |
private CssLayout toolBar= new CssLayout(); |
58 | 59 |
private CssLayout compositeWrapper = new CssLayout(); |
59 | 60 |
|
60 |
private LazyComboBox<TeamOrPersonBase> teamOrPersonSelect = new LazyComboBox<TeamOrPersonBase>(TeamOrPersonBase.class);
|
|
61 |
private ReloadableLazyComboBox<TeamOrPersonBase> teamOrPersonSelect = new ReloadableLazyComboBox<TeamOrPersonBase>(TeamOrPersonBase.class);
|
|
61 | 62 |
|
62 | 63 |
private Button selectConfirmButton = new Button("OK"); |
63 | 64 |
private Button removeButton = new Button(FontAwesome.REMOVE); |
... | ... | |
76 | 77 |
|
77 | 78 |
private CdmFilterablePagingProvider<AgentBase, Person> pagingProviderPerson; |
78 | 79 |
|
79 |
public TeamOrPersonField(String caption){ |
|
80 |
private TeamOrPersonBaseCaptionGenerator.CacheType cacheType; |
|
81 |
|
|
82 |
public TeamOrPersonField(String caption, TeamOrPersonBaseCaptionGenerator.CacheType cacheType){ |
|
80 | 83 |
|
81 | 84 |
setCaption(caption); |
82 | 85 |
|
83 |
teamOrPersonSelect.setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TeamOrPersonBase>()); |
|
86 |
this.cacheType = cacheType; |
|
87 |
teamOrPersonSelect.setCaptionGenerator(new TeamOrPersonBaseCaptionGenerator<TeamOrPersonBase>(cacheType)); |
|
84 | 88 |
|
85 | 89 |
|
86 | 90 |
addStyledComponent(teamOrPersonSelect); |
... | ... | |
329 | 333 |
PersonField f = new PersonField(); |
330 | 334 |
f.setAllowNewEmptyEntity(true); // otherwise new entities can not be added to the personsListEditor |
331 | 335 |
f.getPersonSelect().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize()); |
332 |
f.getPersonSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Person>());
|
|
336 |
f.getPersonSelect().setCaptionGenerator(new TeamOrPersonBaseCaptionGenerator<Person>(cacheType));
|
|
333 | 337 |
f.getPersonSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Person>(f.getPersonSelect(), cachingPresenter)); |
334 | 338 |
return f; |
335 | 339 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/TeamOrPersonBaseCaptionGenerator.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 org.vaadin.viritin.fields.CaptionGenerator; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author a.kohlbecker |
|
17 |
* @since Jun 7, 2017 |
|
18 |
* |
|
19 |
*/ |
|
20 |
public final class TeamOrPersonBaseCaptionGenerator<T extends TeamOrPersonBase<?>> implements CaptionGenerator<T> { |
|
21 |
|
|
22 |
public enum CacheType { |
|
23 |
NOMENCLATURAL_TITLE, |
|
24 |
COLLECTOR_TITLE, |
|
25 |
BIBLIOGRAPHIC_TITLE; |
|
26 |
} |
|
27 |
|
|
28 |
CacheType cacheType; |
|
29 |
|
|
30 |
private static final long serialVersionUID = 116448502301429773L; |
|
31 |
|
|
32 |
public TeamOrPersonBaseCaptionGenerator(CacheType cacheType){ |
|
33 |
this.cacheType = cacheType; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public String getCaption(T option) { |
|
38 |
switch(cacheType){ |
|
39 |
case NOMENCLATURAL_TITLE: |
|
40 |
return option.getNomenclaturalTitle(); |
|
41 |
case COLLECTOR_TITLE: |
|
42 |
// return option.getCollectorTitle(); // enable once #4311 is solved |
|
43 |
case BIBLIOGRAPHIC_TITLE: |
|
44 |
default: |
|
45 |
return option.getTitleCache(); |
|
46 |
} |
|
47 |
} |
|
48 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
219 | 219 |
} |
220 | 220 |
|
221 | 221 |
|
222 |
|
|
222 | 223 |
@EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class) |
223 | 224 |
public void onTaxonNameEditorActionAdd(TaxonNameEditorAction action){ |
224 | 225 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetPopupEditor.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO; |
34 | 34 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
35 | 35 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
36 |
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator; |
|
36 | 37 |
import eu.etaxonomy.cdm.vaadin.view.PerEntityAuthorityGrantingEditor; |
37 | 38 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
38 | 39 |
|
... | ... | |
144 | 145 |
bindField(distanceToGroundMinMax.getTextField(), "distanceToGroundText"); |
145 | 146 |
|
146 | 147 |
row++; |
147 |
collectorField = new TeamOrPersonField("Collector"); |
|
148 |
collectorField = new TeamOrPersonField("Collector", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
|
|
148 | 149 |
addField(collectorField, "collector", 0, row, 2, row); |
149 | 150 |
|
150 | 151 |
row++; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java | ||
---|---|---|
34 | 34 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
35 | 35 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
36 | 36 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
37 |
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator; |
|
37 | 38 |
import eu.etaxonomy.cdm.vaadin.util.converter.SetToListConverter; |
38 | 39 |
import eu.etaxonomy.vaadin.component.SwitchableTextField; |
39 | 40 |
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect; |
... | ... | |
252 | 253 |
grid.addComponent(new Label("Hint: <i>Edit nomenclatural authors in the nomenclatural reference.</i>", ContentMode.HTML), 0, row, 3, row); |
253 | 254 |
|
254 | 255 |
row++; |
255 |
combinationAuthorshipField = new TeamOrPersonField("combination author(s)"); |
|
256 |
combinationAuthorshipField = new TeamOrPersonField("combination author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
|
|
256 | 257 |
combinationAuthorshipField.setWidth(100, Unit.PERCENTAGE); |
257 | 258 |
addField(combinationAuthorshipField, "combinationAuthorship", 0, row, GRID_COLS-1, row); |
258 | 259 |
|
... | ... | |
280 | 281 |
nomenclaturalReferenceDetail.setWidth(100, Unit.PIXELS); |
281 | 282 |
|
282 | 283 |
row++; |
283 |
exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)"); |
|
284 |
exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
|
|
284 | 285 |
exCombinationAuthorshipField.setWidth(100, Unit.PERCENTAGE); |
285 | 286 |
addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row); |
286 | 287 |
|
... | ... | |
310 | 311 |
}); |
311 | 312 |
grid.setComponentAlignment(basionymsComboboxSelect, Alignment.TOP_RIGHT); |
312 | 313 |
row++; |
313 |
basionymAuthorshipField = new TeamOrPersonField("Basionym author(s)"); |
|
314 |
basionymAuthorshipField = new TeamOrPersonField("Basionym author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
|
|
314 | 315 |
basionymAuthorshipField.setWidth(100, Unit.PERCENTAGE); |
315 | 316 |
addField(basionymAuthorshipField, "basionymAuthorship", 0, row, GRID_COLS-1, row); |
316 | 317 |
row++; |
317 |
exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)"); |
|
318 |
exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
|
|
318 | 319 |
exBasionymAuthorshipField.setWidth(100, Unit.PERCENTAGE); |
319 | 320 |
addField(exBasionymAuthorshipField, "exBasionymAuthorship", 0, row, GRID_COLS-1, row); |
320 | 321 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.vaadin.component.common.TimePeriodField; |
28 | 28 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
29 | 29 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
30 |
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator; |
|
30 | 31 |
import eu.etaxonomy.cdm.vaadin.util.converter.DoiConverter; |
31 | 32 |
import eu.etaxonomy.cdm.vaadin.util.converter.UriConverter; |
32 | 33 |
import eu.etaxonomy.vaadin.component.SwitchableTextField; |
... | ... | |
119 | 120 |
row++; |
120 | 121 |
addTextField("Nomenclatural title", "abbrevTitle", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE); |
121 | 122 |
row++; |
122 |
authorshipField = new TeamOrPersonField("Author(s)"); |
|
123 |
authorshipField = new TeamOrPersonField("Author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.BIBLIOGRAPHIC_TITLE);
|
|
123 | 124 |
authorshipField.setWidth(100, Unit.PERCENTAGE); |
124 | 125 |
addField(authorshipField, "authorship", 0, row, 3, row); |
125 | 126 |
row++; |
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/StatusPresenterTest.java | ||
---|---|---|
125 | 125 |
|
126 | 126 |
String uuid = (String)item.getItemProperty("UUID").getValue(); |
127 | 127 |
Assert.assertEquals(uuids[count], uuid); |
128 |
String titleCache = (String)item.getItemProperty("TITLECACHE").getValue();
|
|
128 |
String titleCache = (String)item.getItemProperty("BIBLIOGRAPHIC_TITLE").getValue();
|
|
129 | 129 |
logger.info("titleCache : " + titleCache); |
130 | 130 |
count++; |
131 | 131 |
|
Also available in: Unified diff
fix #7207 NomenclaturalTitle, Collector titel and bibliographic title for TeamOrPersonField