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
.application
.CdmApplicationState
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
22 import eu
.etaxonomy
.cdm
.api
.service
.IGroupService
;
23 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
24 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
25 import eu
.etaxonomy
.taxeditor
.editor
.CdmEntitySessionInput
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * Editor input for the {@link CdmAuthorityEditor}.
32 * @created Mar 28, 2013
36 public class CdmAuthorityEditorInput
extends CdmEntitySessionInput
implements IEditorInput
, IConversationEnabled
{
37 private ConversationHolder conversation
;
40 protected CdmAuthorityEditorInput(ConversationHolder conversation
, Group group
) {
42 this.conversation
= conversation
;
43 this.group
= CdmApplicationState
.getCurrentAppConfig().getGroupService().load(group
.getUuid());
48 * Creates a new instance of the input for a given group.
54 public static CdmAuthorityEditorInput
NewInstance(UUID groupUuid
) throws Exception
{
55 ConversationHolder conversation
= CdmStore
.createConversation();
56 Group group
= CdmStore
.getService(IGroupService
.class).load(groupUuid
, null);
57 return new CdmAuthorityEditorInput(conversation
, group
);
61 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
64 public Object
getAdapter(Class adapter
) {
65 if (adapter
== Group
.class) {
72 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
75 public void update(CdmDataChangeMap changeEvents
) {
76 // TODO Auto-generated method stub
80 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
83 public ConversationHolder
getConversationHolder() {
84 return this.conversation
;
87 * @see org.eclipse.ui.IEditorInput#exists()
90 public boolean exists() {
94 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
97 public ImageDescriptor
getImageDescriptor() {
98 // TODO Auto-generated method stub
102 * @see org.eclipse.ui.IEditorInput#getName()
105 public String
getName() {
106 return group
.getName();
109 * @see org.eclipse.ui.IEditorInput#getPersistable()
112 public IPersistableElement
getPersistable() {
113 // TODO Auto-generated method stub
117 * @see org.eclipse.ui.IEditorInput#getToolTipText()
120 public String
getToolTipText() {
125 * @see java.lang.Object#equals(java.lang.Object)
128 public boolean equals(Object object
) {
129 if (object
instanceof CdmAuthorityEditorInput
130 && getGroup() != null
131 && getGroup().equals(((CdmAuthorityEditorInput
) object
).getGroup())
135 return super.equals(object
);
139 * Getter method for group member.
143 public Group
getGroup() {
148 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
151 public Collection
<Group
> getRootEntities() {
152 return Arrays
.asList(group
);
156 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
159 public void merge() {
160 group
= CdmStore
.getService(IGroupService
.class).merge(group
);