Fixes #2309
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / selection / EditFromSelectionWizard.java
index 1cb6eefbd11bfc3b94648048109747e612fc671c..b470254f0e25550f5ff0dc0ce63448e360c67a85 100644 (file)
@@ -1,17 +1,16 @@
 // $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.selection;
 
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.events.SelectionEvent;
@@ -43,95 +42,114 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage;
 import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceWizardPage;
 
 /**
- * <p>EditFromSelectionWizard class.</p>
- *
+ * <p>
+ * EditFromSelectionWizard class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Jun 1, 2010
  * @version 1.0
  */
-public class EditFromSelectionWizard extends Wizard implements SelectionListener {
-       
-       private AbstractSelectionElement selectionElement;
-       
+public class EditFromSelectionWizard extends Wizard implements
+               SelectionListener {
+
+       private final AbstractSelectionElement selectionElement;
+
        /**
-        * <p>Constructor for EditFromSelectionWizard.</p>
-        *
-        * @param selectionElement a {@link eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement} object.
+        * <p>
+        * Constructor for EditFromSelectionWizard.
+        * </p>
+        * 
+        * @param selectionElement
+        *            a
+        *            {@link eu.etaxonomy.taxeditor.ui.selection.AbstractSelectionElement}
+        *            object.
         */
-       public EditFromSelectionWizard(AbstractSelectionElement selectionElement){
-               this.selectionElement = selectionElement;               
+       public EditFromSelectionWizard(AbstractSelectionElement selectionElement) {
+               this.selectionElement = selectionElement;
                this.setWindowTitle("Edit Entity");
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void addPages() {
-                       
+
                CdmFormFactory formFactory = selectionElement.getFormFactory();
-               IdentifiableEntity entity = (IdentifiableEntity) HibernateProxyHelper.deproxy(selectionElement.getEntity());
-               
-               if(entity instanceof Reference){
-                       addPage(new ReferenceWizardPage(formFactory, selectionElement.getConversationHolder(), (Reference) entity));
-               }
-               else if(entity instanceof Team){
-                       addPage(new TeamWizardPage(formFactory, selectionElement.getConversationHolder(), (Team) entity));
-               }
-               else if(entity instanceof Person){
-                       addPage(new PersonWizardPage(formFactory, selectionElement.getConversationHolder(), (Person) entity));
-               }
-               else if(entity instanceof NonViralName){
-                       addPage(new NonViralNameWizardPage(formFactory, selectionElement.getConversationHolder(), (NonViralName) entity));
-               }
-               else if (entity instanceof DerivedUnitBase){
-                       
-                       
-//                     addPage(new DerivedUnitFacadeWizardPage(formFactory, selectionElement.getConversationHolder(), (DerivedUnitBase) entity));
-                       
+               IdentifiableEntity entity = (IdentifiableEntity) HibernateProxyHelper
+                               .deproxy(selectionElement.getEntity());
+
+               if (entity instanceof Reference) {
+                       addPage(new ReferenceWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(),
+                                       (Reference) entity));
+               } else if (entity instanceof Team) {
+                       addPage(new TeamWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(), (Team) entity));
+               } else if (entity instanceof Person) {
+                       addPage(new PersonWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(), (Person) entity));
+               } else if (entity instanceof NonViralName) {
+                       addPage(new NonViralNameWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(),
+                                       (NonViralName) entity));
+               } else if (entity instanceof DerivedUnitBase) {
+
                        DerivedUnitFacade facade;
                        try {
-                               facade = DerivedUnitFacade.NewInstance((DerivedUnitBase) entity, PreferencesUtil.getDerivedUnitConfigurator());
+                               facade = DerivedUnitFacade.NewInstance(
+                                               (DerivedUnitBase) entity,
+                                               PreferencesUtil.getDerivedUnitConfigurator());
                        } catch (DerivedUnitFacadeNotSupportedException e) {
                                // we should never get here
                                throw new IllegalStateException();
                        }
-                       
-                       addPage(new GeneralWizardPage(formFactory, selectionElement.getConversationHolder(), facade));
-                       addPage(new GatheringEventWizardPage(formFactory, selectionElement.getConversationHolder(), facade));
-                       addPage(new FieldObservationWizardPage(formFactory, selectionElement.getConversationHolder(), facade));
-                       addPage(new DerivedUnitBaseWizardPage(formFactory, selectionElement.getConversationHolder(), facade));
-               }
-               else if(entity instanceof Collection){
-                       addPage(new CollectionWizardPage(formFactory, selectionElement.getConversationHolder(), (Collection) entity));
-               }
-               else if(entity instanceof Institution){
-                       addPage(new InstitutionWizardPage(formFactory, selectionElement.getConversationHolder(), (Institution) entity));
-               }
-               else{
-                       StoreUtil.warningDialog("Missing interface", this, "No detail element for current selection");
+
+                       addPage(new GeneralWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(), facade));
+                       addPage(new GatheringEventWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(), facade));
+                       addPage(new FieldObservationWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(), facade));
+                       addPage(new DerivedUnitBaseWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(), facade));
+               } else if (entity instanceof Collection) {
+                       addPage(new CollectionWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(),
+                                       (Collection) entity));
+               } else if (entity instanceof Institution) {
+                       addPage(new InstitutionWizardPage(formFactory,
+                                       selectionElement.getConversationHolder(),
+                                       (Institution) entity));
+               } else {
+                       StoreUtil.warningDialog("Missing interface", this,
+                                       "No detail element for current selection");
                }
-               
+
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.jface.wizard.Wizard#performFinish()
         */
        /** {@inheritDoc} */
        @Override
        public boolean performFinish() {
-               for(IWizardPage page : getPages()){
-                       page.dispose();
-               }
                return true;
        }
 
        /** {@inheritDoc} */
+       @Override
        public void widgetSelected(SelectionEvent e) {
-               WizardDialog dialog = new WizardDialog(selectionElement.getShell(), this);
-               if(dialog.open() == IStatus.OK){
+               WizardDialog dialog = new WizardDialog(selectionElement.getShell(),
+                               this);
+               if (dialog.open() == IStatus.OK) {
                        selectionElement.updateFromWizard();
                }
        }
-       
+
        /** {@inheritDoc} */
-       public void widgetDefaultSelected(SelectionEvent e) {}
+       @Override
+       public void widgetDefaultSelected(SelectionEvent e) {
+       }
 }