From 5a0731384fe4249373ebcfa5fab58bbbf0bfb472 Mon Sep 17 00:00:00 2001 From: Patrick Plitzner
Abstract AbstractCdmDataViewer class.
- * * @author n.hoffmann * @created Feb 9, 2010 * @version 1.0 @@ -53,20 +55,11 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat private final AbstractCdmViewPart viewPart; - /** - *Constructor for AbstractCdmDataViewer.
- * - * @param parent a {@link org.eclipse.swt.widgets.Composite} object. - * @param viewPart a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} object. - */ public AbstractCdmDataViewer(Composite parent, AbstractCdmViewPart viewPart) { this.viewPart = viewPart; managedForm = new ManagedForm(parent){ - /* (non-Javadoc) - * @see org.eclipse.ui.forms.ManagedForm#dirtyStateChanged() - */ @Override public void dirtyStateChanged() { markViewPartDirty(); @@ -84,9 +77,6 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat rootElement = new RootElement(formFactory, body); } - /** - *createFormFactory
- */ protected void createFormFactory() { if(formFactory != null){ formFactory.dispose(); @@ -99,17 +89,10 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat viewPart.changed(input); } - - /** - * @return - */ protected AbstractCdmViewPart getViewPart() { return viewPart; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.Viewer#getControl() - */ /** {@inheritDoc} */ @Override public Control getControl() { @@ -123,9 +106,6 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat return body; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object) - */ /** {@inheritDoc} */ @Override public void setInput(Object input) { @@ -135,18 +115,12 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat refresh(); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.Viewer#getInput() - */ /** {@inheritDoc} */ @Override public Object getInput() { return input; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.Viewer#refresh() - */ /** {@inheritDoc} */ @Override public void refresh() { @@ -159,26 +133,15 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat managedForm.reflow(true); } - - /** - *layout
- */ public void layout(){ body.layout(); } - /** - *showParts
- */ protected abstract void showParts(); - - /** - *destroySections
- */ protected void destroySections() { for (IFormPart formPart : managedForm.getParts()){ - removePart((CdmSectionPart) formPart); + removePart((CdmSectionPart>) formPart); } managedForm.setInput(null); @@ -195,10 +158,6 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat } } - - /** - *setFocus
- */ public void setFocus(){ // we have to set focus to a control of this viewer // otherwise, after opening a dialog from the details, the focus will not be @@ -209,39 +168,24 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat } } - /** - *reflow
- */ public void reflow(){ managedForm.reflow(true); } - /** - *removePart
- * - * @param sectionPart a {@link eu.etaxonomy.taxeditor.view.detail.CdmSectionPart} object. - */ - protected void removePart(CdmSectionPart sectionPart){ + protected void removePart(CdmSectionPart> sectionPart){ managedForm.removePart(sectionPart); formFactory.removePropertyChangeListener(sectionPart); } - /** - *addPart
- * - * @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object. - */ - protected void addPart(AbstractFormSection section){ - CdmSectionPart sectionPart = new CdmSectionPart(section); + protected void addPart(AbstractFormSection> section, boolean isDefaultExpanded){ + CdmSectionPart> sectionPart = new CdmSectionPart<>(section); managedForm.addPart(sectionPart); formFactory.addPropertyChangeListener(sectionPart); + 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)); } - /** - *getConversationHolder
- * - * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object. - */ @Override public ConversationHolder getConversationHolder() { return viewPart.getConversationHolder(); @@ -250,5 +194,25 @@ public abstract class AbstractCdmDataViewer extends Viewer implements IConversat /** {@inheritDoc} */ @Override public void update(CdmDataChangeMap changeEvents) {} + + 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()); + } + + } } 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 015b38521..79f8a19d2 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,10 +18,7 @@ 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; @@ -330,7 +327,7 @@ public class DetailsViewer extends AbstractCdmDataViewer { EmptySection emptySection = formFactory.createEmptySection(formFactory, parent, SWT.NONE); - addPart(emptySection); + addPart(emptySection, false); } private void createGroupSection(RootElement parent) { @@ -782,32 +779,5 @@ public class DetailsViewer extends AbstractCdmDataViewer { AbstractFormSection> definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); 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()); - } - - } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java index 2bf4227dd..4cd8d0601 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java @@ -131,7 +131,7 @@ public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISe private void createHeadlineSection(RootElement parent){ HeadlineSection headlineSection = formFactory.createHeadlineSection(parent); - addPart(headlineSection); + addPart(headlineSection, false); } private void createAnnotationSections(RootElement parent) { @@ -143,8 +143,8 @@ public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISe formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(annotationSection); - addPart(markerSection); + addPart(annotationSection, false); + addPart(markerSection, false); } private void createIdentifiableSections(RootElement parent) { @@ -166,11 +166,11 @@ public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISe IdentifierSection identifierSection = formFactory.createIdentifierDetailSection(getConversationHolder(), parent, ExpandableComposite.TWISTIE); - addPart(creditSection); - addPart(extensionSection); - addPart(rightsSection); - addPart(sourceSection); - addPart(identifierSection); + addPart(creditSection, false); + addPart(extensionSection, false); + addPart(rightsSection, false); + addPart(sourceSection, false); + addPart(identifierSection, false); } @@ -179,12 +179,12 @@ public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISe formFactory.createHorizontalSeparator(parent, SWT.BORDER); - addPart(mediaSection); + addPart(mediaSection, false); } private void createVersionSection(RootElement parent){ VersionSection versionSection = formFactory.createVersionSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED); - addPart(versionSection); + addPart(versionSection, true); } /** @@ -193,7 +193,7 @@ public class SupplementalDataViewer extends AbstractCdmDataViewer implements ISe private void createCdmBaseSection(RootElement parent) { CdmBaseSection cdmBaseSection = formFactory.createCdmBaseSection(parent, ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED); - addPart(cdmBaseSection); + addPart(cdmBaseSection, true); } /* -- 2.34.1