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.e4;
|
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.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
|
20
|
import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour;
|
21
|
|
22
|
/**
|
23
|
* @author n.hoffmann
|
24
|
* @created May 5, 2011
|
25
|
* @version 1.0
|
26
|
*/
|
27
|
public class KeyEditorDataChangeBehaviourE4 extends AbstractDataChangeBehaviour {
|
28
|
|
29
|
private final PolytomousKeyListEditorE4 source;
|
30
|
private PolytomousKeyEditorInput input;
|
31
|
|
32
|
public KeyEditorDataChangeBehaviourE4(PolytomousKeyListEditorE4 keyEditor) {
|
33
|
source = keyEditor;
|
34
|
}
|
35
|
|
36
|
@Override
|
37
|
public void reactOnDataChange(CdmDataChangeMap changeEvents) {
|
38
|
input = source.getEditorInput();
|
39
|
|
40
|
if(changeEvents.sizeByEventType(EventType.UPDATE) > 0){
|
41
|
reactOnUpdate(changeEvents.getEvents(EventType.UPDATE));
|
42
|
}
|
43
|
}
|
44
|
|
45
|
/** {@inheritDoc} */
|
46
|
@Override
|
47
|
public void reactOnUpdate(Vector<CdmDataChangeEvent> events){
|
48
|
|
49
|
for(CdmDataChangeEvent event : events){
|
50
|
|
51
|
// update editor title
|
52
|
if(event.getEntity() instanceof PolytomousKey){
|
53
|
if(input.getKey().equals(event.getEntity())){
|
54
|
// set the name of the editor window
|
55
|
source.setPartName();
|
56
|
}
|
57
|
}
|
58
|
}
|
59
|
}
|
60
|
}
|