Project

General

Profile

Download (60.1 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2011 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.taxeditor.view.e4.details;
10

    
11
import java.util.Collection;
12
import java.util.EnumSet;
13
import java.util.HashSet;
14
import java.util.Set;
15

    
16
import javax.inject.Inject;
17

    
18
import org.apache.lucene.search.BulkScorer;
19
import org.eclipse.e4.core.di.annotations.Optional;
20
import org.eclipse.e4.ui.di.UIEventTopic;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.SelectionChangedEvent;
24
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.jface.viewers.TreeNode;
26
import org.eclipse.swt.SWT;
27
import org.springframework.security.core.GrantedAuthority;
28

    
29
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
30
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
31
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
32
import eu.etaxonomy.cdm.model.agent.Person;
33
import eu.etaxonomy.cdm.model.agent.Team;
34
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
35
import eu.etaxonomy.cdm.model.common.CdmBase;
36
import eu.etaxonomy.cdm.model.common.Marker;
37
import eu.etaxonomy.cdm.model.description.CategoricalData;
38
import eu.etaxonomy.cdm.model.description.Character;
39
import eu.etaxonomy.cdm.model.description.DescriptionBase;
40
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
41
import eu.etaxonomy.cdm.model.description.Distribution;
42
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
43
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
44
import eu.etaxonomy.cdm.model.description.TaxonDescription;
45
import eu.etaxonomy.cdm.model.media.Media;
46
import eu.etaxonomy.cdm.model.molecular.DnaSample;
47
import eu.etaxonomy.cdm.model.molecular.Sequence;
48
import eu.etaxonomy.cdm.model.molecular.SingleRead;
49
import eu.etaxonomy.cdm.model.name.TaxonName;
50
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
51
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
52
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
53
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
54
import eu.etaxonomy.cdm.model.permission.CRUD;
55
import eu.etaxonomy.cdm.model.permission.Group;
56
import eu.etaxonomy.cdm.model.permission.User;
57
import eu.etaxonomy.cdm.model.reference.Reference;
58
import eu.etaxonomy.cdm.model.taxon.SecundumSource;
59
import eu.etaxonomy.cdm.model.taxon.Synonym;
60
import eu.etaxonomy.cdm.model.taxon.Taxon;
61
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
62
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
63
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
64
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
65
import eu.etaxonomy.cdm.model.term.TermNode;
66
import eu.etaxonomy.cdm.model.term.TermTree;
67
import eu.etaxonomy.cdm.model.term.TermType;
68
import eu.etaxonomy.cdm.model.term.TermVocabulary;
69
import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
70
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
71
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
72
import eu.etaxonomy.taxeditor.editor.IBulkEditor;
73
import eu.etaxonomy.taxeditor.editor.IDistributionEditorPart;
74
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
75
import eu.etaxonomy.taxeditor.l10n.Messages;
76
import eu.etaxonomy.taxeditor.model.AbstractUtility;
77
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
78
import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
79
import eu.etaxonomy.taxeditor.model.MessagingUtils;
80
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
81
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
82
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
83
import eu.etaxonomy.taxeditor.store.CdmStore;
84
import eu.etaxonomy.taxeditor.store.StoreUtil;
85
import eu.etaxonomy.taxeditor.store.UsageTermCollection;
86
import eu.etaxonomy.taxeditor.termtree.e4.ICharacterEditor;
87
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
88
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
89
import eu.etaxonomy.taxeditor.ui.element.RootElement;
90
import eu.etaxonomy.taxeditor.ui.section.agent.PersonDetailSection;
91
import eu.etaxonomy.taxeditor.ui.section.agent.TeamDetailSection;
92
import eu.etaxonomy.taxeditor.ui.section.agent.TeamOrPersonBaseDetailSection;
93
import eu.etaxonomy.taxeditor.ui.section.common.ReferencedEntityDetailSection;
94
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection;
95
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
96
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection;
97
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementMediaSection;
98
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementSourceSection;
99
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionSourceSection;
100
import eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection;
101
import eu.etaxonomy.taxeditor.ui.section.description.NaturalLanguageSection;
102
import eu.etaxonomy.taxeditor.ui.section.description.ScopeSection;
103
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
104
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
105
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDetailSection;
106
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailSection;
107
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection;
108
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailSection;
109
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSection;
110
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSectionForNode;
111
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection;
112
import eu.etaxonomy.taxeditor.ui.section.group.GroupDetailSection;
113
import eu.etaxonomy.taxeditor.ui.section.group.MemberDetailSection;
114
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
115
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyNodeDetailSection;
116
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
117
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
118
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
119
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
120
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection;
121
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection;
122
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
123
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeDetailSection;
124
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitFacadeGeneralDetailSection;
125
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
126
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.DerivedUnitTypeDesignationSection;
127
import eu.etaxonomy.taxeditor.ui.section.occurrence.association.TaxonAssociationDetailSection;
128
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaQualityDetailSection;
129
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSampleGeneralDetailSection;
130
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.DnaSamplePreparationPreservationSection;
131
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SampleDesignationDetailSection;
132
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceContigFileCollectionDetailSection;
133
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceGeneralDetailSection;
134
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SequenceReferenceCollectionDetailSection;
135
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadGeneralDetailSection;
136
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.SingleReadPherogramCollectionDetailSection;
137
import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.TissueSampleGeneralDetailSection;
138
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection;
139
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalSourceDetailSection;
140
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
141
import eu.etaxonomy.taxeditor.ui.section.reference.SecundumSourceSection;
142
import eu.etaxonomy.taxeditor.ui.section.supplemental.RightsSection;
143
import eu.etaxonomy.taxeditor.ui.section.supplemental.identifier.DerivedUnitFacadeIdentifierSection;
144
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
145
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
146
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
147
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
148
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
149
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
150
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
151
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermMediaSection;
152
import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
153
import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
154
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewer;
155

    
156
/**
157
 * The DetailsViewer handles the content of the details view (
158
 * {@link DetailsPartE4}).<br>
159
 * Depending on the type of the selected element the section of the details view
160
 * are created.
161
 *
162
 * @author pplitzner
163
 * @date 18.07.2017
164
 */
165
public class DetailsViewerE4 extends AbstractCdmDataViewer {
166

    
167
    private ISelection selection;
168
    private boolean detailsEnabled = true;
169
    private Object activePart;
170

    
171
    public boolean isDetailsEnabled() {
172
		return detailsEnabled;
173
	}
174

    
175
	public void setDetailsEnabled(boolean detailsEnabled) {
176
		this.detailsEnabled = detailsEnabled;
177
	}
178

    
179
	public void setInput(Object input, Object activePart) {
180
	    this.activePart = activePart;
181
        setInput(input);
182

    
183
    }
184
    // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
185
    // since we are getting implementations of DerivedUnitBase from the bulk
186
    // editor
187
    // and not derived unit facade objects,
188

    
189
    @Override
190
    public void setInput(Object input) {
191

    
192
        if(input instanceof TreeNode){
193
            input = ((TreeNode) input).getValue();
194
        }
195
        if(input instanceof GbifResponse){
196
            input = ((GbifResponse) input).getDerivedUnitFacade();
197
        }
198
        if (input instanceof DerivedUnit) {
199
            DerivedUnit derivedUnit = (DerivedUnit)input;
200
            if ((derivedUnit instanceof MediaSpecimen
201
                    ||  (derivedUnit instanceof DnaSample && derivedUnit.getRecordBasis() == SpecimenOrObservationType.DnaSample ))
202
                && !(this.activePart instanceof IBulkEditor)){
203
                    //do nothing
204
            }else{
205
                try {
206
                    input = DerivedUnitFacade.NewInstance(derivedUnit,
207
                            PreferencesUtil.getDerivedUnitConfigurator());
208
                } catch (DerivedUnitFacadeNotSupportedException e) {
209
                    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
210
                }
211
            }
212
        }
213
        else if(input instanceof FieldUnit){
214
            input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input);
215
        }
216
        super.setInput(input);
217
        
218
        
219
    }
220

    
221
    @Override
222
    protected void markViewPartDirty() {
223
        if (getInput() instanceof DerivedUnitFacade) {
224
            if(part instanceof IDerivedUnitFacadePart){
225
                part.changed(getInput());
226
            }
227
            else{
228
                DerivedUnitFacade facade = (DerivedUnitFacade) getInput();
229
                if(facade.innerDerivedUnit()!=null){
230
                    part.changed(facade.innerDerivedUnit());
231
                }
232
                else if(facade.innerFieldUnit()!=null){
233
                    part.changed(facade.innerFieldUnit());
234
                }
235
            }
236
        }
237
        else{
238
            super.markViewPartDirty();
239
        }
240
    }
241

    
242
    @Override
243
    protected void showParts() {
244
        // FIXME (CM) : Need to clean out this code.
245
        // Too much type checking to decide which detail view to display.
246
        // Need to build in a mechanism where navigators / editors are 'aware'
247
        // of the corresponding detail viewer.
248

    
249
        Object input = getInput();
250
        if (input == null){
251
            return;
252
        }
253
        destroySections();
254
        if (input instanceof TaxonBase) {
255
            if(((TaxonBase<?>) input).getName()==null){
256
                createEmptySection(Messages.DetailsViewerE4_TAXON_HAS_NO_NAME, rootElement);
257
            }
258
            else{
259
                createTaxonSections(rootElement);
260
            }
261
        } else if (input instanceof TaxonName) {
262
            createNameSections(rootElement);
263
        } else if (input instanceof Reference) {
264
            createReferenceSections(rootElement);
265

    
266
        } else if (input instanceof Team) {
267
            createTeamDetailSection(rootElement);
268

    
269
        } else if (input instanceof Person) {
270
            createPersonDetailSection(rootElement);
271

    
272
        } else if (input instanceof TeamOrPersonBase) {
273
            createTeamOrPersonBaseDetailSection(rootElement);
274

    
275
        } else if (input instanceof DescriptionBase) {
276
            if ((((DescriptionBase)input).isComputed() || ((DescriptionBase)input).isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled()){
277
                this.setDetailsEnabled(false);
278
            }
279
            if(input instanceof SpecimenDescription){
280
                //TODO: add more sections to DetailsView for SpecimenDescription
281
                createSpecimenDescriptionSection(rootElement);
282
            }
283
            else{
284
                Set<Marker> descriptionMarkers = ((DescriptionBase<?>) input).getMarkers();
285

    
286
                Boolean isUseDescription = false;
287
                for (Marker marker : descriptionMarkers) {
288
                    if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
289
                        isUseDescription = true;
290
                    }
291
                }
292
                if (((DescriptionBase<?>) input).isImageGallery()) {
293
                    createImageGallerySection(rootElement);
294

    
295
                } else if (isUseDescription) {
296
                    createUseDescriptionSection(rootElement);
297
                } else if (input instanceof TaxonDescription){
298
                    createTaxonDescriptionSection(rootElement, !(((DescriptionBase) input).isComputed() && PreferencesUtil.isComputedDesciptionHandlingDisabled()));
299

    
300
                } else{
301
                    createDescriptionSection(rootElement, false, !(((DescriptionBase) input).isComputed() && PreferencesUtil.isComputedDesciptionHandlingDisabled()));
302
                }
303
            }
304
        } else if (input instanceof DescriptionElementBase){
305
            Set<Marker> descriptionMarkers = new HashSet<>();
306
            if(((DescriptionElementBase) input).getInDescription()!=null) {
307
                descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers();
308
            }
309

    
310
            Boolean isUseDescription = false;
311
            for (Marker marker : descriptionMarkers) {
312
                if (marker.getMarkerType()!= null && marker.getMarkerType().getUuid().equals(UsageTermCollection.uuidUseMarkerType)) {
313
                    isUseDescription = true;
314
                }
315
            }
316
            if (((DescriptionElementBase)input).getInDescription() != null && ((DescriptionElementBase)input).getInDescription().isComputed() && PreferencesUtil.isComputedDesciptionHandlingDisabled()){
317
                this.setDetailsEnabled(false);
318
            }
319
            if (isUseDescription == true && input instanceof CategoricalData) {
320
                createUseRecordSection(rootElement);
321
            } else {
322
                createDescriptionElementSection(rootElement, activePart);
323
            }
324

    
325
        } else if (input instanceof Media) {
326
            createMediaElementSection(rootElement);
327
        }
328
        //FIXME hack to show more informative message to the user when
329
        //DerivedUnit has more than one FieldUnit #4363
330
        else if (input instanceof DerivedUnit && !(input instanceof MediaSpecimen) && !(input instanceof DnaSample)) {
331
            DerivedUnit derivedUnit = (DerivedUnit)input;
332
            try {
333
                input = DerivedUnitFacade.NewInstance(derivedUnit,
334
                        PreferencesUtil.getDerivedUnitConfigurator());
335
            } catch (DerivedUnitFacadeNotSupportedException e) {
336
                createEmptySection(e.getMessage(), rootElement);
337
            }
338
        } else if (input instanceof DerivedUnitFacade) {
339
            DerivedUnitFacade facade = (DerivedUnitFacade) input;
340
            if(facade.getType() == SpecimenOrObservationType.FieldUnit){
341
                if(facade.innerFieldUnit() == null){
342
                    MessagingUtils.error(DetailsViewerE4.class, "FieldUnit of facade is null", null); //$NON-NLS-1$
343
                }
344
                else{
345
                    createFieldUnitFacadeSection(rootElement);
346
                }
347
            }
348
            else if(facade.getType() == SpecimenOrObservationType.PreservedSpecimen){
349
                if(facade.innerDerivedUnit() == null){
350
                    MessagingUtils.error(DetailsViewerE4.class, "DerivedUnit of facade is null", null); //$NON-NLS-1$
351
                }
352
                else{
353
                    createDerivedUnitBaseElementSection(rootElement);
354
                }
355
            }
356
            else if(facade.getType() == SpecimenOrObservationType.TissueSample){
357
                //TissueSample should only be created by using it's own class
358
                //in future using only one class with different SpecimenOrObservationTypes is desired
359
                createTissueSampleSection(rootElement);
360
            }else if (facade.innerDerivedUnit() instanceof DnaSample){
361
                createEmptySection("DNA sample not supported by specimen list editor", rootElement);
362
            }else if (facade.innerDerivedUnit() instanceof MediaSpecimen){
363
                createEmptySection("Image specimen not supported by specimen list editor", rootElement);
364
            }else if(facade.getType()==SpecimenOrObservationType.DnaSample){
365

    
366
                if(facade.innerDerivedUnit().getRecordBasis()==SpecimenOrObservationType.TissueSample){
367
                    //this case seems to be very unlikely as innerDerivedUnit in real cases should more or less always have the same type
368
                    createTissueSampleSection(rootElement);
369
                }
370
                else if(facade.innerDerivedUnit().getRecordBasis()==SpecimenOrObservationType.DnaSample){
371
                    createDnaSampleSection(rootElement);
372
                }
373
            }else{
374
                createDerivedUnitBaseElementSection(rootElement);
375
            }
376
        } else if (input instanceof DnaSample){
377
            DnaSample dnaSample = (DnaSample)input;
378
            if(dnaSample.getRecordBasis()==SpecimenOrObservationType.TissueSample){
379
                createTissueSampleSection(rootElement);
380
            }
381
            else if(dnaSample.getRecordBasis()==SpecimenOrObservationType.DnaSample){
382
                createDnaSampleSection(rootElement);
383
            }
384
        } else if (input instanceof MediaSpecimen){
385
            createMediaSpecimenSection(rootElement);
386
        }
387
        else if(input instanceof Sequence){
388
            createSequenceSection(rootElement);
389
        }
390
        else if(input instanceof SingleRead){
391
            createSingleReadSection(rootElement);
392
        }
393
        else if (input instanceof FeatureNodeContainer) {
394
            createFeatureDistributionSection(rootElement);
395

    
396
        } else if (input instanceof TermNode) {
397
            TermType type= ((TermNode<?>) input).getTermType();
398
            if(type.equals(TermType.Character) ){
399
                createCharacterNodeSection(rootElement);
400
            }
401
            else if(type.equals(TermType.Feature)){
402
                createFeatureNodeSection(rootElement);
403
            }
404

    
405
        } else if (input instanceof TermTree) {
406
            createFeatureTreeSection(rootElement);
407
        }  else if (input instanceof TermNodeDto) {
408
            TermType type= ((TermNodeDto) input).getTerm().getTermType();
409
            if(type.equals(TermType.Character) && activePart instanceof ICharacterEditor){
410
                createCharacterNodeDtoSection(rootElement);
411
            }
412
            else if(type.equals(TermType.Feature) || type.equals(TermType.Character)){
413
                createFeatureNodeSection(rootElement);
414
            }
415

    
416
        } else if (input instanceof TermTreeDto) {
417
            createFeatureTreeSectionForDto(rootElement);
418

    
419
        } else if (input instanceof Character) {
420
            createCharacterSection(rootElement);
421

    
422
        }else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) {
423
            createPolytomousKeyNodeSection(rootElement);
424
        } else if (input instanceof User) {
425
            createUserSection(rootElement);
426
        } else if (input instanceof Group) {
427
            createGroupSection(rootElement);
428
        } else if (input instanceof TaxonRelationship && ((TaxonRelationship)input).getType()!=null
429
                && (((TaxonRelationship)input).getType().isAnyMisappliedName() || ((TaxonRelationship)input).getType().isAnySynonym() || ((TaxonRelationship)input).getType().isMisappliedName())){
430
            createMisappliedNameSection(rootElement);
431
        }else if (input instanceof TaxonRelationship ) {
432
            createTaxonRelationshipSection(rootElement);
433
        } else if (input instanceof TermVocabulary) {
434
            createTermVocabularySection(rootElement);
435
        } else if (input instanceof DefinedTermBase) {
436
            createDefinedTermSection(rootElement);
437

    
438
        } else if (input instanceof SelectionChangedEvent ) {
439
            IStructuredSelection sel =(IStructuredSelection) ((SelectionChangedEvent)input).getSelection();
440
            if (sel.getFirstElement()instanceof Distribution){
441
                createDescriptionElementSection(rootElement);
442
            }
443

    
444
//            createDescriptionElementSection(rootElement);
445

    
446
        }else {
447
            createEmptySection(null, rootElement);
448
        }
449
        layout();
450
    }
