Project

General

Profile

Download (40.6 KB) Statistics
| Branch: | Tag: | Revision:
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.api.service.ITermService;
26
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
27
import eu.etaxonomy.cdm.model.agent.Person;
28
import eu.etaxonomy.cdm.model.agent.Team;
29
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
30
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
31
import eu.etaxonomy.cdm.model.common.Group;
32
import eu.etaxonomy.cdm.model.common.Marker;
33
import eu.etaxonomy.cdm.model.common.MarkerType;
34
import eu.etaxonomy.cdm.model.common.TermVocabulary;
35
import eu.etaxonomy.cdm.model.common.User;
36
import eu.etaxonomy.cdm.model.description.CategoricalData;
37
import eu.etaxonomy.cdm.model.description.DescriptionBase;
38
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
39
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
40
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
41
import eu.etaxonomy.cdm.model.media.Media;
42
import eu.etaxonomy.cdm.model.molecular.DnaSample;
43
import eu.etaxonomy.cdm.model.molecular.Sequence;
44
import eu.etaxonomy.cdm.model.molecular.SingleRead;
45
import eu.etaxonomy.cdm.model.name.NonViralName;
46
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
47
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
48
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
49
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
50
import eu.etaxonomy.cdm.model.reference.Reference;
51
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
52
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
53
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
54
import eu.etaxonomy.taxeditor.model.AbstractUtility;
55
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
56
import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
57
import eu.etaxonomy.taxeditor.model.MessagingUtils;
58
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
59
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
60
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
61
import eu.etaxonomy.taxeditor.store.CdmStore;
62
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
63
import eu.etaxonomy.taxeditor.ui.element.RootElement;
64
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
65
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
66
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
67
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
68
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection;
69
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
70
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
71
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
72
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
73
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
74
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
75
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
76
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
77
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
78
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
79
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
80
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
81
import eu.etaxonomy.taxeditor.ui.section.identifier.IdentifierDetailSection;
82
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
83
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
84
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
85
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
86
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
87
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
88
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
89
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
90
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
91
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
92
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
93
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
94
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
95
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
96
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
97
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
98
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
99
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
100
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
101
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
102
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
103
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
104
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
105
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
106
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
107
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
108
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
109
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
110
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
111
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
112
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
113
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
114
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
115
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
116
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
117
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
118
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
119
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
120
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
121

    
122
/**
123
 *
124
 * The DetailsViewer handles the content of the details view (
125
 * {@link DetailsViewPart}).<br>
126
 * Depending on the type of the selected element the section of the details view
127
 * are created.
128
 *
129
 * @author n.hoffmann
130
 * @created Feb 12, 2010
131
 * @version 1.0
132
 */
133
public class DetailsViewer extends AbstractCdmDataViewer {
134

    
135
    private ISelection selection;
136

    
137
    /**
138
     * <p>
139
     * Constructor for DetailsViewer.
140
     * </p>
141
     *
142
     * @param parent
143
     *            a {@link org.eclipse.swt.widgets.Composite} object.
144
     * @param viewPart
145
     *            a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart}
146
     *            object.
147
     */
148
    public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
149
        super(parent, viewPart);
150
    }
151

    
152
    // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
153
    // since we are getting implementations of DerivedUnitBase from the bulk
154
    // editor
155
    // and not derived unit facade objects,
156

    
157
    /*
158
     * (non-Javadoc)
159
     *
160
     * @see
161
     * eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java
162
     * .lang.Object)
163
     */
164
    @Override
165
    public void setInput(Object input) {
166
        if(input instanceof TreeNode){
167
            input = ((TreeNode) input).getValue();
168
        }
169
        if(input instanceof GbifResponse){
170
            input = ((GbifResponse) input).getDerivedUnitFacade();
171
        }
172
        if (input.getClass().equals(DerivedUnit.class)) {
173
            DerivedUnit derivedUnit = (DerivedUnit)input;
174
            try {
175
                input = DerivedUnitFacade.NewInstance(derivedUnit,
176
                        PreferencesUtil.getDerivedUnitConfigurator());
177
            } catch (DerivedUnitFacadeNotSupportedException e) {
178
//                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
179
            }
180
        }
181
        else if(input instanceof FieldUnit){
182
            input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input);
183
        }
