ref #8223: disable name/taxon if existing taxon/name is selected
authorKatja Luther <k.luther@bgbm.org>
Wed, 10 Apr 2019 12:41:21 +0000 (14:41 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 10 Apr 2019 12:42:11 +0000 (14:42 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeDetailElement.java

index 38ce05d..729dc0a 100644 (file)
@@ -107,10 +107,22 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
 //                             .createSelectionElement(Classification.class,//getConversationHolder(),
 //                                     formElement, "Classification",
 //                                             null, EntitySelectionElement.DELETABLE, style);
+
                selection_parentTaxonNode = formFactory
                                .createTaxonNodeSelectionElement(getConversationHolder(), formElement, "Parent", parentTreeNode,
                                                EntitySelectionElement.DELETABLE, style);
 
+
+
+               selection_Ref = formFactory
+                    .createSelectionElement(Reference.class,
+                            formElement, "Parent Child Relation Source", null,
+                            EntitySelectionElement.DELETABLE, style);
+
+
+            microReference = formFactory.createTextWithLabelElement(formElement,"Detail", "", style);
+            microReference.setText(getEntity().getMicroReference());
+
                selection_reuseExistingTaxon = formFactory
                                .createSelectionElement(Taxon.class,//getConversationHolder(),
                                        formElement,
@@ -135,9 +147,13 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
 
                }
            }else{
-               TextWithLabelElement textClassification = formFactory.createTextWithLabelElement(formElement,"Classification", entity.getClassification().getTitleCache(), style);
-               textClassification.setEnabled(false);
-
+               if (entity.getParent().getTaxon() == null){
+                   TextWithLabelElement textParent = formFactory.createTextWithLabelElement(formElement,"Classification", entity.getClassification().getTitleCache(), style);
+                textParent.setEnabled(false);
+               }else{
+                   TextWithLabelElement textParent = formFactory.createTextWithLabelElement(formElement,"Parent", entity.getParent().getTaxon().getTitleCache(), style);
+                   textParent.setEnabled(false);
+               }
 //             TextWithLabelElement textTaxon = formFactory.createTextWithLabelElement(formElement,"Taxon", taxon.getTitleCache(), style);
 //             textTaxon.setEnabled(false);
 
@@ -157,14 +173,11 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
 
            }
 
-           selection_Ref = formFactory
-                .createSelectionElement(Reference.class,//getConversationHolder(),
-                        formElement, "Parent Child Relation Source", null,
-                        EntitySelectionElement.DELETABLE, style);
-        microReference = formFactory.createTextWithLabelElement(formElement,"Detail", "", style);
-        microReference.setText(getEntity().getMicroReference());
+
         if (!isCreateNew()){
-            selection_Ref.setEntity(entity.getReference());
+            if (entity.getReference() != null){
+                selection_Ref.setEntity(entity.getReference());
+            }
         }
         parentTreeNode = entity.getParent();
 
@@ -225,9 +238,7 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                    selectionNodeAgentRelation.setEntity(entity);
                    selectionNodeAgentRelation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
                }
-//             checkbox_openInEditor = formFactory.createCheckbox(formElement,
-//                     "Open in Editor", true, style);
-//             setOpenInEditor(true);
+
        }
 
        private void preFillTaxonName() {
@@ -283,6 +294,11 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                        }
                        checkbox_publish.setSelected(getTaxon().isPublish());
             }
+                   boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
+                   if (selection_reuseExistingName != null){
+                       selection_reuseExistingName.setEnabled(enabled);
+            }
+               textNewTaxonName.setEnabled(enabled);
                        complete = true;
                } else if (eventSource == selection_reuseExistingName) {
                    boolean enabled = selection_reuseExistingName.getEntity() == null;
@@ -339,9 +355,7 @@ public class TaxonNodeDetailElement extends AbstractCdmDetailElement<TaxonNode>
                return classification;
        }
 
-//     public boolean isOpenInEditor() {
-//             return openInEditor;
-//     }
+
 
        public ITaxonTreeNode getParentTreeNode() {
                return parentTreeNode;