451

    
452
    private void createGroupSection(RootElement parent) {
453
        GroupDetailSection groupDetailSection = formFactory.createGroupDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(GroupDetailSection.class, getInput().getClass().getCanonicalName()));
454
        MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(MemberDetailSection.class, getInput().getClass().getCanonicalName()));
455
        GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,StoreUtil.getSectionStyle(GrantedAuthorityDetailSection.class, getInput().getClass().getCanonicalName()));
456

    
457
        addPart(groupDetailSection);
458
        addPart(memberDetailSection);
459
        addPart(grantedAuthorityDetailSection);
460
    }
461

    
462
    @Override
463
    public ISelection getSelection() {
464
        return selection;
465
    }
466

    
467
    @Override
468
    public void setSelection(ISelection selection, boolean reveal) {
469

    
470
        this.selection = selection;
471
        if(this.selection!=null){
472
            SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection);
473
            fireSelectionChanged(selectionChangedEvent);
474
        }
475
    }
476

    
477
    private void createTaxonSections(RootElement parent) {
478
        NameDetailsConfigurator config = PreferencesUtil.getPreferredNameDetailsConfiguration();
479
        EnumSet<CRUD> requiredCrud;
480
        if(getInput() == null || StoreUtil.getCdmEntity(getInput()).getId() == 0) {
481
            // new entity, not yet saved
482
            requiredCrud = EnumSet.of(CRUD.CREATE);
483
        } else {
484
            requiredCrud = EnumSet.of(CRUD.UPDATE);
485
        }
486
        boolean hasPermission = CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getInput()), requiredCrud);
