ref #8136: add warning message when changing type away from lectotype and citation...
authorKatja Luther <k.luther@bgbm.org>
Fri, 5 Apr 2019 10:17:19 +0000 (12:17 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 5 Apr 2019 10:17:19 +0000 (12:17 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameTypeDesignationElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java

index af1eafb0629f70d3736295540bc1c70c4a6b97c1..6d5f94e1c0a6ee7f3d688209fcde16ccae4b7734 100644 (file)
@@ -16,6 +16,7 @@ import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
 import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -85,16 +86,24 @@ public class NameTypeDesignationElement extends
                } else if (eventSource == selection_typeName) {
                        getEntity().setTypeName(selection_typeName.getEntity());
                } else if (eventSource == combo_typeStatus) {
+                   if (getEntity().getTypeStatus().isLectotype() && !combo_typeStatus.getSelection().isLectotype() && entity.getCitation() != null){
+                boolean ok = MessagingUtils.confirmDialog("Citation will be removed", "When changing the type from lectotype to a non lectotype the citation will be removed.Do you want to continue?");
+                if (!ok){
+                    combo_typeStatus.setSelection(entity.getTypeStatus());
+                    return;
+                }
+            }
                        getEntity().setTypeStatus(combo_typeStatus.getSelection());
+
                        setEntity(entity);
                } else if (eventSource == checkbox_notDesignated) {
                        getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
                }
-//             else if (eventSource == selection_reference) {
-//                     getEntity().setCitation(selection_reference.getSelection());
-//             } else if (eventSource == text_referenceDetail) {
-//                     getEntity().setCitationMicroReference(
-//                                     text_referenceDetail.getText());
-//             }
+               else if (eventSource == selection_reference) {
+                       getEntity().setCitation(selection_reference.getSelection());
+               } else if (eventSource == text_referenceDetail) {
+                       getEntity().setCitationMicroReference(
+                                       text_referenceDetail.getText());
+               }
        }
 }
index 54120d15561f7a25f48bf051625a521b624052fd..e0441d58cebede3c494bcd932d4d48240a6882ca 100644 (file)
@@ -18,6 +18,7 @@ import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -78,8 +79,16 @@ public class SpecimenTypeDesignationElement extends
        public void handleEvent(Object eventSource) {
            super.handleEvent(eventSource);
                if (eventSource == combo_typeStatus) {
+                   if (getEntity().getTypeStatus().isLectotype() && !combo_typeStatus.getSelection().isLectotype() && entity.getCitation() != null){
+                       boolean ok = MessagingUtils.confirmDialog("Citation will be removed", "When changing the type from lectotype to a non lectotype the citation will be removed.Do you want to continue?");
+                       if (!ok){
+                           combo_typeStatus.setSelection(entity.getTypeStatus());
+                           return;
+                       }
+                   }
                        getEntity().setTypeStatus(combo_typeStatus.getSelection());
                        setEntity(entity);
+
                }
                // TODO remove this once specimens are correctly implemented
                else if (eventSource == text_specimenTypeText) {
@@ -96,11 +105,11 @@ public class SpecimenTypeDesignationElement extends
                } else if (eventSource == checkbox_notDesignated) {
                        getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
                }
-//             else if (eventSource == selection_reference) {
-//                     getEntity().setCitation(selection_reference.getSelection());
-//             } else if (eventSource == text_referenceDetail) {
-//                     getEntity().setCitationMicroReference(
-//                                     text_referenceDetail.getText());
-//             }
+               else if (eventSource == selection_reference) {
+                       getEntity().setCitation(selection_reference.getSelection());
+               } else if (eventSource == text_referenceDetail) {
+                       getEntity().setCitationMicroReference(
+                                       text_referenceDetail.getText());
+               }
        }
 }