Project

General

Profile

Download (7 KB) Statistics
| Branch: | Tag: | Revision:
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.mvp.AbstractCdmPopupEditor;
30

    
31
/**
32
 * @author a.kohlbecker
33
 * @since May 22, 2017
34
 *
35
 */
36
@SpringComponent
37
@Scope("prototype")
38
public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonNameBase, TaxonNameEditorPresenter> implements TaxonNamePopupEditorView, AccessRestrictedView {
39

    
40
    private static final long serialVersionUID = -7037436241474466359L;
41

    
42
    @Autowired
43
    private SelectFieldFactory selectFieldFactory;
44

    
45
    private final static int GRID_COLS = 4;
46

    
47
    private final static int GRID_ROWS = 7;
48

    
49
    private TextField titleField;
50

    
51
    private TextField genusOrUninomialField;
52

    
53
    private TextField infraGenericEpithetField;
54

    
55
    private TextField specificEpithetField;
56

    
57
    private TextField infraSpecificEpithetField;
58

    
59

    
60

    
61
    /**
62
     * @param layout
63
     * @param dtoType
64
     */
65
    public TaxonNamePopupEditor() {
66
        super(new GridLayout(GRID_COLS, GRID_ROWS), TaxonNameBase.class);
67
    }
68

    
69
    /**
70
     * {@inheritDoc}
71
     */
72
    @Override
73
    public String getWindowCaption() {
74
        return "Name editor";
75
    }
76

    
77
    /**
78
     * {@inheritDoc}
79
     */
80
    @Override
81
    public void focusFirst() {
82
        // titleField.focus();
83

    
84
    }
85

    
86
    /**
87
     * {@inheritDoc}
88
     */
89
    @Override
90
    protected String getDefaultComponentStyles() {
91
        return "tiny";
92
    }
93

    
94
    /**
95
     * {@inheritDoc}
96
     */
97
    @Override
98
    protected void initContent() {
99

    
100
        GridLayout grid = (GridLayout)getFieldLayout();
101
        grid.setSpacing(true);
102
        grid.setMargin(true);
103

    
104
        /*
105
         - nameType: preset, needs to be set in the presenter for new names
106
         - appendedPhrase: -> TODO field
107
         - nomenclaturalMicroReference:  -> TODO field
108
         - nomenclaturalReference ->  field but disabled for REGISTRY
109
         - rank -> SelectField which determines the visiblity of the other fields
110

    
111
         - fullTitleCache + protectedFullTitleCache -> SwitchableTextField : ADVANCED_MODE
112
         - nameCache + protectedNameCache -> SwitchableTextField : ADVANCED_MODE
113

    
114
         - homotypicalGroup -> hidden
115
         - typeDesignations -> hidden
116
         - descriptions -> hidden
117
         - taxonBases -> hidden
118
         - registrations -> hidden
119

    
120
         - relationsFromThisName-> TODO implement later
121
         - relationsToThisName -> TODO implement later
122

    
123
         - genusOrUninomial -> textField
124
         - infraGenericEpithet  -> textField
125
         - specificEpithet  -> textField
126
         - infraSpecificEpithet  -> textField
127

    
128
         - authorshipCache + protectedAuthorshipCache -> SwitchableTextField : only ADVANCED_MODE and disabled for REGISTRY
129
         - basionymAuthorship -> field but disabled for REGISTRY, basionym is set as nameRelationShip
130
         - combinationAuthorship -> field but disabled for REGISTRY author team of the reference
131
         - exCombinationAuthorship -> textField
132
         - exBasionymAuthorship -> textField
133

    
134
         - status -> TODO field
135
         - monomHybrid -> TODO implement hybrids later
136
         - binomHybrid -> TODO implement hybrids later
137
         - trinomHybrid -> TODO implement hybrids later
138

    
139
         - hybridParentRelations -> TODO implement hybrids later
140
         - hybridChildRelations -> TODO implement hybrids later
141
         - hybridFormula -> TODO implement hybrids later
142

    
143
         ** ViralName attributes **
144
         - acronym
145

    
146
         ** BacterialName attributes **
147
         - subGenusAuthorship
148
         - nameApprobation
149
         - breed
150
         - publicationYear
151
         - originalPublicationYear
152
         - cultivarName
153
        */
154

    
155
        int row = 0;
156
        ListSelect rankSelect = selectFieldFactory.createListSelect("Rank", Rank.class, OrderHint.BY_ORDER_INDEX.asList(), "label");
157
        rankSelect.setNullSelectionAllowed(false);
158
        rankSelect.setRows(1);
159
        rankSelect.addValidator(e -> updateFieldVisibility());
160
        addField(rankSelect, "rank", 3, row);
161
        grid.setComponentAlignment(rankSelect, Alignment.TOP_RIGHT);
162
        row++;
163
        // fullTitleCache
164
        addSwitchableTextField("Full title cache", "fullTitleCache", "protectedFullTitleCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
165
        row++;
166
        addSwitchableTextField("Name cache", "nameCache", "protectedNameCache", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
167
        row++;
168
        genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
169
        genusOrUninomialField.setWidth(200, Unit.PIXELS);
170
        infraGenericEpithetField = addTextField("Infrageneric epithet", "infraGenericEpithet", 2, row, 3, row);
171
        infraGenericEpithetField.setWidth(200, Unit.PIXELS);
172
        row++;
173
        specificEpithetField = addTextField("Specific epithet", "specificEpithet", 0, row, 1, row);
174
        specificEpithetField.setWidth(200, Unit.PIXELS);
175
        infraSpecificEpithetField = addTextField("Infraspecific epithet", "infraSpecificEpithet", 2, row, 3, row);
176
        infraSpecificEpithetField.setWidth(200, Unit.PIXELS);
177
        row++;
178
        TeamOrPersonField exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)");
179
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
180
        addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
181
        row++;
182
        TeamOrPersonField exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)");
183
        exBasionymAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
184
        addField(exBasionymAuthorshipField, "exBasionymAuthorship", 0, row, GRID_COLS-1, row);
185
        row++;
186

    
187

    
188

    
189
    }
190

    
191
    /**
192
     * @return
193
     */
194
    private Object updateFieldVisibility() {
195
        // TODO Auto-generated method stub
196
        // TODO change label of
197
        // - genusOrUninomialField
198
        return null;
199
    }
200

    
201
    /**
202
     * {@inheritDoc}
203
     */
204
    @Override
205
    public boolean allowAnonymousAccess() {
206
        return false;
207
    }
208

    
209
    /**
210
     * {@inheritDoc}
211
     */
212
    @Override
213
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
214
        return null;
215
    }
216

    
217
}
(2-2/3)