487
        TaxonBase<?> taxonBase = (TaxonBase<?>)getInput();
488
        if (hasPermission){
489
            // check for subtree permissions as well.
490
            
491
            Taxon acceptedTaxon = null;
492
            if (taxonBase instanceof Taxon){
493
                acceptedTaxon = (Taxon)taxonBase;
494
            }else{
495
                acceptedTaxon = ((Synonym)taxonBase).getAcceptedTaxon();
496
            }
497
            if (acceptedTaxon != null){ //needs discussion if synonyms without accepted taxon should never be filtered by subtree permission(current implementation). See also #8849
498
                Set<TaxonNode> nodes = acceptedTaxon.getTaxonNodes();
499
                for (TaxonNode node: nodes){
500
                    hasPermission &= CdmStore.currentAuthentiationHasPermission(node, requiredCrud);
501
                    if (!hasPermission){
502
                        //check whether there are explicit TaxonNode rights
503
                        boolean taxonnodePermissionExists = false;
504
                        Collection<? extends GrantedAuthority> authorities = CdmStore.getCurrentAuthentiation().getAuthorities();
505
                        for (GrantedAuthority grantedAuthority: authorities){
506
                            if (grantedAuthority.getAuthority().startsWith("TAXONNODE")){
507
                                taxonnodePermissionExists = true;
508
                            }
509
                        }
510
                        if (!taxonnodePermissionExists){
511
                            hasPermission = true;
512
                        }
513
                    }
514
                }
515
            }
516
        }
