Project

General

Profile

« Previous | Next » 

Revision 838412f6

Added by Andreas Kohlbecker almost 7 years ago

ref #6612 introducing EntityChangeEvent and generalizing Event class hierarchy

View differences:

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
}

Also available in: Unified diff