Project

General

Profile

« Previous | Next » 

Revision b3e242fe

Added by Andreas Kohlbecker almost 7 years ago

fix #6810 View for starting new registrations implemented

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmStore.java
200 200

  
201 201
        logger.trace(this._toString() + ".onEditorSaveEvent - merging bean into session");
202 202
        // merge the changes into the session, ...
203
        T mergedBean = mergedBean(bean);
203
        //T mergedBean = mergedBean(bean);
204
        T mergedBean = bean;
204 205
        repo.getCommonService().saveOrUpdate(mergedBean);
205 206
        session.flush();
206 207
        commitTransction();
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
190 190
        } else {
191 191
            referenceEditorAction = new ReferenceEditorAction(Action.ADD);
192 192
        }
193
        TimePeriod datePublished = workingSet.getRegistrationDTOs().get(0).getDatePublished();
193
        TimePeriod datePublished = null;
194
        String submitterName = null;
195
        if(workingSet.getRegistrationDTOs().size() > 0){
196
            datePublished = workingSet.getRegistrationDTOs().get(0).getDatePublished();
197
            submitterName = workingSet.getRegistrationDTOs().get(0).getSubmitterUserName();
198
        }
194 199
        updateUI(workingSet.getCitation(), workingSet.getCreated(), datePublished, workingSet.messagesCount(),
195
                referenceEditorAction, FontAwesome.EDIT, null, workingSet.getRegistrationDTOs().get(0).getSubmitterUserName());
200
                referenceEditorAction, FontAwesome.EDIT, null, submitterName);
196 201
    }
197 202

  
198 203
    /**
......
264 269

  
265 270

  
266 271
    private void updateDateLabels(DateTime created, TimePeriod datePublished, DateTime released) {
267
        getCreatedLabel().setValue("<span class=\"caption\">" + LABEL_CAPTION_CREATED + "</span>&nbsp;" + created.toString(ISODateTimeFormat.yearMonthDay()));
272
        if(created != null){
273
            getCreatedLabel().setValue("<span class=\"caption\">" + LABEL_CAPTION_CREATED + "</span>&nbsp;" + created.toString(ISODateTimeFormat.yearMonthDay()));
274
        }
268 275
        if(datePublished != null){
269 276
            getPublishedLabel().setVisible(true);
270 277
            getPublishedLabel().setValue("<span class=\"caption\">" + LABEL_CAPTION_PUBLISHED + "</span>&nbsp;" + timePeriodFormatter.print(datePublished));
src/main/java/eu/etaxonomy/cdm/vaadin/design/registration/StartRegistrationDesign.java
1
package eu.etaxonomy.cdm.vaadin.design.registration;
2

  
3
import com.vaadin.annotations.AutoGenerated;
4
import com.vaadin.annotations.DesignRoot;
5
import com.vaadin.ui.Button;
6
import com.vaadin.ui.CssLayout;
7
import com.vaadin.ui.VerticalLayout;
8
import com.vaadin.ui.declarative.Design;
9

  
10
/** 
11
 * !! DO NOT EDIT THIS FILE !!
12
 * 
13
 * This class is generated by Vaadin Designer and will be overwritten.
14
 * 
15
 * Please make a subclass with logic and additional interfaces as needed,
16
 * e.g class LoginView extends LoginDesign implements View { }
17
 */
