Project

General

Profile

Revision 8d7c5c55

ID8d7c5c5580ace79c5aac67d2de1b5c7586310763
Parent 754d57e3
Child f65345c7

Added by Andreas Kohlbecker over 2 years ago

ref #6169 renaming taxon package to name

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.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.view.name;
10

  
11
import java.util.Arrays;
12
import java.util.List;
13

  
14
import org.vaadin.viritin.fields.CaptionGenerator;
15
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
16
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
17

  
18
import eu.etaxonomy.cdm.api.service.DeleteResult;
19
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
20
import eu.etaxonomy.cdm.api.service.pager.Pager;
21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.persistence.query.MatchMode;
24
import eu.etaxonomy.cdm.persistence.query.OrderHint;
25
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
26

  
27
/**
28
 * @author a.kohlbecker
29
 * @since May 22, 2017
30
 *
31
 */
32
public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonNameBase, TaxonNamePopupEditorView> {
33

  
34
    private static final long serialVersionUID = -3538980627079389221L;
35

  
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    public void handleViewEntered() {
41
        super.handleViewEntered();
42

  
43
        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new CaptionGenerator<Reference>(){
44

  
45
            @Override
46
            public String getCaption(Reference option) {
47
                return option.getTitleCache();
48
            }
49

  
50
        });
51
        getView().getNomReferenceCombobox().loadFrom(new FilterablePagingProvider<Reference>(){
52

  
53
            @Override
54
            public List<Reference> findEntities(int firstRow, String filter) {
55
                Pager<Reference> page = getRepo().getReferenceService().findByTitle(
56
                        null,
57
                        filter,
58
                        MatchMode.ANYWHERE,
59
                        null,
60
                        20,
61
                        firstRow,
62
                        OrderHint.ORDER_BY_TITLE_CACHE.asList(),
63
                        Arrays.asList("$")
64
                      );
65
                return page.getRecords();
66
            }},
67
            new FilterableCountProvider(){
68
                @Override
69
                public int size(String filter) {
70
                    Pager<Reference> page = getRepo().getReferenceService().findByTitle(
71
                            null,
72
                            filter,
73
                            MatchMode.ANYWHERE,
74
                            null,
75
                            1,
76
                            0,
77
                            null,
78
                            null
79
                          );
80
                    return page.getCount().intValue();
81
                }}
82
            , 20);
83
    }
84

  
85

  
86
    /**
87
     * {@inheritDoc}
88
     */
89
    @Override
90
    protected DeleteResult executeServiceDeleteOperation(TaxonNameBase bean) {
91
        NameDeletionConfigurator config = new NameDeletionConfigurator();
92
        return getRepo().getNameService().delete(bean.getUuid(), config);
93
    }
94

  
95

  
96
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.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.view.name;
10

  
11
import java.util.Collection;
12

  
13
import org.springframework.security.core.GrantedAuthority;
14

  
15
import com.vaadin.ui.Alignment;
16
import com.vaadin.ui.GridLayout;
17
import com.vaadin.ui.ListSelect;
18
import com.vaadin.ui.TextField;
19

  
20
import eu.etaxonomy.cdm.model.name.Rank;
21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.persistence.query.OrderHint;
24
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
25
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction;
26
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
27
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
28
import eu.etaxonomy.vaadin.component.SwitchableTextField;
29
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
30
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
31

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

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

  
41
    private final static int GRID_COLS = 4;
42

  
43
    private final static int GRID_ROWS = 9;
44

  
45
    private TextField genusOrUninomialField;
46

  
47
    private TextField infraGenericEpithetField;
48

  
49
    private TextField specificEpithetField;
50

  
51
    private TextField infraSpecificEpithetField;
52

  
53
    private SwitchableTextField fullTitleCacheFiled;
54

  
55
    private SwitchableTextField protectedNameCacheField;
56

  
57
    private ToOneRelatedEntityCombobox<Reference> nomReferenceCombobox;
58

  
59
    private TextField nomenclaturalReferenceDetail;
60

  
61

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

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

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

  
85
    }
86

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

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

  
101
        GridLayout grid = (GridLayout)getFieldLayout();