517
        detailsEnabled = hasPermission;
518
        ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
519
                StoreUtil.getSectionStyle(ParsingMessagesSection.class, getInput().getClass().getCanonicalName(), true));
520
        if (config == null){
521
            TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
522
                    StoreUtil.getSectionStyle(TaxonBaseDetailSection.class, getInput().getClass().getCanonicalName(), true));
523
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
524
          //  boolean hasPermission = CdmStore.currentAuthentiationHasPermission(getInput(), Operation.UPDATE);
525
            taxonBaseDetailSection.setEnabled(detailsEnabled);
526
            addPart(taxonBaseDetailSection);
527
        }else{
528
            if (config.isTaxonSectionActivated()){
529
                TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
530
                        StoreUtil.getSectionStyle(TaxonBaseDetailSection.class, getInput().getClass().getCanonicalName(), true));
531
                taxonBaseDetailSection.setEnabled(detailsEnabled);
532
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
533
                addPart(taxonBaseDetailSection);
534
            }
535
        }
536
        //TODO: test code for secundum source section
537
//        SecundumSourceSection sourceSection = formFactory.createSecundumDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(SecundumSourceSection.class, getInput().getClass().getCanonicalName(), true));
538
//        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
539
//        addPart(sourceSection);
540
//        if (taxonBase.getSecSource() == null){
541
//            SecundumSource source = SecundumSource.NewSecundumInstance(taxonBase);
542
//            taxonBase.setSecSource(source);
543
//            sourceSection.setEntity(taxonBase);
544
//        }else{
545
//        	sourceSection.setEntity(taxonBase);
546
//        }
547
//
548
//        if (config != null && !config.isSecEnabled()){
549
//        	sourceSection.setEnabled(false);
550
//        }
551
        NonViralNameDetailSection nonViralNameSection = formFactory
