Project

General

Profile

« Previous | Next » 

Revision 90524380

Added by Patrick Plitzner over 5 years ago

ref #6554 Evaluate expansion state at widget creation time

Conflicts:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/StoreUtil.java
22 22
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23 23
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
24 24
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
25
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
25 26

  
26 27
/**
27 28
 * <p>StoreUtil class.</p>
......
133 134
	    return title.replace("&", "&&");
134 135
	}
135 136

  
137
    public static String getPrefKey(Class<? extends AbstractFormSection> sectionClass, Object entity) {
138
        return sectionClass.getCanonicalName()+";"+entity.getClass().getCanonicalName();
139
    }
140

  
136 141
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java
26 26
import org.eclipse.swt.widgets.Display;
27 27
import org.eclipse.swt.widgets.TypedListener;
28 28
import org.eclipse.swt.widgets.Widget;
29
import org.eclipse.ui.forms.events.ExpansionEvent;
30
import org.eclipse.ui.forms.events.IExpansionListener;
31 29
import org.eclipse.ui.forms.widgets.Section;
32 30
import org.eclipse.ui.forms.widgets.TableWrapLayout;
33 31
import org.eclipse.ui.forms.widgets.ToggleHyperlink;
......
37 35
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
38 36
import eu.etaxonomy.taxeditor.model.AbstractUtility;
39 37
import eu.etaxonomy.taxeditor.model.MessagingUtils;
40
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
41 38

  
42 39
/**
43 40
 * <p>
......
167 164
	 */
168 165
	public void setEntity(ENTITY entity) {
169 166
		this.entity = entity;
170
		addExpandListener();
171 167
	}
172 168

  
173 169
	/**
......
590 586

  
591 587
	}
592 588

  
593
    public class ExpandListener implements IExpansionListener{
594
		@Override
595
		public void expansionStateChanging(ExpansionEvent e) {
596
		}
597
		@Override
598
		public void expansionStateChanged(ExpansionEvent e) {
599
			PreferencesUtil.getPreferenceStore().setValue(getPrefKey(), e.getState());
600
		}
601
    }
602

  
603
    /**
604
     * Adds a custom implementation of IExpansionListener to this section
605
     * which stores the expansion state in the preferences
606
     */
607
	protected void addExpandListener() {
608
		PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(), isExpanded());
609
		setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey()));
610
		addExpansionListener(new ExpandListener());
611
	}
612

  
613
	private String getPrefKey() {
614
		return this.getClass().getCanonicalName()+";"+entity.getClass().getCanonicalName();
615
	}
