ref #9836: add name in Source for Secundum source
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / reference / SecundumSourceElement.java
index dbe913db586ea615dc104ea4cda9d3ec21b02b04..844e7ff5bb77909fc8dd7dcb35d2e40b07d4cea6 100755 (executable)
@@ -13,6 +13,8 @@ import org.eclipse.swt.widgets.Label;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
+import eu.etaxonomy.cdm.model.name.TaxonName;
+import eu.etaxonomy.cdm.model.reference.NamedSourceBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.SecundumSource;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
@@ -30,6 +32,7 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
  */
 public class SecundumSourceElement extends OriginalSourceElement<SecundumSource> {
 
+       protected EntitySelectionElement<TaxonName> select_nameUsedInSource;
     /**
      * @param formFactory
      * @param formElement
@@ -64,7 +67,9 @@ public class SecundumSourceElement extends OriginalSourceElement<SecundumSource>
 
         Label sep = formFactory.createLabel(formElement.getLayoutComposite(), "");
         sep.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-
+        
+        select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((NamedSourceBase)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
+//        select_nameUsedInSource.setBackground(background);
 
         externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, "Links", false, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
         externalLinks.setEmptySectionString("No links yet.");
@@ -87,5 +92,14 @@ public class SecundumSourceElement extends OriginalSourceElement<SecundumSource>
 //        addElement(advancedSection);
         this.getLayoutComposite().layout();
     }
+    @Override
+    public void handleEvent(Object eventSource) {
+        if (eventSource.equals(select_nameUsedInSource)){
+               getEntity().setNameUsedInSource(select_nameUsedInSource.getEntity());
+        }else{
+               super.handleEvent(eventSource);
+        }
+    }
+
 
 }