Handle ampersand correctly in section titles (#5142)
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 24 Aug 2015 05:00:42 +0000 (07:00 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 24 Aug 2015 08:39:19 +0000 (10:39 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AuthorshipDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailSection.java

index 07f08c7..1d27907 100644 (file)
@@ -42,27 +42,6 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
 
        protected ICdmDetailElement<ENTITY> detailElement;
 
-       /**
-        * <p>
-        * Constructor for AbstractCdmDetailSection.
-        * </p>
-        *
-        * @param formFactory
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
-        *            object.
-        * @param conversation
-        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *            object.
-        * @param parentElement
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
-        *            object.
-        * @param selectionProvider
-        *            a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
-        * @param style
-        *            a int.
-        * @param <ENTITY>
-        *            a ENTITY object.
-        */
        public AbstractCdmDetailSection(CdmFormFactory formFactory,
                        ConversationHolder conversation, ICdmFormElement parentElement,
                        ISelectionProvider selectionProvider, int style) {
@@ -88,11 +67,6 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
         }
        }
 
-       /**
-        * @param abstractCdmDetailSection
-        * @param definedTermClass
-        * @param null1
-        */
        protected void createControlsByType(AbstractCdmDetailSection<ENTITY> formElement, Class<ENTITY> entityClass, int style) {
            TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout();
            layout.topMargin = 10;
@@ -107,19 +81,6 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
            }
        }
 
-
-       /**
-        * <p>
-        * createControls
-        * </p>
-        *
-        * @param formElement
-        *            a
-        *            {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection}
-        *            object.
-        * @param style
-        *            a int.
-        */
        protected void createControls(AbstractCdmDetailSection<ENTITY> formElement, int style) {
            createControlsByType(formElement, null, style);
        }
@@ -130,13 +91,6 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
            return createCdmDetailElement(parentElement, style);
        }
 
-       /**
-        * <p>
-        * getHeading
-        * </p>
-        *
-        * @return the heading for this section
-        */
        public abstract String getHeading();
 
        /** {@inheritDoc} */
@@ -152,13 +106,6 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
                super.dispose();
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground
-        * (org.eclipse.swt.graphics.Color)
-        */
        /** {@inheritDoc} */
        @Override
        public void setBackground(Color color) {
@@ -168,14 +115,6 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
                super.setBackground(color);
        }
 
