Project

General

Profile

« Previous | Next » 

Revision 446b26b9

Added by Katja Luther over 1 year ago

ref #10202: disable specimen selection or reference selection if the other possibility is already used

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceElement.java
8 8
 */
9 9
package eu.etaxonomy.taxeditor.ui.section.description;
10 10

  
11
import java.util.Iterator;
12

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

  
14 17
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
15 18
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
......
21 24
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 25
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23 26
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
27
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
24 28
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
29
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
25 30
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
31
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceElement;
26 32
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractOriginalSourceElement;
27 33
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
28 34

  
......
35 41
		IEntityElement<DescriptionElementSource>{
36 42

  
37 43
	private EntitySelectionElement<TaxonName> selection_name;
38
	private EntitySelectionElement<SpecimenOrObservationBase> selection_specimen;
39 44
	boolean isEnabled = true;
40 45

  
41 46
	public DescriptionElementSourceElement(CdmFormFactory cdmFormFactory,
......
52 57
				.createSelectionElement(TaxonName.class,
53 58
				        formElement, "Name in Source",
54 59
						null, EntitySelectionElement.ALL, SWT.NULL);
55
		if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimenInFactSource.getKey())) {
56
			selection_specimen = formFactory
57
					.createSelectionElement(SpecimenOrObservationBase.class,
58
					        formElement, "Specimen",
59
							null, EntitySelectionElement.ALL, SWT.NULL);
60
		}
60
		
61 61
		externalLinks = formFactory.createExternalLinksSection(formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
62 62
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
63 63
        if (getEntity() != null){
......
68 68
	@Override
69 69
	public void setEntity(DescriptionElementSource entity) {
70 70
		super.setEntity(entity);
71
		if (selection_reference != null){
71
		if (selection_reference != null ){
72 72
			if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
73 73
			    text_idInSource.setText(entity.getIdInSource());
74 74
			}
......
80 80
			text_referenceDetail.setText(entity.getCitationMicroReference());
81 81
			text_originalInfo.setText(entity.getOriginalInfo());
82 82
			selection_name.setEntity(entity.getNameUsedInSource());
83
			if (selection_specimen != null) {
84
				selection_specimen.setEntity(entity.getSpecimen());
85
			}
83
			
86 84
			combo_origsourcetype.setSelection(entity.getType());
87 85
			externalLinks.setEntity(entity);
88 86
		}
......
96 94
	    super.handleEvent(eventSource);
97 95
        if (eventSource == selection_name) {
98 96
            getEntity().setNameUsedInSource(selection_name.getSelection());
97
           
99 98
        }
100 99
        if (eventSource == selection_specimen) {
101 100
            getEntity().setSpecimen(selection_specimen.getSelection());
101
            this.selection_reference.setEnabled(selection_specimen.getSelection() == null);
102
        }
103
        if (eventSource == selection_reference) {
104

  
105
            this.selection_specimen.setEnabled(selection_reference.getSelection() == null);
102 106
        }
103 107
	}
104 108

  
......
107 111
		super.setEnabled(enabled);
108 112
		externalLinks.setEnabled(isEnabled);
109 113
	}
114
	 
110 115
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java
16 16
import eu.etaxonomy.cdm.model.common.CdmBase;
17 17
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
18 18
import eu.etaxonomy.cdm.model.common.TimePeriod;
19
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
19 20
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
21
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
20 22
import eu.etaxonomy.cdm.model.reference.ICdmTarget;
21 23
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
22 24
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
......
45 47

  
46 48
    protected boolean isCommonNameReference = false;
47 49
    protected EntitySelectionElement<Reference> selection_reference;
50
    protected EntitySelectionElement<SpecimenOrObservationBase> selection_specimen;
48 51
    protected TextWithLabelElement text_referenceDetail;
49 52
    protected TimePeriodElement accessed;
50 53
	protected EnumComboElement<OriginalSourceType> combo_origsourcetype;
......
108 111
          selection_reference = formFactory
109 112
                    .createCommonNameReferenceSelectionElement(formElement, "Reference",
110 113
                            null, EntitySelectionElement.ALL, style);
111
        }else{
114
        }else if (entity instanceof DescriptionElementSource && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimenInFactSource.getKey())) {
115
        	selection_reference = formFactory
116
                    .createSelectionElement(Reference.class,
117
                             formElement, "Reference",
118
                            null, EntitySelectionElement.ALL, style);
119
        	selection_specimen = formFactory
120
					.createSelectionElement(SpecimenOrObservationBase.class,
121
					        formElement, "or Specimen",
122
							null, EntitySelectionElement.ALL, SWT.NULL);
123
		}else{
112 124
           selection_reference = formFactory
113 125
                      .createSelectionElement(Reference.class,
114 126
                               formElement, "Reference",
......
147 159

  
148 160
		if (entity != null){
149 161
			selection_reference.setEntity(entity.getCitation());
162
			if (selection_specimen != null && entity instanceof DescriptionElementSource) {
163
				selection_specimen.setEntity(((DescriptionElementSource)entity).getSpecimen());
164
			}
150 165
	        text_referenceDetail.setText(entity.getCitationMicroReference());
151 166
	        text_originalInfo.setText(entity.getOriginalInfo());
152 167

  

Also available in: Unified diff