1
|
package eu.etaxonomy.taxeditor.view.userecords;
|
2
|
|
3
|
import org.eclipse.jface.viewers.ISelection;
|
4
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
5
|
import org.eclipse.swt.SWT;
|
6
|
import org.eclipse.swt.widgets.Composite;
|
7
|
import org.eclipse.ui.forms.widgets.Section;
|
8
|
|
9
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
10
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
|
11
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
12
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
13
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
14
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
|
15
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
16
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
17
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
18
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.RootElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
|
27
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
|
28
|
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
|
29
|
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
|
30
|
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
|
31
|
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
|
32
|
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
|
33
|
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
|
34
|
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
|
35
|
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
|
36
|
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
|
37
|
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
|
38
|
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
|
39
|
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
|
40
|
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
|
41
|
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
|
42
|
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
|
43
|
|
44
|
|
45
|
|
46
|
|
47
|
|
48
|
public class UseRecordsViewer extends AbstractCdmDataViewer {
|
49
|
|
50
|
private ISelection selection;
|
51
|
|
52
|
public UseRecordsViewer(Composite parent, AbstractCdmViewPart viewPart) {
|
53
|
super(parent, viewPart);
|
54
|
}
|
55
|
|
56
|
// START HACK TO MAKE THE DERIVED UNIT FACADE WORK
|
57
|
// since we are getting implementations of DerivedUnitBase from the bulk
|
58
|
// editor
|
59
|
// and not derived unit facade objects,
|
60
|
|
61
|
/*
|
62
|
* (non-Javadoc)
|
63
|
*
|
64
|
* @see
|
65
|
* eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java
|
66
|
* .lang.Object)
|
67
|
*/
|
68
|
@Override
|
69
|
public void setInput(Object input) {
|
70
|
if (input instanceof DerivedUnitBase) {
|
71
|
try {
|
72
|
input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input,
|
73
|
PreferencesUtil.getDerivedUnitConfigurator());
|
74
|
} catch (DerivedUnitFacadeNotSupportedException e) {
|
75
|
StoreUtil.error(getClass(), e);
|
76
|
}
|
77
|
}
|
78
|
super.setInput(input);
|
79
|
}
|
80
|
|
81
|
@Override
|
82
|
protected void markViewPartDirty() {
|
83
|
if (getInput() instanceof DerivedUnitFacade) {
|
84
|
getViewPart().changed(
|
85
|
((DerivedUnitFacade) getInput()).innerDerivedUnit());
|
86
|
}
|
87
|
|
88
|
super.markViewPartDirty();
|
89
|
}
|
90
|
|
91
|
// END HACK TO MAKE THE DERIVED UNIT FACADE WORK
|
92
|
|
93
|
|
94
|
@Override
|
95
|
protected void showParts() {
|
96
|
if (getInput() instanceof TaxonBase) {
|
97
|
createTaxonSections(rootElement);
|
98
|
|
99
|
} else if (getInput() instanceof DescriptionBase) {
|
100
|
if (((DescriptionBase) getInput()).isImageGallery()) {
|
101
|
createImageGallerySection(rootElement);
|
102
|
|
103
|
} else {
|
104
|
createUseSection(rootElement);
|
105
|
|
106
|
}
|
107
|
} else if (getInput() instanceof DescriptionElementBase) {
|
108
|
createUseRecordSection(rootElement);
|
109
|
|
110
|
} else if (getInput() instanceof TermVocabulary) {
|
111
|
createTermVocabularySection(rootElement);
|
112
|
|
113
|
}
|
114
|
|
115
|
/*if (getInput() instanceof TaxonBase) {
|
116
|
if (currentViewPart != VIEW_PART.TAXON) {
|
117
|
createTaxonSections(rootElement);
|
118
|
currentViewPart = VIEW_PART.TAXON;
|
119
|
}
|
120
|
} else if (getInput() instanceof Reference) {
|
121
|
if (currentViewPart != VIEW_PART.REFEERENCE) {
|
122
|
createReferenceSections(rootElement);
|
123
|
currentViewPart = VIEW_PART.REFEERENCE;
|
124
|
}
|
125
|
} else if (getInput() instanceof DescriptionBase) {
|
126
|
if (((DescriptionBase) getInput()).isImageGallery()) {
|
127
|
if (currentViewPart != VIEW_PART.IMAGE_GALLERY) {
|
128
|
createImageGallerySection(rootElement);
|
129
|
currentViewPart = VIEW_PART.IMAGE_GALLERY;
|
130
|
}
|
131
|
} else {
|
132
|
if (currentViewPart != VIEW_PART.DESCRIPTION) {
|
133
|
createDescriptionSection(rootElement);
|
134
|
currentViewPart = VIEW_PART.DESCRIPTION;
|
135
|
}
|
136
|
}
|
137
|
} else if (getInput() instanceof DescriptionElementBase) {
|
138
|
if (currentViewPart != VIEW_PART.DESCRIPTION_ELEMENT) {
|
139
|
createDescriptionElementSection(rootElement);
|
140
|
currentViewPart = VIEW_PART.DESCRIPTION_ELEMENT;
|
141
|
}
|
142
|
} else {
|
143
|
destroySections();
|
144
|
currentViewPart = VIEW_PART.EMPTY;
|
145
|
}
|
146
|
layout();
|
147
|
*/
|
148
|
}
|
149
|
private void createTaxonSections(RootElement parent) {
|
150
|
destroySections();
|
151
|
|
152
|
TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory
|
153
|
.createCdmDetailSection(DetailType.TAXONBASE,
|
154
|
getConversationHolder(), parent, this, Section.TWISTIE);
|
155
|
|
156
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
157
|
|
158
|
NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory
|
159
|
.createCdmDetailSection(DetailType.NONVIRALNAME,
|
160
|
getConversationHolder(), parent, this, Section.TWISTIE
|
161
|
| Section.EXPANDED);
|
162
|
|
163
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
164
|
|
165
|
NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
|
166
|
.createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,
|
167
|
getConversationHolder(), parent, this, Section.TWISTIE);
|
168
|
|
169
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
170
|
|
171
|
NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
|
172
|
.createEntityDetailSection(
|
173
|
EntityDetailType.NOMENCLATURALSTATUS,
|
174
|
getConversationHolder(), parent, Section.TWISTIE);
|
175
|
|
176
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
177
|
|
178
|
ProtologueSection protologSection = (ProtologueSection) formFactory
|
179
|
.createEntityDetailSection(EntityDetailType.PROTOLOG,
|
180
|
getConversationHolder(), parent, Section.TWISTIE);
|
181
|
|
182
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
183
|
|
184
|
TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory
|
185
|
.createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,
|
186
|
getConversationHolder(), parent, Section.TWISTIE);
|
187
|
|
188
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
189
|
|
190
|
NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
|
191
|
.createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,
|
192
|
getConversationHolder(), parent, Section.TWISTIE);
|
193
|
|
194
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
195
|
|
196
|
ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory
|
197
|
.createCdmDetailSection(DetailType.PARSINGMESSAGE,
|
198
|
getConversationHolder(), parent, this, Section.EXPANDED);
|
199
|
|
200
|
addPart(taxonBaseDetailSection);
|
201
|
addPart(nonViralNameSection);
|
202
|
addPart(nomenclaturalStatusSection);
|
203
|
addPart(protologSection);
|
204
|
addPart(referenceDetailSection);
|
205
|
addPart(typeDesignationSection);
|
206
|
addPart(nameRelationshipSection);
|
207
|
addPart(parsingMessagesSection);
|
208
|
}
|
209
|
|
210
|
private void createTermVocabularySection(RootElement parent) {
|
211
|
destroySections();
|
212
|
|
213
|
TermVocabularyDetailSection termVocabularyDetailSection = (TermVocabularyDetailSection) formFactory
|
214
|
.createCdmDetailSection(DetailType.TERM_VOCABULARY,
|
215
|
getConversationHolder(), parent, this, Section.TWISTIE
|
216
|
| Section.EXPANDED);
|
217
|
addPart(termVocabularyDetailSection);
|
218
|
}
|
219
|
|
220
|
private void createUseRecordSection(RootElement parent) {
|
221
|
destroySections();
|
222
|
|
223
|
UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
|
224
|
.createCdmDetailSection(DetailType.USE_RECORD,
|
225
|
getConversationHolder(), parent, this, Section.TWISTIE
|
226
|
| Section.EXPANDED);
|
227
|
|
228
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
229
|
|
230
|
addPart(descriptionUseRecordSection);
|
231
|
|
232
|
|
233
|
}
|
234
|
|
235
|
private void createUseSection(RootElement parent) {
|
236
|
destroySections();
|
237
|
DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
|
238
|
.createCdmDetailSection(DetailType.DESCRIPTION,
|
239
|
getConversationHolder(), parent, this, Section.TWISTIE
|
240
|
| Section.EXPANDED);
|
241
|
|
242
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
243
|
|
244
|
/*NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory
|
245
|
.createCdmDetailSection(DetailType.NATURAL_LANGUAGE,
|
246
|
getConversationHolder(), parent, this, Section.TWISTIE
|
247
|
| Section.EXPANDED);
|
248
|
|
249
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
250
|
|
251
|
DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory
|
252
|
.createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,
|
253
|
getConversationHolder(), parent, Section.TWISTIE);
|
254
|
|
255
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
|
256
|
|
257
|
DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
|
258
|
.createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
|
259
|
getConversationHolder(), parent, Section.TWISTIE);
|
260
|
|
261
|
/*formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
262
|
|
263
|
ScopeSection scopeSection = (ScopeSection) formFactory
|
264
|
.createEntityDetailSection(EntityDetailType.SCOPE,
|
265
|
getConversationHolder(), parent, Section.TWISTIE);
|
266
|
|
267
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
|
268
|
|
269
|
addPart(descriptionDetailSection);
|
270
|
addPart(descriptionSourceSection);
|
271
|
|
272
|
}
|
273
|
|
274
|
|
275
|
|
276
|
private void createImageGallerySection(RootElement parent) {
|
277
|
destroySections();
|
278
|
DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
|
279
|
.createCdmDetailSection(DetailType.DESCRIPTION,
|
280
|
getConversationHolder(), parent, this, Section.TWISTIE
|
281
|
| Section.EXPANDED);
|
282
|
|
283
|
addPart(descriptionDetailSection);
|
284
|
}
|
285
|
|
286
|
private void createReferenceSections(RootElement parent) {
|
287
|
destroySections();
|
288
|
|
289
|
ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory
|
290
|
.createCdmDetailSection(DetailType.REFERENCEBASE,
|
291
|
getConversationHolder(), parent, this, Section.TWISTIE
|
292
|
| Section.EXPANDED);
|
293
|
|
294
|
addPart(referenceDetailSection);
|
295
|
|
296
|
}
|
297
|
@Override
|
298
|
public ISelection getSelection() {
|
299
|
return selection;
|
300
|
}
|
301
|
@Override
|
302
|
public void setSelection(ISelection selection, boolean reveal) {
|
303
|
this.selection = selection;
|
304
|
SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(
|
305
|
this, selection);
|
306
|
fireSelectionChanged(selectionChangedEvent);
|
307
|
}
|
308
|
|
309
|
}
|