Project

General

Profile

« Previous | Next » 

Revision e5237e50

Added by Andreas Kohlbecker over 5 years ago

fix #7899 orthographic variant and corrections implemented in taxon name popup editor

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
73 73

  
74 74
    private final static int GRID_COLS = 4;
75 75

  
76
    private final static int GRID_ROWS = 18;
76
    private final static int GRID_ROWS = 19;
77 77

  
78 78
    private static final boolean HAS_BASIONYM_DEFAULT = false;
79 79

  
......
103 103

  
104 104
    private NameRelationField validationField;
105 105

  
106
    private NameRelationField orthographicVariantField;
107

  
106 108
    private CheckBox basionymToggle;
107 109

  
108 110
    private CheckBox replacedSynonymsToggle;
109 111

  
110 112
    private CheckBox validationToggle;
111 113

  
114
    private CheckBox orthographicVariantToggle;
115

  
112 116
    private ListSelect rankSelect;
113 117

  
114 118
    private TeamOrPersonField combinationAuthorshipField;
......
275 279
        addField(rankSelect, "rank", 0, row, 1, row);
276 280
        grid.setComponentAlignment(rankSelect, Alignment.TOP_RIGHT);
277 281

  
282
        row++;
278 283
        basionymToggle = new CheckBox("With basionym");
279 284
        basionymToggle.setValue(HAS_BASIONYM_DEFAULT);
280

  
281 285
        basionymToggle.setStyleName(getDefaultComponentStyles());
282
        grid.addComponent(basionymToggle, 2, row, 3, row);
286
        grid.addComponent(basionymToggle, 0, row);
283 287
        grid.setComponentAlignment(basionymToggle, Alignment.BOTTOM_LEFT);
284 288

  
285
        row++;
286 289
        replacedSynonymsToggle = new CheckBox("With replaced synonym");
287
        grid.addComponent(replacedSynonymsToggle, 2, row, 3, row);
290
        grid.addComponent(replacedSynonymsToggle, 1, row);
288 291
        grid.setComponentAlignment(replacedSynonymsToggle, Alignment.BOTTOM_LEFT);
289 292

  
290
        row++;
291 293
        validationToggle = new CheckBox("Validation");
292

  
293
        grid.addComponent(validationToggle, 2, row, 3, row);
294
        grid.addComponent(validationToggle, 2, row);
294 295
        grid.setComponentAlignment(validationToggle, Alignment.BOTTOM_LEFT);
295 296

  
297
        orthographicVariantToggle = new CheckBox("Orthographic variant");
298
        grid.addComponent(orthographicVariantToggle, 3, row);
299
        grid.setComponentAlignment(orthographicVariantToggle, Alignment.BOTTOM_LEFT);
300

  
296 301
        row++;
297 302
        // fullTitleCache
298 303
        fullTitleCacheFiled = addSwitchableTextField("Full title cache", "fullTitleCache", "protectedFullTitleCache", 0, row, GRID_COLS-1, row);
......
401 406

  
402 407
        // --------------- Validation
403 408
        row++;
404
        validationField = new NameRelationField("Validation", Direction.relatedTo, NameRelationshipType.VALIDATED_BY_NAME());
409
        validationField = new NameRelationField("Validation", "Validated name", Direction.relatedTo, NameRelationshipType.VALIDATED_BY_NAME());
405 410
        validationField.setWidth(100, Unit.PERCENTAGE);
406
        ToOneRelatedEntityCombobox<TaxonName> validatedNameComboBox = validationField.getValidatedNameComboBox();
411
        ToOneRelatedEntityCombobox<TaxonName> validatedNameComboBox = validationField.getRelatedNameComboBox();
407 412
        validatedNameComboBox.addClickListenerAddEntity(e -> getViewEventBus().publish(
408 413
                this,
409 414
                new TaxonNameEditorAction(EditorActionType.ADD, null, validatedNameComboBox, this)
......
422 427
        });
423 428
        ToOneRelatedEntityCombobox<Reference> validationCitatonComboBox = validationField.getCitatonComboBox();
