Project

General

Profile

Revision 9f40979f

ID9f40979f5e0d2fc55100acc5a7fabac00d48ce12
Parent 4478751c
Child 803af83e

Added by Katja Luther about 1 year ago

fix #8136: update type section when changing type to or from lectotype

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.ui.section.name;
11 11

  
12
import java.util.Iterator;
13

  
12 14
import org.eclipse.swt.SWT;
13 15
import org.eclipse.swt.events.SelectionListener;
14 16

  
15 17
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
16 18
import eu.etaxonomy.cdm.model.reference.Reference;
19
import eu.etaxonomy.taxeditor.store.StoreUtil;
17 20
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
18 21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 22
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
20 23
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
25
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
21 26
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22 27
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractSourcedEntityBaseElement;
23 28
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
......
62 67
	@Override
63 68
	public void setEntity(T entity){
64 69
	    super.setEntity(entity);
70

  
65 71
	    if (this.entity != null && this.entity.isLectoType()){
66
            selection_reference = formFactory
67
                    .createSelectionElement(Reference.class, formElement, "Reference",
68
                            null, EntitySelectionElement.ALL, SWT.NULL);
69
            text_referenceDetail = formFactory.createTextWithLabelElement(
70
                formElement, "Reference Detail", null, SWT.NULL);
72
	        if (selection_reference == null){
73
    	        selection_reference = formFactory
74
                        .createSelectionElement(Reference.class, formElement, "Reference",
75
                                null, EntitySelectionElement.ALL, SWT.NULL);
76

  
77
                text_referenceDetail = formFactory.createTextWithLabelElement(
78
                    formElement, "Reference Detail", null, SWT.NULL);
79
	        }
80
        }else{
81
            if (selection_reference != null){
82
                removeReferenceControls();
83
            }
71 84
        }
85
        StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
86

  
72 87
	}
73 88

  
89
	/**
90
     * Updates all widgets to display the latest data
91
     */
92
    protected void updateContent() {
93
      // if (this.getParentElement() instanceof NameDetailSection
94

  
95
    }
96

  
97

  
98
    public void removeReferenceControls(){
99
        for (Iterator<ICdmFormElement> iterator = getElements().iterator();iterator.hasNext();) {
100
            ICdmFormElement childElement = iterator.next();
101
            // recursion
102
           if (childElement instanceof EntitySelectionElement && ((EntitySelectionElement)childElement).equals(selection_reference)) {
103
                childElement.removeElements();
104

  
105
                // unregister selection arbitrator
106
                if(childElement instanceof ISelectableElement){
107
                    SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator();
108
                    if(selectionArbitrator != null){
109
                        formFactory.destroySelectionArbitrator(selectionArbitrator);
110
                    }
111
                }
112

  
113
                // unregister from property changes
114
                formFactory.removePropertyChangeListener(childElement);
115
                selection_reference = null;
116
           }
117
          if (childElement instanceof TextWithLabelElement && ((TextWithLabelElement)childElement).equals(text_referenceDetail)) {
118

  
119
                  childElement.removeElements();
120

  
121
                  // unregister selection arbitrator
122
                  if(childElement instanceof ISelectableElement){
123
                      SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator();
124
                      if(selectionArbitrator != null){
125
                          formFactory.destroySelectionArbitrator(selectionArbitrator);
126
                      }
127
                  }
128

  
129
                  // unregister from property changes
130
                  formFactory.removePropertyChangeListener(childElement);
131
                  text_referenceDetail = null;
132

  
133

  
134
          }
135
        }
136

  
137
    }
138

  
139

  
74 140
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameTypeDesignationElement.java
12 12
import org.eclipse.swt.events.SelectionListener;
13 13

  
14 14
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
15
import eu.etaxonomy.cdm.model.term.TermType;
16 15
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
17 16
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
18 17
import eu.etaxonomy.cdm.model.name.TaxonName;
18
import eu.etaxonomy.cdm.model.term.TermType;
19 19
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20 20
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
21 21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
86 86
			getEntity().setTypeName(selection_typeName.getEntity());
87 87
		} else if (eventSource == combo_typeStatus) {
88 88
			getEntity().setTypeStatus(combo_typeStatus.getSelection());
89

  
89
			setEntity(entity);
90 90
		} else if (eventSource == checkbox_notDesignated) {
91 91
			getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
92 92
		}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java
13 13

  
14 14
import eu.etaxonomy.cdm.api.service.name.TypeDesignationStatusComparator;
15 15
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
16
import eu.etaxonomy.cdm.model.term.TermType;
17 16
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
18 17
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
19 18
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
20 19
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
20
import eu.etaxonomy.cdm.model.term.TermType;
21 21
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
22 22
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
23 23
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
24
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
25 24
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
26 25
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
27 26
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
......
79 78
	public void handleEvent(Object eventSource) {
80 79
		if (eventSource == combo_typeStatus) {
81 80
			getEntity().setTypeStatus(combo_typeStatus.getSelection());
82

  
83
			firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
84

  
81
			setEntity(entity);
85 82
		}
86 83
		// TODO remove this once specimens are correctly implemented
87 84
		else if (eventSource == text_specimenTypeText) {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)