552
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
553
                        StoreUtil.getSectionStyle(NonViralNameDetailSection.class, getInput().getClass().getCanonicalName(), true));
554
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
555
        nonViralNameSection.setEnabled(detailsEnabled);
556
        if (config == null || config.isNomenclaturalReferenceSectionActivated()){
557
            NomenclaturalSourceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
558
                    StoreUtil.getSectionStyle(NomenclaturalSourceDetailSection.class, getInput().getClass().getCanonicalName(), true));
559
            referenceDetailSection.setEnabled(detailsEnabled);
560
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
561
            addPart(referenceDetailSection);
562

    
563
        }
564
        if ( config == null || config.isNomenclaturalStatusSectionActivated()){
565
            NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
566
                    StoreUtil.getSectionStyle(NomenclaturalStatusSection.class, getInput().getClass().getCanonicalName(), true));
567
            nomenclaturalStatusSection.setEnabled(detailsEnabled);
568
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
569
            addPart(nomenclaturalStatusSection);
570
        }
571

    
572
//        if ( config == null || config.isProtologueActivated()){
573
//            ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(ProtologueSection.class, getInput().getClass().getCanonicalName()));
574
//            protologSection.setEnabled(detailsEnabled);
575
//            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
576
//            addPart(protologSection);
577
//        }
578

    
579
        if (config == null || config.isTypeDesignationSectionActivated()){
580
            TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(TypeDesignationSection.class, getInput().getClass().getCanonicalName()));
581
            typeDesignationSection.setEnabled(detailsEnabled);
582
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
583
            addPart(typeDesignationSection);
584
        }
585

    
586
        if (config == null || config.isNameRelationsSectionActivated()){
587
            NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(NameRelationshipDetailSection.class, getInput().getClass().getCanonicalName()));
588
            nameRelationshipSection.setEnabled(detailsEnabled);
589
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
590
            addPart(nameRelationshipSection);
591
        }
592

    
593
        addPart(parsingMessagesSection);
594
        addPart(nonViralNameSection);
595
    }
596

    
597
    private void createNameSections(RootElement parent) {
598
        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(
599
                getConversationHolder(), parent, this, false, StoreUtil.getSectionStyle(NonViralNameDetailSection.class, getInput().getClass().getCanonicalName(), true));
600

    
601
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
602

    
603
        NomenclaturalSourceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
604
                StoreUtil.getSectionStyle(NomenclaturalSourceDetailSection.class, getInput().getClass().getCanonicalName(), true));
605
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
606

    
607
        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
608
                StoreUtil.getSectionStyle(NomenclaturalStatusSection.class, getInput().getClass().getCanonicalName(), true));
609
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
610

    
611
        addPart(nonViralNameSection);
612
        addPart(nomenclaturalStatusSection);
613
        addPart(referenceDetailSection);
614

    
615
//        ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(ProtologueSection.class, getInput().getClass().getCanonicalName()));
616
//        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
617

    
618
        TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(TypeDesignationSection.class, getInput().getClass().getCanonicalName()));
619
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
620

    
621
        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(NameRelationshipDetailSection.class, getInput().getClass().getCanonicalName()));
622
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
623
//        addPart(protologSection);
624
        addPart(typeDesignationSection);
625
        addPart(nameRelationshipSection);
626
    }
627

    
628
    private void createReferenceSections(RootElement parent) {
629
        ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
630
                StoreUtil.getSectionStyle(ReferenceDetailSection.class, getInput().getClass().getCanonicalName(), true));
631

    
632
        addPart(referenceDetailSection);
633
    }
634

    
635
    private void createTeamOrPersonBaseDetailSection(RootElement parent) {
636
        TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TeamOrPersonBaseDetailSection.class, getInput().getClass().getCanonicalName(), true));
637

    
638
        addPart(teamOrPersonBaseDetailSection);
639
    }
640

    
641
    private void createTeamDetailSection(RootElement parent) {
642
        TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(TeamDetailSection.class, getInput().getClass().getCanonicalName(), true));
643

    
644
        addPart(teamDetailSection);
645
    }
646

    
647
    private void createPersonDetailSection(RootElement parent) {
648
        PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(PersonDetailSection.class, getInput().getClass().getCanonicalName(), true));
649
        addPart(personDetailSection);
650
    }
651

    
652
    private void createDescriptionElementSection(RootElement parent) {
653
        createDescriptionElementSection(parent, null);
654
    }
655

    
656
    private void createDescriptionElementSection(RootElement parent, Object activePart) {
657
        DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DescriptionElementDetailSection.class, getInput().getClass().getCanonicalName(), true));
658

    
659

    
660
        //  IntextReferenceSection intextReferenceSection = formFactory.createIntextReferenceSection(getConversationHolder(), parent,  getSectionStyle(.class, getInput().getClass().getCanonicalName()));
