Merge branch 'develop' into unify_derivative_views
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / detail / DetailsViewer.java
1
2 // $Id$
3 /**
4 * Copyright (C) 2011 EDIT
5 * European Distributed Institute of Taxonomy
6 * http://www.e-taxonomy.eu
7 *
8 * The contents of this file are subject to the Mozilla Public License Version 1.1
9 * See LICENSE.TXT at the top of this package for the full license terms.
10 */
11
12 package eu.etaxonomy.taxeditor.view.detail;
13
14 import java.util.Set;
15
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.jface.viewers.SelectionChangedEvent;
18 import org.eclipse.jface.viewers.TreeNode;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.ui.forms.widgets.ExpandableComposite;
22
23 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
24 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
25 import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
26 import eu.etaxonomy.cdm.model.agent.Person;
27 import eu.etaxonomy.cdm.model.agent.Team;
28 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
29 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
30 import eu.etaxonomy.cdm.model.common.Group;
31 import eu.etaxonomy.cdm.model.common.Marker;
32 import eu.etaxonomy.cdm.model.common.TermVocabulary;
33 import eu.etaxonomy.cdm.model.common.User;
34 import eu.etaxonomy.cdm.model.description.CategoricalData;
35 import eu.etaxonomy.cdm.model.description.DescriptionBase;
36 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
37 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
38 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
39 import eu.etaxonomy.cdm.model.media.Media;
40 import eu.etaxonomy.cdm.model.molecular.DnaSample;
41 import eu.etaxonomy.cdm.model.molecular.Sequence;
42 import eu.etaxonomy.cdm.model.molecular.SingleRead;
43 import eu.etaxonomy.cdm.model.name.NonViralName;
44 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
45 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
46 import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
47 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
48 import eu.etaxonomy.cdm.model.reference.Reference;
49 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
50 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
51 import eu.etaxonomy.taxeditor.model.AbstractUtility;
52 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
53 import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
54 import eu.etaxonomy.taxeditor.model.MessagingUtils;
55 import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
56 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
57 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
58 import eu.etaxonomy.taxeditor.store.UsageTermCollection;
59 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
60 import eu.etaxonomy.taxeditor.ui.element.RootElement;
61 import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
62 import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
63 import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
64 import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
65 import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
66 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
67 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
68 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
69 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
70 import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
71 import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
72 import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
73 import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
74 import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
75 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
76 import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
77 import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
78 import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
79 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
80 import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
81 import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
82 import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
83 import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
84 import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
85 import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
86 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
87 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
88 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
89 import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
90 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
91 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
92 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
93 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
94 import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
95 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
96 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
97 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
98 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
99 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
100 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
101 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
102 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
103 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
104 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
105 import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
106 import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
107 import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
108 import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
109 import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
110 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
111 import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
112 import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
113 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
114 import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
115 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
116 import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
117 import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
118
119 /**
120 *
121 * The DetailsViewer handles the content of the details view (
122 * {@link DetailsViewPart}).<br>
123 * Depending on the type of the selected element the section of the details view
124 * are created.
125 *
126 * @author n.hoffmann
127 * @created Feb 12, 2010
128 * @version 1.0
129 */
130 public class DetailsViewer extends AbstractCdmDataViewer {
131
132 private ISelection selection;
133
134 public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
135 super(parent, viewPart);
136 }
137
138 // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
139 // since we are getting implementations of DerivedUnitBase from the bulk
140 // editor
141 // and not derived unit facade objects,
142
143 @Override
144 public void setInput(Object input) {
145 if(input instanceof TreeNode){
146 input = ((TreeNode) input).getValue();
147 }
148 if(input instanceof GbifResponse){
149 input = ((GbifResponse) input).getDerivedUnitFacade();
150 }
151 if (input.getClass().equals(DerivedUnit.class)) {
152 DerivedUnit derivedUnit = (DerivedUnit)input;
153 try {
154 input = DerivedUnitFacade.NewInstance(derivedUnit,
155 PreferencesUtil.getDerivedUnitConfigurator());
156 } catch (DerivedUnitFacadeNotSupportedException e) {
157 // MessagingUtils.error(getClass(), e); //nothing should happen, later on the Details View will show an according information that it is not possible to open this data
158 }
159 }
160 else if(input instanceof FieldUnit){
161 input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input);
162 }
163 super.setInput(input);
164 }
165
166 @Override
167 protected void markViewPartDirty() {
168 if (getInput() instanceof DerivedUnitFacade) {
169 DerivedUnitFacade facade = (DerivedUnitFacade) getInput();
170 if(facade.innerDerivedUnit()!=null){
171 getViewPart().changed(facade.innerDerivedUnit());
172 }
173 else if(facade.innerFieldUnit()!=null){
174 getViewPart().changed(facade.innerFieldUnit());
175 }
176 }
177 else{
178 super.markViewPartDirty();
179 }
180 }
181
182 // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
183
184
185 /** {@inheritDoc} */
186 @Override
187 protected void showParts() {
188 // FIXME (CM) : Need to clean out this code.
189 // Too much type checking to decide which detail view to display.
190 // Need to build in a mechanism where navigators / editors are 'aware'
191 // of the corresponding detail viewer.
192 Object input = getInput();
193
194 destroySections();
195 if (input instanceof TaxonBase) {
196 if(((TaxonBase) input).getName()==null){
197 createEmptySection(rootElement);
198 }
199 else{
200 createTaxonSections(rootElement);
201 }
202
203 } else if (input instanceof NonViralName) {
204 createNameSections(rootElement);
205
206 } else if (input instanceof Reference) {
207 createReferenceSections(rootElement);
208
209 } else if (input instanceof Team) {
210 createTeamDetailSection(rootElement);
211
212 } else if (input instanceof Person) {
213 createPersonDetailSection(rootElement);
214
215 } else if (input instanceof TeamOrPersonBase) {
216 createTeamOrPersonBaseDetailSection(rootElement);
217
218 } else if (input instanceof DescriptionBase) {
219 if(input instanceof SpecimenDescription){
220 //TODO: add more sections to DetailsView for SpecimenDescription
221 createSpecimenDescriptionSection(rootElement);
222 }
223 else{
224 Set<Marker> descriptionMarkers = ((DescriptionBase<?>) input).getMarkers();
225
226 Boolean isUseDescription = false;
227 for (Marker marker : descriptionMarkers) {
228 if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
229 isUseDescription = true;
230 }
231 }
232 if (((DescriptionBase<?>) input).isImageGallery()) {
233 createImageGallerySection(rootElement);
234
235 } else if (isUseDescription) {
236 createUseDescriptionSection(rootElement);
237 } else {
238 createDescriptionSection(rootElement);
239
240 }
241 }
242 } else if (input instanceof DescriptionElementBase) {
243 Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
244
245 Boolean isUseDescription = false;
246 for (Marker marker : descriptionMarkers) {
247 if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
248 isUseDescription = true;
249 }
250 }
251
252 if (isUseDescription == true && input instanceof CategoricalData) {
253 createUseRecordSection(rootElement);
254 } else {
255 createDescriptionElementSection(rootElement);
256 }
257
258 } else if (input instanceof Media) {
259 createMediaElementSection(rootElement);
260
261 } else if (input instanceof DerivedUnitFacade) {
262 if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.FieldUnit){
263 if(((DerivedUnitFacade) input).innerFieldUnit()==null){
264 MessagingUtils.error(DetailsViewer.class, "FieldUnit of facade is null", null);
265 }
266 else{
267 createFieldUnitSection(rootElement);
268 }
269 }
270 else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.PreservedSpecimen){
271 if(((DerivedUnitFacade) input).innerDerivedUnit()==null){
272 MessagingUtils.error(DetailsViewer.class, "DerivedUnit of facade is null", null);
273 }
274 else{
275 createDerivedUnitBaseElementSection(rootElement);
276 }
277 }
278 else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.TissueSample){
279 //TissueSample should only be created by using it's own class
280 //in future using only one class with different SpecimenOrObservationTypes is desired
281 // createTissueSampleSection(rootElement);
282 }
283 else{
284 createDerivedUnitBaseElementSection(rootElement);
285 }
286 } else if (input instanceof DnaSample){
287 DnaSample dnaSample = (DnaSample)input;
288 if(dnaSample.getRecordBasis()==SpecimenOrObservationType.TissueSample){
289 createTissueSampleSection(rootElement);
290 }
291 else if(dnaSample.getRecordBasis()==SpecimenOrObservationType.DnaSample){
292 createDnaSampleSection(rootElement);
293 }
294 } else if (input instanceof MediaSpecimen){
295 createMediaSpecimenSection(rootElement);
296 }
297 else if(input instanceof Sequence){
298 createSequenceSection(rootElement);
299 }
300 else if(input instanceof SingleRead){
301 createSingleReadSection(rootElement);
302 }
303 else if (input instanceof FeatureNodeContainer) {
304 createFeatureDistributionSection(rootElement);
305
306 }else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
307 createPolytomousKeyNodeSection(rootElement);
308 } else if (input instanceof User) {
309 createUserSection(rootElement);
310 } else if (input instanceof Group) {
311 createGroupSection(rootElement);
312 } else if (input instanceof TaxonRelationship) {
313 createTaxonRelationshipSection(rootElement);
314 } else if (input instanceof TermVocabulary) {
315 createTermVocabularySection(rootElement);
316 } else if (input instanceof DefinedTermBase) {
317 createDefinedTermSection(rootElement);
318 }
319 else {
320 createEmptySection(rootElement);
321 }
322 layout();
323 }
324
325
326 private void createEmptySection(RootElement parent) {
327 destroySections();
328
329 EmptySection emptySection = formFactory.createEmptySection(formFactory, parent, SWT.NONE);
330
331 addPart(emptySection);
332 }
333
334 private void createGroupSection(RootElement parent) {
335 destroySections();
336
337 GroupDetailSection groupDetailSection = formFactory.createGroupDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED);
338 MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
339 GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
340
341 addPart(groupDetailSection);
342 addPart(memberDetailSection);
343 addPart(grantedAuthorityDetailSection);
344 }
345
346 /** {@inheritDoc} */
347 @Override
348 public ISelection getSelection() {
349 return selection;
350 }
351
352 /** {@inheritDoc} */
353 @Override
354 public void setSelection(ISelection selection, boolean reveal) {
355 this.selection = selection;
356 if(this.selection!=null){
357 SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
358 fireSelectionChanged(selectionChangedEvent);
359 }
360 }
361
362 private void createTaxonSections(RootElement parent) {
363 destroySections();
364
365 ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
366 ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
367
368 TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
369 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
370 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
371
372 NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
373 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
374 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
375
376 NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
377 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
378 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
379
380 NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
381 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
382 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
383
384 //TODO RL
385 if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
386 ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
387 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
388
389 TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
390 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
391
392 NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
393 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
394
395 addPart(protologSection);
396 addPart(typeDesignationSection);
397 addPart(nameRelationshipSection);
398 }
399
400 addPart(parsingMessagesSection);
401 addPart(taxonBaseDetailSection);
402 addPart(nonViralNameSection);
403 addPart(nomenclaturalStatusSection);
404 addPart(referenceDetailSection);
405 }
406
407 private void createNameSections(RootElement parent) {
408 destroySections();
409 NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
410 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
411 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
412
413 NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
414 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
415 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
416
417 NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
418 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
419 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
420
421 addPart(nonViralNameSection);
422 addPart(nomenclaturalStatusSection);
423 addPart(referenceDetailSection);
424 //TODO RL
425 if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
426 ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
427 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
428
429 TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
430 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
431
432 NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
433 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
434 addPart(protologSection);
435 addPart(typeDesignationSection);
436 addPart(nameRelationshipSection);
437 }
438 }
439
440 private void createReferenceSections(RootElement parent) {
441 destroySections();
442
443 ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
444 ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
445
446 addPart(referenceDetailSection);
447 }
448
449 private void createTeamOrPersonBaseDetailSection(RootElement parent) {
450 destroySections();
451 TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
452
453 addPart(teamOrPersonBaseDetailSection);
454 }
455
456 private void createTeamDetailSection(RootElement parent) {
457 destroySections();
458 TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
459
460 addPart(teamDetailSection);
461 }
462
463 private void createPersonDetailSection(RootElement parent) {
464 destroySections();
465 PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
466 addPart(personDetailSection);
467 }
468
469 private void createDescriptionElementSection(RootElement parent) {
470 destroySections();
471
472 DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
473
474 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
475
476 DescriptionElementSourceSection descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
477
478 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
479
480 DescriptionElementMediaSection descriptionElementMediaSection = formFactory.createDescriptionElementMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
481
482 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
483
484 addPart(descriptionElementDetailSection);
485 addPart(descriptionElementSourceSection);
486 addPart(descriptionElementMediaSection);
487 }
488
489 private void createDescriptionSection(RootElement parent) {
490 destroySections();
491 DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
492
493 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
494
495 NaturalLanguageSection naturalLanguageSection = formFactory.createNaturalLanguageSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
496
497 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
498
499 DescribedSpecimenSection describedSpecimenSection = formFactory.createDescribedSpecimenSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
500
501 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
502
503 // DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
504 // .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
505 // getConversationHolder(), parent, Section.TWISTIE);
506 //
507 // formFactory.createHorizontalSeparator(parent, SWT.BORDER);
508
509 ScopeSection scopeSection = formFactory.createScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
510
511 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
512
513 addPart(descriptionDetailSection);
514 addPart(naturalLanguageSection);
515 addPart(describedSpecimenSection);
516 // addPart(descriptionSourceSection);
517 addPart(scopeSection);
518 }
519
520 private void createSpecimenDescriptionSection(RootElement parent) {
521 destroySections();
522 DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
523 addPart(descriptionDetailSection);
524 }
525
526 private void createUseDescriptionSection(RootElement parent) {
527 destroySections();
528 DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
529
530 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
531
532 DescriptionSourceSection descriptionSourceSection = formFactory.createDescriptionSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
533
534 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
535
536 addPart(descriptionDetailSection);
537 addPart(descriptionSourceSection);
538
539 }
540
541 private void createImageGallerySection(RootElement parent) {
542 destroySections();
543 DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
544
545 addPart(descriptionDetailSection);
546 }
547
548 private void createMediaElementSection(RootElement parent) {
549 destroySections();
550
551 MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
552
553 addPart(mediaDetailSection);
554 }
555
556 private void createDerivedUnitBaseElementSection(RootElement parent) {
557 destroySections();
558
559 DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
560 //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
561 if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
562 derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
563 }
564 addPart(derivedUnitGeneralDetailSection);
565
566 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
567
568 DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
569 addPart(derivedUnitBaseDetailSection);
570
571 //for editors working with facades
572 if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
573 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
574 GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
575 addPart(gatheringEventDetailSection);
576
577 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
578 FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
579 addPart(fieldUnitDetailSection);
580 }
581 else{
582
583 if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS)){
584 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
585 TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
586 addPart(taxonAssociationDetailSection);
587 }
588 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
589 IdentifierDetailSection identifierDetailSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
590 addPart(identifierDetailSection);
591 }
592 if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
593 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
594 DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
595 addPart(determinationDetailSection);
596 }
597
598 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
599 DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
600 addPart(derivedUnitTypeDesignationSection);
601
602 }
603
604 private void createFieldUnitSection(RootElement parent) {
605 destroySections();
606
607 FieldUnitGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
608
609 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
610
611 GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
612
613 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
614
615 FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
616
617 addPart(fielUnitGeneralDetailSection);
618 addPart(gatheringEventDetailSection);
619 addPart(fieldUnitDetailSection);
620
621 if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
622 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
623 DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
624 addPart(determinationDetailSection);
625 }
626 }
627
628 private void createTissueSampleSection(RootElement parent) {
629 destroySections();
630
631 TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
632
633 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
634
635 SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
636
637 addPart(section);
638 addPart(sampleDesignationDetailSection);
639 }
640
641 private void createDnaSampleSection(RootElement parent) {
642 destroySections();
643
644 DnaSampleGeneralDetailSection section = formFactory.createDnaSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
645
646 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
647
648 DnaSamplePreparationPreservationSection preparationPreservationSection = formFactory.createDnaSamplePreparationPreservationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
649
650 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
651
652 DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
653
654 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
655
656 SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
657
658 addPart(section);
659 addPart(preparationPreservationSection);
660 addPart(qualitySection);
661 addPart(sampleDesignationDetailSection);
662 }
663
664 private void createSequenceSection(RootElement parent) {
665 destroySections();
666
667 SequenceGeneralDetailSection section = formFactory.createSequenceGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
668
669 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
670
671 SequenceReferenceCollectionDetailSection referenceSection = formFactory.createSequenceReferenceCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
672
673 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
674
675 SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
676
677
678 addPart(section);
679 addPart(referenceSection);
680 addPart(contigFileSection);
681 }
682
683 private void createSingleReadSection(RootElement parent) {
684 destroySections();
685
686 SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
687 addPart(section);
688
689 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
690
691 SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
692 addPart(pherogramSection);
693
694 }
695
696 private void createMediaSpecimenSection(RootElement parent) {
697 destroySections();
698
699 MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
700 addPart(generalSection);
701
702 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
703
704 RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
705 addPart(rightsSection);
706
707 }
708
709 private void createFeatureDistributionSection(RootElement parent) {
710 destroySections();
711
712 FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
713
714 addPart(featureDistributionSection);
715 }
716
717 private void createPolytomousKeyNodeSection(RootElement parent) {
718 destroySections();
719
720 PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
721
722 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
723
724 PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
725
726 addPart(polytomousKeyDetailSection);
727 addPart(polytomousKeyNodeDetailSection);
728
729 }
730
731 private void createUseRecordSection(RootElement parent) {
732 destroySections();
733
734 UseRecordDetailSection descriptionUseRecordSection = formFactory.createUseRecordDetailSection(getConversationHolder(), parent, this,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
735
736 formFactory.createHorizontalSeparator(parent, SWT.BORDER);
737
738 addPart(descriptionUseRecordSection);
739
740
741 }
742
743 private void createUserSection(RootElement parent) {
744 destroySections();
745
746 UserDetailSection userDetailSection = formFactory.createUserDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
747
748 GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
749
750 addPart(userDetailSection);
751 addPart(groupByUserDetailSection);
752 }
753
754 private void createTaxonRelationshipSection(RootElement parent) {
755 destroySections();
756
757 TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
758
759 ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
760 addPart(taxonRelationshipDetailSection);
761 addPart(referencedEntityBaseDetailSection);
762 }
763
764 private void createTermVocabularySection(RootElement parent) {
765 destroySections();
766
767 TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
768 addPart(termVocabularyDetailSection);
769 }
770
771 private void createDefinedTermSection(RootElement parent) {
772 destroySections();
773
774 AbstractFormSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
775 addPart(definedTermDetailSection);
776 }
777
778 }