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.view.taxon;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.context.annotation.Scope;
|
15
|
import org.springframework.security.core.GrantedAuthority;
|
16
|
|
17
|
import com.vaadin.spring.annotation.SpringComponent;
|
18
|
import com.vaadin.ui.Alignment;
|
19
|
import com.vaadin.ui.GridLayout;
|
20
|
import com.vaadin.ui.ListSelect;
|
21
|
import com.vaadin.ui.TextField;
|
22
|
|
23
|
import eu.etaxonomy.cdm.model.name.Rank;
|
24
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
25
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
26
|
import eu.etaxonomy.cdm.vaadin.component.SelectFieldFactory;
|
27
|
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
|
28
|
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
|
29
|
import eu.etaxonomy.vaadin.component.SwitchableTextField;
|
30
|
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
|
31
|
|
32
|
/**
|
33
|
* @author a.kohlbecker
|
34
|
* @since May 22, 2017
|
35
|
*
|
36
|
*/
|
37
|
@SpringComponent
|
38
|
@Scope("prototype")
|
39
|
public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonNameBase, TaxonNameEditorPresenter> implements TaxonNamePopupEditorView, AccessRestrictedView {
|
40
|
|
41
|
private static final long serialVersionUID = -7037436241474466359L;
|
42
|
|
43
|
@Autowired
|
44
|
private SelectFieldFactory selectFieldFactory;
|
45
|
|
46
|
private final static int GRID_COLS = 4;
|
47
|
|
48
|
private final static int GRID_ROWS = 7;
|
49
|
|
50
|
private TextField genusOrUninomialField;
|
51
|
|
52
|
private TextField infraGenericEpithetField;
|
53
|
|
54
|
private TextField specificEpithetField;
|
55
|
|
56
|
private TextField infraSpecificEpithetField;
|
57
|
|
58
|
private SwitchableTextField fullTitleCacheFiled;
|
59
|
|
60
|
private SwitchableTextField protectedNameCacheField;
|
61
|
|
62
|
|
63
|
/**
|
64
|
* @param layout
|
65
|
* @param dtoType
|
66
|
*/
|
67
|
public TaxonNamePopupEditor() {
|
68
|
super(new GridLayout(GRID_COLS, GRID_ROWS), TaxonNameBase.class);
|
69
|
}
|
70
|
|
71
|
/**
|
72
|
* {@inheritDoc}
|
73
|
*/
|
74
|
@Override
|
75
|
public String getWindowCaption() {
|
76
|
return "Name editor";
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* {@inheritDoc}
|
81
|
*/
|
82
|
@Override
|
83
|
public void focusFirst() {
|
84
|
// titleField.focus();
|
85
|
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* {@inheritDoc}
|
90
|
*/
|
91
|
@Override
|
92
|
protected String getDefaultComponentStyles() {
|
93
|
return "tiny";
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* {@inheritDoc}
|
98
|
*/
|
99
|
@Override
|
100
|
protected void initContent() {
|
101
|
|
102
|
GridLayout grid = (GridLayout)getFieldLayout();
|
103
|
grid.setSpacing(true);
|
104
|
|
105
|
/*
|
106
|
- nameType: preset, needs to be set in the presenter for new names
|
107
|
- appendedPhrase: -> TODO field
|
108
|
- nomenclaturalMicroReference: -> TODO field
|
109
|
- nomenclaturalReference -> field but disabled for REGISTRY
|
110
|
- rank -> SelectField which determines the visiblity of the other fields
|
111
|
|
112
|
- fullTitleCache + protectedFullTitleCache -> SwitchableTextField : ADVANCED_MODE
|
113
|
- nameCache + protectedNameCache -> SwitchableTextField : ADVANCED_MODE
|
114
|
|
115
|
- homotypicalGroup -> hidden
|
116
|
- typeDesignations -> hidden
|
117
|
- descriptions -> hidden
|
118
|
- taxonBases -> hidden
|
119
|
- registrations -> hidden
|
120
|
|
121
|
- relationsFromThisName-> TODO implement later
|
122
|
- relationsToThisName -> TODO implement later
|
123
|
|
124
|
- genusOrUninomial -> textField
|
125
|
- infraGenericEpithet -> textField
|
126
|
- specificEpithet -> textField
|
127
|
- infraSpecificEpithet -> textField
|
128
|
|
129
|
- authorshipCache + protectedAuthorshipCache -> SwitchableTextField : only ADVANCED_MODE and disabled for REGISTRY
|
130
|
- basionymAuthorship -> field but disabled for REGISTRY, basionym is set as nameRelationShip
|
131
|
- combinationAuthorship -> field but disabled for REGISTRY author team of the reference
|
132
|
- exCombinationAuthorship -> textField
|
133
|
- exBasionymAuthorship -> textField
|
134
|
|
135
|
- status -> TODO field
|
136
|
- monomHybrid -> TODO implement hybrids later
|
137
|
- binomHybrid -> TODO implement hybrids later
|
138
|
- trinomHybrid -> TODO implement hybrids later
|
139
|
|
140
|
- hybridParentRelations -> TODO implement hybrids later
|
141
|
- hybridChildRelations -> TODO implement hybrids later
|
142
|
- hybridFormula -> TODO implement hybrids later
|
143
|
|
144
|
** ViralName attributes **
|
145
|
- acronym
|
146
|
|
147
|
** BacterialName attributes **
|
148
|
- subGenusAuthorship
|
149
|
- nameApprobation
|
150
|
- breed
|
151
|
- publicationYear
|
152
|
- originalPublicationYear
|
153
|
- cultivarName
|
154
|
*/
|
155
|
|
156
|
int row = 0;
|
157
|
ListSelect rankSelect = selectFieldFactory.createListSelect("Rank", Rank.class, OrderHint.BY_ORDER_INDEX.asList(), "label");
|
158
|
rankSelect.setNullSelectionAllowed(false);
|
159
|
rankSelect.setRows(1);
|
160
|
rankSelect.addValueChangeListener(e -> updateFieldVisibility((Rank)e.getProperty().getValue()));
|
161
|
addField(rankSelect, "rank", 3, row);
|
162
|
grid.setComponentAlignment(rankSelect, Alignment.TOP_RIGHT);
|
163
|
row++;
|
164
|
// fullTitleCache
|
165
|
fullTitleCacheFiled = addSwitchableTextField("Full title cache", "fullTitleCache", "protectedFullTitleCache", 0, row, GRID_COLS-1, row);
|
166
|
fullTitleCacheFiled.setWidth(100, Unit.PERCENTAGE);
|
167
|
row++;
|
168
|
protectedNameCacheField = addSwitchableTextField("Name cache", "nameCache", "protectedNameCache", 0, row, GRID_COLS-1, row);
|
169
|
protectedNameCacheField.setWidth(100, Unit.PERCENTAGE);
|
170
|
row++;
|
171
|
genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
|
172
|
genusOrUninomialField.setWidth(200, Unit.PIXELS);
|
173
|
infraGenericEpithetField = addTextField("Infrageneric epithet", "infraGenericEpithet", 2, row, 3, row);
|
174
|
infraGenericEpithetField.setWidth(200, Unit.PIXELS);
|
175
|
row++;
|
176
|
specificEpithetField = addTextField("Specific epithet", "specificEpithet", 0, row, 1, row);
|
177
|
specificEpithetField.setWidth(200, Unit.PIXELS);
|
178
|
infraSpecificEpithetField = addTextField("Infraspecific epithet", "infraSpecificEpithet", 2, row, 3, row);
|
179
|
infraSpecificEpithetField.setWidth(200, Unit.PIXELS);
|
180
|
row++;
|
181
|
TeamOrPersonField exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)");
|
182
|
exCombinationAuthorshipField.setWidth(100, Unit.PERCENTAGE);
|
183
|
addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
|
184
|
row++;
|
185
|
TeamOrPersonField exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)");
|
186
|
exBasionymAuthorshipField.setWidth(100, Unit.PERCENTAGE);
|
187
|
addField(exBasionymAuthorshipField, "exBasionymAuthorship", 0, row, GRID_COLS-1, row);
|
188
|
row++;
|
189
|
|
190
|
setAdvancedModeEnabled(true);
|
191
|
registerAdvancedModeComponents(fullTitleCacheFiled, protectedNameCacheField);
|
192
|
setAdvancedMode(false);
|
193
|
|
194
|
}
|
195
|
|
196
|
/**
|
197
|
* @param rank
|
198
|
* @return
|
199
|
*/
|
200
|
private void updateFieldVisibility(Rank rank) {
|
201
|
boolean isSpeciesOrBelow = !rank.isHigher(Rank.SPECIES());
|
202
|
infraSpecificEpithetField.setVisible(rank.isInfraSpecific());
|
203
|
specificEpithetField.setVisible(isSpeciesOrBelow);
|
204
|
infraGenericEpithetField.setVisible(rank.isInfraGenericButNotSpeciesGroup());
|
205
|
genusOrUninomialField.setCaption(isSpeciesOrBelow ? "Genus" : "Uninomial");
|
206
|
}
|
207
|
|
208
|
/**
|
209
|
* {@inheritDoc}
|
210
|
*/
|
211
|
@Override
|
212
|
public boolean allowAnonymousAccess() {
|
213
|
return false;
|
214
|
}
|
215
|
|
216
|
/**
|
217
|
* {@inheritDoc}
|
218
|
*/
|
219
|
@Override
|
220
|
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
|
221
|
return null;
|
222
|
}
|
223
|
|
224
|
}
|