661

    
662
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
663
        DescriptionElementSourceSection descriptionElementSourceSection;
664
        if (activePart != null && activePart instanceof IDistributionEditorPart){
665
            Reference defaultSource =((IDistributionEditorPart)activePart).getEditor().getDefaultSource();
666
            descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, defaultSource, StoreUtil.getSectionStyle(DescriptionElementSourceSection.class, getInput().getClass().getCanonicalName()));
667

    
668
        }else{
669
            descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DescriptionElementSourceSection.class, getInput().getClass().getCanonicalName()) );
670
            descriptionElementSourceSection.setEnabled(this.detailsEnabled);
671

    
672
        }
673

    
674

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

    
677
        DescriptionElementMediaSection descriptionElementMediaSection = formFactory.createDescriptionElementMediaSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DescriptionElementMediaSection.class, getInput().getClass().getCanonicalName()));
678

    
679
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
680

    
681
        addPart(descriptionElementDetailSection);
682
        addPart(descriptionElementSourceSection);
683
        addPart(descriptionElementMediaSection);
684
    }
685

    
686
    private void createDescriptionSection(RootElement parent, boolean isTaxonDescription, boolean isEnabled) {
687
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DescriptionDetailSection.class, getInput().getClass().getCanonicalName(), true));
688
        descriptionDetailSection.setEnabled(isEnabled);
689
        addPart(descriptionDetailSection);
690

    
691
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
692

    
693
        if(isTaxonDescription) {
694
            NaturalLanguageSection naturalLanguageSection = formFactory.createNaturalLanguageSection(
695
                    getConversationHolder(), parent, this, StoreUtil.getSectionStyle(NaturalLanguageSection.class, getInput().getClass().getCanonicalName(), true));
696
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
697
            naturalLanguageSection.setEnabled(isEnabled);
698
            addPart(naturalLanguageSection);
699
        }
700
        DescriptionSourceSection descriptionSourceSection = formFactory.createDescriptionSourceSection(
701
                getConversationHolder(), parent, StoreUtil.getSectionStyle(DescriptionSourceSection.class, getInput().getClass().getCanonicalName(), true));
702
        descriptionSourceSection.setEnabled(isEnabled);
703
        addPart(descriptionSourceSection);
704

    
705
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
706

    
707
        if(isTaxonDescription) {
708
            ScopeSection scopeSection = formFactory.createScopeSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(ScopeSection.class, getInput().getClass().getCanonicalName()));
709
            scopeSection.setEnabled(isEnabled);
710
            addPart(scopeSection);
711
        }
712
    }
713

    
714
    private void createTaxonDescriptionSection(RootElement parent, boolean isEnabled) {
715
        createDescriptionSection(parent, true, isEnabled);
716
    }
717

    
718
    private void createSpecimenDescriptionSection(RootElement parent) {
719
        createDescriptionSection(parent, false, true);
720
    }
721

    
722
    private void createUseDescriptionSection(RootElement parent) {
723
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DescriptionDetailSection.class, getInput().getClass().getCanonicalName()));
724

    
725
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
726

    
727
        DescriptionSourceSection descriptionSourceSection = formFactory.createDescriptionSourceSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DescriptionSourceSection.class, getInput().getClass().getCanonicalName()));
728

    
729
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
730

    
731
        addPart(descriptionDetailSection);
732
        addPart(descriptionSourceSection);
733
    }
734

    
735
    private void createImageGallerySection(RootElement parent) {
736
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DescriptionDetailSection.class, getInput().getClass().getCanonicalName()));
737

    
738
        addPart(descriptionDetailSection);
739
    }
740

    
741
    private void createMediaElementSection(RootElement parent) {
742
        MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(MediaDetailsSection.class, getInput().getClass().getCanonicalName(), true));
743

    
744
        addPart(mediaDetailSection);
745
    }
746

    
747
    private void createDerivedUnitBaseElementSection(RootElement parent) {
748
        DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DerivedUnitGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
749
        //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
750
        if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
751
            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
752
        }
753
        addPart(derivedUnitGeneralDetailSection);
754

    
755
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
756

    
757
        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DerivedUnitBaseDetailSection.class, getInput().getClass().getCanonicalName(), true));
758
        addPart(derivedUnitBaseDetailSection);
759

    
760
        //for editors working with facades
761
        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
762
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
763
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(GatheringEventDetailSection.class, getInput().getClass().getCanonicalName()));
764
            addPart(gatheringEventDetailSection);
765

    
766
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
767
            FieldUnitFacadeDetailSection fieldUnitDetailSection = formFactory.createFieldUnitFacadeDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(FieldUnitFacadeDetailSection.class, getInput().getClass().getCanonicalName()));
768
            addPart(fieldUnitDetailSection);
769
        }
770
        else{
771

    
772
            if(PreferencesUtil.isShowTaxonAssociations()){
773
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
774
                TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TaxonAssociationDetailSection.class, getInput().getClass().getCanonicalName(), true));
775
                addPart(taxonAssociationDetailSection);
776
            }
777
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
778
            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DerivedUnitFacadeIdentifierSection.class, getInput().getClass().getCanonicalName()));
779
            addPart(identifierDetailSection);
780
        }
781
        if(!PreferencesUtil.isDeterminationOnlyForFieldUnits()){
782
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
783
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DeterminationDetailSection.class, getInput().getClass().getCanonicalName()));
784
            addPart(determinationDetailSection);
785
        }
786

    
787
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
788
        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DerivedUnitTypeDesignationSection.class, getInput().getClass().getCanonicalName()));
789
        addPart(derivedUnitTypeDesignationSection);
790
    }
