Allow creating new taxa in taxon selection dialog #2402
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / element / AbstractCdmEntityWizardPage.java
index e04928fa8f31ed0575a4354fd6857df368c54c65..505a653a2f701fb19b4a378dbb5413ea58e52082 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * 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.
  */
@@ -28,7 +28,7 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
  * <p>
  * Abstract AbstractCdmEntityWizardPage class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Jun 1, 2010
  * @version 1.0
@@ -46,7 +46,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
         * <p>
         * Constructor for AbstractCdmEntityWizardPage.
         * </p>
-        * 
+        *
         * @param formFactory
         *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
         *            object.
@@ -82,7 +82,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
         * .Composite)
@@ -115,7 +115,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
         * <p>
         * Getter for the field <code>entity</code>.
         * </p>
-        * 
+        *
         * @return a T object.
         */
        public T getEntity() {
@@ -124,7 +124,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
 
        /**
         * Creates the detail element for this wizard page
-        * 
+        *
         * @param rootElement
         *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
         *            object.
@@ -169,6 +169,17 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
                if (event.getSource() == getDetailElement()) {
                        checkComplete();
                }
+               else if(event.getSource() instanceof AbstractCdmDetailElement){
+                   //check if parent element is set as detail element
+                   ICdmFormElement formElement = (ICdmFormElement) event.getSource();
+            while(formElement.getParentElement()!=null){
+                if(formElement.getParentElement() == getDetailElement()){
+                    checkComplete();
+                    return;
+                }
+                formElement = formElement.getParentElement();
+            }
+               }
        }
 
        /**
@@ -191,7 +202,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
         * <p>
         * getConversationHolder
         * </p>
-        * 
+        *
         * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
         *         object.
         */
@@ -214,7 +225,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage
         * <p>
         * Getter for the field <code>detailElement</code>.
         * </p>
-        * 
+        *
         * @return a
         *         {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement}
         *         object.