616

  
617

  
618 589
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/CdmSectionPart.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.view.detail;
11 11

  
12
import java.awt.Event;
13 12
import java.util.EventObject;
14 13

  
15 14
import org.eclipse.jface.util.IPropertyChangeListener;
......
27 26
import eu.etaxonomy.taxeditor.model.MessagingUtils;
28 27
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
29 28
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
29
import eu.etaxonomy.taxeditor.store.StoreUtil;
30 30
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
31 31
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
32 32
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
33 33
import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
34 34
import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
35 35
import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
36
import eu.etaxonomy.taxeditor.ui.section.name.NameDetailSection;
37 36
import eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection;
38 37
import eu.etaxonomy.taxeditor.ui.section.name.NomenclaturalStatusSection;
39 38
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
......
42 41
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
43 42
import eu.etaxonomy.taxeditor.ui.section.occurrence.IDerivedUnitFacadeDetailSection;
44 43
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection;
45
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
46
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailElement;
47 44
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonDetailSection;
48
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonRelationshipDetailSection;
49 45

  
50 46
/**
51 47
 * <p>
......
151 147
			return true;
152 148
		}
153 149

  
154
		
150

  
155 151
		formSection.setEntity((T) input);
156 152

  
157 153
		return true;
......
194 190
		}
195 191
	}
196 192

  
193
	@Override
194
	protected void expansionStateChanged(boolean expanded) {
195
	    super.expansionStateChanged(expanded);
196
	    PreferencesUtil.getPreferenceStore().setValue(StoreUtil.getPrefKey(formSection.getClass(), formSection.getEntity()), expanded);
197
	}
198

  
197 199
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java
26 26
import org.eclipse.swt.widgets.Display;
27 27
import org.eclipse.ui.forms.IFormPart;
28 28
import org.eclipse.ui.forms.ManagedForm;
29
import org.eclipse.ui.forms.widgets.ExpandableComposite;
29 30
import org.eclipse.ui.forms.widgets.ScrolledForm;
30 31

  
31 32
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
......
34 35
import eu.etaxonomy.taxeditor.model.MessagingUtils;
35 36
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
36 37
import eu.etaxonomy.taxeditor.remoting.CdmEagerLoadingException;
38
import eu.etaxonomy.taxeditor.store.StoreUtil;
37 39
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
38 40
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
39 41
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
......
175 177
		body.layout();
176 178
	}
177 179

  
180
    protected int getSectionStyle(Class<? extends AbstractFormSection> clazz){
181
        int style = ExpandableComposite.TWISTIE;
182
        if(PreferencesUtil.getPreferenceStore().getBoolean(StoreUtil.getPrefKey(clazz, getInput()))){
183
            style |= ExpandableComposite.EXPANDED;
184
        }
185
        return style;
186
    }
187

  
178 188
	protected abstract void showParts();
179 189

  
180 190
	public void destroySections() {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
674 674

  
675 675
            destroySections();
676 676

  
677
            DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
678
            //TODO for DerivateEditor do not use facade anymore to avoid this special case handling #4539
679
            //        if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){
677
            DerivedUnitGeneralDetailSection derivedUnitGeneralDetailSection = formFactory.createDerivedUnitGeneralDetailSection(getConversationHolder(), parent, this, getSectionStyle(DerivedUnitGeneralDetailSection.class));
680 678
            derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true);
681 679
            //        }
682 680
            addPart(derivedUnitGeneralDetailSection);
......
685 683

  
686 684
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
687 685

  
688
            DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
686
            DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, getSectionStyle(DerivedUnitBaseDetailSection.class));
689 687
            addPart(derivedUnitBaseDetailSection);
690 688
            sections.add(derivedUnitBaseDetailSection);
691

  
692 689
            //        //for editors working with facades
693 690
            //        if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){
694 691
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
695
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
692
            GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, getSectionStyle(GatheringEventDetailSection.class));
696 693
            addPart(gatheringEventDetailSection);
697 694
            sections.add(gatheringEventDetailSection);
698 695

  
699 696
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
700
            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
697
            FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, getSectionStyle(FieldUnitDetailSection.class));
701 698
            addPart(fieldUnitDetailSection);
702 699
            sections.add(fieldUnitDetailSection);
703 700
            //        }
......
705 702
            //
706 703
            if(PreferencesUtil.isShowTaxonAssociations()){
707 704
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
708
                TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
705
                TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, getSectionStyle(TaxonAssociationDetailSection.class));
709 706
                addPart(taxonAssociationDetailSection);
710 707
                sections.add(taxonAssociationDetailSection);
711 708
            }
712 709
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
713
            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE);
710
            DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, getSectionStyle(DerivedUnitFacadeIdentifierSection.class));
714 711
            addPart(identifierDetailSection);
715 712
            sections.add(identifierDetailSection);
716 713
            //    }
717 714
            if(!PreferencesUtil.isDeterminationOnlyForFieldUnits()){
718 715
                formFactory.createHorizontalSeparator(parent, SWT.BORDER);
719
                DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
716
                DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, getSectionStyle(DeterminationDetailSection.class));
720 717
                addPart(determinationDetailSection);
721 718
                sections.add(determinationDetailSection);
722 719
            }
......
725 722
            DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
726 723
            addPart(derivedUnitTypeDesignationSection);
727 724
            sections.add(derivedUnitTypeDesignationSection);
728

  
729
            entityToSectionsMap.put(id, sections);
730 725
        }
726
        entityToSectionsMap.put(id, sections);
731 727
    }
732 728

  
733 729
    private void createFieldUnitSection(RootElement parent) {
734 730
        destroySections();
735 731

  
736
        FieldUnitGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
732
        FieldUnitGeneralDetailSection fielUnitGeneralDetailSection = formFactory.createFieldUnitGeneralDetailSection(getConversationHolder(), parent, this, getSectionStyle(FieldUnitGeneralDetailSection.class));
737 733

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

  
740
        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
736
        GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, getSectionStyle(GatheringEventDetailSection.class));
741 737

  
742 738
        formFactory.createHorizontalSeparator(parent, SWT.BORDER);
743 739

  
744
        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
740
        FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, getSectionStyle(FieldUnitDetailSection.class));
745 741

  
746 742
        addPart(fielUnitGeneralDetailSection);
747 743
        addPart(gatheringEventDetailSection);
......
749 745

  
750 746
        if(PreferencesUtil.isDeterminationOnlyForFieldUnits()){
751 747
            formFactory.createHorizontalSeparator(parent, SWT.BORDER);
752
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE);
748
            DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, getSectionStyle(DeterminationDetailSection.class));
753 749
            addPart(determinationDetailSection);
754 750
        }
755 751
    }

Also available in: Unified diff