424 429
        validationCitatonComboBox.addClickListenerAddEntity(e -> getViewEventBus().publish(
430
                // NOTE: adding new references is currently not allowed for name relations, see NameRelationField!!
425 431
                this,
426 432
                new ReferenceEditorAction(EditorActionType.ADD, null, validationCitatonComboBox, this)
427 433
                ));
......
440 446
        addField(validationField, "validationFor", 0, row, 3, row);
441 447
        grid.setComponentAlignment(validationField, Alignment.TOP_RIGHT);
442 448

  
449
        // ------- Orthographic Variant (Correction)
450
        row++;
451
        orthographicVariantField = new NameRelationField("Orthographic variant", "Name variant", Direction.relatedTo, NameRelationshipType.ORTHOGRAPHIC_VARIANT());
452
        orthographicVariantField.setWidth(100, Unit.PERCENTAGE);
453
        // corrected name must have same
454
        ToOneRelatedEntityCombobox<TaxonName> orthographicVariantCombobox = orthographicVariantField.getRelatedNameComboBox();
455
        orthographicVariantCombobox.addClickListenerAddEntity(e -> getViewEventBus().publish(
456
                this,
457
                new TaxonNameEditorAction(EditorActionType.ADD, null, orthographicVariantCombobox, this)
458
                ));
459
        orthographicVariantCombobox.addClickListenerEditEntity(e -> {
460
            if(orthographicVariantCombobox.getValue() != null){
461
                getViewEventBus().publish(this,
462
                    new TaxonNameEditorAction(
463
                            EditorActionType.EDIT,
464
                            orthographicVariantCombobox.getValue().getUuid(),
465
                            e.getButton(),
466
                            orthographicVariantCombobox,
467
                            this)
468
                );
469
            }
470
        });
471
        ToOneRelatedEntityCombobox<Reference> orthographicCorrectionCitatonComboBox = orthographicVariantField.getCitatonComboBox();
472
        orthographicCorrectionCitatonComboBox.addClickListenerAddEntity(e -> getViewEventBus().publish(
473
                // NOTE: adding new references is currently not allowed for name relations, see NameRelationField!!
474
                this,
475
                new ReferenceEditorAction(EditorActionType.ADD, null, orthographicCorrectionCitatonComboBox, this)
476
                ));
477
        orthographicCorrectionCitatonComboBox.addClickListenerEditEntity(e -> {
478
            if(orthographicCorrectionCitatonComboBox.getValue() != null){
479
                getViewEventBus().publish(this,
480
                    new ReferenceEditorAction(
481
                            EditorActionType.EDIT,
482
                            orthographicCorrectionCitatonComboBox.getValue().getUuid(),
483
                            e.getButton(),
484
                            orthographicCorrectionCitatonComboBox,
485
                            this)
486
                );
487
            }
488
        });
489
        addField(orthographicVariantField, "orthographicVariant", 0, row, 3, row);
490
        grid.setComponentAlignment(orthographicVariantField, Alignment.TOP_RIGHT);
491

  
443 492
        row++;
444 493
        exCombinationAuthorshipField = new TeamOrPersonField("Ex-combination author(s)", TeamOrPersonBaseCaptionGenerator.CacheType.NOMENCLATURAL_TITLE);
445 494
        exCombinationAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
......
531 580
            boolean enable = e.getProperty().getValue() != null && (Boolean)e.getProperty().getValue();
532 581
            replacedSynonymsComboboxSelect.setVisible(enable);
533 582
        });
534

  
583
        orthographicVariantToggle.addValueChangeListener(e -> {
584
            boolean enable = e.getProperty().getValue() != null && (Boolean)e.getProperty().getValue();
585
            orthographicVariantField.setVisible(enable);
586
        });
535 587

  
536 588
        TaxonNameDTO taxonNameDTO = getBean();
537 589
        boolean showBasionymSection = taxonNameDTO.getBasionyms().size() > 0
......
546 598
        replacedSynonymsComboboxSelect.setVisible(showReplacedSynonyms);