18
@DesignRoot
19
@AutoGenerated
20
@SuppressWarnings("serial")
21
public class StartRegistrationDesign extends VerticalLayout {
22
    protected CssLayout dashboard;
23
    protected Button buttonName;
24
    protected Button buttonTypification;
25

  
26
    public StartRegistrationDesign() {
27
        Design.read(this);
28
    }
29
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/registration/RegistrationWorkflowEvent.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.event.registration;
10 10

  
11
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationType;
12

  
13 11
/**
14 12
 * @author a.kohlbecker
15 13
 * @since Mar 3, 2017
......
17 15
 */
18 16
public class RegistrationWorkflowEvent {
19 17

  
20
    private RegistrationType type = null;
21 18
    private Action action;
22 19
    private Integer citationID = null;
23 20

  
......
26 23
     * @param citationID the id of a {@link Reference} denoting a
27 24
     * complete registration working set.
28 25
     */
29
    public RegistrationWorkflowEvent(int citationID){
30
        this.action = Action.open;
26
    public RegistrationWorkflowEvent(int citationID, Action action){
27
        this.action = action;
31 28
        this.citationID = citationID;
32 29
    }
33 30

  
34
    public RegistrationWorkflowEvent(RegistrationType type){
35
        this.type = type;
36
        this.action = Action.start;
37
    }
38

  
39
    /**
40
     * @return the type
41
     */
42
    public RegistrationType getType() {
43
        return type;
44
    }
45

  
46 31
    /**
47 32
     * @return the action
48 33
     */
......
62 47
    }
63 48

  
64 49

  
65
    enum Action {
50
    public enum Action {
66 51
        start, open;
67 52
    }
68 53

  
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/RegistrationWorkingSet.java
17 17

  
18 18
import eu.etaxonomy.cdm.model.name.Registration;
19 19
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
20
import eu.etaxonomy.cdm.model.reference.Reference;
20 21
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO;
21 22
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationValidationException;
22 23

  
......
38 39
    /**
39 40
     * Creates an empty working set
40 41
     */
41
    public RegistrationWorkingSet() {
42
    public RegistrationWorkingSet(Reference citation) {
43
        citationId = citation.getId();
44
        this.citation= citation.getTitleCache();
42 45

  
43 46
    }
44 47

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
55 55

  
56 56
    private static final long serialVersionUID = 4255636253714476918L;
57 57

  
58
    CdmStore<Registration, IRegistrationService> store ;
58
    CdmStore<Registration, IRegistrationService> store;
59 59

  
60 60
    protected CdmStore<Registration, IRegistrationService> getStore() {
61 61
        if(store == null){
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/DashBoardView.java
36 36

  
37 37
    public DashBoardView() {
38 38
        Responsive.makeResponsive(dashboard);
39
        buttonNew.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(StartRegistrationView.NAME)));
39
        buttonNew.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(StartRegistrationViewBean.NAME)));
40 40
        buttonContinue.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(ListViewBean.NAME + "/" + ListViewBean.OPTION_IN_PROGRESS)));
41 41
        buttonList.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(ListViewBean.NAME + "/" + ListViewBean.OPTION_ALL)));
42 42
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java
221 221
        return citation;
222 222
    }
223 223

  
224
    public void setCitation(IReference citation) throws Exception {
225
        if(this.citation == null){
226
            this.citation = citation;
227
        } else {
228
            throw new Exception("Can not set the citation on a non emtpy RegistrationDTO");
229
        }
230
    }
231

  
224 232
    /**
225 233
     * @return the citationID
226 234
     */
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowPresenter.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.view.registration;
10 10

  
11
import java.io.Serializable;
12 11
import java.util.ArrayList;
13 12
import java.util.List;
14 13

  
15
import org.apache.log4j.Logger;
16 14
import org.springframework.beans.factory.annotation.Autowired;
17 15
import org.springframework.context.event.EventListener;
18 16

  
......
20 18
import com.vaadin.spring.annotation.SpringComponent;
21 19
import com.vaadin.spring.annotation.ViewScope;
22 20

  
23
import eu.etaxonomy.cdm.model.name.Rank;
24 21
import eu.etaxonomy.cdm.model.name.Registration;
25 22
import eu.etaxonomy.cdm.model.name.TaxonName;
26
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
27 23
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
28 24
import eu.etaxonomy.cdm.model.reference.Reference;
29 25
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService;
......
33 29
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
34 30
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
35 31
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
36
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
37 32
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
38 33
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType;
39 34
import eu.etaxonomy.cdm.vaadin.view.name.RegistrationAndWorkingsetId;
40 35
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor;
41 36
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor;
42 37
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
38
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationWorkflowViewBean.ViewParameters;
43 39
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
44 40

  
45 41
/**
......
49 45
 */
