New wizards are not finishable when no data was entered
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NonViralNameDetailElement.java
index 5381a12dc52c6913ab890a27317925fbff97e757..17b19a994e519479e858d79b8e9d201e5a892fec 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
-* Copyright (C) 2007 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.
-*/
+ * Copyright (C) 2007 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.section.name;
 
@@ -17,22 +17,26 @@ import org.eclipse.ui.forms.widgets.Section;
 
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EnumComboType;
+import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
+import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
 import eu.etaxonomy.taxeditor.ui.term.NomenclaturalCodeComboElement;
 
 /**
- * <p>NonViralNameDetailElement class.</p>
- *
+ * <p>
+ * NonViralNameDetailElement class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created May 20, 2010
  * @version 1.0
  */
-public class NonViralNameDetailElement extends AbstractCdmDetailElement<NonViralName> {
+public class NonViralNameDetailElement extends
+               AbstractCdmDetailElement<NonViralName> {
 
        private NameDetailSection section_name;
        private AuthorshipDetailSection section_author;
@@ -40,51 +44,72 @@ public class NonViralNameDetailElement extends AbstractCdmDetailElement<NonViral
        private NomenclaturalCodeComboElement combo_nomenclaturalCode;
 
        /**
-        * <p>Constructor for NonViralNameDetailElement.</p>
-        *
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
-        * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
+        * <p>
+        * Constructor for NonViralNameDetailElement.
+        * </p>
+        * 
+        * @param formFactory
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+        *            object.
+        * @param formElement
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+        *            object.
         */
        public NonViralNameDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement) {
                super(formFactory, formElement);
        }
-       
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement, eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
+        * (eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement,
+        * eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
         */
        /** {@inheritDoc} */
        @Override
        protected void createControls(ICdmFormElement formElement,
                        final NonViralName entity, int style) {
-               
-               toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
-               
-               combo_nomenclaturalCode = (NomenclaturalCodeComboElement) formFactory.createEnumComboElement(EnumComboType.NOMENCLATURALCODE, formElement, style);
+
+               toggleable_cache = formFactory.createToggleableTextField(formElement,
+                               "Cache", entity.getTitleCache(), entity.isProtectedTitleCache()
+                                               || entity.isProtectedFullTitleCache(), style);
+
+               combo_nomenclaturalCode = (NomenclaturalCodeComboElement) formFactory
+                               .createEnumComboElement(EnumComboType.NOMENCLATURALCODE,
+                                               formElement, style);
                combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
-               
-               section_name = (NameDetailSection) formFactory.createCdmDetailSection(DetailType.SCIENTIFICNAME, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
+
+               section_name = (NameDetailSection) formFactory.createCdmDetailSection(
+                               DetailType.SCIENTIFICNAME, getConversationHolder(),
+                               formElement, null, Section.TWISTIE | Section.EXPANDED);
                section_name.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
                addControl(section_name);
                addElement(section_name);
-               section_author = (AuthorshipDetailSection) formFactory.createCdmDetailSection(DetailType.AUTHORSHIP, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
+               section_author = (AuthorshipDetailSection) formFactory
+                               .createCdmDetailSection(DetailType.AUTHORSHIP,
+                                               getConversationHolder(), formElement, null,
+                                               Section.TWISTIE | Section.EXPANDED);
                section_author.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
                addControl(section_author);
                addElement(section_author);
        }
 
-       
        /** {@inheritDoc} */
        @Override
        protected void updateContent() {
                super.updateContent();
-               
-               // disable nomenclatural code, because changing of nom.code is not implemented on library side
+
+               // disable nomenclatural code, because changing of nom.code is not
+               // implemented on library side
                combo_nomenclaturalCode.setEnabled(false);
-               
-               setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache}));
+
+               setIrrelevant(toggleable_cache.getState(),
+                               Arrays.asList(new Object[] { toggleable_cache }));
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void setEntity(NonViralName entity) {
@@ -92,50 +117,58 @@ public class NonViralNameDetailElement extends AbstractCdmDetailElement<NonViral
                section_name.setEntity(entity);
                section_author.setEntity(entity);
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void removeElements() {
                super.removeElements();
-               if(section_name != null){
+               if (section_name != null) {
                        section_name.removeElements();
                        removeControl(section_name);
                        section_name.dispose();
                        section_name = null;
                }
-               if(section_author != null){
+               if (section_author != null) {
                        section_author.removeElements();
                        removeControl(section_author);
                        section_author.dispose();
                        section_author = null;
                }
        }
-       
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
+        * .lang.Object)
         */
        /** {@inheritDoc} */
        @Override
        public void handleEvent(Object eventSource) {
-               if(eventSource == toggleable_cache){
-                       getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
-                       // we never want the fullTitleCache to be protected since we only use it for 
+               if (eventSource == toggleable_cache) {
+                       getEntity().setTitleCache(toggleable_cache.getText(),
+                                       toggleable_cache.getState());
+                       // we never want the fullTitleCache to be protected since we only
+                       // use it for
                        // initiating the free text name editor
                        getEntity().setProtectedFullTitleCache(false);
                        boolean irrelevant = toggleable_cache.getState();
-                       List<Object> except = Arrays.asList(new Object[]{toggleable_cache});
+                       List<Object> except = Arrays
+                                       .asList(new Object[] { toggleable_cache });
                        setIrrelevant(irrelevant, except);
-               }
-               else if(eventSource == section_name || eventSource == section_author){
-                       if(getParentElement() instanceof AbstractCdmDetailSection)
+               } else if (eventSource == section_name || eventSource == section_author) {
+                       if (getParentElement() instanceof AbstractCdmDetailSection)
                                ((AbstractCdmDetailSection) getParentElement()).updateTitle();
-                       if(! toggleable_cache.getState()){
+                       if (!toggleable_cache.getState()) {
                                toggleable_cache.setText(getEntity().getTitleCache());
                        }
                }
-               if(eventSource == section_name){
+               if (eventSource == section_name) {
                        section_name.setEntity(getEntity());
                        getLayoutComposite().layout();
                }
+
+               firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 }