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;
public class DetailsViewer extends AbstractCdmDataViewer {
private ISelection selection;
-
+
public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) {
super(parent, viewPart);
}
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} */
ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
- addPart(taxonBaseDetailSection);
+ addPart(taxonBaseDetailSection, true);
}
NonViralNameDetailSection nonViralNameSection = formFactory
.createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
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)){
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);
}
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);
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);
}
}
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) {
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) {
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) {
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
- addPart(descriptionDetailSection);
- addPart(descriptionSourceSection);
+ addPart(descriptionDetailSection, true);
+ addPart(descriptionSourceSection, true);
}
destroySections();
DescriptionDetailSection descriptionDetailSection = formFactory.createDescriptionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- addPart(descriptionDetailSection);
+ addPart(descriptionDetailSection, true);
}
private void createMediaElementSection(RootElement parent) {
MediaDetailsSection mediaDetailSection = formFactory.createMediaDetailsSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- addPart(mediaDetailSection);
+ addPart(mediaDetailSection, true);
}
private void createDerivedUnitBaseElementSection(RootElement parent) {
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);
}
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);
}
}
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) {
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) {
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);
}
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);
}
FeatureDistributionDetailSection featureDistributionSection = formFactory.createFeatureDistributionDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- addPart(featureDistributionSection);
+ addPart(featureDistributionSection, true);
}
private void createPolytomousKeyNodeSection(RootElement parent) {
PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = formFactory.createPolytomousKeyNodeDetailSection(getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- addPart(polytomousKeyDetailSection);
- addPart(polytomousKeyNodeDetailSection);
+ addPart(polytomousKeyDetailSection, true);
+ addPart(polytomousKeyNodeDetailSection, true);
}
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
- addPart(descriptionUseRecordSection);
+ addPart(descriptionUseRecordSection, true);
}
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) {
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());
+ }
+
}
}