Revision 9a5a83e1
Added by Katja Luther almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.section.taxon; |
10 | 10 |
|
11 |
import java.util.Arrays; |
|
12 |
|
|
13 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
14 |
import org.eclipse.swt.SWT; |
|
11 | 15 |
import org.eclipse.ui.IEditorInput; |
12 | 16 |
|
17 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
18 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
13 | 20 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
14 | 21 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
15 | 22 |
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer; |
... | ... | |
19 | 26 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
20 | 27 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
21 | 28 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
29 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
|
30 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
|
22 | 31 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
23 | 32 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
24 | 33 |
|
... | ... | |
29 | 38 |
*/ |
30 | 39 |
public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<TaxonRelationship> { |
31 | 40 |
|
32 |
private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType; |
|
33 |
|
|
34 |
private EntitySelectionElement<Taxon> selection_relatedTaxon; |
|
41 |
// private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType; |
|
42 |
// |
|
43 |
// private EntitySelectionElement<Taxon> selection_relatedTaxon; |
|
44 |
protected ToggleableTextElement toggleable_cache; |
|
45 |
private EntitySelectionElement<Reference> secReference; |
|
46 |
private EntitySelectionElement<Reference> sensuReference; |
|
47 |
private TextWithLabelElement text_sensu_microreference; |
|
48 |
private CheckboxElement checkbox_doubtful; |
|
49 |
|
|
50 |
private TextWithLabelElement text_secundum_microreference; |
|
51 |
|
|
52 |
private TextWithLabelElement text_appendedPhrase; |
|
53 |
|
|
54 |
private CheckboxElement checkbox_published; |
|
35 | 55 |
|
36 |
private CheckboxElement checkBoxDoubtful; |
|
56 |
|
|
57 |
private Taxon taxon; |
|
37 | 58 |
|
38 | 59 |
public TaxonRelationshipDetailElement(CdmFormFactory formFactory, |
39 | 60 |
ICdmFormElement formElement) { |
... | ... | |
43 | 64 |
@Override |
44 | 65 |
protected void createControls(ICdmFormElement formElement, |
45 | 66 |
TaxonRelationship entity, int style) { |
46 |
combo_taxonRelationshipType = formFactory.createTermComboElement( |
|
47 |
TaxonRelationshipTypeInverseContainer.class, |
|
48 |
formElement, "Relationship Type", |
|
49 |
getTaxonRelationshipTypeInverseContainer(), style); |
|
50 |
combo_taxonRelationshipType.setEnabled(false); |
|
51 |
selection_relatedTaxon = formFactory.createSelectionElement( |
|
52 |
Taxon.class, getConversationHolder(), |
|
53 |
formElement, "Related Taxon", getRelatedTaxon(), |
|
54 |
EntitySelectionElement.SELECTABLE, style); |
|
55 |
checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style); |
|
67 |
// combo_taxonRelationshipType = formFactory.createTermComboElement( |
|
68 |
// TaxonRelationshipTypeInverseContainer.class, |
|
69 |
// formElement, "Relationship Type", |
|
70 |
// getTaxonRelationshipTypeInverseContainer(), style); |
|
71 |
// combo_taxonRelationshipType.setEnabled(false); |
|
72 |
// selection_relatedTaxon = formFactory.createSelectionElement( |
|
73 |
// Taxon.class, getConversationHolder(), |
|
74 |
// formElement, "Related Taxon", getRelatedTaxon(), |
|
75 |
// EntitySelectionElement.SELECTABLE, style); |
|
76 |
taxon = entity.getFromTaxon(); |
|
77 |
toggleable_cache = formFactory.createToggleableTextField(formElement, |
|
78 |
"Title Cache", taxon.getTitleCache(), |
|
79 |
taxon.isProtectedTitleCache(), style); |
|
80 |
|
|
81 |
text_appendedPhrase = formFactory.createTextWithLabelElement( |
|
82 |
formElement, "Appended Phrase", taxon.getAppendedPhrase(), |
|
83 |
SWT.WRAP); |
|
84 |
|
|
85 |
|
|
86 |
sensuReference = formFactory.createSelectionElement(Reference.class, |
|
87 |
getConversationHolder(), formElement, "Sensu", |
|
88 |
getEntity().getCitation(), EntitySelectionElement.ALL, |
|
89 |
style); |
|
90 |
|
|
91 |
text_sensu_microreference = formFactory.createTextWithLabelElement( |
|
92 |
formElement, "Detail", |
|
93 |
getEntity().getCitationMicroReference(),null, |
|
94 |
SWT.WRAP, true); |
|
95 |
|
|
96 |
checkbox_doubtful = formFactory.createCheckbox(formElement, |
|
97 |
entity.getClass().getSimpleName() + " Misappl. doubtful", entity.isDoubtful(), style); |
|
98 |
|
|
99 |
|
|
100 |
checkbox_published = formFactory.createCheckbox(formElement, |
|
101 |
"Taxon is published", taxon.isPublish(), style); |
|
102 |
|
|
103 |
|
|
104 |
secReference = formFactory.createSelectionElement(Reference.class, |
|
105 |
getConversationHolder(), formElement, "err. Secundum", |
|
106 |
taxon.getSec(), EntitySelectionElement.ALL, |
|
107 |
style); |
|
108 |
|
|
109 |
text_secundum_microreference = formFactory.createTextWithLabelElement( |
|
110 |
formElement, "Detail", |
|
111 |
taxon.getSecMicroReference(),null, |
|
112 |
SWT.WRAP, true); |
|
113 |
|
|
114 |
|
|
56 | 115 |
} |
57 | 116 |
|
58 | 117 |
private Taxon getRelatedTaxon() { |
... | ... | |
70 | 129 |
|
71 | 130 |
@Override |
72 | 131 |
public void handleEvent(Object eventSource) { |
73 |
if (eventSource == selection_relatedTaxon){ |
|
74 |
boolean inverse = getTaxonRelationshipTypeInverseContainer().isInverse(); |
|
75 |
Taxon relatedTaxon = selection_relatedTaxon.getEntity(); |
|
76 |
if(inverse){ |
|
77 |
getEntity().setFromTaxon(relatedTaxon); |
|
78 |
}else{ |
|
79 |
getEntity().setToTaxon(relatedTaxon); |
|
80 |
} |
|
132 |
if (eventSource== toggleable_cache) { |
|
133 |
handleToggleableCacheField(); |
|
134 |
} else if (eventSource == checkbox_doubtful) { |
|
135 |
taxon.setDoubtful(checkbox_doubtful.getSelection()); |
|
136 |
} else if (eventSource == secReference) { |
|
137 |
taxon.setSec(secReference.getSelection()); |
|
138 |
} else if (eventSource == text_appendedPhrase) { |
|
139 |
taxon.setAppendedPhrase(text_appendedPhrase.getText()); |
|
140 |
} else if (eventSource == text_secundum_microreference) { |
|
141 |
taxon.setSecMicroReference(text_secundum_microreference.getText()); |
|
142 |
} else if (eventSource == checkbox_published) { |
|
143 |
taxon.setPublish(checkbox_published.getSelection()); |
|
144 |
} else if (eventSource == text_sensu_microreference) { |
|
145 |
getEntity().setCitationMicroReference(text_sensu_microreference.getText()); |
|
146 |
}else if (eventSource == sensuReference) { |
|
147 |
getEntity().setCitation(sensuReference.getSelection()); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
protected void handleToggleableCacheField() { |
|
152 |
boolean pushedState = toggleable_cache.getState(); |
|
153 |
|
|
154 |
taxon.setTitleCache(toggleable_cache.getText(), pushedState); |
|
155 |
setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
|
156 |
updateToggleableCacheField(); |
|
157 |
} |
|
158 |
|
|
159 |
public void updateToggleableCacheField() { |
|
160 |
if (toggleable_cache != null){ |
|
161 |
if (!taxon.isProtectedTitleCache()) { |
|
162 |
toggleable_cache.setText(taxon.generateTitle()); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
protected void updateContent() { |
|
169 |
super.updateContent(); |
|
170 |
toggleable_cache.setEnabled(taxon.isProtectedTitleCache()); |
|
171 |
setIrrelevant(toggleable_cache.getState(), |
|
172 |
Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
|
81 | 173 |
} |
82 |
else if(eventSource==checkBoxDoubtful){ |
|
83 |
getEntity().setDoubtful(checkBoxDoubtful.getSelection()); |
|
174 |
@Override |
|
175 |
protected void updateControlStates() { |
|
176 |
super.updateControlStates(); |
|
177 |
|
|
178 |
} |
|
179 |
@Override |
|
180 |
protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) { |
|
181 |
String title = taxon.generateTitle(); |
|
182 |
taxon.setTitleCache(title); |
|
183 |
super.handleTitleCacheRelevantChange(event); |
|
84 | 184 |
} |
85 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
|
86 |
} |
|
185 |
|
|
186 |
@Override |
|
187 |
public void refresh(){ |
|
188 |
updateContent(); |
|
189 |
updateToggleableCacheField(); |
|
190 |
} |
|
87 | 191 |
} |
Also available in: Unified diff
ref #6390: adapt details view for misapplied names