Project

General

Profile

« Previous | Next » 

Revision 956da1e4

Added by Patrick Plitzner over 7 years ago

fix #5953 Save open/close states of detail view sections for specific
data types

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
18 18
import org.eclipse.jface.viewers.TreeNode;
19 19
import org.eclipse.swt.SWT;
20 20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.ui.forms.events.ExpansionEvent;
22
import org.eclipse.ui.forms.events.IExpansionListener;
21 23
import org.eclipse.ui.forms.widgets.ExpandableComposite;
24
import org.eclipse.ui.forms.widgets.Section;
22 25

  
23 26
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
24 27
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
......
129 132
public class DetailsViewer extends AbstractCdmDataViewer {
130 133

  
131 134
    private ISelection selection;
132

  
135
    
133 136
    public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
134 137
        super(parent, viewPart);
135 138
    }
......
337 340
        MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
338 341
        GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
339 342

  
340
        addPart(groupDetailSection);
341
        addPart(memberDetailSection);
342
        addPart(grantedAuthorityDetailSection);
343
        addPart(groupDetailSection, true);
344
        addPart(memberDetailSection, true);
345
        addPart(grantedAuthorityDetailSection, true);
343 346
    }
344 347

  
345 348
    /** {@inheritDoc} */
......
368 371
            		ExpandableComposite.TWISTIE	| ExpandableComposite.EXPANDED);
369 372
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
370 373

  
371
            addPart(taxonBaseDetailSection);
374
            addPart(taxonBaseDetailSection, true);
372 375
        }
373 376
        NonViralNameDetailSection nonViralNameSection = formFactory
374 377
                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
......
383 386
            		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
384 387
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
385 388

  
386
            addPart(nomenclaturalStatusSection);
387
            addPart(referenceDetailSection);
389
            addPart(nomenclaturalStatusSection, true);
390
            addPart(referenceDetailSection, true);
388 391
        }
389 392
        //TODO RL
390 393
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)  && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){
......
397 400
	        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
398 401
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
399 402

  
400
			addPart(protologSection);
401
			addPart(typeDesignationSection);
402
			addPart(nameRelationshipSection);
403
			addPart(protologSection, false);
404
			addPart(typeDesignationSection, false);
405
			addPart(nameRelationshipSection, false);
403 406
        }
404 407

  
405
        addPart(parsingMessagesSection);
408
        addPart(parsingMessagesSection, true);
406 409

  
407
        addPart(nonViralNameSection);
410
        addPart(nonViralNameSection, true);
408 411

  
409 412
    }
410 413

  
......
423 426
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
424 427
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
425 428

  
426
        addPart(nonViralNameSection);
427
        addPart(nomenclaturalStatusSection);
428
        addPart(referenceDetailSection);
429
        addPart(nonViralNameSection, true);
430
        addPart(nomenclaturalStatusSection, true);
431
        addPart(referenceDetailSection, true);
429 432
//TODO RL
430 433
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
431 434
			ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
......
436 439

  
437 440
	        NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
438 441
	        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
439
	        addPart(protologSection);
440
	        addPart(typeDesignationSection);
441
	        addPart(nameRelationshipSection);
442
	        addPart(protologSection, false);
443
	        addPart(typeDesignationSection, false);
444
	        addPart(nameRelationshipSection, false);
442 445
        }
443 446
    }
444 447

  
......
448 451
        ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this,
449 452
        		ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
450 453

  
451
        addPart(referenceDetailSection);
454
        addPart(referenceDetailSection, true);
452 455
    }
453 456

  
454 457
    private void createTeamOrPersonBaseDetailSection(RootElement parent) {
455 458
        destroySections();
456 459
        TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
457 460

  
458
        addPart(teamOrPersonBaseDetailSection);
461
        addPart(teamOrPersonBaseDetailSection, true);
459 462
    }
460 463

  
461 464
    private void createTeamDetailSection(RootElement parent) {
462 465
        destroySections();
463 466
        TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
464 467

  
465
        addPart(teamDetailSection);
468
        addPart(teamDetailSection, true);
466 469
    }
