Project

General

Profile

« Previous | Next » 

Revision 508b8f01

Added by Andreas Kohlbecker about 3 years ago

ref #9290 NameTypeDesignationEditor now using designation reference correctly

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationEditorView.java
24 24
 */
25 25
public interface NameTypeDesignationEditorView extends ApplicationView<NameTypeDesignationPresenter>, AnnotationsEditor  {
26 26

  
27
    ToOneRelatedEntityCombobox<Reference> getCitationCombobox();
27
    ToOneRelatedEntityCombobox<Reference> getDesignationReferenceCombobox();
28 28

  
29 29
    NativeSelect getTypeStatusSelect();
30 30

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPopupEditor.java
20 20
import eu.etaxonomy.cdm.api.utility.RoleProber;
21 21
import eu.etaxonomy.cdm.model.common.AnnotationType;
22 22
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
23
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
23 24
import eu.etaxonomy.cdm.model.name.TaxonName;
24 25
import eu.etaxonomy.cdm.model.reference.Reference;
25 26
import eu.etaxonomy.cdm.service.UserHelperAccess;
......
58 59

  
59 60
    private NativeSelect typeStatusSelect;
60 61

  
61
    private ToOneRelatedEntityCombobox<Reference> citationCombobox;
62
    private ToOneRelatedEntityCombobox<Reference> designationReferenceCombobox;
62 63

  
63
    private TextField citationDetailField;
64
    private TextField designationReferenceDetailField;
64 65

  
65 66
    private boolean showTypeFlags = true;
66 67

  
......
144 145
        typeStatusSelect.setWidth(100, Unit.PERCENTAGE);
145 146
        addField(typeStatusSelect, "typeStatus", 0, row, 1, row);
146 147
        grid.setComponentAlignment(typeStatusSelect, Alignment.TOP_RIGHT);
148
        typeStatusSelect.addValueChangeListener(e -> {
149
            updateDesignationReferenceFields();
150
        });
147 151

  
148 152
        row++;
149 153
        typeNameField = new ToOneRelatedEntityCombobox<TaxonName>("Type name", TaxonName.class);
......
176 180
        typifiedNamesComboboxSelect.setReadOnly(false); // FIXME this does not help, see #7389
177 181

  
178 182
        row++;
179
        citationCombobox = new ToOneRelatedEntityCombobox<Reference>("Citation", Reference.class);
180
        addField(citationCombobox, "citation", 0, row, 2, row);
181
        citationCombobox.setWidth(400, Unit.PIXELS);
182
        citationDetailField = addTextField("Citation detail", "citationMicroReference", 3, row);
183
        designationReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Designation reference", Reference.class);
184
        addField(designationReferenceCombobox, "citation", 0, row, 2, row);
185
        designationReferenceCombobox.setWidth(400, Unit.PIXELS);
186
        designationReferenceDetailField = addTextField("Reference detail", "citationMicroReference", 3, row);
183 187

  
184 188
        row++;
185 189
        annotationsListField = new FilterableAnnotationsField("Editorial notes");
......
194 198
        addField(annotationsListField, "annotations", 0, row, 3, row);
195 199
    }
196 200

  
201

  
202

  
203
    @Override
204
    protected void afterItemDataSourceSet() {
205
        super.afterItemDataSourceSet();
206
        updateDesignationReferenceFields();
207
    }
208

  
209
    protected void updateDesignationReferenceFields() {
210
        boolean hasDesignationSource = typeStatusSelect.getValue() != null && ((NameTypeDesignationStatus)typeStatusSelect.getValue()).hasDesignationSource();
211
        designationReferenceDetailField.setVisible(hasDesignationSource);
212
        designationReferenceCombobox.setVisible(hasDesignationSource);
213
        // NOTE: For better usability we only hide these fields here,
214
        // NameTypeDesignationPresenter.preSaveBean(NameTypeDesignation bean) will empty them in needed
215
    }
216

  
197 217
    /**
198 218
     * @return the typeNameField
199 219
     */
......
222 242
     * @return the citationCombobox
223 243
     */
224 244
    @Override
225
    public ToOneRelatedEntityCombobox<Reference> getCitationCombobox() {
226
        return citationCombobox;
245
    public ToOneRelatedEntityCombobox<Reference> getDesignationReferenceCombobox() {
246
        return designationReferenceCombobox;
227 247
    }
228 248

  
229 249

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
80 80
        }
81 81
    };
82 82

  
83
    private CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider;
84

  
83 85

  
84 86
    @Override
85 87
    protected BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator(){
......
93 95
    protected NameTypeDesignation loadBeanById(Object identifier) {
94 96
        if(identifier instanceof Integer || identifier == null){
95 97
            return super.loadBeanById(identifier);
96
//        } else if(identifier instanceof TypedEntityReference && ((TypedEntityReference)identifier).getType().equals(TaxonName.class)) {
97
//            typifiedNameInContext = getRepo().getNameService().find(((TypedEntityReference)identifier).getUuid());
98
//            bean = super.loadBeanById(null);
99 98
        } else {
100 99
            TypeDesignationWorkingsetEditorIdSet idset = (TypeDesignationWorkingsetEditorIdSet)identifier;
101 100
            RegistrationDTO regDTO = registrationWorkingSetService.loadDtoByUuid(idset.registrationUuid);
102 101
            typifiedNameInContext = regDTO.typifiedName();
103 102
            // find the working set
104 103
            TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(idset.baseEntityRef);
105

  
106
            // NameTypeDesignation bameTypeDesignation = regDTO.getNameTypeDesignation(typeDesignationWorkingSet.getBaseEntityReference());
107 104
            if(!typeDesignationWorkingSet.getBaseEntityReference().getType().equals(NameTypeDesignation.class)){
108 105
                throw new RuntimeException("TypeDesignationWorkingsetEditorIdSet references not a NameTypeDesignation");
106
            } else {
107
                // TypeDesignationWorkingSet for NameTyped only contain one item!!!
108
                UUID nameTypeDesignationUuid = typeDesignationWorkingSet.getTypeDesignations().get(0).getUuid();
109
                return super.loadBeanById(nameTypeDesignationUuid);
109 110
            }
110
            // TypeDesignationWorkingSet for NameTyped only contain one item!!!
111
            UUID nameTypeDesignationUuid = typeDesignationWorkingSet.getTypeDesignations().get(0).getUuid();
112
            return super.loadBeanById(nameTypeDesignationUuid);
113 111
        }
114 112
    }
115 113

  
......
127 125
                "source.citation",
128 126
                "source.annotations",
129 127
                "source.markers",
128
                "source.links",
130 129
                }
