1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.vaadin.session;
|
11
|
|
12
|
import java.util.List;
|
13
|
|
14
|
import com.vaadin.ui.Component;
|
15
|
|
16
|
/**
|
17
|
* @author cmathew
|
18
|
* @date 7 Apr 2015
|
19
|
*
|
20
|
*/
|
21
|
public class CdmChangeEvent {
|
22
|
|
23
|
public enum Action {
|
24
|
Create,
|
25
|
Update,
|
26
|
Delete
|
27
|
}
|
28
|
|
29
|
private final Action action;
|
30
|
private final List<Object> changedObjects;
|
31
|
private Class<? extends Component> sourceType;
|
32
|
private Object source;
|
33
|
|
34
|
public CdmChangeEvent(Action action, List<Object> changedObjects, Class<? extends Component> sourceType) {
|
35
|
this.action = action;
|
36
|
this.changedObjects = changedObjects;
|
37
|
if(changedObjects == null || changedObjects.isEmpty()) {
|
38
|
throw new IllegalArgumentException("Changed objects cannot be empty");
|
39
|
}
|
40
|
this.sourceType = sourceType;
|
41
|
if(sourceType == null) {
|
42
|
throw new IllegalArgumentException("Source type cannot be null");
|
43
|
}
|
44
|
}
|
45
|
|
46
|
public CdmChangeEvent(Action action, List<Object> changedObjects, Component source) {
|
47
|
this.action = action;
|
48
|
this.changedObjects = changedObjects;
|
49
|
if(changedObjects == null || changedObjects.isEmpty()) {
|
50
|
throw new IllegalArgumentException("Changed objects cannot be empty");
|
51
|
}
|
52
|
this.source= source;
|
53
|
if(source == null) {
|
54
|
throw new IllegalArgumentException("Source cannot be null");
|
55
|
}
|
56
|
this.sourceType = source.getClass();
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* @return the action
|
61
|
*/
|
62
|
public Action getAction() {
|
63
|
return action;
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* @return the changedObjects
|
68
|
*/
|
69
|
public List<Object> getChangedObjects() {
|
70
|
return changedObjects;
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* @return the sourceType
|
75
|
*/
|
76
|
public Class<? extends Component> getSourceType() {
|
77
|
return sourceType;
|
78
|
}
|
79
|
|
80
|
|
81
|
/**
|
82
|
* @return the source
|
83
|
*/
|
84
|
public Object getSource() {
|
85
|
return source;
|
86
|
}
|
87
|
|
88
|
}
|