Revision 20b57c9c
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 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.section.taxon; |
10 | 10 |
|
11 |
import java.util.Arrays; |
|
12 |
|
|
13 | 11 |
import org.eclipse.jface.util.PropertyChangeEvent; |
14 | 12 |
import org.eclipse.swt.SWT; |
15 | 13 |
import org.eclipse.ui.IEditorInput; |
16 |
import org.eclipse.ui.forms.widgets.ExpandableComposite; |
|
17 | 14 |
|
18 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
19 | 15 |
import eu.etaxonomy.cdm.model.reference.Reference; |
20 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
21 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
22 | 16 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
23 | 17 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
24 | 18 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
... | ... | |
29 | 23 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
30 | 24 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
31 | 25 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
32 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
|
33 | 26 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
34 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
|
35 | 27 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
36 | 28 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
37 | 29 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
... | ... | |
45 | 37 |
public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<TaxonRelationship> { |
46 | 38 |
|
47 | 39 |
private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType; |
48 |
|
|
40 |
|
|
49 | 41 |
private EntitySelectionElement<Taxon> selection_relatedTaxon; |
50 | 42 |
private CheckboxElement checkBoxDoubtful; |
51 | 43 |
protected ToggleableTextElement toggleable_cache; |
52 | 44 |
private EntitySelectionElement<Reference> secReference; |
53 | 45 |
private EntitySelectionElement<Reference> sensuReference; |
54 | 46 |
private TextWithLabelElement text_sensu_microreference; |
55 |
|
|
47 |
|
|
56 | 48 |
|
57 | 49 |
private TextWithLabelElement text_secundum_microreference; |
58 | 50 |
|
59 | 51 |
private TextWithLabelElement text_appendedPhrase; |
60 | 52 |
private TaxonDetailSection taxonElement; |
61 |
|
|
62 | 53 |
|
63 | 54 |
|
64 |
private Taxon taxon; |
|
55 |
|
|
56 |
private Taxon taxon; |
|
65 | 57 |
|
66 | 58 |
public TaxonRelationshipDetailElement(CdmFormFactory formFactory, |
67 | 59 |
ICdmFormElement formElement) { |
68 | 60 |
super(formFactory, formElement); |
69 |
|
|
70 |
|
|
61 |
|
|
62 |
|
|
71 | 63 |
} |
72 | 64 |
|
73 | 65 |
@Override |
... | ... | |
75 | 67 |
TaxonRelationship entity, int style) { |
76 | 68 |
if (!entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
77 | 69 |
combo_taxonRelationshipType = formFactory.createTermComboElement( |
78 |
TaxonRelationshipTypeInverseContainer.class,
|
|
79 |
formElement, "Relationship Type",
|
|
70 |
TaxonRelationshipTypeInverseContainer.class, |
|
71 |
formElement, "Relationship Type", |
|
80 | 72 |
getTaxonRelationshipTypeInverseContainer(), style); |
81 | 73 |
combo_taxonRelationshipType.setEnabled(false); |
82 | 74 |
selection_relatedTaxon = formFactory.createSelectionElement( |
83 |
Taxon.class, getConversationHolder(),
|
|
84 |
formElement, "Related Taxon", getRelatedTaxon(),
|
|
75 |
Taxon.class, getConversationHolder(), |
|
76 |
formElement, "Related Taxon", getRelatedTaxon(), |
|
85 | 77 |
EntitySelectionElement.SELECTABLE, style); |
86 | 78 |
checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style); |
87 | 79 |
}else{ |
... | ... | |
90 | 82 |
taxonElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
91 | 83 |
addControl(taxonElement); |
92 | 84 |
addElement(taxonElement); |
93 |
|
|
85 |
|
|
94 | 86 |
sensuReference = formFactory.createSelectionElement(Reference.class, |
95 | 87 |
getConversationHolder(), formElement, "Sensu", |
96 | 88 |
taxon.getSec(), EntitySelectionElement.ALL, |
97 | 89 |
style); |
98 |
|
|
90 |
|
|
99 | 91 |
text_sensu_microreference = formFactory.createTextWithLabelElement( |
100 | 92 |
formElement, "Detail", |
101 | 93 |
taxon.getSecMicroReference(),null, |
102 | 94 |
SWT.WRAP); |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
109 | 101 |
secReference = formFactory.createSelectionElement(Reference.class, |
110 | 102 |
getConversationHolder(), formElement, "Misappl. Sec.", |
111 | 103 |
entity.getCitation(), EntitySelectionElement.ALL, |
112 | 104 |
style); |
113 |
|
|
105 |
|
|
114 | 106 |
text_secundum_microreference = formFactory.createTextWithLabelElement( |
115 | 107 |
formElement, "Detail", |
116 | 108 |
entity.getCitationMicroReference(),null, |
117 | 109 |
SWT.WRAP); |
118 |
|
|
110 |
|
|
119 | 111 |
} |
120 |
|
|
112 |
|
|
121 | 113 |
} |
122 |
|
|
114 |
|
|
123 | 115 |
private Taxon getRelatedTaxon() { |
124 | 116 |
return TaxonRelationshipTypeInverseContainer.RelatedTaxon(getSourceTaxon(), getEntity()); |
125 | 117 |
} |
... | ... | |
127 | 119 |
private TaxonRelationshipTypeInverseContainer getTaxonRelationshipTypeInverseContainer(){ |
128 | 120 |
return TaxonRelationshipTypeInverseContainer.CreateFromSource(getSourceTaxon(), getEntity()); |
129 | 121 |
} |
130 |
|
|
122 |
|
|
131 | 123 |
private Taxon getSourceTaxon(){ |
132 | 124 |
IEditorInput editorInput = StoreUtil.getActiveEditorInput(); |
133 |
return (Taxon) editorInput.getAdapter(Taxon.class); |
|
125 |
if(editorInput!=null){ |
|
126 |
return editorInput.getAdapter(Taxon.class); |
|
127 |
} |
|
128 |
return null; |
|
134 | 129 |
} |
135 | 130 |
|
136 | 131 |
@Override |
... | ... | |
157 | 152 |
}else if(eventSource==checkBoxDoubtful){ |
158 | 153 |
getEntity().setDoubtful(checkBoxDoubtful.getSelection()); |
159 | 154 |
} |
160 |
}
|
|
155 |
} |
|
161 | 156 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
162 | 157 |
} |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
167 | 162 |
@Override |
168 | 163 |
protected void updateControlStates() { |
169 | 164 |
super.updateControlStates(); |
170 |
|
|
165 |
|
|
171 | 166 |
} |
172 | 167 |
@Override |
173 | 168 |
protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) { |
... | ... | |
177 | 172 |
super.handleTitleCacheRelevantChange(event); |
178 | 173 |
} |
179 | 174 |
} |
180 |
|
|
175 |
|
|
181 | 176 |
@Override |
182 | 177 |
public void refresh(){ |
183 | 178 |
updateContent(); |
184 |
|
|
179 |
|
|
185 | 180 |
} |
186 | 181 |
|
187 | 182 |
@Override |
... | ... | |
190 | 185 |
if (taxonElement!=null) { |
191 | 186 |
taxonElement.setEntity(entity.getFromTaxon()); |
192 | 187 |
} |
193 |
|
|
188 |
|
|
194 | 189 |
} |
195 |
|
|
190 |
|
|
196 | 191 |
} |
Also available in: Unified diff
ref #6911 Fix potential NPE