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.Arrays;
|
12
|
import java.util.Collection;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.eclipse.jface.resource.ImageDescriptor;
|
16
|
import org.eclipse.ui.IEditorInput;
|
17
|
import org.eclipse.ui.IPersistableElement;
|
18
|
|
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;
|
26
|
|
27
|
/**
|
28
|
* Editor input for the {@link CdmAuthorityEditor}.
|
29
|
*
|
30
|
* @author cmathew
|
31
|
* @created Mar 28, 2013
|
32
|
*
|
33
|
*/
|
34
|
|
35
|
public class CdmAuthorityEditorInput extends CdmEntitySessionInput implements IEditorInput, IConversationEnabled {
|
36
|
private ConversationHolder conversation;
|
37
|
private Group group;
|
38
|
|
39
|
protected CdmAuthorityEditorInput(ConversationHolder conversation, Group group) {
|
40
|
super(true);
|
41
|
this.conversation = conversation;
|
42
|
this.group = group;
|
43
|
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* Creates a new instance of the input for a given group.
|
48
|
*
|
49
|
* @param groupUuid
|
50
|
* @return
|
51
|
* @throws Exception
|
52
|
*/
|
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);
|
57
|
}
|
58
|
|
59
|
/* (non-Javadoc)
|
60
|
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
61
|
*/
|
62
|
@Override
|
63
|
public Object getAdapter(Class adapter) {
|
64
|
if (adapter == Group.class) {
|
65
|
return this.group;
|
66
|
}
|
67
|
|
68
|
return null;
|
69
|
}
|
70
|
/* (non-Javadoc)
|
71
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
72
|
*/
|
73
|
@Override
|
74
|
public void update(CdmDataChangeMap changeEvents) {
|
75
|
// TODO Auto-generated method stub
|
76
|
|
77
|
}
|
78
|
/* (non-Javadoc)
|
79
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
80
|
*/
|
81
|
@Override
|
82
|
public ConversationHolder getConversationHolder() {
|
83
|
return this.conversation;
|
84
|
}
|
85
|
/* (non-Javadoc)
|
86
|
* @see org.eclipse.ui.IEditorInput#exists()
|
87
|
*/
|
88
|
@Override
|
89
|
public boolean exists() {
|
90
|
return group != null;
|
91
|
}
|
92
|
/* (non-Javadoc)
|
93
|
* @see org.eclipse.ui.IEditorInput#getImageDescriptor()
|
94
|
*/
|
95
|
@Override
|
96
|
public ImageDescriptor getImageDescriptor() {
|
97
|
// TODO Auto-generated method stub
|
98
|
return null;
|
99
|
}
|
100
|
/* (non-Javadoc)
|
101
|
* @see org.eclipse.ui.IEditorInput#getName()
|
102
|
*/
|
103
|
@Override
|
104
|
public String getName() {
|
105
|
return group.getName();
|
106
|
}
|
107
|
/* (non-Javadoc)
|
108
|
* @see org.eclipse.ui.IEditorInput#getPersistable()
|
109
|
*/
|
110
|
@Override
|
111
|
public IPersistableElement getPersistable() {
|
112
|
// TODO Auto-generated method stub
|
113
|
return null;
|
114
|
}
|
115
|
/* (non-Javadoc)
|
116
|
* @see org.eclipse.ui.IEditorInput#getToolTipText()
|
117
|
*/
|
118
|
@Override
|
119
|
public String getToolTipText() {
|
120
|
return getName();
|
121
|
}
|
122
|
|
123
|
/* (non-Javadoc)
|
124
|
* @see java.lang.Object#equals(java.lang.Object)
|
125
|
*/
|
126
|
@Override
|
127
|
public boolean equals(Object object) {
|
128
|
if (object instanceof CdmAuthorityEditorInput
|
129
|
&& getGroup() != null
|
130
|
&& getGroup().equals(((CdmAuthorityEditorInput) object).getGroup())
|
131
|
){
|
132
|
return true;
|
133
|
}
|
134
|
return super.equals(object);
|
135
|
}
|
136
|
|
137
|
/**
|
138
|
* Getter method for group member.
|
139
|
*
|
140
|
* @return
|
141
|
*/
|
142
|
public Group getGroup() {
|
143
|
return this.group;
|
144
|
}
|
145
|
|
146
|
/* (non-Javadoc)
|
147
|
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
|
148
|
*/
|
149
|
@Override
|
150
|
public Collection<Group> getRootEntities() {
|
151
|
return Arrays.asList(group);
|
152
|
}
|
153
|
|
154
|
/* (non-Javadoc)
|
155
|
* @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
|
156
|
*/
|
157
|
@Override
|
158
|
public void merge() {
|
159
|
CdmStore.getService(IGroupService.class).merge(group);
|
160
|
}
|
161
|
}
|