791

    
792
    private void createFieldUnitFacadeSection(RootElement parent) {
793
        FieldUnitFacadeGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitFacadeGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(FieldUnitFacadeGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
794

    
795
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
796

    
797
        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(GatheringEventDetailSection.class, getInput().getClass().getCanonicalName()));
798

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

    
801
        FieldUnitFacadeDetailSection fieldUnitDetailSection = formFactory.createFieldUnitFacadeDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(FieldUnitFacadeDetailSection.class, getInput().getClass().getCanonicalName()));
802

    
803
        addPart(fielUnitGeneralDetailSection);
804
        addPart(gatheringEventDetailSection);
805
        addPart(fieldUnitDetailSection);
806

    
807
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
808
        DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DeterminationDetailSection.class, getInput().getClass().getCanonicalName()));
809
        addPart(determinationDetailSection);
810
    }
811

    
812
    private void createTissueSampleSection(RootElement parent) {
813
        TissueSampleGeneralDetailSection section = formFactory.createTissueSampleGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TissueSampleGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
814

    
815
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
816

    
817
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(SampleDesignationDetailSection.class, getInput().getClass().getCanonicalName(), true));
818

    
819
        addPart(section);
820
        addPart(sampleDesignationDetailSection);
821
    }
822

    
823
    private void createDnaSampleSection(RootElement parent) {
824
        DnaSampleGeneralDetailSection section = formFactory.createDnaSampleGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DnaSampleGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
825

    
826
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
827

    
828
        DnaSamplePreparationPreservationSection preparationPreservationSection = formFactory.createDnaSamplePreparationPreservationSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DnaSamplePreparationPreservationSection.class, getInput().getClass().getCanonicalName(), true));
829

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

    
832
        DnaQualityDetailSection qualitySection = formFactory.createDnaQualityDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DnaQualityDetailSection.class, getInput().getClass().getCanonicalName(), true));
833

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

    
836
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(SampleDesignationDetailSection.class, getInput().getClass().getCanonicalName(), true));
837

    
838
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
839
        DeterminationDetailSection determinationDetailSection = null;
840
        if(!PreferencesUtil.isDeterminationOnlyForFieldUnits()){
841
            determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DeterminationDetailSection.class, getInput().getClass().getCanonicalName()));
842
        }
843
        addPart(section);
844
        addPart(preparationPreservationSection);
845
        addPart(qualitySection);
846
        addPart(sampleDesignationDetailSection);
847
        if(!PreferencesUtil.isDeterminationOnlyForFieldUnits()){
848
            addPart(determinationDetailSection);
849
        }
850
    }
851

    
852
    private void createSequenceSection(RootElement parent) {
853
        SequenceGeneralDetailSection section = formFactory.createSequenceGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(SequenceGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
854

    
855
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
856

    
857
        SequenceReferenceCollectionDetailSection referenceSection = formFactory.createSequenceReferenceCollectionDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(SequenceReferenceCollectionDetailSection.class, getInput().getClass().getCanonicalName(), true));
858

    
859
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
860

    
861
        SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(SequenceContigFileCollectionDetailSection.class, getInput().getClass().getCanonicalName(), true));
862

    
863
        addPart(section);
864
        addPart(referenceSection);
865
        addPart(contigFileSection);
866
    }
867

    
868
    private void createSingleReadSection(RootElement parent) {
869
        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(SingleReadGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
870
        addPart(section);
871

    
872
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
873

    
874
        SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(SingleReadPherogramCollectionDetailSection.class, getInput().getClass().getCanonicalName(), true));
875
        addPart(pherogramSection);
876
    }
877

    
878
    private void createMediaSpecimenSection(RootElement parent) {
879
        MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(MediaSpecimenGeneralDetailSection.class, getInput().getClass().getCanonicalName(), true));
880
        addPart(generalSection);
881

    
882
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
883

    
884
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(RightsSection.class, getInput().getClass().getCanonicalName()));
885
//        rightsSection.setEntity(generalSection.getEntity().innerDerivedUnit());
886
        addPart(rightsSection);
887
    }
888

    
889
    private void createFeatureTreeSectionForDto(RootElement parent) {
890
        TermTreeDetailSection section = formFactory.createFeatureTreeDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TermTreeDetailSection.class, getInput().getClass().getCanonicalName(), true));
891

    
892
        addPart(section);
893
    }
894
    private void createFeatureTreeSection(RootElement parent) {
895
        TermTreeDetailSectionForNode section = formFactory.createFeatureTreeDetailSectionForTree(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TermTreeDetailSection.class, getInput().getClass().getCanonicalName(), true));
896
        addPart(section);
897
    }
898

    
899
    private void createFeatureNodeSection(RootElement parent) {
900
        TermNodeDetailSection featureDistributionSection = formFactory.createFeatureNodeDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TermNodeDetailSection.class, getInput().getClass().getCanonicalName(), true));
901
        addPart(featureDistributionSection);
902
    }
903

    
904
    private void createFeatureDistributionSection(RootElement parent) {
905
        FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(FeatureDistributionDetailSection.class, getInput().getClass().getCanonicalName(), true));
906
        addPart(featureDistributionSection);
907
    }
908

    
909
    private void createCharacterNodeSection(RootElement parent) {
910
        CharacterNodeDetailSection featureDistributionSection = formFactory.createCharacterNodeDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(CharacterDetailSection.class, getInput().getClass().getCanonicalName(), true));
911
        addPart(featureDistributionSection);
912
    }
913

    
914
    private void createCharacterNodeDtoSection(RootElement parent) {
915
        CharacterNodeDtoDetailSection featureDistributionSection = formFactory.createCharacterNodeDtoDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(CharacterDetailSection.class, getInput().getClass().getCanonicalName(), true));