184
        super.setInput(input);
185
    }
186

    
187
    @Override
188
    protected void markViewPartDirty() {
189
        if (getInput() instanceof DerivedUnitFacade) {
190
            DerivedUnitFacade facade = (DerivedUnitFacade) getInput();
191
            if(facade.innerDerivedUnit()!=null){
192
                getViewPart().changed(facade.innerDerivedUnit());
193
            }
194
            else if(facade.innerFieldUnit()!=null){
195
                getViewPart().changed(facade.innerFieldUnit());
196
            }
197
        }
198
        else{
199
            super.markViewPartDirty();
200
        }
201
    }
202

    
203
    // END HACK TO MAKE THE DERIVED UNIT FACADE WORK
204

    
205
    /*
206
     * (non-Javadoc)
207
     *
208
     * @see org.eclipse.jface.viewers.Viewer#refresh()
209
     */
210
    /** {@inheritDoc} */
211
    @Override
212
    protected void showParts() {
213
        // FIXME (CM) : Need to clean out this code.
214
        // Too much type checking to decide which detail view to display.
215
        // Need to build in a mechanism where navigators / editors are 'aware'
216
        // of the corresponding detail viewer.
217
        Object input = getInput();
218

    
219
        destroySections();
220
        if (input instanceof TaxonBase) {
221
            createTaxonSections(rootElement);
222

    
223
        } else if (input instanceof NonViralName) {
224
            createNameSections(rootElement);
225

    
226
        } else if (input instanceof Reference) {
227
            createReferenceSections(rootElement);
228

    
229
        } else if (input instanceof Team) {
230
            createTeamDetailSection(rootElement);
231

    
232
        } else if (input instanceof Person) {
233
            createPersonDetailSection(rootElement);
234

    
235
        } else if (input instanceof TeamOrPersonBase) {
236
            createTeamOrPersonBaseDetailSection(rootElement);
237

    
238
        } else if (input instanceof DescriptionBase) {
239
            if(input instanceof SpecimenDescription){
240
                //TODO: add more sections to DetailsView for SpecimenDescription
241
                createSpecimenDescriptionSection(rootElement);
242
            }
243
            else{
244
                Set<Marker> descriptionMarkers = ((DescriptionBase<?>) input).getMarkers();
245
                MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
246
                        UsageTermCollection.uuidUseMarkerType);
247
                Boolean isUseDescription = false;
248
                for (Marker marker : descriptionMarkers) {
249
                    if (marker.getMarkerType().equals(useMarkertype)) {
250
                        isUseDescription = true;
251
                    }
252
                }
253
                if (((DescriptionBase<?>) input).isImageGallery()) {
254
                    createImageGallerySection(rootElement);
255

    
256
                } else if (isUseDescription) {
257
                    createUseDescriptionSection(rootElement);
258
                } else {
259
                    createDescriptionSection(rootElement);
260

    
261
                }
262
            }
263
        } else if (input instanceof DescriptionElementBase) {
264
            Set<Marker> descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
265
            MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(
266
                    UsageTermCollection.uuidUseMarkerType);
267
            Boolean isUseDescription = false;
268
            for (Marker marker : descriptionMarkers) {
269
                if (marker.getMarkerType().equals(useMarkertype)) {
270
                    isUseDescription = true;
271
                }
272
            }
273

    
274
            if (isUseDescription == true && input instanceof CategoricalData) {
275
                createUseRecordSection(rootElement);
276
            } else {
277
                createDescriptionElementSection(rootElement);
278
            }
279

    
280
        } else if (input instanceof Media) {
281
            createMediaElementSection(rootElement);
282

    
283
        } else if (input instanceof DerivedUnitFacade) {
284
            if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.FieldUnit){
285
                if(((DerivedUnitFacade) input).innerFieldUnit()==null){
286
                    MessagingUtils.error(DetailsViewer.class, "FieldUnit of facade is null", null);
287
                }
288
                else{
289
                    createFieldUnitSection(rootElement);
290
                }
291
            }
