cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / AuthorshipDetailSection.java
index 7fba074cd955d3b01b3917ce0afeeb8a6d05d765..6a407358a9769ba96540c87d83e8ddcbeef8f4ce 100644 (file)
@@ -1,94 +1,74 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
-
 package eu.etaxonomy.taxeditor.ui.section.name;
 
 import org.eclipse.jface.viewers.ISelectionProvider;
 
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.name.INonViralName;
+import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
+import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 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
  */
-public class AuthorshipDetailSection extends AbstractCdmDetailSection<NonViralName> implements ITaxonBaseDetailSection {
+public class AuthorshipDetailSection extends AbstractCdmDetailSection<INonViralName> implements ITaxonBaseDetailSection {
 
-       private TaxonBase taxonBase;
+       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,
+       public AuthorshipDetailSection(CdmFormFactory cdmFormFactory, 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){
-                       this.setText(getHeading() + ": " + getEntity().getAuthorshipCache());
-               }
+               super(cdmFormFactory, parentElement, selectionProvider, style);
        }
 
-       /** {@inheritDoc} */
-       public void setTaxonBase(TaxonBase entity) {
+       @Override
+    public void setTaxonBase(TaxonBase entity) {
                this.taxonBase = entity;
-               NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
+               INonViralName name = HibernateProxyHelper.deproxy(entity.getName());
                setEntity(name);
        }
 
-       /*
-        * (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractCdmDetailSection#getHeading()
-        */
-       /** {@inheritDoc} */
        @Override
        public String getHeading() {
                return "Authorship";
        }
-       
-       /** {@inheritDoc} */
-       @Override
-       protected DetailType getDetailType() {
-               return DetailType.AUTHORSHIP;
-       }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
-        */
        @Override
        public TaxonBase getTaxonBase() {
                return taxonBase;
        }
-       
-}
+
+       @Override
+       protected void setSectionTitle() {
+        String title = "";
+        String label = "";
+        if (getEntity() != null && (getEntity() instanceof TaxonName) ) {
+            label =((TaxonName) getEntity()).getAuthorshipCache();
+            title = ": " + label;
+        }
+        this.setText(String.format("%s%s", getHeading(), title));
+        setTextClient(createToolbar());
+    }
+
+       @Override
+       protected AbstractCdmDetailElement<INonViralName> createCdmDetailElement(
+                       AbstractCdmDetailSection<INonViralName> parentElement, int style) {
+           return formFactory.createAuthorshipDetailElement(parentElement, style);
+       }
+
+       public void updateContent(){
+               ((AuthorshipDetailElement)this.detailElement).updateContent();
+       }
+}
\ No newline at end of file