Project

General

Profile

Revision 838412f6

ID838412f6bfa678403ef89d35722b8cce53af4e54
Parent 154f5e57
Child 9d5ae601

Added by Andreas Kohlbecker about 3 years ago

ref #6612 introducing EntityChangeEvent and generalizing Event class hierarchy

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
26 26
import com.vaadin.ui.themes.ValoTheme;
27 27

  
28 28
import eu.etaxonomy.cdm.model.common.TimePeriod;
29
import eu.etaxonomy.cdm.vaadin.event.EditorActionType;
29
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Type;
30 30
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
31 31
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
32 32
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
......
168 168
        this.parentView = parentView;
169 169
        ReferenceEditorAction openButtonEvent;
170 170
        if(workingSet.getCitationId() != null){
171
            openButtonEvent = new ReferenceEditorAction(EditorActionType.EDIT, workingSet.getCitationId());
171
            openButtonEvent = new ReferenceEditorAction(Type.EDIT, workingSet.getCitationId());
172 172
        } else {
173
            openButtonEvent = new ReferenceEditorAction(EditorActionType.ADD);
173
            openButtonEvent = new ReferenceEditorAction(Type.ADD);
174 174
        }
175 175
        TimePeriod datePublished = workingSet.getRegistrationDTOs().get(0).getDatePublished();