102
        grid.setSpacing(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.addValueChangeListener(e -> updateFieldVisibility((Rank)e.getProperty().getValue()));
160
        addField(rankSelect, "rank", 3, row);
161
        grid.setComponentAlignment(rankSelect, Alignment.TOP_RIGHT);
162
        row++;
163
        // fullTitleCache
164
        fullTitleCacheFiled = addSwitchableTextField("Full title cache", "fullTitleCache", "protectedFullTitleCache", 0, row, GRID_COLS-1, row);
165
        fullTitleCacheFiled.setWidth(100, Unit.PERCENTAGE);
166
        row++;
167
        protectedNameCacheField = addSwitchableTextField("Name cache", "nameCache", "protectedNameCache", 0, row, GRID_COLS-1, row);
168
        protectedNameCacheField.setWidth(100, Unit.PERCENTAGE);
169
        row++;
170
        genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
171
        genusOrUninomialField.setWidth(200, Unit.PIXELS);
172
        infraGenericEpithetField = addTextField("Infrageneric epithet", "infraGenericEpithet", 2, row, 3, row);
173
        infraGenericEpithetField.setWidth(200, Unit.PIXELS);
174
        row++;
175
        specificEpithetField = addTextField("Specific epithet", "specificEpithet", 0, row, 1, row);
176
        specificEpithetField.setWidth(200, Unit.PIXELS);
177
        infraSpecificEpithetField = addTextField("Infraspecific epithet", "infraSpecificEpithet", 2, row, 3, row);
178
        infraSpecificEpithetField.setWidth(200, Unit.PIXELS);
179
        row++;
180
        TeamOrPersonField exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)");
181
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
182
        addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
183
        row++;
184
        TeamOrPersonField exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)");
185
        exBasionymAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
186
        addField(exBasionymAuthorshipField, "exBasionymAuthorship", 0, row, GRID_COLS-1, row);
187
        row++;
188

  
189
        // nomenclaturalReference
190
        nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
191
        nomReferenceCombobox.setWidth(100, Unit.PERCENTAGE);
192
        nomReferenceCombobox.addClickListenerAddEntity(e -> getEventBus().publishEvent(
193
                new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, nomReferenceCombobox, this)
194
                ));
195
        nomReferenceCombobox.addClickListenerEditEntity(e -> {
196
            if(nomReferenceCombobox.getValue() != null){
197
                getEventBus().publishEvent(
198
                    new ReferenceEditorAction(
199
                            AbstractEditorAction.Action.EDIT,
200
                            nomReferenceCombobox.getValue().getId(),
201
                            nomReferenceCombobox,
202
                            this)
203
                );
204
            }
205
            });
206
        addField(nomReferenceCombobox, "nomenclaturalReference", 0, row, 3, row);
207
        row++;
208
        nomenclaturalReferenceDetail = addTextField("Reference detail", "nomenclaturalMicroReference", 0, row, 1, row);
209

  
210
        setAdvancedModeEnabled(true);
211
        registerAdvancedModeComponents(fullTitleCacheFiled, protectedNameCacheField);
212
        setAdvancedMode(false);
213

  
214
    }
215

  
216
    /**
217
     * @param rank
218
     * @return
219
     */
220
    private void updateFieldVisibility(Rank rank) {
221
        boolean isSpeciesOrBelow = !rank.isHigher(Rank.SPECIES());
222
        // TODO use getField() instead and remove field references
223
        infraSpecificEpithetField.setVisible(rank.isInfraSpecific());
224
        specificEpithetField.setVisible(isSpeciesOrBelow);
225
        infraGenericEpithetField.setVisible(rank.isInfraGenericButNotSpeciesGroup());
226
        genusOrUninomialField.setCaption(isSpeciesOrBelow ? "Genus" : "Uninomial");
227
    }
228

  
229
    /**
230
     * {@inheritDoc}
231
     */
232
    @Override
233
    public boolean allowAnonymousAccess() {
234
        return false;
235
    }
236

  
237
    /**
238
     * {@inheritDoc}
239
     */
240
    @Override
241
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
242
        return null;
243
    }
244

  
245
    /**
246
     * {@inheritDoc}
247
     */
248
    @Override
249
    public ToOneRelatedEntityCombobox<Reference> getNomReferenceCombobox() {
250
        return nomReferenceCombobox;
251
    }
252

  
253
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.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.view.name;
10

  
11
import eu.etaxonomy.cdm.model.reference.Reference;
12
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
13
import eu.etaxonomy.vaadin.mvp.ApplicationView;
14

  
15
/**
16
 * @author a.kohlbecker
17
 * @since May 22, 2017
18
 *
19
 */
