2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.group
.authority
;
11 import java
.util
.Arrays
;
12 import java
.util
.Collection
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
16 import org
.eclipse
.ui
.IEditorInput
;
17 import org
.eclipse
.ui
.IPersistableElement
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IGroupService
;
22 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
23 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
24 import eu
.etaxonomy
.taxeditor
.editor
.CdmEntitySessionInput
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * Editor input for the {@link CdmAuthorityEditor}.
31 * @created Mar 28, 2013
35 public class CdmAuthorityEditorInput
extends CdmEntitySessionInput
implements IEditorInput
, IConversationEnabled
{
36 private ConversationHolder conversation
;
39 protected CdmAuthorityEditorInput(ConversationHolder conversation
, Group group
) {
41 this.conversation
= conversation
;
47 * Creates a new instance of the input for a given group.
53 public static CdmAuthorityEditorInput
NewInstance(UUID groupUuid
) throws Exception
{
54 ConversationHolder conversation
= CdmStore
.createConversation();
55 Group group
= CdmStore
.getService(IGroupService
.class).load(groupUuid
, null);
56 return new CdmAuthorityEditorInput(conversation
, group
);
60 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
63 public Object
getAdapter(Class adapter
) {
64 if (adapter
== Group
.class) {
71 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
74 public void update(CdmDataChangeMap changeEvents
) {
75 // TODO Auto-generated method stub
79 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
82 public ConversationHolder
getConversationHolder() {
83 return this.conversation
;
86 * @see org.eclipse.ui.IEditorInput#exists()
89 public boolean exists() {
93 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
96 public ImageDescriptor
getImageDescriptor() {
97 // TODO Auto-generated method stub
101 * @see org.eclipse.ui.IEditorInput#getName()
104 public String
getName() {
105 return group
.getName();
108 * @see org.eclipse.ui.IEditorInput#getPersistable()
111 public IPersistableElement
getPersistable() {
112 // TODO Auto-generated method stub
116 * @see org.eclipse.ui.IEditorInput#getToolTipText()
119 public String
getToolTipText() {
124 * @see java.lang.Object#equals(java.lang.Object)
127 public boolean equals(Object object
) {
128 if (object
instanceof CdmAuthorityEditorInput
129 && getGroup() != null
130 && getGroup().equals(((CdmAuthorityEditorInput
) object
).getGroup())
134 return super.equals(object
);
138 * Getter method for group member.
142 public Group
getGroup() {
147 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
150 public Collection
<Group
> getRootEntities() {
151 return Arrays
.asList(group
);
155 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
158 public void merge() {
159 CdmStore
.getService(IGroupService
.class).merge(group
);