292
            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.PreservedSpecimen){
293
                if(((DerivedUnitFacade) input).innerDerivedUnit()==null){
294
                    MessagingUtils.error(DetailsViewer.class, "DerivedUnit of facade is null", null);
295
                }
296
                else{
297
                    createDerivedUnitBaseElementSection(rootElement);
298
                }
299
            }
300
            else if(((DerivedUnitFacade) input).getType()==SpecimenOrObservationType.TissueSample){
301
                //TissueSample should only be created by using it's own class
302
                //in future using only one class with different SpecimenOrObservationTypes is desired
303
//                createTissueSampleSection(rootElement);
304
            }
305
            else{
306
                createDerivedUnitBaseElementSection(rootElement);
307
            }
308
        } else if (input instanceof DnaSample){
309
            DnaSample dnaSample = (DnaSample)input;
310
            if(dnaSample.getRecordBasis()==SpecimenOrObservationType.TissueSample){
311
                createTissueSampleSection(rootElement);
312
            }
313
            else if(dnaSample.getRecordBasis()==SpecimenOrObservationType.DnaSample){
314
                createDnaSampleSection(rootElement);
315
            }
316
        } else if (input instanceof MediaSpecimen){
317
            createMediaSpecimenSection(rootElement);
318
        }
319
        else if(input instanceof Sequence){
320
            createSequenceSection(rootElement);
321
        }
322
        else if(input instanceof SingleRead){
323
            createSingleReadSection(rootElement);
324
        }
325
        else if (input instanceof FeatureNodeContainer) {
326
            createFeatureDistributionSection(rootElement);
327

    
328
        }else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
329
            createPolytomousKeyNodeSection(rootElement);
330
        } else if (input instanceof User) {
331
            createUserSection(rootElement);
332
        } else if (input instanceof Group) {
333
            createGroupSection(rootElement);
334
        } else if (input instanceof TaxonRelationship) {
335
            createTaxonRelationshipSection(rootElement);
336
        } else if (input instanceof TermVocabulary) {
337
            createTermVocabularySection(rootElement);
338
        } else if (input instanceof DefinedTermBase) {
339
            createDefinedTermSection(rootElement);
340
        }
341
        else {
342
            createEmptySection(rootElement);
343
        }
344
        layout();
345
    }
346

    
347

    
348
    /**
349
     * @param rootElement
350
     */
351
    private void createEmptySection(RootElement parent) {
352
        destroySections();
353

    
354
        EmptySection emptySection = formFactory.createEmptySection(formFactory, parent, SWT.NONE);
355

    
356
        addPart(emptySection);
357
    }
358

    
359
    /**
360
     * @param rootElement
361
     */
362
    private void createGroupSection(RootElement parent) {
363
        destroySections();
364

    
365
        GroupDetailSection groupDetailSection = formFactory.createGroupDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED);
366
        MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
367
        GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
368

    
369
        addPart(groupDetailSection);
370
        addPart(memberDetailSection);
371
        addPart(grantedAuthorityDetailSection);
372
    }
373

    
374
    /*
375
     * (non-Javadoc)
376
     *
377
     * @see org.eclipse.jface.viewers.Viewer#getSelection()
378
     */
379
    /** {@inheritDoc} */
380
    @Override
381
    public ISelection getSelection() {
382
        return selection;
383
    }
384

    
385
    /*
386
     * (non-Javadoc)
387
     *
388
     * @see
389
     * org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers
390
     * .ISelection, boolean)
391
     */
392
    /** {@inheritDoc} */
393
    @Override
