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.taxon.TaxonBase;
|
16
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
17
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.RootElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
|
21
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
|
27
|
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
|
28
|
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
|
29
|
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
|
30
|
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
|
31
|
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
|
32
|
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
|
33
|
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
|
34
|
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
|
35
|
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
|
36
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
/**
|
42
|
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners.
|
43
|
*
|
44
|
* @author a.theys
|
45
|
* @created mar 13, 2012
|
46
|
* @version 1.0
|
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
|
//TODO Use the code below to move the useRecords view and UseRecordDetailElement into the details view.
|
110
|
DescriptionElementBase desc = ((DescriptionElementBase) getInput()).
|
111
|
|
112
|
} else if (getInput() instanceof TermVocabulary) {
|
113
|
createTermVocabularySection(rootElement);
|
114
|
|
115
|
}
|
116
|
|
117
|
/*if (getInput() instanceof TaxonBase) {
|
118
|
if (currentViewPart != VIEW_PART.TAXON) {
|
119
|
createTaxonSections(rootElement);
|
120
|
currentViewPart = VIEW_PART.TAXON;
|
121
|
}
|
122
|
} else if (getInput() instanceof Reference) {
|
123
|
if (currentViewPart != VIEW_PART.REFEERENCE) {
|
124
|
createReferenceSections(rootElement);
|
125
|
currentViewPart = VIEW_PART.REFEERENCE;
|
126
|
}
|
127
|
} else if (getInput() instanceof DescriptionBase) {
|
128
|
if (((DescriptionBase) getInput()).isImageGallery()) {
|
129
|
if (currentViewPart != VIEW_PART.IMAGE_GALLERY) {
|
130
|
createImageGallerySection(rootElement);
|
131
|
currentViewPart = VIEW_PART.IMAGE_GALLERY;
|
132
|
}
|
133
|
} else {
|
134
|
if (currentViewPart != VIEW_PART.DESCRIPTION) {
|
135
|
createDescriptionSection(rootElement);
|
136
|
currentViewPart = VIEW_PART.DESCRIPTION;
|
137
|
}
|
138
|
}
|
139
|
} else if (getInput() instanceof DescriptionElementBase) {
|
140
|
if (currentViewPart != VIEW_PART.DESCRIPTION_ELEMENT) {
|
141
|
createDescriptionElementSection(rootElement);
|
142
|
currentViewPart = VIEW_PART.DESCRIPTION_ELEMENT;
|
143
|
}
|
144
|
} else {
|
145
|
destroySections();
|
146
|
currentViewPart = VIEW_PART.EMPTY;
|
147
|
}
|
148
|
layout();
|
149
|
*/
|
150
|
}
|
151
|
private void createTaxonSections(RootElement parent) {
|
152
|
destroySections();
|
153
|
|
154
|
TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory
|
155
|
.createCdmDetailSection(DetailType.TAXONBASE,
|
156
|
getConversationHolder(), parent, this, Section.TWISTIE);
|
157
|
|
158
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
159
|
|
160
|
NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory
|
161
|
.createCdmDetailSection(DetailType.NONVIRALNAME,
|
162
|
getConversationHolder(), parent, this, Section.TWISTIE
|
163
|
| Section.EXPANDED);
|
164
|
|
165
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
166
|
|
167
|
NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory
|
168
|
.createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE,
|
169
|
getConversationHolder(), parent, this, Section.TWISTIE);
|
170
|
|
171
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
172
|
|
173
|
NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory
|
174
|
.createEntityDetailSection(
|
175
|
EntityDetailType.NOMENCLATURALSTATUS,
|
176
|
getConversationHolder(), parent, Section.TWISTIE);
|
177
|
|
178
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
179
|
|
180
|
ProtologueSection protologSection = (ProtologueSection) formFactory
|
181
|
.createEntityDetailSection(EntityDetailType.PROTOLOG,
|
182
|
getConversationHolder(), parent, Section.TWISTIE);
|
183
|
|
184
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
185
|
|
186
|
TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory
|
187
|
.createEntityDetailSection(EntityDetailType.TYPEDESIGNATION,
|
188
|
getConversationHolder(), parent, Section.TWISTIE);
|
189
|
|
190
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
191
|
|
192
|
NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory
|
193
|
.createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP,
|
194
|
getConversationHolder(), parent, Section.TWISTIE);
|
195
|
|
196
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
197
|
|
198
|
ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory
|
199
|
.createCdmDetailSection(DetailType.PARSINGMESSAGE,
|
200
|
getConversationHolder(), parent, this, Section.EXPANDED);
|
201
|
|
202
|
addPart(taxonBaseDetailSection);
|
203
|
addPart(nonViralNameSection);
|
204
|
addPart(nomenclaturalStatusSection);
|
205
|
addPart(protologSection);
|
206
|
addPart(referenceDetailSection);
|
207
|
addPart(typeDesignationSection);
|
208
|
addPart(nameRelationshipSection);
|
209
|
addPart(parsingMessagesSection);
|
210
|
}
|
211
|
|
212
|
private void createTermVocabularySection(RootElement parent) {
|
213
|
destroySections();
|
214
|
|
215
|
TermVocabularyDetailSection termVocabularyDetailSection = (TermVocabularyDetailSection) formFactory
|
216
|
.createCdmDetailSection(DetailType.TERM_VOCABULARY,
|
217
|
getConversationHolder(), parent, this, Section.TWISTIE
|
218
|
| Section.EXPANDED);
|
219
|
addPart(termVocabularyDetailSection);
|
220
|
}
|
221
|
|
222
|
private void createUseRecordSection(RootElement parent) {
|
223
|
destroySections();
|
224
|
|
225
|
UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
|
226
|
.createCdmDetailSection(DetailType.USE_RECORD,
|
227
|
getConversationHolder(), parent, this, Section.TWISTIE
|
228
|
| Section.EXPANDED);
|
229
|
|
230
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
231
|
|
232
|
addPart(descriptionUseRecordSection);
|
233
|
|
234
|
|
235
|
}
|
236
|
|
237
|
private void createUseSection(RootElement parent) {
|
238
|
destroySections();
|
239
|
DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
|
240
|
.createCdmDetailSection(DetailType.DESCRIPTION,
|
241
|
getConversationHolder(), parent, this, Section.TWISTIE
|
242
|
| Section.EXPANDED);
|
243
|
|
244
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
245
|
|
246
|
/*NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory
|
247
|
.createCdmDetailSection(DetailType.NATURAL_LANGUAGE,
|
248
|
getConversationHolder(), parent, this, Section.TWISTIE
|
249
|
| Section.EXPANDED);
|
250
|
|
251
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
252
|
|
253
|
DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory
|
254
|
.createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,
|
255
|
getConversationHolder(), parent, Section.TWISTIE);
|
256
|
|
257
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
|
258
|
|
259
|
DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
|
260
|
.createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
|
261
|
getConversationHolder(), parent, Section.TWISTIE);
|
262
|
|
263
|
/*formFactory.createHorizontalSeparator(parent, SWT.BORDER);
|
264
|
|
265
|
ScopeSection scopeSection = (ScopeSection) formFactory
|
266
|
.createEntityDetailSection(EntityDetailType.SCOPE,
|
267
|
getConversationHolder(), parent, Section.TWISTIE);
|
268
|
|
269
|
formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
|
270
|
|
271
|
addPart(descriptionDetailSection);
|
272
|
addPart(descriptionSourceSection);
|
273
|
|
274
|
}
|
275
|
|
276
|
|
277
|
|
278
|
private void createImageGallerySection(RootElement parent) {
|
279
|
destroySections();
|
280
|
DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
|
281
|
.createCdmDetailSection(DetailType.DESCRIPTION,
|
282
|
getConversationHolder(), parent, this, Section.TWISTIE
|
283
|
| Section.EXPANDED);
|
284
|
|
285
|
addPart(descriptionDetailSection);
|
286
|
}
|
287
|
|
288
|
private void createReferenceSections(RootElement parent) {
|
289
|
destroySections();
|
290
|
|
291
|
ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory
|
292
|
.createCdmDetailSection(DetailType.REFERENCEBASE,
|
293
|
getConversationHolder(), parent, this, Section.TWISTIE
|
294
|
| Section.EXPANDED);
|
295
|
|
296
|
addPart(referenceDetailSection);
|
297
|
|
298
|
}
|
299
|
@Override
|
300
|
public ISelection getSelection() {
|
301
|
return selection;
|
302
|
}
|
303
|
@Override
|
304
|
public void setSelection(ISelection selection, boolean reveal) {
|
305
|
this.selection = selection;
|
306
|
SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(
|
307
|
this, selection);
|
308
|
fireSelectionChanged(selectionChangedEvent);
|
309
|
}
|
310
|
|
311
|
}
|