Project

General

Profile

Revision b0339f85

IDb0339f856e66f874b01c21de32136ebde2955482
Parent 3f010594
Child d0237f32

Added by Andreas Kohlbecker almost 2 years ago

ref #7995 invoking Registration.updateStatusAndDate() from RegistrationEditorPresenter

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationEditorPresenter.java
9 9
package eu.etaxonomy.cdm.vaadin.view.registration;
10 10

  
11 11
import java.util.Arrays;
12
import java.util.Date;
12 13
import java.util.List;
13 14
import java.util.UUID;
14 15

  
......
20 21
import eu.etaxonomy.cdm.model.agent.Institution;
21 22
import eu.etaxonomy.cdm.model.common.User;
22 23
import eu.etaxonomy.cdm.model.name.Registration;
24
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
23 25
import eu.etaxonomy.cdm.service.UserHelperAccess;
24 26
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
27
import eu.etaxonomy.cdm.vaadin.util.converter.JodaDateTimeConverter;
25 28
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
29
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
26 30
import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
27 31

  
28 32
/**
......
35 39
public class RegistrationEditorPresenter extends AbstractCdmEditorPresenter<Registration, RegistrationPopEditorView> {
36 40

  
37 41
    private static final long serialVersionUID = 6930557602995331944L;
42
    private RegistrationStatus lastStatus;
38 43

  
39 44
    /**
40 45
     * {@inheritDoc}
......
75 80
        return reg;
76 81
    }
77 82

  
83

  
84

  
78 85
    /**
79 86
     * {@inheritDoc}
80 87
     */
......
110 117

  
111 118
        getView().getSubmitterField().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(User.class));
112 119
        getView().getSubmitterField().setItemCaptionPropertyId("username");
120

  
121

  
122
    }
123

  
124
    @Override
125
    protected void adaptDataProviders() {
126
        getView().getStatusSelect().addValueChangeListener( e -> updateRegStatus((RegistrationStatus) e.getProperty().getValue()) );
127
    }
128

  
129
    private void updateRegStatus(RegistrationStatus status){
130
        Registration reg = ((AbstractPopupEditor<Registration, RegistrationEditorPresenter>)getView()).getBean();
131
        if(lastStatus != null){
132
            // set last status again to allow updateStatusAndDate() to the job
133
            reg.setStatus(lastStatus);
134
        }
135
        reg.updateStatusAndDate(status);
136
        lastStatus = status;
137
        JodaDateTimeConverter converter = new JodaDateTimeConverter();
138
        getView().getRegistrationDateField().setValue(converter.convertToPresentation(reg.getRegistrationDate(), Date.class, null));
113 139
    }
114 140

  
115 141

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

  
11
import com.vaadin.ui.DateField;
11 12
import com.vaadin.ui.ListSelect;
12 13

  
13 14
import eu.etaxonomy.vaadin.mvp.ApplicationView;
......
34 35
     * @return
35 36
     */
36 37
    public ListSelect getStatusSelect();
38

  
39
    /**
40
     * @return
41
     */
42
    public DateField getRegistrationDateField();
37 43
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationPopupEditor.java
46 46

  
47 47
    private ListSelect statusSelect;
48 48

  
49
    private DateField registrationDateField;
50

  
49 51
    public RegistrationPopupEditor() {
50 52
        super(new FormLayout(), Registration.class);
51 53
    }
......
69 71
        statusSelect = new ListSelect("Status", Arrays.asList(RegistrationStatus.values()));
70 72
        statusSelect.setNullSelectionAllowed(false);
71 73
        statusSelect.setRows(1);
72
        statusSelect.addValueChangeListener( e -> getBean().updateStatusAndDate((RegistrationStatus) e.getProperty().getValue()));
73 74
        addField(statusSelect, "status");
74 75

  
75 76
        submitterField = new ListSelect("Submitter");
......
82 83
        institutionField.setWidth(100, Unit.PERCENTAGE);
83 84
        addField(institutionField, "institution");
84 85

  
85
        DateField registrationDateField = new DateField("Registration date");
86
        registrationDateField = new DateField("Registration date");
86 87
        addField(registrationDateField, "registrationDate");
87 88
        registrationDateField.setConverter(new JodaDateTimeConverter());
88 89

  
......
138 139
    public ListSelect getStatusSelect() {
139 140
        return statusSelect;
140 141
    }
142

  
143
    @Override
144
    public DateField getRegistrationDateField() {
145
        return this.registrationDateField;
146
    }
141 147
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)