20
public interface TaxonNamePopupEditorView extends ApplicationView<TaxonNameEditorPresenter> {
21

  
22
    /**
23
     * @return
24
     */
25
    public ToOneRelatedEntityCombobox<Reference> getNomReferenceCombobox();
26

  
27
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowPresenter.java
36 36
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
37 37
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
38 38
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
39
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor;
39 40
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
40
import eu.etaxonomy.cdm.vaadin.view.taxon.TaxonNamePopupEditor;
41 41
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
42 42

  
43 43
/**
src/main/java/eu/etaxonomy/cdm/vaadin/view/taxon/TaxonNameEditorPresenter.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.view.taxon;
10

  
11
import java.util.Arrays;
12
import java.util.List;
13

  
14
import org.vaadin.viritin.fields.CaptionGenerator;
15
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider;
16
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider;
17

  
18
import eu.etaxonomy.cdm.api.service.DeleteResult;
19
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
20
import eu.etaxonomy.cdm.api.service.pager.Pager;
21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.persistence.query.MatchMode;
24
import eu.etaxonomy.cdm.persistence.query.OrderHint;
25
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
26

  
27
/**
28
 * @author a.kohlbecker
29
 * @since May 22, 2017
30
 *
31
 */
32
public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonNameBase, TaxonNamePopupEditorView> {
33

  
34
    private static final long serialVersionUID = -3538980627079389221L;
35

  
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    public void handleViewEntered() {
41
        super.handleViewEntered();
42

  
43
        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new CaptionGenerator<Reference>(){
44

  
45
            @Override
46
            public String getCaption(Reference option) {
47
                return option.getTitleCache();
48
            }
49

  
50
        });
51
        getView().getNomReferenceCombobox().loadFrom(new FilterablePagingProvider<Reference>(){
52

  
53
            @Override
54
            public List<Reference> findEntities(int firstRow, String filter) {
55
                Pager<Reference> page = getRepo().getReferenceService().findByTitle(
56
                        null,
57
                        filter,
58
                        MatchMode.ANYWHERE,
59
                        null,
60
                        20,
61
                        firstRow,
62
                        OrderHint.ORDER_BY_TITLE_CACHE.asList(),
63
                        Arrays.asList("$")
64
                      );
65
                return page.getRecords();
66
            }},
67
            new FilterableCountProvider(){
68
                @Override
69
                public int size(String filter) {
70
                    Pager<Reference> page = getRepo().getReferenceService().findByTitle(
71
                            null,
72
                            filter,
73
                            MatchMode.ANYWHERE,
74
                            null,
75
                            1,
76
                            0,
77
                            null,
78
                            null
79
                          );
80
                    return page.getCount().intValue();
81
                }}
82
            , 20);
83
    }
84

  
85

  
86
    /**
87
     * {@inheritDoc}
88
     */
89
    @Override
90
    protected DeleteResult executeServiceDeleteOperation(TaxonNameBase bean) {
91
        NameDeletionConfigurator config = new NameDeletionConfigurator();
92
        return getRepo().getNameService().delete(bean.getUuid(), config);
93
    }
94

  
95

  
96
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/taxon/TaxonNamePopupEditor.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.view.taxon;
10

  
11
import java.util.Collection;
12

  
13
import org.springframework.security.core.GrantedAuthority;
14

  
15
import com.vaadin.ui.Alignment;
16
import com.vaadin.ui.GridLayout;
17
import com.vaadin.ui.ListSelect;
18
import com.vaadin.ui.TextField;
19

  
20
import eu.etaxonomy.cdm.model.name.Rank;
21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.persistence.query.OrderHint;
24
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
25
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction;
26
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
27
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
28
import eu.etaxonomy.vaadin.component.SwitchableTextField;
29
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
30
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
31

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

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

  
41
    private final static int GRID_COLS = 4;
42

  
43
    private final static int GRID_ROWS = 9;
44

  
45
    private TextField genusOrUninomialField;
46

  
47
    private TextField infraGenericEpithetField;
48

  
49
    private TextField specificEpithetField;
50

  
51
    private TextField infraSpecificEpithetField;
52

  
53
    private SwitchableTextField fullTitleCacheFiled;
54

  
55
    private SwitchableTextField protectedNameCacheField;
56

  
57
    private ToOneRelatedEntityCombobox<Reference> nomReferenceCombobox;
58

  
59
    private TextField nomenclaturalReferenceDetail;
60

  
61

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

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

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

  
85
    }
86

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

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

  
101
        GridLayout grid = (GridLayout)getFieldLayout();
