From: Patrick Plitzner Date: Thu, 4 Aug 2016 08:58:48 +0000 (+0200) Subject: fix #5953 Save open/close states of detail view sections for specific X-Git-Tag: 4.3.0^2~91 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/956da1e40a57f4e7afd00e384bd1223efeab6af9?hp=2d7d6704d437d8d698819614b942ee7a4621a0ab fix #5953 Save open/close states of detail view sections for specific data types --- diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java index 0b4be864f..015b38521 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java @@ -18,7 +18,10 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeNode; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.events.IExpansionListener; import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.forms.widgets.Section; import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException; @@ -129,7 +132,7 @@ import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; public class DetailsViewer extends AbstractCdmDataViewer { private ISelection selection; - + public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) { super(parent, viewPart); } @@ -337,9 +340,9 @@ public class DetailsViewer extends AbstractCdmDataViewer { MemberDetailSection memberDetailSection = formFactory.createMemberDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); GrantedAuthorityDetailSection grantedAuthorityDetailSection = formFactory.createGrantedAuthorityDetailSection(getConversationHolder(), parent,ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(groupDetailSection); - addPart(memberDetailSection); - addPart(grantedAuthorityDetailSection); + addPart(groupDetailSection, true); + addPart(memberDetailSection, true); + addPart(grantedAuthorityDetailSection, true); } /** {@inheritDoc} */ @@ -368,7 +371,7 @@ public class DetailsViewer extends AbstractCdmDataViewer { ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(taxonBaseDetailSection); + addPart(taxonBaseDetailSection, true); } NonViralNameDetailSection nonViralNameSection = formFactory .createNonViralNameDetailSection(getConversationHolder(), parent, this, true, @@ -383,8 +386,8 @@ public class DetailsViewer extends AbstractCdmDataViewer { ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(nomenclaturalStatusSection); - addPart(referenceDetailSection); + addPart(nomenclaturalStatusSection, true); + addPart(referenceDetailSection, true); } //TODO RL if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL) && !PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION)){ @@ -397,14 +400,14 @@ public class DetailsViewer extends AbstractCdmDataViewer { NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(protologSection); - addPart(typeDesignationSection); - addPart(nameRelationshipSection); + addPart(protologSection, false); + addPart(typeDesignationSection, false); + addPart(nameRelationshipSection, false); } - addPart(parsingMessagesSection); + addPart(parsingMessagesSection, true); - addPart(nonViralNameSection); + addPart(nonViralNameSection, true); } @@ -423,9 +426,9 @@ public class DetailsViewer extends AbstractCdmDataViewer { ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(nonViralNameSection); - addPart(nomenclaturalStatusSection); - addPart(referenceDetailSection); + addPart(nonViralNameSection, true); + addPart(nomenclaturalStatusSection, true); + addPart(referenceDetailSection, true); //TODO RL if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){ ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); @@ -436,9 +439,9 @@ public class DetailsViewer extends AbstractCdmDataViewer { NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(protologSection); - addPart(typeDesignationSection); - addPart(nameRelationshipSection); + addPart(protologSection, false); + addPart(typeDesignationSection, false); + addPart(nameRelationshipSection, false); } } @@ -448,27 +451,27 @@ public class DetailsViewer extends AbstractCdmDataViewer { ReferenceDetailSection referenceDetailSection = formFactory.createReferenceDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(referenceDetailSection); + addPart(referenceDetailSection, true); } private void createTeamOrPersonBaseDetailSection(RootElement parent) { destroySections(); TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = formFactory.createTeamOrPersonBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(teamOrPersonBaseDetailSection); + addPart(teamOrPersonBaseDetailSection, true); } private void createTeamDetailSection(RootElement parent) { destroySections(); TeamDetailSection teamDetailSection = formFactory.createTeamDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(teamDetailSection); + addPart(teamDetailSection, true); } private void createPersonDetailSection(RootElement parent) { destroySections(); PersonDetailSection personDetailSection = formFactory.createPersonDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(personDetailSection); + addPart(personDetailSection, true); } private void createDescriptionElementSection(RootElement parent) { @@ -486,9 +489,9 @@ public class DetailsViewer extends AbstractCdmDataViewer { formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(descriptionElementDetailSection); - addPart(descriptionElementSourceSection); - addPart(descriptionElementMediaSection); + addPart(descriptionElementDetailSection, true); + addPart(descriptionElementSourceSection, false); + addPart(descriptionElementMediaSection, false); } private void createDescriptionSection(RootElement parent) { @@ -515,17 +518,17 @@ public class DetailsViewer extends AbstractCdmDataViewer { formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(descriptionDetailSection); - addPart(naturalLanguageSection); + addPart(descriptionDetailSection, true); + addPart(naturalLanguageSection, true); // addPart(describedSpecimenSection); // addPart(descriptionSourceSection); - addPart(scopeSection); + addPart(scopeSection, false); } private void createSpecimenDescriptionSection(RootElement parent) { destroySections(); DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(descriptionDetailSection); + addPart(descriptionDetailSection, true); } private void createUseDescriptionSection(RootElement parent) { @@ -538,8 +541,8 @@ public class DetailsViewer extends AbstractCdmDataViewer { formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(descriptionDetailSection); - addPart(descriptionSourceSection); + addPart(descriptionDetailSection, true); + addPart(descriptionSourceSection, true); } @@ -547,7 +550,7 @@ public class DetailsViewer extends AbstractCdmDataViewer { destroySections(); DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(descriptionDetailSection); + addPart(descriptionDetailSection, true); } private void createMediaElementSection(RootElement parent) { @@ -555,7 +558,7 @@ public class DetailsViewer extends AbstractCdmDataViewer { MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(mediaDetailSection); + addPart(mediaDetailSection, true); } private void createDerivedUnitBaseElementSection(RootElement parent) { @@ -566,43 +569,43 @@ public class DetailsViewer extends AbstractCdmDataViewer { if(!(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart)){ derivedUnitGeneralDetailSection.setShowOnlyDerivedUnitData(true); } - addPart(derivedUnitGeneralDetailSection); + addPart(derivedUnitGeneralDetailSection, true); formFactory.createHorizontalSeparator(parent, SWT.BORDER); DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(derivedUnitBaseDetailSection); + addPart(derivedUnitBaseDetailSection, true); //for editors working with facades if(AbstractUtility.getActivePart() instanceof IDerivedUnitFacadePart){ formFactory.createHorizontalSeparator(parent, SWT.BORDER); GatheringEventDetailSection gatheringEventDetailSection = formFactory.createGatheringEventDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - addPart(gatheringEventDetailSection); + addPart(gatheringEventDetailSection, false); formFactory.createHorizontalSeparator(parent, SWT.BORDER); FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - addPart(fieldUnitDetailSection); + addPart(fieldUnitDetailSection, false); } else{ if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS)){ formFactory.createHorizontalSeparator(parent, SWT.BORDER); TaxonAssociationDetailSection taxonAssociationDetailSection = formFactory.createTaxonAssociationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(taxonAssociationDetailSection); + addPart(taxonAssociationDetailSection, true); } formFactory.createHorizontalSeparator(parent, SWT.BORDER); DerivedUnitFacadeIdentifierSection identifierDetailSection = formFactory.createDerivedUnitFacadeIdentifierSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); - addPart(identifierDetailSection); + addPart(identifierDetailSection, false); } if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){ formFactory.createHorizontalSeparator(parent, SWT.BORDER); DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - addPart(determinationDetailSection); + addPart(determinationDetailSection, false); } formFactory.createHorizontalSeparator(parent, SWT.BORDER); DerivedUnitTypeDesignationSection derivedUnitTypeDesignationSection = formFactory.createDerivedUnitTypeDesignationSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - addPart(derivedUnitTypeDesignationSection); + addPart(derivedUnitTypeDesignationSection, false); } @@ -619,14 +622,14 @@ public class DetailsViewer extends AbstractCdmDataViewer { FieldUnitDetailSection fieldUnitDetailSection = formFactory.createFieldUnitDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - addPart(fielUnitGeneralDetailSection); - addPart(gatheringEventDetailSection); - addPart(fieldUnitDetailSection); + addPart(fielUnitGeneralDetailSection, true); + addPart(gatheringEventDetailSection, false); + addPart(fieldUnitDetailSection, false); if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){ formFactory.createHorizontalSeparator(parent, SWT.BORDER); DeterminationDetailSection determinationDetailSection = formFactory.createDeterminationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - addPart(determinationDetailSection); + addPart(determinationDetailSection, false); } } @@ -639,8 +642,8 @@ public class DetailsViewer extends AbstractCdmDataViewer { SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(section); - addPart(sampleDesignationDetailSection); + addPart(section, true); + addPart(sampleDesignationDetailSection, true); } private void createDnaSampleSection(RootElement parent) { @@ -660,10 +663,10 @@ public class DetailsViewer extends AbstractCdmDataViewer { SampleDesignationDetailSection sampleDesignationDetailSection = formFactory.createSampleDesignationDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(section); - addPart(preparationPreservationSection); - addPart(qualitySection); - addPart(sampleDesignationDetailSection); + addPart(section, true); + addPart(preparationPreservationSection, true); + addPart(qualitySection, true); + addPart(sampleDesignationDetailSection, true); } private void createSequenceSection(RootElement parent) { @@ -680,21 +683,21 @@ public class DetailsViewer extends AbstractCdmDataViewer { SequenceContigFileCollectionDetailSection contigFileSection = formFactory.createSequenceContigFileCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(section); - addPart(referenceSection); - addPart(contigFileSection); + addPart(section, true); + addPart(referenceSection, true); + addPart(contigFileSection, true); } private void createSingleReadSection(RootElement parent) { destroySections(); SingleReadGeneralDetailSection section = formFactory.createSingleReadGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(section); + addPart(section, true); formFactory.createHorizontalSeparator(parent, SWT.BORDER); SingleReadPherogramCollectionDetailSection pherogramSection = formFactory.createSingleReadPherogramCollectionDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(pherogramSection); + addPart(pherogramSection, true); } @@ -702,12 +705,12 @@ public class DetailsViewer extends AbstractCdmDataViewer { destroySections(); MediaSpecimenGeneralDetailSection generalSection = formFactory.createMediaSpecimenGeneralDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(generalSection); + addPart(generalSection, true); formFactory.createHorizontalSeparator(parent, SWT.BORDER); RightsSection rightsSection = formFactory.createRightsSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); - addPart(rightsSection); + addPart(rightsSection, false); } @@ -716,7 +719,7 @@ public class DetailsViewer extends AbstractCdmDataViewer { FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(featureDistributionSection); + addPart(featureDistributionSection, true); } private void createPolytomousKeyNodeSection(RootElement parent) { @@ -728,8 +731,8 @@ public class DetailsViewer extends AbstractCdmDataViewer { PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(polytomousKeyDetailSection); - addPart(polytomousKeyNodeDetailSection); + addPart(polytomousKeyDetailSection, true); + addPart(polytomousKeyNodeDetailSection, true); } @@ -740,7 +743,7 @@ public class DetailsViewer extends AbstractCdmDataViewer { formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(descriptionUseRecordSection); + addPart(descriptionUseRecordSection, true); } @@ -752,8 +755,8 @@ public class DetailsViewer extends AbstractCdmDataViewer { GroupsByUserDetailSection groupByUserDetailSection = formFactory.createGroupsByUserDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(userDetailSection); - addPart(groupByUserDetailSection); + addPart(userDetailSection, true); + addPart(groupByUserDetailSection, true); } private void createTaxonRelationshipSection(RootElement parent) { @@ -762,22 +765,49 @@ public class DetailsViewer extends AbstractCdmDataViewer { TaxonRelationshipDetailSection taxonRelationshipDetailSection = formFactory.createTaxonRelationshipDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); ReferencedEntityDetailSection referencedEntityBaseDetailSection = formFactory.createReferencedEntityDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(taxonRelationshipDetailSection); - addPart(referencedEntityBaseDetailSection); + addPart(taxonRelationshipDetailSection, true); + addPart(referencedEntityBaseDetailSection, true); } private void createTermVocabularySection(RootElement parent) { destroySections(); TermVocabularyDetailSection termVocabularyDetailSection = formFactory.createTermVocabularyDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(termVocabularyDetailSection); + addPart(termVocabularyDetailSection, true); } private void createDefinedTermSection(RootElement parent) { destroySections(); AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(definedTermDetailSection); + addPart(definedTermDetailSection, true); + } + + protected void addPart(AbstractFormSection section, boolean isDefaultExpanded){ + super.addPart(section); + PreferencesUtil.getPreferenceStore().setDefault(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), isDefaultExpanded); + section.setExpanded(PreferencesUtil.getPreferenceStore().getBoolean(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName())); + section.addExpansionListener(new ExpandListener(section)); + } + + private class ExpandListener implements IExpansionListener{ + + private Section section; + + public ExpandListener(Section section) { + super(); + this.section = section; + } + + @Override + public void expansionStateChanging(ExpansionEvent e) { + } + + @Override + public void expansionStateChanged(ExpansionEvent e) { + PreferencesUtil.getPreferenceStore().setValue(section.getClass().getCanonicalName()+";"+getInput().getClass().getCanonicalName(), e.getState()); + } + } }