Project

General

Profile

Revision 85743e03

ID85743e03023024ec6a9d0449fa91aa6bc08f5f6e
Parent bcf6a056
Child 8626f584

Added by Andreas Kohlbecker over 1 year ago

fix #7624 notes field for the RegistrationPopupEditor implemented

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.reference;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.Arrays;
12 13
import java.util.List;
13 14
import java.util.UUID;
......
23 24
import eu.etaxonomy.cdm.model.agent.AgentBase;
24 25
import eu.etaxonomy.cdm.model.agent.Person;
25 26
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
27
import eu.etaxonomy.cdm.model.common.Annotation;
28
import eu.etaxonomy.cdm.model.common.AnnotationType;
26 29
import eu.etaxonomy.cdm.model.reference.Reference;
27 30
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
28 31
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
29 32
import eu.etaxonomy.cdm.service.UserHelperAccess;
33
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
30 34
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
31 35
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
32 36
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
......
70 74

  
71 75
        });
72 76

  
77
        CdmBeanItemContainerFactory selectFieldFactory = new CdmBeanItemContainerFactory(getRepo());
73 78
        CdmFilterablePagingProvider<Reference, Reference> collectionPagingProvider = pagingProviderFactory.referencePagingProvider();
74 79
        getView().getInReferenceCombobox().loadFrom(collectionPagingProvider, collectionPagingProvider, collectionPagingProvider.getPageSize());
75 80
        getView().getInReferenceCombobox().setNestedButtonStateUpdater(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getInReferenceCombobox()));
......
79 84
        CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = new CdmFilterablePagingProvider<AgentBase, Person>(getRepo().getAgentService(), Person.class);
80 85
        getView().getAuthorshipField().setFilterableTeamPagingProvider(teamOrPersonPagingProvider, this);
81 86
        getView().getAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
87

  
88
        getView().getAnnotationsField().setAnnotationTypeItemContainer(selectFieldFactory.buildTermItemContainer(
89
                AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid()));
82 90
    }
83 91

  
84 92
    /**
......
89 97

  
90 98
        List<String> initStrategy = Arrays.asList(new String []{
91 99

  
92
                "$"
100
                "$",
101
                "annotations.*", // needed as log as we are using a table in FilterableAnnotationsField
93 102
                }
94 103
        );
95 104

  
......
185 194
    }
186 195

  
187 196

  
197
    /**
198
     * {@inheritDoc}
199
     */
200
    @Override
201
    protected Reference preSaveBean(Reference bean) {
202

  
203
        // handle annotation changes
204
        List<Annotation> annotations = getView().getAnnotationsField().getValue();
205
        List<Annotation> currentAnnotations = new ArrayList<>(bean.getAnnotations());
206
        List<Annotation> annotationsSeen = new ArrayList<>();
207
        for(Annotation a : annotations){
208
            if(a == null){
209
                continue;
210
            }
211
            if(!currentAnnotations.contains(a)){
212
                bean.addAnnotation(a);
213
            }
214
            annotationsSeen.add(a);
215
        }
216
        for(Annotation a : currentAnnotations){
217
            if(!annotationsSeen.contains(a)){
218
                bean.removeAnnotation(a);
219
            }
220
        }
221

  
222

  
223
        return bean;
224
    }
225

  
226

  
227

  
188 228

  
189 229
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java
28 28
import com.vaadin.ui.ListSelect;
29 29
import com.vaadin.ui.TextField;
30 30

  
31
import eu.etaxonomy.cdm.model.common.AnnotationType;
31 32
import eu.etaxonomy.cdm.model.reference.Reference;
32 33
import eu.etaxonomy.cdm.model.reference.ReferencePropertyDefinitions;
33 34
import eu.etaxonomy.cdm.model.reference.ReferencePropertyDefinitions.UnimplemetedCaseException;
34 35
import eu.etaxonomy.cdm.model.reference.ReferenceType;
35 36
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix;
37
import eu.etaxonomy.cdm.vaadin.component.common.FilterableAnnotationsField;
36 38
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
37 39
import eu.etaxonomy.cdm.vaadin.component.common.VerbatimTimePeriodField;
38 40
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
39 41
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
42
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
40 43
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator;
41 44
import eu.etaxonomy.cdm.vaadin.util.converter.DoiConverter;
42 45
import eu.etaxonomy.cdm.vaadin.util.converter.UriConverter;
......
63 66

  
64 67
    private final static int GRID_COLS = 4; // 12 would fits for 2,3, and 4 Components per row
65 68

  
66
    private final static int GRID_ROWS = 10;
69
    private final static int GRID_ROWS = 11;
67 70

  
68 71
    private ListSelect typeSelect;
69 72

  
......
71 74

  
72 75
    private TeamOrPersonField authorshipField;
73 76

  
77
    private FilterableAnnotationsField annotationsListField;
78

  
79
    private AnnotationType[] editableAnotationTypes = RegistrationUIDefaults.EDITABLE_ANOTATION_TYPES;
80

  
74 81
    private EnumSet<ReferenceType> referenceTypes = EnumSet.allOf(ReferenceType.class);
75 82

  
76 83
    private static Map<String,String> propertyNameLabelMap = new HashMap<>();
......
209 216

  
210 217
        variableGridLastRow = row;
211 218

  
219
        row++;
220
        annotationsListField = new FilterableAnnotationsField("Editorial notes");
221
        annotationsListField.setWidth(100, Unit.PERCENTAGE);
222
        annotationsListField.setAnnotationTypesVisible(editableAnotationTypes);
223
        addField(annotationsListField, "annotations", 0, row, GRID_COLS-1, row);
224

  
225

  
212 226
//        titleField.setRequired(true);
213 227
//        publisherField.setRequired(true);
214 228

  
......
327 341
    }
328 342

  
329 343
    /**
330
     * {@inheritDoc}
344
     * {@inheritDoc}            // TODO Auto-generated method stub
331 345
     */
332 346
    @Override
333 347
    public void focusFirst() {
......
379 393
        return authorshipField;
380 394
    }
381 395

  
396
    @Override
397
    public FilterableAnnotationsField getAnnotationsField() {
398
        return annotationsListField;
399
    }
400

  
382 401
    public void withReferenceTypes(EnumSet<ReferenceType> types){
383 402
        this.referenceTypes = types;
384 403
        if(typeSelect != null){
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditorView.java
11 11
import com.vaadin.ui.ListSelect;
12 12

  
13 13
import eu.etaxonomy.cdm.model.reference.Reference;
14
import eu.etaxonomy.cdm.vaadin.component.common.FilterableAnnotationsField;
14 15
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
15 16
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
16 17
import eu.etaxonomy.vaadin.mvp.ApplicationView;
......
28 29

  
29 30
    public TeamOrPersonField getAuthorshipField();
30 31

  
32
    /**
33
     * @return
34
     */
35
    FilterableAnnotationsField getAnnotationsField();
36

  
31 37

  
32 38
}
src/test/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterTest.java
20 20

  
21 21
import eu.etaxonomy.cdm.api.application.CdmRepository;
22 22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.vaadin.component.common.FilterableAnnotationsField;
23 24
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
24 25
import eu.etaxonomy.cdm.vaadin.view.reference.ReferenceEditorPresenter;
25 26
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditorView;
......
82 83
            return null;
83 84
        }
84 85

  
86
        /**
87
         * {@inheritDoc}
88
         */
89
        @Override
90
        public FilterableAnnotationsField getAnnotationsField() {
91
            return null;
92
        }
93

  
85 94

  
86 95

  
87 96
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)