Fixes #2309
authorn.hoffmann <n.hoffmann@localhost>
Mon, 28 Mar 2011 14:56:26 +0000 (14:56 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 28 Mar 2011 14:56:26 +0000 (14:56 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/DateDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/AbstractSelectionElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java

index 46d5ceb18016e574f405eb9f79e864345ac17682..0d5643a9defcabdcaf9796c9f7fc9e6957ed52c3 100644 (file)
@@ -142,10 +142,10 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage implemen
        /** {@inheritDoc} */
        @Override
        public void dispose() {
-               super.dispose();
                if(detailElement != null){
                        detailElement.removeElements();
                }
+               super.dispose();
        }
        
        /**
index a21df261c8a9296937bd977f697bc98776f55de8..b3ef32b96b611ef0a5cb14c0316c28739d7eca8a 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.forms;
 
@@ -14,51 +14,71 @@ import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.widgets.Text;
 import org.joda.time.Partial;
 
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.common.TimePeriod;
 
 /**
- * <p>DateDetailSection class.</p>
- *
+ * <p>
+ * DateDetailSection class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Mar 31, 2010
  * @version 1.0
  */
 public class DateDetailSection extends AbstractFormSection<TimePeriod> {
 
-       private TextWithLabelElement text_freeText;
-       private PartialElement partialElement_start;
-       private PartialElement partialElement_end;
-       private TextWithLabelElement text_parseText;
+       private final TextWithLabelElement text_freeText;
+       private final PartialElement partialElement_start;
+       private final PartialElement partialElement_end;
+       private final TextWithLabelElement text_parseText;
        private int cursorPosition;
-       
+
        /**
-        * <p>Constructor for DateDetailSection.</p>
-        *
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
-        * @param style a int.
+        * <p>
+        * Constructor for DateDetailSection.
+        * </p>
+        * 
+        * @param formFactory
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+        *            object.
+        * @param parentElement
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+        *            object.
+        * @param style
+        *            a int.
         */
-       protected DateDetailSection(CdmFormFactory formFactory, ICdmFormElement parentElement,
-                       int style) {
+       protected DateDetailSection(CdmFormFactory formFactory,
+                       ICdmFormElement parentElement, int style) {
                super(formFactory, null, parentElement, style);
-               
-               partialElement_start = formFactory.createPartialElement(this, "Start: ", null, style);
-               partialElement_end = formFactory.createPartialElement(this, "End: ", null, style);
-               
-               text_parseText = formFactory.createTextWithLabelElement(this, "Parse", null, style);
-               text_parseText.getMainControl().setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(6, 1));
-               
-               text_freeText = formFactory.createTextWithLabelElement(this, "Freetext", null, style);
-               text_freeText.getMainControl().setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(6, 1));
-               
+
+               partialElement_start = formFactory.createPartialElement(this,
+                               "Start: ", null, style);
+               partialElement_end = formFactory.createPartialElement(this, "End: ",
+                               null, style);
+
+               text_parseText = formFactory.createTextWithLabelElement(this, "Parse",
+                               null, style);
+               text_parseText.getMainControl().setLayoutData(
+                               CdmFormFactory.FILL_HORIZONTALLY(6, 1));
+
+               text_freeText = formFactory.createTextWithLabelElement(this,
+                               "Freetext", null, style);
+               text_freeText.getMainControl().setLayoutData(
+                               CdmFormFactory.FILL_HORIZONTALLY(6, 1));
+
                formFactory.addPropertyChangeListener(this);
        }
 
        /**
-        * <p>Setter for the field <code>timePeriod</code>.</p>
-        *
-        * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
+        * <p>
+        * Setter for the field <code>timePeriod</code>.
+        * </p>
+        * 
+        * @param timePeriod
+        *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
         */
+       @Override
        public void setEntity(TimePeriod timePeriod) {
                Partial start = timePeriod.getStart();
                partialElement_start.setPartial(start);
@@ -68,23 +88,23 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                text_parseText.setText(timePeriod.toString());
                ((Text) text_parseText.getMainControl()).setSelection(cursorPosition);
                text_freeText.setText(timePeriod.getFreeText());
-               
-               this.setText(timePeriod.toString());
-               
+
+               this.setText(CdmUtils.Nz(timePeriod.toString()));
+
                super.setEntity(timePeriod);
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void propertyChange(PropertyChangeEvent event) {
-               if(event == null){
+               if (event == null) {
                        return;
                }
                Object eventSource = event.getSource();
-               
-               if(getElements().contains(eventSource)){
-                       if(event instanceof CdmPropertyChangeEvent){
-                               if(((CdmPropertyChangeEvent) event).hasException()){
+
+               if (getElements().contains(eventSource)) {
+                       if (event instanceof CdmPropertyChangeEvent) {
+                               if (((CdmPropertyChangeEvent) event).hasException()) {
                                        handleException((CdmPropertyChangeEvent) event);
                                        return;
                                }
@@ -92,34 +112,35 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                        handleEvent(eventSource);
                }
        }
-       
+
        /**
         * @param event
         */
        private void handleException(CdmPropertyChangeEvent event) {
-               firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event.getException()));
+               firePropertyChangeEvent(new CdmPropertyChangeEvent(this,
+                               event.getException()));
        }
-       
-       private void handleEvent(Object eventSource){
-               if(eventSource == partialElement_start){
+
+       private void handleEvent(Object eventSource) {
+               if (eventSource == partialElement_start) {
                        Partial start = partialElement_start.getPartial();
                        getEntity().setStart(start);
-               }
-               else if(eventSource == partialElement_end){
+               } else if (eventSource == partialElement_end) {
                        Partial end = partialElement_end.getPartial();
                        getEntity().setEnd(end);
-               }
-               else if(eventSource == text_parseText){
-                       cursorPosition = ((Text) text_parseText.getMainControl()).getCaretPosition();
+               } else if (eventSource == text_parseText) {
+                       cursorPosition = ((Text) text_parseText.getMainControl())
+                                       .getCaretPosition();
                        setEntity(TimePeriod.parseString(text_parseText.getText()));
-               }
-               else if(eventSource == text_freeText){
+               } else if (eventSource == text_freeText) {
                        getEntity().setFreeText(text_freeText.getText());
                }
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see eu.etaxonomy.taxeditor.forms.AbstractFormSection#dispose()
         */
        /** {@inheritDoc} */
@@ -128,5 +149,5 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                formFactory.removePropertyChangeListener(this);
                super.dispose();
        }
-       
+
 }
index 20765f6c9d356af12641f115f14aec99a8c2f081..91bceab123bcba3a04ffc164afdaaab7de34aeec 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.agent;
 
@@ -21,8 +21,10 @@ import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 
 /**
- * <p>TeamWizardPage class.</p>
- *
+ * <p>
+ * TeamWizardPage class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Jun 1, 2010
  * @version 1.0
@@ -30,21 +32,31 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 public class TeamWizardPage extends AbstractCdmEntityWizardPage<Team> {
 
        /**
-        * <p>Constructor for TeamWizardPage.</p>
-        *
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param entity a {@link eu.etaxonomy.cdm.model.agent.Team} object.
+        * <p>
+        * Constructor for TeamWizardPage.
+        * </p>
+        * 
+        * @param formFactory
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+        *            object.
+        * @param conversation
+        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *            object.
+        * @param entity
+        *            a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         */
-       public TeamWizardPage(CdmFormFactory formFactory, ConversationHolder conversation, Team entity) {
+       public TeamWizardPage(CdmFormFactory formFactory,
+                       ConversationHolder conversation, Team entity) {
                super(formFactory, conversation, entity);
                setTitle("Team");
        }
-       
+
        /** {@inheritDoc} */
        @Override
-       public AbstractCdmDetailElement createElement(ICdmFormElement rootElement) {
-               TeamDetailElement teamElement = (TeamDetailElement) formFactory.createCdmDetailElement(DetailType.TEAM, rootElement, SWT.NULL);
+       public AbstractCdmDetailElement<Team> createElement(
+                       ICdmFormElement rootElement) {
+               TeamDetailElement teamElement = (TeamDetailElement) formFactory
+                               .createCdmDetailElement(DetailType.TEAM, rootElement, SWT.NULL);
                teamElement.setEntity(entity);
                return teamElement;
        }
index 347658400c0bba1b8e8853a9bbbd2ae27ccab759..1a6a8123667d326280f88615ef3e6556da6272c5 100644 (file)
@@ -3,6 +3,8 @@
  */
 package eu.etaxonomy.taxeditor.ui.selection;
 
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -32,313 +34,389 @@ import eu.etaxonomy.taxeditor.ui.forms.ISelectableElement;
 import eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator;
 
 /**
- * <p>Abstract AbstractSelectionElement class.</p>
- *
+ * <p>
+ * Abstract AbstractSelectionElement class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Nov 17, 2009
  * @version 1.0
  * @param <T>
  */
-public abstract class AbstractSelectionElement<T> extends AbstractCdmFormElement implements SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, IConversationEnabled{
+public abstract class AbstractSelectionElement<T> extends
+               AbstractCdmFormElement implements SelectionListener,
+               IEnableableFormElement, ISelectableElement, IEntityElement<T>,
+               ILabeledElement, IConversationEnabled {
 
        protected T entity;
-       
+
        protected Label label;
        protected Label text;
        protected Button button_selection;
-       
+
        private SelectionArbitrator selectionArbitrator;
 
        protected Button button_edit;
 
-       private String labelString;
+       private final String labelString;
 
        private Composite selectableComposite;
 
        private Button button_remove;
 
-       private boolean isEditable;
+       private final boolean isEditable;
 
-       private boolean isDeletable;
+       private final boolean isDeletable;
 
-       private EditFromSelectionWizard wizard;
-       
-       private ConversationHolder conversation;
+       private final ConversationHolder conversation;
 
        /**
-        * <p>Constructor for AbstractSelectionElement.</p>
-        *
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
-        * @param conversation TODO
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
-        * @param labelString a {@link java.lang.String} object.
-        * @param entity a T object.
-        * @param isEditable a boolean.
-        * @param isSelectable a boolean.
-        * @param isDeletable a boolean.
-        * @param style a int.
-        * @param <T> a T object.
+        * <p>
+        * Constructor for AbstractSelectionElement.
+        * </p>
+        * 
+        * @param formFactory
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+        *            object.
+        * @param conversation
+        *            TODO
+        * @param parentElement
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+        *            object.
+        * @param labelString
+        *            a {@link java.lang.String} object.
+        * @param entity
+        *            a T object.
+        * @param isEditable
+        *            a boolean.
+        * @param isSelectable
+        *            a boolean.
+        * @param isDeletable
+        *            a boolean.
+        * @param style
+        *            a int.
+        * @param <T>
+        *            a T object.
         */
-       public AbstractSelectionElement(
-                       CdmFormFactory formFactory, 
-                       ConversationHolder conversation, 
-                       ICdmFormElement parentElement, 
-                       String labelString, 
-                       T entity, 
-                       boolean isEditable, 
-                       boolean isSelectable, 
-                       boolean isDeletable, int style) {
+       public AbstractSelectionElement(CdmFormFactory formFactory,
+                       ConversationHolder conversation, ICdmFormElement parentElement,
+                       String labelString, T entity, boolean isEditable,
+                       boolean isSelectable, boolean isDeletable, int style) {
                super(formFactory, parentElement);
-               
+
                this.isEditable = isEditable;
                this.isDeletable = isDeletable;
-               
+
                this.labelString = labelString;
-               
+
                this.conversation = conversation;
-               
-               if(isSelectable && formFactory.getSelectionProvider() != null){
+
+               if (isSelectable && formFactory.getSelectionProvider() != null) {
                        selectionArbitrator = formFactory.createSelectionArbitrator(this);
                }
-               
-               createControls(getLayoutComposite(), SWT.NULL);         
-               
+
+               createControls(getLayoutComposite(), SWT.NULL);
+
                setEntity(entity);
        }
-       
-       private void createControls(Composite parent, int style){
-               
-               label = formFactory.createLabel(getLayoutComposite(), labelString, SWT.NULL);
-               
+
+       private void createControls(Composite parent, int style) {
+
+               label = formFactory.createLabel(getLayoutComposite(), labelString,
+                               SWT.NULL);
+
                addControl(label);
-               
+
                selectableComposite = formFactory.createComposite(getLayoutComposite());
-               
+
                int columns = 2;
-               if(isEditable) columns += 1;
-               if(isDeletable) columns += 1;           
-               
+               if (isEditable) {
+                       columns += 1;
+               }
+               if (isDeletable) {
+                       columns += 1;
+               }
+
                selectableComposite.setLayout(CdmFormFactory.LAYOUT(columns, false));
                selectableComposite.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY());
-               
+
                addControl(selectableComposite);
-               
+
                text = formFactory.createLabel(selectableComposite, null, SWT.WRAP);
                addControl(text);
-               
+
                text.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY());
-               text.setBackground(StoreUtil.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
-               
-               button_selection = formFactory.createButton(selectableComposite, null, SWT.PUSH);
-               button_selection.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
+               text.setBackground(StoreUtil
+                               .getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
+
+               button_selection = formFactory.createButton(selectableComposite, null,
+                               SWT.PUSH);
+               button_selection.setImage(ImageResources
+                               .getImage(ImageResources.BROWSE_ICON));
                button_selection.setToolTipText("Browse existing");
                addControl(button_selection);
                button_selection.addSelectionListener(this);
-               
-               if(isEditable){
-                       button_edit = formFactory.createButton(selectableComposite, null, SWT.PUSH);
-                       button_edit.setImage(ImageResources.getImage(ImageResources.EDIT_ICON));
-                       button_edit.setToolTipText("Edit");
+
+               if (isEditable) {
+                       button_edit = formFactory.createButton(selectableComposite, null,
+                                       SWT.PUSH);
+                       button_edit.setImage(ImageResources
+                                       .getImage(ImageResources.EDIT_ICON));
+                       button_edit.setToolTipText("Edit");
                        addControl(button_edit);
+                       button_edit.addSelectionListener(new EditListener(this));
                }
-               
-               if(isDeletable){
-                       button_remove = formFactory.createButton(selectableComposite, null, SWT.PUSH);
-                       button_remove.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
+
+               if (isDeletable) {
+                       button_remove = formFactory.createButton(selectableComposite, null,
+                                       SWT.PUSH);
+                       button_remove.setImage(ImageResources
+                                       .getImage(ImageResources.TRASH_ICON));
                        button_remove.setToolTipText("Remove");
                        addControl(button_remove);
                        button_remove.addSelectionListener(new DeleteListener(this));
                }
        }
-       
+
        /**
         * Return the selected object
-        *
+        * 
         * @return a T object.
         */
-       public T getSelection(){
+       public T getSelection() {
                return entity;
        }
-       
+
        /*
         * (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.forms.IEnableableFormElement#setEnabled(boolean)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.forms.IEnableableFormElement#setEnabled(boolean)
         */
        /** {@inheritDoc} */
+       @Override
        public void setEnabled(boolean enabled) {
                button_selection.setEnabled(enabled);
-               if(isEditable){
+               if (isEditable) {
                        button_edit.setEnabled(enabled && entity != null);
                }
        }
-       
+
        /**
-        * <p>setSelectionInternal</p>
-        *
-        * @param selection a T object.
+        * <p>
+        * setSelectionInternal
+        * </p>
+        * 
+        * @param selection
+        *            a T object.
         */
-       protected void setSelectionInternal(T selection){
-               if(selection != null && !selection.equals(this.entity)){
+       protected void setSelectionInternal(T selection) {
+               if (selection != null && !selection.equals(this.entity)) {
                        setEntity(selection);
                        firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
                }
        }
-       
+
        /**
-        * <p>Setter for the field <code>entity</code>.</p>
-        *
-        * @param selection a T object.
+        * <p>
+        * Setter for the field <code>entity</code>.
+        * </p>
+        * 
+        * @param selection
+        *            a T object.
         */
-       public void setEntity(T selection){
-               this.entity = selection;        
-               if(isEditable){
-                       createEditWizard();
-               }
+       public void setEntity(T selection) {
+               this.entity = selection;
                updateElement();
        }
-       
-       private void createEditWizard(){
-               if(entity != null){
-                       wizard = new EditFromSelectionWizard(this);
-                       button_edit.addSelectionListener(wizard);
-               }
-       }
 
        /**
         * Updates this elements view
         */
-       protected void updateElement(){
+       protected void updateElement() {
                String title = CdmUtils.Nz(getTitle());
-               // we have to duplicate ampersands otherwise they are treated as mnenomic (see Label.setText() documentation)
+               // we have to duplicate ampersands otherwise they are treated as
+               // mnenomic (see Label.setText() documentation)
                title = title.replace("&", "&&");
                text.setText(title); // title can be null
-               if(isEditable){
+               if (isEditable) {
                        button_edit.setEnabled(entity != null);
                }
        }
-       
+
        /**
-        * <p>updateFromWizard</p>
+        * <p>
+        * updateFromWizard
+        * </p>
         */
-       protected void updateFromWizard(){
+       protected void updateFromWizard() {
                updateElement();
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
-       
+
        /**
-        * <p>getTitle</p>
-        *
+        * <p>
+        * getTitle
+        * </p>
+        * 
         * @return a {@link java.lang.String} object.
         */
-       protected String getTitle(){
+       protected String getTitle() {
                if (entity != null && entity instanceof IIdentifiableEntity) {
                        return ((IIdentifiableEntity) entity).getTitleCache();
                }
                return "";
        }
-       
+
        /** {@inheritDoc} */
+       @Override
        public void setSelected(boolean selected) {
                Color color = getColor(selected);
                getLayoutComposite().setBackground(color);
                selectableComposite.setBackground(color);
                label.setBackground(color);
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
         */
        /**
-        * <p>Getter for the field <code>entity</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>entity</code>.
+        * </p>
+        * 
         * @return a T object.
         */
+       @Override
        public T getEntity() {
                return entity;
        }
-       
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#getSelectionArbitrator()
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#
+        * getSelectionArbitrator()
         */
        /**
-        * <p>Getter for the field <code>selectionArbitrator</code>.</p>
-        *
-        * @return a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator} object.
+        * <p>
+        * Getter for the field <code>selectionArbitrator</code>.
+        * </p>
+        * 
+        * @return a {@link eu.etaxonomy.taxeditor.ui.forms.SelectionArbitrator}
+        *         object.
         */
+       @Override
        public SelectionArbitrator getSelectionArbitrator() {
                return selectionArbitrator;
        }
-       
+
        /**
         * Convenient access to current shell
-        *
+        * 
         * @return a {@link org.eclipse.swt.widgets.Shell} object.
         */
-       protected Shell getShell(){
+       protected Shell getShell() {
                return getLayoutComposite().getShell();
        }
 
        /** {@inheritDoc} */
+       @Override
        public void setIrrelevant(boolean irrelevant) {
-               String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_TEXT_DISABLED_BACKGROUND;
-               
+               String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT
+                               : Resources.COLOR_TEXT_DISABLED_BACKGROUND;
+
                Color color = StoreUtil.getColor(colorId);
                text.setBackground(color);
        }
-       
-       private class DeleteListener extends SelectionAdapter{
-               
-               private AbstractSelectionElement selectionElement;
 
-               public DeleteListener(AbstractSelectionElement selectionElement){
+       private class DeleteListener extends SelectionAdapter {
+
+               private final AbstractSelectionElement<T> selectionElement;
+
+               public DeleteListener(AbstractSelectionElement<T> selectionElement) {
                        this.selectionElement = selectionElement;
                }
-               
+
                @Override
                public void widgetSelected(SelectionEvent e) {
                        setEntity(null);
-                       firePropertyChangeEvent(new CdmPropertyChangeEvent(selectionElement, null));
+                       firePropertyChangeEvent(new CdmPropertyChangeEvent(
+                                       selectionElement, null));
+               }
+       }
+
+       private class EditListener extends SelectionAdapter {
+
+               private final AbstractSelectionElement<T> selectionElement;
+
+               public EditListener(AbstractSelectionElement<T> selectionElement) {
+                       this.selectionElement = selectionElement;
+               }
+
+               /** {@inheritDoc} */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       WizardDialog dialog = new WizardDialog(selectionElement.getShell(),
+                                       new EditFromSelectionWizard(selectionElement));
+                       if (dialog.open() == IStatus.OK) {
+                               selectionElement.updateFromWizard();
+                       }
                }
        }
-       
+
        // not used
        /** {@inheritDoc} */
-       public void widgetDefaultSelected(SelectionEvent e) {}
-       
+       @Override
+       public void widgetDefaultSelected(SelectionEvent e) {
+       }
+
        /**
-        * <p>getConversationHolder</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+        * <p>
+        * getConversationHolder
+        * </p>
+        * 
+        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *         object.
         */
+       @Override
        public ConversationHolder getConversationHolder() {
                return conversation;
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void setBackground(Color color) {
                label.setBackground(color);
        }
-       
+
        /** {@inheritDoc} */
-       public void setLabel(String labelString){
-               if(label != null){
+       @Override
+       public void setLabel(String labelString) {
+               if (label != null) {
                        label.setText(labelString);
                }
        }
-       
+
        /**
-        * <p>Getter for the field <code>label</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>label</code>.
+        * </p>
+        * 
         * @return a {@link java.lang.String} object.
         */
-       public String getLabel(){
-               if(label != null){
+       @Override
+       public String getLabel() {
+               if (label != null) {
                        return label.getText();
                }
                return null;
        }
-       
+
        /** {@inheritDoc} */
-       public void update(CdmDataChangeMap changeEvents) {}
+       @Override
+       public void update(CdmDataChangeMap changeEvents) {
+       }
 }
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) {
+       }
 }