Project

General

Profile

Download (23.2 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.name;
10

    
11
import java.util.Collection;
12
import java.util.EnumSet;
13

    
14
import org.apache.commons.lang3.BooleanUtils;
15
import org.springframework.context.annotation.Scope;
16
import org.springframework.security.core.GrantedAuthority;
17

    
18
import com.vaadin.shared.ui.label.ContentMode;
19
import com.vaadin.spring.annotation.SpringComponent;
20
import com.vaadin.ui.AbstractField;
21
import com.vaadin.ui.Alignment;
22
import com.vaadin.ui.CheckBox;
23
import com.vaadin.ui.GridLayout;
24
import com.vaadin.ui.Label;
25
import com.vaadin.ui.ListSelect;
26
import com.vaadin.ui.TextField;
27

    
28
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
29
import eu.etaxonomy.cdm.model.common.CdmBase;
30
import eu.etaxonomy.cdm.model.name.Rank;
31
import eu.etaxonomy.cdm.model.name.TaxonName;
32
import eu.etaxonomy.cdm.model.reference.Reference;
33
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
34
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
35
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
36
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
37
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
38
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
39
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator;
40
import eu.etaxonomy.cdm.vaadin.util.converter.SetToListConverter;
41
import eu.etaxonomy.vaadin.component.SwitchableTextField;
42
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect;
43
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
44
import eu.etaxonomy.vaadin.event.EditorActionType;
45
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
46
import eu.etaxonomy.vaadin.permission.EditPermissionTester;
47

    
48
/**
49
 * @author a.kohlbecker
50
 * @since May 22, 2017
51
 *
52
 */
53
@SpringComponent
54
@Scope("prototype")
55
public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, TaxonNameEditorPresenter> implements TaxonNamePopupEditorView, AccessRestrictedView {
56

    
57
    private static final long serialVersionUID = -7037436241474466359L;
58

    
59
    private final static int GRID_COLS = 4;
60

    
61
    private final static int GRID_ROWS = 13;
62

    
63
    private static final boolean HAS_BASIONYM_DEFAULT = false;
64

    
65
    private TextField genusOrUninomialField;
66

    
67
    private TextField infraGenericEpithetField;
68

    
69
    private TextField specificEpithetField;
70

    
71
    private TextField infraSpecificEpithetField;
72

    
73
    private SwitchableTextField fullTitleCacheFiled;
74

    
75
    private SwitchableTextField protectedNameCacheField;
76

    
77
    private ToOneRelatedEntityCombobox<Reference> nomReferenceCombobox;
78

    
79
    private TextField nomenclaturalReferenceDetail;
80

    
81
    private TeamOrPersonField exBasionymAuthorshipField;
82

    
83
    private TeamOrPersonField basionymAuthorshipField;
84

    
85
    private ToManyRelatedEntitiesComboboxSelect<TaxonName> basionymsComboboxSelect;
86

    
87
    private CheckBox basionymToggle;
88

    
89
    private CheckBox validationToggle;
90

    
91
    private ListSelect rankSelect;
92

    
93
    private TeamOrPersonField combinationAuthorshipField;
94

    
95
    private TeamOrPersonField exCombinationAuthorshipField;
96

    
97
    private EnumSet<TaxonNamePopupEditorMode> modesActive = EnumSet.noneOf(TaxonNamePopupEditorMode.class);
98

    
99
    private Boolean isInferredCombinationAuthorship = null;
100

    
101
    private Boolean isInferredBasionymAuthorship = null;
102

    
103
    private Boolean isInferredExBasionymAuthorship = null;
104

    
105
    /**
106
     * @param layout
107
     * @param dtoType
108
     */
109
    public TaxonNamePopupEditor() {
110
        super(new GridLayout(GRID_COLS, GRID_ROWS), TaxonName.class);
111
    }
112

    
113
    /**
114
     * {@inheritDoc}
115
     */
116
    @Override
117
    public String getWindowCaption() {
118
        return "Name editor";
119
    }
120

    
121

    
122

    
123
    /**
124
     * {@inheritDoc}
125
     */
126
    @Override
127
    public int getWindowWidth() {
128
        return 800;
129
    }
130

    
131
    /**
132
     * {@inheritDoc}
133
     */
134
    @Override
135
    public void focusFirst() {
136
        // titleField.focus();
137

    
138
    }
139

    
140
    /**
141
     * {@inheritDoc}
142
     */
143
    @Override
144
    protected String getDefaultComponentStyles() {
145
        return "tiny";
146
    }
147

    
148
    /**
149
     * {@inheritDoc}
150
     */
151
    @Override
152
    protected void initContent() {
153

    
154
        GridLayout grid = (GridLayout)getFieldLayout();
155
        grid.setSizeFull();
156
        grid.setHideEmptyRowsAndColumns(true);
157
        grid.setSpacing(true);
158
        grid.setColumnExpandRatio(0, 0.3f);
159
        grid.setColumnExpandRatio(1, 0.3f);
160
        grid.setColumnExpandRatio(2, 0.3f);
161
        grid.setColumnExpandRatio(3, 0.0f);
162

    
163
        /*
164
         - nameType: preset, needs to be set in the presenter for new names
165
         - appendedPhrase: -> TODO field
166
         - nomenclaturalMicroReference:  -> TODO field
167
         - nomenclaturalReference ->  field but disabled for REGISTRY
168
         - rank -> SelectField which determines the visiblity of the other fields
169

    
170
         - fullTitleCache + protectedFullTitleCache -> SwitchableTextField : ADVANCED_MODE
171
         - nameCache + protectedNameCache -> SwitchableTextField : ADVANCED_MODE
172

    
173
         - homotypicalGroup -> hidden
174
         - typeDesignations -> hidden
175
         - descriptions -> hidden
176
         - taxonBases -> hidden
177
         - registrations -> hidden
178

    
179
         - relationsFromThisName-> TODO implement later
180
         - relationsToThisName -> TODO implement later
181

    
182
         - genusOrUninomial -> textField
183
         - infraGenericEpithet  -> textField
184
         - specificEpithet  -> textField
185
         - infraSpecificEpithet  -> textField
186

    
187
         - authorshipCache + protectedAuthorshipCache -> SwitchableTextField : only ADVANCED_MODE and disabled for REGISTRY
188
         - basionymAuthorship -> field but disabled for REGISTRY, basionym is set as nameRelationShip
189
         - combinationAuthorship -> field but disabled for REGISTRY author team of the reference
190
         - exCombinationAuthorship -> textField
191
         - exBasionymAuthorship -> textField
192

    
193
         - status -> TODO field
194
         - monomHybrid -> TODO implement hybrids later
195
         - binomHybrid -> TODO implement hybrids later
196
         - trinomHybrid -> TODO implement hybrids later
197

    
198
         - hybridParentRelations -> TODO implement hybrids later
199
         - hybridChildRelations -> TODO implement hybrids later
200
         - hybridFormula -> TODO implement hybrids later
201

    
202
         ** ViralName attributes **
203
         - acronym
204

    
205
         ** BacterialName attributes **
206
         - subGenusAuthorship
207
         - nameApprobation
208
         - breed
209
         - publicationYear
210
         - originalPublicationYear
211
         - cultivarName
212
        */
213

    
214
        int row = 0;
215

    
216
        rankSelect = new ListSelect("Rank");
217
        rankSelect.setNullSelectionAllowed(false);
218
        rankSelect.setRows(1);
219
        rankSelect.setWidth(100, Unit.PERCENTAGE);
220
        rankSelect.addValueChangeListener(e -> updateFieldVisibility());
221
        addField(rankSelect, "rank", 0, row, 1, row);
222
        grid.setComponentAlignment(rankSelect, Alignment.TOP_RIGHT);
223

    
224
        basionymToggle = new CheckBox("With basionym");
225
        basionymToggle.setValue(HAS_BASIONYM_DEFAULT);
226
        basionymToggle.addValueChangeListener(e -> {
227
                updateFieldVisibility();
228
                updateAuthorshipFields();
229
            });
230
        basionymToggle.setStyleName(getDefaultComponentStyles());
231
        grid.addComponent(basionymToggle, 2, row, 3, row);
232
        grid.setComponentAlignment(basionymToggle, Alignment.BOTTOM_LEFT);
233

    
234
        row++;
235
        validationToggle = new CheckBox("Validation");
236
        validationToggle.addValueChangeListener(e -> {
237
                boolean enable = e.getProperty().getValue() != null && (Boolean)e.getProperty().getValue();
238
                exCombinationAuthorshipField.setVisible(enable);
239
            });
240
        grid.addComponent(validationToggle, 2, row, 3, row);
241
        grid.setComponentAlignment(validationToggle, Alignment.BOTTOM_LEFT);
242

    
243
        row++;
244
        // fullTitleCache
245
        fullTitleCacheFiled = addSwitchableTextField("Full title cache", "fullTitleCache", "protectedFullTitleCache", 0, row, GRID_COLS-1, row);
246
        fullTitleCacheFiled.setWidth(100, Unit.PERCENTAGE);
247
        row++;
248
        protectedNameCacheField = addSwitchableTextField("Name cache", "nameCache", "protectedNameCache", 0, row, GRID_COLS-1, row);
249
        protectedNameCacheField.setWidth(100, Unit.PERCENTAGE);
250
        row++;
251
        genusOrUninomialField = addTextField("Genus or uninomial", "genusOrUninomial", 0, row, 1, row);
252
        genusOrUninomialField.setWidth(200, Unit.PIXELS);
253
        infraGenericEpithetField = addTextField("Infrageneric epithet", "infraGenericEpithet", 2, row, 3, row);
254
        infraGenericEpithetField.setWidth(200, Unit.PIXELS);
255
        row++;
256
        specificEpithetField = addTextField("Specific epithet", "specificEpithet", 0, row, 1, row);
257
        specificEpithetField.setWidth(200, Unit.PIXELS);
258
        infraSpecificEpithetField = addTextField("Infraspecific epithet", "infraSpecificEpithet", 2, row, 3, row);
259
        infraSpecificEpithetField.setWidth(200, Unit.PIXELS);
260

    
261
        row++;
262
        grid.addComponent(new Label("Hint: <i>Edit nomenclatural authors in the nomenclatural reference.</i>", ContentMode.HTML), 0, row, 3, row);
263

    
264
        row++;
265
        combinationAuthorshipField = new TeamOrPersonField("combination author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
266
        combinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
267
        addField(combinationAuthorshipField, "combinationAuthorship", 0, row, GRID_COLS-1, row);
268

    
269
        row++;
270
        nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
271
        nomReferenceCombobox.addClickListenerAddEntity(e -> getViewEventBus().publish(
272
                this,
273
                new ReferenceEditorAction(EditorActionType.ADD, null, nomReferenceCombobox, this)
274
                ));
275
        nomReferenceCombobox.addClickListenerEditEntity(e -> {
276
            if(nomReferenceCombobox.getValue() != null){
277
                getViewEventBus().publish(this,
278
                    new ReferenceEditorAction(
279
                            EditorActionType.EDIT,
280
                            nomReferenceCombobox.getValue().getId(),
281
                            nomReferenceCombobox,
282
                            this)
283
                );
284
            }
285
            });
286
        // nomReferenceCombobox.setWidth(300, Unit.PIXELS);
287
        nomReferenceCombobox.setWidth("100%");
288
        addField(nomReferenceCombobox, "nomenclaturalReference", 0, row, 2, row);
289
        nomenclaturalReferenceDetail = addTextField("Reference detail", "nomenclaturalMicroReference", 3, row, 3, row);
290
        nomenclaturalReferenceDetail.setWidth(100, Unit.PIXELS);
291

    
292
        row++;
293
        exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
294
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
295
        addField(exCombinationAuthorshipField, "exCombinationAuthorship", 0, row, GRID_COLS-1, row);
296

    
297
        // Basionym
298
        row++;
299
        basionymsComboboxSelect = new ToManyRelatedEntitiesComboboxSelect<TaxonName>(TaxonName.class, "Basionym");
300
        basionymsComboboxSelect.setConverter(new SetToListConverter<TaxonName>());
301
        addField(basionymsComboboxSelect, "basionyms", 0, row, 3, row);
302
        basionymsComboboxSelect.setWidth(100, Unit.PERCENTAGE);
303
        basionymsComboboxSelect.withEditButton(true);
304
        basionymsComboboxSelect.setEditPermissionTester(new EditPermissionTester() {
305

    
306
            @Override
307
            public boolean userHasEditPermission(Object bean) {
308
                return  UserHelper.fromSession().userHasPermission((CdmBase)bean, CRUD.UPDATE, CRUD.DELETE);
309
            }
310
        });
311
        basionymsComboboxSelect.setEditActionListener(e -> {
312

    
313
            Object fieldValue = e.getSource().getValue();
314
            Integer beanId = null;
315
            if(fieldValue != null){
316
                beanId = ((CdmBase)fieldValue).getId();
317

    
318
            }
319
            getViewEventBus().publish(this, new TaxonNameEditorAction(e.getAction(), beanId, e.getSource(), this));
320
        });
321
        grid.setComponentAlignment(basionymsComboboxSelect, Alignment.TOP_RIGHT);
322
        row++;
323
        basionymAuthorshipField = new TeamOrPersonField("Basionym author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
324
        basionymAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
325
        addField(basionymAuthorshipField, "basionymAuthorship", 0, row, GRID_COLS-1, row);
326
        row++;
327
        exBasionymAuthorshipField = new TeamOrPersonField("Ex-basionym author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
328
        exBasionymAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
329
        addField(exBasionymAuthorshipField, "exBasionymAuthorship", 0, row, GRID_COLS-1, row);
330

    
331

    
332

    
333
        setAdvancedModeEnabled(true);
334
        registerAdvancedModeComponents(fullTitleCacheFiled, protectedNameCacheField);
335

    
336
        registerAdvancedModeComponents(combinationAuthorshipField);
337
        registerAdvancedModeComponents(basionymAuthorshipField);
338
        registerAdvancedModeComponents(exBasionymAuthorshipField);
339

    
340
        registerAdvancedModeComponents(combinationAuthorshipField.getCachFields());
341
        registerAdvancedModeComponents(exCombinationAuthorshipField.getCachFields());
342
        registerAdvancedModeComponents(basionymAuthorshipField.getCachFields());
343
        registerAdvancedModeComponents(exBasionymAuthorshipField.getCachFields());
344

    
345
        setAdvancedMode(false);
346

    
347
    }
348

    
349
    protected TeamOrPersonBase inferBasiomynAuthors(TaxonName taxonName) {
350
        TaxonName basionym = taxonName.getBasionym();
351
        if(basionym != null){
352
            if(basionym.getCombinationAuthorship() != null){
353
                return basionym.getCombinationAuthorship();
354
            } else if(basionym.getNomenclaturalReference() != null){
355
                return basionym.getNomenclaturalReference().getAuthorship();
356
            }
357
        }
358
        return null;
359
    }
360

    
361
    protected TeamOrPersonBase inferExBasiomynAuthors(TaxonName taxonName) {
362
        TaxonName basionym = taxonName.getBasionym();
363
        if(basionym != null){
364
                return basionym.getExCombinationAuthorship();
365
        }
366
        return null;
367
    }
368

    
369
    protected TeamOrPersonBase inferCombinationAuthors(TaxonName taxonName) {
370
        if(taxonName.getNomenclaturalReference() != null) {
371
            return taxonName.getNomenclaturalReference().getAuthorship();
372
        }
373
        return null;
374
    }
375

    
376
    @Override
377
    protected void afterItemDataSourceSet() {
378
        TaxonName taxonName = getBean();
379
        boolean showBasionymSection = taxonName.getBasionyms().size() > 0
380
                || taxonName.getBasionymAuthorship() != null
381
                || taxonName.getExBasionymAuthorship() != null;
382
        basionymToggle.setValue(showBasionymSection);
383
        basionymToggle.setReadOnly(showBasionymSection);
384

    
385
        boolean showExAuthors = taxonName.getExCombinationAuthorship() != null;
386
        validationToggle.setValue(showExAuthors);
387
        validationToggle.setReadOnly(showExAuthors);
388
        exCombinationAuthorshipField.setVisible(showExAuthors);
389

    
390
        if(isModeEnabled(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA)){
391
            updateAuthorshipFields();
392
        }
393
        if(isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY) && getBean().getNomenclaturalReference() != null) {
394
            nomReferenceCombobox.setCaption("Selection limited to nomenclatural reference and sections");
395
        }
396
        if(isModeEnabled(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE)) {
397
            if(combinationAuthorshipField.getValue() == null){
398
                nomReferenceCombobox.setRequired(true);
399
            } else {
400
                combinationAuthorshipField.addValueChangeListener(e -> {
401
                    if(e.getProperty().getValue() == null){
402
                        nomReferenceCombobox.setRequired(true);
403
                    }
404
                });
405
            }
406
        }
407

    
408
    }
409

    
410
    /**
411
     * @param taxonName
412
     */
413
    @Override
414
    public void updateAuthorshipFields() {
415

    
416
        TaxonName taxonName = getBean();
417

    
418
        // ------------- CombinationAuthors
419
        isInferredCombinationAuthorship = updateAuthorshipField(
420
                taxonName.getCombinationAuthorship(),
421
                inferCombinationAuthors(taxonName),
422
                combinationAuthorshipField,
423
                nomReferenceCombobox.getSelect(),
424
                isInferredCombinationAuthorship);
425

    
426

    
427
        // ------------- Basionym and ExBasionymAuthors
428
        if(BooleanUtils.isTrue(basionymToggle.getValue())){
429

    
430
            isInferredBasionymAuthorship = updateAuthorshipField(
431
                    taxonName.getBasionymAuthorship(),
432
                    inferBasiomynAuthors(taxonName),
433
                    basionymAuthorshipField,
434
                    basionymsComboboxSelect,
435
                    isInferredBasionymAuthorship
436
                    );
437

    
438
            isInferredExBasionymAuthorship = updateAuthorshipField(
439
                    taxonName.getExBasionymAuthorship(),
440
                    inferExBasiomynAuthors(taxonName),
441
                    exBasionymAuthorshipField,
442
                    //no point adding the basionymsComboboxSelect again, it has bee registered already for the BasionymAuthorship above
443
                    null,
444
                    isInferredExBasionymAuthorship
445
                    );
446
        }
447
    }
448

    
449
    /**
450
     *
451
     * @param authorship
452
     *    the value of the taxonName authorship field
453
     * @param inferredAuthors
454
     *    the value inferred from other fields which may be set as authorship to the taxon name
455
     * @param authorshipField
456
     *    the ui element to edit the taxonName authorship field
457
     * @param updateTriggerField
458
     * @param lastInferredAuthorshipState
459
     * @return
460
     */
461
    protected Boolean updateAuthorshipField(TeamOrPersonBase<?> authorship, TeamOrPersonBase inferredAuthors,
462
            TeamOrPersonField authorshipField, AbstractField updateTriggerField,
463
            Boolean lastInferredAuthorshipState) {
464

    
465
        if(authorship == null){
466
            authorshipField.setValue(inferredAuthors);
467
            lastInferredAuthorshipState = true;
468
        } else {
469
            boolean authorshipMatch = authorship == inferredAuthors;
470
            if(lastInferredAuthorshipState == null){
471
                // initialization of isInferredCombinationAuthorship in case the editor is just being initialized
472
                lastInferredAuthorshipState = authorshipMatch;
473
                if(updateTriggerField != null){
474
                    // IMPORTANT!
475
                    // this ChangeListener must be added at this very late point in the editor lifecycle so that it is called after
476
                    // the ToOneRelatedEntityReloader which may have been added to the updateTriggerField in the presenters handleViewEntered() method.
477
                    // Otherwise we risk multiple representation problems in the hibernate session
478
                    updateTriggerField.addValueChangeListener(e -> updateAuthorshipFields());
479
                }
480
            }
481
            if(!authorshipMatch && lastInferredAuthorshipState){
482
                // update the combinationAuthorshipField to follow changes of the nomenclatural reference in case it was autofilled before
483
                authorshipField.setValue(inferredAuthors);
484
                lastInferredAuthorshipState = true;
485
            }
486
        }
487
        authorshipField.setVisible(!lastInferredAuthorshipState);
488
        return lastInferredAuthorshipState;
489
    }
490

    
491
    /**
492
     * @param rank
493
     * @return
494
     */
495
    private void updateFieldVisibility() {
496

    
497
        // TODO use getField() instead and remove field references
498

    
499
        TaxonName taxonName = getBean();
500
        Rank rank = taxonName.getRank();
501

    
502
        boolean isSpeciesOrBelow = !rank.isHigher(Rank.SPECIES());
503
        Boolean withBasionym = BooleanUtils.isTrue(basionymToggle.getValue());
504
        Boolean withValidation = BooleanUtils.isTrue(validationToggle.getValue());
505

    
506
        basionymAuthorshipField.setVisible(withBasionym != null && withBasionym);
507
        exBasionymAuthorshipField.setVisible(withBasionym);
508
        basionymsComboboxSelect.setVisible(withBasionym);
509

    
510
        if(taxonName != null){
511
            if(modesActive.contains(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA)){
512
                updateAuthorshipFields();
513
            }
514
        }
515

    
516
        infraSpecificEpithetField.setVisible(rank.isInfraSpecific());
517
        specificEpithetField.setVisible(isSpeciesOrBelow);
518
        infraGenericEpithetField.setVisible(rank.isInfraGenericButNotSpeciesGroup());
519
        genusOrUninomialField.setCaption(isSpeciesOrBelow ? "Genus" : "Uninomial");
520
        exCombinationAuthorshipField.setVisible(isSpeciesOrBelow && withValidation);
521
    }
522

    
523
    /**
524
     * {@inheritDoc}
525
     */
526
    @Override
527
    public boolean allowAnonymousAccess() {
528
        return false;
529
    }
530

    
531
    /**
532
     * {@inheritDoc}
533
     */
534
    @Override
535
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
536
        return null;
537
    }
538

    
539
    /**
540
     * {@inheritDoc}
541
     */
542
    @Override
543
    public ToOneRelatedEntityCombobox<Reference> getNomReferenceCombobox() {
544
        return nomReferenceCombobox;
545
    }
546

    
547
    /**
548
     * {@inheritDoc}
549
     */
550
    @Override
551
    public ToManyRelatedEntitiesComboboxSelect<TaxonName> getBasionymComboboxSelect() {
552
        return basionymsComboboxSelect;
553
    }
554

    
555
    /**
556
     * {@inheritDoc}
557
     */
558
    @Override
559
    public ListSelect getRankSelect() {
560
        return rankSelect;
561
    }
562

    
563
    /**
564
     * @return the exBasionymAuthorshipField
565
     */
566
    @Override
567
    public TeamOrPersonField getExBasionymAuthorshipField() {
568
        return exBasionymAuthorshipField;
569
    }
570

    
571
    /**
572
     * @return the basionymAuthorshipField
573
     */
574
    @Override
575
    public TeamOrPersonField getBasionymAuthorshipField() {
576
        return basionymAuthorshipField;
577
    }
578

    
579
    /**
580
     * @return the combinationAuthorshipField
581
     */
582
    @Override
583
    public TeamOrPersonField getCombinationAuthorshipField() {
584
        return combinationAuthorshipField;
585
    }
586

    
587
    /**
588
     * @return the exCombinationAuthorshipField
589
     */
590
    @Override
591
    public TeamOrPersonField getExCombinationAuthorshipField() {
592
        return exCombinationAuthorshipField;
593
    }
594

    
595
    @Override
596
    public void enableMode(TaxonNamePopupEditorMode mode){
597
            modesActive.add(mode);
598
    }
599

    
600
    @Override
601
    public boolean isModeEnabled(TaxonNamePopupEditorMode mode){
602
        return modesActive.contains(mode);
603
    }
604

    
605
    @Override
606
    public void disableMode(TaxonNamePopupEditorMode mode){
607
        modesActive.remove(mode);
608
    }
609

    
610
    @Override
611
    public EnumSet<TaxonNamePopupEditorMode> getModesActive(){
612
        return modesActive;
613
    }
614

    
615
    @Override
616
    public CheckBox getBasionymToggle() {
617
        return basionymToggle;
618
    }
619

    
620
    /**
621
     * {@inheritDoc}
622
     */
623
    @Override
624
    public void setReadOnly(boolean readOnly) {
625
        boolean basionymToggleReadonly = basionymToggle.isReadOnly();
626
        boolean validationToggleReadonly = validationToggle.isReadOnly();
627
        super.setReadOnly(readOnly);
628
        // preserve old readonly states if they were true
629
        if(basionymToggleReadonly){
630
            basionymToggle.setReadOnly(true);
631
        }
632
        if(validationToggleReadonly){
633
            validationToggle.setReadOnly(true);
634
        }
635
    }
636

    
637

    
638

    
639

    
640
}
(10-10/13)