-       /**
-        * <p>
-        * setEntity
-        * </p>
-        *
-        * @param entity
-        *            a ENTITY object.
-        */
        @Override
        public void setEntity(ENTITY entity) {
                if (detailElement != null) {
@@ -186,33 +125,24 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
                layout();
        }
 
-       /**
-        * <p>
-        * setSectionTitle
-        * </p>
-        */
        protected void setSectionTitle() {
                String title = "";
                if (getEntity() != null && (getEntity() instanceof IdentifiableEntity) && !(getEntity() instanceof SpecimenOrObservationBase)) {
                        title = ": " + ((IdentifiableEntity) getEntity()).getTitleCache();
+                       // we have to duplicate ampersands otherwise they are treated as
+                       // mnenomic (see Label.setText() documentation)
+                       // see also #4302
+                       title = title.replace("&", "&&");
                }
                this.setText(String.format("%s%s", getHeading(), title));
                setTextClient(createToolbar());
        }
 
-       /**
-        * @return
-        */
        protected Control createToolbar() {
                ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
                return toolBarManager.createControl(this);
        }
 
-       /**
-        * <p>
-        * updateTitle
-        * </p>
-        */
        public void updateTitle() {
                if (!isDisposed()) {
                        setSectionTitle();
index 44aa277..e6f7939 100644 (file)
@@ -23,8 +23,6 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
 
 /**
- * <p>AuthorshipDetailSection class.</p>
- *
  * @author n.hoffmann
  * @created 05.06.2009
  * @version 1.0
@@ -33,38 +31,11 @@ public class AuthorshipDetailSection extends AbstractCdmDetailSection<NonViralNa
 
        private TaxonBase taxonBase;
 
-       /**
-        * <p>Constructor for AuthorshipDetailSection.</p>
-        *
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
-        * @param style a int.
-        * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
-        */
        public AuthorshipDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement,
                        ISelectionProvider selectionProvider, int style) {
                super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
        }
 
-       /**
-        * {@inheritDoc}
-        *
-        * Author title is not in titleCache field
-        * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#setSectionTitle()
-        */
-       @Override
-       protected void setSectionTitle() {
-               if(getEntity() != null){
-                       String title = getHeading() + ": " + getEntity().getAuthorshipCache();
-               // we have to duplicate ampersands otherwise they are treated as
-               // mnenomic (see Label.setText() documentation)
-            // see also #4302
-               title = title.replace("&", "&&");
-            this.setText(title);
-               }
-       }
-
        /** {@inheritDoc} */
        @Override
     public void setTaxonBase(TaxonBase entity) {
@@ -73,27 +44,17 @@ public class AuthorshipDetailSection extends AbstractCdmDetailSection<NonViralNa
                setEntity(name);
        }
 
-       /*
-        * (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractCdmDetailSection#getHeading()
-        */
        /** {@inheritDoc} */
        @Override
        public String getHeading() {
                return "Authorship";
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
-        */
        @Override
        public TaxonBase getTaxonBase() {
                return taxonBase;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
-        */
        @Override
        protected AbstractCdmDetailElement<NonViralName> createCdmDetailElement(AbstractCdmDetailSection<NonViralName> parentElement, int style) {
            return formFactory.createAuthorshipDetailElement(parentElement, style);
index a44b2e7..4f4c09e 100644 (file)
@@ -36,8 +36,6 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
 
 /**
- * <p>NonViralNameDetailSection class.</p>
- *
  * @author n.hoffmann
  * @created May 20, 2010
  * @version 1.0
@@ -61,9 +59,6 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
                super(formFactory, conversation, parentElement, selectionProvider, style);
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#createToolbar()
-        */
        @Override
        protected Control createToolbar() {
                ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
@@ -122,26 +117,16 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
        }
 
 
-       /**
-        * @param nonViralName
-        *
-        */
        private boolean checkForMultipleNameUsages(NonViralName nonViralName) {
                return nonViralName.getTaxonBases().size() != 1;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading()
-        */
        /** {@inheritDoc} */
        @Override
        public String getHeading() {
                return "Name";
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
-        */
        /** {@inheritDoc} */
        @Override
     public void setTaxonBase(TaxonBase taxon) {
@@ -150,32 +135,11 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
                setEntity(name);
        }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#setSectionTitle()
-     */
-    @Override
-    protected void setSectionTitle() {
-        super.setSectionTitle();
-        String title = getText();
-        // we have to duplicate ampersands otherwise they are treated as
-        // mnenomic (see Label.setText() documentation)
-        // see also #4302
-        title = title.replace("&", "&&");
-        setText(title);
-    }
-
-
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
-        */
        @Override
        public TaxonBase getTaxonBase() {
                return taxonBase;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
-        */
        @Override
        protected AbstractCdmDetailElement<NonViralName> createCdmDetailElement(AbstractCdmDetailSection<NonViralName> parentElement, int style) {
            return formFactory.createNonViralNameDetailElement(parentElement);
index 3a3a1fa..86c1dec 100644 (file)
@@ -20,23 +20,12 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
 
 /**
- * <p>TaxonBaseDetailSection class.</p>
- *
  * @author n.hoffmann
  * @created Nov 4, 2009
  * @version 1.0
  */
 public class TaxonBaseDetailSection extends AbstractCdmDetailSection<TaxonBase> {
 
-       /**
-        * <p>Constructor for TaxonBaseDetailSection.</p>
-        *
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
-        * @param style a int.
-        * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
-        */
        public TaxonBaseDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
                super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
        }
@@ -47,26 +36,9 @@ public class TaxonBaseDetailSection extends AbstractCdmDetailSection<TaxonBase>
                return getEntity() != null ? getEntity().getClass().getSimpleName() : "TaxonBase";
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
-        */
        @Override
        protected AbstractCdmDetailElement<TaxonBase> createCdmDetailElement(AbstractCdmDetailSection<TaxonBase> parentElement, int style) {
            return formFactory.createTaxonBaseDetailElement(parentElement, style);
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#setSectionTitle()
-        */
-       @Override
-       protected void setSectionTitle() {
-           super.setSectionTitle();
-           String title = getText();
-        // we have to duplicate ampersands otherwise they are treated as
-        // mnenomic (see Label.setText() documentation)
-        // see also #4302
-        title = title.replace("&", "&&");
-        setText(title);
-       }
-
 }