1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.editor.key.polytomous;
|
5
|
|
6
|
import java.util.UUID;
|
7
|
|
8
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
9
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
10
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
11
|
import eu.etaxonomy.taxeditor.editor.key.AbstractIdentificationEditorInput;
|
12
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
|
13
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
14
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
15
|
|
16
|
/**
|
17
|
* @author n.hoffmann
|
18
|
*
|
19
|
*/
|
20
|
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> implements ICdmEntitySessionEnabled {
|
21
|
|
22
|
private final PolytomousKey key;
|
23
|
private final ICdmEntitySession cdmEntitySession;
|
24
|
|
25
|
protected PolytomousKeyEditorInput(ConversationHolder conversation,
|
26
|
PolytomousKey key) {
|
27
|
super(conversation);
|
28
|
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
|
29
|
|
30
|
this.key = key;
|
31
|
}
|
32
|
|
33
|
|
34
|
|
35
|
public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
|
36
|
try{
|
37
|
ConversationHolder conversation = CdmStore.createConversation();
|
38
|
|
39
|
return NewInstance(polytomousKeyUuid, conversation);
|
40
|
}catch(Exception e){
|
41
|
throw e;
|
42
|
}
|
43
|
}
|
44
|
|
45
|
public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid, ConversationHolder conversation) throws Exception{
|
46
|
PolytomousKey polytomousKey = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, null);
|
47
|
|
48
|
return new PolytomousKeyEditorInput(conversation, polytomousKey);
|
49
|
}
|
50
|
|
51
|
/* (non-Javadoc)
|
52
|
* @see org.eclipse.ui.IEditorInput#getName()
|
53
|
*/
|
54
|
@Override
|
55
|
public String getName() {
|
56
|
return key.getTitleCache();
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public PolytomousKey getKey() {
|
61
|
return key;
|
62
|
}
|
63
|
|
64
|
/* (non-Javadoc)
|
65
|
* @see java.lang.Object#equals(java.lang.Object)
|
66
|
*/
|
67
|
@Override
|
68
|
public boolean equals(Object object) {
|
69
|
if (object instanceof PolytomousKeyEditorInput
|
70
|
&& getKey() != null
|
71
|
&& getKey().equals(((PolytomousKeyEditorInput) object).getKey())
|
72
|
){
|
73
|
return true;
|
74
|
}
|
75
|
return super.equals(object);
|
76
|
}
|
77
|
|
78
|
public void dispose() {
|
79
|
cdmEntitySession.dispose();
|
80
|
}
|
81
|
|
82
|
|
83
|
|
84
|
/* (non-Javadoc)
|
85
|
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
|
86
|
*/
|
87
|
@Override
|
88
|
public ICdmEntitySession getCdmEntitySession() {
|
89
|
return cdmEntitySession;
|
90
|
}
|
91
|
}
|