176 176
        updateUI(workingSet.getCitation(), workingSet.getCreated(), datePublished, workingSet.messagesCount(),
src/main/java/eu/etaxonomy/cdm/vaadin/event/AbstractEditorAction.java
13 13
 * @since Mar 22, 2017
14 14
 *
15 15
 */
16
public abstract class AbstractEditorAction {
16
public abstract class AbstractEditorAction extends AbstractEntityEvent<AbstractEditorAction.Type> {
17 17

  
18
    public enum Type {
19
        ADD,
20
        EDIT,
21
        REMOVE;
22
    }
18 23

  
19
    private EditorActionType actionType;
20

  
21
    private Integer entityId = null;
22

  
23
    public AbstractEditorAction(EditorActionType eventType, Integer entityId) {
24
        this.actionType = eventType;
25
        if(eventType == null){
26
            throw new NullPointerException();
27
        }
28
        this.setEntityId(entityId);
24
    public AbstractEditorAction(Type type) {
25
        super(type, null);
29 26
    }
30 27

  
31
    public AbstractEditorAction(EditorActionType actionType) {
32
        this(actionType, null);
28
    /**
29
     * @param type
30
     * @param citationId
31
     */
32
    public AbstractEditorAction(Type type, Integer entityId) {
33
        super(type, entityId);
33 34
    }
34 35

  
35
    public EditorActionType getActionType() {
36
        return actionType;
36
    public Type getActionType() {
37
        return type;
37 38
    }
38 39

  
39 40
    public boolean isAddAction() {
40
        return actionType.equals(EditorActionType.ADD);
41
        return type.equals(Type.ADD);
41 42
    }
42 43
    public boolean isEditAction() {
43
        return actionType.equals(EditorActionType.EDIT);
44
        return type.equals(Type.EDIT);
44 45
    }
45 46
    public boolean isRemoveAction() {
46
        return actionType.equals(EditorActionType.REMOVE);
47
    }
48

  
49
    /**
50
     * @return the entityId
51
     */
52
    public Integer getEntityId() {
53
        return entityId;
47
        return type.equals(Type.REMOVE);
54 48
    }
55 49

  
56
    /**
57
     * @param entityId the entityId to set
58
     */
59
    private void setEntityId(Integer entityId) {
60
        this.entityId = entityId;
61
    }
62 50

  
63 51
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/AbstractEntityEvent.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.event;
10

  
11
/**
12
 * @author a.kohlbecker
13
 * @since May 10, 2017
14
 *
15
 */
16
public abstract class AbstractEntityEvent<T extends Enum> {
17

  
18
    private Integer entityId = null;
19

  
20
    protected T type;
21

  
22
    public AbstractEntityEvent(T type, Integer entityId) {
23
        this.entityId = entityId;
24
        this.type = type;
25
        if(type == null){
26
            throw new NullPointerException();
27
        }
28
    }
29

  
30
    /**
31
     * @return the entityId
32
     */
33
    public Integer getEntityId() {
34
        return entityId;
35
    }
36

  
37
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/EditorActionType.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.event;
10

  
11
/**
12
 * @author a.kohlbecker
13
 * @since Mar 22, 2017
14
 *
15
 */
16
public enum EditorActionType {
17

  
18
    ADD,
19
    EDIT,
20
    REMOVE;
21

  
22
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/EntityChangeEvent.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.event;
10

  
11
/**
12
 * @author a.kohlbecker
13
 * @since May 10, 2017
14
 *
15
 */
16
public class EntityChangeEvent extends AbstractEntityEvent<EntityChangeEvent.Type> {
17

  
18
    public enum Type {
19
        CREATED,
20
        MODIFIED,
21
        REMOVED;
22
    }
23

  
24
    /**
25
     * @param type
26
     * @param entityId
27
     */
28
    public EntityChangeEvent(Type type, Integer entityId) {
29
        super(type, entityId);
30
    }
31

  
32

  
33
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/ReferenceEditorAction.java
18 18
    /**
19 19
     * @param eventType
20 20
     */
21
    public ReferenceEditorAction(EditorActionType eventType) {
22
        super(eventType);
21
    public ReferenceEditorAction(Type type) {
22
        super(type);
23 23
    }
24 24

  
25 25
    /**
26
     * @param eventType
27
     * @param entityId
26
     * @param edit
27
     * @param citationId
28 28
     */
29
    public ReferenceEditorAction(EditorActionType eventType, Integer entityId) {
30
        super(eventType, entityId);
29
    public ReferenceEditorAction(Type type, Integer citationId) {
30
        super(type, citationId);
31 31
    }
32 32

  
33

  
34

  
35

  
36 33
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/TaxonNameEditorAction.java
16 16
public class TaxonNameEditorAction extends AbstractEditorAction {
17 17

  
18 18

  
19
    public TaxonNameEditorAction(EditorActionType eventType) {
19
    public TaxonNameEditorAction(Type eventType) {
20 20
        super(eventType);
21 21
    }
22 22

  
23
    /**
24
     * @param type
25
     * @param entityId
26
     */
27
    public TaxonNameEditorAction(Type type, Integer entityId) {
28
        super(type, entityId);
29
    }
30

  
31

  
23 32
}
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationEditorAction.java
16 16
public class TypeDesignationEditorAction extends AbstractEditorAction {
17 17

  
18 18

  
19
    public TypeDesignationEditorAction(EditorActionType eventType) {
19
    public TypeDesignationEditorAction(Type eventType) {
20 20
        super(eventType);
21 21
    }
22 22

  
23
    /**
24
     * @param type
25
     * @param entityId
26
     */
27
    public TypeDesignationEditorAction(Type type, Integer entityId) {
28
        super(type, entityId);
29
    }
30

  
31

  
32

  
23 33
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
38 38
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
39 39
import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel;
40 40
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
41
import eu.etaxonomy.cdm.vaadin.event.EditorActionType;
41
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Type;
42 42
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
43 43
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
44 44
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
......
232 232
   private void addBulletWorkflowName() {
233 233
       WorkflowSteps steps = new WorkflowSteps();
234 234
       steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
235
               e -> eventBus.publishEvent(new ReferenceEditorAction(EditorActionType.EDIT)));
235
               e -> eventBus.publishEvent(new ReferenceEditorAction(Type.EDIT)));
236 236
       steps.appendNewWorkflowItem(2, "One or multiple published scientific new names.",
237
               e -> eventBus.publishEvent(new TaxonNameEditorAction(EditorActionType.EDIT)));
237
               e -> eventBus.publishEvent(new TaxonNameEditorAction(Type.EDIT)));
238 238
       steps.appendNewWorkflowItem(3, "Request for data curation and await approval.", null);
239 239
       steps.appendNewWorkflowItem(4, "Awaiting publication", null);
240 240
       getWorkflow().addComponent(steps);
......
246 246
  private void addBulletWorkflowTypification() {
247 247
      WorkflowSteps steps = new WorkflowSteps();
248 248
      steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
249
              e -> eventBus.publishEvent(new ReferenceEditorAction(EditorActionType.EDIT)));
249
              e -> eventBus.publishEvent(new ReferenceEditorAction(Type.EDIT)));
250 250
      steps.appendNewWorkflowItem(2, "One or multiple published typifications.",
251
              e -> eventBus.publishEvent(new TaxonNameEditorAction(EditorActionType.EDIT)));
251
              e -> eventBus.publishEvent(new TaxonNameEditorAction(Type.EDIT)));
252 252
      steps.appendNewWorkflowItem(3, "Request for data curation and await approval.", null);
253 253
      steps.appendNewWorkflowItem(4, "Awaiting publication", null);
254 254
      getWorkflow().addComponent(steps);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)