commit 414b03e61821a03711b35f9a066cd383da0db4c3
Author: Katja Luther <k.luther@bgbm.org>
Date:   Mon Aug 27 10:37:18 2018 +0200

    ref #7415: add external link section to original source part

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/common/ExternalLinksElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/common/ExternalLinksElement.java
new file mode 100755
index 000000000..e5d29530d
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/common/ExternalLinksElement.java
@@ -0,0 +1,98 @@
+/**
+* Copyright (C) 2018 EDIT
+* 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.common;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
+
+import eu.etaxonomy.cdm.model.media.ExternalLink;
+import eu.etaxonomy.cdm.model.media.ExternalLinkType;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
+import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
+import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
+import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
+
+/**
+ * @author k.luther
+ * @since 23.08.2018
+ *
+ */
+public class ExternalLinksElement extends AbstractEntityCollectionElement<ExternalLink> implements ISelectableElement{
+
+    private final SelectionArbitrator selectionArbitrator;
+
+    private UriWithLabelElement externalLinkUriText;
+    private EnumComboElement<ExternalLinkType> combo_linkType;
+    private TextWithLabelElement description;
+
+
+
+    /**
+     * @param formFactory
+     * @param section
+     * @param entity
+     * @param removeListener
+     * @param style
+     */
+    public ExternalLinksElement(CdmFormFactory formFactory, AbstractFormSection section, ExternalLink entity,
+            SelectionListener removeListener, int style) {
+        super(formFactory, section, entity, removeListener, null, style);
+        selectionArbitrator = formFactory.createSelectionArbitrator(this);
+    }
+
+    @Override
+    public SelectionArbitrator getSelectionArbitrator() {
+
+        return selectionArbitrator;
+    }
+
+    @Override
+    public void setEntity(ExternalLink entity) {
+        if (entity.getUri() != null){
+            externalLinkUriText.setText(entity.getUri().toString());
+        }
+        if (entity.getLinkType() != null){
+            combo_linkType.setSelection(entity.getLinkType());
+        }
+        if (entity.getDescription() != null) {
+            description.setText(entity.getDescription().get(
+                        CdmStore.getDefaultLanguage()).getText());
+        }
+    }
+
+    @Override
+    public void createControls(ICdmFormElement element, int style) {
+        externalLinkUriText = formFactory.createUriWithLabelElement(element, "External Link URI", null, style);
+        combo_linkType = formFactory.createEnumComboElement(ExternalLinkType.class, element, style);
+        description = formFactory.createMultiLineTextWithLabel(this, "Description", 50, SWT.WRAP);
+
+
+    }
+
+    @Override
+    public void handleEvent(Object eventSource) {
+        if (eventSource.equals(externalLinkUriText)){
+            getEntity().setUri(externalLinkUriText.parseText());
+        }else if (eventSource.equals(combo_linkType)){
+            getEntity().setLinkType(combo_linkType.getSelection());
+        }else if (eventSource.equals(description)){
+            getEntity().putDescription(CdmStore.getDefaultLanguage(), description.getText());
+        }
+
+    }
+
+
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/common/ExternalLinksSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/common/ExternalLinksSection.java
new file mode 100755
index 000000000..d6f4f6a60
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/common/ExternalLinksSection.java
@@ -0,0 +1,125 @@
+/**
+* Copyright (C) 2018 EDIT
+* 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.common;
+
+import java.util.Collection;
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
+import eu.etaxonomy.cdm.model.media.ExternalLink;
+import eu.etaxonomy.cdm.model.media.ExternalLinkType;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+
+/**
+ * @author k.luther
+ * @since 23.08.2018
+ *
+ */
+public class ExternalLinksSection extends AbstractEntityCollectionSection<OriginalSourceBase, ExternalLink> {
+
+
+
+    /**
+     * @param formFactory
+     * @param formElement
+     */
+    public ExternalLinksSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
+        super(cdmFormFactory, conversation, parentElement, "External links", style);
+
+    }
+
+
+    @Override
+    public Comparator<ExternalLink> getComparator() {
+        return new Comparator<ExternalLink>(){
+
+            @Override
+            public int compare(ExternalLink o1, ExternalLink o2) {
+                if (o1 == o2){
+                    return 0;
+                }
+                if (o1 == null){
+                    return -1;
+
+                }
+                if (o2== null){
+                    return 1;
+                }
+                if (o1.getUri() == o1.getUri()){
+                    return 0;
+                }
+                if (o1.getUri() == null){
+                    return -1;
+                }
+                if (o2.getUri() == null){
+                    return 1;
+                }
+               return o1.getUri().toString().compareTo(o2.getUri().toString());
+
+            }
+
+      };
+
+    }
+
+
+
+    @Override
+    public Collection<ExternalLink> getCollection(OriginalSourceBase entity) {
+        if (entity != null){
+            return entity.getLinks();
+        } else {
+            return null;
+        }
+
+    }
+
+    @Override
+    public ExternalLink createNewElement() {
+        ExternalLink link = ExternalLink.NewInstance(ExternalLinkType.Unknown, null);
+        return link;
+    }
+
+    @Override
+    public void addElement(ExternalLink element) {
+        getEntity().addLink(element);
+
+    }
+
+    @Override
+    public ExternalLink addExisting() {
+        return null;
+    }
+
+    @Override
+    public boolean allowAddExisting() {
+        return false;
+    }
+
+    @Override
+    public void removeElement(ExternalLink element) {
+        getEntity().removeLink(element);
+
+    }
+
+    @Override
+    public String getEmptyString() {
+        return "No external link yet.";
+    }
+
+
+    @Override
+    protected String getTooltipString() {
+        return null;
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java
index d122962ce..0bc7f11e2 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java
@@ -13,6 +13,7 @@ import java.util.Comparator;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
 
 import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
 import eu.etaxonomy.cdm.model.common.OriginalSourceType;
@@ -20,7 +21,9 @@ import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
 
 /**
  * @author n.hoffmann
@@ -33,6 +36,8 @@ public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase
 	protected TextWithLabelElement text_idNamespace;
     protected TextWithLabelElement text_originaleNameString;
 
+    protected ExternalLinksSection externalLinks;
+
 	public AbstractOriginalSourceElement(CdmFormFactory formFactory,
 			AbstractFormSection section,
 			T element, SelectionListener removeListener,
@@ -47,9 +52,11 @@ public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase
 	public void setEntity(T entity) {
 	    super.setEntity(entity);
         text_originaleNameString.setText(entity.getOriginalNameString());
+        externalLinks.setEntity(entity);
 	}
 
-	/** {@inheritDoc} */
+	/** {@inheritDoc}
+	 * @wbp.parser.entryPoint*/
 	@Override
 	public void createControls(ICdmFormElement formElement, int style) {
 		combo_origsourcetype = formFactory
@@ -60,6 +67,9 @@ public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase
 		text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", null, style);
 		text_originaleNameString = formFactory.createTextWithLabelElement(
 		        formElement, "Original Name", null, SWT.NULL);
+		externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
+		externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+
 	}
 
 	/**