394
    public void setSelection(ISelection selection, boolean reveal) {
395
        this.selection = selection;
396
        if(this.selection!=null){
397
            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
398
            fireSelectionChanged(selectionChangedEvent);
399
        }
400
    }
401

    
402
    /**
403
     * createTaxonSections(RootElement parent)
404
     *
405
     * @param parent
406
     */
407
    private void createTaxonSections(RootElement parent) {
408
        destroySections();
409

    
410
        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
411
                ExpandableComposite.EXPANDED | ExpandableComposite.EXPANDED);
412

    
413
        TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
414
        		ExpandableComposite.TWISTIE	| ExpandableComposite.EXPANDED);
415
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
416

    
417
        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
418
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
419
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
420

    
421
        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
422
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
423
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
424

    
425
        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
426
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
427
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
428

    
429
        //TODO RL
430
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
431
	        ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
432
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
433

    
434
	        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
435
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
436

    
437
	        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
438
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
439

    
440
			addPart(protologSection);
441
			addPart(typeDesignationSection);
442
			addPart(nameRelationshipSection);
443
        }
444

    
445

    
446
        addPart(parsingMessagesSection);
447
        addPart(taxonBaseDetailSection);
448
        addPart(nonViralNameSection);
449
        addPart(nomenclaturalStatusSection);
450
        addPart(referenceDetailSection);
451
    }
452

    
453
    /**
454
     * createNameSections
455
     *
456
     * @param parent
457
     */
458
    private void createNameSections(RootElement parent) {
459
        destroySections();
460
        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
461
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
462
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
463

    
464
        NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
465
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
466
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
467

    
468
        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
469
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
470
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
471

    
472
        addPart(nonViralNameSection);
473
        addPart(nomenclaturalStatusSection);
474
        addPart(referenceDetailSection);
475
//TODO RL
476
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
477
			ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
478
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
479

    
480
	        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
481
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
482

    
483
	        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
484
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
485
	        addPart(protologSection);
486
	        addPart(typeDesignationSection);
487
	        addPart(nameRelationshipSection);
488
        }
489
    }
490

    
491
    /**
492
     * createReferenceSections
493
     *
494
     * @param parent
495
     */
496
    private void createReferenceSections(RootElement parent) {
497
        destroySections();
498

    
499
        ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
500
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
501

    
502
        addPart(referenceDetailSection);
503
    }
504

    
505
    /**
506
     * createTeamOrPersonBaseDetailSection
507
     *
508
     * @param parent
509
     */
510
    private void createTeamOrPersonBaseDetailSection(RootElement parent) {
511
        destroySections();
512
        TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
513

    
514
        addPart(teamOrPersonBaseDetailSection);
515
    }
516

    
517
    /**
518
     * createTeamDetailSection
519
     *
520
     * @param parent
521
     */
522
    private void createTeamDetailSection(RootElement parent) {
523
        destroySections();
524
        TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
525

    
526
        addPart(teamDetailSection);
527
    }
528

    
529
    /**
530
     * createPersonDetailSection
531
     *
532
     * @param parent
533
     */
534
    private void createPersonDetailSection(RootElement parent) {
535
        destroySections();
536
        PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
537
        addPart(personDetailSection);
538
    }
539

    
540
    /**
541
     * createDescriptionElementSection
542
     *
543
     * @param parent
544
     */
545
    private void createDescriptionElementSection(RootElement parent) {
546
        destroySections();
547

    
548
        DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
549

    
550
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
551

    
552
        DescriptionElementSourceSection descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
553

    
554
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
555

    
556
        DescriptionElementMediaSection descriptionElementMediaSection = formFactory.createDescriptionElementMediaSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
557

    
558
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
559

    
560
        addPart(descriptionElementDetailSection);
561
        addPart(descriptionElementSourceSection);
562
        addPart(descriptionElementMediaSection);
563
    }
564

    
565
    /**
566
     * createDescriptionSection
567
     *
568
     * @param parent
569
     */