916
        addPart(featureDistributionSection);
917
    }
918

    
919
    private void createCharacterSection(RootElement parent) {
920
        CharacterDetailSection featureDistributionSection = formFactory.createCharacterDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(CharacterDetailSection.class, getInput().getClass().getCanonicalName(), true));
921
        addPart(featureDistributionSection);
922
    }
923

    
924
    private void createPolytomousKeyNodeSection(RootElement parent) {
925
        PolytomousKeyDetailSection polytomousKeyDetailSection = formFactory.createPolytomousKeyDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(PolytomousKeyDetailSection.class, getInput().getClass().getCanonicalName()));
926

    
927
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
928

    
929
        PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(PolytomousKeyNodeDetailSection.class, getInput().getClass().getCanonicalName(), true));
930

    
931
        addPart(polytomousKeyDetailSection);
932
        addPart(polytomousKeyNodeDetailSection);
933

    
934
    }
935

    
936
    private void createUseRecordSection(RootElement parent) {
937
        UseRecordDetailSection descriptionUseRecordSection = formFactory.createUseRecordDetailSection(getConversationHolder(), parent, this,StoreUtil.getSectionStyle(UseRecordDetailSection.class, getInput().getClass().getCanonicalName(), true));
938
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
939
        addPart(descriptionUseRecordSection);
940
    }
941

    
942
    private void createUserSection(RootElement parent) {
943
        UserDetailSection userDetailSection = formFactory.createUserDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(UserDetailSection.class, getInput().getClass().getCanonicalName(), true));
944

    
945
        GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(GroupsByUserDetailSection.class, getInput().getClass().getCanonicalName(), true));
946

    
947
        addPart(userDetailSection);
948
        addPart(groupByUserDetailSection);
949
    }
950

    
951
    private void createMisappliedNameSection(RootElement parent) {
952
        TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this,
953
                StoreUtil.getSectionStyle(TaxonRelationshipDetailSection.class, getInput().getClass().getCanonicalName(), true));
954
        addPart(taxonRelationshipDetailSection);
955

    
956
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
957

    
958
        NonViralNameDetailSection nonViralNameSection = formFactory
959
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
960
                        StoreUtil.getSectionStyle(NonViralNameDetailSection.class, getInput().getClass().getCanonicalName(), true));
961
        addPart(nonViralNameSection);
962

    
963
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
964

    
965
        NomenclaturalSourceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
966
                StoreUtil.getSectionStyle(NomenclaturalSourceDetailSection.class, getInput().getClass().getCanonicalName(), true));
967
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
968
        addPart(referenceDetailSection);
969

    
970
        NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
971
            		StoreUtil.getSectionStyle(NomenclaturalStatusSection.class, getInput().getClass().getCanonicalName(), true));
972
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
973
        addPart(nomenclaturalStatusSection);
974

    
975
//		ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(ProtologueSection.class, getInput().getClass().getCanonicalName()));
976
//		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
977
//		addPart(protologSection);
978

    
979
		TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(TypeDesignationSection.class, getInput().getClass().getCanonicalName()));
980
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
981
		addPart(typeDesignationSection);
982

    
983
		NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(NameRelationshipDetailSection.class, getInput().getClass().getCanonicalName()));
984
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
985
		addPart(nameRelationshipSection);
986
    }
987

    
988
    private void createTaxonRelationshipSection(RootElement parent) {
989
        TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TaxonRelationshipDetailSection.class, getInput().getClass().getCanonicalName(), true));
990

    
991
        ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(ReferencedEntityDetailSection.class, getInput().getClass().getCanonicalName(), true));
992
        addPart(taxonRelationshipDetailSection);
993
        addPart(referencedEntityBaseDetailSection);
994
    }
995
    private void createTermVocabularySection(RootElement parent) {
996
        TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(TermVocabularyDetailSection.class, getInput().getClass().getCanonicalName(), true));
997
        addPart(termVocabularyDetailSection);
998
    }
999

    
1000
    private void createDefinedTermSection(RootElement parent) {
1001
        DefinedTermDetailSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DefinedTermDetailSection.class, getInput().getClass().getCanonicalName(), true));
1002
        addPart(definedTermDetailSection);
1003
        TermMediaSection termMediaSection = formFactory.createTermMediaSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DefinedTermDetailSection.class, getInput().getClass().getCanonicalName(), true));
1004
        addPart(termMediaSection);
1005
    }
1006

    
1007
    @Override
1008
    public void update(CdmDataChangeMap arg0) {
1009

    
1010
    }
1011
    @Inject
1012
    @Optional
1013
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_DETAILS)boolean refresh){
1014
        if(refresh){
1015
            refresh();
1016
        }
1017
    }
1018

    
1019
    @Inject
1020
    @Optional
1021
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_DETAILS_DISTRIBUTION)String nameCache){
1022
        if(nameCache != null && getInput() instanceof Distribution && this.activePart instanceof IDistributionEditorPart){
1023
           if (part instanceof CdmSectionPart && ((CdmSectionPart)part).getSection() instanceof DescriptionElementDetailSection){
1024
               for (ICdmFormElement element: ((DescriptionElementDetailSection)((CdmSectionPart)part).getSection()).getElements()){
1025
                   if (element instanceof DescriptionElementDetailElement){
1026
                       for(ICdmFormElement descriptionElement:((DescriptionElementDetailElement)element).getElements()){
1027
                           if (descriptionElement instanceof DistributionDetailElement){
1028
                               ((DistributionDetailElement) descriptionElement).setName(nameCache);
1029
                           }
1030
                       }
1031
                   }
1032
               }
1033
           }
1034
        }
1035
    }
1036
}
(2-2/2)