X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/be497f38c5dd0e2ffccb31c0991eb3083d177a93..9e150d47d8abe8a2ceb2c542d9c6eac020e0aed4:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java index 2a397b9b1..adf31bd98 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java @@ -1,23 +1,30 @@ -// $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. */ package eu.etaxonomy.taxeditor.ui.section.name; +import java.util.Iterator; + import org.eclipse.swt.events.SelectionListener; import eu.etaxonomy.cdm.model.name.TypeDesignationBase; -import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement; +import eu.etaxonomy.cdm.model.reference.Reference; +import eu.etaxonomy.taxeditor.store.StoreUtil; import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; -import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement; +import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; +import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; +import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; +import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; +import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractSourcedEntityBaseElement; +import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; /** *

Abstract AbstractTypeDesignationElement class.

@@ -26,10 +33,13 @@ import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityEl * @created May 17, 2010 * @version 1.0 */ -public abstract class AbstractTypeDesignationElement extends AbstractReferencedEntityElement { +public abstract class AbstractTypeDesignationElement extends AbstractSourcedEntityBaseElement { protected CheckboxElement checkbox_notDesignated; - + protected EntitySelectionElement selection_reference; + protected TextWithLabelElement text_referenceDetail; + protected ICdmFormElement formElement; + protected int style; /** *

Constructor for AbstractTypeDesignationElement.

@@ -46,12 +56,130 @@ public abstract class AbstractTypeDesignationElement iterator = getElements().iterator();iterator.hasNext();) { + ICdmFormElement childElement = iterator.next(); + // recursion + if (childElement instanceof EntitySelectionElement && ((EntitySelectionElement)childElement).equals(selection_reference)) { + childElement.removeElements(); + + // unregister selection arbitrator + if(childElement instanceof ISelectableElement){ + SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator(); + if(selectionArbitrator != null){ + formFactory.destroySelectionArbitrator(selectionArbitrator); + } + } + + // unregister from property changes + formFactory.removePropertyChangeListener(childElement); + selection_reference = null; + } + if (childElement instanceof TextWithLabelElement && ((TextWithLabelElement)childElement).equals(text_referenceDetail)) { + + childElement.removeElements(); + + // unregister selection arbitrator + if(childElement instanceof ISelectableElement){ + SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator(); + if(selectionArbitrator != null){ + formFactory.destroySelectionArbitrator(selectionArbitrator); + } + } + + // unregister from property changes + formFactory.removePropertyChangeListener(childElement); + text_referenceDetail = null; + + + } + } + + } + + public void removeNotDesignatedControls(){ + for (Iterator iterator = getElements().iterator();iterator.hasNext();) { + ICdmFormElement childElement = iterator.next(); + // recursion + if (childElement instanceof CheckboxElement && ((CheckboxElement)childElement).equals(this.checkbox_notDesignated)) { + childElement.removeElements(); + + // unregister selection arbitrator + if(childElement instanceof ISelectableElement){ + SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator(); + if(selectionArbitrator != null){ + formFactory.destroySelectionArbitrator(selectionArbitrator); + } + } + + // unregister from property changes + formFactory.removePropertyChangeListener(childElement); + checkbox_notDesignated = null; + } + + } + + } + @Override + public void handleEvent(Object eventSource) { + if (eventSource == selection_reference) { + getEntity().setCitation(selection_reference.getEntity()); + setEntity(entity); + } + if (eventSource == text_referenceDetail) { + getEntity().setCitationMicroReference(text_referenceDetail.getText()); + setEntity(entity); + } + if (eventSource == checkbox_notDesignated) { + getEntity().setNotDesignated(checkbox_notDesignated.getSelection()); + } + } + }