570
    private void createDescriptionSection(RootElement parent) {
571
        destroySections();
572
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
573

    
574
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
575

    
576
        NaturalLanguageSection naturalLanguageSection = formFactory.createNaturalLanguageSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
577

    
578
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
579

    
580
        DescribedSpecimenSection describedSpecimenSection = formFactory.createDescribedSpecimenSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
581

    
582
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
583

    
584
        //		DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
585
        //				.createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
586
        //						getConversationHolder(), parent, Section.TWISTIE);
587
        //
588
        //		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
589

    
590
        ScopeSection scopeSection = formFactory.createScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
591

    
592
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
593

    
594
        addPart(descriptionDetailSection);
595
        addPart(naturalLanguageSection);
596
        addPart(describedSpecimenSection);
597
        //		addPart(descriptionSourceSection);
598
        addPart(scopeSection);
599
    }
600

    
601
    /**
602
     * createDescriptionSection
603
     *
604
     * @param parent
605
     */
606
    private void createSpecimenDescriptionSection(RootElement parent) {
607
        destroySections();
608
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
609
        addPart(descriptionDetailSection);
610
    }
611

    
612
    /**
613
     * Creates the use Description section
614
     *
615
     * @param parent
616
     */
617
    private void createUseDescriptionSection(RootElement parent) {
618
        destroySections();
619
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
620

    
621
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
622

    
623
        DescriptionSourceSection descriptionSourceSection = formFactory.createDescriptionSourceSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
624

    
625
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
626

    
627
        addPart(descriptionDetailSection);
628
        addPart(descriptionSourceSection);
629

    
630
    }
631

    
632

    
633
    /**
634
     * @param rootElement
635
     */
636
    private void createImageGallerySection(RootElement parent) {
637
        destroySections();
638
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
639

    
640
        addPart(descriptionDetailSection);
641
    }
642

    
643
    /**
644
     * createMediaElementSection
645
     *
646
     * @param parent
647
     */
648

    
649
    private void createMediaElementSection(RootElement parent) {
650
        destroySections();
651

    
652
        MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
653

    
654
        addPart(mediaDetailSection);
655
    }
656

    
657
    /**
658
     * createDerivedUnitBaseElementSection
659
     *
660
     * @param parent
661
     */
662
    private void createDerivedUnitBaseElementSection(RootElement parent) {
663
        destroySections();
664

    
665
        DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
666
        //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
667
        if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
668
            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
669
        }
670
        addPart(derivedUnitGeneralDetailSection);
671

    
672
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
673

    
674
        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
675
        addPart(derivedUnitBaseDetailSection);
676

    
677
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
678

    
679
        OriginalLabelDataSection originalLabelDataSection = formFactory.createOriginalLabelDataSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
680
        addPart(originalLabelDataSection);
681

    
682
        //for editors working with facades
683
        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
684
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
685
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
686
            addPart(gatheringEventDetailSection);
687

    
688
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
689
            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
690
            addPart(fieldUnitDetailSection);
691
        }
692

    
693
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
694
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
695
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
696
            addPart(determinationDetailSection);
697
        }
698
        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS)){
699
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
700
            TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
701
            addPart(taxonAssociationDetailSection);
702
        }
703
        
704
    }
705

    
706
    private void createFieldUnitSection(RootElement parent) {
707
        destroySections();
708

    
709
        FieldUnitGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
710

    
711
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
712

    
713
        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
714

    
715
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
716

    
717
        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
718

    
719
        addPart(fielUnitGeneralDetailSection);
720
        addPart(gatheringEventDetailSection);
721
        addPart(fieldUnitDetailSection);
722

    
723
        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
724
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
725
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
726
            addPart(determinationDetailSection);
727
        }
728
    }
729

    
730
    private void createTissueSampleSection(RootElement parent) {
731
        destroySections();
732

    
733
        TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
734

    
735
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
736

    
737
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
738

    
739
        addPart(section);
740
        addPart(sampleDesignationDetailSection);
741
    }
