1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.editor.group.authority;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.eclipse.jface.resource.ImageDescriptor;
|
14
|
import org.eclipse.ui.IEditorInput;
|
15
|
import org.eclipse.ui.IPersistableElement;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
18
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
19
|
import eu.etaxonomy.cdm.api.service.IGroupService;
|
20
|
import eu.etaxonomy.cdm.model.common.Group;
|
21
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* Editor input for the {@link CdmAuthorityEditor}.
|
26
|
*
|
27
|
* @author cmathew
|
28
|
* @created Mar 28, 2013
|
29
|
*
|
30
|
*/
|
31
|
|
32
|
public class CdmAuthorityEditorInput implements IEditorInput, IConversationEnabled {
|
33
|
private ConversationHolder conversation;
|
34
|
private Group group;
|
35
|
|
36
|
protected CdmAuthorityEditorInput(ConversationHolder conversation, Group group) {
|
37
|
this.conversation = conversation;
|
38
|
this.group = group;
|
39
|
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* Creates a new instance of the input for a given group.
|
44
|
*
|
45
|
* @param groupUuid
|
46
|
* @return
|
47
|
* @throws Exception
|
48
|
*/
|
49
|
public static CdmAuthorityEditorInput NewInstance(UUID groupUuid) throws Exception{
|
50
|
ConversationHolder conversation = CdmStore.createConversation();
|
51
|
Group group = CdmStore.getService(IGroupService.class).load(groupUuid, null);
|
52
|
return new CdmAuthorityEditorInput(conversation, group);
|
53
|
}
|
54
|
|
55
|
/* (non-Javadoc)
|
56
|
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
57
|
*/
|
58
|
@Override
|
59
|
public Object getAdapter(Class adapter) {
|
60
|
if (adapter == Group.class) {
|
61
|
return this.group;
|
62
|
}
|
63
|
|
64
|
return null;
|
65
|
}
|
66
|
/* (non-Javadoc)
|
67
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
68
|
*/
|
69
|
@Override
|
70
|
public void update(CdmDataChangeMap changeEvents) {
|
71
|
// TODO Auto-generated method stub
|
72
|
|
73
|
}
|
74
|
/* (non-Javadoc)
|
75
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
76
|
*/
|
77
|
@Override
|
78
|
public ConversationHolder getConversationHolder() {
|
79
|
return this.conversation;
|
80
|
}
|
81
|
/* (non-Javadoc)
|
82
|
* @see org.eclipse.ui.IEditorInput#exists()
|
83
|
*/
|
84
|
@Override
|
85
|
public boolean exists() {
|
86
|
return group != null;
|
87
|
}
|
88
|
/* (non-Javadoc)
|
89
|
* @see org.eclipse.ui.IEditorInput#getImageDescriptor()
|
90
|
*/
|
91
|
@Override
|
92
|
public ImageDescriptor getImageDescriptor() {
|
93
|
// TODO Auto-generated method stub
|
94
|
return null;
|
95
|
}
|
96
|
/* (non-Javadoc)
|
97
|
* @see org.eclipse.ui.IEditorInput#getName()
|
98
|
*/
|
99
|
@Override
|
100
|
public String getName() {
|
101
|
return group.getName();
|
102
|
}
|
103
|
/* (non-Javadoc)
|
104
|
* @see org.eclipse.ui.IEditorInput#getPersistable()
|
105
|
*/
|
106
|
@Override
|
107
|
public IPersistableElement getPersistable() {
|
108
|
// TODO Auto-generated method stub
|
109
|
return null;
|
110
|
}
|
111
|
/* (non-Javadoc)
|
112
|
* @see org.eclipse.ui.IEditorInput#getToolTipText()
|
113
|
*/
|
114
|
@Override
|
115
|
public String getToolTipText() {
|
116
|
return getName();
|
117
|
}
|
118
|
|
119
|
/* (non-Javadoc)
|
120
|
* @see java.lang.Object#equals(java.lang.Object)
|
121
|
*/
|
122
|
@Override
|
123
|
public boolean equals(Object object) {
|
124
|
if (object instanceof CdmAuthorityEditorInput
|
125
|
&& getGroup() != null
|
126
|
&& getGroup().equals(((CdmAuthorityEditorInput) object).getGroup())
|
127
|
){
|
128
|
return true;
|
129
|
}
|
130
|
return super.equals(object);
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* Getter method for group member.
|
135
|
*
|
136
|
* @return
|
137
|
*/
|
138
|
public Group getGroup() {
|
139
|
return this.group;
|
140
|
}
|
141
|
}
|