1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.taxeditor.editor.key;
|
11
|
|
12
|
import java.util.Vector;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
15
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent;
|
16
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
|
17
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
18
|
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
|
19
|
import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour;
|
20
|
|
21
|
/**
|
22
|
* @author n.hoffmann
|
23
|
* @created May 5, 2011
|
24
|
* @version 1.0
|
25
|
*/
|
26
|
public class KeyEditorDataChangeBehaviour extends AbstractDataChangeBehaviour {
|
27
|
|
28
|
private final KeyEditor source;
|
29
|
private PolytomousKeyEditorInput input;
|
30
|
|
31
|
/**
|
32
|
* @param keyEditor
|
33
|
*/
|
34
|
public KeyEditorDataChangeBehaviour(KeyEditor keyEditor) {
|
35
|
source = keyEditor;
|
36
|
}
|
37
|
|
38
|
/* (non-Javadoc)
|
39
|
* @see eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour#reactOnDataChange(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
40
|
*/
|
41
|
@Override
|
42
|
public void reactOnDataChange(CdmDataChangeMap changeEvents) {
|
43
|
input = (PolytomousKeyEditorInput) source.getEditorInput();
|
44
|
|
45
|
if(changeEvents.sizeByEventType(EventType.UPDATE) > 0){
|
46
|
reactOnUpdate(changeEvents.getEvents(EventType.UPDATE));
|
47
|
}
|
48
|
}
|
49
|
|
50
|
/** {@inheritDoc} */
|
51
|
@Override
|
52
|
public void reactOnUpdate(Vector<CdmDataChangeEvent> events){
|
53
|
|
54
|
for(CdmDataChangeEvent event : events){
|
55
|
|
56
|
// update editor title
|
57
|
if(event.getEntity() instanceof PolytomousKey){
|
58
|
if(input.getKey().equals(event.getEntity())){
|
59
|
// set the name of the editor window
|
60
|
source.setPartName();
|
61
|
}
|
62
|
}
|
63
|
}
|
64
|
}
|
65
|
}
|