commit 909326e9b74be422e80071325ae93e53102404a5
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri May 17 08:36:01 2019 +0200

    fix #8283 Add media section to term details view

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
index 61f55e559..f3b9e96ea 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
@@ -354,6 +354,7 @@ import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionEle
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionElement;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
+import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermMediaSection;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
 import eu.etaxonomy.taxeditor.ui.selection.CommonNameReferenceSelectionElement;
@@ -1675,6 +1676,15 @@ public class CdmFormFactory extends FormToolkit {
 
     }
 
+    public TermMediaSection createTermMediaSection(ConversationHolder conversation,
+            ICdmFormElement parentElement, int style) {
+        TermMediaSection section = new TermMediaSection(this, conversation, parentElement, style);
+        parentElement.addElement(section);
+        adapt(section);
+        return section;
+
+    }
+
     /**
      * @param definedTermClass
      * @param formElement
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermMediaSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermMediaSection.java
new file mode 100644
index 000000000..6a81862e7
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermMediaSection.java
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.ui.section.vocabulary;
+
+import java.util.Collection;
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
+
+/**
+ *
+ * @author pplitzner
+ * @since May 17, 2019
+ *
+ */
+public class TermMediaSection extends AbstractEntityCollectionSection<DefinedTermBase, Media>{
+
+	public TermMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
+		super(cdmFormFactory, conversation, parentElement, "Media", style);
+	}
+
+	@Override
+	public Media createNewElement() {
+		return Media.NewInstance();
+	}
+
+	@Override
+	public Collection<Media> getCollection(DefinedTermBase entity) {
+		return entity.getMedia();
+	}
+
+	@Override
+	public Comparator<Media> getComparator() {
+        return new DefaultCdmBaseComparator<>();
+	}
+
+	@Override
+	public String getEmptyString() {
+		return "No media yet.";
+	}
+
+	@Override
+	protected String getTooltipString() {
+		return "Create new media";
+	}
+
+	@Override
+	public void addElement(Media element) {
+		getEntity().addMedia(element);
+	}
+
+	@Override
+	public void removeElement(Media element) {
+		getEntity().removeMedia(element);
+	}
+
+    @Override
+    public Media addExisting() {
+        return MediaSelectionDialog.select(getShell(), null);
+    }
+
+    @Override
+    public boolean allowAddExisting() {
+        return true;
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
index 133c9bed6..b02ffac24 100755
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
@@ -29,18 +29,14 @@ import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
-import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.cdm.model.common.Marker;
-import eu.etaxonomy.cdm.model.term.TermVocabulary;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.description.CategoricalData;
 import eu.etaxonomy.cdm.model.description.Character;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.Distribution;
-import eu.etaxonomy.cdm.model.term.FeatureNode;
-import eu.etaxonomy.cdm.model.term.FeatureTree;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
@@ -56,6 +52,10 @@ import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+import eu.etaxonomy.cdm.model.term.FeatureNode;
+import eu.etaxonomy.cdm.model.term.FeatureTree;
+import eu.etaxonomy.cdm.model.term.TermVocabulary;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
 import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
@@ -125,6 +125,7 @@ import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermMediaSection;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
 import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
 
@@ -869,6 +870,8 @@ public class DetailsViewerE4 extends AbstractCdmDataViewerE4 {
     private void createDefinedTermSection(RootElement parent) {
         DefinedTermDetailSection definedTermDetailSection = formFactory.createDefinedTermDetailSection(getInput().getClass(), getConversationHolder(), parent, this, getSectionStyle(DefinedTermDetailSection.class, true));
         addPart(definedTermDetailSection);
+        TermMediaSection termMediaSection = formFactory.createTermMediaSection(getConversationHolder(), parent, getSectionStyle(DefinedTermDetailSection.class, true));
+        addPart(termMediaSection);
     }
 
     @Override