742

    
743
    private void createDnaSampleSection(RootElement parent) {
744
        destroySections();
745

    
746
        DnaSampleGeneralDetailSection section = formFactory.createDnaSampleGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
747

    
748
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
749

    
750
        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
751

    
752
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
753

    
754
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
755

    
756
        addPart(section);
757
        addPart(qualitySection);
758
        addPart(sampleDesignationDetailSection);
759
    }
760

    
761
    private void createSequenceSection(RootElement parent) {
762
        destroySections();
763

    
764
        SequenceGeneralDetailSection section = formFactory.createSequenceGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
765

    
766
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
767

    
768
        SequenceReferenceCollectionDetailSection referenceSection = formFactory.createSequenceReferenceCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
769

    
770
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
771

    
772
        SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
773

    
774

    
775
        addPart(section);
776
        addPart(referenceSection);
777
        addPart(contigFileSection);
778
    }
779

    
780
    private void createSingleReadSection(RootElement parent) {
781
        destroySections();
782

    
783
        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
784
        addPart(section);
785

    
786
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
787

    
788
        SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
789
        addPart(pherogramSection);
790

    
791
    }
792

    
793
    private void createMediaSpecimenSection(RootElement parent) {
794
        destroySections();
795

    
796
        MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
797
        addPart(generalSection);
798

    
799
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
800

    
801
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
802
        addPart(rightsSection);
803

    
804
    }
805

    
806

    
807

    
808
    /**
809
     * @param rootElement
810
     */
811
    private void createFeatureDistributionSection(RootElement parent) {
812
        destroySections();
813

    
814
        FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
815

    
816
        addPart(featureDistributionSection);
817
    }
818

    
819
    /**
820
     * createPolytomousKeyNodeSection
821
     *
822
     * @param parent
823
     */
824
    private void createPolytomousKeyNodeSection(RootElement parent) {
825
        destroySections();
826

    
827
        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
828

    
829
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
830

    
831
        PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
832

    
833
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
834

    
835
        TaxonomicScopeSection taxonomicScopeSection = formFactory.createTaxonomicScopeSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT);
836

    
837
        addPart(polytomousKeyDetailSection);
838
        addPart(polytomousKeyNodeDetailSection);
839
        addPart(taxonomicScopeSection);
840

    
841
    }
842

    
843
    /**
844
     * create the UseRecordSection
845
     *
846
     * @param parent
847
     */
848
    private void createUseRecordSection(RootElement parent) {
849
        destroySections();
850

    
851
        UseRecordDetailSection descriptionUseRecordSection = formFactory.createUseRecordDetailSection(getConversationHolder(), parent, this,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
852

    
853
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
854

    
855
        addPart(descriptionUseRecordSection);
856

    
857

    
858
    }
859

    
860
    /**
861
     * createUserSection
862
     *
863
     * @param parent
864
     */
865
    private void createUserSection(RootElement parent) {
866
        destroySections();
867

    
868
        UserDetailSection userDetailSection = formFactory.createUserDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
869

    
870
        GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
871

    
872
        addPart(userDetailSection);
873
        addPart(groupByUserDetailSection);
874
    }
875

    
876
    /**
877
     * createTaxonRelationshipSection
878
     *
879
     * @param parent
880
     */
881
    private void createTaxonRelationshipSection(RootElement parent) {
882
        destroySections();
883

    
884
        TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
885

    
886
        ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
887
        addPart(taxonRelationshipDetailSection);
888
        addPart(referencedEntityBaseDetailSection);
889
    }
890

    
891
    /**
892
     * @param rootElement
893
     */
894
    private void createTermVocabularySection(RootElement parent) {
895
        destroySections();
896

    
897
        TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
898
        addPart(termVocabularyDetailSection);
899
    }
900

    
901
    /**
902
     * createDefinedTermSection
903
     *
904
     * @param parent
905
     */
906
    private void createDefinedTermSection(RootElement parent) {
907
        destroySections();
908

    
909
        AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
910
        addPart(definedTermDetailSection);
911
    }
912

    
913
}
(3-3/3)