Project

General

Profile

Revision 2e814df1

ID2e814df11215efb681b5b5e67ffdd044271bde25
Parent 782f192b
Child cf8c950b

Added by Andreas Kohlbecker almost 2 years ago

ref #7458 implementation of the note field for the NameTypeEditor

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationEditorView.java
12 12

  
13 13
import eu.etaxonomy.cdm.model.name.TaxonName;
14 14
import eu.etaxonomy.cdm.model.reference.Reference;
15
import eu.etaxonomy.cdm.vaadin.view.AnnotationsEditor;
15 16
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect;
16 17
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
17 18
import eu.etaxonomy.vaadin.mvp.ApplicationView;
......
21 22
 * @since Jan 26, 2018
22 23
 *
23 24
 */
24
public interface NameTypeDesignationEditorView extends ApplicationView<NameTypeDesignationPresenter> {
25
public interface NameTypeDesignationEditorView extends ApplicationView<NameTypeDesignationPresenter>, AnnotationsEditor  {
25 26

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

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPopupEditor.java
17 17
import com.vaadin.ui.ListSelect;
18 18
import com.vaadin.ui.TextField;
19 19

  
20
import eu.etaxonomy.cdm.model.common.AnnotationType;
20 21
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
21 22
import eu.etaxonomy.cdm.model.name.TaxonName;
22 23
import eu.etaxonomy.cdm.model.reference.Reference;
24
import eu.etaxonomy.cdm.vaadin.component.common.FilterableAnnotationsField;
23 25
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
24 26
import eu.etaxonomy.cdm.vaadin.permission.CdmEditDeletePermissionTester;
27
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
25 28
import eu.etaxonomy.cdm.vaadin.util.converter.SetToListConverter;
26 29
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect;
27 30
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
......
39 42
    implements NameTypeDesignationEditorView {
40 43

  
41 44
    private static final int GRID_COLS = 4;
42
    private static final int GRID_ROWS = 6;
45
    private static final int GRID_ROWS = 7;
43 46

  
44 47
    private CheckBox conservedTypeField;
45 48
    private CheckBox rejectedTypeField;
......
58 61
    private boolean showTypeFlags = true;
59 62

  
60 63

  
64
    private FilterableAnnotationsField annotationsListField;
65

  
66
    private AnnotationType[] editableAnotationTypes = RegistrationUIDefaults.EDITABLE_ANOTATION_TYPES;
67

  
68

  
61 69
    /**
62 70
     * @param layout
63 71
     * @param dtoType
......
169 177
        addField(citationCombobox, "citation", 0, row, 2, row);
170 178
        citationCombobox.setWidth(400, Unit.PIXELS);
171 179
        citationDetailField = addTextField("Citation detail", "citationMicroReference", 3, row);
180

  
181
        row++;
182
        annotationsListField = new FilterableAnnotationsField("Editorial notes");
183
        annotationsListField.setWidth(100, Unit.PERCENTAGE);
184
        annotationsListField.setAnnotationTypesVisible(editableAnotationTypes);
185
        addField(annotationsListField, "annotations", 0, row, 3, row);
172 186
    }
173 187

  
174 188
    /**
......
219 233
    public void setShowTypeFlags(boolean showTypeFlags) {
220 234
        this.showTypeFlags = showTypeFlags;
221 235
    }
236

  
237
    /**
238
     * {@inheritDoc}
239
     */
240
    @Override
241
    public AnnotationType[] getEditableAnotationTypes() {
242
        return editableAnotationTypes;
243
    }
244

  
245
    /**
246
     * {@inheritDoc}
247
     */
248
    @Override
249
    public void setEditableAnotationTypes(AnnotationType... editableAnotationTypes) {
250
        this.editableAnotationTypes = editableAnotationTypes;
251
    }
252

  
253
    /**
254
     * {@inheritDoc}
255
     */
256
    @Override
257
    public FilterableAnnotationsField getAnnotationsField() {
258
        return annotationsListField;
259
    }
222 260
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.name;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.Arrays;
12 13
import java.util.EnumSet;
13 14
import java.util.HashSet;
......
24 25
import eu.etaxonomy.cdm.api.service.IService;
25 26
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
26 27
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSet;
28
import eu.etaxonomy.cdm.model.common.Annotation;
27 29
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
28 30
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
29 31
import eu.etaxonomy.cdm.model.name.TaxonName;
......
99 101
    protected NameTypeDesignation loadCdmEntity(UUID uuid) {
100 102
        List<String> initStrategy = Arrays.asList(new String []{
101 103
                "$",
104
                "annotations.*", // * is needed as log as we are using a table in FilterableAnnotationsField
102 105
                "typifiedNames.typeDesignations", // important !!
103 106
                "typeName.$",
104 107
                "citation.authorship.$",
......
218 221
            // FIXME do we need to save the names here or is the delete cascaded from the typedesignation to the name?
219 222
        }
220 223

  
224
        // handle annotation changes
225
        List<Annotation> annotations = getView().getAnnotationsField().getValue();
226
        List<Annotation> currentAnnotations = new ArrayList<>(bean.getAnnotations());
227
        List<Annotation> annotationsSeen = new ArrayList<>();
228
        for(Annotation a : annotations){
229
            if(a == null){
230
                continue;
231
            }
232
            if(!currentAnnotations.contains(a)){
233
                bean.addAnnotation(a);
234
            }
235
            annotationsSeen.add(a);
236
        }
237
        for(Annotation a : currentAnnotations){
238
            if(!annotationsSeen.contains(a)){
239
                bean.removeAnnotation(a);
240
            }
241
        }
242

  
243

  
221 244
        return bean;
222 245
    }
223 246

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)