Project

General

Profile

Download (1.96 KB) Statistics
| Branch: | Tag: | Revision:
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.ISessionEventListener;
13
import eu.etaxonomy.taxeditor.store.CdmStore;
14

    
15
/**
16
 * @author n.hoffmann
17
 *
18
 */
19
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> implements ISessionEventListener {
20

    
21
	private PolytomousKey key;
22

    
23
	protected PolytomousKeyEditorInput(ConversationHolder conversation,
24
			PolytomousKey key) {
25
		super(conversation);
26
		CdmStore.getCurrentSessionManager().bind(this);
27
		CdmStore.getCurrentSessionManager().load(key);
28
		this.key = key;
29
	}
30
	
31
	
32

    
33
	public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
34
		try{
35
			ConversationHolder conversation = CdmStore.createConversation();
36
			
37
			return NewInstance(polytomousKeyUuid, conversation);
38
		}catch(Exception e){
39
			throw e;
40
		}
41
	}
42
	
43
	public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid, ConversationHolder conversation) throws Exception{
44
		PolytomousKey polytomousKey = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, null);
45
			
46
		return new PolytomousKeyEditorInput(conversation, polytomousKey);
47
	}
48
	
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.ui.IEditorInput#getName()
51
	 */
52
	@Override
53
	public String getName() {
54
		return key.getTitleCache();
55
	}
56
	
57
	@Override
58
	public PolytomousKey getKey() {
59
		return key;
60
	}
61
	
62
	/* (non-Javadoc)
63
	 * @see java.lang.Object#equals(java.lang.Object)
64
	 */
65
	@Override
66
	public boolean equals(Object object) {
67
		if (object instanceof PolytomousKeyEditorInput
68
				&& getKey() != null
69
				&& getKey().equals(((PolytomousKeyEditorInput) object).getKey())
70
		){
71
			return true;
72
		}
73
		return super.equals(object);
74
	}
75
}
(3-3/9)