467 470

  
468 471
    private void createPersonDetailSection(RootElement parent) {
469 472
        destroySections();
470 473
        PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
471
        addPart(personDetailSection);
474
        addPart(personDetailSection, true);
472 475
    }
473 476

  
474 477
    private void createDescriptionElementSection(RootElement parent) {
......
486 489

  
487 490
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
488 491

  
489
        addPart(descriptionElementDetailSection);
490
        addPart(descriptionElementSourceSection);
491
        addPart(descriptionElementMediaSection);
492
        addPart(descriptionElementDetailSection, true);
493
        addPart(descriptionElementSourceSection, false);
494
        addPart(descriptionElementMediaSection, false);
492 495
    }
493 496

  
494 497
    private void createDescriptionSection(RootElement parent) {
......
515 518

  
516 519
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
517 520

  
518
        addPart(descriptionDetailSection);
519
        addPart(naturalLanguageSection);
521
        addPart(descriptionDetailSection, true);
522
        addPart(naturalLanguageSection, true);
520 523
//        addPart(describedSpecimenSection);
521 524
        //		addPart(descriptionSourceSection);
522
        addPart(scopeSection);
525
        addPart(scopeSection, false);
523 526
    }
524 527

  
525 528
    private void createSpecimenDescriptionSection(RootElement parent) {
526 529
        destroySections();
527 530
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
528
        addPart(descriptionDetailSection);
531
        addPart(descriptionDetailSection, true);
529 532
    }
530 533

  
531 534
    private void createUseDescriptionSection(RootElement parent) {
......
538 541

  
539 542
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
540 543

  
541
        addPart(descriptionDetailSection);
542
        addPart(descriptionSourceSection);
544
        addPart(descriptionDetailSection, true);
545
        addPart(descriptionSourceSection, true);
543 546

  
544 547
    }
545 548

  
......
547 550
        destroySections();
548 551
        DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
549 552

  
550
        addPart(descriptionDetailSection);
553
        addPart(descriptionDetailSection, true);
551 554
    }
552 555

  
553 556
    private void createMediaElementSection(RootElement parent) {
......
555 558

  
556 559
        MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
557 560

  
558
        addPart(mediaDetailSection);
561
        addPart(mediaDetailSection, true);
559 562
    }
560 563

  
561 564
    private void createDerivedUnitBaseElementSection(RootElement parent) {
......
566 569
        if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
567 570
            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
568 571
        }
569
        addPart(derivedUnitGeneralDetailSection);
572
        addPart(derivedUnitGeneralDetailSection, true);
570 573

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

  
573 576
        DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
574
        addPart(derivedUnitBaseDetailSection);
577
        addPart(derivedUnitBaseDetailSection, true);
575 578

  
576 579
        //for editors working with facades
577 580
        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
578 581
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
579 582
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
580
            addPart(gatheringEventDetailSection);
583
            addPart(gatheringEventDetailSection, false);
581 584

  
582 585
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
583 586
            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
584
            addPart(fieldUnitDetailSection);
587
            addPart(fieldUnitDetailSection, false);
585 588
        }
586 589
        else{
587 590

  
588 591
            if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS)){
589 592
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
590 593
                TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
591
                addPart(taxonAssociationDetailSection);
594
                addPart(taxonAssociationDetailSection, true);
592 595
            }
593 596
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
594 597
            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
595
            addPart(identifierDetailSection);
598
            addPart(identifierDetailSection, false);
596 599
        }
597 600
        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
598 601
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
599 602
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
600
            addPart(determinationDetailSection);
603
            addPart(determinationDetailSection, false);
601 604
        }
602 605

  
603 606
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
604 607
        DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
605
        addPart(derivedUnitTypeDesignationSection);
608
        addPart(derivedUnitTypeDesignationSection, false);
606 609

  
607 610
    }
608 611

  
......
619 622

  
620 623
        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
621 624

  
622
        addPart(fielUnitGeneralDetailSection);
623
        addPart(gatheringEventDetailSection);
624
        addPart(fieldUnitDetailSection);
625
        addPart(fielUnitGeneralDetailSection, true);