547 599

  
548 600
        boolean showValidationSection = taxonNameDTO.getValidationFor() != null || taxonNameDTO.getExCombinationAuthorship() != null;
549

  
550 601
        validationToggle.setValue(showValidationSection);
551 602
        validationToggle.setReadOnly(showValidationSection);
552
//        validationField.setVisible(showValidation);
553
//        exCombinationAuthorshipField.setVisible(showExAuthors);
603

  
604
        boolean showOrthographicCorrectionSection = taxonNameDTO.getOrthographicVariant() != null;
605
        orthographicVariantToggle.setValue(showOrthographicCorrectionSection);
606
        orthographicVariantToggle.setReadOnly(showOrthographicCorrectionSection);
554 607

  
555 608
        if(isModeEnabled(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA)){
556 609
            updateAuthorshipFields();
......
621 674
                taxonName.getExCombinationAuthorship(),
622 675
                inferExCombinationAuthors(),
623 676
                exCombinationAuthorshipField,
624
                validationField.getValidatedNameComboBox(),
677
                validationField.getRelatedNameComboBox(),
625 678
                isInferredExCombinationAuthorship
626 679
                );
627 680

  
628 681
        updateFieldVisibility();
629

  
630 682
    }
631 683

  
632
//    /**
633
//     *
634
//     */
635
//    protected void updateAuthorshipFieldsVisibility() {
636
//        combinationAuthorshipField.setVisible(!isInferredCombinationAuthorship);
637
//        if(BooleanUtils.isTrue(basionymToggle.getValue())){
638
//            basionymAuthorshipField.setVisible(!isInferredBasionymAuthorship);
639
//            exBasionymAuthorshipField.setVisible(!isInferredExBasionymAuthorship);
640
//        }
641
//    }
642 684

  
643 685
    /**
644 686
     *
......
702 744
        boolean isSpeciesOrBelow = !rank.isHigher(Rank.SPECIES());
703 745
        Boolean withBasionymSection = BooleanUtils.isTrue(basionymToggle.getValue());
704 746
        Boolean withValidationSection = BooleanUtils.isTrue(validationToggle.getValue());
747
        Boolean withOrthographicCorrectionSection = BooleanUtils.isTrue(orthographicVariantToggle.getValue());
705 748

  
706 749
        if(isModeEnabled(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART)){
707 750
            if(isSpeciesOrBelow) {
......
765 808
            }
766 809
        }
767 810

  
811
        if(isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)){
812
            orthographicVariantField.setCaption("Orthographic correction");
813
            orthographicVariantField.getRelatedNameComboBox().setCaption("Corrected name");
814
            orthographicVariantToggle.setCaption("Orthographic correction");
815
        } else {
816
            orthographicVariantField.setCaption("Orthographic variant");
817
            orthographicVariantField.getRelatedNameComboBox().setCaption("Name variant");
818
            orthographicVariantToggle.setCaption("Orthographic variant");
819
        }
820

  
768 821
        specificEpithetField.setVisible(isSpeciesOrBelow);
769 822
        infraSpecificEpithetField.setVisible(rank.isInfraSpecific());
770 823
        infraGenericEpithetField.setVisible(rank.isInfraGeneric());
......
778 831
        validationField.setVisible(withValidationSection);
779 832
        exCombinationAuthorshipField.setVisible(withValidationSection && isInferredExCombinationAuthorship != null && !isInferredExCombinationAuthorship);
780 833

  
834
        orthographicVariantField.setVisible(withOrthographicCorrectionSection);
781 835

  
782 836
//        if(taxonName != null){
783 837
//            if(modesActive.contains(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA)){
......
891 945
        return validationField;
892 946
    }
893 947

  
948
    @Override
949
    public NameRelationField getOrthographicVariantField() {
950
        return orthographicVariantField;
951
    }
952

  
894 953
    @Override
895 954
    public void enableMode(TaxonNamePopupEditorMode mode){
896 955
            modesActive.add(mode);

Also available in: Unified diff