commit 3a9975f6a6d489a36210e991ec44b29d75656b0b
Author: Katja Luther <k.luther@bgbm.org>
Date:   Fri Feb 16 14:55:48 2018 +0100

    ref #7215: add combobox for selecting misapplied name type

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/MisappliedRelationshipComboElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/MisappliedRelationshipComboElement.java
new file mode 100755
index 000000000..1ba9e5292
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/MisappliedRelationshipComboElement.java
@@ -0,0 +1,46 @@
+// $Id$
+/**
+* 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.combo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+
+/**
+ * @author k.luther
+ * @date 16.02.2018
+ *
+ */
+public class MisappliedRelationshipComboElement extends TermComboElement<TaxonRelationshipType> {
+
+    /**
+     * @param formFactory
+     * @param parentElement
+     * @param termType
+     * @param labelString
+     * @param selection
+     * @param addEmptyElement
+     * @param style
+     * @param useAbbrevLabel
+     * @param comparator
+     */
+    public MisappliedRelationshipComboElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
+             String labelString, TaxonRelationshipType selection, boolean addEmptyElement, int style, boolean useAbbrevLabel) {
+        super(formFactory, parentElement, TaxonRelationshipType.class, labelString, selection, addEmptyElement, style);
+        List<TaxonRelationshipType> relTypes = new ArrayList<>();
+        relTypes.add(TaxonRelationshipType.MISAPPLIED_NAME_FOR());
+        relTypes.add(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR());
+        populateTerms(relTypes);
+    }
+
+}
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 e90ace877..a5e7ffba7 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
@@ -111,10 +111,11 @@ import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
-import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
+import eu.etaxonomy.taxeditor.ui.combo.MisappliedRelationshipComboElement;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
 import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
@@ -216,6 +217,7 @@ import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
 import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
 import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
 import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
@@ -236,7 +238,6 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
-import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
@@ -996,6 +997,14 @@ public class CdmFormFactory extends FormToolkit {
 	        return null;
 	    }
 	}
+	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
+	        ICdmFormElement parentElement,
+            String labelString,
+            TaxonRelationshipType selection,
+            int style) {
+	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
+        return combo;
+    }
 
 	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
 	        Class<T> enumComboType, ICdmFormElement parentElement,
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java
index dfaaec7dd..c412ab2ae 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java
@@ -17,6 +17,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.taxeditor.event.EventUtility;
 import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
+import eu.etaxonomy.taxeditor.ui.combo.MisappliedRelationshipComboElement;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
@@ -36,6 +37,7 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<TaxonRelationship> {
 
 	private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType;
+	private MisappliedRelationshipComboElement combo_misappliedRelationshipType;
 
 	private EntitySelectionElement<Taxon> selection_relatedTaxon;
 	private CheckboxElement checkBoxDoubtful;
@@ -61,11 +63,12 @@ public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<Tax
 	@Override
 	protected void createControls(ICdmFormElement formElement,
 			TaxonRelationship entity, int style) {
-		if (!entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
-			combo_taxonRelationshipType = formFactory.createTermComboElement(
-					TaxonRelationshipTypeInverseContainer.class,
-					formElement, "Relationship Type",
-					getTaxonRelationshipTypeInverseContainer(), style);
+		if (!(entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) || entity.getType().equals(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR())) ){
+		    combo_taxonRelationshipType = formFactory.createTermComboElement(
+                    TaxonRelationshipTypeInverseContainer.class,
+                    formElement, "Relationship Type",
+                    getTaxonRelationshipTypeInverseContainer(), style);
+
 			combo_taxonRelationshipType.setEnabled(false);
 			selection_relatedTaxon = formFactory.createSelectionElement(
 					Taxon.class, //getConversationHolder(),
@@ -74,19 +77,15 @@ public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<Tax
 			checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style);
 		}else{
 			taxon = entity.getFromTaxon();
-//			toggleable_cache = formFactory.createToggleableTextField(formElement,
-//					"Title Cache", taxon.getTitleCache(),
-//					taxon.isProtectedTitleCache(), style);
-//
-//			text_appendedPhrase = formFactory.createTextWithLabelElement(
-//					formElement, "Appended Phrase", taxon.getAppendedPhrase(),
-//					SWT.WRAP);
-
 
 			taxonElement = formFactory.createTaxonDetailSection(getConversationHolder(), formElement, null, style);
 			taxonElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
 			addControl(taxonElement);
 			addElement(taxonElement);
+			combo_misappliedRelationshipType = formFactory.createMisappliedRelationshipComboElement(formElement, "Relationship Type",
+                    entity.getType(), style);
+
+			combo_misappliedRelationshipType.setEnabled(true);
 
 			sensuReference = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
 				 formElement, "Sensu",
@@ -131,9 +130,11 @@ public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<Tax
 				getEntity().setCitationMicroReference(text_secundum_microreference.getText());
 			}  else if (eventSource == text_sensu_microreference) {
 		        taxon.setSecMicroReference(text_sensu_microreference.getText());
-			}else if (eventSource == sensuReference) {
+			} else if (eventSource == sensuReference) {
 				taxon.setSec(sensuReference.getSelection());
-			}
+			} else if (eventSource == combo_taxonRelationshipType) {
+			    getEntity().setType(combo_taxonRelationshipType.getSelection().getType());
+        }
 		}else{
 			if (eventSource == selection_relatedTaxon){
 				boolean inverse = getTaxonRelationshipTypeInverseContainer().isInverse();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java
index 87be89877..a4743eb66 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java
@@ -25,6 +25,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
@@ -95,9 +96,11 @@ public class TaxonRelationshipDetailSection extends AbstractCdmDetailSection<Tax
                             TaxonRelationship rel = getEntity();
                             rel.setFromTaxon(taxon);
                             setEntity(rel);
+                            detailElement.firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
                             setTaxonBase(taxon);
 
-                            firePropertyChangeEvent(TaxonRelationshipDetailSection.this);
+
+                            firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
 	                    }
 	                }
 	            };
