Project

General

Profile

Download (1.95 KB) Statistics
| Branch: | Tag: | Revision:
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.vaadin.event;
10

    
11
import java.util.EnumSet;
12

    
13
import com.vaadin.ui.AbstractField;
14

    
15
/**
16
 * An Event which represents the request to start an editor to enable the
17
 * user to perform the <code>action</code> transported with this event.
18
 *
19
 * @author a.kohlbecker
20
 *
21
 */
22
public class EntityEditorActionEvent<T>  {
23

    
24
    private Class<T> beanType;
25
    private EditorActionType action;
26
    private AbstractField<T> field;
27
    private T bean;
28

    
29
    /**
30
     * @param type
31
     * @param entityId
32
     * @param field
33
     */
34
    public EntityEditorActionEvent(EditorActionType action, Class<T> beanType, AbstractField<T> field) {
35
        this.action = action;
36
        this.beanType = beanType;
37
        this.field = field;
38
    }
39

    
40
    /**
41
     *
42
     * @param type
43
     * @param entityId
44
     * @param field
45
     */
46
    public EntityEditorActionEvent(EditorActionType action, Class<T> beanType, T bean, AbstractField<T> field) {
47
        this.action = action;
48
        this.beanType = beanType;
49
        if(EnumSet.of(EditorActionType.REMOVE, EditorActionType.EDIT).contains(action) && bean == null){
50
            throw new NullPointerException("bean must not be null when creating an event with " + action);
51
        }
52
        this.bean = bean;
53
        this.field = field;
54
    }
55

    
56
    /**
57
     * @return the beanType
58
     */
59
    public Class<?> getBeanType() {
60
        return beanType;
61
    }
62

    
63
    /**
64
     * @return the action
65
     */
66
    public EditorActionType getAction() {
67
        return action;
68
    }
69

    
70
    /**
71
     * @return the field which contains the bean
72
     */
73
    public AbstractField<T> getSource() {
74
        return field;
75
    }
76

    
77
    /**
78
     * @return the bean
79
     */
80
    public T getBean() {
81
        return bean;
82
    }
83

    
84
}
(2-2/3)