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