Revision 446b26b9
Added by Katja Luther over 1 year ago
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 |
} |
Also available in: Unified diff
ref #10202: disable specimen selection or reference selection if the other possibility is already used