Revision fb85fe2e
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
15 | 15 |
import org.eclipse.ui.IEditorInput; |
16 | 16 |
|
17 | 17 |
import eu.etaxonomy.cdm.model.reference.Reference; |
18 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
20 | 18 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
21 | 19 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
22 | 20 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
21 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
|
23 | 22 |
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer; |
24 | 23 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
25 | 24 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
... | ... | |
27 | 26 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
28 | 27 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
29 | 28 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
30 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
|
31 | 29 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
32 | 30 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
33 | 31 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
... | ... | |
42 | 40 |
public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<TaxonRelationship> { |
43 | 41 |
|
44 | 42 |
private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType; |
45 |
|
|
43 |
|
|
46 | 44 |
private EntitySelectionElement<Taxon> selection_relatedTaxon; |
47 | 45 |
private CheckboxElement checkBoxDoubtful; |
48 | 46 |
protected ToggleableTextElement toggleable_cache; |
... | ... | |
56 | 54 |
private TextWithLabelElement text_appendedPhrase; |
57 | 55 |
|
58 | 56 |
private CheckboxElement checkbox_published; |
59 |
|
|
57 |
|
|
60 | 58 |
private SelectionArbitrator selectionArbitrator; |
61 |
|
|
62 | 59 |
|
63 |
private Taxon taxon; |
|
60 |
|
|
61 |
private Taxon taxon; |
|
64 | 62 |
|
65 | 63 |
public TaxonRelationshipDetailElement(CdmFormFactory formFactory, |
66 | 64 |
ICdmFormElement formElement) { |
67 | 65 |
super(formFactory, formElement); |
68 |
|
|
66 |
|
|
69 | 67 |
} |
70 | 68 |
|
71 | 69 |
@Override |
... | ... | |
73 | 71 |
TaxonRelationship entity, int style) { |
74 | 72 |
if (!entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
75 | 73 |
combo_taxonRelationshipType = formFactory.createTermComboElement( |
76 |
TaxonRelationshipTypeInverseContainer.class,
|
|
77 |
formElement, "Relationship Type",
|
|
74 |
TaxonRelationshipTypeInverseContainer.class, |
|
75 |
formElement, "Relationship Type", |
|
78 | 76 |
getTaxonRelationshipTypeInverseContainer(), style); |
79 | 77 |
combo_taxonRelationshipType.setEnabled(false); |
80 | 78 |
selection_relatedTaxon = formFactory.createSelectionElement( |
81 |
Taxon.class, getConversationHolder(),
|
|
82 |
formElement, "Related Taxon", getRelatedTaxon(),
|
|
79 |
Taxon.class, getConversationHolder(), |
|
80 |
formElement, "Related Taxon", getRelatedTaxon(), |
|
83 | 81 |
EntitySelectionElement.SELECTABLE, style); |
84 | 82 |
checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style); |
85 | 83 |
}else{ |
... | ... | |
87 | 85 |
toggleable_cache = formFactory.createToggleableTextField(formElement, |
88 | 86 |
"Title Cache", taxon.getTitleCache(), |
89 | 87 |
taxon.isProtectedTitleCache(), style); |
90 |
|
|
88 |
|
|
91 | 89 |
text_appendedPhrase = formFactory.createTextWithLabelElement( |
92 | 90 |
formElement, "Appended Phrase", taxon.getAppendedPhrase(), |
93 | 91 |
SWT.WRAP); |
94 |
|
|
95 |
|
|
92 |
|
|
93 |
|
|
96 | 94 |
sensuReference = formFactory.createSelectionElement(Reference.class, |
97 | 95 |
getConversationHolder(), formElement, "Sensu", |
98 | 96 |
taxon.getSec(), EntitySelectionElement.ALL, |
99 | 97 |
style); |
100 |
|
|
98 |
|
|
101 | 99 |
text_sensu_microreference = formFactory.createTextWithLabelElement( |
102 | 100 |
formElement, "Detail", |
103 | 101 |
taxon.getSecMicroReference(),null, |
104 | 102 |
SWT.WRAP); |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
109 | 107 |
checkbox_published = formFactory.createCheckbox(formElement, |
110 | 108 |
"Published", taxon.isPublish(), style); |
111 |
|
|
112 |
|
|
109 |
|
|
110 |
|
|
113 | 111 |
secReference = formFactory.createSelectionElement(Reference.class, |
114 | 112 |
getConversationHolder(), formElement, "Misappl. Sec.", |
115 | 113 |
entity.getCitation(), EntitySelectionElement.ALL, |
116 | 114 |
style); |
117 |
|
|
115 |
|
|
118 | 116 |
text_secundum_microreference = formFactory.createTextWithLabelElement( |
119 | 117 |
formElement, "Detail", |
120 | 118 |
entity.getCitationMicroReference(),null, |
... | ... | |
122 | 120 |
checkbox_doubtful = formFactory.createCheckbox(formElement, |
123 | 121 |
"Misappl. Doubtful", entity.isDoubtful(), style); |
124 | 122 |
} |
125 |
|
|
123 |
|
|
126 | 124 |
} |
127 |
|
|
125 |
|
|
128 | 126 |
private Taxon getRelatedTaxon() { |
129 | 127 |
return TaxonRelationshipTypeInverseContainer.RelatedTaxon(getSourceTaxon(), getEntity()); |
130 | 128 |
} |
... | ... | |
132 | 130 |
private TaxonRelationshipTypeInverseContainer getTaxonRelationshipTypeInverseContainer(){ |
133 | 131 |
return TaxonRelationshipTypeInverseContainer.CreateFromSource(getSourceTaxon(), getEntity()); |
134 | 132 |
} |
135 |
|
|
133 |
|
|
136 | 134 |
private Taxon getSourceTaxon(){ |
137 |
IEditorInput editorInput = StoreUtil.getActiveEditorInput(); |
|
138 |
return (Taxon) editorInput.getAdapter(Taxon.class); |
|
135 |
IEditorInput input = StoreUtil.getActiveEditorInput(); |
|
136 |
if(input!=null){ |
|
137 |
return input.getAdapter(Taxon.class); |
|
138 |
} |
|
139 |
return EventUtility.getCurrentTaxon(); |
|
139 | 140 |
} |
140 | 141 |
|
141 | 142 |
@Override |
... | ... | |
170 | 171 |
}else if(eventSource==checkBoxDoubtful){ |
171 | 172 |
getEntity().setDoubtful(checkBoxDoubtful.getSelection()); |
172 | 173 |
} |
173 |
}
|
|
174 |
} |
|
174 | 175 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
175 | 176 |
} |
176 |
|
|
177 |
|
|
177 | 178 |
protected void handleToggleableCacheField() { |
178 | 179 |
boolean pushedState = toggleable_cache.getState(); |
179 | 180 |
|
... | ... | |
181 | 182 |
setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
182 | 183 |
updateToggleableCacheField(); |
183 | 184 |
} |
184 |
|
|
185 |
|
|
185 | 186 |
public void updateToggleableCacheField() { |
186 | 187 |
if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
187 | 188 |
if (toggleable_cache != null){ |
... | ... | |
191 | 192 |
} |
192 | 193 |
} |
193 | 194 |
} |
194 |
|
|
195 |
|
|
195 | 196 |
@Override |
196 | 197 |
protected void updateContent() { |
197 | 198 |
super.updateContent(); |
198 | 199 |
if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
199 |
|
|
200 |
|
|
200 | 201 |
toggleable_cache.setEnabled(taxon.isProtectedTitleCache()); |
201 | 202 |
setIrrelevant(toggleable_cache.getState(), |
202 | 203 |
Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
... | ... | |
205 | 206 |
@Override |
206 | 207 |
protected void updateControlStates() { |
207 | 208 |
super.updateControlStates(); |
208 |
|
|
209 |
|
|
209 | 210 |
} |
210 | 211 |
@Override |
211 | 212 |
protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) { |
... | ... | |
215 | 216 |
super.handleTitleCacheRelevantChange(event); |
216 | 217 |
} |
217 | 218 |
} |
218 |
|
|
219 |
|
|
219 | 220 |
@Override |
220 | 221 |
public void refresh(){ |
221 | 222 |
updateContent(); |
222 | 223 |
updateToggleableCacheField(); |
223 | 224 |
} |
224 | 225 |
|
225 |
|
|
226 |
|
|
227 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
228 | 229 |
} |
Also available in: Unified diff
ref #6595 Evaluate current taxon in taxon relationship detail element