Project

General

Profile

Download (40.5 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.key.PolytomousKeyDetailSection;
82
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
83
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
84
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
85
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
86
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
87
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
88
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
89
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
90
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
91
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
92
import eu.etaxonomy.taxeditor.ui.section.occurrence.EmptySection;
93
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitDetailSection;
94
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralDetailSection;
95
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
96
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
97
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
98
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
99
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
100
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
101
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
102
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
103
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
104
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
105
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
106
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
107
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
108
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
109
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
110
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
111
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
112
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
113
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
114
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
115
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
116
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
117
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
118
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
119
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
120

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

    
134
    private ISelection selection;
135

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
346

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

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

    
355
        addPart(emptySection);
356
    }
357

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
444

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

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

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

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

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

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

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

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

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

    
501
        addPart(referenceDetailSection);
502
    }
503

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

    
513
        addPart(teamOrPersonBaseDetailSection);
514
    }
515

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

    
525
        addPart(teamDetailSection);
526
    }
527

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
629
    }
630

    
631

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

    
639
        addPart(descriptionDetailSection);
640
    }
641

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

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

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

    
653
        addPart(mediaDetailSection);
654
    }
655

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

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

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

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

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

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

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

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

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

    
703
    }
704

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
773

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

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

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

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

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

    
790
    }
791

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

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

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

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

    
803
    }
804

    
805

    
806

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

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

    
815
        addPart(featureDistributionSection);
816
    }
817

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

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

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

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

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

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

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

    
840
    }
841

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

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

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

    
854
        addPart(descriptionUseRecordSection);
855

    
856

    
857
    }
858

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

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

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

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

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

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

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

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

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

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

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

    
912
}
(3-3/3)