102
        grid.setSpacing(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.addValueChangeListener(e -> updateFieldVisibility((Rank)e.getProperty().getValue()));
160
        addField(rankSelect, "rank", 3, row);
161
        grid.setComponentAlignment(rankSelect, Alignment.TOP_RIGHT);
162
        row++;
163
        // fullTitleCache
164
        fullTitleCacheFiled = addSwitchableTextField("Full title cache", "fullTitleCache", "protectedFullTitleCache", 0, row, GRID_COLS-1, row);
165
        fullTitleCacheFiled.setWidth(100, Unit.PERCENTAGE);
166
        row++;
167
        protectedNameCacheField = addSwitchableTextField("Name cache", "nameCache", "protectedNameCache", 0, row, GRID_COLS-1, row);
168
        protectedNameCacheField.setWidth(100, Unit.PERCENTAGE);
169
        row++;
170
        genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
171
        genusOrUninomialField.setWidth(200, Unit.PIXELS);
172
        infraGenericEpithetField = addTextField("Infrageneric epithet", "infraGenericEpithet", 2, row, 3, row);
173
        infraGenericEpithetField.setWidth(200, Unit.PIXELS);
174
        row++;
175
        specificEpithetField = addTextField("Specific epithet", "specificEpithet", 0, row, 1, row);
176
        specificEpithetField.setWidth(200, Unit.PIXELS);
177
        infraSpecificEpithetField = addTextField("Infraspecific epithet", "infraSpecificEpithet", 2, row, 3, row);
178
        infraSpecificEpithetField.setWidth(200, Unit.PIXELS);
179
        row++;
180
        TeamOrPersonField exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)");
181
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
182
        addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
183
        row++;
184
        TeamOrPersonField exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)");
185
        exBasionymAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
186
        addField(exBasionymAuthorshipField, "exBasionymAuthorship", 0, row, GRID_COLS-1, row);
187
        row++;
188

  
189
        // nomenclaturalReference
190
        nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
191
        nomReferenceCombobox.setWidth(100, Unit.PERCENTAGE);
192
        nomReferenceCombobox.addClickListenerAddEntity(e -> getEventBus().publishEvent(
193
                new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, nomReferenceCombobox, this)
194
                ));
195
        nomReferenceCombobox.addClickListenerEditEntity(e -> {
196
            if(nomReferenceCombobox.getValue() != null){
197
                getEventBus().publishEvent(
198
                    new ReferenceEditorAction(
199
                            AbstractEditorAction.Action.EDIT,
200
                            nomReferenceCombobox.getValue().getId(),
201
                            nomReferenceCombobox,
202
                            this)
203
                );
204
            }
205
            });
206
        addField(nomReferenceCombobox, "nomenclaturalReference", 0, row, 3, row);
207
        row++;
208
        nomenclaturalReferenceDetail = addTextField("Reference detail", "nomenclaturalMicroReference", 0, row, 1, row);
209

  
210
        setAdvancedModeEnabled(true);
211
        registerAdvancedModeComponents(fullTitleCacheFiled, protectedNameCacheField);
212
        setAdvancedMode(false);
213

  
214
    }
215

  
216
    /**
217
     * @param rank
218
     * @return
219
     */
220
    private void updateFieldVisibility(Rank rank) {
221
        boolean isSpeciesOrBelow = !rank.isHigher(Rank.SPECIES());
222
        // TODO use getField() instead and remove field references
223
        infraSpecificEpithetField.setVisible(rank.isInfraSpecific());
224
        specificEpithetField.setVisible(isSpeciesOrBelow);
225
        infraGenericEpithetField.setVisible(rank.isInfraGenericButNotSpeciesGroup());
226
        genusOrUninomialField.setCaption(isSpeciesOrBelow ? "Genus" : "Uninomial");
227
    }
228

  
229
    /**
230
     * {@inheritDoc}
231
     */
232
    @Override
233
    public boolean allowAnonymousAccess() {
234
        return false;
235
    }
236

  
237
    /**
238
     * {@inheritDoc}
239
     */
240
    @Override
241
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
242
        return null;
243
    }
244

  
245
    /**
246
     * {@inheritDoc}
247
     */
248
    @Override
249
    public ToOneRelatedEntityCombobox<Reference> getNomReferenceCombobox() {
250
        return nomReferenceCombobox;
251
    }
252

  
253
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/taxon/TaxonNamePopupEditorView.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.view.taxon;
10

  
11
import eu.etaxonomy.cdm.model.reference.Reference;
12
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
13
import eu.etaxonomy.vaadin.mvp.ApplicationView;
14

  
15
/**
16
 * @author a.kohlbecker
17
 * @since May 22, 2017
18
 *
19
 */
20
public interface TaxonNamePopupEditorView extends ApplicationView<TaxonNameEditorPresenter> {
21

  
22
    /**
23
     * @return
24
     */
25
    public ToOneRelatedEntityCombobox<Reference> getNomReferenceCombobox();
26

  
27
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)