626
        addPart(gatheringEventDetailSection, false);
627
        addPart(fieldUnitDetailSection, false);
625 628

  
626 629
        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
627 630
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
628 631
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
629
            addPart(determinationDetailSection);
632
            addPart(determinationDetailSection, false);
630 633
        }
631 634
    }
632 635

  
......
639 642

  
640 643
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
641 644

  
642
        addPart(section);
643
        addPart(sampleDesignationDetailSection);
645
        addPart(section, true);
646
        addPart(sampleDesignationDetailSection, true);
644 647
    }
645 648

  
646 649
    private void createDnaSampleSection(RootElement parent) {
......
660 663

  
661 664
        SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
662 665

  
663
        addPart(section);
664
        addPart(preparationPreservationSection);
665
        addPart(qualitySection);
666
        addPart(sampleDesignationDetailSection);
666
        addPart(section, true);
667
        addPart(preparationPreservationSection, true);
668
        addPart(qualitySection, true);
669
        addPart(sampleDesignationDetailSection, true);
667 670
    }
668 671

  
669 672
    private void createSequenceSection(RootElement parent) {
......
680 683
        SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
681 684

  
682 685

  
683
        addPart(section);
684
        addPart(referenceSection);
685
        addPart(contigFileSection);
686
        addPart(section, true);
687
        addPart(referenceSection, true);
688
        addPart(contigFileSection, true);
686 689
    }
687 690

  
688 691
    private void createSingleReadSection(RootElement parent) {
689 692
        destroySections();
690 693

  
691 694
        SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
692
        addPart(section);
695
        addPart(section, true);
693 696

  
694 697
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
695 698

  
696 699
        SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
697
        addPart(pherogramSection);
700
        addPart(pherogramSection, true);
698 701

  
699 702
    }
700 703

  
......
702 705
        destroySections();
703 706

  
704 707
        MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
705
        addPart(generalSection);
708
        addPart(generalSection, true);
706 709

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

  
709 712
        RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
710
        addPart(rightsSection);
713
        addPart(rightsSection, false);
711 714

  
712 715
    }
713 716

  
......
716 719

  
717 720
        FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
718 721

  
719
        addPart(featureDistributionSection);
722
        addPart(featureDistributionSection, true);
720 723
    }
721 724

  
722 725
    private void createPolytomousKeyNodeSection(RootElement parent) {
......
728 731

  
729 732
        PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
730 733

  
731
        addPart(polytomousKeyDetailSection);
732
        addPart(polytomousKeyNodeDetailSection);
734
        addPart(polytomousKeyDetailSection, true);
735
        addPart(polytomousKeyNodeDetailSection, true);
733 736

  
734 737
    }
735 738

  
......
740 743

  
741 744
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
742 745

  
743
        addPart(descriptionUseRecordSection);
746
        addPart(descriptionUseRecordSection, true);
744 747

  
745 748

  
746 749
    }
......
752 755

  
753 756
        GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
754 757

  
755
        addPart(userDetailSection);
756
        addPart(groupByUserDetailSection);
758
        addPart(userDetailSection, true);
759
        addPart(groupByUserDetailSection, true);
757 760
    }
758 761

  
759 762
    private void createTaxonRelationshipSection(RootElement parent) {
......
762 765
        TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
763 766

  
764 767
        ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
765
        addPart(taxonRelationshipDetailSection);
766
        addPart(referencedEntityBaseDetailSection);
768
        addPart(taxonRelationshipDetailSection, true);
769
        addPart(referencedEntityBaseDetailSection, true);
767 770
    }
768 771

  
769 772
    private void createTermVocabularySection(RootElement parent) {
770 773
        destroySections();
771 774

  
772 775
        TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
773
        addPart(termVocabularyDetailSection);
776
        addPart(termVocabularyDetailSection, true);
774 777
    }
775 778

  
776 779
    private void createDefinedTermSection(RootElement parent) {
777 780
        destroySections();
778 781

  
779 782
        AbstractFormSection<?> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
780
        addPart(definedTermDetailSection);
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
    	
781 811
    }
782 812

  
783 813
}

Also available in: Unified diff