50 46
@SpringComponent
51 47
@ViewScope
52
public class RegistrationWorkflowPresenter extends AbstractPresenter<RegistrationWorkflowView> implements Serializable{
48
public class RegistrationWorkflowPresenter extends AbstractPresenter<RegistrationWorkflowView> {
53 49

  
54 50
    private static final long serialVersionUID = 1L;
55 51

  
......
66 62

  
67 63
    private RegistrationWorkingSet workingset;
68 64

  
65
    private Reference citation;
66

  
69 67

  
70 68
    /**
71 69
     *
......
73 71
    public RegistrationWorkflowPresenter() {
74 72
    }
75 73

  
76
    @EventListener
77
    protected void onRegistrationStartEvent(RegistrationWorkflowEvent event){
78 74

  
79
        boolean HACK = true;
80
        if(workingset != null && !HACK){
81
            Logger.getLogger(RegistrationWorkflowPresenter.class).warn("Can't start a new workflow over an existing one.");
82
            return;
83
        }
84 75

  
85
        if(event.isStart()) {
86
            workingset = new RegistrationWorkingSet();
87
            Registration reg = Registration.NewInstance();
88
            reg.setName(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()));
89
            getView().setHeaderText("New Registration");
90
            try {
91
                workingset.add(reg);
92
            } catch (RegistrationValidationException error) {
93
                getView().getWorkflow().setComponentError(new SystemError(error));
94
            }
76
    /**
77
     * {@inheritDoc}
78
     */
79
    @Override
80
    public void handleViewEntered() {
81

  
82
        super.handleViewEntered();
83
        ViewParameters viewParams = getView().getViewParameters();
84
        if(viewParams.action.equals(RegistrationWorkflowView.ACTION_NEW)){
85
            citation = getRepo().getReferenceService().find(viewParams.referenceId);
86
            workingset = new RegistrationWorkingSet(citation);
87
            getView().setHeaderText("Registration for " + workingset.getCitation());
95 88
            getView().setWorkingset(workingset);
96
        } else {
97
            Integer citationID = event.getCitationID();
98
            presentWorkingSetByRegID(citationID);
99 89
        }
100

  
90
        if(viewParams.action.equals(RegistrationWorkflowView.ACTION_EDIT)){
91
            presentWorkingSetByRegID(viewParams.referenceId);
92
        }
101 93
    }
102 94

  
103 95
    /**
......
206 198

  
207 199
    @EventListener
208 200
    public void onEntityChangeEvent(EntityChangeEvent event){
201
        if(workingset == null){
202
            return;
203
        }
209 204
        if(Reference.class.isAssignableFrom(event.getEntityType())){
210 205
            if(workingset.getCitationId().equals(event.getEntityId())){
211 206
                refreshView();
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowView.java
14 14
import com.vaadin.ui.CssLayout;
15 15

  
16 16
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
17
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationWorkflowViewBean.ViewParameters;
17 18
import eu.etaxonomy.vaadin.mvp.ApplicationView;
18 19

  
19 20
/**
......
23 24
 */
24 25
public interface RegistrationWorkflowView extends ApplicationView{
25 26

  
27
    public static final String ACTION_NEW = "new";
28

  
29
    public static final String ACTION_EDIT = "edit";
30

  
26 31

  
27 32
    CssLayout getWorkflow();
28 33

  
......
66 71
    void openDetailsPopup(String caption, List<String> messages);
67 72

  
68 73

  
74
    ViewParameters getViewParameters();
75

  
76

  
69 77

  
70 78
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
49 49
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
50 50
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
51 51
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
52
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
53 52
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
54 53
import eu.etaxonomy.cdm.vaadin.model.registration.WorkflowStep;
55 54
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
......
77 76

  
78 77
    public static final String NAME = "workflow";
79 78

  
80
    public static final String ACTION_NEW = "new";
81

  
82
    public static final String ACTION_EDIT = "edit";
83

  
84 79
    private static final boolean REG_ITEM_AS_BUTTON_GROUP = true;
85 80

  
86 81
    public RegistrationType regType = null;
......
94 89

  
95 90
    private boolean addNameAndTypeEditButtons = false;
96 91

  
92
    private ViewParameters viewParameters;
93

  
94

  
95
    /**
96
     * @return the viewParameters
97
     */
98
    @Override
99
    public ViewParameters getViewParameters() {
100
        return viewParameters;
101
    }
97 102

  
98 103
    public RegistrationWorkflowViewBean() {
99 104
        super();
......
113 118
    @Override
114 119
    public void enter(ViewChangeEvent event) {
115 120
        if(event.getParameters() != null){
116
           String[] params = event.getParameters().split("/");
117

  
118
           if(params[0].equals(ACTION_NEW)) {
119
               regType = RegistrationType.valueOf(params[1]);
120
               headerText = regType.name() + " ...";
121
               eventBus.publishEvent(new RegistrationWorkflowEvent(regType));
122

  
123
           } else if( params[0].equals(ACTION_EDIT)) {
124
               headerText = params[1];
125
               eventBus.publishEvent(new RegistrationWorkflowEvent(Integer.parseInt(params[1])));
126
           }
127
           updateHeader();
121
            this.viewParameters = new ViewParameters(event.getParameters().split("/"));
122

  
123
            getPresenter().handleViewEntered();
128 124
        }
129 125
    }
130 126

  
......
202 198
     */
203 199
    public Panel createRegistrationsList(RegistrationWorkingSet workingset) {
204 200
        // prepare name and type list
205
        GridLayout namesTypesList = new GridLayout(3, workingset.getRegistrationDTOs().size());
201
        GridLayout namesTypesList = new GridLayout(3, workingset.getRegistrationDTOs().size() + 1);
206 202
        int row = 0;
207 203
        for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
208 204
            registrationListComponent(namesTypesList, row++, dto);
......
448 444
    @Override
449 445
    public void setHeaderText(String text) {
450 446
        this.headerText = text;
447
        updateHeader();
451 448

  
452 449
    }
453 450

  
......
464 461
    @Override
465 462
    public void setSubheaderText(String text) {
466 463
        subheaderText = text;
464
        updateHeader();
467 465
    }
468 466

  
469 467
    /**
......
510 508
        return null;
511 509
    }
512 510

  
511
    protected class ViewParameters {
512

  
513
        String action;
514
        Integer referenceId;
515

  
516
        public ViewParameters(String[] params){
517
            action = params[0];
518
            referenceId = Integer.parseInt(params[1]);
519
        }
520
    }
521

  
513 522
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.view.registration;
10

  
11
import org.springframework.context.event.EventListener;
12
import org.vaadin.viritin.fields.LazyComboBox;
13

  
14
import com.vaadin.server.SystemError;
15
import com.vaadin.server.UserError;
16
import com.vaadin.spring.annotation.SpringComponent;
17
import com.vaadin.spring.annotation.ViewScope;
18

  
19
import eu.etaxonomy.cdm.api.service.DeleteResult;
20
import eu.etaxonomy.cdm.model.reference.Reference;
21
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
22
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
23
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
24
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
25
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
26
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter;
27
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
28
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent;
29
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason;
30

  
31
/**
32
 * @author a.kohlbecker
33
 * @since Jul 11, 2017
34
 *
35
 */
36
@SpringComponent
37
@ViewScope
38
public class StartRegistrationPresenter extends AbstractEditorPresenter<RegistrationDTO, StartRegistrationView> {
39

  
40
    private static final long serialVersionUID = 2283189121081612574L;
41

  
42
    private ReferencePopupEditor newReferencePopup;
43

  
44
    private Reference newReference;
45

  
46
    private boolean registrationInProgress;
47

  
48
    public StartRegistrationPresenter (){
49
        super();
50
    }
51

  
52
    /**
53
     * {@inheritDoc}
54
     */
55
    @Override
56
    public void onPresenterReady() {
57

  
58
        super.onPresenterReady();
59

  
60
        CdmFilterablePagingProvider<Reference> pagingProvider = new CdmFilterablePagingProvider<Reference>(
61
                getRepo().getReferenceService(), this);
62
        CdmTitleCacheCaptionGenerator<Reference> titleCacheGenrator = new CdmTitleCacheCaptionGenerator<Reference>();
63
        getView().getReferenceCombobox().setCaptionGenerator(titleCacheGenrator);
64
        getView().getReferenceCombobox().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
65
    }
66

  
67
    /**
68
     * {@inheritDoc}
69
     */
70
    @Override
71
    public void handleViewExit() {
72
        if(!registrationInProgress && newReference != null){
73
            logger.info("Deleting newly created Reference due to canceled registration");
74
            getRepo().getReferenceService().delete(newReference);
75
        }
76
        super.handleViewExit();
77
    }
78

  
79
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
80
    public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
81

  
82
        if(getView().getNewPublicationButton() != event.getSourceComponent()){
83
            return;
84
        }
85
        newReferencePopup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
86

  
87
        newReferencePopup.withDeleteButton(true);
88
        newReferencePopup.loadInEditor(null);
89
    }
90

  
91
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).REMOVE")
92
    public void onReferenceEditorActionRemove(ReferenceEditorAction event) {
93

  
94
        if(getView().getRemoveNewPublicationButton() != event.getSourceComponent()){
95
            return;
96
        }
97
        DeleteResult result = getRepo().getReferenceService().delete(newReference);
98
        if(!result.isOk()){
99
            String message = "";
100
            for(Exception e : result.getExceptions()){
101
                message += e.getMessage() + "\n" + e.getStackTrace().toString() + "\n";
102
            }
103
            getView().getRemoveNewPublicationButton().setComponentError(new SystemError(message));
104
        }
105

  
106
        getView().getReferenceCombobox().setEnabled(false);
107

  
108
        getView().getRemoveNewPublicationButton().setVisible(false);
109

  
110
        getView().getNewPublicationButton().setVisible(true);
111
        getView().getNewPublicationLabel().setCaption(null);
112
        getView().getNewPublicationLabel().setVisible(false);
113
    }
114

  
115
    @EventListener
116
    public void onDoneWithPopupEvent(DoneWithPopupEvent event){
117
        if(event.getPopup() == newReferencePopup){
118
            if(event.getReason() == Reason.SAVE){
119

  
120
                newReference = newReferencePopup.getBean();
121

  
122
                getView().getReferenceCombobox().setValue(null);  // deselect
123
                getView().getReferenceCombobox().setEnabled(false);
124

  
125
                getView().getContinueButton().setEnabled(true);
126

  
127
                getView().getNewPublicationButton().setVisible(false);
128

  
129
                getView().getRemoveNewPublicationButton().setVisible(true);
130
                getView().getNewPublicationLabel().setCaption(newReference.getTitleCache());
131
                getView().getNewPublicationLabel().setVisible(true);
132
            }
133

  
134
            newReferencePopup = null;
135
        }
136
    }
137

  
138
    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
139
    public void onRegistrationEditorActionAdd(RegistrationEditorAction event) {
140

  
141
        if(getView().getContinueButton().equals(event.getSourceComponent())){
142
            return;
143
        }
144
        Integer referenceId = null;
145
        LazyComboBox<Reference> referenceCombobox = getView().getReferenceCombobox();
146
        referenceCombobox.commit();
147
        if(newReference != null){
148
            referenceId = newReference.getId();
149
       // } else if(referenceCombobox.getValue() != null) {
150
        } else if ( event.getEntityId() != null) { // HACKED, see view implementation
151
            referenceId = event.getEntityId();
152
        }
153
        if(referenceId == null){
154
            getView().getContinueButton().setComponentError(new UserError("Can't continue. No Reference is chosen."));
155
            getView().getContinueButton().setEnabled(false);
156
        }
157
        registrationInProgress = true;
158
        eventBus.publishEvent(new NavigationEvent(RegistrationWorkflowViewBean.NAME, "new", Integer.toString(referenceId)));
159

  
160
    }
161

  
162
    /**
163
     * {@inheritDoc}
164
     */
165
    @Override
166
    protected RegistrationDTO loadBeanById(Object identifier) {
167
        // not needed //
168
        return null;
169
    }
170

  
171
    /**
172
     * {@inheritDoc}
173
     */
174
    @Override
175
    protected void saveBean(RegistrationDTO bean) {
176
        // TODO Auto-generated method stub
177

  
178
    }
179

  
180
    /**
181
     * {@inheritDoc}
182
     */
183
    @Override
184
    protected void deleteBean(RegistrationDTO bean) {
185
        // TODO Auto-generated method stub
186

  
187
    }
188

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

  
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.context.ApplicationEventPublisher;
11
import org.vaadin.viritin.fields.LazyComboBox;
13 12

  
14
import com.vaadin.navigator.View;
15
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
16
import com.vaadin.spring.annotation.SpringView;
13
import com.vaadin.ui.Button;
14
import com.vaadin.ui.Label;
17 15

  
18
import eu.etaxonomy.cdm.vaadin.design.registration.StartRegistrationDesign;
19
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
16
import eu.etaxonomy.cdm.model.reference.Reference;
17
import eu.etaxonomy.vaadin.mvp.ApplicationView;
20 18

  
21 19
/**
22 20
 * @author a.kohlbecker
23 21
 * @since Mar 2, 2017
24 22
 *
25 23
 */
26
@SpringView(name=StartRegistrationView.NAME)
27
public class StartRegistrationView extends StartRegistrationDesign implements View {
24
public interface StartRegistrationView extends ApplicationView<StartRegistrationPresenter>  {
28 25

  
29
    private static final long serialVersionUID = -213040114015958970L;
26
    Button getNewPublicationButton();
30 27

  
31
    public static final String NAME = "regStart";
28
    LazyComboBox<Reference> getReferenceCombobox();
32 29

  
33
    @Autowired
34
    ApplicationEventPublisher eventBus;
35

  
36
    public StartRegistrationView() {
37
        buttonName.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(
38
                RegistrationWorkflowViewBean.NAME,
39
                RegistrationWorkflowViewBean.ACTION_NEW,
40
                RegistrationType.NAME.name()
41
                )));
42
    }
30
    /**
31
     * @return
32
     */
33
    Button getRemoveNewPublicationButton();
43 34

  
44 35
    /**
45
     * {@inheritDoc}
36
     * @return
46 37
     */
47
    @Override
48
    public void enter(ViewChangeEvent event) {
38
    Button getContinueButton();
39

  
40
    Label getNewPublicationLabel();
41

  
49 42

  
50
    }
51 43

  
52 44
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationViewBean.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.view.registration;
10

  
11
import java.util.Collection;
12

  
13
import org.springframework.security.core.GrantedAuthority;
14
import org.vaadin.viritin.fields.LazyComboBox;
15

  
16
import com.vaadin.navigator.View;
17
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
18
import com.vaadin.spring.annotation.SpringView;
19
import com.vaadin.ui.Alignment;
20
import com.vaadin.ui.Button;
21
import com.vaadin.ui.CssLayout;
22
import com.vaadin.ui.HorizontalLayout;
23
import com.vaadin.ui.Label;
24
import com.vaadin.ui.VerticalLayout;
25
import com.vaadin.ui.themes.ValoTheme;
26

  
27
import eu.etaxonomy.cdm.model.reference.Reference;
28
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action;
29
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
30
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
31
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
32
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
33

  
34
/**
35
 * @author a.kohlbecker
36
 * @since Mar 2, 2017
37
 *
38
 */
39
@SpringView(name=StartRegistrationViewBean.NAME)
40
public class StartRegistrationViewBean extends AbstractPageView<StartRegistrationPresenter>
41
    implements StartRegistrationView, AccessRestrictedView, View {
42

  
43
    private static final long serialVersionUID = -9055865292188732909L;
44

  
45
    public static final String NAME = "regStart";
46

  
47
    public static final String SUBHEADER_DEEFAULT = "Any valid nomenclatural act can only be etablished in a publication. "
48
            + "To start a new registration process, please choose an existing one or create a new publication.";
49

  
50
    private LazyComboBox<Reference> referenceCombobox;
51

  
52
    private Button newPublicationButton;
53

  
54
    private Button removeNewPublicationButton;
55

  
56
    private Label newPublicationLabel;
57

  
58
    private Button continueButton;
59

  
60
    private static final String ELEMENT_WIDTH = "330px";
61

  
62

  
63
    public StartRegistrationViewBean() {
64
        super();
65
    }
66

  
67
    /**
68
     * {@inheritDoc}
69
     */
70
    @Override
71
    public boolean allowAnonymousAccess() {
72
        return false;
73
    }
74

  
75
    /**
76
     * {@inheritDoc}
77
     */
78
    @Override
79
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
80
        return null;
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    protected String getHeaderText() {
88
        return "New Registration";
89
    }
90

  
91
    /**
92
     * {@inheritDoc}
93
     */
94
    @Override
95
    protected String getSubHeaderText() {
96
        return SUBHEADER_DEEFAULT;
97
    }
98

  
99
    /**
100
     * {@inheritDoc}
101
     */
102
    @Override
103
    protected void initContent() {
104

  
105
        VerticalLayout vlayout = new VerticalLayout();
106
        vlayout.setSpacing(true);
107
        vlayout.setMargin(true);
108

  
109
        HorizontalLayout publicationLayout = new HorizontalLayout();
110
        publicationLayout.setSpacing(true);
111

  
112
        referenceCombobox = new LazyComboBox<Reference>(Reference.class);
113
        referenceCombobox.setWidth(ELEMENT_WIDTH);
114
        referenceCombobox.setBuffered(false);
115
        referenceCombobox.addValueChangeListener( e -> {
116
            boolean isValueSelected = e.getProperty().getValue() != null;
117
            continueButton.setEnabled(isValueSelected);
118
        });
119

  
120
        newPublicationButton = new Button("New");
121
        newPublicationButton.addClickListener( e -> eventBus.publishEvent(
122
                new ReferenceEditorAction(Action.ADD, newPublicationButton)
123
                ));
124
        newPublicationButton.setCaption("New");
125
        newPublicationButton.setWidth(ELEMENT_WIDTH);
126

  
127
        newPublicationLabel = new Label();
128
        newPublicationLabel.setVisible(false);
129

  
130
        removeNewPublicationButton = new Button("Delete");
131
        removeNewPublicationButton.setStyleName(ValoTheme.BUTTON_DANGER);
132
        removeNewPublicationButton.setWidth(ELEMENT_WIDTH);
133
        removeNewPublicationButton.addClickListener( e -> eventBus.publishEvent(
134
                new ReferenceEditorAction(Action.REMOVE, removeNewPublicationButton)
135
                ));
136

  
137
        removeNewPublicationButton.setVisible(false);
138

  
139
        Label labelLeft = new Label("Choose from existing publications");
140
        Label labelRight = new Label("Create a new publication");
141
        labelLeft.setWidth(ELEMENT_WIDTH);
142
        labelRight.setWidth(ELEMENT_WIDTH);
143

  
144
        CssLayout leftContainer = new CssLayout(labelLeft, referenceCombobox);
145
        CssLayout rightContainer = new CssLayout(labelRight, newPublicationButton, removeNewPublicationButton, newPublicationLabel);
146
        leftContainer.setWidth(ELEMENT_WIDTH);
147
        rightContainer.setWidth(ELEMENT_WIDTH);
148

  
149
        publicationLayout.addComponents(
150
                leftContainer,
151
                rightContainer
152
                );
153
        publicationLayout.setComponentAlignment(leftContainer, Alignment.TOP_RIGHT);
154
        publicationLayout.setComponentAlignment(rightContainer, Alignment.TOP_LEFT);
155

  
156
        continueButton = new Button("Continue");
157
        continueButton.setStyleName(ValoTheme.BUTTON_PRIMARY + " " + ValoTheme.BUTTON_HUGE);
158
        continueButton.setEnabled(false);
159
        continueButton.addClickListener(e -> {
160

  
161
            Integer refId = null;
162
            referenceCombobox.commit();
163
            if(referenceCombobox.getValue() != null){
164
                refId = referenceCombobox.getValue().getId();
165
            }
166
            eventBus.publishEvent(
167
                new RegistrationEditorAction(Action.ADD,
168
                        // passing the refId is hack, bit for some reason the presenter is always referring to the wrong view
169
                        refId,
170
                        continueButton,
171
                        StartRegistrationViewBean.this)
172
                );
173
              }
174
            );
175

  
176
        vlayout.addComponents(publicationLayout, continueButton);
177
        vlayout.setComponentAlignment(publicationLayout, Alignment.TOP_CENTER);
178
        vlayout.setComponentAlignment(continueButton, Alignment.TOP_CENTER);
179

  
180
        getLayout().addComponent(vlayout);
181
    }
182

  
183

  
184

  
185
    /**
186
     * {@inheritDoc}
187
     */
188
    @Override
189
    public void enter(ViewChangeEvent event) {
190
        // TODO Auto-generated method stub
191

  
192
    }
193

  
194
    // ------- StartRegistrationView interface methods ----- //
195

  
196
    /**
197
     * @return the referenceCombobox
198
     */
199
    @Override
200
    public LazyComboBox<Reference> getReferenceCombobox() {
201
        return referenceCombobox;
202
    }
203

  
204
    /**
205
     * @return the newPublicationButton
206
     */
207
    @Override
208
    public Button getNewPublicationButton() {
209
        return newPublicationButton;
210
    }
211

  
212
    /**
213
     * @return the newPublicationButton
214
     */
215
    @Override
216
    public Button getRemoveNewPublicationButton() {
217
        return removeNewPublicationButton;
218
    }
219

  
220
    /**
221
     * @return the newPublicationButton
222
     */
223
    @Override
224
    public Button getContinueButton() {
225
        return continueButton;
226
    }
227

  
228
    /**
229
     * @return the newPublicationLabel
230
     */
231
    @Override
232
    public Label getNewPublicationLabel() {
233
        return newPublicationLabel;
234
    }
235

  
236

  
237

  
238
}
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPresenter.java
208 208
    /**
209 209
	 * Extending classes should overwrite this method in order to perform logic
210 210
	 * after presenter has finished initializing.
211
	 *
212
	 * At this point in the life cycle of the MVP the {@link AbstractView#initContent() initContent()}
213
	 * method has been executed already.
211 214
	 */
212 215
	protected void onPresenterReady() {
213 216
	    logger.trace(String.format("Presenter %s ready", _toString()));
......
267 270

  
268 271
	public final void onViewExit() {
269 272
	    logger.trace(String.format("%s onViewExit()", _toString()));
273
	    handleViewExit();
270 274
	    // un-register as request start and end listener
271 275
	    if(conversationBound){
272 276
    	    logger.trace(String.format("<<<<< %s onViewExit() unbind()", _toString()));
......
285 289
        } else {
286 290
            throw new RuntimeException("Using the CdmSpringVaadinServletService is required for proper per view conversation handling");
287 291
        }
288
	    handleViewExit();
289 292
	}
290 293

  
291 294
	/**
......
301 304
    /**
302 305
     * Extending classes may overwrite this method to react to
303 306
     * the event when user leaves the view that this presenter
304
     * governs.
307
     * governs. This method is executed before un-binding and closing the
308
     * conversation holder.
305 309
     */
306 310
    public void handleViewExit() {
307 311
    }
src/main/java/org/springframework/context/event/DefaultPojoEventListenerManager.java
29 29
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
30 30

  
31 31
/**
32
 * The DefaultPojoEventListenerManager helps sending events to  event listener methods defined in beans
33
 * which are not manages by the Spring {@link ApplicationEventMulticaster}. The {@link ApplicationEventMulticaster}
34
 * for example misses sending events to spring beans with scope "Prototype".
35
 *
32 36
 * @author a.kohlbecker
33 37
 * @since May 29, 2017
34 38
 *
src/main/resources/eu/etaxonomy/cdm/vaadin/design/registration/StartRegistrationDesign.html
1
<!doctype html>
2
<html>
3
 <head>
4
  <meta charset="UTF-8">
5
  <meta name="design-properties" content="{&quot;RULERS_VISIBLE&quot;:true,&quot;GUIDELINES_VISIBLE&quot;:false,&quot;SNAP_TO_OBJECTS&quot;:true,&quot;SNAP_TO_GRID&quot;:true,&quot;SNAPPING_DISTANCE&quot;:10,&quot;JAVA_SOURCES_ROOT&quot;:&quot;src/main/java&quot;,&quot;THEME&quot;:&quot;edit-valo&quot;}">
6
  <meta name="vaadin-version" content="7.7.0">
7
 </head>
8
 <body>
9
  <vaadin-vertical-layout spacing>
10
   <vaadin-label style-name="huge" size-auto plain-text :center>
11
     New Registration 
12
   </vaadin-label>
13
   <vaadin-label size-auto plain-text :middle :center>
14
     What are you about to register, a scientific name or a typification for a name? 
15
   </vaadin-label>
16
   <vaadin-css-layout style-name="dashboard-actions" responsive _id="dashboard" :center>
17
    <vaadin-vertical-layout style-name="dashboard-action-2" spacing size-auto margin>
18
     <vaadin-button icon="fonticon://FontAwesome/f02b" style-name="borderless icon-align-top giant" plain-text _id="buttonName" :middle :center>
19
       Name 
20
     </vaadin-button>
21
     <vaadin-label size-auto plain-text :center>
22
       Start the registration process for a scientific name. 
23
     </vaadin-label>
24
    </vaadin-vertical-layout>
25
    <vaadin-vertical-layout style-name="dashboard-action-2" spacing size-auto margin>
26
     <vaadin-button icon="fonticon://FontAwesome/f02c" enabled="false" style-name="borderless icon-align-top giant" plain-text _id="buttonTypification" :middle :center>
27
       Typification 
28
     </vaadin-button>
29
     <vaadin-label size-auto plain-text :center>
30
       Start the registration process for a typification. 
31
     </vaadin-label>
32
    </vaadin-vertical-layout>
33
   </vaadin-css-layout>
34
  </vaadin-vertical-layout>
35
 </body>
36
</html>

Also available in: Unified diff