Project

General

Profile

Download (1.78 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.store.CdmStore;
13

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

    
20
	private PolytomousKey key;
21

    
22
	protected PolytomousKeyEditorInput(ConversationHolder conversation,
23
			PolytomousKey key) {
24
		super(conversation);
25
		this.key = key;
26
	}
27
	
28
	
29

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