4 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
;
6 import java
.util
.Arrays
;
10 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
11 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
12 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
13 import eu
.etaxonomy
.taxeditor
.editor
.key
.AbstractIdentificationEditorInput
;
14 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySession
;
15 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
16 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 public class PolytomousKeyEditorInput
extends AbstractIdentificationEditorInput
<PolytomousKey
> implements ICdmEntitySessionEnabled
{
24 private final PolytomousKey key
;
25 private final ICdmEntitySession cdmEntitySession
;
27 protected PolytomousKeyEditorInput(ConversationHolder conversation
,
30 cdmEntitySession
= CdmStore
.getCurrentSessionManager().newSession(this, true);
37 public static PolytomousKeyEditorInput
NewInstance(UUID polytomousKeyUuid
) throws Exception
{
39 ConversationHolder conversation
= CdmStore
.createConversation();
41 return NewInstance(polytomousKeyUuid
, conversation
);
47 public static PolytomousKeyEditorInput
NewInstance(UUID polytomousKeyUuid
, ConversationHolder conversation
) throws Exception
{
48 PolytomousKey polytomousKey
= CdmStore
.getService(IPolytomousKeyService
.class).load(polytomousKeyUuid
, null);
50 return new PolytomousKeyEditorInput(conversation
, polytomousKey
);
54 * @see org.eclipse.ui.IEditorInput#getName()
57 public String
getName() {
58 return key
.getTitleCache();
62 public PolytomousKey
getKey() {
67 * @see java.lang.Object#equals(java.lang.Object)
70 public boolean equals(Object object
) {
71 if (object
instanceof PolytomousKeyEditorInput
73 && getKey().equals(((PolytomousKeyEditorInput
) object
).getKey())
77 return super.equals(object
);
80 public void dispose() {
81 cdmEntitySession
.dispose();
87 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
90 public ICdmEntitySession
getCdmEntitySession() {
91 return cdmEntitySession
;
97 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
100 public List
<PolytomousKey
> getRootEntities() {
101 return Arrays
.asList(key
);