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