Revision 836df5a3
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonDetailSection.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.ui.section.taxon; |
|
2 |
|
|
3 |
import org.eclipse.jface.viewers.ISelectionProvider; |
|
4 |
|
|
5 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
6 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
7 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
8 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
9 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
10 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
|
11 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
|
12 |
import eu.etaxonomy.taxeditor.ui.section.ICdmDetailElement; |
|
13 |
|
|
14 |
public class TaxonDetailSection extends AbstractCdmDetailSection<Taxon> { |
|
15 |
|
|
16 |
|
|
17 |
public TaxonDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { |
|
18 |
super(cdmFormFactory, conversation, parentElement, selectionProvider, style); |
|
19 |
} |
|
20 |
|
|
21 |
|
|
22 |
/** {@inheritDoc} */ |
|
23 |
@Override |
|
24 |
public String getHeading() { |
|
25 |
return getEntity() != null ? getEntity().getClass().getSimpleName() : "Taxon"; |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
protected AbstractCdmDetailElement<Taxon> createCdmDetailElement(AbstractCdmDetailSection<Taxon> parentElement, int style) { |
|
30 |
return formFactory.createTaxonOfRelationshipDetailElement(parentElement, style); |
|
31 |
} |
|
32 |
|
|
33 |
public void setTaxon(Taxon fromTaxon) { |
|
34 |
// TODO Auto-generated method stub |
|
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonOfRelationshipElement.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.ui.section.taxon; |
|
2 |
|
|
3 |
import java.util.Arrays; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Set; |
|
6 |
|
|
7 |
import org.eclipse.jface.util.IPropertyChangeListener; |
|
8 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
9 |
import org.eclipse.swt.SWT; |
|
10 |
import org.eclipse.swt.events.ModifyEvent; |
|
11 |
import org.eclipse.swt.events.ModifyListener; |
|
12 |
import org.eclipse.swt.graphics.Color; |
|
13 |
import org.eclipse.swt.widgets.Composite; |
|
14 |
import org.eclipse.swt.widgets.Control; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
17 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
18 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
|
20 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement; |
|
21 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
22 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
|
23 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
|
24 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
25 |
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement; |
|
26 |
import eu.etaxonomy.taxeditor.ui.element.IEntityElement; |
|
27 |
import eu.etaxonomy.taxeditor.ui.element.ISelectable; |
|
28 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
|
29 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
|
30 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
|
31 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
|
32 |
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement; |
|
33 |
|
|
34 |
public class TaxonOfRelationshipElement extends AbstractIdentifiableEntityDetailElement<Taxon>{ |
|
35 |
|
|
36 |
// private Taxon taxon; |
|
37 |
protected ToggleableTextElement toggleable_cache; |
|
38 |
private TextWithLabelElement text_appendedPhrase; |
|
39 |
private SelectionArbitrator selectionArbitrator; |
|
40 |
private CheckboxElement checkbox_doubtful; |
|
41 |
|
|
42 |
private CheckboxElement checkbox_published; |
|
43 |
|
|
44 |
public TaxonOfRelationshipElement(CdmFormFactory formFactory, ICdmFormElement formElement, int style ) { |
|
45 |
super(formFactory, formElement); |
|
46 |
// make this element selectable |
|
47 |
if(formFactory.getSelectionProvider() != null){ |
|
48 |
selectionArbitrator = formFactory.createSelectionArbitrator(this); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
protected void handleToggleableCacheField() { |
|
55 |
boolean pushedState = toggleable_cache.getState(); |
|
56 |
|
|
57 |
getEntity().setTitleCache(toggleable_cache.getText(), pushedState); |
|
58 |
setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
|
59 |
updateToggleableCacheField(); |
|
60 |
} |
|
61 |
|
|
62 |
public void updateToggleableCacheField() { |
|
63 |
|
|
64 |
if (toggleable_cache != null){ |
|
65 |
if (!getEntity().isProtectedTitleCache()) { |
|
66 |
toggleable_cache.setText(getEntity().generateTitle()); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void refresh(){ |
|
73 |
updateContent(); |
|
74 |
updateToggleableCacheField(); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
protected void updateContent() { |
|
79 |
super.updateContent(); |
|
80 |
toggleable_cache.setEnabled(getEntity().isProtectedTitleCache()); |
|
81 |
setIrrelevant(toggleable_cache.getState(), |
|
82 |
Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
@Override |
|
89 |
protected void createControls(ICdmFormElement formElement, Taxon entity, int style) { |
|
90 |
toggleable_cache = formFactory.createToggleableTextField(this, |
|
91 |
"Title Cache", getEntity().getTitleCache(), |
|
92 |
getEntity().isProtectedTitleCache(), style); |
|
93 |
|
|
94 |
text_appendedPhrase = formFactory.createTextWithLabelElement( |
|
95 |
this, "Appended Phrase", getEntity().getAppendedPhrase(), |
|
96 |
SWT.WRAP); |
|
97 |
|
|
98 |
checkbox_published = formFactory.createCheckbox(this, |
|
99 |
"Published", getEntity().isPublish(), style); |
|
100 |
|
|
101 |
checkbox_doubtful = formFactory.createCheckbox(this, |
|
102 |
"Misappl. Doubtful", getEntity().isDoubtful(), style); |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
@Override |
|
109 |
public void handleEvent(Object eventSource) { |
|
110 |
if (eventSource== toggleable_cache) { |
|
111 |
handleToggleableCacheField(); |
|
112 |
} else if (eventSource == checkbox_doubtful) { |
|
113 |
getEntity().setDoubtful(checkbox_doubtful.getSelection()); |
|
114 |
} else if (eventSource == text_appendedPhrase) { |
|
115 |
getEntity().setAppendedPhrase(text_appendedPhrase.getText()); |
|
116 |
} else if (eventSource == checkbox_published) { |
|
117 |
getEntity().setPublish(checkbox_published.getSelection()); |
|
118 |
} |
|
119 |
|
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java | ||
---|---|---|
13 | 13 |
import org.eclipse.jface.util.PropertyChangeEvent; |
14 | 14 |
import org.eclipse.swt.SWT; |
15 | 15 |
import org.eclipse.ui.IEditorInput; |
16 |
import org.eclipse.ui.forms.widgets.ExpandableComposite; |
|
16 | 17 |
|
18 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
17 | 19 |
import eu.etaxonomy.cdm.model.reference.Reference; |
18 | 20 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
19 | 21 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
... | ... | |
28 | 30 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
29 | 31 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
30 | 32 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
33 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
31 | 34 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
32 | 35 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
33 | 36 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
... | ... | |
45 | 48 |
|
46 | 49 |
private EntitySelectionElement<Taxon> selection_relatedTaxon; |
47 | 50 |
private CheckboxElement checkBoxDoubtful; |
48 |
protected ToggleableTextElement toggleable_cache;
|
|
51 |
protected ToggleableTextElement toggleable_cache; |
|
49 | 52 |
private EntitySelectionElement<Reference> secReference; |
50 | 53 |
private EntitySelectionElement<Reference> sensuReference; |
51 | 54 |
private TextWithLabelElement text_sensu_microreference; |
52 |
private CheckboxElement checkbox_doubtful; |
|
55 |
|
|
53 | 56 |
|
54 | 57 |
private TextWithLabelElement text_secundum_microreference; |
55 | 58 |
|
56 | 59 |
private TextWithLabelElement text_appendedPhrase; |
57 |
|
|
58 |
private CheckboxElement checkbox_published; |
|
59 |
|
|
60 |
private SelectionArbitrator selectionArbitrator; |
|
60 |
private TaxonDetailSection taxonElement; |
|
61 | 61 |
|
62 | 62 |
|
63 |
|
|
63 | 64 |
private Taxon taxon; |
64 | 65 |
|
65 | 66 |
public TaxonRelationshipDetailElement(CdmFormFactory formFactory, |
66 | 67 |
ICdmFormElement formElement) { |
67 | 68 |
super(formFactory, formElement); |
68 | 69 |
|
70 |
|
|
69 | 71 |
} |
70 | 72 |
|
71 | 73 |
@Override |
... | ... | |
84 | 86 |
checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style); |
85 | 87 |
}else{ |
86 | 88 |
taxon = entity.getFromTaxon(); |
87 |
toggleable_cache = formFactory.createToggleableTextField(formElement, |
|
88 |
"Title Cache", taxon.getTitleCache(), |
|
89 |
taxon.isProtectedTitleCache(), style); |
|
90 |
|
|
91 |
text_appendedPhrase = formFactory.createTextWithLabelElement( |
|
92 |
formElement, "Appended Phrase", taxon.getAppendedPhrase(), |
|
93 |
SWT.WRAP); |
|
94 |
|
|
95 |
|
|
89 |
taxonElement = formFactory.createTaxonDetailSection(getConversationHolder(), formElement, null, style); |
|
90 |
taxonElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
91 |
addControl(taxonElement); |
|
92 |
addElement(taxonElement); |
|
93 |
|
|
96 | 94 |
sensuReference = formFactory.createSelectionElement(Reference.class, |
97 | 95 |
getConversationHolder(), formElement, "Sensu", |
98 | 96 |
taxon.getSec(), EntitySelectionElement.ALL, |
... | ... | |
106 | 104 |
|
107 | 105 |
|
108 | 106 |
|
109 |
checkbox_published = formFactory.createCheckbox(formElement, |
|
110 |
"Published", taxon.isPublish(), style); |
|
111 |
|
|
107 |
|
|
112 | 108 |
|
113 | 109 |
secReference = formFactory.createSelectionElement(Reference.class, |
114 | 110 |
getConversationHolder(), formElement, "Misappl. Sec.", |
... | ... | |
119 | 115 |
formElement, "Detail", |
120 | 116 |
entity.getCitationMicroReference(),null, |
121 | 117 |
SWT.WRAP); |
122 |
checkbox_doubtful = formFactory.createCheckbox(formElement, |
|
123 |
"Misappl. Doubtful", entity.isDoubtful(), style); |
|
118 |
|
|
124 | 119 |
} |
125 | 120 |
|
126 | 121 |
} |
... | ... | |
141 | 136 |
@Override |
142 | 137 |
public void handleEvent(Object eventSource) { |
143 | 138 |
if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
144 |
if (eventSource== toggleable_cache) { |
|
145 |
handleToggleableCacheField(); |
|
146 |
} else if (eventSource == checkbox_doubtful) { |
|
147 |
taxon.setDoubtful(checkbox_doubtful.getSelection()); |
|
148 |
} else if (eventSource == secReference) { |
|
139 |
if (eventSource == secReference) { |
|
149 | 140 |
getEntity().setCitation(secReference.getSelection()); |
150 |
} else if (eventSource == text_appendedPhrase) { |
|
151 |
taxon.setAppendedPhrase(text_appendedPhrase.getText()); |
|
152 | 141 |
} else if (eventSource == text_secundum_microreference) { |
153 | 142 |
getEntity().setCitationMicroReference(text_secundum_microreference.getText()); |
154 |
} else if (eventSource == checkbox_published) { |
|
155 |
taxon.setPublish(checkbox_published.getSelection()); |
|
156 |
} else if (eventSource == text_sensu_microreference) { |
|
143 |
} else if (eventSource == text_sensu_microreference) { |
|
157 | 144 |
taxon.setSecMicroReference(text_sensu_microreference.getText()); |
158 | 145 |
}else if (eventSource == sensuReference) { |
159 | 146 |
taxon.setSec(sensuReference.getSelection()); |
... | ... | |
174 | 161 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null)); |
175 | 162 |
} |
176 | 163 |
|
177 |
protected void handleToggleableCacheField() { |
|
178 |
boolean pushedState = toggleable_cache.getState(); |
|
179 |
|
|
180 |
taxon.setTitleCache(toggleable_cache.getText(), pushedState); |
|
181 |
setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
|
182 |
updateToggleableCacheField(); |
|
183 |
} |
|
184 | 164 |
|
185 |
public void updateToggleableCacheField() { |
|
186 |
if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
|
187 |
if (toggleable_cache != null){ |
|
188 |
if (!taxon.isProtectedTitleCache()) { |
|
189 |
toggleable_cache.setText(taxon.generateTitle()); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 | 165 |
|
195 |
@Override |
|
196 |
protected void updateContent() { |
|
197 |
super.updateContent(); |
|
198 |
if (getEntity().getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){ |
|
199 |
|
|
200 |
toggleable_cache.setEnabled(taxon.isProtectedTitleCache()); |
|
201 |
setIrrelevant(toggleable_cache.getState(), |
|
202 |
Arrays.asList(new Object[] { toggleable_cache, checkbox_published})); |
|
203 |
} |
|
204 |
} |
|
166 |
|
|
205 | 167 |
@Override |
206 | 168 |
protected void updateControlStates() { |
207 | 169 |
super.updateControlStates(); |
... | ... | |
219 | 181 |
@Override |
220 | 182 |
public void refresh(){ |
221 | 183 |
updateContent(); |
222 |
updateToggleableCacheField(); |
|
184 |
|
|
223 | 185 |
} |
224 | 186 |
|
187 |
@Override |
|
188 |
public void setEntity(TaxonRelationship entity) { |
|
189 |
super.setEntity(entity); |
|
190 |
if (taxonElement!=null) { |
|
191 |
taxonElement.setEntity(entity.getFromTaxon()); |
|
192 |
} |
|
225 | 193 |
|
226 |
|
|
194 |
} |
|
227 | 195 |
|
228 | 196 |
} |
Also available in: Unified diff
ref #6789: taxon of misapplied name is now clickable and supplemental data enabled