131 130
        ));
132 131

  
......
144 143
    }
145 144

  
146 145

  
147

  
148

  
149 146
    /**
150 147
     * {@inheritDoc}
151 148
     */
......
155 152
        getView().getTypeStatusSelect().setContainerDataSource(cdmBeanItemContainerFactory.buildBeanItemContainer(NameTypeDesignationStatus.class));
156 153
        getView().getTypeStatusSelect().setItemCaptionPropertyId("description");
157 154

  
158
        getView().getCitationCombobox().getSelect().setCaptionGenerator(
159
                new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, getView().getCitationCombobox().getSelect())
155
        getView().getDesignationReferenceCombobox().getSelect().setCaptionGenerator(
156
                new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, getView().getDesignationReferenceCombobox().getSelect())
160 157
                );
161
        CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider = pagingProviderFactory.referencePagingProvider();
162
        getView().getCitationCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize());
163
        getView().getCitationCombobox().setNestedButtonStateUpdater(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getCitationCombobox()));
164
        getView().getCitationCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getCitationCombobox(), this));
158
        referencePagingProvider = pagingProviderFactory.referencePagingProvider();
159
        getView().getDesignationReferenceCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize());
160
        getView().getDesignationReferenceCombobox().setNestedButtonStateUpdater(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getDesignationReferenceCombobox()));
161
        getView().getDesignationReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getDesignationReferenceCombobox(), this));
165 162

  
166 163
        CdmFilterablePagingProvider<TaxonName,TaxonName> namePagingProvider = pagingProviderFactory.taxonNamesWithoutOrthophicIncorrect();
167 164
        getView().getTypeNameField().loadFrom(namePagingProvider, namePagingProvider, namePagingProvider.getPageSize());
......
214 211
    @Override
215 212
    protected NameTypeDesignation preSaveBean(NameTypeDesignation bean) {
216 213

  
214
        if(!bean.hasDesignationSource()) {
215
            bean.setSource(null); // this effectively removes the designation reference and reference detail
216
        }
217

  
217 218
        // the typifiedNames can only be set on the name side, so we need to
218 219
        // handle changes explicitly here
219 220
        HashSet<TaxonName> typifiedNames = new HashSet<>(bean.getTypifiedNames());
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TypeDesignationWorkingsetEditorIdSet.java
26 26
     * @param baseEntityRef
27 27
     *
28 28
     * @param publicationUuid
29
     *            Can <code>null</code> if the <code>workingsetID</code> is given.
29
     *            Can <code>null</code> if the <code>workingsetId</code> is given.
30 30
     * @param typifiedNameUuid
31 31
     *            Can <code>null</code> if the <code>workingsetId</code> is given
32 32
     */
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
567 567
            popup.setParentEditorActionContext(event.getContext(), event.getTarget());
568 568
            popup.withDeleteButton(true);
569 569
            popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationUuid(), event.getBaseEntityRef()));
570

  
571
            popup.getCitationCombobox().setEnabled(false);
572 570
            popup.getTypifiedNamesComboboxSelect().setEnabled(false);
573

  
574 571
            if(event.hasSource()){
575 572
                // propagate readonly state from source button to popup
576 573
                popup.setReadOnly(event.getSource().isReadOnly());
......
619 616
            NameTypeDesignationPopupEditor popup = openPopupEditor(NameTypeDesignationPopupEditor.class, event);
620 617
            popup.setParentEditorActionContext(event.getContext(), event.getTarget());
621 618
            popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
622
            RegistrationDTO regDto = workingset.getRegistrationDTO(event.getRegistrationUuid()).get();
623
            Reference citation = regDto.getCitation();
624 619
            nameTypeDesignationPopupEditorRegistrationUUIDMap.put(popup, event.getRegistrationUuid());
625 620
            popup.setBeanInstantiator(new BeanInstantiator<NameTypeDesignation>() {
626 621

  
......
629 624

  
630 625
                    TaxonName typifiedName = getRepo().getNameService().load(event.getTypifiedNameUuid(), Arrays.asList(new String[]{"typeDesignations", "homotypicalGroup"}));
631 626
                    NameTypeDesignation nameTypeDesignation  = NameTypeDesignation.NewInstance();
632
                    nameTypeDesignation.setCitation(citation);
633 627
                    nameTypeDesignation.getTypifiedNames().add(typifiedName);
634 628
                    return nameTypeDesignation;
635 629
                }
636 630
            });
637 631
            popup.withDeleteButton(false);
638 632
            popup.loadInEditor(null);
639
            popup.getCitationCombobox().setEnabled(false);
640 633
            popup.getTypifiedNamesComboboxSelect().setEnabled(false);
641 634
            if(event.hasSource()){
642 635
                // propagate readonly state from source component to popup

Also available in: Unified diff